function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Loop through all permission control rows and set the levels as best we can.
     $pclf = TTnew('PermissionControlListFactory');
     $pclf->getAll();
     if ($pclf->getRecordCount() > 0) {
         $pf = TTnew('PermissionFactory');
         $preset_options = $pf->getOptions('preset');
         $preset_level_options = $pf->getOptions('preset_level');
         foreach ($pclf as $pc_obj) {
             $name = $pc_obj->getName();
             $closest_preset_id = Misc::findClosestMatch($name, $preset_options, 75);
             if (isset($preset_level_options[$closest_preset_id])) {
                 $preset_level = $preset_level_options[$closest_preset_id];
             } else {
                 $preset_level = 1;
                 //Use the lowest level if we can't find one, so by default they can't add a new administrator/supervisor.
                 //Try to count the number of permissions and match them to the number of permissions in each preset and use the closest level?
                 $permission_user_data = $pc_obj->getPermission();
                 if (is_array($permission_user_data)) {
                     foreach ($preset_options as $preset => $preset_name) {
                         $tmp_preset_permissions = $pf->getPresetPermissions($preset, array());
                         $preset_permission_diff_arr = Misc::arrayDiffAssocRecursive($permission_user_data, $tmp_preset_permissions);
                         $preset_permission_diff_count = count($preset_permission_diff_arr, COUNT_RECURSIVE);
                         Debug::text('Preset Permission Diff Count...: ' . $preset_permission_diff_count . ' Preset ID: ' . $preset, __FILE__, __LINE__, __METHOD__, 10);
                         $preset_match[$preset] = $preset_permission_diff_count;
                     }
                     unset($tmp_preset_permissions);
                     krsort($preset_match);
                     //Flip the array so if there are more then one preset with the same match_count, we use the smallest preset value.
                     $preset_match = array_flip($preset_match);
                     //Flip the array back so the key is the match_preset again.
                     $preset_match = array_flip($preset_match);
                     foreach ($preset_match as $best_match_preset => $match_value) {
                         break;
                     }
                     Debug::Arr($preset_match, 'Preset Match: Best Match: ' . $best_match_preset . ' Value: ' . $match_value . ' Current Name: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 10);
                     if (isset($preset_options[$best_match_preset])) {
                         $preset_level = $preset_level_options[$best_match_preset];
                         //Use the preset level minus one, so they don't match exactly.
                         if ($preset_level > 1) {
                             $preset_level--;
                         }
                         Debug::Text('Closest PreSet Match Level: ' . $preset_level . ' Tmp: ' . $preset_options[$best_match_preset], __FILE__, __LINE__, __METHOD__, 10);
                     }
                 }
             }
             Debug::Text('Closest Match For: ' . $name . ' ID: ' . (int) $closest_preset_id . ' Level: ' . $preset_level, __FILE__, __LINE__, __METHOD__, 10);
             //Update level for permission group.
             $pc_obj->setLevel($preset_level);
             if ($pc_obj->isValid()) {
                 $pc_obj->Save();
             }
             unset($pc_obj);
         }
     }
     unset($pclf);
     return TRUE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Go through each permission group, and enable payroll export report for anyone who can see pay stub summary report.
     $clf = TTnew('CompanyListFactory');
     $clf->getAll();
     if ($clf->getRecordCount() > 0) {
         foreach ($clf as $c_obj) {
             Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
             if ($c_obj->getStatus() != 30) {
                 $pclf = TTnew('PermissionControlListFactory');
                 $pclf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('name' => 'asc'));
                 //Force order to avoid referencing column that was added in a later version (level)
                 if ($pclf->getRecordCount() > 0) {
                     foreach ($pclf as $pc_obj) {
                         Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
                         $plf = TTnew('PermissionListFactory');
                         $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'report', 'view_pay_stub_summary');
                         if ($plf->getRecordCount() > 0) {
                             Debug::text('Found permission group with pay stub report enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9);
                             $pc_obj->setPermission(array('report' => array('view_payroll_export' => TRUE)));
                         } else {
                             Debug::text('Permission group does NOT have pay stub report enabled...', __FILE__, __LINE__, __METHOD__, 9);
                         }
                     }
                 }
             }
         }
     }
     return TRUE;
 }
 function getFormObject($form, $country = NULL, $province = NULL, $district = NULL)
 {
     $class_name = 'GovernmentForms';
     $class_directory = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'country';
     if ($country != '') {
         $class_name .= '_' . strtoupper($country);
         $class_directory .= DIRECTORY_SEPARATOR . strtolower($country);
     }
     if ($province != '') {
         $class_name .= '_' . strtoupper($province);
         $class_directory .= DIRECTORY_SEPARATOR . strtolower($province);
     }
     if ($district != '') {
         $class_name .= '_' . strtoupper($district);
         $class_directory .= DIRECTORY_SEPARATOR . strtolower($district);
     }
     $class_name .= '_' . $form;
     $class_file_name = $class_directory . DIRECTORY_SEPARATOR . strtolower($form) . '.class.php';
     Debug::text('Class Directory: ' . $class_directory, __FILE__, __LINE__, __METHOD__, 10);
     Debug::text('Class File Name: ' . $class_file_name, __FILE__, __LINE__, __METHOD__, 10);
     Debug::text('Class Name: ' . $class_name, __FILE__, __LINE__, __METHOD__, 10);
     if (file_exists($class_file_name)) {
         include_once $class_file_name;
         $obj = new $class_name();
         $obj->setClassDirectory($class_directory);
         return $obj;
     } else {
         Debug::text('Class File does not exist!', __FILE__, __LINE__, __METHOD__, 10);
     }
     return FALSE;
 }
