/** * read * controler for get all items */ public static function read($args = array()) { // Security check if (!wbSecurity::check('p_vat_type_dtl')) { return; } // Get arguments from argument array extract($args); $start = wbRequest::getVarClean('start', 'int', 0); $limit = wbRequest::getVarClean('limit', 'int', 50); $sort = wbRequest::getVarClean('sort', 'str', 'p_vat_type_dtl_id'); $dir = wbRequest::getVarClean('dir', 'str', 'ASC'); $query = wbRequest::getVarClean('query', 'str', ''); $p_vat_type_dtl_id = wbRequest::getVarClean('p_vat_type_dtl_id', 'int', 0); $p_vat_type_id = wbRequest::getVarClean('p_vat_type_id', 'int', 0); $code = wbRequest::getVarClean('code', 'str', ''); $vat_code = wbRequest::getVarClean('vat_code', 'str', ''); $description = wbRequest::getVarClean('description', 'str', ''); $vat_pct = wbRequest::getVarClean('vat_pct', 'float', 0); $searchHotel = wbRequest::getVarClean('searchHotel', 'str', ''); $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); try { $table =& wbModule::getModel('bds', 'p_vat_type_dtl'); //Set default criteria. You can override this if you want foreach ($table->fields as $key => $field) { if (!empty(${$key})) { // <-- Perhatikan simbol $$ if ($field['type'] == 'str') { $table->setCriteria($table->getAlias() . $key . $table->likeOperator . '?', array(${$key})); } else { $table->setCriteria($table->getAlias() . $key . ' = ?', array(${$key})); } } } if (!empty($searchHotel)) { $table->setCriteria('(code ILIKE ? OR hotel_name ILIKE ?)', array('%' . $searchHotel . '%', '%' . $searchHotel . '%')); } $query = $table->getDisplayFieldCriteria($query); if (!empty($query)) { $table->setCriteria($query); } $items = $table->getAll($start, $limit, $sort, $dir); $total = $table->countAll(); $data['items'] = $items; $data['total'] = $total; $data['success'] = true; } catch (Exception $e) { $data['message'] = $e->getMessage(); } return $data; }
/** * update * controler for remove item */ public static function destroy($args = array()) { // Security check if (!wbSecurity::check('PWilayahPerson')) { return; } // Get arguments from argument array extract($args); $jsonItems = wbRequest::getVarClean('items', 'str', ''); $items =& wbUtil::jsonDecode($jsonItems); $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); $table =& wbModule::getModel('bds', 'p_wilayah_person'); try { $table->dbconn->BeginTrans(); if (is_array($items)) { foreach ($items as $key => $value) { if (empty($value)) { throw new Exception('Empty parameter'); } $table->remove($value); $data['items'][] = array($table->pkey => $value); $data['total']++; } } else { $items = (int) $items; if (empty($items)) { throw new Exception('Empty parameter'); } $table->remove($items); $data['items'][] = array($table->pkey => $items); $data['total'] = 1; } $data['success'] = true; $data['message'] = $data['total'] . ' Data berhasil dihapus'; $table->dbconn->CommitTrans(); } catch (Exception $e) { $table->dbconn->RollbackTrans(); $data['message'] = $e->getMessage(); $data['items'] = array(); $data['total'] = 0; } return $data; }
public static function updateInfo($args = array()) { // Security check wbSecurity::check('User', ACCESS_EDIT); // Get arguments from argument array extract($args); $user_password1 = trim(wbRequest::getVarClean('user_password1', 'str', '')); $user_password2 = trim(wbRequest::getVarClean('user_password2', 'str', '')); $user_email = trim(wbRequest::getVarClean('user_email', 'str', '')); $mobile_no = trim(wbRequest::getVarClean('mobile_no', 'str', '')); $user_realname = trim(wbRequest::getVarClean('user_realname', 'str', '')); $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); $sessionInfo = wbUser::getSession(); $uid = $sessionInfo['user_id']; try { if (empty($uid)) { throw new Exception('Bad Params : Empty UserID'); } $table =& wbModule::getModel('base', 'roles.p_app_user'); $table->actionType = 'UPDATE'; $record = array('p_app_user_id' => $uid, 'email_address' => $user_email, 'full_name' => $user_realname); if (!empty($user_password1)) { if (strcmp($user_password1, $user_password2) != 0) { throw new Exception("Password tidak sama. Mohon periksa kembali"); } if (strlen($user_password1) < 5) { throw new Exception("Panjang password minimal 5 karakter"); } $record['user_pwd'] = $user_password1; } $table->setRecord($record); $table->update(); $sql = "update t_cust_account a\n\t\t\t\t\tset a.mobile_no = '" . $mobile_no . "'\n\t\t\t\t\twhere t_customer_id = (select t_customer_id from t_customer_user where p_app_user_id = " . $uid . ")"; $data['items'] = $table->dbconn->GetItem($sql); $data['success'] = true; $data['message'] = 'Data berhasil di-update'; } catch (Exception $e) { $data['message'] = $e->getMessage(); } return $data; }
public static function execReject($args = array()) { // Security check if (!wbSecurity::check('Inquiry')) { return; } // Get arguments from argument array extract($args); $start = wbRequest::getVarClean('start', 'int', 0); $limit = wbRequest::getVarClean('limit', 'int', 50); $sort = wbRequest::getVarClean('sort', 'str', 'listing_no'); $dir = wbRequest::getVarClean('dir', 'str', 'ASC'); $query = wbRequest::getVarClean('query', 'str', ''); $no_registration = wbRequest::getVarClean('no_registration', 'int', 0); $getAll = wbRequest::getVarClean('getAll', 'str', ''); $jsonItems = wbRequest::getVarClean('items', 'str', ''); $arrItems = (array) json_decode($jsonItems); $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); try { $db = NewADOConnection("oci8"); $ora_tns = wbConfig::get('DB.ora_tns'); $ora_user = wbConfig::get('DB.ora_user'); $ora_pass = wbConfig::get('DB.ora_pass'); $db->Connect($ora_tns, $ora_user, $ora_pass); $stmt = $db->PrepareSP("BEGIN\r\n p_exec_reject_websrvc(:i_receipt_no,\r\n :in_payment_receipt_id,\r\n :i_kode_bank,\r\n :i_branch_id,\r\n :i_user_id,\r\n :i_user_name,\r\n :i_id_pelanggan,\r\n :i_nama,\r\n :i_jml_bill,\r\n :i_jml_adm,\r\n :on_t_cancel_receipt_id,\r\n :on_return_code,\r\n :os_cancel_info\r\n );\r\n END;\r\n "); $i_kode_bank = wbSession::getVar('bank_name'); $branch_id = wbSession::getVar('branch_id'); $user_id = wbSession::getVar('user_id'); $user_name = wbSession::getVar('user_name'); $in_payment_receipt_id = $arrItems['T_RECEIPT_ID']; $i_receipt_no = $arrItems['RECEIPT_NO']; $i_id_pelanggan = $arrItems['ID_PELANGGAN']; $i_nama = $arrItems['ACC_LAST_NAME']; $i_jml_bill = $arrItems['BILL_AMOUNT']; $i_jml_adm = $arrItems['ADMIN_AMOUNT']; $db->InParameter($stmt, $i_kode_bank, 'i_kode_bank', 4000); $db->InParameter($stmt, $branch_id, 'i_branch_id', 4000); $db->InParameter($stmt, $user_id, 'i_user_id', 4000); $db->InParameter($stmt, $user_name, 'i_user_name', 4000); $db->InParameter($stmt, $in_payment_receipt_id, 'in_payment_receipt_id', 4000); $db->InParameter($stmt, $i_receipt_no, 'i_receipt_no', 4000); $db->InParameter($stmt, $i_id_pelanggan, 'i_id_pelanggan', 4000); $db->InParameter($stmt, $i_nama, 'i_nama', 4000); $db->InParameter($stmt, $i_jml_adm, 'i_jml_adm', 4000); $db->InParameter($stmt, $i_jml_bill, 'i_jml_bill', 4000); $db->OutParameter($stmt, $on_t_cancel_receipt_id, 'on_t_cancel_receipt_id', 4000); $db->OutParameter($stmt, $on_return_code, 'on_return_code', 4000); $db->OutParameter($stmt, $os_return_msg, 'os_cancel_info', 4000); $ok = $db->Execute($stmt); //exit; } catch (Exception $e) { $data['message'] = $e->getMessage(); $data['success'] = false; } $data['items'] = array('on_return_code' => $on_return_code, 'os_cancel_info' => $os_return_msg, 'on_t_cancel_receipt_id' => $on_t_cancel_receipt_id); $data['total'] = 1; $data['success'] = true; $data['message'] = $os_return_msg; return $data; }
/** * create * controler for create new item */ public static function create($args = array()) { // Security check if (!wbSecurity::check('t_cust_account')) { return; } // Get arguments from argument array extract($args); $data = array('items' => array(), 'success' => false, 'message' => ''); $jsonItems = wbRequest::getVarClean('items', 'str', ''); $items =& wbUtil::jsonDecode($jsonItems); $t_cust_order_legal_doc_id = wbRequest::getVarClean('t_cust_order_legal_doc_id', 'int', 0); $t_customer_order_id = wbRequest::getVarClean('t_customer_order_id', 'int', 0); $p_legal_doc_type_id = wbRequest::getVarClean('p_legal_doc_type_id', 'str', ''); $legal_doc_desc = wbRequest::getVarClean('legal_doc_desc', 'str', ''); $origin_file_name = wbRequest::getVarClean('file_name', 'str', ''); $file_folder = wbRequest::getVarClean('file_folder', 'int', 0); $file_name = wbRequest::getVarClean('file_name', 'int', 0); $jsonItems = wbRequest::getVarClean('items', 'str', ''); if (!is_array($items)) { $data['message'] = 'Invalid items parameter'; return $data; } $table =& wbModule::getModel('bds', 't_cust_order_legal_doc'); $table->actionType = 'CREATE'; if (isset($items[0])) { $errors = array(); $numSaved = 0; $numItems = count($items); $savedItems = array(); for ($i = 0; $i < $numItems; $i++) { try { $table->dbconn->BeginTrans(); $items[$i][$table->pkey] = $table->GenID(); $table->setRecord($items[$i]); $table->create(); $numSaved++; $table->dbconn->CommitTrans(); } catch (Exception $e) { $table->dbconn->RollbackTrans(); $errors[] = $e->getMessage(); } $items[$i] = array_merge($items[$i], $table->record); } $numErrors = count($errors); if (count($errors)) { $data['message'] = $numErrors . " dari " . $numItems . " record gagal disimpan.<br/><br/><b>System Response:</b><br/>- " . implode("<br/>- ", $errors) . ""; } else { $data['success'] = true; $data['message'] = 'Data berhasil disimpan'; } $data['items'] = $items; } else { try { // begin transaction block $table->dbconn->BeginTrans(); // insert master $items[$table->pkey] = $table->dbconn->GetOne("select generate_id('sikp','t_cust_order_legal_doc','t_cust_order_legal_doc_id') from dual"); $items['description'] = $legal_doc_desc; $items['origin_file_name'] = $items['file_name']; $items['file_name'] = time() . $items['file_name']; $table->setRecord($items); $table->create(); // insert detail ///////////////////////////////////this is the magic for upload//////////////////////////////////// $encoded = $_POST['uploaded']->file_name; $location = self::imurl() . $items[$table->pkey] . '_' . $items['file_name']; // Mention where to upload the file $current = @file_get_contents($location); // Get the file content. This will create an empty file if the file does not exist $current = base64_decode($encoded); // Now decode the content which was sent by the client file_put_contents($location, $current); // Write the decoded content in the file mentioned at particular location /////////////////////////////////////////////////////////////////////////////////////////////////// $data['success'] = true; $data['message'] = 'Data berhasil disimpan'; $data['items'] = $table->get($items[$table->pkey]); // all ok, commit transaction $table->dbconn->CommitTrans(); } catch (Exception $e) { // something happen, rollback transaction $table->dbconn->RollbackTrans(); $data['message'] = $e->getMessage(); $data['items'] = $items; } } return $data; }
/** * update * controler for remove item */ public static function destroy($args = array()) { // Security check wbSecurity::check('PRoleMenu', ACCESS_DELETE); // Get arguments from argument array extract($args); $jsonItems = wbRequest::getVarClean('items', 'str', ''); $items =& wbUtil::jsonDecode($jsonItems); $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); $table =& wbModule::getModel('bds', 'p_role_menu'); try { $table->dbconn->BeginTrans(); if (is_array($items)) { foreach ($items as $key => $value) { if (empty($value)) { throw new Exception('Empty parameter'); } $keys = explode('.', $value); if (empty($keys[0]) || empty($keys[1])) { throw new Exception('Invalid Role Permission ID'); } $table->remove($keys[0], $keys[1]); $data['items'][] = array('p_role_menu_id' => $value); $data['total']++; } } else { if (empty($items)) { throw new Exception('Empty parameter'); } $keys = explode('.', $items); if (empty($keys[0]) || empty($keys[1])) { throw new Exception('Invalid Role Permission ID'); } $table->remove($keys[0], $keys[1]); $data['items'][] = array('p_role_menu_id' => $items); $data['total'] = 1; } $data['success'] = true; $data['message'] = $data['total'] . ' Data berhasil dihapus'; $table->dbconn->CommitTrans(); } catch (Exception $e) { $table->dbconn->RollbackTrans(); $data['message'] = $e->getMessage(); $data['items'] = array(); $data['total'] = 0; } return $data; }
public static function cancelPembayaran($args = array()) { // Security check //if (!wbSecurity::check('DHotel')) return; if (!wbSecurity::check('Inquiry')) { return; } // Get arguments from argument array extract($args); $start = wbRequest::getVarClean('start', 'int', 0); $limit = wbRequest::getVarClean('limit', 'int', 50); $sort = wbRequest::getVarClean('sort', 'str', 'listing_no'); $dir = wbRequest::getVarClean('dir', 'str', 'ASC'); $query = wbRequest::getVarClean('query', 'str', ''); $no_registration = wbRequest::getVarClean('no_registration', 'str', 0); $bphtb_amount = wbRequest::getVarClean('bphtb_amount', 'float', 0); $bit48 = wbRequest::getVarClean('bit48', 'str', 0); $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); $dbConnParams_rwnet = array('name' => wbConfig::get('DB.name_rwnet'), 'user' => wbConfig::get('DB.user_rwnet'), 'password' => wbConfig::get('DB.password_rwnet'), 'host' => wbConfig::get('DB.host_rwnet'), 'type' => wbConfig::get('DB.type_rwnet'), 'schema' => 'sikp'); try { $table =& wbModule::getModel('bds', 'd_hotel'); $result = $table->dbconn->GetItem("select * from core_user where user_id=" . wbSession::getVar('user_id')); $dbConn_rwnet = ADONewConnection($dbConnParams_rwnet['type']); $dbConn_rwnet->Connect($dbConnParams_rwnet['host'], $dbConnParams_rwnet['user'], $dbConnParams_rwnet['password'], $dbConnParams_rwnet['name']); $query = "select * from sikp.f_manual_reversal('{$no_registration}','" . $result['user_name'] . "', 'Cancel Pembayaran')"; $long_code = $dbConn_rwnet->GetItem($query); } catch (UserLoginFailedException $e) { $data['message'] = $e->getMessage(); } $data['items'] = $long_code; $data['total'] = 2; $data['success'] = true; return $data; }
public static function create($args = array()) { // Security check if ($_POST['_LOCAL_ONLY']) { return self::createLocal(); } if (!wbSecurity::check('t_cust_account')) { return; } // Get arguments from argument array extract($args); $data = array('items' => array(), 'success' => false, 'message' => ''); $jsonItems = wbRequest::getVarClean('items', 'str', ''); $items =& wbUtil::jsonDecode($jsonItems); $t_cust_account_id = wbRequest::getVarClean('t_cust_account_id', 'int', 0); $p_vat_type_dtl_id = wbRequest::getVarClean('p_vat_type_dtl_id', 'int', 0); if (!is_array($items)) { $data['message'] = 'Invalid items parameter'; return $data; } $table =& wbModule::getModel('bds', 'cust_acc_trans'); $table->actionType = 'CREATE'; if (isset($items[0])) { $errors = array(); $numSaved = 0; $numItems = count($items); $savedItems = array(); for ($i = 0; $i < $numItems; $i++) { try { $table->dbconn->BeginTrans(); //$items[$i][$table->pkey] = $table->GenID(); $date_only = explode('T', $items[$i]["trans_date"]); $session = wbUser::getSession(); /*$query = "SELECT COUNT(1) from sikp.f_get_cust_acc_dtl_trans(".$items[$i]["t_cust_account_id"].",'".$items[$i]["i_tgl_trans"]."') ".$table->getCriteriaSQL(); $countitems = $table->dbconn->GetOne($query); if($countitems > 0){ $data['message'] = 'Data Transaksi Tanggal '.wbUtil::dateToString($items[$i]["i_tgl_trans"]). ' sudah ada'; $data['success'] = false; return $data; }*/ //$cust_id = $table->dbconn->GetOne("select t_cust_account_id".$session['user_id']); $table->dbconn->Execute("select o_result_code, o_result_msg from \n" . "f_ins_cust_acc_dtl_trans(" . $items[$i]["t_cust_account_id"] . ",\n" . " '" . $items[$i]["i_tgl_trans"] . "',\n" . " '" . $items[$i]["i_bill_no"] . "',\n" . " '" . $items[$i]["i_serve_desc"] . "',\n" . " " . $items[$i]["i_serve_charge"] . ",\n" . " null,\n" . " '" . $items[$i]["i_description"] . "',\n" . " '" . $session['user_name'] . "',\n" . " '" . $p_vat_type_dtl_id . "',\n" . " null)"); /*echo "select o_result_code, o_result_msg from \n" . "f_ins_cust_acc_dtl_trans(" . $items["t_cust_account_id"]. ",\n" . " '" . $items[$i]["i_tgl_trans"]. "',\n" . " '" . $items[$i]["i_bill_no"]. "',\n" . " '" . $items[$i]["i_serve_desc"]. "',\n" . " " . $items[$i]["i_serve_charge"]. ",\n" . " null,\n" . " '" . $items[$i]["i_description"]. "',\n" . " '" . $session['user_name']. "')"; exit;*/ $numSaved++; $table->dbconn->CommitTrans(); } catch (Exception $e) { $table->dbconn->RollbackTrans(); $errors[] = $e->getMessage(); $data['message'] = $e->getMessage(); $data['success'] = false; //$items[$i] = array_merge($items[$i], $table->record); } } $numErrors = count($errors); if (count($errors)) { $data['message'] = $numErrors . " dari " . $numItems . " record gagal disimpan.<br/><br/><b>System Response:</b><br/>- " . implode("<br/>- ", $errors) . ""; } else { $data['success'] = true; $data['message'] = 'Data berhasil disimpan'; } $data['items'] = $items; } else { try { // begin transaction block $table->dbconn->BeginTrans(); // insert master //$items[$table->pkey] = $table->GenID(); /*$table->setRecord($items); $table->create(); // insert */ $session = wbUser::getSession(); $date_only = explode('T', $items["trans_date"]); //$cust_id = $table->dbconn->GetOne("select t_cust_account_id".$session['user_id']); $table->dbconn->Execute("select o_result_code, o_result_msg from \n" . "f_ins_cust_acc_dtl_trans(" . $items["t_cust_account_id"] . ",\n" . " '" . $date_only[0] . "',\n" . " '" . $items["bill_no"] . "',\n" . " null,\n" . " " . $items["service_charge"] . ",\n" . " null,\n" . " '" . $items["description"] . "',\n" . " '" . $session['user_name'] . "',\n" . " " . $p_vat_type_dtl_id . ",\n" . " null)"); $tr_id = $table->dbconn->GetOne("select last_value from t_cust_acc_dtl_trans_seq"); $query = "select to_char(trans_date,'yyyy-mm-dd') as trans_date,t_cust_acc_dtl_trans_id, t_cust_account_id, bill_no, service_desc, service_charge, vat_charge, description\n from sikp.f_get_cust_acc_dtl_trans(" . $items['t_cust_account_id'] . ",'" . $date_only[0] . "')AS tbl (t_cust_acc_dtl_trans_id) where t_cust_acc_dtl_trans_id = ?"; $item = $table->dbconn->GetItem($query, array($tr_id)); $data['success'] = true; $data['message'] = 'Data berhasil disimpan'; $data['items'] = $item; // all ok, commit transaction $table->dbconn->CommitTrans(); } catch (Exception $e) { // something happen, rollback transaction $table->dbconn->RollbackTrans(); $data['message'] = $e->getMessage(); $data['items'] = $items; } } return $data; }
/** * update * controler for remove item */ public static function destroy($args = array()) { // Security check if (!wbSecurity::check('t_vat_settlement')) { return; } // Get arguments from argument array extract($args); $jsonItems = wbRequest::getVarClean('items', 'str', ''); $items =& wbUtil::jsonDecode($jsonItems); $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); $table =& wbModule::getModel('bds', 't_vat_settlement'); try { $table->dbconn->BeginTrans(); if (is_array($items)) { foreach ($items as $key => $value) { if (empty($value)) { throw new Exception('Empty parameter'); } $table->dbconn->GetOne("select * from f_del_vat_setllement(" . $value . ",34,'23')"); $data['items'][] = array($table->pkey => $value); $data['total']++; } } else { $items = (int) $items; if (empty($items)) { throw new Exception('Empty parameter'); } $return = $table->dbconn->GetAll("select o_result_code,o_result_msg from f_del_vat_setllement(" . $items . ",34,'23')"); $data['items'][] = $return[0]; $data['total'] = 1; $data['message'] = $return[0]['o_result_msg']; if ($return[0]['o_result_code'] != '0') { $data['success'] = false; return $data; } } $data['success'] = true; $data['message'] = $data['total'] . ' Data berhasil dihapus'; $table->dbconn->CommitTrans(); } catch (Exception $e) { $table->dbconn->RollbackTrans(); $data['message'] = $e->getMessage(); $data['items'] = array(); $data['total'] = 0; } return $data; }