/** * This function will use to display all user list * * @access public * @return render view */ public function userinfo() { $session = $this->session->userdata('admin_id'); if (empty($session)) { redirect(site_url('login'), 'refresh'); } $login_type = $this->session->userdata('type'); $this->load->helper('xcrud'); Xcrud_config::$dbname = 'iwmf_user'; $xcruduser = Xcrud::get_instance(); $xcruduser->table('users'); $xcruduser->subselect('Name', "CONCAT_WS(' ',firstname,lastname)"); $xcruduser->columns('Name,checkin_count,alert_count, language, phone, jobtitle,created_on,status,last_checkin_time,checkin_status'); $xcruduser->change_type('checkin_status', 'select', '', array('values' => array('0' => 'Pending', '1' => 'Started', '2' => 'Confirmed', '3' => 'Deleted', '4' => 'Closed', '5' => 'Missed'))); $xcruduser->where('delete', 0); $xcruduser->column_name('jobtitle', 'Title'); $xcruduser->column_name('created_on', 'Join Date'); $xcruduser->column_name('alert_count', '# Alerts'); $xcruduser->column_name('checkin_count', '# Check-Ins'); $xcruduser->column_name('last_checkin_time', 'Last Check-in'); $xcruduser->column_name('checkin_status', 'Check-in Status'); $xcruduser->change_type('status', 'select', '', array('values' => array('-1' => 'Locked', '0' => 'Inactive', '1' => 'Active'))); /*view user link for normal admin*/ if ($login_type == 1) { $url = site_url('userinfo/userinfo/viewuser/{id}'); } else { /*Edit user link for supper admin*/ $url = site_url('userinfo/userinfo/index/{id}'); } $xcruduser->column_pattern('Name', '<a href=' . $url . ' class="" data-task="" data-primary="{id}">{Name}</a>'); $xcruduser->change_type('status', 'select', '', array('values' => array('-1' => 'Locked', '0' => 'Inactive', '1' => 'Active'))); $xcruduser->change_type('type', 'select', '', array('values' => array('1' => 'Admin', '2' => 'User'))); $xcruduser->change_type('Check-in Status', 'select', '', array('values' => array('0' => 'Pending', '1' => 'Started', '2' => 'Confirmed', '3' => 'Deleted', '4' => 'Closed', '5' => 'Missed'))); $xcruduser->search_columns('Name,language,jobtitle,status', 'Name'); $xcruduser->unset_edit(); $xcruduser->unset_add(); $xcruduser->unset_view(); $xcruduser->unset_title(); $xcruduser->unset_print(); $xcruduser->unset_remove(); if ($login_type == 1) { $xcruduser->button(site_url('userinfo/userinfo/viewuser/{id}'), 'EDIT', 'glyphicon glyphicon-eye-open'); } else { $xcruduser->button(site_url('userinfo/userinfo/index/{id}'), 'EDIT', 'glyphicon glyphicon-pencil'); $xcruduser->button('{id}', 'Delete', 'glyphicon glyphicon-trash', 'ref', '', array('type', '!=', 3)); } $data['content'] = $xcruduser->render(); $this->load->view('home', $data); }
function update_price() { //mengupdate field lpb_detail yang belum memiliki price HANYA UNTUK PR (cukup dijalankan sekali) Xcrud_config::$dbname = 'bcspurchase_2015'; Xcrud_config::$dbuser = '******'; Xcrud_config::$dbpass = '******'; Xcrud_config::$dbhost = '10.2.2.32'; $db = Xcrud_db::get_instance(); $select = "select lpb_id from lpb_detail"; $db->query($select); $arr = $db->result(); $count = 0; //die("Arr :".$arr[0]['lpb_id']); foreach ($arr as $ar) { foreach ($ar as $a) { $count++; } } for ($x = 0; $x < $count; $x++) { $query = "select po_item_id from lpb_detail where lpb_id='" . $arr[$x]['lpb_id'] . "'"; $db->query($query); $po_item_id = $db->row()['po_item_id']; //die("po item id : ".$po_item_id); if ($po_item_id != '') { $query2 = "select price from po_item where po_item_id='{$po_item_id}'"; $db->query($query2); $price = $db->row()['price']; //die("material id : ".$material_id); $query3 = "update lpb_detail set price='{$price}' where lpb_id='" . $arr[$x]['lpb_id'] . "'"; $db->query($query3); } } die; }
public static function get_requested_instance() { if (stripos($_POST['xcrud']['column'], 'users.') !== FALSE) { Xcrud_config::$dbname = 'iwmf_user'; } if (isset($_POST['xcrud']['instance']) && isset($_POST['xcrud']['key']) && isset($_POST['xcrud']['task'])) { static::init_prepare('post'); $key = $_POST['xcrud']['key'] ? $_POST['xcrud']['key'] : static::error('Security key cannot be empty'); $inst_name = $_POST['xcrud']['instance'] ? $_POST['xcrud']['instance'] : static::error('Instance name cannot be empty'); $is_get = false; } elseif (isset($_GET['xcrud']['instance']) && isset($_GET['xcrud']['key']) && isset($_GET['xcrud']['task']) && $_GET['xcrud']['task'] == 'file') { static::init_prepare('get'); $key = $_GET['xcrud']['key'] ? $_GET['xcrud']['key'] : static::error('Security key cannot be empty'); $inst_name = $_GET['xcrud']['instance'] ? $_GET['xcrud']['instance'] : static::error('Instance name cannot be empty'); $is_get = true; } else { static::error('Wrong request!'); } if (isset($_SESSION['xcrud_session'][$inst_name]['key']) && $_SESSION['xcrud_session'][$inst_name]['key'] == $key) { static::$instance[$inst_name] = new self(); static::$instance[$inst_name]->is_get = $is_get; static::$instance[$inst_name]->ajax_request = true; static::$instance[$inst_name]->instance_name = $inst_name; static::$instance[$inst_name]->import_vars($key); static::$instance[$inst_name]->inner_where(); return static::$instance[$inst_name]->render(); } else { static::error('<strong>The verification key is out of date</strong><br /> This means that your browser cached a previous version of this page with an old key (for security reasons the verification key is generated every request)<br /> Why? Maybe you pressed the back button in your browser or opened a bookmark from last session. <br /><strong>Just reload the page, nothing happened :)</strong>'); } }
function update_balance($postdata, $xcrud) { Xcrud_config::$dbname = 'bcspurchase_2015'; Xcrud_config::$dbuser = '******'; Xcrud_config::$dbpass = ''; Xcrud_config::$dbhost = 'localhost'; $db = Xcrud_db::get_instance(); //$db->query("INSERT INTO test(test) values ('".$postdata->get('po_item_id')."')"); $qty_lpb = $postdata->get('qty'); $po_item_id = $postdata->get('po_item_id'); $unit = $postdata->get('unit'); $a = 'select po_item.qty from po_item where po_item_id="' . $po_item_id . '"'; $db->query($a); $qty_po = $db->row()['qty']; $balance = $qty_po - $qty_lpb; $query = $db->query("UPDATE po_item SET lpb_balance ='" . $balance . "' WHERE po_item_id ='" . $po_item_id . "'"); $db->query($query); }
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include '../inc/commons.php'; include BASE_URL . 'xcrud/xcrud.php'; if (!function_exists('xcrud_get_instance')) { function xcrud_get_instance($name = true) { return Xcrud::get_instance($name); } } Xcrud_config::$dbname = 'shop'; Xcrud_config::$dbuser = '******'; Xcrud_config::$dbpass = '******'; Xcrud_config::$dbhost = 'localhost'; $db = Xcrud_db::get_instance('shop'); $exec = $db->query("SELECT counter from counter"); $array = $db->result(); $counter = $array[0]['counter']; $exec = $db->query("SELECT count(*),country from visitors group by country order by count(*) desc"); $array = $db->result(); $country = $array[0]['country']; $exec = $db->query("SELECT count(*) as items from items"); $array = $db->result(); $items = $array[0]['items']; $exec = $db->query("SELECT count(*) as count_category from (select distinct category from items group by category) as tbl1"); $array = $db->result(); $category = $array[0]['count_category']; $exec = $db->query("SELECT count(*) as new from (select * from items where date_created+INTERVAL 1 WEEK > NOW()) as tbl1"); $array = $db->result();