Example #1
0
 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;
 }
Example #2
0
	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;
	}
Example #3
0
 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) {
     }
 }
Example #4
0
 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) {
     }
 }