Skip to content

Instantly share code, notes, and snippets.

@inuvalogic
Last active February 17, 2018 11:30
Show Gist options
  • Save inuvalogic/8956048333975ffd63fe13e9520574f0 to your computer and use it in GitHub Desktop.
Save inuvalogic/8956048333975ffd63fe13e9520574f0 to your computer and use it in GitHub Desktop.
<?php
case 'add':
$web->breadcumbs->add('?content=sub_account','Sub Account');
$web->breadcumbs->add('current','Add');
echo BACKLINK;
if ( (isset($_POST['ppost'])) && ($_POST['ppost']==MENU_ADD) )
{
if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['phone']) && !empty($_POST['alamat']) && !empty($_POST['id_provinsi']) && !empty($_POST['id_kota']) && !empty($_POST['status']))
{
unset($_POST['ppost']);
$_POST['action'] = 'insert';
$_POST['table'] = 'user';
$_POST['password'] = $web->encrypt_password($_POST['password']);
$_POST['register_date'] = 'NOW()';
$id_user = $web->db2->auto_save();
unset($_POST);
$_POST['id_user'] = $id_user;
$_POST['id_user_utama'] = $_SESSION['logid'];
$_POST['action'] = 'insert';
$_POST['table'] = 'sub_account';
$web->db2->auto_save();
$web->gotopage(THISFILE);
} else { echo ERROR_NULL; }
}
$this->forms
->form_header('Add Sub Account')
->add('name', 'text', array('required' => true))
->add('email', 'text', array('required' => true))
->add('password', 'password', array('required' => true))
->add('phone', 'text', array('required' => true))
->add('alamat', 'textarea', array('required' => true))
->add('id_provinsi', 'relation', array(
'required' => true,
'table' => 'provinsi',
'primary_column' => 'id',
'display_column' => 'nama_provinsi',
'params' => array('class' => 'select2')
))
->add('id_kota', 'relation', array(
'required' => true,
'table' => 'kota',
'primary_column' => 'id',
'display_column' => 'nama_kota',
'params' => array('class' => 'select2')
))
->add('user_level', 'select', array('select_data' => array('admin' => 'Admin', 'staff' => 'Staff'), 'required' => true))
->add('status', 'select', array('select_data' => array('valid' => 'Active', 'invalid' => 'Suspend'), 'required' => true))
->renderForm(MENU_ADD);
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment