Пример #1
0
 public function addpopupAction()
 {
     $msgarray = array();
     $emptyFlag = '';
     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');
     $controllername = 'clients';
     $clientsForm = new Timemanagement_Form_Clients();
     $clientsModel = new Timemanagement_Model_Clients();
     $clientsForm->setAction(BASE_URL . 'timemanagement/clients/addpopup');
     if ($this->getRequest()->getPost()) {
         if ($clientsForm->isValid($this->_request->getPost())) {
             $country_id = NULL;
             $state_id = NULL;
             $id = $this->_request->getParam('id');
             $address = $this->_request->getParam('address');
             $client_name = $this->_request->getParam('client_name');
             if ($this->_request->getParam('country_id')) {
                 $country_id = $this->_request->getParam('country_id');
             }
             $email = $this->_request->getParam('email');
             $phone_no = $this->_request->getParam('phone_no');
             $poc = $this->_request->getParam('poc');
             $fax = $this->_request->getParam('fax');
             if ($this->_request->getParam('state_id')) {
                 $state_id = $this->_request->getParam('state_id');
             }
             $date = gmdate("Y-m-d H:i:s");
             $data = array('address' => $address, 'client_name' => $client_name, 'country_id' => $country_id, 'email' => $email, 'phone_no' => $phone_no, 'poc' => $poc, 'fax' => $fax, 'state_id' => $state_id);
             $data['created_by'] = $loginUserId;
             $data['created'] = gmdate("Y-m-d H:i:s");
             $data['modified'] = gmdate("Y-m-d H:i:s");
             $data['is_active'] = 1;
             $where = '';
             $Id = $clientsModel->saveOrUpdateClientsData($data, $where);
             $clientsData = $clientsModel->fetchAll('is_active = 1', 'client_name')->toArray();
             $opt = '';
             foreach ($clientsData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['client_name']);
             }
             $this->view->clientsData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $clientsForm->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 = $clientsForm;
     $this->view->ermsg = '';
 }