Example #1
0
 function processPost($formvalues)
 {
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('companyid', $formvalues)) {
         $formvalues['companyid'] = getCompanyID();
     }
     if (isArrayKeyAnEmptyString('defaultquantity', $formvalues)) {
         unset($formvalues['defaultquantity']);
     }
     if (isArrayKeyAnEmptyString('quantitytype', $formvalues)) {
         unset($formvalues['quantitytype']);
     }
     if (isArrayKeyAnEmptyString('deductfromallowance', $formvalues)) {
         unset($formvalues['deductfromallowance']);
     }
     if (isArrayKeyAnEmptyString('paid', $formvalues)) {
         unset($formvalues['paid']);
     }
     if (isArrayKeyAnEmptyString('bookable', $formvalues)) {
         unset($formvalues['bookable']);
     }
     if (isArrayKeyAnEmptyString('authorised', $formvalues)) {
         unset($formvalues['authorised']);
     }
     if (isArrayKeyAnEmptyString('viewoncalendar', $formvalues)) {
         unset($formvalues['viewoncalendar']);
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
Example #2
0
 function processPost($formvalues)
 {
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('companyid', $formvalues)) {
         $formvalues['companyid'] = getCompanyID();
     }
     if (isArrayKeyAnEmptyString('hours', $formvalues)) {
         unset($formvalues['hours']);
     }
     if (isArrayKeyAnEmptyString('starttime', $formvalues)) {
         unset($formvalues['starttime']);
     } else {
         $formvalues['starttime'] = date("H:i:s", strtotime($formvalues['starttime']));
     }
     if (isArrayKeyAnEmptyString('endtime', $formvalues)) {
         unset($formvalues['endtime']);
     } else {
         $formvalues['endtime'] = date("H:i:s", strtotime($formvalues['endtime']));
     }
     if (isArrayKeyAnEmptyString('overduestarttime', $formvalues)) {
         unset($formvalues['overduestarttime']);
     } else {
         $formvalues['overduestarttime'] = date("H:i:s", strtotime($formvalues['overduestarttime']));
     }
     if (isArrayKeyAnEmptyString('breakhrs', $formvalues)) {
         unset($formvalues['breakhrs']);
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
Example #3
0
 function processPost($formvalues)
 {
     $session = SessionWrapper::getInstance();
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('parentid', $formvalues)) {
         unset($formvalues['parentid']);
     }
     if (isArrayKeyAnEmptyString('sectorid', $formvalues)) {
         unset($formvalues['sectorid']);
         if (!isEmptyString($formvalues['parentid'])) {
             $category = new Category();
             $category->populate($formvalues['parentid']);
             $formvalues['sectorid'] = $category->getSectorID();
         }
     }
     if (isArrayKeyAnEmptyString('level', $formvalues)) {
         unset($formvalues['level']);
     }
     if (isArrayKeyAnEmptyString('type', $formvalues)) {
         unset($formvalues['type']);
     }
     if (isArrayKeyAnEmptyString('status', $formvalues)) {
         unset($formvalues['status']);
     }
     if (isArrayKeyAnEmptyString('uneditable', $formvalues)) {
         unset($formvalues['uneditable']);
     }
     if (isArrayKeyAnEmptyString('sortorder', $formvalues)) {
         if (!isEmptyString($formvalues['parentid']) && !isEmptyString($formvalues['sectorid'])) {
             $formvalues['sortorder'] = $this->getNextSortOrder($formvalues['sectorid'], $formvalues['parentid']);
         }
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
 function updatestatusAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     debugMessage($formvalues);
     $session = SessionWrapper::getInstance();
     $this->_translate = Zend_Registry::get("translate");
     $formvalues['id'] = $id = $formvalues['id'];
     $formvalues['dateapproved'] = date("Y-m-d H:i:s", strtotime('now'));
     $formvalues['approvedbyid'] = $session->getVar('userid');
     // debugMessage($formvalues);
     $leave = new Leave();
     $leave->populate($id);
     $leave->setStatus($formvalues['status']);
     $leave->setDateApproved(DEFAULT_DATETIME);
     $leave->setApprovedByID($session->getVar('userid'));
     if (!isArrayKeyAnEmptyString('reason', $formvalues)) {
         $leave->setReason("<br/>Rejected with remarks: " . $formvalues['reason']);
     }
     try {
         $leave->save();
         $leave->afterApprove($formvalues['status']);
         $session->setVar(SUCCESS_MESSAGE, $this->_translate->translate($formvalues[SUCCESS_MESSAGE]));
     } catch (Exception $e) {
         // debugMessage('error '.$e->getMessage());
         $session->setVar(ERROR_MESSAGE, $e->getMessage());
     }
     // exit();
     $this->_helper->redirector->gotoUrl(decode($formvalues[URL_SUCCESS]));
 }
Example #5
0
 function processPost($formvalues)
 {
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('type', $formvalues)) {
         unset($formvalues['type']);
     }
     if (isArrayKeyAnEmptyString('benefitid', $formvalues)) {
         unset($formvalues['benefitid']);
     }
     if (isArrayKeyAnEmptyString('amount', $formvalues)) {
         unset($formvalues['amount']);
     }
     if (isArrayKeyAnEmptyString('benefitfrequency', $formvalues)) {
         unset($formvalues['benefitfrequency']);
     }
     if (isArrayKeyAnEmptyString('leavetypeid', $formvalues)) {
         unset($formvalues['leavetypeid']);
     }
     if (isArrayKeyAnEmptyString('accrualtype', $formvalues)) {
         unset($formvalues['accrualtype']);
     }
     if (isArrayKeyAnEmptyString('accrualfrequency', $formvalues)) {
         unset($formvalues['accrualfrequency']);
     }
     if (isArrayKeyAnEmptyString('accrualvalue', $formvalues)) {
         unset($formvalues['accrualvalue']);
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
 function eventsAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $config = Zend_Registry::get("config");
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     $acl = getACLInstance();
     $user = new UserAccount();
     // $user->populate($formvalues['id']);
     $events = getLeaveRequests("", getYearStart(), getYearEnd());
     // debugMessage($events);
     $jsondata = array();
     $i = 0;
     if (count($events) > 0) {
         // $jsondata = $events;
         $leaveoptions = getHoursDaysDropdown();
         foreach ($events as $key => $value) {
             $jsondata[$key]['id'] = $value['id'];
             $unit = '';
             if (!isArrayKeyAnEmptyString($value['durationtype'], $leaveoptions)) {
                 $unit = ' on Leave';
             }
             $jsondata[$key]['title'] = $value['user'] . $unit;
             $jsondata[$key]['start'] = $value['startdate'];
             $jsondata[$key]['end'] = $value['enddate'];
             if (isTimesheetEmployee() && $value['userid'] == $session->getVar('userid') || $acl->checkPermission('Leave', ACTION_APPROVE)) {
                 // $jsondata[$key]['url'] = $this->view->serverUrl($this->view->baseUrl('leave/view/id/'.encode($value['id'])));
             }
         }
     }
     // debugMessage($jsondata);
     echo json_encode($jsondata);
 }
 function processPost($formvalues)
 {
     $session = SessionWrapper::getInstance();
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('create', $formvalues)) {
         $formvalues['create'] = 0;
     }
     if (isArrayKeyAnEmptyString('edit', $formvalues)) {
         $formvalues['edit'] = 0;
     }
     if (isArrayKeyAnEmptyString('view', $formvalues)) {
         $formvalues['view'] = 0;
     }
     if (isArrayKeyAnEmptyString('list', $formvalues)) {
         $formvalues['list'] = 0;
     }
     if (isArrayKeyAnEmptyString('delete', $formvalues)) {
         $formvalues['delete'] = 0;
     }
     if (isArrayKeyAnEmptyString('export', $formvalues)) {
         $formvalues['export'] = 0;
     }
     if (isArrayKeyAnEmptyString('approve', $formvalues)) {
         $formvalues['approve'] = 0;
     }
     if (isArrayKeyAnEmptyString('flag', $formvalues)) {
         $formvalues['flag'] = 0;
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
 function processPost($formvalues)
 {
     # force setting of default none string column values. enum, int and date
     if (isArrayKeyAnEmptyString('isread', $formvalues)) {
         $formvalues['isread'] = '0';
     }
     parent::processPost($formvalues);
 }
Example #9
0
 /**
  * Clean up the post array before populating the values of the object:
  * - Remove the blank values for the executedby field which will cause a foreign key error
  *
  * @param Array $post_array The post array
  * 
  * @see BaseRecord::processPost
  */
 public function processPost($formvalues)
 {
     // remove the executedby field if it is empty
     if (isArrayKeyAnEmptyString('isupdate', $formvalues)) {
         unset($formvalues['isupdate']);
     }
     if (isArrayKeyAnEmptyString('userid', $formvalues)) {
         unset($formvalues['userid']);
     }
     parent::processPost($formvalues);
 }
Example #10
0
 function processPost($formvalues)
 {
     // check if the active is not specified and set to default value
     if (isArrayKeyAnEmptyString('active', $formvalues)) {
         unset($formvalues['active']);
     }
     if (isArrayKeyAnEmptyString('editable', $formvalues)) {
         unset($formvalues['editable']);
     }
     # debugMessage($formvalues);
     parent::processPost($formvalues);
 }
Example #11
0
 function processPost($formvalues)
 {
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('companyid', $formvalues)) {
         unset($formvalues['companyid']);
     }
     if (isArrayKeyAnEmptyString('status', $formvalues)) {
         unset($formvalues['status']);
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
Example #12
0
 /**
  * Pre process model data
  */
 function processPost($formvalues)
 {
     # force setting of default none string column values. enum, int and date
     if (isArrayKeyAnEmptyString('parentid', $formvalues)) {
         unset($formvalues['parentid']);
     }
     if (isArrayKeyAnEmptyString('type', $formvalues)) {
         unset($formvalues['type']);
     }
     if (isArrayKeyAnEmptyString('refid', $formvalues)) {
         unset($formvalues['refid']);
     }
     parent::processPost($formvalues);
 }
Example #13
0
 function processPost($formvalues)
 {
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('companyid', $formvalues)) {
         $formvalues['companyid'] = 1;
     }
     if (isArrayKeyAnEmptyString('defaultamount', $formvalues)) {
         unset($formvalues['defaultamount']);
     }
     if (isArrayKeyAnEmptyString('amounttype', $formvalues)) {
         unset($formvalues['amounttype']);
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
Example #14
0
 function processPost($formvalues)
 {
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('headid', $formvalues)) {
         if (isArrayKeyAnEmptyString('headid_old', $formvalues)) {
             unset($formvalues['headid']);
         } else {
             $formvalues['headid'] = NULL;
         }
     }
     if (isArrayKeyAnEmptyString('companyid', $formvalues)) {
         $formvalues['companyid'] = DEFAULT_COMPANYID;
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
Example #15
0
 /**
  * Preprocess model data
  */
 function processPost($formvalues)
 {
     // set default values for integers, dates, decimals
     if (isArrayKeyAnEmptyString('userid', $formvalues)) {
         unset($formvalues['userid']);
     }
     if (isArrayKeyAnEmptyString('personid', $formvalues)) {
         unset($formvalues['personid']);
     }
     if (isArrayKeyAnEmptyString('namesection', $formvalues)) {
         unset($formvalues['namesection']);
     }
     if (isArrayKeyAnEmptyString('familysection', $formvalues)) {
         unset($formvalues['familysection']);
     }
     if (isArrayKeyAnEmptyString('clansection', $formvalues)) {
         unset($formvalues['clansection']);
     }
     if (isArrayKeyAnEmptyString('personalsection', $formvalues)) {
         unset($formvalues['personalsection']);
     }
     if (isArrayKeyAnEmptyString('emailaddresssection', $formvalues)) {
         unset($formvalues['emailaddresssection']);
     }
     if (isArrayKeyAnEmptyString('phonesection', $formvalues)) {
         unset($formvalues['phonesection']);
     }
     if (isArrayKeyAnEmptyString('physicaladdresssection', $formvalues)) {
         unset($formvalues['physicaladdresssection']);
     }
     if (isArrayKeyAnEmptyString('webaddresssection', $formvalues)) {
         unset($formvalues['webaddresssection']);
     }
     if (isArrayKeyAnEmptyString('birthsection', $formvalues)) {
         unset($formvalues['birthsection']);
     }
     if (isArrayKeyAnEmptyString('birthrule', $formvalues)) {
         unset($formvalues['birthrule']);
     }
     if (isArrayKeyAnEmptyString('defaultprivacy', $formvalues)) {
         unset($formvalues['defaultprivacy']);
     }
     parent::processPost($formvalues);
 }
Example #16
0
 /**
  * Populate the attributes of the object with the data. Also add the auditing data, createdby and lastupdatedby to 
  * the relationships if not specified
  *
  * @param Array $post_array The array of data values to populate the object attributes
  * @return boolean true if the object validates after populaton, or false if there are any validation errors
  */
 function processPost($post_array)
 {
     // $post_array = trimArray($post_array);
     # format the date fields
     foreach ($this->datefields as $fieldname) {
         if (isArrayKeyAnEmptyString($fieldname, $post_array)) {
             // remove the empty string from the array otherwise the date will be set to January 1, 1970
             unset($post_array[$fieldname]);
         } else {
             $post_array[$fieldname] = changeDateFromPageToMySQLFormat($post_array[$fieldname]);
             // TODO: SM - 09/17/10 - Cleanup this funny hack for dates,
             // I am not sure why new values for the dates are not picked up,
             // make the dates an empty string so that they can be updated
             $this->_set($fieldname, "");
         }
     }
     $relations = $this->getTable()->getRelations();
     # loop through each relation and add auditing fields
     foreach ($relations as $alias => $arelation) {
         if (!isArrayKeyAnEmptyString($alias, $post_array)) {
             foreach ($post_array[$alias] as $key => $value) {
                 # force the loading of only the hasOne relationships to conserve memory
                 if ($arelation['type'] == 0) {
                     $this->{$alias};
                 }
                 if (!isArrayKeyAnEmptyString('createdby', $post_array)) {
                     // add createdby to each relation
                     if ($arelation['type'] == 0) {
                         // hasOne so only one item in the relation
                         $post_array[$alias]['createdby'] = $post_array['createdby'];
                     } else {
                         // hasMany, use a key to populate each item in the relation
                         $post_array[$alias][$key]['createdby'] = $post_array['createdby'];
                     }
                 }
                 // check if the createdby field is still empty then use the lastupdatedby field since the relation is new
                 if (isArrayKeyAnEmptyString('createdby', $post_array[$alias])) {
                     if (!isArrayKeyAnEmptyString('lastupdatedby', $post_array)) {
                         if ($arelation['type'] == 0) {
                             // hasOne so only one item in the relation
                             $post_array[$alias]['createdby'] = $post_array['lastupdatedby'];
                         } else {
                             // hasMany, use a key to populate each item in the relation
                             $post_array[$alias][$key]['createdby'] = $post_array['lastupdatedby'];
                         }
                     }
                 }
                 if (!isArrayKeyAnEmptyString('lastupdatedby', $post_array)) {
                     // add lastupdatedby to each data item
                     if ($arelation['type'] == 0) {
                         // hasOne so only one item in the relation
                         $post_array[$alias]['lastupdatedby'] = $post_array['lastupdatedby'];
                     } else {
                         // hasMany, use a key to populate each item in the relation
                         $post_array[$alias][$key]['lastupdatedby'] = $post_array['lastupdatedby'];
                     }
                 }
                 // remove any empty id columns
                 if ($arelation['type'] == 0) {
                     // unset any empty id columns which have been sent - hasOne
                     if (isArrayKeyAnEmptyString('id', $post_array[$alias])) {
                         // remove the empty id field
                         unset($post_array[$alias]['id']);
                     }
                 } else {
                     // unset any empty id columns which have been sent - hasMany
                     if (isArrayKeyAnEmptyString('id', $post_array[$alias][$key])) {
                         // remove the empty id field
                         unset($post_array[$alias][$key]['id']);
                     }
                 }
             }
         }
         // end check whether alias exists in the data for population to eliminate PHP warnings
     }
     # remove the ID field if it is empty
     if (isArrayKeyAnEmptyString('id', $post_array)) {
         unset($post_array['id']);
     }
     $this->synchronizeWithArray($post_array, true);
     return $this->isValid(true);
 }
 function createAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $this->_translate = Zend_Registry::get("translate");
     $config = Zend_Registry::get("config");
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit();
     $isuserdoc = false;
     $iscompanydoc = false;
     if (!isArrayKeyAnEmptyString('userid', $formvalues)) {
         $isuserdoc = true;
         $folderid = $formvalues['userid'];
     } else {
         $iscompanydoc = true;
         $folderid = getCompanyID();
     }
     if (isset($_FILES["FileInput"]) && $_FILES["FileInput"]["error"] == UPLOAD_ERR_OK && !array_key_exists('submit', $formvalues)) {
         if (!isset($_FILES['FileInput']['name'])) {
             $error = "<span class='alert alert-danger blocked'>Error: Please select a File to Upload.</span>";
             $result = array('msg' => $error, 'result' => '');
             echo $error;
             exit;
         }
         // if uploading a user document
         if ($isuserdoc) {
             // base path for user documents
             $destination_path = BASE_PATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . "users" . DIRECTORY_SEPARATOR . "user_";
             // determine if user has destination avatar folder. Else user is editing there picture
             if (!is_dir($destination_path . $folderid)) {
                 // no folder exits. Create the folder
                 mkdir($destination_path . $folderid, 0775);
             }
         }
         // if uploading a company document
         if ($iscompanydoc) {
             // base path for user documents
             $destination_path = BASE_PATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . "company" . DIRECTORY_SEPARATOR . "comp_";
             // determine if user has destination avatar folder. Else user is editing there picture
             if (!is_dir($destination_path . $folderid)) {
                 // no folder exits. Create the folder
                 mkdir($destination_path . $folderid, 0775);
             }
         }
         $destination_path = $destination_path . $folderid . DIRECTORY_SEPARATOR . "documents";
         if (!is_dir($destination_path)) {
             mkdir($destination_path, 0775);
         }
         // create archive folder for each user
         $archivefolder = $destination_path . DIRECTORY_SEPARATOR . "archive";
         if (!is_dir($archivefolder)) {
             mkdir($archivefolder, 0775);
         }
         $oldfile = $_FILES['FileInput']['name'];
         $File_Name = strtolower($oldfile);
         $File_Ext = findExtension($File_Name);
         //get file extention
         $ext = strtolower($_FILES['FileInput']['type']);
         // debugMessage($ext);
         $allowedformatsarray = explode(',', str_replace(' ', '', $config->uploads->docallowedformats));
         // debugMessage($allowedformatsarray);exit();
         $uploadedext = findExtension($File_Name);
         $currenttime = time();
         //Random number to be added to name.
         $currenttime_file = $currenttime . '.' . $uploadedext;
         $thefilename = $destination_path . DIRECTORY_SEPARATOR . $currenttime_file;
         if (isEmptyString($folderid)) {
             $destination_path = BASE_PATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . "temp";
             if (!is_dir($destination_path)) {
                 // no folder exits. Create the folder
                 mkdir($destination_path, 0775);
             }
             $thefilename = $destination_path . DIRECTORY_SEPARATOR . $currenttime_file;
         }
         // check if this is an ajax request
         if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
             $error = "<span class='alert alert-danger blocked'>Error: No Request received.</span>";
             $result = array('msg' => $error, 'result' => '');
             echo $error;
             exit;
         }
         // debugMessage('size '.$_FILES["FileInput"]["size"]);
         // validate maximum allowed size
         $size = $_FILES["FileInput"]["size"];
         if ($size > $config->uploads->docmaximumfilesize) {
             $error = "<span class='alert alert-danger blocked'>Error: Maximum allowed size exceeded.</span>";
             $result = array('msg' => $error, 'result' => '');
             echo $error;
             exit;
         }
         // validate allowed formats
         if (!in_array($File_Ext, $allowedformatsarray)) {
             $error = "<span class='alert alert-danger blocked'>Error: Format '." . $File_Ext . "' not supported. Formats allowed include '" . $config->uploads->docallowedformats . "'</span>";
             $result = array('msg' => $error, 'result' => '');
             echo $error;
             exit;
         }
         # move the file
         try {
             move_uploaded_file($_FILES['FileInput']['tmp_name'], $thefilename);
             // die('File '.$NewFileName.' Uploaded.');
             $result = array('oldfilename' => $oldfile, 'newfilename' => $currenttime_file, 'msg' => 'Successfully uploaded', 'result' => 1, 'filesize' => $size);
             // debugMessage($result);
             echo json_encode($result);
             exit;
         } catch (Exception $e) {
             $error = 'Error in uploading File ' . $File_Name . '. ' . $e->getMessage();
             $result = array('msg' => $error, 'result' => '');
             echo $error;
             exit;
         }
     }
     if (array_key_exists('submit', $formvalues) || array_key_exists('id', $formvalues)) {
         $this->_setParam('uploadedbyid', $session->getVar('userid'));
         $this->_setParam('dateuploaded', DEFAULT_DATETIME);
         $this->_setParam("action", ACTION_CREATE);
         if (!isArrayKeyAnEmptyString('id', $formvalues)) {
             $this->_setParam("action", ACTION_EDIT);
         }
         // debugMessage($formvalues); exit();
         parent::createAction();
     }
 }
Example #18
0
 /**
  * Clean out the data received from the screen by:
  * - remove empty/blank groupid  - the groupid is not required and therefore is an empty value is maintained will cause an out of range exception 
  *
  * @param Array $post_array
  */
 function processPost($post_array)
 {
     $session = SessionWrapper::getInstance();
     // check if the groupid is blank then remove it
     $permissions = $this->getPermissions();
     $permissions_array = $permissions->toArray();
     if (array_key_exists('permissions', $post_array)) {
         if (is_array($post_array['permissions'])) {
             $data = array();
             foreach ($post_array['permissions'] as $key => $value) {
                 $data[$key] = $value;
                 if (array_key_exists('groupid', $value)) {
                     if (isEmptyString($value['groupid'])) {
                         unset($post_array['permissions'][$key]['groupid']);
                     }
                 }
                 if (isArrayKeyAnEmptyString('create', $value)) {
                     $post_array['permissions'][$key]['create'] = 0;
                 } else {
                     $post_array['permissions'][$key]['create'] = trim(intval($value['create']));
                 }
                 if (isArrayKeyAnEmptyString('edit', $value)) {
                     $post_array['permissions'][$key]['edit'] = 0;
                 } else {
                     $post_array['permissions'][$key]['edit'] = trim(intval($value['edit']));
                 }
                 if (isArrayKeyAnEmptyString('view', $value)) {
                     $post_array['permissions'][$key]['view'] = 0;
                 } else {
                     $post_array['permissions'][$key]['view'] = trim(intval($value['view']));
                 }
                 if (isArrayKeyAnEmptyString('list', $value)) {
                     $post_array['permissions'][$key]['list'] = 0;
                 } else {
                     $post_array['permissions'][$key]['list'] = trim(intval($value['list']));
                 }
                 if (isArrayKeyAnEmptyString('delete', $value)) {
                     $post_array['permissions'][$key]['delete'] = 0;
                 } else {
                     $post_array['permissions'][$key]['delete'] = trim(intval($value['delete']));
                 }
                 if (isArrayKeyAnEmptyString('approve', $value)) {
                     $post_array['permissions'][$key]['approve'] = 0;
                 } else {
                     $post_array['permissions'][$key]['approve'] = trim(intval($value['approve']));
                 }
                 if (isArrayKeyAnEmptyString('export', $value)) {
                     $post_array['permissions'][$key]['export'] = 0;
                 } else {
                     $post_array['permissions'][$key]['export'] = trim(intval($value['export']));
                 }
                 if (isArrayKeyAnEmptyString('id', $value)) {
                     unset($post_array['permissions'][$key]['id']);
                     $post_array['permissions'][$key]['createdby'] = $session->getVar('userid');
                     $post_array['permissions'][$key]['datecreated'] = getCurrentMysqlTimestamp();
                 }
                 if (!isArrayKeyAnEmptyString('id', $value)) {
                     $post_array['permissions'][$key]['lastupdatedby'] = $session->getVar('userid');
                     $post_array['permissions'][$key]['lastupdatedate'] = getCurrentMysqlTimestamp();
                     $data = $post_array['permissions'][$key];
                     unset($post_array['permissions'][$key]);
                     $newkey = array_search_key_by_id($permissions_array, $value['id']);
                     // debugMessage($data);
                     $post_array['permissions'][$newkey] = $data;
                 }
             }
             // end loop through permissions to unset empty groupids
         }
     }
     // now process the data
     // debugMessage($post_array['permissions']); // exit();
     parent::processPost($post_array);
 }
 function schedulecreateAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     // parent::createAction();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit();
     $formvalues['id'] = $id = decode($formvalues['id']);
     $status = $formvalues['status'];
     $old_shift = $formvalues['shift_old'];
     $isactive = false;
     $shift = new ShiftSchedule();
     if (!isArrayKeyAnEmptyString('id', $formvalues)) {
         $shift->populate($id);
         $isactive = $shift->isActive();
     } else {
         $formvalues['addedbyid'] = $session->getVar('userid');
         $formvalues['dateadded'] = DEFAULT_DATETIME;
     }
     $shift->processPost($formvalues);
     if ($shift->hasError()) {
         debugMessage('errors are ' . $shift->getErrorStackAsString());
         exit;
         $session->setVar(ERROR_MESSAGE, $shift->getErrorStackAsString());
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
         exit;
     }
     // exit;
     try {
         $updateshift = false;
         if ($status == 1) {
             if ($old_shift != $shift->getSessionID()) {
                 $shift->getUser()->setShift($shift->getSessionID());
                 $updateshift = true;
             }
         } else {
             if (!isEmptyString($old_shift) && $isactive) {
                 $shift->getUser()->setShift(NULL);
                 $updateshift = true;
             }
         }
         // debugMessage($shift->toArray()); exit;
         $shift->save();
         # update any previous shifts that could still be active when setting a new active session
         if ($status == 1) {
             $updateableshifts = $shift->getCurrentActiveShiftsForUser($shift->getUserID());
             // debugMessage($updateableshifts->toArray());
             if ($updateableshifts->count() > 0) {
                 foreach ($updateableshifts as $ashift) {
                     $ashift->setStatus(0);
                     $ashift->save();
                 }
             }
         }
         $session->setVar(SUCCESS_MESSAGE, $this->_getParam('successmessage'));
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_SUCCESS)));
     } catch (Exception $e) {
         $session->setVar(ERROR_MESSAGE, $e->getMessage());
         //debugMessage('save error '.$e->getMessage());
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
 }
 function checkloginAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     # check that an email has been provided
     if (isEmptyString(trim($this->_getParam("email")))) {
         $session->setVar(ERROR_MESSAGE, $this->_translate->translate("profile_email_error"));
         $session->setVar(FORM_VALUES, $this->_getAllParams());
         // return to the home page
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
     if (isEmptyString(trim($this->_getParam("password")))) {
         $session->setVar(ERROR_MESSAGE, $this->_translate->translate("profile_password_error"));
         $session->setVar(FORM_VALUES, $this->_getAllParams());
         // return to the home page
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
     # check which field user is using to login. default is username
     $credcolumn = "username";
     $login = (string) trim($this->_getParam("email"));
     // $password = encode(sha1(trim($this->_getParam("password"))));
     # check if credcolumn is emai
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($login)) {
         $usertable = new UserAccount();
         if ($usertable->findByEmail($login)) {
             $credcolumn = 'email';
         }
     }
     if (stringContains('!@#', $login)) {
         $credcolumn = 'trx';
         $loginarray = explode('.', $login);
         // debugMessage($loginarray);
         $id = $loginarray[0];
     }
     // debugMessage($credcolumn); exit;
     $browser = new Browser();
     $audit_values = $browser_session = array("browserdetails" => $browser->getBrowserDetailsForAudit(), "browser" => $browser->getBrowser(), "version" => $browser->getVersion(), "useragent" => $browser->getUserAgent(), "os" => $browser->getPlatform(), "ismobile" => $browser->isMobile() ? '1' : 0, "ipaddress" => $browser->getIPAddress());
     // debugMessage($audit_values);
     if ($credcolumn == 'email' || $credcolumn == 'username') {
         $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get("dbAdapter"));
         // define the table, fields and additional rules to use for authentication
         $authAdapter->setTableName('useraccount');
         $authAdapter->setIdentityColumn($credcolumn);
         $authAdapter->setCredentialColumn('password');
         $authAdapter->setCredentialTreatment("sha1(?) AND status = '1' ");
         // set the credentials from the login form
         $authAdapter->setIdentity($login);
         $authAdapter->setCredential($this->_getParam("password"));
         // new class to audit the type of Browser and OS that the visitor is using
         if (!$authAdapter->authenticate()->isValid()) {
             // debugMessage('invalid'); exit;
             // add failed login to audit trail
             $audit_values['module'] = 1;
             $audit_values['usecase'] = '1.1';
             $audit_values['transactiontype'] = USER_LOGIN;
             $audit_values['status'] = "N";
             $audit_values['transactiondetails'] = "Login for user with id '" . $this->_getParam("email") . "' failed. Invalid username or password";
             // exit();
             $this->notify(new sfEvent($this, USER_LOGIN, $audit_values));
             // return to the home page
             if (!isArrayKeyAnEmptyString(URL_FAILURE, $formvalues)) {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
             } else {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoSimple('login', "user");
             }
             return false;
         }
         // user is logged in sucessfully so add information to the session
         $user = $authAdapter->getResultRowObject();
         $useraccount = new UserAccount();
         $useraccount->populate($user->id);
     }
     // exit;
     # trx login
     if ($credcolumn == 'trx') {
         $useraccount = new UserAccount();
         $useraccount->populate($id);
         // debugMessage($result); exit();
         if (isEmptyString($useraccount->getID())) {
             // return to the home page
             if (!isArrayKeyAnEmptyString(URL_FAILURE, $formvalues)) {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
             } else {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoSimple('login', "user");
             }
             return false;
         }
     }
     // debugMessage($useraccount->toArray()); exit();
     $session->setVar("userid", $useraccount->getID());
     $session->setVar("username", $useraccount->getUserName());
     $session->setVar("type", $useraccount->getType());
     $session->setVar("companyid", $useraccount->getCompanyID());
     $session->setVar("istimesheetuser", $useraccount->getIsTimesheetUser());
     $session->setVar("browseraudit", $browser_session);
     $session->setVar("user", json_encode($useraccount->toArray()));
     $session->setVar("company", json_encode($useraccount->getCompany()->toArray()));
     // clear user specific cache, before it is used again
     $this->clearUserCache();
     // Add successful login event to the audit trail
     $audit_values['module'] = 1;
     $audit_values['usecase'] = '1.1';
     $audit_values['transactiontype'] = USER_LOGIN;
     $audit_values['status'] = "Y";
     $audit_values['userid'] = $useraccount->getID();
     $audit_values['transactiondetails'] = "Login for user with id '" . $this->_getParam("email") . "' successful";
     // $this->notify(new sfEvent($this, USER_LOGIN, $audit_values));
     if (isEmptyString($this->_getParam("redirecturl"))) {
         # forward to the dashboard
         $this->_helper->redirector->gotoSimple("index", "dashboard");
     } else {
         # redirect to the page the user was coming from
         if (!isEmptyString($this->_getParam(SUCCESS_MESSAGE))) {
             $successmessage = decode($this->_getParam(SUCCESS_MESSAGE));
             $session->setVar(SUCCESS_MESSAGE, $successmessage);
         }
         $this->_helper->redirector->gotoUrl(decode($this->_getParam("redirecturl")));
     }
 }
 function processnotificationAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $config = Zend_Registry::get("config");
     $message_collection = new Doctrine_Collection(Doctrine_Core::getTable("Message"));
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit;
     $recipients_array = array();
     $messagedata = array();
     $users = array();
     $execresult = array('result' => '', 'msg' => '');
     $type = $formvalues['type'];
     if ($type == 1) {
         $ismail = true;
         $issms = false;
         $msgtype = "mail";
     }
     if ($type == 2) {
         $issms = true;
         $ismail = false;
         $msgtype = "sms";
     }
     $custom_query = "";
     if ($formvalues['selecttype'] == 2) {
         if (!isArrayKeyAnEmptyString('userids', $formvalues)) {
             $users = $formvalues['userids'];
         }
     }
     if ($formvalues['selecttype'] == 4) {
         if ($ismail) {
             $users = getUsersWithEmail();
         }
         if ($issms) {
             $users = getUsersWithPhone();
         }
     }
     //debugMessage($users); exit;
     # if no receipients specified
     if (count($users) == 0) {
         $session->setVar(ERROR_MESSAGE, "Error: No Receipients specified!");
         $this->_helper->redirector->gotoUrl(decode($formvalues[URL_SUCCESS]));
         $execresult = array('result' => 'fail', 'msg' => "Error: No Receipients specified!");
         exit;
     }
     $messages = array();
     $sent = array();
     $phones = array();
     $messages['contents'] = $formvalues['contents'];
     $messages['type'] = $formvalues['type'];
     if (!isArrayKeyAnEmptyString('subject', $formvalues)) {
         $messages['subject'] = $formvalues['subject'];
     } else {
         $messages['subject'] = '';
     }
     $messages['senderid'] = 0;
     if (!isArrayKeyAnEmptyString('senderid', $formvalues)) {
         $messages['senderid'] = $formvalues['senderid'];
     }
     if (!isArrayKeyAnEmptyString('senderemail', $formvalues) && isEmptyString($session->getVar('userid'))) {
         $messages['senderemail'] = $formvalues['senderemail'];
     }
     if (!isArrayKeyAnEmptyString('sendername', $formvalues) && isEmptyString($session->getVar('userid'))) {
         $messages['sendername'] = $formvalues['sendername'];
     }
     # process receipients depending on select type
     foreach ($users as $key => $userid) {
         $user = new UserAccount();
         $id = '';
         if ($formvalues['selecttype'] == 2) {
             $id = $userid;
         }
         if ($formvalues['selecttype'] == 4) {
             $id = $key;
         }
         $user->populate($id);
         // debugMessage($memb->toArray());
         $recipients_array[$id]['recipientid'] = $user->getID();
         $messagedata[$id]['id'] = $user->getID();
         $messagedata[$id]['name'] = $user->getName();
         $messagedata[$id]['email'] = $user->getEmail();
         $messagedata[$id]['phone'] = $user->getPhone();
         $messagedata[$id]['sendemail'] = $user->allowEmailForPrivateMessage() ? 1 : 0;
         if ($ismail) {
             $sent[] = $user->getName() . ' (' . $user->getEmail() . ')';
         }
         if ($issms) {
             $sent[] = $user->getName() . ' (' . $user->getPhone() . ')';
             $phones[] = $user->getPhone();
         }
     }
     $messages['recipients'] = $recipients_array;
     $messages['membertotal'] = count($messagedata);
     $messages['usertotal'] = count($recipients_array);
     $messages['type'] = "notification";
     $messages['subtype'] = "new_" . $msgtype;
     /* debugMessage($sent); 
     		debugMessage($messagedata);  */
     $msg = new Message();
     $msg->processPost($messages);
     /* debugMessage($msg->toArray());
     		debugMessage('error is '.$msg->getErrorStackAsString()); exit(); */
     // save the messages to system inbox
     if ($msg->hasError()) {
         $session->setVar(ERROR_MESSAGE, "Error: " . $msg->getErrorStackAsString());
         $session->setVar(FORM_VALUES, $this->_getAllParams());
         $this->_helper->redirector->gotoUrl(decode($formvalues[URL_SUCCESS]));
         $execresult = array('result' => 'fail', 'msg' => "Error: " . $msg->getErrorStackAsString());
         // debugMessage($execresult);
         exit;
     } else {
         try {
             $msg->save();
             // send message to emails
             if (count($messagedata) > 0) {
                 foreach ($messagedata as $key => $receipient) {
                     $msgdetail = new MessageRecipient();
                     if (!isArrayKeyAnEmptyString('email', $receipient) && $receipient['sendemail'] == 1) {
                         $msgdetail->sendInboxEmailNotification($formvalues['senderemail'], $formvalues['sendername'], $messages['subject'], $receipient['email'], $receipient['name'], $messages['contents']);
                     }
                 }
             }
             // send message to phones
             if (count($phones) > 0) {
                 $messagechuncks = array_chunk($messagedata, 100, true);
                 if (count($messagedata) <= 100) {
                     $phonelist = implode(',', $phones);
                     //$result = sendSMSMessage($phonelist, $messages['contents'], '', $msg->getID());
                     // debugMessage($result); exit;
                 } else {
                     foreach ($messagechuncks as $key => $messagegrp) {
                         $phones_temp_array = array();
                         foreach ($messagegrp as $keynest => $messageline) {
                             $phones_temp_array[] = $messageline['phone'];
                         }
                         $phonelist = implode(',', $phones_temp_array);
                         // $result = sendSMSMessage($phonelist, $messages['contents'], '', $msg->getID());
                         // debugMessage($result);
                     }
                 }
             }
             if (count($messagedata) == 1) {
                 $key = current(array_keys($messagedata));
                 if ($ismail) {
                     $rcpt = $messagedata[$key]['name'] . ' (' . $messagedata[$key]['email'] . ')';
                     $sentmessage = "Message sent to " . $rcpt;
                     $session->setVar(SUCCESS_MESSAGE, $sentmessage);
                 }
                 if ($issms) {
                     $rcpt = $messagedata[$key]['name'] . ' (' . $messagedata[$key]['phone'] . ')';
                     $sentmessage = "Message sent to " . $rcpt;
                     $session->setVar(SUCCESS_MESSAGE, $sentmessage);
                 }
             } else {
                 $sentmessage = "Message successfully sent to <b>" . count($messagedata) . "</b> member(s). <br />See full list of recipient(s) at the bottom of this page.";
                 $sentresult = createHTMLListFromArray($sent, 'successmsg alert alert-success');
                 $session->setVar('sentlist', $sentresult);
                 $session->setVar(SUCCESS_MESSAGE, "Message sent to " . count($messagedata) . " members. <br />See full list of recipients at the bottom of this page.");
             }
             $execresult = array('result' => 'success', 'msg' => $sentmessage);
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, "An error occured in sending the message. " . $e->getMessage());
             $session->setVar(FORM_VALUES, $this->_getAllParams());
             $execresult = array('result' => 'success', 'msg' => "An error occured in sending the message. " . $e->getMessage());
         }
     }
     // exit;
     $this->_helper->redirector->gotoUrl(decode($formvalues[URL_SUCCESS]));
     echo json_encode($execresult);
 }
 function processPost($formvalues)
 {
     # force setting of default none string column values. enum, int and date
     if (isArrayKeyAnEmptyString('empstatus', $formvalues)) {
         unset($formvalues['empstatus']);
     }
     if (isArrayKeyAnEmptyString('rate', $formvalues)) {
         unset($formvalues['rate']);
     }
     if (isArrayKeyAnEmptyString('ratetype', $formvalues)) {
         unset($formvalues['ratetype']);
     }
     if (isArrayKeyAnEmptyString('istimesheetuser', $formvalues)) {
         unset($formvalues['istimesheetuser']);
     }
     if (isArrayKeyAnEmptyString('payrolltype', $formvalues)) {
         unset($formvalues['payrolltype']);
     }
     if (isArrayKeyAnEmptyString('isignored', $formvalues)) {
         unset($formvalues['isignored']);
     }
     if (isArrayKeyAnEmptyString('daysworked', $formvalues)) {
         unset($formvalues['daysworked']);
     }
     if (isArrayKeyAnEmptyString('hourspending', $formvalues)) {
         unset($formvalues['hourspending']);
     }
     if (isArrayKeyAnEmptyString('halfhoursworked', $formvalues)) {
         unset($formvalues['halfhoursworked']);
     }
     if (isArrayKeyAnEmptyString('fullhoursworked', $formvalues)) {
         unset($formvalues['fullhoursworked']);
     }
     if (isArrayKeyAnEmptyString('leavehrs', $formvalues)) {
         unset($formvalues['leavehrs']);
     }
     if (isArrayKeyAnEmptyString('sickhrs', $formvalues)) {
         unset($formvalues['sickhrs']);
     }
     if (isArrayKeyAnEmptyString('midgross', $formvalues)) {
         unset($formvalues['midgross']);
     }
     if (isArrayKeyAnEmptyString('endgross', $formvalues)) {
         unset($formvalues['endgross']);
     }
     if (isArrayKeyAnEmptyString('nssf', $formvalues)) {
         unset($formvalues['nssf']);
     }
     if (isArrayKeyAnEmptyString('paye', $formvalues)) {
         unset($formvalues['paye']);
     }
     if (isArrayKeyAnEmptyString('otherdebit', $formvalues)) {
         unset($formvalues['otherdebit']);
     }
     if (isArrayKeyAnEmptyString('netearning', $formvalues)) {
         unset($formvalues['netearning']);
     }
     if (isArrayKeyAnEmptyString('transport', $formvalues)) {
         unset($formvalues['transport']);
     }
     if (isArrayKeyAnEmptyString('othercredit', $formvalues)) {
         unset($formvalues['othercredit']);
     }
     if (isArrayKeyAnEmptyString('netpay', $formvalues)) {
         unset($formvalues['netpay']);
     }
     if (isArrayKeyAnEmptyString('totaltaxable', $formvalues)) {
         unset($formvalues['totaltaxable']);
     }
     if (isArrayKeyAnEmptyString('totalbenefits', $formvalues)) {
         unset($formvalues['totalbenefits']);
     }
     parent::processPost($formvalues);
 }
