Exemplo n.º 1
0
    public static function main()
    {
        if (!wbUser::isLoggedIn()) {
            $redirecturl = wbModule::url('bds', 'bds', 'main');
            wbResponse::Redirect(wbModule::url('base', 'base', 'loginform', array('redirecturl' => urlencode($redirecturl))));
        }
        $loadjsmod = wbRequest::getVarClean('loadjsmod', 'str', '');
        wbPage::setPage('jspage');
        $userInfo = wbUser::getSession();
        $role = '';
        if (isset($userInfo['roles'][0]['role_name'])) {
            $role = strtolower($userInfo['roles'][0]['role_name']);
        }
        $script = <<<HEREDOC
    Webi.ROUTE_URL = "ws.php?type=json&module=bds";
    var _UNAME = "{$userInfo['user_name']}";
    var _RNAME = "{$userInfo['user_realname']}";
    var _GNAME = "{$role}";
HEREDOC;
        wbPage::addScriptCode($script);
        wbPage::addScript('modules/bds/views/script/properties.js');
        wbPage::addScript('modules/bds/views/script/GridPanel.js');
        wbPage::addScript('modules/bds/views/script/FormPanel.js');
        wbPage::addScript('modules/bds/views/script/ModulePanel.js');
        wbPage::addScript('modules/base/views/script/roles-jsloader.php');
        wbPage::addScript('modules/bds/views/script/jsloader.php');
        return array('loadjsmod' => $loadjsmod);
    }
Exemplo n.º 2
0
 public static function init($config = array())
 {
     //-- todo : load log handler here
     // load system config
     sys::import('webi.config');
     wbConfig::init();
     // load variables handler, server/request/response utilities
     sys::import('webi.server');
     sys::import('webi.nusoap');
     // load template, page handler
     sys::import('webi.template');
     sys::import('webi.htmlElementWidget');
     wbPage::init();
     // load database
     sys::import('webi.db');
     $dbConnParams = array('name' => wbConfig::get('DB.name'), 'user' => wbConfig::get('DB.user'), 'password' => wbConfig::get('DB.password'), 'host' => wbConfig::get('DB.host'), 'type' => wbConfig::get('DB.type'));
     wbDB::init($dbConnParams);
     // load session handler
     sys::import('webi.sessions');
     wbSession::init();
     //-- todo : load language system
     // load utilities function
     sys::import('webi.utils');
     // load module handler
     sys::import('webi.modules');
     sys::import('webi.crud.AbstractTable');
     //-- todo : load users and security system
     sys::import('webi.users');
     wbUser::init();
     sys::import('webi.security');
     return true;
 }
 public static function logout()
 {
     wbUser::delSession();
     $_COOKIE = '';
     $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => '');
     $data['items'] = array();
     $data['total'] = 0;
     $data['message'] = 'Logout Berhasil';
     $data['success'] = true;
     return $data;
 }
Exemplo n.º 4
0
 /**
  * call module controller
  */
 public static function call($module, $class, $method, $params = array(), $type = '')
 {
     $className = self::loadController($module, $class, $type);
     if (!method_exists($className, $method)) {
         throw new ClassMethodNotExistException('Method ' . $method . ' does not exist in Class ' . $className);
     }
     $vars = get_class_vars($className);
     if (isset($vars['loggedInFirst']) && $vars['loggedInFirst'] === true) {
         if (!wbUser::isLoggedIn()) {
             $redirecturl = wbModule::url($module, $module, 'main');
             $url = wbModule::url('base', 'base', 'loginform', array('redirecturl' => $redirecturl));
             throw new Exception('Session login anda telah expire atau belum login. Silahkan <a href="' . $url . '" title="Login">Login</a> kembali.<br/><br/><b>Security Info</b><br/>Hal ini dilakukan untuk menjaga keamanan aplikasi, jika anda telah idle dalam jangka waktu yg cukup lama maka anda diharuskan untuk melakukan autentifikasi kembali');
         }
     }
     return call_user_func($className . '::' . $method, $params);
 }
