Beispiel #1
0
 function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $encoding = 'UTF-8', $diskcache = FALSE)
 {
     if (TTi18n::getPDFDefaultFont() != 'freeserif' and $encoding == 'ISO-8859-1') {
         parent::__construct($orientation, $unit, $format, FALSE, 'ISO-8859-1', $diskcache);
         //Make sure TCPDF constructor is called with all the arguments
     } else {
         parent::__construct($orientation, $unit, $format, TRUE, $encoding, $diskcache);
         //Make sure TCPDF constructor is called with all the arguments
     }
     Debug::Text('PDF Encoding: ' . $encoding, __FILE__, __LINE__, __METHOD__, 10);
     /*
     if ( TTi18n::getPDFDefaultFont() == 'freeserif' ) {
     	Debug::Text('Using unicode PDF: Font: freeserif Unicode: '. (int)$unicode .' Encoding: '. $encoding, __FILE__, __LINE__, __METHOD__,10);
     } else {
     	//If we're only using English, default to faster non-unicode settings.
     	//unicode=FALSE and encoding='ISO-8859-1' is about 20-30% faster.
     	Debug::Text('Using non-unicode PDF: Font: helvetica Unicode: '. (int)$unicode .' Encoding: '. $encoding, __FILE__, __LINE__, __METHOD__,10);
     	parent::__construct($orientation, $unit, $format, FALSE, 'ISO-8859-1', $diskcache); //Make sure TCPDF constructor is called with all the arguments
     }
     */
     //Using freeserif font enabling font subsetting is slow and produces PDFs at least 1mb. Helvetica is fine though.
     $this->setFontSubsetting(TRUE);
     //When enabled, makes PDFs smaller, but severly slows down TCPDF if enabled. (+6 seconds per PDF)
     $this->SetCreator(APPLICATION_NAME . ' ' . getTTProductEditionName() . ' v' . APPLICATION_VERSION);
     return TRUE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Modify all hierarchies with the request object type included, to add new request object types.
     $hclf = TTnew('HierarchyControlListFactory');
     $hclf->getAll();
     if ($hclf->getRecordCount() > 0) {
         foreach ($hclf as $hc_obj) {
             $src_object_types = $hc_obj->getObjectType();
             $request_key = array_search(50, $src_object_types);
             if ($request_key !== FALSE) {
                 Debug::Text('Found request object type, ID: ' . $hc_obj->getId() . ' Company ID: ' . $hc_obj->getCompany(), __FILE__, __LINE__, __METHOD__, 10);
                 unset($src_object_types[$request_key]);
                 $src_object_types[] = 1010;
                 $src_object_types[] = 1020;
                 $src_object_types[] = 1030;
                 $src_object_types[] = 1040;
                 $src_object_types[] = 1100;
                 $src_object_types = array_unique($src_object_types);
                 $hc_obj->setObjectType($src_object_types);
                 if ($hc_obj->isValid()) {
                     $hc_obj->Save();
                 }
             } else {
                 Debug::Text('Request object type not found for ID: ' . $hc_obj->getId() . ' Company ID: ' . $hc_obj->getCompany(), __FILE__, __LINE__, __METHOD__, 10);
             }
         }
     }
     return TRUE;
 }
