Ejemplo n.º 1
0
 function init()
 {
     $auth = Zend_Auth::getInstance();
     $this->_userInfo = $auth->getIdentity();
     $this->_dirApp = Zend_Registry::get('dirApp')->toArray();
     $this->view = Myapp_View_Smarty::getInstance();
     $this->view->setView($this->_dirApp['template_front'] . $this->_dirApp['style'] . '/');
     $smarty = $this->view->getEngine();
     $smarty->compile_dir = $this->_dirApp['template_front_cache'];
     $viewRenderer = $this->_helper->getHelper('viewRenderer');
     $viewRenderer->setView($this->view)->setViewBasePathSpec($smarty->template_dir)->setViewScriptPathSpec(':controller/:action.:suffix')->setViewScriptPathNoControllerSpec(':action.:suffix')->setViewSuffix($this->_dirApp['template_extension']);
     $this->_base_url = $this->_dirApp['base_url'];
     $this->view->assign('base_url', $this->_base_url);
     $this->view->assign('base_tpl', $this->_dirApp['base_tpl']);
     $this->_model = Front_Model_General::getInstance();
     $this->_module = $this->_getParam('module');
     $this->_control = $this->_getParam('controller');
     $action = $this->_getParam('action');
     $this->view->assign('form', array('module' => $this->_module, 'control' => $this->_control, 'action' => $action, 'lang' => $_SESSION['lang']));
     $this->_lable = Zend_Registry::get('lable');
     $this->view->assign('lable', $this->_lable);
     if (empty($this->_userInfo->adminId)) {
         $this->_redirect($this->_base_url . 'login/');
     }
     if ($this->_userInfo->adminId != '') {
         $file_name = $this->_dirApp['dir_auth'] . $this->_userInfo->adminLogin . '.ini';
         $sessionAuth = Myapp_File_Createauth::getInstance()->compareSession($file_name);
         if ($sessionAuth == true) {
             $this->_redirect($this->_base_url . 'logout/');
         }
     }
     $this->view->assign('userInfo', $this->_userInfo);
 }