Esempio n. 4
0
 function getStateTaxPayable()
 {
     //Arizona is a percent of federal tax rate.
     //However after 01-Jul-10 it changed to a straight percent of gross.
     $annual_income = $this->getAnnualTaxableIncome();
     $rate = $this->getUserValue1();
     Debug::text('Raw Rate: ' . $rate, __FILE__, __LINE__, __METHOD__, 10);
     //Because of the change from a percent of federal rate to a gross rate,
     //add some checks so if an employee's amount isn't changed we default to the closest rate.
     if ($rate >= 39.5) {
         $rate = 5.1;
     } elseif ($rate >= 33.1) {
         $rate = 4.2;
     } elseif ($rate >= 26.7) {
         $rate = 3.6;
     } elseif ($rate >= 24.5) {
         $rate = 2.7;
     } elseif ($rate >= 20.3) {
         $rate = 1.8;
     } elseif ($rate >= 10.7) {
         $rate = 1.3;
     }
     Debug::text(' Adjusted Rate: ' . $rate, __FILE__, __LINE__, __METHOD__, 10);
     $retval = bcmul($annual_income, bcdiv($rate, 100));
     if ($retval < 0) {
         $retval = 0;
     }
     Debug::text('State Annual Tax Payable: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
     return $retval;
 }
 function postInstall()
 {
     global $cache;
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     return TRUE;
 }
Esempio n. 6
0
 static function text($val)
 {
     if (is_object($val)) {
         if (method_exists($val, 'hasMethod')) {
             $hasDebugMethod = $val->hasMethod('debug');
         } else {
             $hasDebugMethod = method_exists($val, 'debug');
         }
         if ($hasDebugMethod) {
             return $val->debug();
         }
     }
     if (is_array($val)) {
         $result = "<ul>\n";
         foreach ($val as $k => $v) {
             $result .= "<li>{$k} = " . Debug::text($v) . "</li>\n";
         }
         $val = $result . "</ul>\n";
     } else {
         if (is_object($val)) {
             $val = var_export($val, true);
         } else {
             if (true || !Director::is_ajax()) {
                 $val = "<pre style=\"font-family: Courier new\">" . htmlentities($val) . "</pre>\n";
             }
         }
     }
     return $val;
 }
 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;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Make sure Medicare Employer uses the same include/exclude accounts as Medicare Employee.
     $clf = TTnew('CompanyListFactory');
     $clf->getAll();
     if ($clf->getRecordCount() > 0) {
         foreach ($clf as $c_obj) {
             Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
             if ($c_obj->getStatus() != 30) {
                 $ppslf = TTNew('PayPeriodScheduleListFactory');
                 $ppslf->getByCompanyID($c_obj->getId());
                 if ($ppslf->getRecordCount() > 0) {
                     $minimum_time_between_shifts = $ppslf->getCurrent()->getNewDayTriggerTime();
                 }
                 if (isset($minimum_time_between_shifts)) {
                     $pplf = TTNew('PremiumPolicyListFactory');
                     $pplf->getAPISearchByCompanyIdAndArrayCriteria($c_obj->getID(), array('type_id' => 50));
                     if ($pplf->getRecordCount() > 0) {
                         foreach ($pplf as $pp_obj) {
                             $pp_obj->setMinimumTimeBetweenShift($minimum_time_between_shifts);
                             if ($pp_obj->isValid()) {
                                 $pp_obj->Save();
                             }
                         }
                     }
                 }
             }
         }
     }
     return TRUE;
 }
