function getDataAll($user_id, $from_date, $to_date) { $cur_mod = new Application_Model_DbTable_DbCurrencies(); $usr_mod = new Application_Model_DbTable_DbUsers(); $rsCur = $cur_mod->getCurrencyList(); $rsUser = null; $tmp_summary = null; $return_araray = array(); if ($user_id == -1) { $rsUser = $usr_mod->getUserListSelect(); if (!empty($rsCur)) { $tmp_summary = array(); foreach ($rsCur as $k => $rc) { $cur_type = $rc['symbol']; $bought = $this->sumValue($cur_type, null, "in", $from_date, $to_date); $sale = $this->sumValue($cur_type, null, "out", $from_date, $to_date); $tmp_summary[$k]['saleamount'] = $sale; $tmp_summary[$k]['boughtamount'] = $bought; $tmp_summary[$k]['currncytype'] = $rc['name']; $tmp_summary[$k]['currncysymbol'] = $cur_type; } $return_araray['summary'] = $tmp_summary; } } else { $rsUser = $usr_mod->getUserInfoByfetchAll($user_id); } //print_r($return_araray); exit(); if (!empty($rsUser)) { $tmp_data = array(); $row_index = 0; foreach ($rsUser as $i => $ru) { if (empty($rsCur)) { break; } foreach ($rsCur as $k => $rc) { $cur_type = $rc['symbol']; $bought = $this->sumValue($cur_type, $ru['id'], "in", $from_date, $to_date); $sale = $this->sumValue($cur_type, $ru['id'], "out", $from_date, $to_date); if ($bought != 0 || $sale != 0) { $tmp_data[$row_index]['username'] = $ru['name']; $tmp_data[$row_index]['userid'] = $ru['id']; $tmp_data[$row_index]['saleamount'] = $sale; $tmp_data[$row_index]['boughtamount'] = $bought; $tmp_data[$row_index]['currncytype'] = $rc['name']; $tmp_data[$row_index]['currncysymbol'] = $cur_type; $row_index++; } } } if (!empty($tmp_data)) { $return_araray['data'] = $tmp_data; } } return $return_araray; }
public function indexAction(){ try{ $db_tran=new Application_Model_DbTable_DbGlobal(); $session_transfer=new Zend_Session_Namespace('search_xhcange'); $db = new Tellerandexchange_Model_DbTable_Dbexchange(); $session_user=new Zend_Session_Namespace('auth'); $user_id = $session_user->user_id; if($this->getRequest()->isPost()){ $search=$this->getRequest()->getPost(); } else{ $search = array( 'user_id' => -1, 'status' => -1, 'from_date' =>date('Y-m-d'), 'to_date' => date('Y-m-d'), ); } $this->view->list_search=$search; // $rs_row= $db->getAllExchangeListMulti($search); $rs_row= $db->getAllSigleExchange($search); $glClass = new Application_Model_GlobalClass(); $rs_rows = $glClass->getImgActive($rs_row, BASE_URL, true); $list = new Application_Form_Frmtable(); $collumns = array("DATE","EXCHANGE","FROM_AMOUNT","អត្រាប្តូរប្រាក់","ចំនួនទឹកប្រាក់បានប្តូររួច","ប្រាក់ទទួលបាន","ប្រាក់អាប់","STATUS"); $link=array( 'module'=>'tellerandexchange','controller'=>'xchanges','action'=>'edit', ); $this->view->list=$list->getCheckList(0, $collumns, $rs_rows,array('statusDate'=>$link,'from_to'=>$link,'fromAmount'=>$link)); $usr_mod = new Application_Model_DbTable_DbUsers(); $this->view->users = $usr_mod->getUserListSelect(); $this->view->user_id = $user_id; //$this->view->from_date=$session_transfer->from_date; //$this->view->to_date=$session_transfer->to_date; }catch (Exception $e){ Application_Form_FrmMessage::message("Application Error"); echo $e->getMessage(); Application_Model_DbTable_DbUserLog::writeMessageError($e->getMessage()); } $frm = new Application_Form_FrmAdvanceSearch(); $frm = $frm->AdvanceSearch(); Application_Model_Decorator::removeAllDecorator($frm); $this->view->frm_search = $frm; }
public function editedAction() { // action body $us_id = $this->getRequest()->getParam('us_id'); $us_id = empty($us_id) ? 0 : $us_id; $db_user = new Application_Model_DbTable_DbUsers(); $this->view->user_edit = $db_user->getUserEdit($us_id); $this->view->user_typelist = $this->user_typelist; if ($this->getRequest()->isPost()) { $userdata = $this->getRequest()->getPost(); try { $db = $db_user->updateUser($userdata); Application_Form_FrmMessage::Sucessfull('ការបញ្ចូលជោគជ័យ', self::REDIRECT_URL); } catch (Exception $e) { $this->view->msg = 'ការបញ្ចូលមិនជោគជ័យ'; } } }
public function indexAction() { $this->_helper->layout()->disableLayout(); ///sopharat disablelayout to display login $tr = Application_Form_FrmLanguages::getCurrentlanguage(); if ($this->getRequest()->isPost()) { $formdata = $this->getRequest()->getPost(); $db_user = new Application_Model_DbTable_DbUsers(); $email = $formdata['txt_email']; $password = $formdata['txt_password']; if ($db_user->checkEmail($email)) { if ($db_user->userAuthenticate($email, $password)) { $user_id = $db_user->getUserID($email); $user_info = $db_user->getUserInfo($user_id); $arr_acl = $db_user->getArrAcl($user_info['user_type_id']); //in case user have no right to access any module of the system if (!$arr_acl) { $this->view->msg = $tr->translate('LOGIN_FAIL_NO_MODULE'); } else { $session_user = new Zend_Session_Namespace('auth'); $session_user->unlock(); $session_user->user_id = $user_id; $session_user->fullname = $user_info['fullname']; $session_user->user_name = $user_info['username']; $session_user->level = $user_info['user_type_id']; $session_user->user_type = $user_info['user_type']; $session_user->location_id = $user_info['LocationId']; $session_user->email = $email; for ($i = 0; $i < count($arr_acl); $i++) { $arr_module[$i] = $arr_acl[$i]['module']; } $arr_module = array_unique($arr_module); $session_user->arr_acl = $arr_acl; $session_user->arr_module = $arr_module; $session_user->lock(); //echo $session_user->user_name;sales/sales-order //echo $session_user->user_id=$user_id;exit(); //$_url=($arr_acl[0]!=='')? '/'.$arr_acl[0]['module']:'/default/index/home' ;//before //$_url=($arr_acl[0]!=='')? '/default/index/dashboad':'/default/index/home' ;//after //print_r($arr_acl[0]); //exit(); //$this->_redirect("/sales/sales-order"); $_url = $arr_acl[0] !== '' ? '/default/index/dashboad' : '/sales/sales-order'; //after $this->_redirect($_url); } } elseif (!$db_user->checkStatusByEmail($email)) { $this->view->msg = $tr->translate('LOGIN_FAIL_COMFIRM'); } else { $this->view->msg = $tr->translate('LOGIN_FAIL'); } } else { $this->view->msg = $tr->translate('EMAIL_NOT'); } } }
public function indexAction() { // action body $this->_helper->layout()->disableLayout(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if ($data["lange"] == 2) { $dbs = new Application_Model_DbTable_DbSiteLanguages(); $ids = 2; $lang = $dbs->getbyid($ids); $session_lang = new Zend_Session_Namespace('lang'); $session_lang->unlock(); $session_lang->lang_id = $lang['id']; $session_lang->lang = $lang['language']; } if ($data["lange"] == 1) { $dbs = new Application_Model_DbTable_DbSiteLanguages(); $ids = 1; $lang = $dbs->getbyid($ids); $session_lang = new Zend_Session_Namespace('lang'); $session_lang->unlock(); $session_lang->lang_id = $lang['id']; $session_lang->lang = $lang['language']; } $db_user = new Application_Model_DbTable_DbUsers(); $login = $data['login']; $password = $data['password']; if ($db_user->checkUsr($login)) { if ($db_user->userAuthenticate($login, $password)) { $user_id = $db_user->getUserID($login); $user_info = $db_user->getUserInfo($user_id); if ($user_info['user_type'] == 1) { $session_user = new Zend_Session_Namespace('auth'); $session_user->unlock(); $session_user->user_id = $user_id; $session_user->fullname = $user_info['name']; $session_user->user_name = $user_info['user_name']; $session_user->level = $user_info['user_type']; $session_user->email = $user_info['email']; Application_Form_FrmMessage::redirector('/index/pos'); } else { $session_user = new Zend_Session_Namespace('auth'); $session_user->unlock(); $session_user->user_id = $user_id; $session_user->fullname = $user_info['name']; $session_user->user_name = $user_info['user_name']; $session_user->level = $user_info['user_type']; $session_user->email = $user_info['email']; Application_Form_FrmMessage::redirector('/index/home'); } } elseif (!$db_user->checkStatusBy($login)) { $this->view->msg = ' Login Fall Comfirm ! '; } else { $this->view->msg = ' User Name or Password Incorect ! '; } } else { $this->view->msg = ' Login not Success ! '; } } }
/** * To validate the user name * and password is valids or not * @param <string> $username * @param <string> $password */ public function userAuthenticate($username, $password) { $db_adapter = Application_Model_DbTable_DbUsers::getDefaultAdapter(); $auth_adapter = new Zend_Auth_Adapter_DbTable($db_adapter); $auth_adapter->setTableName($this->_name)->setIdentityColumn('user_name')->setCredentialColumn('password')->setCredentialTreatment('MD5(?) AND active=1'); // optional if password has been hashed $auth_adapter->setIdentity($username); // set value of username field $auth_adapter->setCredential($password); // set value of password field //instantiate Zend_Auth class $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($auth_adapter); if ($result->isValid()) { return true; } else { return false; } }
public function changepasswordAction() { // action body if ($this->getRequest()->isPost()) { $session_user = new Zend_Session_Namespace('auth'); $pass_data = $this->getRequest()->getPost(); if ($pass_data['password'] == $session_user->pwd) { $db_user = new Application_Model_DbTable_DbUsers(); try { $db_user->changePassword($pass_data['new_password'], $session_user->user_id); $session_user->unlock(); $session_user->pwd = $pass_data['new_password']; $session_user->lock(); Application_Form_FrmMessage::Sucessfull('ការផ្លាស់ប្តូរដោយជោគជ័យ', self::REDIRECT_URL); } catch (Exception $e) { Application_Form_FrmMessage::message('ការផ្លាស់ប្តូរត្រូវបរាជ័យ'); } } else { Application_Form_FrmMessage::message('ការផ្លាស់ប្តូរត្រូវបរាជ័យ'); } } }
public function rptPcsAction() { try { $db_tran = new Application_Model_DbTable_Dbpsc(); // create sesesion $from_date = date("Y-m-d"); $to_date = date("Y-m-d"); $type_money = -1; $staff_name = -1; $this->view->from_date = $from_date; $this->view->to_date = $to_date; $this->view->staff = $staff_name; $cur = new Application_Model_DbTable_DbCurrencies(); $this->view->currencylist = $cur->getCurrencyList(); $this->view->type_money = $type_money; if ($this->getRequest()->isPost()) { $formdata = $this->getRequest()->getPost(); $this->view->type_money = $formdata['type_money']; $this->view->staff_name = $formdata['staff_name']; $this->view->from_date = $formdata['from_date']; $this->view->to_date = $formdata['to_date']; } else { $formdata = array('from_date' => $from_date, 'to_date' => $to_date, 'type_money' => $type_money, 'staff_name' => $staff_name); } $trans = $db_tran->countAllStaffpcsAmount($formdata); if (empty($trans)) { $trans = array('err' => 1, 'msg' => 'មិនទាន់មានទន្និន័យនូវឡើយទេ!'); } $this->view->rpt_list = $trans; $this->view->curr_type = $this->curr_typesimble; $usr_mod = new Application_Model_DbTable_DbUsers(); $user_list = $usr_mod->getUserListSelect(); array_unshift($user_list, array('id' => '-1', "name" => "ជ្រើសរើសឈ្មោះបុគ្គលិក")); $this->view->users = $user_list; $session_user = new Zend_Session_Namespace('auth'); $this->view->user_name = $session_user->last_name . ' ' . $session_user->first_name; } catch (Exception $e) { } }
public function balanceAction() { $session_user = new Zend_Session_Namespace('auth'); $b = new Application_Model_DbTable_DbCapital(); $user_id = $session_user->user_id; if ($this->getRequest()->isPost()) { $formdata = $this->getRequest()->getPost(); $user_id = $formdata['user_id']; if ($formdata['actions'] == "add_capital") { //$b->addBalanceByUser($user_id, $formdata); } } $cp_db = new Application_Model_DbTable_DbCapital(); $rs_d = $cp_db->DetechCapitalExist($user_id, 1, null); //check if add capital exist $rs_b = $cp_db->DetechCapitalExist($user_id, 2, null); //check if add capital exist $rs_r = $cp_db->DetechCapitalExist($user_id, 3, null); //check if add capital exist $total_balance = array('dollar' => empty($rs_d) ? 0 : $rs_d['amount'], 'baht' => empty($rs_b) ? 0 : $rs_b['amount'], 'riel' => empty($rs_r) ? 0 : $rs_r['amount']); $balance = $b->getCurrentBallancesByCurrentUser($user_id); $arr_img = array(); foreach ($balance as $key => $val) { if ($key == 'dollar') { $k = 'dollar'; } elseif ($key == 'bath') { $k = 'baht'; } else { $k = 'riel'; } if ($total_balance[$k] > $val) { $arr_img[$k] = array('amount' => $total_balance[$k] - $val, 'img' => 'up'); } elseif ($total_balance[$k] < $val) { $arr_img[$k] = array('amount' => $val - $total_balance[$k], 'img' => 'down'); } else { $arr_img[$k] = array('amount' => 0, 'img' => ''); } } $usr_mod = new Application_Model_DbTable_DbUsers(); $this->view->users = $usr_mod->getUserListSelect(); $this->view->balance = $balance; $this->view->total_balance = $total_balance; $this->view->img = $arr_img; $this->view->user_id = $user_id; }
public function indexAction() { try { $db_tran = new Application_Model_DbTable_Dbpsc(); //create sesesion $session_capital = new Zend_Session_Namespace('search_capital'); if (empty($session_capital->limit)) { $session_capital->limit = Application_Form_FrmNavigation::getLimit(); $session_capital->type_money = -1; $session_capital->staff_name = -1; $session_capital->from_date = date('Y-m-d'); $session_capital->to_date = date('Y-m-d'); $session_capital->lock(); } //start page nevigation $limit = $session_capital->limit; $start = $this->getRequest()->getParam('limit_satrt', 0); $this->view->from_date = $session_capital->from_date; $this->view->to_date = $session_capital->to_date; $this->view->staff = $session_capital->staff; $cur = new Application_Model_DbTable_DbCurrencies(); $this->view->currencylist = $cur->getCurrencyList(); $this->view->type_money = $session_capital->type_money; if ($this->getRequest()->isPost()) { $formdata = $this->getRequest()->getPost(); $session_capital->unlock(); $session_capital->limit = $formdata['rows_per_page']; $session_capital->type_money = $formdata['type_money']; $session_capital->staff_name = $formdata['staff_name']; $session_capital->from_date = $formdata['from_date']; $session_capital->to_date = $formdata['to_date']; $session_capital->lock(); $this->view->type_money = $formdata['type_money']; $this->view->staff_name = $formdata['staff_name']; $this->view->from_date = $session_capital->from_date; $this->view->to_date = $session_capital->to_date; $limit = $session_capital->limit; } else { $formdata = array('from_date' => $session_capital->from_date, 'to_date' => $session_capital->to_date, 'type_money' => $session_capital->type_money, 'staff_name' => $session_capital->staff_name); } $trans = $db_tran->getPscAmountListBy($formdata, $start, $limit); $record_count = $db_tran->getAllPscList($formdata); $result = array(); $row_num = $start; if (!empty($trans)) { foreach ($trans as $i => $tran) { $expired = ''; $is_expired = 0; $volum = Application_Model_DbTable_DbGlobal::CurrencyOption($tran['currency_type'], $tran['volum']); $result[$i] = array('num' => ++$row_num, 'id' => $tran['id'], 'staff_name' => $tran['staff_name'], 'currency_type' => $this->curr_type[$tran['currency_type']], 'volum' => number_format($volum) . ' ' . $this->curr_type[$tran['currency_type']], 'psc_amount' => $tran['psc_amount'] . " សន្លឹក", 'total_amount' => number_format($volum * $tran['psc_amount']) . ' ' . $this->curr_type[$tran['currency_type']], 'note' => $tran['note'], 'date' => date_format(date_create($tran['date']), "d/m/Y"), 'img' => $tran['id']); } } else { $result = array('err' => 1, 'msg' => 'មិនទាន់មានទន្និន័យនូវឡើយទេ!'); } $this->view->tranlist = Zend_Json::encode($result); $page = new Application_Form_FrmNavigation(self::REDIRECT_URL, $start, $limit, $record_count); $page->init(self::REDIRECT_URL, $start, $limit, $record_count); $this->view->nevigation = $page->navigationPage(); $this->view->rows_per_page = $page->getRowsPerPage($limit, 'frmlist_mt'); $this->view->result_row = $page->getResultRows(); $usr_mod = new Application_Model_DbTable_DbUsers(); $user_list = $usr_mod->getUserListSelect(); array_unshift($user_list, array('id' => '-1', "name" => "ជ្រើសរើសឈ្មោះបុគ្គលិក")); $this->view->users = $user_list; $session_user = new Zend_Session_Namespace('auth'); $this->view->user_name = $session_user->last_name . ' ' . $session_user->first_name; $db_keycode = new Application_Model_DbTable_DbKeycode(); $this->view->keycode = $db_keycode->getKeyCodeMiniInv(); $this->view->rpt_list = $db_tran->countAllStaffpcsAmount($formdata); $this->view->curr_type = $this->curr_typesimble; } catch (Exception $e) { } }
public function changepasswordAction() { // action body if ($this->getRequest()->isPost()) { $session_user = new Zend_Session_Namespace('auth'); $pass_data = $this->getRequest()->getPost(); if ($pass_data['password'] == $session_user->pwd) { $db_user = new Application_Model_DbTable_DbUsers(); try { $db_user->changePassword($pass_data['new_password'], $session_user->user_id); $session_user->unlock(); $session_user->pwd = $pass_data['new_password']; $session_user->lock(); Application_Form_FrmMessage::Sucessfull('ពាក្យសំងាត់នាពេលបច្ចុប្បន្ន កែប្រែ ជោគជ័យ', self::REDIRECT_URL); } catch (Exception $e) { Application_Form_FrmMessage::message('ពាក្យសំងាត់នាពេលបច្ចុប្បន្ន កែប្រែ មិន ជោគជ័យ'); } } else { Application_Form_FrmMessage::message('ពាក្យសំងាត់នាពេលបច្ចុប្បន្ន មិនត្រឹមត្រូវ'); } } }
public function changepasswordAction() { // action body if ($this->getRequest()->isPost()) { $session_user = new Zend_Session_Namespace('auth'); $pass_data = $this->getRequest()->getPost(); if ($pass_data['password'] == $session_user->pwd) { $db_user = new Application_Model_DbTable_DbUsers(); try { $db_user->changePassword($pass_data['new_password'], $session_user->user_id); $session_user->unlock(); $session_user->pwd = $pass_data['new_password']; $session_user->lock(); Application_Form_FrmMessage::Sucessfull('ការផ្លាស់ប្�ូរដោយជោគជ�យ', self::REDIRECT_URL); } catch (Exception $e) { Application_Form_FrmMessage::message('ការផ្លាស់ប្�ូរ�្រូវបរាជ�យ'); } } else { Application_Form_FrmMessage::message('ការផ្លាស់ប្�ូរ�្រូវបរាជ�យ'); } } }