public function editpopupAction()
 {
     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');
     $userid = $this->getRequest()->getParam('unitId');
     if ($id == '') {
         $id = $loginUserId;
     }
     // For open the form in popup...
     $empjobhistoryform = new Default_Form_empjobhistory();
     $empjobhistoryModel = new Default_Model_Empjobhistory();
     $employeeModel = new Default_Model_Employee();
     $positionModel = new Default_Model_Positions();
     $departmentModel = new Default_Model_Departments();
     $jobtitleModel = new Default_Model_Jobtitles();
     $clientsModel = new Timemanagement_Model_Clients();
     if ($id) {
         $employeeArr = $employeeModel->getActiveEmployeeData($userid);
         if (!empty($employeeArr)) {
             if (isset($employeeArr[0]['businessunit_id']) && $employeeArr[0]['businessunit_id'] != '') {
                 $departmentArr = $departmentModel->getDepartmentList($employeeArr[0]['businessunit_id']);
                 if (!empty($departmentArr)) {
                     $empjobhistoryform->department->addMultiOption('', 'Select Department');
                     foreach ($departmentArr as $departmentres) {
                         $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']);
                     }
                 }
             } else {
                 $departmentArr = $departmentModel->getTotalDepartmentList();
                 if (!empty($departmentArr)) {
                     $empjobhistoryform->department->addMultiOption('', 'Select Department');
                     foreach ($departmentArr as $departmentres) {
                         $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']);
                     }
                 }
             }
         }
         $positionArr = $positionModel->getTotalPositionList();
         if (!empty($positionArr)) {
             $empjobhistoryform->positionheld->addMultiOption('', 'Select Position');
             foreach ($positionArr as $positionres) {
                 $empjobhistoryform->positionheld->addMultiOption($positionres['id'], $positionres['positionname']);
             }
         }
         $jobtitleArr = $jobtitleModel->getJobTitleList();
         if (!empty($jobtitleArr)) {
             $empjobhistoryform->jobtitleid->addMultiOption('', 'Select Job Title');
             foreach ($jobtitleArr as $jobtitleres) {
                 $empjobhistoryform->jobtitleid->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
             }
         }
         $clientsArr = $clientsModel->getActiveClientsData();
         if (!empty($clientsArr)) {
             $empjobhistoryform->client->addMultiOption('', 'Select a Client');
             foreach ($clientsArr as $clientsres) {
                 $empjobhistoryform->client->addMultiOption($clientsres['id'], $clientsres['client_name']);
             }
         }
         $data = $empjobhistoryModel->getsingleEmpJobHistoryData($id);
         if (!empty($data)) {
             $empjobhistoryform->populate($data[0]);
             $empjobhistoryform->setDefault('department', $data[0]['department']);
             $empjobhistoryform->setDefault('positionheld', $data[0]['positionheld']);
             $empjobhistoryform->setDefault('jobtitleid', $data[0]['jobtitleid']);
             $empjobhistoryform->setDefault('client', $data[0]['client_id']);
             if (isset($data[0]['start_date']) && $data[0]['start_date'] != '') {
                 $start_date = sapp_Global::change_date($data[0]['start_date'], 'view');
                 $empjobhistoryform->start_date->setValue($start_date);
             }
             if (isset($data[0]['end_date']) && $data[0]['end_date'] != '') {
                 $end_date = sapp_Global::change_date($data[0]['end_date'], 'view');
                 $empjobhistoryform->end_date->setValue($end_date);
             }
         }
     }
     $empjobhistoryform->setAttrib('action', BASE_URL . 'empjobhistory/editpopup/unitId/' . $userid);
     $this->view->form = $empjobhistoryform;
     $this->view->controllername = 'empjobhistory';
     if ($this->getRequest()->getPost()) {
         $result = $this->save($empjobhistoryform, $userid);
         $this->view->msgarray = $result;
     }
 }