Esempio n. 9
0
 function delete()
 {
     if (file_exists($this->getFileName())) {
         return unlink($this->getFileName());
     }
     Debug::text(' Failed deleting lock file: ' . $this->file_name, __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
Esempio n. 10
0
	public function debug() {
		$val = "<h2>" . $this->class . "</h2><ul>";
		foreach($this->toNestedArray() as $item) {
			$val .= "<li style=\"list-style-type: disc; margin-left: 20px\">" . Debug::text($item) . "</li>";
		}
		$val .= "</ul>";
		return $val;
	}
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Assume any company that already exists is already setup.
     $cf = new CompanyFactory();
     $query = 'update ' . $cf->getTable() . ' set is_setup_complete = 1';
     $this->db->Execute($query);
     return TRUE;
 }
Esempio n. 12
0
 function getStateTaxPayable()
 {
     //Arizona is a percent of federal tax rate.
     $federal_tax = $this->getFederalTaxPayable();
     $rate = bcdiv($this->getUserValue1(), 100);
     $retval = bcmul($federal_tax, $rate);
     if ($retval < 0) {
         $retval = 0;
     }
     Debug::text('State Annual Tax Payable: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
     return $retval;
 }
Esempio n. 13
0
 function getDistrictTaxPayable()
 {
     $annual_income = $this->getDistrictAnnualTaxableIncome();
     $retval = 0;
     if ($annual_income > 0) {
         $rate = bcdiv($this->getUserValue3(), 100);
         $retval = bcmul($annual_income, $rate);
     }
     if ($retval < 0) {
         $retval = 0;
     }
     Debug::text('District Annual Tax Payable: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
     return $retval;
 }
Esempio n. 14
0
    static function setCrumb($name, $url = NULL)
    {
        global $db, $current_user;
        //
        // If bread crumbs "seem" like they are getting overwritten, make sure the
        // setCrumb function is being called ONLY in the default section of the switch statement. NOT THE TOP.
        //
        if ($url == '') {
            $url = $_SERVER['REQUEST_URI'];
        }
        if (!is_object($current_user)) {
            return FALSE;
        }
        Debug::text('Dropping Bread Crumb: ' . $name . ' URL: ' . $url, __FILE__, __LINE__, __METHOD__, 10);
        $ph = array('user_id' => $current_user->getId(), 'name' => $name);
        //Determine if we should update or insert bread crumb.
        $query = 'select name
					FROM bread_crumb
					WHERE user_id = ?
						AND name = ?
					LIMIT 1';
        try {
            $rs = $db->Execute($query, $ph);
        } catch (Exception $e) {
            throw new DBError($e);
        }
        if ($rs->RecordCount() == 1) {
            $ph = array('url' => $url, 'created_date' => TTDate::getTime(), 'user_id' => $current_user->getId(), 'name' => $name);
            $query = 'UPDATE bread_crumb
						SET		url = ?,
								created_date = ?
						WHERE	user_id = ?
							AND name = ?';
        } else {
            $ph = array('user_id' => $current_user->getId(), 'name' => $name, 'url' => $url, 'created_date' => TTDate::getTime());
            $query = 'insert into bread_crumb (user_id,name,url,created_date)
							VALUES(
									?,
									?,
									?,
									?
								)';
        }
        try {
            $db->Execute($query, $ph);
        } catch (Exception $e) {
            throw new DBError($e);
        }
        return TRUE;
    }
    function postInstall()
    {
        Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
        //Go through each permission group, and enable affordable_care report for for anyone who can view W2's.
        $clf = TTnew('CompanyListFactory');
        $clf->getAll();
        if ($clf->getRecordCount() > 0) {
            foreach ($clf as $c_obj) {
                Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
                if ($c_obj->getStatus() != 30) {
                    $pclf = TTnew('PermissionControlListFactory');
                    $pclf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('name' => 'asc'));
                    //Force order to prevent references to columns that haven't been created yet.
                    if ($pclf->getRecordCount() > 0) {
                        foreach ($pclf as $pc_obj) {
                            Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
                            $plf = TTnew('PermissionListFactory');
                            $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'report', array('view_formW2'));
                            if ($plf->getRecordCount() > 0) {
                                Debug::text('Found permission group with view_formW2 enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9);
                                $pc_obj->setPermission(array('report' => array('view_affordable_care' => TRUE)));
                            } else {
                                Debug::text('Permission group does NOT have view_formW2 enabled...', __FILE__, __LINE__, __METHOD__, 9);
                            }
                        }
                    }
                }
            }
        }
        //Go through all stations and disable ones that don't have any employees activated for them.
        //This greatly speeds up station checks, as most stations never have employees activated.
        $query = 'update station set status_id = 10
					where status_id = 20
					AND
					(
						( user_group_selection_type_id = 20 AND NOT EXISTS( select b.id from station_user_group as b WHERE id = b.station_id ) )
						AND
						( branch_selection_type_id = 20 AND NOT EXISTS( select c.id from station_branch as c WHERE id = c.station_id ) )
						AND
						( department_selection_type_id = 20 AND NOT EXISTS( select d.id from station_department as d WHERE id = d.station_id ) )
						AND
						NOT EXISTS( select f.id from station_exclude_user as f WHERE id = f.station_id )
						AND
						NOT EXISTS( select e.id from station_include_user as e WHERE id = e.station_id )
					)
					AND ( deleted = 0 )';
        $this->getDatabaseConnection()->Execute($query);
        return TRUE;
    }
 function testCR_2007a_BiWeekly_Single_LowIncome()
 {
     Debug::text('CR - BiWeekly - Beginning of 2007 01-Jan-07: ', __FILE__, __LINE__, __METHOD__, 10);
     $pd_obj = new PayrollDeduction('CR', NULL);
     $pd_obj->setDate(strtotime('01-Jan-07'));
     $pd_obj->setAnnualPayPeriods(26);
     //Bi-Weekly
     $pd_obj->setFederalFilingStatus(10);
     //Single
     $pd_obj->setFederalAllowance(1);
     //$pd_obj->setUserCurrency('CRC');
     $pd_obj->setGrossPayPeriodIncome(260000.0);
     $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '260000.00');
     $this->assertEquals($this->mf($pd_obj->getFederalPayPeriodDeductions()), '3993.85');
     //100.73
 }
Esempio n. 17
0
 function getStateTaxPayable()
 {
     $annual_income = $this->getStateAnnualTaxableIncome();
     $retval = 0;
     if ($annual_income > 0) {
         $rate = $this->getData()->getStateRate($annual_income);
         $state_constant = $this->getData()->getStateConstant($annual_income);
         $state_rate_income = $this->getData()->getStateRatePreviousIncome($annual_income);
         $retval = bcadd(bcmul(bcsub($annual_income, $state_rate_income), $rate), $state_constant);
     }
     if ($retval < 0) {
         $retval = 0;
     }
     Debug::text('State Annual Tax Payable: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
     return $retval;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Add calcQuickException cronjob to database.
     $cjf = TTnew('CronJobFactory');
     $cjf->setName('calcQuickExceptions');
     //This is primarily for Late Starting/Ending Shift, assume a 5 minute grace period, so notifications
     //can be emailed out as soon as 7 minutes after the hour and every 15 minute intervals thereafter.
     $cjf->setMinute('7,22,37,52');
     $cjf->setHour('*');
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('*');
     $cjf->setCommand('calcQuickExceptions.php');
     $cjf->Save();
     return TRUE;
 }
Esempio n. 19
0
 function getStateTaxPayable()
 {
     $annual_income = $this->getStateAnnualTaxableIncome();
     $retval = 0;
     if ($annual_income > 0) {
         $retarr = $this->getDataFromRateArray($this->getDate(), $this->state_options);
         if ($retarr == FALSE) {
             return FALSE;
         }
         $rate = bcdiv($retarr['rate'], 100);
         $retval = bcmul($annual_income, $rate);
     }
     if ($retval < 0) {
         $retval = 0;
     }
     Debug::text('State Annual Tax Payable: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
     return $retval;
 }
Esempio n. 20
0
 static function addEntry($object_id, $action_id, $description, $user_id, $table, $object = NULL)
 {
     global $config_vars;
     if (isset($config_vars['other']['disable_audit_log']) and $config_vars['other']['disable_audit_log'] == TRUE) {
         return TRUE;
     }
     if (!is_numeric($object_id)) {
         return FALSE;
     }
     if ($action_id == '') {
         return FALSE;
     }
     if ($user_id == '') {
         global $current_user;
         if (is_object($current_user)) {
             $user_id = $current_user->getId();
         } else {
             $user_id = 0;
         }
     }
     if ($table == '') {
         return FALSE;
     }
     $lf = TTnew('LogFactory');
     $lf->setObject($object_id);
     $lf->setAction($action_id);
     $lf->setTableName($table);
     $lf->setUser((int) $user_id);
     $lf->setDescription($description);
     //Debug::text('Object ID: '. $object_id .' Action ID: '. $action_id .' Table: '. $table .' Description: '. $description, __FILE__, __LINE__, __METHOD__, 10);
     if ($lf->isValid() === TRUE) {
         $insert_id = $lf->Save();
         if ((!isset($config_vars['other']['disable_audit_log_detail']) or isset($config_vars['other']['disable_audit_log_detail']) and $config_vars['other']['disable_audit_log_detail'] != TRUE) and is_object($object) and $object->getEnableSystemLogDetail() == TRUE) {
             $ldf = TTnew('LogDetailFactory');
             $ldf->addLogDetail($action_id, $insert_id, $object);
         } else {
             Debug::text('LogDetail Disabled... Object ID: ' . $object_id . ' Action ID: ' . $action_id . ' Table: ' . $table . ' Description: ' . $description, __FILE__, __LINE__, __METHOD__, 10);
             //Debug::text('LogDetail Disabled... Config: '. (int)$config_vars['other']['disable_audit_log_detail'] .' Function: '. (int)$object->getEnableSystemLogDetail(), __FILE__, __LINE__, __METHOD__, 10);
         }
         return TRUE;
     }
     return FALSE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //New Pay Period Schedule format, update any current schedules.
     $ppslf = new PayPeriodScheduleListFactory();
     $ppslf->getAll();
     Debug::text('Found Pay Period Schedules: ' . $ppslf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 9);
     if ($ppslf->getRecordCount() > 0) {
         foreach ($ppslf as $pps_obj) {
             if ($pps_obj->getType() == 10 or $pps_obj->getType() == 20) {
                 $pps_obj->setStartDayOfWeek(TTDate::getDayOfWeek(TTDate::strtotime($pps_obj->getColumn('anchor_date'))));
                 $pps_obj->setTransactionDate(floor((TTDate::strtotime($pps_obj->getColumn('primary_transaction_date')) - TTDate::strtotime($pps_obj->getColumn('primary_date'))) / 86400) + 1);
             } elseif ($pps_obj->getType() == 30) {
                 $pps_obj->setPrimaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('anchor_date'))) + 1);
                 if ($pps_obj->getColumn('primary_transaction_date_ldom') == 1) {
                     $pps_obj->setPrimaryTransactionDayOfMonth(-1);
                 } else {
                     $pps_obj->setPrimaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_transaction_date'))));
                 }
                 $pps_obj->setSecondaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_date'))));
                 if ($pps_obj->getColumn('secondary_transaction_date_ldom') == 1) {
                     $pps_obj->setSecondaryTransactionDayOfMonth(-1);
                 } else {
                     $pps_obj->setSecondaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('secondary_transaction_date'))));
                 }
             } elseif ($pps_obj->getType() == 50) {
                 $pps_obj->setPrimaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('anchor_date'))));
                 if ($pps_obj->getColumn('primary_transaction_date_ldom') == 1) {
                     $pps_obj->setPrimaryTransactionDayOfMonth(-1);
                 } else {
                     $pps_obj->setPrimaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_transaction_date'))));
                 }
             }
             if ($pps_obj->getColumn('transaction_date_bd') == 1 or $pps_obj->getColumn('secondary_transaction_date_bd') == 1) {
                 $pps_obj->setTransactionDateBusinessDay(TRUE);
             }
             if ($pps_obj->isValid()) {
                 $pps_obj->Save();
             }
         }
     }
     return TRUE;
 }