Example #23
0
 function processPost($formvalues)
 {
     $config = Zend_Registry::get("config");
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('status', $formvalues)) {
         unset($formvalues['status']);
     }
     if (isArrayKeyAnEmptyString('returndate', $formvalues)) {
         unset($formvalues['returndate']);
     }
     if (isArrayKeyAnEmptyString('durationtype', $formvalues)) {
         unset($formvalues['durationtype']);
     } else {
         if ($formvalues['durationtype'] == 2) {
             $formvalues['duration'] = $formvalues['duration'] * getHoursInDay();
             $formvalues['durationtype'] = 1;
         }
     }
     if (isArrayKeyAnEmptyString('dateapproved', $formvalues)) {
         unset($formvalues['dateapproved']);
     }
     if (isArrayKeyAnEmptyString('approvedbyid', $formvalues)) {
         unset($formvalues['approvedbyid']);
     }
     if (isArrayKeyAnEmptyString('starttime', $formvalues)) {
         unset($formvalues['starttime']);
     } else {
         $formvalues['starttime'] = date("H:i:s", strtotime($formvalues['starttime']));
     }
     if (isArrayKeyAnEmptyString('endtime', $formvalues)) {
         unset($formvalues['endtime']);
     } else {
         $formvalues['endtime'] = date("H:i:s", strtotime($formvalues['endtime']));
     }
     if (isArrayKeyAnEmptyString('returntime', $formvalues)) {
         unset($formvalues['returntime']);
     } else {
         $formvalues['returntime'] = date("H:i:s", strtotime($formvalues['returntime']));
     }
     if (!isArrayKeyAnEmptyString('istaken', $formvalues)) {
         $formvalues['status'] = 4;
     }
     // debugMessage($formvalues); //exit();
     parent::processPost($formvalues);
 }