Exemplo n.º 5
0
 /**
  * validate
  * input record validator
  */
 public function validate()
 {
     $userInfo = wbUser::getSession();
     if ($this->actionType == 'CREATE') {
         // TODO : Write your validation for CREATE here
         $this->record['creation_date'] = date('Y-m-d');
         $this->record['created_by'] = $userInfo['user_name'];
         $this->record['updated_date'] = date('Y-m-d');
         $this->record['updated_by'] = $userInfo['user_name'];
     } else {
         if ($this->actionType == 'UPDATE') {
             // TODO : Write your validation for UPDATE here
             $this->record['updated_date'] = date('Y-m-d');
             $this->record['updated_by'] = $userInfo['user_name'];
         }
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * validate
  * input record validator
  */
 public function validate()
 {
     $userInfo = wbUser::getSession();
     if ($this->actionType == 'CREATE') {
         $table_inbox =& wbModule::getModel('bds', 't_message_outbox');
         // TODO : Write your validation for CREATE here
         $this->record['creation_date'] = date('Y-m-d h:i:s');
         $this->record['created_by'] = $userInfo['user_name'];
         $this->record['update_date'] = date('Y-m-d');
         $this->record['update_by'] = $userInfo['user_name'];
     } else {
         if ($this->actionType == 'UPDATE') {
             // TODO : Write your validation for UPDATE here
             $this->record['updated_date'] = date('Y-m-d');
             $this->record['updated_by'] = $userInfo['user_name'];
         }
     }
     return true;
 }
Exemplo n.º 7
0
 /**
  * validate
  * input record validator
  */
 public function validate()
 {
     $userInfo = wbUser::getSession();
     if ($this->actionType == 'CREATE') {
         // TODO : Write your validation for CREATE here
         $this->record['wilayah_creation_date'] = date('Y-m-d');
         $this->record['wilayah_creation_by'] = $userInfo['user_name'];
         $this->record['wilayah_updated_date'] = date('Y-m-d');
         $this->record['wilayah_updated_by'] = $userInfo['user_name'];
         if (!isset($this->record['wilayah_pid'])) {
             //do nothing
         } else {
             $itemParent = $this->get($this->record['wilayah_pid']);
             if (strlen($this->record['wilayah_kode']) <= strlen($itemParent['wilayah_kode'])) {
                 throw new Exception("Jumlah Karakter Kode Wilayah(" . $this->record['wilayah_kode'] . ") Harus Melebihi Jumlah Karakter Kode Parent(" . $itemParent['wilayah_kode'] . ") ");
             }
             if (substr($this->record['wilayah_kode'], 0, strlen($itemParent['wilayah_kode'])) !== $itemParent['wilayah_kode']) {
                 throw new Exception("Prefix Kode Wilayah Harus Sama Dengan Kode Parent '" . $itemParent['wilayah_kode'] . "'");
             }
         }
     } else {
         if ($this->actionType == 'UPDATE') {
             // TODO : Write your validation for UPDATE here
             $this->record['wilayah_updated_date'] = date('Y-m-d');
             $this->record['wilayah_updated_by'] = $userInfo['user_name'];
             if (!isset($this->record['wilayah_kode'])) {
                 //do nothing
             } else {
                 $item = $this->get($this->record['wilayah_id']);
                 $itemParent = $this->get($item['wilayah_pid']);
                 if (strlen($this->record['wilayah_kode']) <= strlen($itemParent['wilayah_kode'])) {
                     throw new Exception("Jumlah Karakter Kode Wilayah(" . $this->record['wilayah_kode'] . ") Harus Melebihi Jumlah Karakter Kode Parent(" . $itemParent['wilayah_kode'] . ") ");
                 }
                 if (substr($this->record['wilayah_kode'], 0, strlen($itemParent['wilayah_kode'])) !== $itemParent['wilayah_kode']) {
                     throw new Exception("Prefix Kode Wilayah Harus Sama Dengan Kode Parent '" . $itemParent['wilayah_kode'] . "'");
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 8
0
 /**
  * validate
  * input record validator
  */
 public function validate()
 {
     $userInfo = wbUser::getSession();
     if ($this->actionType == 'CREATE') {
         // TODO : Write your validation for CREATE here
         $this->record['menu_creation_date'] = date('Y-m-d');
         $this->record['menu_creation_by'] = $userInfo['user_name'];
         $this->record['menu_updated_date'] = date('Y-m-d');
         $this->record['menu_updated_by'] = $userInfo['user_name'];
         /*Menentukan Level Menu*/
         if (!isset($this->record['menu_pid'])) {
             //pid kosong
             $this->record['menu_level'] = 1;
         } else {
             $itemParent = $this->get($this->record['menu_pid'], true);
             $this->record['menu_level'] = $itemParent['menu_level'] + 1;
         }
         /*Menentukan Path Menu*/
         if (!isset($this->record['menu_pid'])) {
             //pid kosong
             $this->record['menu_path'] = $this->record['menu_id'];
         } else {
             $query = "SELECT COUNT(1) FROM bds_p_app_menu WHERE menu_pid = ?";
             $count_child = $this->dbconn->GetOne($query, array($this->record['menu_pid']));
             if (empty($count_child)) {
                 $count_child = 0;
             }
             $itemParent = $this->get($this->record['menu_pid'], true);
             $thepath = $itemParent['menu_path'] . "." . ($count_child + 1);
             $this->record['menu_path'] = $thepath;
         }
     } else {
         if ($this->actionType == 'UPDATE') {
             // TODO : Write your validation for UPDATE here
             $this->record['menu_updated_date'] = date('Y-m-d');
             $this->record['menu_updated_by'] = $userInfo['user_name'];
         }
     }
     return true;
 }
 public static function check($name, $action = 1, $module = "")
 {
     if (empty($module)) {
         $module = wbCache::getCached('current', 'module');
     }
     if (empty($module)) {
         throw new Exception("Unknown Module");
     }
     if (!self::isPermissionExist($name)) {
         throw new Exception('Unknown Permission Name ' . $name . ' on module ' . $module);
     }
     $sessionInfo = wbUser::getSession();
     $dbconn = wbDB::getConn();
     $prefix = wbConfig::get('DB.prefix');
     $query = "SELECT role_id FROM " . $prefix . "_user_role \r\n                    WHERE role_id IN (select role_id FROM " . $prefix . "_role_permission) AND user_id = ?";
     $result =& $dbconn->Execute($query, array($sessionInfo['user_id']));
     if (!$result) {
         throw new Exception($dbconn->ErrorMsg());
     }
     while (!$result->EOF) {
         list($role_id) = $result->fields;
         // check ACCESS
         $query = "SELECT COUNT(1) FROM " . $prefix . "_role_permission as a, " . $prefix . "_permission as b\r\n                        WHERE a.role_id = ? AND \r\n                              a.permission_level >= ? AND \r\n                              a.permission_id = b.permission_id AND\r\n                              b.permission_name = ? AND \r\n                              b.permission_module = ?";
         $count = $dbconn->GetOne($query, array($role_id, $action, $name, $module));
         if ($count === false) {
             throw new Exception($dbconn->ErrorMsg());
         }
         if ($count) {
             return true;
         }
         // this user has ACCESS
         $result->MoveNext();
     }
     $result->Close();
     // this user does not access
     throw new Exception(json_encode(array('error' => 'sess_error', 'msg' => "Anda tidak memiliki hak akses untuk melakukan operasi ini atau sessi login anda sudah berakhir<br/><br/>Silahkan untuk melakukan login kembali")));
     throw new Exception("Anda tidak memiliki hak akses untuk melakukan operasi ini atau sessi login anda sudah berakhir<br/><br/>Nama Akses : " . self::$accessList[$action] . " on " . $module . '.' . $name . "<br/>Silahkan hubungi Administrator untuk mendapatkan akses tersebut");
 }
Exemplo n.º 10
0
 /**
  * validate
  * input record validator
  */
 public function validate()
 {
     $userInfo = wbUser::getSession();
     if ($this->record['tahun_aktif'] == 'Y') {
         $this->updateStatus($this->record[$this->pkey]);
     }
     if ($this->actionType == 'CREATE') {
         // TODO : Write your validation for CREATE here
         $this->record['tahun_creation_date'] = date('Y-m-d');
         $this->record['tahun_creation_by'] = $userInfo['user_name'];
         $this->record['tahun_updated_date'] = date('Y-m-d');
         $this->record['tahun_updated_by'] = $userInfo['user_name'];
         if (!$this->isUnique($this->pkey, $this->record[$this->pkey])) {
             throw new Exception('Duplicate entry: ID Tahun ' . $this->record[$this->pkey] . ' sudah ada dalam database');
         }
     } else {
         if ($this->actionType == 'UPDATE') {
             // TODO : Write your validation for UPDATE here
             $this->record['tahun_updated_date'] = date('Y-m-d');
             $this->record['tahun_updated_by'] = $userInfo['user_name'];
         }
     }
     return true;
 }
 public static function menunodes($args = array())
 {
     $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => '');
     $userInfo = wbUser::getSession();
     if ($userInfo['user_id'] == "") {
         return $data;
     }
     $text = '';
     $dbconn = wbDB::getConn();
     $isdmin = false;
     if ($userInfo['user_id'] == "1") {
         $isdmin = true;
     }
     $query = "select count(*) ada from core_user_role where role_id=1 and user_id=" . $userInfo['user_id'];
     $result =& $dbconn->Execute($query);
     if (!$result->EOF) {
         list($ada) = $result->fields;
     }
     if ($ada > 0) {
         $isdmin = true;
     }
     if ($isdmin == true) {
         $query = "select menu_id, nvl (menu_pid, 0) menu_pid, menu_code, menu_file_name " . "from (select menu_id, menu_pid, menu_code, nvl (menu_file_name, '-') as menu_file_name, " . "menu_description, menu_listing_no  " . "from bds_p_app_menu  " . "where menu_is_active = 'Y'  " . "start with menu_pid is null connect by prior menu_id = menu_pid order siblings by nvl(menu_listing_no, 9999)) ";
     } else {
         $query = "select menu_id, nvl (menu_pid, 0) menu_pid, menu_code, menu_file_name " . "from (select menu_id, menu_pid, menu_code, nvl (menu_file_name, '-') as menu_file_name, " . "menu_description, menu_listing_no " . "from bds_p_app_menu " . "where menu_is_active = 'Y' " . "and menu_id in ( " . "select rm.menu_id " . "from bds_p_role_menu rm, core_user_role ur " . "where nvl(rm.rolemenu_status,'N')='Y' and rm.role_id = ur.role_id " . "and ur.user_id = " . $userInfo['user_id'] . " ) " . "start with menu_pid is null connect by prior menu_id = menu_pid order siblings by nvl(menu_listing_no, 9999)) ";
     }
     //       echo("\/\/[disini" . $query . "]");
     $text .= "[" . chr(13);
     $result =& $dbconn->Execute($query);
     if (!$result) {
         exit;
     }
     $PLevel = array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
     $level = 0;
     $bdmnid = 0;
     $nplevel = -1;
     $parid = 0;
     while (!$result->EOF) {
         list($menu_id, $menu_pid, $menu_code, $menu_file_name) = $result->fields;
         if ($menu_id != $bdmnid) {
             if ($menu_pid == $PLevel[$level]) {
                 $text .= '"leaf":true},' . chr(13);
             } else {
                 if ($menu_pid == $nplevel) {
                     $text .= '"leaf":false,' . chr(13);
                     $text .= '"expanded":false,' . chr(13);
                     $text .= '"children":[' . chr(13);
                     $level = $level + 1;
                     $PLevel[$level] = $menu_pid;
                 } else {
                     if ($level > 0) {
                         $text .= '"leaf":true},' . chr(13);
                     }
                     while ($PLevel[$level] != $menu_pid && $level > 0) {
                         $text .= "]" . chr(13);
                         $text .= "}," . chr(13);
                         $level = $level - 1;
                     }
                 }
             }
             $nplevel = $menu_id;
             $text .= "{" . chr(13);
             if ($menu_file_name == "-") {
                 $text .= '"id":"' . $menu_id . '",' . chr(13);
             } else {
                 $text .= '"id":"' . $menu_file_name . '",' . chr(13);
             }
             $text .= '"text":"' . $menu_code . '",' . chr(13);
         }
         $result->MoveNext();
     }
     $result->Close();
     if ($level > 0) {
         $text .= '"leaf":true},' . chr(13);
     }
     while ($level > 0) {
         $text .= "]" . chr(13);
         $text .= "}," . chr(13);
         $level = $level - 1;
     }
     $text .= "]" . chr(13);
     $data['items'] = $text;
     $data['success'] = true;
     $data['message'] = 'Menu Success';
     return $data;
 }
Exemplo n.º 12
0
echo $wbPageTitle;
?>
    </title>
    <link rel="stylesheet" href="<?php 
echo $wbPageThemeDir;
?>
/style/style.css" type="text/css" />
    <?php 
echo $wbPageStyle;
?>
    <?php 
echo $wbPageScriptHead;
?>
</head>
<body <?php 
echo wbUser::isLoggedIn() ? '' : 'class="login"';
?>
 >
    <div class="page-wrapper">
        <div class="page-header">
            <!--<div class="logo"></div>-->
			<H1 align="center">APLIKASI PEMBAYARAN DAN PELAPORAN <br>WAJIB PAJAK DAERAH ONLINE</H1>
        </div>
        <div class="page-body">
            <?php 
echo $wbPageContent;
?>
            <div class="clear"></div>
        </div>
        <div class="page-footer">
            
Exemplo n.º 13
0
 public static function uploadExcelLocal($args = array())
 {
     global $_FILES;
     try {
         //'excel_file' adalah nama field di form
         if (empty($_FILES['excel_trans_cust']['name'])) {
             throw new Exception('File tidak boleh kosong');
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }
     $file_name = $_FILES['excel_trans_cust']['name'];
     // <-- File Name
     $file_location = 'var/uploadexcel/' . $file_name;
     // <-- LOKASI Upload File
     //upload file ke lokasi tertentu
     try {
         if (!move_uploaded_file($_FILES['excel_trans_cust']['tmp_name'], $file_location)) {
             throw new Exception("Upload file gagal");
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }
     include 'lib/excel/reader.php';
     $xl_reader = new Spreadsheet_Excel_Reader();
     $res = $xl_reader->_ole->read($file_location);
     if ($res === false) {
         if ($xl_reader->_ole->error == 1) {
             echo "File Harus Format Excel";
             exit;
         }
     }
     try {
         $xl_reader->read($file_location);
         $firstColumn = $xl_reader->sheets[0]['cells'][1][1];
         // $DBConnect = new clsDBConnSIKP();
         $session = wbUser::getSession();
         $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);
         $items = array();
         for ($i = 2; $i <= $xl_reader->sheets[0]['numRows']; $i++) {
             if (empty($xl_reader->sheets[0]['cells'][$i][1])) {
             }
             continue;
             $item['t_cust_account_id'] = $t_cust_account_id;
             $item['i_tgl_trans'] = $xl_reader->sheets[0]['cells'][$i][1];
             $item['i_bill_no'] = $xl_reader->sheets[0]['cells'][$i][2];
             $item['i_serve_desc'] = $xl_reader->sheets[0]['cells'][$i][3];
             $item['i_serve_charge'] = $xl_reader->sheets[0]['cells'][$i][4];
             //$i_vat_charge = $xl_reader->sheets[0]['cells'][$i][4];
             $item['i_vat_charge'] = "null";
             $item['i_desc'] = $xl_reader->sheets[0]['cells'][$i][5];
             $item['p_vat_type_dtl_id'] = $temp_cust_account['items'][0]['p_vat_type_dtl_id'];
             $items[] = $item;
         }
         $_POST['items'] = json_encode($items);
         $_POST['_LOCAL_ONLY'] = true;
         $data = self::create();
         echo json_encode($data);
         exit;
     } catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }
 }
Exemplo n.º 14
0
 public static function logout()
 {
     $ws_client = self::getNusoap();
     $params = array('search' => '', 'getParams' => json_encode($_GET), 'controller' => json_encode(array('module' => 'base', 'class' => 'roles.dologin', 'method' => 'logout', 'type' => 'json')), 'postParams' => json_encode($_POST), 'jsonItems' => '', 'start' => $start, 'limit' => $limit);
     wbUser::delSession();
     wbResponse::Redirect('http://45.118.112.232:81/portal/');
 }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
<?php

if (wbUser::isLoggedIn()) {
    $userInfo = wbUser::getSession();
    ?>
    Anda telah login sebagai <?php 
    echo $userInfo['user_name'];
    ?>
.
    <br/>
    [<a href="<?php 
    echo wbModule::url('base', 'base', 'logout');
    ?>
" title="LogOut">LogOut</a>]
<?php 
    return;
}
?>

<form action="<?php 
echo $loginurl;
?>
" method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="redirecturl" id="redirecturl" value="<?php 
echo $redirecturl;
?>
" />
    
	<div class="loginform">
   		<div class="loginform-title"></div>
	   	<div class="loginform-content">
 public static function createLocal($args = array())
 {
     // Security check
     // 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);
     $user_name = wbRequest::getVarClean('user_name', 'str', '');
     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"]);
                 $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" . "                         '" . $user_name . "',\n" . "                         '" . $p_vat_type_dtl_id . "',\n" . "                         null)");
                 $numSaved++;
                 /*$querystring = "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" .
                                     "                         '" . $user_name. "',\n" .
                                     "                         '" . $p_vat_type_dtl_id. "',\n" .
                                     "                         null)";
                 		$data['items']=$querystring;
                 		return $data;*/
                 $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;
 }
Exemplo n.º 18
0
 public static function logout()
 {
     wbUser::delSession();
     wbResponse::Redirect('index.php');
 }
 public static function uploadExcel($args = array())
 {
     //$temp_cust_account = self::getNpwd();
     //delete DSR yang belum di submit
     $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => '');
     try {
         $ws_client = self::getNusoap();
         $params = array('search' => '', 'getParams' => json_encode($_GET), 'controller' => json_encode(array('module' => 'bds', 'class' => 't_vat_settlement', 'method' => 'deleteDSR', 'type' => 'json')), 'postParams' => json_encode($_POST), 'jsonItems' => '', 'start' => $start, 'limit' => $limit);
         $ws_data = self::getResultData($ws_client, $params);
         $data['items'] = $ws_data['data'];
         $data['total'] = $ws_data['total'];
         $data['message'] = $ws_data['message'];
         $data['success'] = $ws_data['success'];
     } catch (Exception $e) {
         $data['message'] = $e->getMessage();
     }
     if ($data['success'] == true) {
         //upload data transaksi
         global $_FILES;
         try {
             //'excel_file' adalah nama field di form
             if (empty($_FILES['excel_trans_cust']['name'])) {
                 throw new Exception('File tidak boleh kosong');
             }
         } catch (Exception $e) {
             echo $e->getMessage();
             exit;
         }
         $file_name = $_FILES['excel_trans_cust']['name'];
         // <-- File Name
         $file_location = 'var/uploadexcel/' . $file_name;
         // <-- LOKASI Upload File
         //upload file ke lokasi tertentu
         try {
             if (!move_uploaded_file($_FILES['excel_trans_cust']['tmp_name'], $file_location)) {
                 throw new Exception("Upload file gagal");
             }
         } catch (Exception $e) {
             echo $e->getMessage();
             exit;
         }
         include 'lib/excel/reader.php';
         $xl_reader = new Spreadsheet_Excel_Reader();
         $res = $xl_reader->_ole->read($file_location);
         if ($res === false) {
             if ($xl_reader->_ole->error == 1) {
                 echo "File Harus Format Excel";
                 exit;
             }
         }
         try {
             $xl_reader->read($file_location);
             $firstColumn = $xl_reader->sheets[0]['cells'][1][1];
             // $DBConnect = new clsDBConnSIKP();
             $session = wbUser::getSession();
             //$sqll = "select * from f_get_npwd_by_username('".$session['user_id']."') AS tbl (ty_lov_npwd) where rownum < 2 ";
             //$DBConnect->query($sqll);
             //while ($DBConnect->next_record()){
             //	$value = $DBConnect->f("ty_lov_npwd");
             // }
             $t_cust_account_id = wbRequest::getVarClean('t_cust_account_id', 'int', 0);
             $start_period = wbRequest::getVarClean('start_period', 'str', 0);
             $end_period = wbRequest::getVarClean('end_period', 'str', 0);
             //$i_t_cust_id = CCGetFromGet("t_cust_account_id","");
             //$i_t_cust_account_id = empty($i_t_cust_id) ? $value : $i_t_cust_id;
             //$i_trans = CCGetFromGet("trans_date","");
             //$i_tgl_trans = empty($i_trans) ? date('Y-m-d') : $i_trans;
             //$uname = CCGetUserLogin(); //harap diubah
             //$uploadForm->t_cust_account_id->SetValue($i_t_cust_account_id);
             //$uploadForm->trans_date->SetValue($i_tgl_trans);
             $jumlah_hari = substr($end_period, 8, 2) - substr($start_period, 8, 2) + 1;
             $tahun_bulan = substr($start_period, 0, 8);
             if ($jumlah_hari != $xl_reader->sheets[0]['numRows'] - 2) {
                 $data['message'] = "Laporan masa pajak anda ini tidak sesuai dengan Laporan Rekapitulasi Penerimaan Harian";
                 $data['success'] = false;
                 echo json_encode($data);
                 exit;
             }
             $items = array();
             for ($i = 3; $i <= $xl_reader->sheets[0]['numRows']; $i++) {
                 $temp_date = $tahun_bulan . sprintf("%02d", $i - 3 + substr($start_period, 8, 2));
                 if ($temp_date != $xl_reader->sheets[0]['cells'][$i][1]) {
                     $data['message'] = "Laporan masa pajak anda ini tidak sesuai dengan Laporan Rekapitulasi Penerimaan Harian";
                     $data['success'] = false;
                     echo json_encode($data);
                     exit;
                 }
                 $item['t_cust_account_id'] = $t_cust_account_id;
                 $item['i_tgl_trans'] = $xl_reader->sheets[0]['cells'][$i][1];
                 $bills = explode("-", $xl_reader->sheets[0]['cells'][$i][2]);
                 $item['i_bill_no'] = $bills[0];
                 $item['i_bill_no_end'] = $bills[1];
                 $item['i_bill_count'] = $xl_reader->sheets[0]['cells'][$i][3];
                 $item['i_serve_desc'] = '';
                 $item['i_serve_charge'] = $xl_reader->sheets[0]['cells'][$i][4];
                 //$i_vat_charge = $xl_reader->sheets[0]['cells'][$i][4];
                 $item['i_vat_charge'] = "null";
                 $item['i_desc'] = $xl_reader->sheets[0]['cells'][$i][5];
                 $item['p_vat_type_dtl_id'] = $temp_cust_account['items'][0]['p_vat_type_dtl_id'];
                 $item['p_vat_type_dtl_cls_id'] = $temp_cust_account['items'][0]['p_vat_type_dtl_cls_id'];
                 $items[] = $item;
             }
             //$_POST['p_vat_type_dtl_id']=$temp_cust_account['items'][0]['p_vat_type_dtl_id'];
             $_POST['items'] = json_encode($items);
             //echo json_encode($items); exit;
             $data = self::createCustAccTrans();
             echo json_encode($data);
             exit;
         } catch (Exception $e) {
             echo $e->getMessage();
             exit;
         }
     }
     echo json_encode($data);
     exit;
 }