Esempio n. 22
0
 function getFormObject($form)
 {
     $class_name = 'ChequeForms';
     $class_name .= '_' . $form;
     $class_directory = dirname(__FILE__);
     $class_file_name = $class_directory . DIRECTORY_SEPARATOR . strtolower($form) . '.class.php';
     Debug::text('Class Directory: ' . $class_directory, __FILE__, __LINE__, __METHOD__, 10);
     Debug::text('Class File Name: ' . $class_file_name, __FILE__, __LINE__, __METHOD__, 10);
     Debug::text('Class Name: ' . $class_name, __FILE__, __LINE__, __METHOD__, 10);
     if (file_exists($class_file_name)) {
         include_once $class_file_name;
         $obj = new $class_name();
         $obj->setClassDirectory($class_directory);
         $obj->default_font = TTi18n::getPDFDefaultFont();
         return $obj;
     } else {
         Debug::text('Class File does not exist!', __FILE__, __LINE__, __METHOD__, 10);
     }
     return FALSE;
 }
 function postInstall()
 {
     global $cache;
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     $cjlf = new CronJobListFactory();
     $cjlf->getAll();
     if ($cjlf->getRecordCount() > 0) {
         foreach ($cjlf as $cj_obj) {
             Debug::text('Original Command: ' . $cj_obj->getCommand(), __FILE__, __LINE__, __METHOD__, 9);
             $retval = preg_match('/([A-Za-z0-9]+\\.php)/i', $cj_obj->getCommand(), $matches);
             if (isset($matches[0]) and $matches[0] != '') {
                 Debug::text('New Command: ' . $matches[0], __FILE__, __LINE__, __METHOD__, 9);
                 $cj_obj->setCommand($matches[0]);
                 if ($cj_obj->isValid()) {
                     $cj_obj->Save();
                 }
             }
         }
     }
     return TRUE;
 }
 function postInstall()
 {
     global $config_vars;
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     $sslf = new SystemSettingListFactory();
     //
     // Tax Data Version
     //
     $sslf->getByName('tax_data_version');
     if ($sslf->getRecordCount() == 1) {
         $obj = $sslf->getCurrent();
     } else {
         $obj = new SystemSettingListFactory();
     }
     $tax_data_version = '20091101';
     $obj->setName('tax_data_version');
     $obj->setValue($tax_data_version);
     if ($obj->isValid()) {
         Debug::text('Setting Tax Data Version to: ' . $tax_data_version, __FILE__, __LINE__, __METHOD__, 9);
         $obj->Save();
     }
     //
     // Tax Engine Version
     //
     $sslf->getByName('tax_engine_version');
     if ($sslf->getRecordCount() == 1) {
         $obj = $sslf->getCurrent();
     } else {
         $obj = new SystemSettingListFactory();
     }
     $tax_engine_version = '1.0.12';
     $obj->setName('tax_engine_version');
     $obj->setValue($tax_engine_version);
     if ($obj->isValid()) {
         Debug::text('Setting Tax Engine Version to: ' . $tax_engine_version, __FILE__, __LINE__, __METHOD__, 9);
         $obj->Save();
     }
     return TRUE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Add Calendar Based Accruals to Cron.
     $maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'maint' . DIRECTORY_SEPARATOR;
     if (PHP_OS == 'WINNT') {
         $cron_job_base_command = 'php-win.exe ' . $maint_base_path;
     } else {
         $cron_job_base_command = 'php ' . $maint_base_path;
     }
     Debug::text('Cron Job Base Command: ' . $cron_job_base_command, __FILE__, __LINE__, __METHOD__, 9);
     $cjf = new CronJobFactory();
     $cjf->setName('AddAccrualPolicyTime');
     $cjf->setMinute(30);
     $cjf->setHour(1);
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('*');
     $cjf->setCommand($cron_job_base_command . 'AddAccrualPolicyTime.php');
     $cjf->Save();
     return TRUE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Go through each permission group, and enable absence/schedule edit field permissions for anyone who can edit absence/schedules.
     $clf = TTnew('CompanyListFactory');
     $clf->getAll();
     if ($clf->getRecordCount() > 0) {
         foreach ($clf as $c_obj) {
             Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
             if ($c_obj->getStatus() != 30) {
                 $pclf = TTnew('PermissionControlListFactory');
                 $pclf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('name' => 'asc'));
                 //Force order to prevent references to columns that haven't been created yet.
                 if ($pclf->getRecordCount() > 0) {
                     foreach ($pclf as $pc_obj) {
                         Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
                         $plf = TTnew('PermissionListFactory');
                         $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'absence', array('edit', 'edit_own', 'edit_child'));
                         if ($plf->getRecordCount() > 0) {
                             Debug::text('Found permission group with Edit Absence enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9);
                             $pc_obj->setPermission(array('absence' => array('edit_branch' => TRUE, 'edit_department' => TRUE)));
                         } else {
                             Debug::text('Permission group does NOT have absences enabled...', __FILE__, __LINE__, __METHOD__, 9);
                         }
                         $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'schedule', array('edit', 'edit_own', 'edit_child'));
                         if ($plf->getRecordCount() > 0) {
                             Debug::text('Found permission group with Edit Schedule enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9);
                             $pc_obj->setPermission(array('schedule' => array('edit_branch' => TRUE, 'edit_department' => TRUE, 'edit_job' => TRUE, 'edit_job_item' => TRUE)));
                         } else {
                             Debug::text('Permission group does NOT have schedules enabled...', __FILE__, __LINE__, __METHOD__, 9);
                         }
                     }
                 }
             }
         }
     }
     return TRUE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     $clf = new CompanyListFactory();
     $clf->StartTransaction();
     $clf->getAll();
     if ($clf->getRecordCount() > 0) {
         foreach ($clf as $c_obj) {
             if ($c_obj->getStatus() == 10) {
                 $ulf = new UserListFactory();
                 $ulf->getHighestEmployeeNumberByCompanyId($c_obj->getId());
                 if ($ulf->getRecordCount() > 0) {
                     $next_available_employee_number = $ulf->getCurrent()->getEmployeeNumber() + 1;
                 } else {
                     $next_available_employee_number = 1;
                 }
                 $ulf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('hire_date' => 'asc'));
                 if ($ulf->getRecordCount() > 0) {
                     foreach ($ulf as $u_obj) {
                         if ($u_obj->getEmployeeNumber() == '') {
                             Debug::text('Setting Employee Number to: ' . $next_available_employee_number . ' for ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 9);
                             $u_obj->setEmployeeNumber($next_available_employee_number);
                             if ($u_obj->isValid()) {
                                 $u_obj->Save();
                                 $next_available_employee_number++;
                             }
                         } else {
                             Debug::text('NOT Setting Employee Number for ' . $u_obj->getUserName() . ' already set to: ' . $u_obj->getEmployeeNumber(), __FILE__, __LINE__, __METHOD__, 9);
                         }
                     }
                 }
             }
         }
     }
     //$clf->FailTransaction();
     $clf->CommitTransaction();
     return TRUE;
 }
