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');
         }
     }
 }
示例#2
0
 public function indexAction()
 {
     // action body
     $this->_helper->layout()->disableLayout();
     /* set this to login page to change the character charset of browsers to Utf-8  ...*/
     $this->_helper->layout()->disableLayout();
     $form = new Application_Form_FrmLogin();
     $form->setAction('index');
     $form->setMethod('post');
     $form->setAttrib('accept-charset', 'utf-8');
     $this->view->form = $form;
     $key = new Application_Model_DbTable_DbKeycode();
     $this->view->data = $key->getKeyCodeMiniInv(TRUE);
     if ($this->getRequest()->isPost()) {
         $formdata = $this->getRequest()->getPost();
         if ($form->isValid($formdata)) {
             $session_lang = new Zend_Session_Namespace('lang');
             $session_lang->lang_id = $formdata["lang"];
             //for creat session
             Application_Form_FrmLanguages::getCurrentlanguage($session_lang->lang_id);
             //for choose lang for when login
             $user_name = $form->getValue('txt_user_name');
             $password = $form->getValue('txt_password');
             $db_user = new Application_Model_DbTable_DbUsers();
             if ($db_user->userAuthenticate($user_name, $password)) {
                 // 					$this->view->msg = 'Authentication Sucessful!';
                 // 					$this->view->err="0";
                 $session_user = new Zend_Session_Namespace('auth');
                 $user_id = $db_user->getUserID($user_name);
                 $user_info = $db_user->getUserInfo($user_id);
                 $arr_acl = $db_user->getArrAcl($user_info['user_type']);
                 $session_user->user_id = $user_id;
                 $session_user->user_name = $user_name;
                 $session_user->pwd = $password;
                 $session_user->level = $user_info['user_type'];
                 $session_user->last_name = $user_info['last_name'];
                 $session_user->first_name = $user_info['first_name'];
                 $session_user->theme_style = $db_user->getThemeByUserId($user_id);
                 $a_i = 0;
                 $arr_actin = array();
                 for ($i = 0; $i < count($arr_acl); $i++) {
                     $arr_module[$i] = $arr_acl[$i]['module'];
                     if ($arr_acl[$i]['module'] == 'exchange') {
                         if ($arr_acl[$i]['action'] == "index" || $arr_acl[$i]['action'] == "add" || $arr_acl[$i]['action'] == "edited") {
                             continue;
                         }
                         $arr_actin[$a_i++] = $arr_acl[$i]['action'];
                     }
                 }
                 $arr_module = $this->sortMenu($arr_module);
                 // 					print_r($arr_module); exit;
                 $session_user->arr_acl = $arr_acl;
                 $session_user->arr_module = $arr_module;
                 $session_user->arr_actin = $arr_actin;
                 $session_user->lock();
                 $log = new Application_Model_DbTable_DbUserLog();
                 $log->insertLogin($user_id);
                 foreach ($arr_module as $i => $d) {
                     if ($d !== 'user') {
                         $url = '/' . @$arr_module[2];
                     } else {
                         $url = self::REDIRECT_URL;
                         break;
                     }
                 }
                 Application_Form_FrmMessage::redirectUrl("/home");
             } else {
                 $this->view->msg = 'ឈ្មោះ​អ្នក​ប្រើ​ប្រាស់ និង ពាក្យ​​សំងាត់ មិន​ត្រឺម​ត្រូវ​ទេ ';
             }
         } else {
             $this->view->msg = 'លោកអ្នកមិនមានសិទ្ធិប្រើប្រាស់ទេ!';
         }
     }
 }