Beispiel #3
0
 function __construct($e, $code = 'DBError')
 {
     global $db, $skip_db_error;
     if (isset($skip_db_error_exception) and $skip_db_error_exception === TRUE) {
         //Used by system_check script.
         return TRUE;
     }
     $db->FailTrans();
     //print_r($e);
     //adodb_pr($e);
     Debug::Text('Begin Exception...', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr(Debug::backTrace(), ' BackTrace: ', __FILE__, __LINE__, __METHOD__, 10);
     //Log database error
     if (isset($e->message)) {
         if (stristr($e->message, 'statement timeout') !== FALSE) {
             $code = 'DBTimeout';
         }
         Debug::Text($e->message, __FILE__, __LINE__, __METHOD__, 10);
     }
     if (isset($e->trace)) {
         $e = strip_tags(adodb_backtrace($e->trace));
         Debug::Arr($e, 'Exception...', __FILE__, __LINE__, __METHOD__, 10);
     }
     Debug::Text('End Exception...', __FILE__, __LINE__, __METHOD__, 10);
     //Dump debug buffer.
     Debug::Display();
     Debug::writeToLog();
     Debug::emailLog();
     Redirect::Page(URLBuilder::getURL(array('exception' => $code), Environment::getBaseURL() . 'DownForMaintenance.php'));
     ob_flush();
     ob_clean();
     exit;
 }
 static function convert($src_unit, $dst_unit, $measurement, $exponent = 1)
 {
     $src_unit = strtolower($src_unit);
     $dst_unit = strtolower($dst_unit);
     if (!isset(self::$units[$src_unit])) {
         return FALSE;
     }
     if (!isset(self::$units[$dst_unit])) {
         return FALSE;
     }
     if ($src_unit == $dst_unit) {
         return $measurement;
     }
     //Make sure we can convert from one unit to another.
     $valid_conversion = FALSE;
     foreach (self::$valid_unit_groups as $base_unit => $valid_units) {
         if (in_array($src_unit, $valid_units) and in_array($dst_unit, $valid_units)) {
             //Valid conversion
             $valid_conversion = TRUE;
         }
     }
     if ($valid_conversion == FALSE) {
         return FALSE;
     }
     $base_measurement = pow(self::$units[$src_unit], $exponent) * $measurement;
     Debug::Text(' Base Measurement: ' . $base_measurement, __FILE__, __LINE__, __METHOD__, 10);
     if ($base_measurement != 0) {
         $retval = 1 / pow(self::$units[$dst_unit], $exponent) * $base_measurement;
         return $retval;
     }
     return FALSE;
 }
 function setCompanyDeduction($id)
 {
     $id = trim($id);
     Debug::Text('ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     $cdlf = new CompanyDeductionListFactory();
     if ($this->Validator->isResultSetWithRows('company_deduction', $cdlf->getByID($id), TTi18n::gettext('Deduction is invalid'))) {
         $this->data['company_deduction_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
 function setHierarchyControl($id)
 {
     $id = trim($id);
     $hclf = TTnew('HierarchyControlListFactory');
     Debug::Text('Hierarchy Control ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     if ($id != 0 or $this->Validator->isResultSetWithRows('hierarchy_control_id', $hclf->getByID($id), TTi18n::gettext('Invalid Hierarchy Control'))) {
         $this->data['hierarchy_control_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
Beispiel #7
0
 function filterCompanyAddress($value)
 {
     Debug::Text('Filtering company address: ' . $value, __FILE__, __LINE__, __METHOD__, 10);
     //Combine company address for multicell display.
     $retarr[] = $this->company_address1;
     if ($this->company_address2 != '') {
         $retarr[] = $this->company_address2;
     }
     $retarr[] = $this->company_city . ', ' . $this->company_state . ' ' . $this->company_zip_code;
     return implode("\n", $retarr);
 }
 function setType($type)
 {
     $type = trim($type);
     $key = Option::getByValue($type, $this->getOptions('type'));
     if ($key !== FALSE) {
         $type = $key;
     }
     Debug::Text('bType: ' . $type, __FILE__, __LINE__, __METHOD__, 10);
     if ($this->Validator->inArrayKey('type', $type, TTi18n::gettext('Incorrect Type'), $this->getOptions('type'))) {
         $this->data['type_id'] = $type;
         return FALSE;
     }
     return FALSE;
 }
 static function page($url = NULL)
 {
     if (empty($url) and !empty($_SERVER['HTTP_REFERER'])) {
         $url = $_SERVER['HTTP_REFERER'];
     }
     Debug::Text('Redirect URL: ' . $url, __FILE__, __LINE__, __METHOD__, 11);
     if (Debug::getVerbosity() != 11) {
         header("Location: {$url}\n\n");
         //Prevent the rest of the script from running after redirect?
         Debug::writeToLog();
         ob_clean();
         exit;
     }
     return TRUE;
 }
Beispiel #10
0
 public function __construct()
 {
     parent::__construct();
     //Make sure parent constructor is always called.
     //When APIImport()->getImportObjects() is called directly, there won't be a main class to call.
     if (isset($this->main_class) and $this->main_class != '') {
         $this->import_obj = new $this->main_class();
         $this->import_obj->company_id = $this->getCurrentCompanyObject()->getID();
         $this->import_obj->user_id = $this->getCurrentUserObject()->getID();
         Debug::Text('Setting main class: ' . $this->main_class . ' Company ID: ' . $this->import_obj->company_id, __FILE__, __LINE__, __METHOD__, 10);
     } else {
         Debug::Text('NOT Setting main class... Company ID: ' . $this->getCurrentCompanyObject()->getID(), __FILE__, __LINE__, __METHOD__, 10);
     }
     return TRUE;
 }
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_EmbeddedAuthorizationList($params, &$smarty)
{
    global $current_company, $current_user;
    $object_type_id = $params['object_type_id'];
    $object_id = $params['object_id'];
    $ulf = new UserListFactory();
    $hlf = new HierarchyListFactory();
    $hotlf = new HierarchyObjectTypeListFactory();
    $alf = new AuthorizationListFactory();
    $alf->setObjectType($object_type_id);
    //$authorizing_obj = $alf->getObjectHandler()->getById( $object_id )->getCurrent();
    $tmp_authorizing_obj = $alf->getObjectHandler()->getById($object_id);
    if (is_object($tmp_authorizing_obj)) {
        $authorizing_obj = $tmp_authorizing_obj->getCurrent();
    } else {
        return FALSE;
    }
    //var_dump($authorizing_obj);
    unset($alf);
    $user_id = $authorizing_obj->getUserObject()->getId();
    $alf = new AuthorizationListFactory();
    $alf->getByObjectTypeAndObjectId($object_type_id, $object_id);
    foreach ($alf as $authorization_obj) {
        $authorization_data[] = array('id' => $authorization_obj->getId(), 'created_by_full_name' => $ulf->getById($authorization_obj->getCreatedBy())->getCurrent()->getFullName(), 'authorized' => $authorization_obj->getAuthorized(), 'created_date' => $authorization_obj->getCreatedDate(), 'created_by' => $authorization_obj->getCreatedBy(), 'updated_date' => $authorization_obj->getUpdatedDate(), 'updated_by' => $authorization_obj->getUpdatedBy(), 'deleted_date' => $authorization_obj->getDeletedDate(), 'deleted_by' => $authorization_obj->getDeletedBy());
        $user_id = $authorization_obj->getCreatedBy();
    }
    if ($authorizing_obj->getStatus() == 30) {
        //If the object is still pending authorization, display who its waiting on...
        $hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($current_company->getId(), $object_type_id)->getCurrent()->getHierarchyControl();
        Debug::Text('Hierarchy ID: ' . $hierarchy_id, __FILE__, __LINE__, __METHOD__, 10);
        //Get Parents
        $parent_level_user_ids = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $user_id);
        Debug::Arr($parent_level_user_ids, 'Parent Level Ids', __FILE__, __LINE__, __METHOD__, 10);
        if ($parent_level_user_ids !== FALSE and count($parent_level_user_ids) > 0) {
            Debug::Text('Adding Pending Line: ', __FILE__, __LINE__, __METHOD__, 10);
            foreach ($parent_level_user_ids as $parent_user_id) {
                $created_by_full_name[] = $ulf->getById($parent_user_id)->getCurrent()->getFullName();
            }
            $authorization_data[] = array('id' => NULL, 'created_by_full_name' => implode('<br>', $created_by_full_name), 'authorized' => NULL, 'created_date' => NULL, 'created_by' => NULL);
        }
    }
    $smarty->assign_by_ref('authorization_data', $authorization_data);
    $smarty->display('authorization/EmbeddedAuthorizationList.tpl');
}
 /**
  * Get accrual balance data for one or more accrual balancees.
  * @param array $data filter data
  * @return array
  */
 function getAccrualBalance($data = NULL, $disable_paging = FALSE)
 {
     if (!$this->getPermissionObject()->Check('accrual', 'enabled') or !($this->getPermissionObject()->Check('accrual', 'view') or $this->getPermissionObject()->Check('accrual', 'view_own') or $this->getPermissionObject()->Check('accrual', 'view_child'))) {
         return $this->getPermissionObject()->PermissionDenied();
     }
     $data = $this->initializeFilterAndPager($data, $disable_paging);
     $data['filter_data']['permission_children_ids'] = $this->getPermissionObject()->getPermissionChildren('accrual', 'view');
     $blf = TTnew('AccrualBalanceListFactory');
     $blf->getAPISearchByCompanyIdAndArrayCriteria($this->getCurrentCompanyObject()->getId(), $data['filter_data'], $data['filter_items_per_page'], $data['filter_page'], NULL, $data['filter_sort']);
     Debug::Text('Record Count: ' . $blf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     if ($blf->getRecordCount() > 0) {
         $this->getProgressBarObject()->start($this->getAMFMessageID(), $blf->getRecordCount());
         $this->setPagerObject($blf);
         foreach ($blf as $b_obj) {
             $retarr[] = $b_obj->getObjectAsArray($data['filter_columns'], $data['filter_data']['permission_children_ids']);
             $this->getProgressBarObject()->set($this->getAMFMessageID(), $blf->getCurrentRow());
         }
         $this->getProgressBarObject()->stop($this->getAMFMessageID());
         return $this->returnHandler($retarr);
     }
     return $this->returnHandler(TRUE);
     //No records returned.
 }
 function __construct($e)
 {
     global $db;
     $db->FailTrans();
     //print_r($e);
     //adodb_pr($e);
     //Log database error
     if (isset($e->message)) {
         Debug::Text($e->message, __FILE__, __LINE__, __METHOD__, 10);
     }
     if (isset($e->trace)) {
         $e = strip_tags(adodb_backtrace($e->trace));
         Debug::Arr($e, 'Exception...', __FILE__, __LINE__, __METHOD__, 10);
     }
     Debug::Arr(Debug::backTrace(), ' BackTrace: ', __FILE__, __LINE__, __METHOD__, 10);
     //Dump debug buffer.
     Debug::Display();
     Debug::writeToLog();
     Debug::emailLog();
     Redirect::Page(URLBuilder::getURL(array('exception' => 'DBError'), Environment::getBaseURL() . 'DownForMaintenance.php'));
     ob_flush();
     ob_clean();
     exit;
 }
Beispiel #14
0
     unset($generic_data['name']);
 default:
     BreadCrumb::setCrumb($title);
     if ($action == 'load') {
         Debug::Text('Loading Report!', __FILE__, __LINE__, __METHOD__, 10);
         extract(UserGenericDataFactory::getReportFormData($generic_data['id']));
     } elseif ($action == '') {
         //Check for default saved report first.
         $ugdlf->getByUserIdAndScriptAndDefault($current_user->getId(), $_SERVER['SCRIPT_NAME']);
         if ($ugdlf->getRecordCount() > 0) {
             Debug::Text('Found Default Report!', __FILE__, __LINE__, __METHOD__, 10);
             $ugd_obj = $ugdlf->getCurrent();
             $filter_data = $ugd_obj->getData();
             $generic_data['id'] = $ugd_obj->getId();
         } else {
             Debug::Text('Default Settings!', __FILE__, __LINE__, __METHOD__, 10);
             //Default selections
             $filter_data['user_status_ids'] = array(10);
             $filter_data['branch_ids'] = array(-1);
             $filter_data['department_ids'] = array(-1);
             $filter_data['user_title_ids'] = array(-1);
             $filter_data['pay_period_ids'] = array('-0000-' . array_shift(array_keys($pay_period_options)));
             $filter_data['start_date'] = $default_start_date;
             $filter_data['end_date'] = $default_end_date;
             $filter_data['group_ids'] = array(-1);
             //$filter_data['user_ids'] = array_keys( UserListFactory::getByCompanyIdArray( $current_company->getId(), FALSE, FALSE ) );
             if (!isset($filter_data['column_ids'])) {
                 $filter_data['column_ids'] = array();
             }
             $filter_data['column_ids'] = array_merge($filter_data['column_ids'], array('-1000-full_name', '-1065-pay_period', '-1090-worked_time', '-1130-paid_time', '-1140-regular_time'));
             $filter_data['primary_sort'] = '-1000-full_name';
Beispiel #15
0
 function postSave()
 {
     //Handle dirty work here.
     Debug::Text('ID we just saved: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
     if ($this->getEnableReCalculate() == TRUE) {
         //Set User Termination date to Last Day.
         $ulf = TTnew('UserListFactory');
         $ulf->getById($this->getUser());
         if ($ulf->getRecordCount() > 0) {
             Debug::Text('Setting User Termination Date', __FILE__, __LINE__, __METHOD__, 10);
             $user_obj = $ulf->getCurrent();
             $user_obj->setStatus(20);
             //Set status to terminated, now that pay stubs will always generate anyways.
             $user_obj->setTerminationDate($this->getLastDate());
             if ($user_obj->isValid()) {
                 $user_obj->Save();
                 UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Employee Record'), 30, TTi18n::gettext('Setting employee termination date to:') . ' ' . TTDate::getDate('DATE', $this->getLastDate()), NULL);
             }
         }
         $this->ReCalculate();
     }
     return TRUE;
 }
Beispiel #16
0
 /**
  * Allows currently logged in user to change their password.
  * @param string $current_password
  * @param string $new_password
  * @param string $new_password2
  * @param string $type
  * @return bool
  */
 function changePassword($current_password, $new_password, $new_password2, $type = 'web')
 {
     $ulf = TTnew('UserListFactory');
     $ulf->getByIdAndCompanyId($this->getCurrentUserObject()->getId(), $this->getCurrentCompanyObject()->getId());
     if ($ulf->getRecordCount() == 1) {
         $uf = $ulf->getCurrent();
         switch (strtolower($type)) {
             case 'quick_punch':
             case 'phone':
                 if ($this->getPermissionObject()->Check('user', 'edit_own_phone_password') == FALSE) {
                     return $this->getPermissionObject()->PermissionDenied();
                 }
                 $log_description = TTi18n::getText('Password - Phone');
                 if ($current_password != '') {
                     if ($uf->checkPhonePassword($current_password) !== TRUE) {
                         Debug::Text('Password check failed!', __FILE__, __LINE__, __METHOD__, 10);
                         $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect'));
                     }
                 } else {
                     Debug::Text('Current password not specified', __FILE__, __LINE__, __METHOD__, 10);
                     $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect'));
                 }
                 if ($new_password != '' or $new_password2 != '') {
                     if ($new_password == $new_password2) {
                         $uf->setPhonePassword($new_password);
                     } else {
                         $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match'));
                     }
                 } else {
                     $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match'));
                 }
                 break;
             case 'web':
                 if ($this->getPermissionObject()->Check('user', 'edit_own_password') == FALSE) {
                     return $this->getPermissionObject()->PermissionDenied();
                 }
                 $log_description = TTi18n::getText('Password - Web');
                 if ($current_password != '') {
                     if ($uf->checkPassword($current_password) !== TRUE) {
                         Debug::Text('Password check failed!', __FILE__, __LINE__, __METHOD__, 10);
                         $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect'));
                     }
                 } else {
                     Debug::Text('Current password not specified', __FILE__, __LINE__, __METHOD__, 10);
                     $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect'));
                 }
                 if ($new_password != '' or $new_password2 != '') {
                     if ($new_password == $new_password2) {
                         $uf->setPassword($new_password);
                     } else {
                         $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match'));
                     }
                 } else {
                     $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match'));
                 }
                 break;
         }
         if ($uf->isValid()) {
             if (DEMO_MODE == TRUE) {
                 //Return TRUE even in demo mode, but nothing happens.
                 return $this->returnHandler(TRUE);
             } else {
                 TTLog::addEntry($this->getCurrentUserObject()->getId(), 20, $log_description, NULL, $uf->getTable());
                 return $this->returnHandler($uf->Save());
                 //Single valid record
             }
         } else {
             return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $uf->Validator->getErrorsArray(), array('total_records' => 1, 'valid_records' => 0));
         }
     }
     return $this->returnHandler(FALSE);
 }
 /**
  * Get exception data for one or more exceptiones.
  * @param array $data filter data
  * @return array
  */
 function getException($data = NULL, $disable_paging = FALSE)
 {
     if (!$this->getPermissionObject()->Check('punch', 'enabled') or !($this->getPermissionObject()->Check('punch', 'view') or $this->getPermissionObject()->Check('punch', 'view_own') or $this->getPermissionObject()->Check('punch', 'view_child'))) {
         //return $this->getPermissionObject()->PermissionDenied();
         $data['filter_columns'] = $this->handlePermissionFilterColumns(isset($data['filter_columns']) ? $data['filter_columns'] : NULL, Misc::trimSortPrefix($this->getOptions('list_columns')));
     }
     $data = $this->initializeFilterAndPager($data, $disable_paging);
     $data['filter_data']['permission_children_ids'] = $this->getPermissionObject()->getPermissionChildren('punch', 'view');
     //If no pay period is specified, force to showing exceptions only in non-closed pay periods. This is a performance optimization too.
     if (!isset($data['filter_data']['pay_period_status_id']) and !isset($data['filter_data']['pay_period_id'])) {
         $data['filter_data']['pay_period_status_id'] = array(10, 12, 30);
         //All but closed
     }
     $blf = TTnew('ExceptionListFactory');
     $blf->getAPISearchByCompanyIdAndArrayCriteria($this->getCurrentCompanyObject()->getId(), $data['filter_data'], $data['filter_items_per_page'], $data['filter_page'], NULL, $data['filter_sort']);
     Debug::Text('Record Count: ' . $blf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     if ($blf->getRecordCount() > 0) {
         $this->getProgressBarObject()->start($this->getAMFMessageID(), $blf->getRecordCount());
         $this->setPagerObject($blf);
         foreach ($blf as $b_obj) {
             $retarr[] = $b_obj->getObjectAsArray($data['filter_columns'], $data['filter_data']['permission_children_ids']);
             $this->getProgressBarObject()->set($this->getAMFMessageID(), $blf->getCurrentRow());
         }
         $this->getProgressBarObject()->stop($this->getAMFMessageID());
         return $this->returnHandler($retarr);
     }
     return $this->returnHandler(TRUE);
     //No records returned.
 }
 function preSave()
 {
     $this->handleDayBoundary();
     $this->findUserDate();
     if ($this->getTotalTime() == FALSE) {
         $this->setTotalTime($this->calcTotalTime());
     }
     if ($this->getStatus() == 10) {
         $this->setAbsencePolicyID(NULL);
     } elseif ($this->getStatus() == FALSE) {
         $this->setStatus(10);
         //Default to working.
     }
     if ($this->getEnableOverwrite() == TRUE and $this->isNew() == TRUE) {
         //Delete any conflicting schedule shift before saving.
         $slf = TTnew('ScheduleListFactory');
         $slf->getConflictingByUserIdAndStartDateAndEndDate($this->getUserDateObject()->getUser(), $this->getStartTime(), $this->getEndTime());
         if ($slf->getRecordCount() > 0) {
             Debug::Text('Found Conflicting Shift!!', __FILE__, __LINE__, __METHOD__, 10);
             //Delete shifts.
             foreach ($slf as $s_obj) {
                 Debug::Text('Deleting Schedule Shift ID: ' . $s_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                 $s_obj->setDeleted(TRUE);
                 if ($s_obj->isValid()) {
                     $s_obj->Save();
                 }
             }
         } else {
             Debug::Text('NO Conflicting Shift found...', __FILE__, __LINE__, __METHOD__, 10);
         }
     }
     return TRUE;
 }
 /**
  * Copy one or more UserPreferencees.
  * @param array $data UserPreference IDs
  * @return array
  */
 function copyUserPreference($data)
 {
     if (is_numeric($data)) {
         $data = array($data);
     }
     if (!is_array($data)) {
         return $this->returnHandler(FALSE);
     }
     Debug::Text('Received data for: ' . count($data) . ' UserPreferences', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
     $src_rows = $this->stripReturnHandler($this->getUserPreference(array('filter_data' => array('id' => $data)), TRUE));
     if (is_array($src_rows) and count($src_rows) > 0) {
         Debug::Arr($src_rows, 'SRC Rows: ', __FILE__, __LINE__, __METHOD__, 10);
         foreach ($src_rows as $key => $row) {
             unset($src_rows[$key]['id'], $src_rows[$key]['manual_id']);
             //Clear fields that can't be copied
             $src_rows[$key]['name'] = Misc::generateCopyName($row['name']);
             //Generate unique name
         }
         //Debug::Arr($src_rows, 'bSRC Rows: ', __FILE__, __LINE__, __METHOD__, 10);
         return $this->setUserPreference($src_rows);
         //Save copied rows
     }
     return $this->returnHandler(FALSE);
 }
 function setPayStubEntryAccount($id)
 {
     $id = trim($id);
     Debug::Text('ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     $psealf = new PayStubEntryAccountListFactory();
     if ($id == '' or $id == 0 or $this->Validator->isResultSetWithRows('pay_stub_entry_account', $psealf->getByID($id), TTi18n::gettext('Pay Stub Account is invalid'))) {
         $this->data['pay_stub_entry_account_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
Beispiel #21
0
 function parse_hierarchy_control_display($input, $default_value = NULL, $parse_hint = NULL)
 {
     if (trim($input) == '') {
         return 0;
         //No Hierarchy
     }
     if (!is_array($this->hierarchy_control_options)) {
         $this->getHierarchyControlOptions();
     }
     Debug::Text('Finding hierarchy for: ' . $input, __FILE__, __LINE__, __METHOD__, 10);
     $retval = $this->findClosestMatch($input, $this->hierarchy_control_options);
     if ($retval === FALSE) {
         $retarr = -1;
         //Make sure this fails.
     } else {
         //Use only the permission object_type_id, if the hierarchies use all objects this will work fine as well.
         $retarr[100] = $retval;
     }
     return $retarr;
 }
Beispiel #22
0
            $request_id = $rf->Save();
            $rf->CommitTransaction();
            //$rf->FailTransaction();
            //Redirect::Page( URLBuilder::getURL( array('refresh' => FALSE ), '../CloseWindow.php') );
            Redirect::Page(URLBuilder::getURL(array('refresh' => TRUE), '../CloseWindow.php'));
        }
        $rf->FailTransaction();
    default:
        if ((int) $id > 0) {
            Debug::Text(' ID was passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
            $rlf = new RequestListFactory();
            $rlf->getByIDAndCompanyID($id, $current_company->getId());
            foreach ($rlf as $r_obj) {
                //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
                $data = array('id' => $r_obj->getId(), 'user_date_id' => $r_obj->getId(), 'user_id' => $r_obj->getUserDateObject()->getUser(), 'user_full_name' => $r_obj->getUserDateObject()->getUserObject()->getFullName(), 'date_stamp' => $r_obj->getUserDateObject()->getDateStamp(), 'type_id' => $r_obj->getType(), 'status_id' => $r_obj->getStatus(), 'created_date' => $r_obj->getCreatedDate(), 'created_by' => $r_obj->getCreatedBy(), 'updated_date' => $r_obj->getUpdatedDate(), 'updated_by' => $r_obj->getUpdatedBy(), 'deleted_date' => $r_obj->getDeletedDate(), 'deleted_by' => $r_obj->getDeletedBy());
            }
        } elseif ($action != 'submit') {
            Debug::Text(' ID was NOT passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
            //UserID has to be set at minimum
            $data = array('user_id' => $current_user->getId(), 'user_full_name' => $current_user->getFullName(), 'date_stamp' => TTDate::getTime());
        } else {
            $data['user_full_name'] = $current_user->getFullName();
        }
        //Select box options;
        $data['status_options'] = $rf->getOptions('status');
        $data['type_options'] = $rf->getOptions('type');
        $smarty->assign_by_ref('data', $data);
        break;
}
$smarty->assign_by_ref('rf', $rf);
$smarty->display('request/EditRequest.tpl');
Beispiel #23
0
if (!$permission->Check('company', 'enabled') or !($permission->Check('company', 'edit') or $permission->Check('company', 'edit_own'))) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'Edit Company'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'id', 'company_data')));
$cf = new CompanyFactory();
$action = Misc::findSubmitButton();
switch ($action) {
    case 'submit':
        //Debug::setVerbosity( 11 );
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $cf->StartTransaction();
        if ($permission->Check('company', 'edit')) {
            $cf->setId($company_data['id']);
            $cf->setParent($company_data['parent']);
            $cf->setStatus($company_data['status']);
        } else {
            $cf->setId($current_company->getId());
        }
        $cf->setProductEdition($company_data['product_edition']);
        if (isset($company_data['name'])) {
            $cf->setName($company_data['name']);
        }
        $cf->setShortName($company_data['short_name']);
        $cf->setBusinessNumber($company_data['business_number']);
        $cf->setOriginatorID($company_data['originator_id']);
 function _postProcess($format = NULL)
 {
     if ($format == 'pdf_form' or $format == 'pdf_form_government' or ($format == 'pdf_form_print' or $format == 'pdf_form_print_government') or $format == 'efile_xml') {
         Debug::Text('Skipping postProcess! Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
         return TRUE;
     } else {
         return parent::_postProcess($format);
     }
 }
 function setOfflinePunch($data)
 {
     Debug::Text('Setting Offline Punches... Rows: ' . count($data), __FILE__, __LINE__, __METHOD__, 10);
     //
     //WHen in Offline mode, default Type/Status to "AUTO"...
     //That way once I get the punches, I can determine what they should be on my end.
     //
     if (!is_array($data) or count($data) == 0) {
         return FALSE;
     }
     ksort($data);
     //Debug::Arr($data, 'offlinePunchDataArr', __FILE__, __LINE__, __METHOD__,10);
     /*
     		//Original
     		$data[] = array(
     						'user_id' => 1,
     						'time_stamp' => '12:00 PM',
     						'date_stamp' => '03-Dec-05',
     						'branch_id' => 1,
     						'department_id' => NULL,
     						'status_id' => 20,
     						'type_id' => 20,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     /*
     		unset($data);
     
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '08:00 AM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 5,
     						'department_id' => 3,
     						'status_id' => 0,
     						'type_id' => 0,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '12:00 PM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 0,
     						'department_id' => 3,
     						'status_id' => 20,
     						'type_id' => 0,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     /*
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '1:00 PM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 6,
     						'department_id' => 0,
     						'status_id' => 0,
     						'type_id' => 20,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     /*
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '5:00 PM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 0,
     						'department_id' => 0,
     						'status_id' => 0,
     						'type_id' => 0,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     //Debug::Arr($data, 'offlinePunchDataArr', __FILE__, __LINE__, __METHOD__,10);
     //One punch per row
     foreach ($data as $row_key => $punch_row) {
         Debug::Text('--------------------------========================---------------------------', __FILE__, __LINE__, __METHOD__, 10);
         Debug::Text('--------------------------========================---------------------------', __FILE__, __LINE__, __METHOD__, 10);
         Debug::Text('Row Key: ' . $row_key . ' Date: ' . $punch_row['date_stamp'] . ' Time: ' . $punch_row['time_stamp'] . ' Station ID: ' . $punch_row['station_id'], __FILE__, __LINE__, __METHOD__, 10);
         if (isset($punch_row['station_id'])) {
             $slf = new StationListFactory();
             $slf->getByStationId($punch_row['station_id']);
             if ($slf->getRecordCount() > 0) {
                 Debug::Text('Found Station Data...', __FILE__, __LINE__, __METHOD__, 10);
                 $current_station = $slf->getCurrent();
             } else {
                 Debug::Text('DID NOT Find Station Data...', __FILE__, __LINE__, __METHOD__, 10);
                 continue;
             }
             unset($slf);
         }
         if (isset($punch_row['user_id']) and $punch_row['user_id'] != '') {
             $ulf = new UserListFactory();
             $ulf->getById($punch_row['user_id']);
             if ($ulf->getRecordCount() > 0) {
                 $current_user = $ulf->getCurrent();
                 Debug::Text('Valid User ID: ' . $punch_row['user_id'] . ' User Name: ' . $current_user->getFullName(), __FILE__, __LINE__, __METHOD__, 10);
                 //Need to handle timezone somehow. The station should send us the system's timezone
                 //so we can calculate based on that.
                 //Or just use the employees date preference.
                 $current_user->getUserPreferenceObject()->setDateTimePreferences();
             } else {
                 Debug::Text('aInValid User ID: ' . $punch_row['user_id'], __FILE__, __LINE__, __METHOD__, 10);
                 continue;
             }
         } else {
             Debug::Text('bInValid User ID: ' . $punch_row['user_id'], __FILE__, __LINE__, __METHOD__, 10);
             continue;
         }
         //Check to make sure the station is allowed.
         if (is_object($current_station) and is_object($current_user) and $current_station->checkAllowed($current_user->getId(), $current_station->getStation(), $current_station->getType()) == FALSE) {
             Debug::text('Station NOT allowed: Station ID: ' . $current_station->getId() . ' User: '******'date_stamp'] . ' ' . $punch_row['time_stamp']);
         //Make sure time stamp converts properly, otherwise skip this punch.
         if (!is_int($punch_full_time_stamp)) {
             Debug::Text('Failed TimeStamp: ' . $punch_full_time_stamp, __FILE__, __LINE__, __METHOD__, 10);
             continue;
         }
         Debug::Text('Punch Date/Time: ' . $punch_full_time_stamp . ' Offset that was already applied: ' . $punch_row['offset'], __FILE__, __LINE__, __METHOD__, 10);
         $fail_transaction = FALSE;
         $pf = new PunchFactory();
         $pf->StartTransaction();
         $slf = new ScheduleListFactory();
         //Auto Punch
         if (isset($punch_row['status_id']) and $punch_row['status_id'] == 0 or isset($punch_row['type_id']) and $punch_row['type_id'] == 0 or isset($punch_row['branch_id']) and $punch_row['branch_id'] == 0 or isset($punch_row['department_id']) and $punch_row['department_id'] == 0 or isset($punch_row['job_id']) and $punch_row['job_id'] == 0 or isset($punch_row['job_item_id']) and $punch_row['job_item_id'] == 0) {
             $plf = new PunchListFactory();
             $plf->getPreviousPunchByUserIDAndEpoch($punch_row['user_id'], $punch_full_time_stamp);
             if ($plf->getRecordCount() > 0) {
                 Debug::Text(' Found Previous Punch within Continuous Time from now: ', __FILE__, __LINE__, __METHOD__, 10);
                 $prev_punch_obj = $plf->getCurrent();
                 $branch_id = $prev_punch_obj->getPunchControlObject()->getBranch();
                 $department_id = $prev_punch_obj->getPunchControlObject()->getDepartment();
                 $job_id = $prev_punch_obj->getPunchControlObject()->getJob();
                 $job_item_id = $prev_punch_obj->getPunchControlObject()->getJobItem();
                 $quantity = $prev_punch_obj->getPunchControlObject()->getQuantity();
                 $bad_quantity = $prev_punch_obj->getPunchControlObject()->getBadQuantity();
                 if ($branch_id == '' or empty($branch_id) or $department_id == '' or empty($department_id)) {
                     Debug::Text(' Branch or department are null. ', __FILE__, __LINE__, __METHOD__, 10);
                     $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($punch_row['user_id'], $punch_full_time_stamp);
                     if (is_object($s_obj)) {
                         Debug::Text(' Found Schedule!: ', __FILE__, __LINE__, __METHOD__, 10);
                         if ($branch_id == '' or empty($branch_id)) {
                             Debug::Text(' overrriding branch: ' . $s_obj->getBranch(), __FILE__, __LINE__, __METHOD__, 10);
                             $branch_id = $s_obj->getBranch();
                         }
                         if ($department_id == '' or empty($department_id)) {
                             Debug::Text(' overrriding department: ' . $s_obj->getDepartment(), __FILE__, __LINE__, __METHOD__, 10);
                             $department_id = $s_obj->getDepartment();
                         }
                     }
                 }
                 $type_id = $prev_punch_obj->getNextType();
                 $status_id = $prev_punch_obj->getNextStatus();
                 $next_type = $prev_punch_obj->getNextType();
                 //Check for break policy window.
                 if ($next_type != 30 and ($prev_punch_obj->getStatus() != 30 and $prev_punch_obj->getType() != 30)) {
                     $prev_punch_obj->setUser($current_user->getId());
                     $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($punch_full_time_stamp));
                     if ($prev_punch_obj->inBreakPolicyWindow($punch_full_time_stamp, $prev_punch_obj->getTimeStamp()) == TRUE) {
                         Debug::Text(' Setting Type to Break: ', __FILE__, __LINE__, __METHOD__, 10);
                         $next_type = 30;
                     }
                 }
                 //Check for meal policy window.
                 if ($next_type != 20 and ($prev_punch_obj->getStatus() != 20 and $prev_punch_obj->getType() != 20)) {
                     $prev_punch_obj->setUser($current_user->getId());
                     $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($punch_full_time_stamp));
                     if ($prev_punch_obj->inMealPolicyWindow($punch_full_time_stamp, $prev_punch_obj->getTimeStamp()) == TRUE) {
                         Debug::Text(' Setting Type to Lunch: ', __FILE__, __LINE__, __METHOD__, 10);
                         $next_type = 20;
                     }
                 }
             } else {
                 Debug::Text(' DID NOT Find Previous Punch within Continuous Time from now: ', __FILE__, __LINE__, __METHOD__, 10);
                 $branch_id = NULL;
                 $department_id = NULL;
                 $job_id = NULL;
                 $job_item_id = NULL;
                 $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($punch_row['user_id'], $punch_full_time_stamp);
                 if (is_object($s_obj)) {
                     Debug::Text(' Found Schedule!: ', __FILE__, __LINE__, __METHOD__, 10);
                     $branch_id = $s_obj->getBranch();
                     $department_id = $s_obj->getDepartment();
                 } else {
                     $branch_id = $current_user->getDefaultBranch();
                     $department_id = $current_user->getDefaultDepartment();
                     //Check station for default/forced settings.
                     if (is_object($current_station)) {
                         if ($current_station->getDefaultBranch() !== FALSE and $current_station->getDefaultBranch() != 0) {
                             $branch_id = $current_station->getDefaultBranch();
                         }
                         if ($current_station->getDefaultDepartment() !== FALSE and $current_station->getDefaultDepartment() != 0) {
                             $department_id = $current_station->getDefaultDepartment();
                         }
                         if ($current_station->getDefaultJob() !== FALSE and $current_station->getDefaultJob() != 0) {
                             $job_id = $current_station->getDefaultJob();
                         }
                         if ($current_station->getDefaultJobItem() !== FALSE and $current_station->getDefaultJobItem() != 0) {
                             $job_item_id = $current_station->getDefaultJobItem();
                         }
                     }
                 }
                 $status_id = 10;
                 //In
                 $type_id = 10;
                 //Normal
             }
             if (isset($punch_row['status_id']) and $punch_row['status_id'] != 0) {
                 Debug::Text(' Status ID is NOT AUTO: ' . $punch_row['status_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $status_id = $punch_row['status_id'];
             }
             if (isset($punch_row['type_id']) and $punch_row['type_id'] != 0) {
                 Debug::Text(' Type ID is NOT AUTO: ' . $punch_row['type_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $type_id = $punch_row['type_id'];
             }
             if (isset($punch_row['branch_id']) and $punch_row['branch_id'] != 0) {
                 Debug::Text(' Branch ID is NOT AUTO: ' . $punch_row['branch_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $branch_id = $punch_row['branch_id'];
             }
             if (isset($punch_row['department_id']) and $punch_row['department_id'] != 0) {
                 Debug::Text(' Department ID is NOT AUTO: ' . $punch_row['department_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $department_id = $punch_row['department_id'];
             }
             if (isset($punch_row['job_id']) and $punch_row['job_id'] != 0) {
                 Debug::Text(' Job ID is NOT AUTO: ' . $punch_row['job_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $job_id = $punch_row['job_id'];
             }
             if (isset($punch_row['job_item_id']) and $punch_row['job_item_id'] != 0) {
                 Debug::Text(' Job Item ID is NOT AUTO: ' . $punch_row['job_item_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $job_item_id = $punch_row['job_item_id'];
             }
             if (isset($punch_row['quantity'])) {
                 Debug::Text(' Quantity is NOT AUTO: ' . $punch_row['quantity'], __FILE__, __LINE__, __METHOD__, 10);
                 $quantity = $punch_row['quantity'];
             }
             if (isset($punch_row['bad_quantity'])) {
                 Debug::Text(' Bad Quantity is NOT AUTO: ' . $punch_row['bad_quantity'], __FILE__, __LINE__, __METHOD__, 10);
                 $bad_quantity = $punch_row['bad_quantity'];
             }
         } else {
             $status_id = $punch_row['status_id'];
             $type_id = $punch_row['type_id'];
             $branch_id = $punch_row['branch_id'];
             $department_id = $punch_row['department_id'];
             $job_id = $punch_row['job_id'];
             $job_item_id = $punch_row['job_item_id'];
             $quantity = $punch_row['quantity'];
             $bad_quantity = $punch_row['bad_quantity'];
         }
         //Set User before setTimeStamp so rounding can be done properly.
         $pf->setUser($punch_row['user_id']);
         if (isset($punch_row['transfer']) and $punch_row['transfer'] == 1) {
             Debug::Text(' Enabling Transfer!: ', __FILE__, __LINE__, __METHOD__, 10);
             $type_id = 10;
             $status_id = 10;
             $pf->setTransfer(TRUE);
         }
         $pf->setType($type_id);
         $pf->setStatus($status_id);
         $pf->setTimeStamp($punch_full_time_stamp, TRUE);
         //Make sure we round here.
         if (isset($status_id) and $status_id == 20 and isset($punch_row['punch_control_id']) and $punch_row['punch_control_id'] != '' and $punch_row['punch_control_id'] != 0) {
             $pf->setPunchControlID($punch_row['punch_control_id']);
         } else {
             $pf->setPunchControlID($pf->findPunchControlID());
         }
         $pf->setStation($current_station->getId());
         if ($pf->isNew()) {
             $pf->setActualTimeStamp($punch_full_time_stamp);
             $pf->setOriginalTimeStamp($pf->getTimeStamp());
         }
         if ($pf->isValid() == TRUE) {
             if ($pf->Save(FALSE) == TRUE) {
                 $pcf = new PunchControlFactory();
                 $pcf->setId($pf->getPunchControlID());
                 $pcf->setPunchObject($pf);
                 if (isset($branch_id) and $branch_id != '') {
                     $pcf->setBranch($branch_id);
                 }
                 if (isset($department_id) and $department_id != '') {
                     $pcf->setDepartment($department_id);
                 }
                 if (isset($job_id) and $job_id != '') {
                     $pcf->setJob($job_id);
                 }
                 if (isset($job_item_id) and $job_item_id != '') {
                     $pcf->setJobItem($job_item_id);
                 }
                 if (isset($quantity) and $quantity != '') {
                     $pcf->setQuantity($quantity);
                 }
                 if (isset($bad_quantity) and $bad_quantity != '') {
                     $pcf->setBadQuantity($bad_quantity);
                 }
                 if (isset($punch_row['note']) and $punch_row['note'] != '') {
                     $pcf->setNote($punch_row['note']);
                 }
                 if (isset($punch_row['other_id1']) and $punch_row['other_id1'] != '') {
                     $pcf->setOtherID1($punch_row['other_id1']);
                 }
                 if (isset($punch_row['other_id2']) and $punch_row['other_id2'] != '') {
                     $pcf->setOtherID2($punch_row['other_id2']);
                 }
                 if (isset($punch_row['other_id3']) and $punch_row['other_id3'] != '') {
                     $pcf->setOtherID3($punch_row['other_id3']);
                 }
                 if (isset($punch_row['other_id4']) and $punch_row['other_id4'] != '') {
                     $pcf->setOtherID4($punch_row['other_id4']);
                 }
                 if (isset($punch_row['other_id5']) and $punch_row['other_id5'] != '') {
                     $pcf->setOtherID5($punch_row['other_id5']);
                 }
                 $pcf->setEnableStrictJobValidation(TRUE);
                 $pcf->setEnableCalcUserDateID(TRUE);
                 $pcf->setEnableCalcTotalTime(TRUE);
                 $pcf->setEnableCalcSystemTotalTime(TRUE);
                 $pcf->setEnableCalcUserDateTotal(TRUE);
                 $pcf->setEnableCalcException(TRUE);
                 $pcf->setEnablePreMatureException(TRUE);
                 //Enable pre-mature exceptions at this point.
                 if ($pcf->isValid() == TRUE) {
                     Debug::Text(' Punch Control is valid, saving...: ', __FILE__, __LINE__, __METHOD__, 10);
                     if ($pcf->Save(TRUE, TRUE) == TRUE) {
                         //Force isNew() lookup.
                         Debug::text('Saved Punch!', __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                         Debug::text('PCF Save failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
                         $fail_transaction = TRUE;
                     }
                 } else {
                     Debug::text('PCF Validate failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
                     $fail_transaction = TRUE;
                 }
             } else {
                 Debug::text('PF Save failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
                 $fail_transaction = TRUE;
             }
         } else {
             Debug::text('PF Validate failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
             $fail_transaction = TRUE;
         }
         if ($fail_transaction == FALSE) {
             $pf->CommitTransaction();
         } else {
             $pf->FailTransaction();
         }
         unset($punch_full_time_stamp, $current_station, $current_user);
         //End Foreach
     }
     return TRUE;
 }
    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('type_id');
        $sort_column_aliases = array('type' => 'type_id', 'status' => 'status_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('a.status_id' => 'asc', 'a.type_id' => 'asc');
            $strict = FALSE;
        } else {
            //Always try to order by status first so INACTIVE records go to the bottom.
            if (!isset($order['status_id'])) {
                $order = Misc::prependArray(array('a.status_id' => 'asc'), $order);
            }
            //Always sort by type, ps_order after other columns
            if (!isset($order['type_id'])) {
                $order['a.type_id'] = 'asc';
            }
            if (!isset($order['ps_order'])) {
                $order['ps_order'] = 'asc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	a.company_id = ?
					';
        if (isset($filter_data['id']) and isset($filter_data['id'][0]) and !in_array(-1, (array) $filter_data['id'])) {
            $query .= ' AND a.id in (' . $this->getListSQL($filter_data['id'], $ph) . ') ';
        }
        if (isset($filter_data['exclude_id']) and isset($filter_data['exclude_id'][0]) and !in_array(-1, (array) $filter_data['exclude_id'])) {
            $query .= ' AND a.id not in (' . $this->getListSQL($filter_data['exclude_id'], $ph) . ') ';
        }
        if (isset($filter_data['status_id']) and isset($filter_data['status_id'][0]) and !in_array(-1, (array) $filter_data['status_id'])) {
            $query .= ' AND a.status_id in (' . $this->getListSQL($filter_data['status_id'], $ph) . ') ';
        }
        if (isset($filter_data['type_id']) and isset($filter_data['type_id'][0]) and !in_array(-1, (array) $filter_data['type_id'])) {
            $query .= ' AND a.type_id in (' . $this->getListSQL($filter_data['type_id'], $ph) . ') ';
        }
        if (isset($filter_data['name']) and trim($filter_data['name']) != '') {
            $ph[] = strtolower(trim($filter_data['name']));
            $query .= ' AND lower(a.name) LIKE ?';
        }
        if (isset($filter_data['created_by']) and isset($filter_data['created_by'][0]) and !in_array(-1, (array) $filter_data['created_by'])) {
            $query .= ' AND a.created_by in (' . $this->getListSQL($filter_data['created_by'], $ph) . ') ';
        }
        if (isset($filter_data['updated_by']) and isset($filter_data['updated_by'][0]) and !in_array(-1, (array) $filter_data['updated_by'])) {
            $query .= ' AND a.updated_by in (' . $this->getListSQL($filter_data['updated_by'], $ph) . ') ';
        }
        $query .= '
						AND a.deleted = 0
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        Debug::Text('Query: ' . $query, __FILE__, __LINE__, __METHOD__, 10);
        if ($limit == NULL) {
            $this->rs = $this->db->Execute($query, $ph);
        } else {
            $this->rs = $this->db->PageExecute($query, $limit, $page, $ph);
        }
        return $this;
    }
Beispiel #27
0
 function Send()
 {
     Debug::Text('Attempting to send email To: ' . $this->getTo(), __FILE__, __LINE__, __METHOD__, 10);
     if ($this->getTo() == FALSE) {
         Debug::Text('To Address invalid...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     if ($this->getBody() == FALSE) {
         Debug::Text('Body invalid...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     Debug::Text('Sending Email To: ' . $this->getTo() . ' Body Size: ' . strlen($this->getBody()) . ' Method: ' . $this->getDeliveryMethod(), __FILE__, __LINE__, __METHOD__, 10);
     if (PRODUCTION == FALSE) {
         Debug::Text('Not in production mode, not sending emails...', __FILE__, __LINE__, __METHOD__, 10);
         //$to = 'root@localhost';
         return FALSE;
     }
     if (DEMO_MODE == TRUE) {
         Debug::Text('In DEMO mode, not sending emails...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     switch ($this->getDeliveryMethod()) {
         case 'smtp':
         case 'mail':
             $send_retval = $this->getMailObject()->send($this->getTo(), $this->getMIMEHeaders(), $this->getBody());
             if (PEAR::isError($send_retval)) {
                 Debug::Text('Send Email Failed... Error: ' . $send_retval->getMessage(), __FILE__, __LINE__, __METHOD__, 10);
                 $send_retval = FALSE;
             }
             break;
         case 'soap':
             $ttsc = new TimeTrexSoapClient();
             $send_retval = $ttsc->sendEmail($this->getTo(), $this->getMIMEHeaders(), $this->getBody());
             break;
     }
     if ($send_retval == TRUE) {
         return TRUE;
     }
     Debug::Arr($send_retval, 'Send Email Failed!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
 /**
  * @param array $data user review control data
  * @return array
  */
 function deleteUserReviewControl($data)
 {
     if (is_numeric($data)) {
         $data = array($data);
     }
     if (!is_array($data)) {
         return $this->returnHandler(FALSE);
     }
     if (!$this->getPermissionObject()->Check('user_review', 'enabled') or !($this->getPermissionObject()->Check('user_review', 'delete') or $this->getPermissionObject()->Check('user_review', 'delete_own') or $this->getPermissionObject()->Check('user_review', 'delete_child'))) {
         return $this->getPermissionObject()->PermissionDenied();
     }
     //Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
     $permission_children_ids = $this->getPermissionChildren();
     Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
     $total_records = count($data);
     $validator_stats = array('total_records' => $total_records, 'valid_records' => 0);
     if (is_array($data)) {
         foreach ($data as $key => $id) {
             $primary_validator = new Validator();
             $lf = TTnew('UserReviewControlListFactory');
             $lf->StartTransaction();
             if (is_numeric($id)) {
                 //Modifying existing object.
                 //Get Kpi object, so we can only modify just changed data for specific records if needed.
                 $lf->getByIdAndCompanyId($id, $this->getCurrentCompanyObject()->getId());
                 if ($lf->getRecordCount() == 1) {
                     //Object exists, check edit permissions
                     if ($this->getPermissionObject()->Check('user_review', 'delete') or $this->getPermissionObject()->Check('user_review', 'delete_own') and $this->getPermissionObject()->isOwner($lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getUser()) === TRUE or $this->getPermissionObject()->Check('user_review', 'delete_child') and $this->getPermissionObject()->isChild($lf->getCurrent()->getUser(), $permission_children_ids) === TRUE) {
                         Debug::Text('Record Exists, deleting record: ', $id, __FILE__, __LINE__, __METHOD__, 10);
                         $lf = $lf->getCurrent();
                     } else {
                         $primary_validator->isTrue('user_review', FALSE, TTi18n::gettext('Delete permission denied'));
                     }
                 } else {
                     //Object doesn't exist.
                     $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
                 }
             } else {
                 $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
             }
             //Debug::Arr($lf, 'AData: ', __FILE__, __LINE__, __METHOD__, 10);
             $is_valid = $primary_validator->isValid();
             if ($is_valid == TRUE) {
                 //Check to see if all permission checks passed before trying to save data.
                 Debug::Text('Attempting to delete record...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->setDeleted(TRUE);
                 $is_valid = $lf->isValid();
                 if ($is_valid == TRUE) {
                     Debug::Text('Record Deleted...', __FILE__, __LINE__, __METHOD__, 10);
                     $save_result[$key] = $lf->Save();
                     $validator_stats['valid_records']++;
                 }
             }
             if ($is_valid == FALSE) {
                 Debug::Text('Data is Invalid...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->FailTransaction();
                 //Just rollback this single record, continue on to the rest.
                 if ($primary_validator->isValid() == FALSE) {
                     $validator[$key] = $primary_validator->getErrorsArray();
                 } else {
                     $validator[$key] = $lf->Validator->getErrorsArray();
                 }
             }
             $lf->CommitTransaction();
         }
         if ($validator_stats['valid_records'] > 0 and $validator_stats['total_records'] == $validator_stats['valid_records']) {
             if ($validator_stats['total_records'] == 1) {
                 return $this->returnHandler($save_result[$key]);
                 //Single valid record
             } else {
                 return $this->returnHandler(TRUE, 'SUCCESS', TTi18n::getText('MULTIPLE RECORDS SAVED'), $save_result, $validator_stats);
                 //Multiple valid records
             }
         } else {
             return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
         }
     }
     return $this->returnHandler(FALSE);
 }
 function _getData($format = NULL)
 {
     $this->tmp_data = array('user' => array(), 'user_preference' => array(), 'user_wage' => array(), 'user_bank' => array(), 'user_deduction' => array(), 'total_user' => array());
     $columns = $this->getColumnDataConfig();
     $filter_data = $this->getFilterConfig();
     $currency_convert_to_base = $this->getCurrencyConvertToBase();
     $base_currency_obj = $this->getBaseCurrencyObject();
     $this->handleReportCurrency($currency_convert_to_base, $base_currency_obj, $filter_data);
     $currency_options = $this->getOptions('currency');
     if ($this->getPermissionObject()->Check('user', 'view') == FALSE or $this->getPermissionObject()->Check('wage', 'view') == FALSE) {
         $hlf = TTnew('HierarchyListFactory');
         $permission_children_ids = $wage_permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($this->getUserObject()->getCompany(), $this->getUserObject()->getID());
         Debug::Arr($permission_children_ids, 'Permission Children Ids:', __FILE__, __LINE__, __METHOD__, 10);
     } else {
         //Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
         $permission_children_ids = array();
         $wage_permission_children_ids = array();
     }
     if ($this->getPermissionObject()->Check('user', 'view') == FALSE) {
         if ($this->getPermissionObject()->Check('user', 'view_child') == FALSE) {
             $permission_children_ids = array();
         }
         if ($this->getPermissionObject()->Check('user', 'view_own')) {
             $permission_children_ids[] = $this->getUserObject()->getID();
         }
         $filter_data['permission_children_ids'] = $permission_children_ids;
     }
     //Get Wage Permission Hierarchy Children first, as this can be used for viewing, or editing.
     if ($this->getPermissionObject()->Check('wage', 'view') == TRUE) {
         $wage_permission_children_ids = TRUE;
     } elseif ($this->getPermissionObject()->Check('wage', 'view') == FALSE) {
         if ($this->getPermissionObject()->Check('wage', 'view_child') == FALSE) {
             $wage_permission_children_ids = array();
         }
         if ($this->getPermissionObject()->Check('wage', 'view_own')) {
             $wage_permission_children_ids[] = $this->getUserObject()->getID();
         }
     }
     //Debug::Text(' Permission Children: '. count($permission_children_ids) .' Wage Children: '. count($wage_permission_children_ids), __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($permission_children_ids, 'Permission Children: '. count($permission_children_ids), __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($wage_permission_children_ids, 'Wage Children: '. count($wage_permission_children_ids), __FILE__, __LINE__, __METHOD__,10);
     //Always include date columns, because 'hire-date_stamp' is not recognized by the UserFactory. This greatly slows down the report though.
     $columns['effective_date'] = $columns['hire_date'] = $columns['termination_date'] = $columns['birth_date'] = $columns['created_date'] = $columns['updated_date'] = TRUE;
     //Get user data for joining.
     $ulf = TTnew('UserListFactory');
     $ulf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
     Debug::Text(' User Rows: ' . $ulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     $this->getProgressBarObject()->start($this->getAMFMessageID(), $ulf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...'));
     foreach ($ulf as $key => $u_obj) {
         //We used to just get return the entire $u_obj->data array, but this wouldn't include tags and other columns that required some additional processing.
         //Not sure why this was done that way... I think because we had problems with the multiple date fields (Hire Date/Termination Date/Birth Date, etc...)
         $this->tmp_data['user'][$u_obj->getId()] = (array) $u_obj->getObjectAsArray($columns);
         if ($currency_convert_to_base == TRUE and is_object($base_currency_obj)) {
             $this->tmp_data['user'][$u_obj->getId()]['currency_rate'] = $u_obj->getColumn('currency_rate');
         }
         $this->tmp_data['user'][$u_obj->getId()]['employee_number'] = isset($columns['employee_number']) ? $this->tmp_data['user'][$u_obj->getId()]['employee_number'] : $u_obj->getEmployeeNumber();
         if (isset($columns['employee_number_barcode'])) {
             $this->tmp_data['user'][$u_obj->getId()]['employee_number_barcode'] = new ReportCellBarcode($this, 'U' . $this->tmp_data['user'][$u_obj->getId()]['employee_number']);
         }
         if (isset($columns['employee_number_qrcode'])) {
             $this->tmp_data['user'][$u_obj->getId()]['employee_number_qrcode'] = new ReportCellQRcode($this, 'U' . $this->tmp_data['user'][$u_obj->getId()]['employee_number']);
         }
         $this->tmp_data['user_preference'][$u_obj->getId()] = array();
         $this->tmp_data['user_wage'][$u_obj->getId()] = array();
         $this->tmp_data['user'][$u_obj->getId()]['total_user'] = 1;
         $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
     }
     //Debug::Arr($this->tmp_data['user'], 'TMP User Data: ', __FILE__, __LINE__, __METHOD__,10);
     //Get user preference data for joining.
     $uplf = TTnew('UserPreferenceListFactory');
     $uplf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
     Debug::Text(' User Preference Rows: ' . $ulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     $this->getProgressBarObject()->start($this->getAMFMessageID(), $uplf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...'));
     foreach ($uplf as $key => $up_obj) {
         $this->tmp_data['user_preference'][$up_obj->getUser()] = (array) $up_obj->getObjectAsArray($columns);
         $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
     }
     //Get user wage data for joining.
     $filter_data['wage_group_id'] = 0;
     //Use default wage groups only.
     $uwlf = TTnew('UserWageListFactory');
     $uwlf->getAPILastWageSearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
     Debug::Text(' User Wage Rows: ' . $uwlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     $this->getProgressBarObject()->start($this->getAMFMessageID(), $ulf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...'));
     foreach ($uwlf as $key => $uw_obj) {
         if ($wage_permission_children_ids === TRUE or in_array($uw_obj->getUser(), $wage_permission_children_ids)) {
             $this->tmp_data['user_wage'][$uw_obj->getUser()] = (array) $uw_obj->getObjectAsArray($columns);
             if ($currency_convert_to_base == TRUE and is_object($base_currency_obj)) {
                 $this->tmp_data['user_wage'][$uw_obj->getUser()]['current_currency'] = Option::getByKey($base_currency_obj->getId(), $currency_options);
                 if (isset($this->tmp_data['user'][$uw_obj->getUser()]['currency_rate'])) {
                     $this->tmp_data['user_wage'][$uw_obj->getUser()]['hourly_rate'] = $base_currency_obj->getBaseCurrencyAmount($uw_obj->getHourlyRate(), $this->tmp_data['user'][$uw_obj->getUser()]['currency_rate'], $currency_convert_to_base);
                     $this->tmp_data['user_wage'][$uw_obj->getUser()]['wage'] = $base_currency_obj->getBaseCurrencyAmount($uw_obj->getWage(), $this->tmp_data['user'][$uw_obj->getUser()]['currency_rate'], $currency_convert_to_base);
                 }
             }
             $this->tmp_data['user_wage'][$uw_obj->getUser()]['effective_date'] = isset($this->tmp_data['user_wage'][$uw_obj->getUser()]['effective_date']) ? TTDate::parseDateTime($this->tmp_data['user_wage'][$uw_obj->getUser()]['effective_date']) : NULL;
         }
         $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
     }
     //Get user bank data for joining.
     $balf = TTnew('BankAccountListFactory');
     $balf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
     Debug::Text(' User Bank Rows: ' . $balf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     $this->getProgressBarObject()->start($this->getAMFMessageID(), $balf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...'));
     foreach ($balf as $key => $ba_obj) {
         $this->tmp_data['user_bank'][$ba_obj->getUser()] = (array) $ba_obj->getObjectAsArray($columns);
         $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
     }
     //Debug::Arr($this->tmp_data['user_preference'], 'TMP Data: ', __FILE__, __LINE__, __METHOD__,10);
     return TRUE;
 }
Beispiel #30
0
 function Rotate()
 {
     //Loop through config entries
     if (is_array($this->config_arr) and isset($this->config_arr[0])) {
         foreach ($this->config_arr as $rotate_config) {
             //Debug::Arr($rotate_config, ' Log Rotate Config: ', __FILE__, __LINE__, __METHOD__, 10);
             if (isset($rotate_config['directory']) and $rotate_config['directory'] != '') {
                 Debug::Text(' Rotating Logs: Dir: ' . $rotate_config['directory'] . ' File: ' . $rotate_config['file'], __FILE__, __LINE__, __METHOD__, 10);
                 $files = $this->getFileList($rotate_config['directory'], $rotate_config['file'], $rotate_config['recurse']);
                 //Debug::Arr( $files, 'Matching files: ', __FILE__, __LINE__, __METHOD__, 10);
                 if (is_array($files) and count($files) > 0) {
                     $this->_rotate($files, $rotate_config);
                 } else {
                     Debug::Text(' No files to rotate...', __FILE__, __LINE__, __METHOD__, 10);
                 }
             }
         }
     } else {
         Debug::Text(' No config loaded!', __FILE__, __LINE__, __METHOD__, 10);
     }
     return TRUE;
 }