Esempio n. 28
0
 function getProvincialSurtax()
 {
     /*
     	V1 =
     	For YU
     		Where T4 <= 6000
     		V1 = 0
     
     		Where T4 > 6000
     		V1 = 0.10 * ( T4 - 6000 )
     */
     $T4 = $this->getProvincialBasicTax();
     $V1 = 0;
     if ($this->getDate() >= strtotime('01-Jan-2008')) {
         if ($T4 <= 6000) {
             $V1 = 0;
         } elseif ($T4 > 6000) {
             $V1 = bcmul(0.05, bcsub($T4, 6000));
         }
     }
     Debug::text('V1: ' . $V1, __FILE__, __LINE__, __METHOD__, 10);
     return $V1;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Go through all employee wages and update HourlyRate to the accurate annual hourly rate.
     //Take into account wage entries that don't have the proper effective date based on the employees hire date, force a correct effective_date.
     $uwlf = TTnew('UserWageListFactory');
     $uwlf->getAll();
     if ($uwlf->getRecordCount() > 0) {
         foreach ($uwlf as $uw_obj) {
             $uw_obj->setHourlyRate($uw_obj->calcHourlyRate(time(), TRUE));
             if ($uw_obj->getWageGroup() == 0 and $uw_obj->isValidEffectiveDate($uw_obj->getEffectiveDate()) == FALSE) {
                 //Set wage effective date to employees hire date.
                 $u_obj = $uw_obj->getUserObject();
                 if (is_object($u_obj)) {
                     $uw_obj->setEffectiveDate($u_obj->getHireDate());
                 }
             }
             if ($uw_obj->isValid()) {
                 $uw_obj->Save();
             }
         }
     }
     return TRUE;
 }