示例#3
0
 public function indexAction()
 {
     // action body
     /* set this to login page to change the character charset of browsers to Utf-8  ...*/
     $this->_helper->layout()->disableLayout();
     $form = new Application_Form_FrmLogin();
     $form->setAction('index');
     $form->setMethod('post');
     $form->setAttrib('accept-charset', 'utf-8');
     $this->view->form = $form;
     $key = new Application_Model_DbTable_DbKeycode();
     $this->view->data = $key->getKeyCodeMiniInv(TRUE);
     $session_user = new Zend_Session_Namespace('auth');
     //redirect page if web broswer still have session
     if (!empty($session_user->arr_module)) {
         foreach ($session_user->arr_module as $i => $d) {
             if ($d !== 'transfer') {
                 $url = '/' . $session_user->arr_module[0];
             } else {
                 $url = self::REDIRECT_URL;
                 break;
             }
         }
         Application_Form_FrmMessage::redirectUrl($url);
         exit;
     }
     if ($this->getRequest()->isPost()) {
         $formdata = $this->getRequest()->getPost();
         if ($form->isValid($formdata)) {
             $db_user = new Application_Model_DbTable_DbUsers();
             $user_name = $form->getValue('txt_user_name');
             $password = $form->getValue('txt_password');
             if ($db_user->userAuthenticate($user_name, $password)) {
                 $db_access = new Application_Model_DbTable_DbAmountPC();
                 $pc_name = strtolower(gethostname());
                 $amount_pc = $db_access->pcAccess($pc_name, 4);
                 // Validate number of user login,params 4 amount of pc limit login
                 if ($amount_pc == true) {
                     //for check user access of using system
                     $user_id = $db_user->getUserID($user_name);
                     $user_info = $db_user->getUserInfo($user_id);
                     $arr_acl = $db_user->getArrAcl($user_info['user_type']);
                     $session_user->user_id = $user_id;
                     $session_user->user_name = $user_name;
                     $session_user->pwd = $password;
                     $session_user->level = $user_info['user_type'];
                     $session_user->last_name = $user_info['last_name'];
                     $session_user->first_name = $user_info['first_name'];
                     $a_i = 0;
                     $arr_actin = array();
                     for ($i = 0; $i < count($arr_acl); $i++) {
                         $arr_module[$i] = $arr_acl[$i]['module'];
                         if ($arr_acl[$i]['module'] == 'exchange') {
                             if ($arr_acl[$i]['action'] == "index" || $arr_acl[$i]['action'] == "add" || $arr_acl[$i]['action'] == "edited") {
                                 continue;
                             }
                             $arr_actin[$a_i++] = $arr_acl[$i]['action'];
                         }
                     }
                     $arr_module = $this->sortMenu($arr_module);
                     $session_user->arr_acl = $arr_acl;
                     $session_user->arr_module = $arr_module;
                     $session_user->arr_actin = $arr_actin;
                     $session_user->lock();
                     $log = new Application_Model_DbTable_DbUserLog();
                     $log->insertLogin($user_id);
                     // Check expired date of transactions.
                     // 					$db_mt = new Application_Model_DbTable_DbMoneyTransactions();
                     // 					$db_mt->checkExpired();
                     foreach ($arr_module as $i => $d) {
                         if ($d !== 'transfer') {
                             $url = '/' . $arr_module[0];
                         } else {
                             $url = self::REDIRECT_URL;
                             break;
                         }
                     }
                     Application_Form_FrmMessage::redirectUrl($url);
                     exit;
                 } else {
                     //if over amount of PC​
                     $this->view->msg = 'ការប្រើប្រាស់លើសចំនួនកំណត់!';
                 }
             } else {
                 $this->view->msg = 'ឈ្មោះ​អ្នក​ប្រើ​ប្រាស់ និង ពាក្យ​​សំងាត់ មិន​ត្រឺម​ត្រូវ​ទេ';
             }
         } else {
             $this->view->msg = 'សូម​ទំនាក់​ទំនង​ជាមួយ​នឹង​ អ្នក​គ្រប់​គ្រងរបស់អ្នក​អំពី​បញ្ហានេះ';
         }
     }
 }