Example #24
0
 function usernameExists($username = '')
 {
     $conn = Doctrine_Manager::connection();
     # validate unique username and email
     $id_check = "";
     if (!isEmptyString($this->getID())) {
         $id_check = " AND id <> '" . $this->getID() . "' ";
     }
     if (isEmptyString($username)) {
         $username = $this->getUsername();
     }
     // list of reserved usernames
     $reservednames = getInvalidSubdomains();
     $reservednames = array_combine($reservednames, $reservednames);
     if (!isArrayKeyAnEmptyString($username, $reservednames)) {
         return true;
     }
     $query = "SELECT id FROM company WHERE username = '******' AND status = '1' AND username <> '' " . $id_check;
     // debugMessage($query);
     $result = $conn->fetchOne($query);
     // debugMessage('>'.$result);
     if (isEmptyString($result)) {
         return false;
     }
     return true;
 }
function getFullTimezone($zone)
{
    $zonesarray = getAllTimezones();
    return isArrayKeyAnEmptyString($zone, $zonesarray) ? '' : $zonesarray[$zone];
}
Example #26
0
 function processPost($formvalues)
 {
     $config = Zend_Registry::get("config");
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('status', $formvalues)) {
         unset($formvalues['status']);
     }
     if (isArrayKeyAnEmptyString('ledgertype', $formvalues)) {
         unset($formvalues['ledgertype']);
     } else {
         if ($formvalues['ledgertype'] == 1) {
             $formvalues['leaveid'] = NULL;
             $formvalues['leavelength'] = NULL;
             $formvalues['lengthtype'] = NULL;
             $formvalues['debitpayroll'] = NULL;
         }
         if ($formvalues['ledgertype'] == 2) {
             $formvalues['amount'] = NULL;
             $formvalues['benefitid'] = NULL;
         }
     }
     if (isArrayKeyAnEmptyString('trxntype', $formvalues)) {
         unset($formvalues['trxntype']);
     }
     if (isArrayKeyAnEmptyString('companyid', $formvalues)) {
         $formvalues['companyid'] = 1;
     }
     if (isArrayKeyAnEmptyString('benefitid', $formvalues)) {
         unset($formvalues['benefitid']);
     }
     if (isArrayKeyAnEmptyString('leaveid', $formvalues)) {
         unset($formvalues['leaveid']);
     }
     if (isArrayKeyAnEmptyString('trxndate', $formvalues)) {
         unset($formvalues['trxndate']);
     }
     if (isArrayKeyAnEmptyString('startdate', $formvalues)) {
         unset($formvalues['startdate']);
     }
     if (isArrayKeyAnEmptyString('enddate', $formvalues)) {
         unset($formvalues['enddate']);
     }
     if (isArrayKeyAnEmptyString('leavelength', $formvalues)) {
         unset($formvalues['leavelength']);
     }
     if (isArrayKeyAnEmptyString('lengthtype', $formvalues)) {
         unset($formvalues['lengthtype']);
     } else {
         if ($formvalues['lengthtype'] == 2) {
             $formvalues['leavelength'] = $formvalues['leavelength'] * getHoursInDay();
             $formvalues['lengthtype'] = 1;
         }
     }
     if (isArrayKeyAnEmptyString('amount', $formvalues)) {
         unset($formvalues['amount']);
     }
     if (isArrayKeyAnEmptyString('debitpayroll', $formvalues)) {
         unset($formvalues['debitpayroll']);
     }
     if (isArrayKeyAnEmptyString('istaxable', $formvalues)) {
         unset($formvalues['istaxable']);
     }
     if (isArrayKeyAnEmptyString('taxabletype', $formvalues)) {
         unset($formvalues['taxabletype']);
     }
     if (!isArrayKeyAnEmptyString('istaxable', $formvalues)) {
         $formvalues['istaxable'] = 1;
     } else {
         $formvalues['istaxable'] = NULL;
     }
     if (isArrayKeyAnEmptyString('payrollid', $formvalues)) {
         unset($formvalues['payrollid']);
     }
     if (isArrayKeyAnEmptyString('payrolltrigger', $formvalues)) {
         unset($formvalues['payrolltrigger']);
     }
     if (isArrayKeyAnEmptyString('isrequest', $formvalues)) {
         unset($formvalues['isrequest']);
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
 function getAttendanceDaysOfWeek()
 {
     $listarray = array();
     $text = '';
     $allvalues = getDaysOfWeek();
     $thevalues = $this->getDaysOfWeekArray();
     if (isEmptyString($this->getWorkingDays())) {
         return $text;
     }
     if (count($thevalues) > 0) {
         foreach ($thevalues as $value) {
             if (!isArrayKeyAnEmptyString($value, $allvalues)) {
                 $listarray[] = $allvalues[$value];
             }
         }
     }
     if (count($listarray) > 0) {
         $text = createHTMLCommaListFromArray($listarray, ', ');
     }
     return $text;
 }
 public function processrolesAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $this->_translate = Zend_Registry::get("translate");
     $post_array = $this->_getAllParams();
     // debugMessage($this->_getAllParams()); exit;
     $id = $post_array['id'];
     $post_array['id'] = decode($id);
     $perms = $post_array['permissions'];
     unset($post_array['permissions']);
     if (isEmptyString($id)) {
         // add new role first
         $newrole = new AclGroup();
         $post_array['createdby'] = $session->getVar('userid');
         $newrole->processPost($post_array);
         // debugMessage($newrole->toArray()); debugMessage('error is '.$newrole->getErrorStackAsString());
         $newrole->save();
         $post_array['id'] = $newrole->getID();
     } else {
         // update role first
         $newrole = new AclGroup();
         $newrole->populate(decode($id));
         $newrole->processPost($post_array);
         // debugMessage($newrole->toArray()); debugMessage('error is '.$newrole->getErrorStackAsString()); // exit();
         $newrole->save();
     }
     // exit;
     $role = new AclGroup();
     $role->populate($post_array['id']);
     $permissions = $role->getPermissions();
     $permissions_array = $permissions->toArray();
     $post_array['permissions'] = $perms;
     // set audit entry before save
     if (!isArrayKeyAnEmptyString('permissions', $post_array)) {
         $data = array();
         foreach ($post_array['permissions'] as $key => $value) {
             $data[$key] = $value;
             $post_array['permissions'][$key]['groupid'] = $post_array['id'];
             if (isArrayKeyAnEmptyString('flag', $value)) {
                 $post_array['permissions'][$key]['flag'] = 0;
             } else {
                 $post_array['permissions'][$key]['flag'] = trim(intval($value['flag']));
             }
             if (isArrayKeyAnEmptyString('create', $value)) {
                 $post_array['permissions'][$key]['create'] = 0;
             } else {
                 $post_array['permissions'][$key]['create'] = trim(intval($value['create']));
             }
             if (isArrayKeyAnEmptyString('edit', $value)) {
                 $post_array['permissions'][$key]['edit'] = 0;
             } else {
                 $post_array['permissions'][$key]['edit'] = trim(intval($value['edit']));
             }
             if (isArrayKeyAnEmptyString('view', $value)) {
                 $post_array['permissions'][$key]['view'] = 0;
             } else {
                 $post_array['permissions'][$key]['view'] = trim(intval($value['view']));
             }
             if (isArrayKeyAnEmptyString('list', $value)) {
                 $post_array['permissions'][$key]['list'] = 0;
             } else {
                 $post_array['permissions'][$key]['list'] = trim(intval($value['list']));
             }
             if (isArrayKeyAnEmptyString('delete', $value)) {
                 $post_array['permissions'][$key]['delete'] = 0;
             } else {
                 $post_array['permissions'][$key]['delete'] = trim(intval($value['delete']));
             }
             if (isArrayKeyAnEmptyString('approve', $value)) {
                 $post_array['permissions'][$key]['approve'] = 0;
             } else {
                 $post_array['permissions'][$key]['approve'] = trim(intval($value['approve']));
             }
             if (isArrayKeyAnEmptyString('export', $value)) {
                 $post_array['permissions'][$key]['export'] = 0;
             } else {
                 $post_array['permissions'][$key]['export'] = trim(intval($value['export']));
             }
             if (isArrayKeyAnEmptyString('id', $value)) {
                 $post_array['permissions'][$key]['id'] = NULL;
             }
             $post_array['permissions'][$key]['createdby'] = $session->getVar('userid');
             $post_array['permissions'][$key]['datecreated'] = getCurrentMysqlTimestamp();
             if (!isArrayKeyAnEmptyString('id', $value)) {
                 $post_array['permissions'][$key]['lastupdatedby'] = $session->getVar('userid');
                 $post_array['permissions'][$key]['lastupdatedate'] = getCurrentMysqlTimestamp();
             } else {
                 $post_array['createdby'] = $session->getVar('userid');
             }
         }
         // end loop through permissions to unset empty groupids
     }
     // debugMessage($post_array); exit();
     if (!isEmptyString($id)) {
         $beforesave = $post_array['permissions'];
         // debugMessage($beforesave);
     }
     $perm_collection = new Doctrine_Collection(Doctrine_Core::getTable("AclPermission"));
     foreach ($post_array['permissions'] as $key => $value) {
         $perm = new AclPermission();
         if (!isArrayKeyAnEmptyString('id', $value)) {
             $perm->populate($value['id']);
         }
         $perm->processPost($value);
         if ($perm->isValid()) {
             $perm_collection->add($perm);
         } else {
             debugMessage('Error: ' . $perm->getErrorStackAsString());
             exit;
         }
     }
     try {
         $perm_collection->save();
         if (isEmptyString($id)) {
             # add log to audit trail
             $url = $this->view->serverUrl($this->view->baseUrl('role/view/id/' . encode($newrole->getID())));
             $usecase = '0.4';
             $module = '0';
             $type = SYSTEM_CREATEROLE;
             $details = "Role <a href='" . $url . "' class='blockanchor'>" . $newrole->getName() . "</a> created";
         } else {
             $url = $this->view->serverUrl($this->view->baseUrl('role/view/id/' . encode($newrole->getID())));
             $usecase = '0.5';
             $module = '0';
             $type = SYSTEM_UPDATEROLE;
             $details = "Role <a href='" . $url . "' class='blockanchor'>" . $newrole->getName() . "</a> updated";
             $prejson = json_encode($beforesave);
             $after = $perm_collection->toArray();
             debugMessage($after);
             $postjson = json_encode($post_array);
             // debugMessage($postjson);
             // $diff = array_diff($beforesave, $after);  // debugMessage($diff);
             $jsondiff = '';
             // debugMessage($jsondiff);
         }
         $browser = new Browser();
         $audit_values = $session->getVar('browseraudit');
         $audit_values['module'] = $module;
         $audit_values['usecase'] = $usecase;
         $audit_values['transactiontype'] = $type;
         $audit_values['status'] = "Y";
         $audit_values['userid'] = $session->getVar('userid');
         $audit_values['transactiondetails'] = $details;
         $audit_values['url'] = $url;
         if (!isEmptyString($id)) {
             $audit_values['isupdate'] = 1;
             $audit_values['prejson'] = $prejson;
             $audit_values['postjson'] = $postjson;
             $audit_values['jsondiff'] = $jsondiff;
         }
         // debugMessage($audit_values);
         $this->notify(new sfEvent($this, $type, $audit_values));
         if (!isEmptyString($this->_getParam(SUCCESS_MESSAGE))) {
             $session->setVar(SUCCESS_MESSAGE, $this->_translate->translate($this->_getParam(SUCCESS_MESSAGE)));
         }
         $this->_helper->redirector->gotoUrl($this->view->baseUrl("role/view/id/" . encode($role->getID())));
     } catch (Exception $e) {
         // debugMessage($perm_collection->toArray());
         // debugMessage('error in save. '.$e->getMessage());
         $session->setVar(ERROR_MESSAGE, $e->getMessage());
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
 }
function getSubdomain($url)
{
    preg_match('/(?:http[s]*\\:\\/\\/)*(.*?)\\.(?=[^\\/]*\\..{2,5})/i', $url, $match);
    $subdomain = isArrayKeyAnEmptyString(1, $match) ? '' : $match[1];
    return $subdomain;
}
 function approveAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $config = Zend_Registry::get("config");
     $this->_translate = Zend_Registry::get("translate");
     $formvalues = $this->_getAllParams();
     debugMessage($formvalues);
     $id = decode($formvalues['id']);
     $formvalues['id'] = $id;
     $successmessage = "";
     if (!isArrayKeyAnEmptyString('id', $formvalues)) {
         if (isArrayKeyAnEmptyString('status', $formvalues)) {
             $formvalues['status'] = 1;
         }
         $ledger = new Ledger();
         $ledger->populate($id);
         if (!isArrayKeyAnEmptyString('reason', $formvalues)) {
             $ledger->setRemarks($ledger->getRemarks() . "<br/> Rejected with remarks: " . $formvalues['reason']);
         }
         $ledger->setDateApproved(DEFAULT_DATETIME);
         $ledger->setApprovedByID($session->getVar('userid'));
         $ledger->setStatus($formvalues['status']);
         // debugMessage($ledger->toArray()); exit();
         try {
             $ledger->save();
             $msg = "Successfully Approved";
             if ($formvalues['status'] == 4) {
                 $msg = "Successfully Rejected";
             }
             $session->setVar(SUCCESS_MESSAGE, $msg);
             $ledger->afterApprove();
         } catch (Exception $e) {
             // debugMessage($e->getMessage());
             $session->setVar(ERROR_MESSAGE, $e->getMessage());
         }
     }
     $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_SUCCESS)));
 }