Esempio n. 30
0
 function getProvincialTaxReduction()
 {
     $A = $this->getAnnualTaxableIncome();
     $T4 = $this->getProvincialBasicTax();
     $V1 = $this->getProvincialSurtax();
     $Y = 0;
     $S = 0;
     Debug::text('BC Specific - Province: ' . $this->getProvince(), __FILE__, __LINE__, __METHOD__, 10);
     $tax_reduction_data = $this->getProvincialTaxReductionData($this->getDate(), $this->getProvince());
     if (is_array($tax_reduction_data)) {
         if ($A <= $tax_reduction_data['income1']) {
             Debug::text('S: Annual Income less than: ' . $tax_reduction_data['income1'], __FILE__, __LINE__, __METHOD__, 10);
             if ($T4 > $tax_reduction_data['amount']) {
                 $S = $tax_reduction_data['amount'];
             } else {
                 $S = $T4;
             }
         } elseif ($A > $tax_reduction_data['income1'] and $A <= $tax_reduction_data['income2']) {
             Debug::text('S: Annual Income less than ' . $tax_reduction_data['income2'], __FILE__, __LINE__, __METHOD__, 10);
             $tmp_S = bcsub($tax_reduction_data['amount'], bcmul(bcsub($A, $tax_reduction_data['income1']), $tax_reduction_data['rate']));
             Debug::text('Tmp_S: ' . $tmp_S, __FILE__, __LINE__, __METHOD__, 10);
             if ($T4 > $tmp_S) {
                 $S = $tmp_S;
             } else {
                 $S = $T4;
             }
             unset($tmp_S);
         }
     }
     Debug::text('aS: ' . $S, __FILE__, __LINE__, __METHOD__, 10);
     if ($S < 0) {
         $S = 0;
     }
     Debug::text('bS: ' . $S, __FILE__, __LINE__, __METHOD__, 10);
     return $S;
 }