示例#4
0
 public function indexAction()
 {
     // action body
     $this->_helper->layout()->disableLayout();
     /* set this to login page to change the character charset of browsers to Utf-8  ...*/
     $this->_helper->layout()->disableLayout();
     $form = new Application_Form_FrmLogin();
     $form->setAction('index');
     $form->setMethod('post');
     $form->setAttrib('accept-charset', 'utf-8');
     $this->view->form = $form;
     $key = new Application_Model_DbTable_DbKeycode();
     $this->view->data = $key->getKeyCodeMiniInv(TRUE);
     if ($this->getRequest()->isPost()) {
         $formdata = $this->getRequest()->getPost();
         if ($form->isValid($formdata)) {
             $session_lang = new Zend_Session_Namespace('lang');
             $session_lang->lang_id = $formdata["lang"];
             //for creat session
             Application_Form_FrmLanguages::getCurrentlanguage($session_lang->lang_id);
             //for choose lang for when login
             $user_name = $form->getValue('txt_user_name');
             $password = $form->getValue('txt_password');
             $db_user = new Application_Model_DbTable_DbUsers();
             if ($db_user->userAuthenticate($user_name, $password)) {
                 // 					$this->view->msg = 'Authentication Sucessful!';
                 // 					$this->view->err="0";
                 $session_user = new Zend_Session_Namespace('auth');
                 $user_id = $db_user->getUserID($user_name);
                 $user_info = $db_user->getUserInfo($user_id);
                 $arr_acl = $db_user->getArrAcl($user_info['user_type']);
                 $session_user->user_id = $user_id;
                 $session_user->user_name = $user_name;
                 $session_user->pwd = $password;
                 $session_user->level = $user_info['user_type'];
                 $session_user->last_name = $user_info['last_name'];
                 $session_user->first_name = $user_info['first_name'];
                 $session_user->theme_style = $db_user->getThemeByUserId($user_id);
                 $a_i = 0;
                 $arr_actin = array();
                 // 					print_r($arr_acl);
                 for ($i = 0; $i < count($arr_acl); $i++) {
                     $arr_module[$i] = $arr_acl[$i]['module'];
                     // 						if($arr_acl[$i]['module'] == 'exchange'){
                     // 							if($arr_acl[$i]['action'] == "index" || $arr_acl[$i]['action'] == "add" || $arr_acl[$i]['action'] == "edit" ) {
                     // 								continue;
                     // 							}
                     $arr_actin[$a_i++] = $arr_acl[$i]['module'] . '/' . $arr_acl[$i]['controller'] . '/' . $arr_acl[$i]['action'];
                     // 						}
                 }
                 // 					print_r($arr_actin);exit();
                 $arr_module = array_unique($arr_module);
                 $arr_actin = array_unique($arr_actin);
                 // 					print_r($arr_module);	echo "<br />============<br />";
                 $arr_module = $this->sortMenu($arr_module);
                 // 					print_r($arr_module);exit();
                 // 					print_r($arr_module); exit;
                 $session_user->arr_acl = $arr_acl;
                 $session_user->arr_module = $arr_module;
                 $session_user->arr_actin = $arr_actin;
                 $session_user->lock();
                 $log = new Application_Model_DbTable_DbUserLog();
                 $log->insertLogin($user_id);
                 foreach ($arr_module as $i => $d) {
                     if ($d !== 'user') {
                         $url = '/' . @$arr_module[2];
                     } else {
                         $url = self::REDIRECT_URL;
                         break;
                     }
                 }
                 Application_Form_FrmMessage::redirectUrl("/home");
             } else {
                 $this->view->msg = 'ឈ្មោះ​អ្នក​ប្រើ​ប្រាស់ និង ពាក្យ​​សំងា�់ មិន​�្រឺម​�្រូវ​ទ� ';
             }
         } else {
             $this->view->msg = 'លោកអ្នកមិនមានសិទ្ធិប្រើប្រាស់ទ�!';
         }
     }
 }