コード例 #1
0
 public function addpopupAction()
 {
     $screenFlag = "";
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     if ($this->getRequest()->getParam('screenflag')) {
         $screenFlag = $this->getRequest()->getParam('screenflag');
     }
     $boxid = $this->_getParam('boxid', null);
     $fromcontroller = $this->_getParam('fromcontroller', null);
     $msgarray = array();
     $controllername = 'employmentstatus';
     $employmentstatusform = new Default_Form_employmentstatus();
     $employmentstatusmodel = new Default_Model_Employmentstatus();
     $employmentstatusform->setAction(BASE_URL . 'employmentstatus/addpopup');
     $activeEmploymentStatusArr = $employmentstatusmodel->getEmploymentStatuslist();
     $newarr = array();
     $empstatusstr = '';
     if (!empty($activeEmploymentStatusArr)) {
         for ($i = 0; $i < sizeof($activeEmploymentStatusArr); $i++) {
             $newarr1[] = $activeEmploymentStatusArr[$i]['workcodename'];
         }
         if ($screenFlag == 'add') {
             array_push($newarr1, 8, 9, 10);
         }
         $empstatusstr = implode(",", $newarr1);
     }
     if ($empstatusstr != '') {
         $statusArr = $employmentstatusmodel->getStatuslist($empstatusstr);
     } else {
         $statusArr = $employmentstatusmodel->getCompleteStatuslist();
     }
     if (!empty($statusArr)) {
         $employmentstatusform->workcodename->addMultiOption('', 'Select Work Code');
         for ($i = 0; $i < sizeof($statusArr); $i++) {
             if ($fromcontroller == 'requisition') {
                 if (!in_array($statusArr[$i]['id'], array(5, 7, 8, 9, 10))) {
                     $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
                 }
             } else {
                 $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
             }
         }
     }
     $this->view->statusArr = $statusArr;
     $this->view->ermsg = '';
     if ($this->getRequest()->getPost()) {
         if ($employmentstatusform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $workcode = $this->_request->getParam('workcode');
             $workcodename = $this->_request->getParam('workcodename');
             $default_leaves = $this->_request->getParam('default_leaves');
             $description = $this->_request->getParam('description');
             $screenFlag = $this->getRequest()->getParam('screenflag');
             $date = new Zend_Date();
             $actionflag = '';
             $tableid = '';
             $data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id != '') {
                 $where = array('id=?' => $id);
                 $actionflag = 2;
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $where = '';
                 $actionflag = 1;
             }
             $Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($data, $where);
             $tableid = $Id;
             $menuID = EMPLOYMENTSTATUS;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
             if (isset($_POST['fromcontroller']) && $_POST['fromcontroller'] != '') {
                 $fromcontroller = $_POST['fromcontroller'];
             }
             if (isset($_POST['boxid']) && $_POST['boxid'] != '') {
                 $boxid = $_POST['boxid'];
             }
         } else {
             $messages = $employmentstatusform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $opt = '';
     if ($fromcontroller == '') {
         if ($screenFlag == 'edit') {
             $empstatusData = $employmentstatusmodel->getempstatuslist();
         }
         if ($screenFlag == 'add') {
             $empstatusData = $employmentstatusmodel->getempstatusActivelist();
         }
         if (!empty($empstatusData)) {
             foreach ($empstatusData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['workcodename'], $record['statusname']);
             }
         }
     } else {
         if ($fromcontroller == 'requisition') {
             $requi_model = new Default_Model_Requisition();
             $empstatusData = $requi_model->getStatusOptionsForRequi();
             foreach ($empstatusData as $stat_id => $stat_name) {
                 $opt .= sapp_Global::selectOptionBuilder($stat_id, $stat_name);
             }
         }
     }
     $this->view->empstatusData = $opt;
     $this->view->screenFlag = $screenFlag;
     $this->view->controllername = $controllername;
     $this->view->form = $employmentstatusform;
     $this->view->ermsg = '';
     $this->view->boxid = $boxid;
     $this->view->fromcontroller = $fromcontroller;
 }