Ejemplo n.º 2
0
 function step8Action()
 {
     $general = Front_Model_General::getInstance();
     $general->_type = "'job_title','paygrade','pay_frequency'";
     $select_box = $general->selectAllItems();
     $this->view->assign('select_box', $select_box);
     //     	echo '<pre>';
     //     	print_r($select_box);
     //     	echo '<pre>';
     $paygrade = $select_box['items']['paygrade'];
     $this->view->assign('paygrade', $select_box['items']['paygrade']);
     $pay_frequency = $select_box['items']['pay_frequency'];
     $this->view->assign('pay_frequency', $pay_frequency);
     $creat_login_account = $this->_getParam('creat_login_account');
     $this->view->assign('creat_login_account', $creat_login_account);
     $this->view->assign('breadcrumb', $this->_lable['add']['value'] . ' ' . $this->_lable['admin']['value']);
     $id = $this->_getParam('id');
     $option = $this->_getParam('option');
     $salary_id = $this->_getParam('sub');
     $sub_option = $this->_getParam('sub_option');
     $step = 8;
     $option = empty($option) ? 'add' : $option;
     $this->view->assign('id', $id);
     $this->view->assign('option', $option);
     $this->view->assign('step', $step);
     $this->view->assign('sub', $salary_id);
     $this->view->assign('sub_option', $sub_option);
     $countries = $this->_model->country();
     $this->view->assign('countries', $countries);
     // Remove physical database
     if ($salary_id != '' && $sub_option == 'del') {
         // delete
         // panpic_emp_salary
         // panpic_emp_directdebit
         $account = $this->_model->editDirectdebit($salary_id);
         $emp_directdebit_id = $account['id'];
         $del_status = $this->_model->deleteStep8($salary_id, $emp_directdebit_id);
         if ($del_status) {
             $this->view->assign('alert', 'success');
             $this->view->assign('msg', $this->_lable['delete_succ']['value']);
         } else {
             $this->view->assign('alert', 'danger');
             $this->view->assign('msg', $this->_lable['delete_fail']['value']);
         }
         $this->_helper->viewRenderer('step8');
         header("refresh:" . $this->_lable['timewait']['value'] . ";url=" . $this->_base_url . $this->_control . "/step8/?id={$id}");
         return;
     }
     $emp_salary = '';
     $account = '';
     $currencys = '';
     if ($salary_id != '' && $sub_option == 'edit') {
         // load salary panpic_emp_salary()
         $emp_salary = $this->_model->editSalary($salary_id);
         $account = $this->_model->editDirectdebit($salary_id);
         $pay_grade_id = $emp_salary[paygrades_id];
         $currencys = $this->_model->getCurrency($pay_grade_id);
         $emp_salary['basic_salary'] = $emp_salary['basic_salary'] + 0;
         $emp_salary['account_amount'] = $emp_salary['account_amount'] + 0;
     }
     //     	echo '<pre>';
     //     	print_r( $select_box['items']['paygrade'] );
     //     	echo '</pre>';
     $this->view->assign('data', $emp_salary);
     $this->view->assign('account', $account);
     $this->view->assign('currencys', $currencys);
     //list Salary
     $salary = $this->_model->getSalary($id);
     $this->view->assign('salary', $salary);
     $cbx = new Zend_Config_Ini(APPLICATION_PATH . '/configs/general.ini', 'SETTING');
     $preset_general = $cbx->toArray();
     $immigration = $preset_general['immigration'];
     $this->view->assign('immigration', $immigration);
     //print_r($immigration);
     if ($id == '') {
         $this->view->assign('msg', $this->_lable['url_invalid']['value']);
         $this->_helper->viewRenderer('step');
         header("refresh:" . $this->_lable['timewait']['value'] . ";url=" . $this->_base_url . $this->_control . "/step1/");
         return;
     }
     $this->_model->emp_id = $id;
     $tb_employee = $this->_model->employee();
     $this->view->assign('tb_employee', $tb_employee);
     $general = Front_Model_General::getInstance();
     $general->_type = "'relation'";
     $select_box = $general->getSomeFieldsTime();
     $this->view->assign('select_box', $select_box);
     if ($this->_request->isPost()) {
         $data = $this->_getParam('data');
         $this->view->assign('data', $data);
         $account = $this->_getParam('account');
         $this->view->assign('account', $account);
         $emp_salary = array('emp_number' => $this->_model->emp_id, 'paygrades_id' => $data['paygrades_id'], 'payperiod_code' => $data['payperiod_code'], 'currency_id' => $data['currency_id'], 'basic_salary' => $data['basic_salary'], 'salary_component' => $data['salary_component'], 'comments' => $data['comments']);
         if ($creat_login_account == 1) {
             $emp_directdebit = array('account_number' => $account['account_number'], 'account_name' => $account['account_name'], 'account_bank' => $account['account_bank'], 'account_amount' => $account['account_amount']);
         } else {
             $emp_directdebit = "";
         }
         $this->_model->emp_id = $id;
         if ($salary_id != '' && $sub_option == 'edit') {
             // truong hop Update
             $update = $this->_model->updateStep8($emp_salary, $emp_directdebit, $salary_id);
             if ($update) {
                 $this->view->assign('alert', 'success');
                 $this->view->assign('msg', $this->_lable['update_succ']['value']);
                 $this->_helper->viewRenderer('step8');
                 header("refresh:" . $this->_lable['timewait']['value'] . ";url=" . $this->_base_url . $this->_control . "/step8/?id={$id}");
                 return;
             } else {
                 $this->view->assign('alert', 'danger');
                 $this->view->assign('msg', $this->_lable['update_fail']['value']);
                 $this->view->assign('data', $data);
                 $this->_helper->viewRenderer('step8');
                 return;
             }
         } else {
             //insert
             $insert = $this->_model->insertStep8($emp_salary, $emp_directdebit);
             if ($insert) {
                 $this->view->assign('alert', 'success');
                 $this->view->assign('msg', $this->_lable['update_succ']['value']);
                 $this->_helper->viewRenderer('step8');
                 header("refresh:" . $this->_lable['timewait']['value'] . ";url=" . $this->_base_url . $this->_control . "/step9/?id={$id}");
                 return;
             } else {
                 $this->view->assign('alert', 'danger');
                 $this->view->assign('msg', $this->_lable['update_fail']['value']);
                 $this->view->assign('data', $data);
                 $this->_helper->viewRenderer('step8');
                 return;
             }
         }
     }
 }