/**
  * Return the option values for a number of type names
  *
  * @param Array $typenames The names of the lookup types
  * @return Array Containing the values of the lookup types
  */
 function getOptionValuesFromMultipleTypes($typenames)
 {
     // get the values for each type
     $values = array();
     foreach ($typenames as $name) {
         $this->setName($name);
         $values = array_merge_maintain_keys($values, $this->getOptionValues());
     }
     // sort the option values alphabetically
     sort($values);
     return $values;
 }
 /**
  * Add custom validation messages
  *
  * @param Array $newmessages Array containing the custom error messages, with the field name as the key and the custom error message as the value
  */
 function addCustomErrorMessages($newmessages)
 {
     $this->customerrormessages = array_merge_maintain_keys($this->customerrormessages, $newmessages);
 }
 function shiftslistsearchAction()
 {
     $this->_helper->redirector->gotoSimple("shifts", "config", $this->getRequest()->getModuleName(), array_remove_empty(array_merge_maintain_keys($this->_getAllParams(), $this->getRequest()->getQuery())));
 }
 public function newAction()
 {
     $this->_helper->redirector->gotoSimple(ACTION_INDEX, $this->getRequest()->getControllerName(), $this->getRequest()->getModuleName(), array_remove_empty(array_merge_maintain_keys($this->_getAllParams(), $this->getRequest()->getQuery())));
 }
 /**
  * Redirect list searches to maintain the urls as per zend format 
  */
 public function reportsearchAction()
 {
     // debugMessage($this->getRequest()->getQuery());
     // debugMessage($this->_getAllParams());
     $action = $this->_getParam('page');
     if (!isEmptyString($this->_getParam('pageaction'))) {
         $action = $this->_getParam('pageaction');
     }
     //exit();
     if (!isEmptyString($action)) {
         $this->_helper->redirector->gotoSimple($action, $this->getRequest()->getControllerName(), $this->getRequest()->getModuleName(), array_remove_empty(array_merge_maintain_keys($this->_getAllParams(), $this->getRequest()->getQuery())));
     }
 }
 function createAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     /* debugMessage('pms: '.ini_get('post_max_size'));
     		debugMessage('ums: '.ini_get("upload_max_filesize"));
     		$size = (int) $_SERVER['CONTENT_LENGTH']; debugMessage('content length '.$size);
     		ini_set("memory_limit", "1024M");
     		$memory_limit = ini_get('memory_limit'); debugMessage('memory is '.$memory_limit); */
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     $restoredata = objectToArray(json_decode(decode($session->getVar('restoredata'))));
     $formvalues = array_merge_maintain_keys($formvalues, $restoredata);
     // debugMessage($formvalues);
     // exit;
     // determine employees on the payroll
     $employees = array();
     $all_results_query = decode($formvalues['employeequery']);
     // debugMessage($all_results_query); exit;
     $conn = Doctrine_Manager::connection();
     $employees = $conn->fetchAll($all_results_query);
     // debugMessage($employees);
     // format payroll data
     $dataarray = array();
     $dataarray['companyid'] = getCompanyID();
     $dataarray['type'] = $formvalues['payrolltype'];
     $dataarray['status'] = $formvalues['status'];
     $dataarray['payrolldate'] = changeDateFromPageToMySQLFormat($formvalues['enddate']);
     $dataarray['url'] = $formvalues['failureurl'];
     $dataarray['startdate'] = changeDateFromPageToMySQLFormat($formvalues['startdate']);
     $dataarray['enddate'] = changeDateFromPageToMySQLFormat($formvalues['enddate']);
     $dataarray['middate'] = changeDateFromPageToMySQLFormat($formvalues['middate']);
     $dataarray['createdby'] = $session->getVar('userid');
     $dataarray['remarks'] = isArrayKeyAnEmptyString('remarks', $formvalues) ? '' : $formvalues['remarks'];
     $dataarray['ignorelist'] = $formvalues['ignorelist'];
     if (count($employees) > 0) {
         foreach ($employees as $key => $employee) {
             $dataarray['details'][$key]['userid'] = $employee['id'];
             $dataarray['details'][$key]['empstatus'] = $employee['empstatus'];
             $dataarray['details'][$key]['ratetype'] = $employee['ratetype'];
             $dataarray['details'][$key]['payrolltype'] = $employee['payrolltype'];
             $dataarray['details'][$key]['rate'] = $employee['rate'];
             $dataarray['details'][$key]['istimesheetuser'] = $employee['istimesheetuser'];
             $dataarray['details'][$key]['daysworked'] = $formvalues['daysworked_' . $employee['id']];
             $dataarray['details'][$key]['hourspending'] = $formvalues['_' . $employee['id']];
             $dataarray['details'][$key]['halfhoursworked'] = $formvalues['halfhoursworked_' . $employee['id']];
             $dataarray['details'][$key]['fullhoursworked'] = $formvalues['fullhoursworked_' . $employee['id']];
             $dataarray['details'][$key]['leavehrs'] = $formvalues['leavehrs_' . $employee['id']];
             $dataarray['details'][$key]['sickhrs'] = $formvalues['sickhrs_' . $employee['id']];
             $dataarray['details'][$key]['midgross'] = str_replace(',', '', $formvalues['midgross_' . $employee['id']]);
             $dataarray['details'][$key]['endgross'] = str_replace(',', '', $formvalues['endgross_' . $employee['id']]);
             $dataarray['details'][$key]['nssf'] = str_replace(',', '', $formvalues['nssf_' . $employee['id']]);
             $dataarray['details'][$key]['paye'] = str_replace(',', '', $formvalues['paye_' . $employee['id']]);
             $dataarray['details'][$key]['otherdebit'] = str_replace(',', '', $formvalues['otherdebit_' . $employee['id']]);
             $dataarray['details'][$key]['netearning'] = str_replace(',', '', $formvalues['netearning_' . $employee['id']]);
             $dataarray['details'][$key]['transport'] = str_replace(',', '', $formvalues['transport_' . $employee['id']]);
             $dataarray['details'][$key]['othercredit'] = str_replace(',', '', $formvalues['othercredit_' . $employee['id']]);
             $dataarray['details'][$key]['netpay'] = str_replace(',', '', $formvalues['netpay_' . $employee['id']]);
             $dataarray['details'][$key]['totaltaxable'] = str_replace(',', '', $formvalues['totaltaxable_' . $employee['id']]);
             $dataarray['details'][$key]['totalbenefits'] = str_replace(',', '', $formvalues['totalbenefits_' . $employee['id']]);
             $dataarray['details'][$key]['benefitdetails'] = $formvalues['benefitdetails_' . $employee['id']];
             $dataarray['details'][$key]['deductiondetails'] = $formvalues['deductiondetails_' . $employee['id']];
             $dataarray['details'][$key]['recurringtrxns'] = $formvalues['recurringtrxns_' . $employee['id']];
             $dataarray['details'][$key]['isignored'] = $formvalues['isignored_' . $employee['id']];
         }
     }
     // debugMessage('url '.decode($this->_getParam(URL_SUCCESS))); // exit;
     $payroll = new Payroll();
     if (!isArrayKeyAnEmptyString('reloadid', $formvalues)) {
         $payroll->populate($formvalues['reloadid']);
     }
     $payroll->processPost($dataarray);
     /* debugMessage($payroll->toArray());
     		debugMessage('errors are '.$payroll->getErrorStackAsString()); exit(); */
     if ($payroll->hasError()) {
         $url = decode($formvalues[URL_FAILURE]);
         $session->setVar(ERROR_MESSAGE, $payroll->getErrorStackAsString());
     } else {
         try {
             if ($payroll->payrollExists() && isArrayKeyAnEmptyString('reloadid', $formvalues)) {
                 $id = $payroll->existingPayroll();
                 $proll = new Payroll();
                 $proll->populate($id);
                 // debugMessage($proll->toArray()); exit();
                 $proll->delete();
             }
             // debugMessage($payroll->toArray()); exit();
             $payroll->save();
             $session->setVar(SUCCESS_MESSAGE, "Successfully saved as Draft");
             if ($dataarray['status'] == 2) {
                 $session->setVar(SUCCESS_MESSAGE, "Successfully marked as Completed and Locked");
             }
             $url = decode($formvalues[URL_SUCCESS]) . encode($payroll->getID());
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, $e->getMessage());
             // debugMessage($e->getMessage());
             $url = decode($formvalues[URL_FAILURE]);
         }
     }
     // debugMessage($url);
     $this->_helper->redirector->gotoUrl($url);
 }
 function attendancesearchAction()
 {
     $this->_helper->redirector->gotoSimple("attendance", "timesheets", $this->getRequest()->getModuleName(), array_remove_empty(array_merge_maintain_keys($this->_getAllParams(), $this->getRequest()->getQuery())));
 }