public function addpopupAction()
 {
     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');
     $msgarray = array();
     $controllername = 'servicedeskdepartment';
     $servicedeskdepartmentform = new Default_Form_servicedeskdepartment();
     $servicedeskdepartmentmodel = new Default_Model_Servicedeskdepartment();
     $servicedeskdepartmentform->setAction(DOMAIN . 'servicedeskdepartment/addpopup');
     if ($this->getRequest()->getPost()) {
         if ($servicedeskdepartmentform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $service_desk_name = $this->_request->getParam('service_desk_name');
             $description = $this->_request->getParam('description');
             $menumodel = new Default_Model_Menu();
             $actionflag = '';
             $tableid = '';
             $data = array('service_desk_name' => $service_desk_name, 'description' => $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 = $servicedeskdepartmentmodel->SaveorUpdateServiceDeskDepartmentData($data, $where);
             $tableid = $Id;
             $menuidArr = $menumodel->getMenuObjID('/servicedeskdepartment');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $servicedeskdepartmentData = $servicedeskdepartmentmodel->getSDDepartmentData();
             $opt = '';
             foreach ($servicedeskdepartmentData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], utf8_encode($record['service_desk_name']));
             }
             $this->view->departmentData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $servicedeskdepartmentform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->controllername = $controllername;
     $this->view->form = $servicedeskdepartmentform;
     $this->view->ermsg = '';
     $this->render('form');
 }
예제 #2
0
 public function savecategoryAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('savecategory', 'json')->initContext();
     $this->_helper->layout->disableLayout();
     $auth = Zend_Auth::getInstance();
     $date = new Zend_Date();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $result['result'] = '';
     $result['id'] = '';
     $result['service_desk_name'] = '';
     $result['description'] = '';
     $servicedeskdepartmentmodel = new Default_Model_Servicedeskdepartment();
     try {
         $service_desk_name = trim($this->_request->getParam('category'));
         $description = $this->_request->getParam('description');
         $isCategoryExist = $servicedeskdepartmentmodel->checkDuplicateCategoryName($service_desk_name);
         if (!empty($isCategoryExist)) {
             if ($isCategoryExist[0]['count'] > 0) {
                 $result['msg'] = 'Category name already exists.';
                 $result['id'] = '';
                 $result['unitname'] = '';
                 $result['address'] = '';
             } else {
                 $menumodel = new Default_Model_Menu();
                 $actionflag = '';
                 $tableid = '';
                 $data = array('service_desk_name' => $service_desk_name, 'description' => $description != '' ? trim($description) : NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where = '';
                 $actionflag = 1;
                 $Id = $servicedeskdepartmentmodel->SaveorUpdateServiceDeskDepartmentData($data, $where);
                 if ($Id) {
                     $menuID = SERVICEDESKDEPARTMENT;
                     $logresult = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id);
                     $result['msg'] = 'success';
                     $result['id'] = $Id;
                     $result['service_desk_name'] = $service_desk_name;
                     $result['description'] = $description;
                 } else {
                     $result['msg'] = 'error';
                     $result['id'] = '';
                     $result['service_desk_name'] = '';
                     $result['description'] = '';
                 }
             }
         }
     } catch (Exception $e) {
         $result['msg'] = $e->getMessage();
         $result['id'] = '';
         $result['service_desk_name'] = '';
         $result['description'] = '';
     }
     $this->_helper->json($result);
 }