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;
 }
예제 #2
0
 function generateData()
 {
     global $current_company, $current_user;
     TTDate::setTimeZone('PST8PDT');
     $current_epoch = time();
     $cf = new CompanyFactory();
     $cf->StartTransaction();
     $company_id = $this->createCompany();
     $clf = new CompanyListFactory();
     $clf->getById($company_id);
     $current_company = $clf->getCurrent();
     if ($company_id !== FALSE) {
         Debug::Text('Company Created Successfully!', __FILE__, __LINE__, __METHOD__, 10);
         $this->createPermissionGroups($company_id);
         //Create currency
         $currency_ids[] = $this->createCurrency($company_id, 10);
         //USD
         $currency_ids[] = $this->createCurrency($company_id, 20);
         //CAD
         //Create branch
         $branch_ids[] = $this->createBranch($company_id, 10);
         //NY
         $branch_ids[] = $this->createBranch($company_id, 20);
         //WA
         //Create departments
         $department_ids[] = $this->createDepartment($company_id, 10);
         $department_ids[] = $this->createDepartment($company_id, 20);
         //Create stations
         $station_id = $this->createStation($company_id);
         //Create pay stub accounts.
         $this->createPayStubAccount($company_id);
         //Link pay stub accounts.
         $this->createPayStubAccountLink($company_id);
         //Company Deductions
         $this->createCompanyDeduction($company_id);
         //Wage Groups
         $wage_group_ids[] = $this->createUserWageGroups($company_id);
         //User Groups
         $user_group_ids[] = $this->createUserGroup($company_id, 10, 0);
         $user_group_ids[] = $this->createUserGroup($company_id, 20, $user_group_ids[0]);
         $user_group_ids[] = $this->createUserGroup($company_id, 30, $user_group_ids[0]);
         $user_group_ids[] = $this->createUserGroup($company_id, 40, 0);
         $user_group_ids[] = $this->createUserGroup($company_id, 50, $user_group_ids[3]);
         //Users
         $user_ids[] = $this->createUser($company_id, 10, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[0]);
         $user_ids[] = $this->createUser($company_id, 11, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]);
         $user_ids[] = $this->createUser($company_id, 12, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]);
         $user_ids[] = $this->createUser($company_id, 13, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]);
         $user_ids[] = $this->createUser($company_id, 14, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]);
         $user_ids[] = $this->createUser($company_id, 15, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[1]);
         $user_ids[] = $this->createUser($company_id, 16, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]);
         $user_ids[] = $this->createUser($company_id, 17, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]);
         $user_ids[] = $this->createUser($company_id, 18, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[2]);
         $user_ids[] = $this->createUser($company_id, 19, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[2]);
         $user_ids[] = $this->createUser($company_id, 20, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[2]);
         $user_ids[] = $this->createUser($company_id, 21, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]);
         $user_ids[] = $this->createUser($company_id, 22, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]);
         $user_ids[] = $this->createUser($company_id, 23, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]);
         $user_ids[] = $this->createUser($company_id, 24, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]);
         $user_ids[] = $this->createUser($company_id, 25, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]);
         $user_ids[] = $this->createUser($company_id, 26, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]);
         $user_ids[] = $this->createUser($company_id, 27, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]);
         $user_ids[] = $this->createUser($company_id, 28, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]);
         $user_ids[] = $this->createUser($company_id, 29, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]);
         $user_ids[] = $this->createUser($company_id, 30, 0, $branch_ids[1], $department_ids[0], $currency_ids[0], $user_group_ids[4]);
         $user_ids[] = $this->createUser($company_id, 40, 0, $branch_ids[1], $department_ids[0], $currency_ids[0], $user_group_ids[4]);
         $current_user_id = $user_ids[] = $this->createUser($company_id, 100, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[1]);
         //Create random users.
         for ($i = 0; $i <= $this->getMaxRandomUsers(); $i++) {
             $tmp_user_id = $this->createUser($company_id, 999, 0, $branch_ids[$i % 2], $department_ids[$i % 2], $currency_ids[0], $user_group_ids[$i % 5]);
             if ($tmp_user_id != FALSE) {
                 $user_ids[] = $tmp_user_id;
             }
         }
         Debug::Arr($user_ids, 'All User IDs:', __FILE__, __LINE__, __METHOD__, 10);
         $ulf = new UserListFactory();
         $ulf->getById($current_user_id);
         $current_user = $ulf->getCurrent();
         unset($current_user_id);
         //Create policies
         $policy_ids['round'][] = $this->createRoundingPolicy($company_id, 10);
         //In
         $policy_ids['round'][] = $this->createRoundingPolicy($company_id, 20);
         //Out
         $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 10);
         //Bank Time
         $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 20);
         //Vacaction
         $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 30);
         //Sick
         $policy_ids['overtime'][] = $this->createOverTimePolicy($company_id, 10);
         $policy_ids['overtime'][] = $this->createOverTimePolicy($company_id, 20, $policy_ids['accrual'][0]);
         $policy_ids['premium'][] = $this->createPremiumPolicy($company_id, 10);
         $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 10, $policy_ids['accrual'][1]);
         $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 20, $policy_ids['accrual'][0]);
         $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 30, $policy_ids['accrual'][2]);
         $policy_ids['meal_1'] = $this->createMealPolicy($company_id);
         $policy_ids['schedule_1'] = $this->createSchedulePolicy($company_id, $policy_ids['meal_1']);
         $policy_ids['exception_1'] = $this->createExceptionPolicy($company_id);
         $hierarchy_user_ids = $user_ids;
         $root_user_id = array_pop($hierarchy_user_ids);
         unset($hierarchy_user_ids[0], $hierarchy_user_ids[1]);
         //Create authorization hierarchy
         $hierarchy_control_id = $this->createAuthorizationHierarchyControl($company_id, $hierarchy_user_ids);
         if ($root_user_id == FALSE) {
             Debug::Text('Administrator wasn\'t created! Duplicate username perhaps? Are we appending a random number?', __FILE__, __LINE__, __METHOD__, 10);
         }
         //Admin user at the top
         $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $root_user_id, 1);
         $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $user_ids[0], 2);
         $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $user_ids[1], 3);
         unset($hierarchy_user_ids, $root_user_id);
         //Pay Period Schedule
         $this->createPayPeriodSchedule($company_id, $user_ids);
         //Create Policy Group
         $this->createPolicyGroup($company_id, $policy_ids['meal_1'], $policy_ids['exception_1'], NULL, $policy_ids['overtime'], $policy_ids['premium'], $policy_ids['round'], $user_ids);
         if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL) {
             //Task Groups
             $task_group_ids[] = $this->createTaskGroup($company_id, 10, 0);
             $task_group_ids[] = $this->createTaskGroup($company_id, 20, $task_group_ids[0]);
             $task_group_ids[] = $this->createTaskGroup($company_id, 30, $task_group_ids[0]);
             $task_group_ids[] = $this->createTaskGroup($company_id, 40, 0);
             $task_group_ids[] = $this->createTaskGroup($company_id, 50, $task_group_ids[3]);
             $task_group_ids[] = $this->createTaskGroup($company_id, 60, $task_group_ids[3]);
             //Job Tasks
             $default_task_id = $this->createTask($company_id, 10, $task_group_ids[2]);
             $task_ids[] = $this->createTask($company_id, 20, $task_group_ids[1]);
             $task_ids[] = $this->createTask($company_id, 30, $task_group_ids[1]);
             $task_ids[] = $this->createTask($company_id, 40, $task_group_ids[2]);
             $task_ids[] = $this->createTask($company_id, 50, $task_group_ids[4]);
             $task_ids[] = $this->createTask($company_id, 60, $task_group_ids[4]);
             $task_ids[] = $this->createTask($company_id, 70, $task_group_ids[5]);
             //Job Groups
             $job_group_ids[] = $this->createJobGroup($company_id, 10, 0);
             $job_group_ids[] = $this->createJobGroup($company_id, 20, $job_group_ids[0]);
             $job_group_ids[] = $this->createJobGroup($company_id, 30, $job_group_ids[0]);
             $job_group_ids[] = $this->createJobGroup($company_id, 40, 0);
             $job_group_ids[] = $this->createJobGroup($company_id, 50, $job_group_ids[3]);
             $job_group_ids[] = $this->createJobGroup($company_id, 60, $job_group_ids[3]);
             //Jobs
             $job_ids[] = $this->createJob($company_id, 10, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 11, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 12, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 13, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 14, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 15, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]);
             $job_ids[] = $this->createJob($company_id, 16, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]);
             $job_ids[] = $this->createJob($company_id, 17, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]);
             $job_ids[] = $this->createJob($company_id, 18, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]);
             $job_ids[] = $this->createJob($company_id, 19, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]);
             $job_ids[] = $this->createJob($company_id, 20, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 21, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 22, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]);
             $job_ids[] = $this->createJob($company_id, 23, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]);
             $job_ids[] = $this->createJob($company_id, 24, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]);
             $job_ids[] = $this->createJob($company_id, 25, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]);
         } else {
             $task_ids[] = 0;
             $job_ids[] = 0;
         }
         //Create Accrual balances
         foreach ($user_ids as $user_id) {
             foreach ($policy_ids['accrual'] as $accrual_policy_id) {
                 $this->createAccrualBalance($user_id, $accrual_policy_id);
             }
             unset($accrual_policy_id);
         }
         //Create recurring schedule templates
         $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 10, $policy_ids['schedule_1']);
         //Morning shift
         $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 20, $policy_ids['schedule_1']);
         //Afternoon shift
         $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 30, $policy_ids['schedule_1']);
         //Evening shift
         $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 40);
         //Split Shift
         $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 50, $policy_ids['schedule_1']);
         //Full rotation
         $recurring_schedule_start_date = TTDate::getBeginWeekEpoch($current_epoch + 86400 * 7.5);
         $this->createRecurringSchedule($company_id, $recurring_schedule_ids[0], $recurring_schedule_start_date, '', array($user_ids[0], $user_ids[1], $user_ids[2], $user_ids[3], $user_ids[4]));
         $this->createRecurringSchedule($company_id, $recurring_schedule_ids[1], $recurring_schedule_start_date, '', array($user_ids[5], $user_ids[6], $user_ids[7], $user_ids[8], $user_ids[9]));
         $this->createRecurringSchedule($company_id, $recurring_schedule_ids[2], $recurring_schedule_start_date, '', array($user_ids[10], $user_ids[11], $user_ids[12], $user_ids[13], $user_ids[14]));
         //Create schedule for each employee.
         foreach ($user_ids as $user_id) {
             //Create schedule starting 6 weeks ago, up to the end of the week.
             $schedule_options_arr = array('status_id' => 10, 'start_time' => '08:00AM', 'end_time' => '05:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']);
             //$schedule_date = ($current_epoch-(86400*42));
             $schedule_date = $current_epoch - 86400 * 14;
             $schedule_end_date = TTDate::getEndWeekEpoch($current_epoch);
             //$schedule_date = ($current_epoch-(86400*14));
             //$schedule_end_date = ($current_epoch+(86400*28));
             while ($schedule_date <= $schedule_end_date) {
                 //Random departments/branches
                 $schedule_options_arr['branch_id'] = $branch_ids[rand(0, count($branch_ids) - 1)];
                 $schedule_options_arr['department_id'] = $department_ids[rand(0, count($department_ids) - 1)];
                 //Skip weekends.
                 if (date('w', $schedule_date) != 0 and date('w', $schedule_date) != 6) {
                     $this->createSchedule($user_id, $schedule_date, $schedule_options_arr);
                 }
                 $schedule_date += 86400;
             }
             //break;
             unset($schedule_options_arr, $schedule_date, $schedule_end_date, $user_id);
         }
         //Punch users in/out randomly.
         foreach ($user_ids as $user_id) {
             //Pick random jobs/tasks that are used for the entire date range.
             //So one employee isn't punching into 15 jobs.
             $user_random_job_ids = array_rand($job_ids, 2);
             $user_random_task_ids = array_rand($job_ids, 3);
             //Create punches starting 6 weeks ago, up to the end of the week.
             //$start_date = $punch_date = ($current_epoch-(86400*42));
             $start_date = $punch_date = $current_epoch - 86400 * 14;
             $end_date = TTDate::getEndWeekEpoch($current_epoch);
             //$start_date = $punch_date = ($current_epoch-(86400*14));
             //$end_date = ($current_epoch+(86400*28));
             $i = 0;
             while ($punch_date <= $end_date) {
                 $date_stamp = TTDate::getDate('DATE', $punch_date);
                 //$punch_full_time_stamp = strtotime($pc_data['date_stamp'].' '.$pc_data['time_stamp']);
                 $exception_cutoff_date = $current_epoch - 86400 * 14;
                 if (date('w', $punch_date) != 0 and date('w', $punch_date) != 6) {
                     if ($punch_date >= $exception_cutoff_date and $i % 4 == 0) {
                         $first_punch_in = rand(7, 8) . ':' . str_pad(rand(0, 30), 2, '0', STR_PAD_LEFT) . 'AM';
                         $last_punch_out = strtotime($date_stamp . ' ' . rand(4, 5) . ':' . str_pad(rand(0, 30), 2, '0', STR_PAD_LEFT) . 'PM');
                         if ($punch_date >= $exception_cutoff_date and rand(0, 20) == 0) {
                             //Create request
                             $this->createRequest(20, $user_id, $date_stamp);
                         }
                         if ($punch_date >= $exception_cutoff_date and rand(0, 16) == 0) {
                             //Create request
                             $this->createRequest(20, $user_id, $date_stamp);
                         }
                     } else {
                         $first_punch_in = '08:00AM';
                         if ($punch_date >= $exception_cutoff_date and $i % 10 == 0) {
                             //Don't punch out to generate exception.
                             $last_punch_out = NULL;
                             //Forgot to punch out request
                             $this->createRequest(30, $user_id, $date_stamp);
                         } else {
                             $last_punch_out = strtotime($date_stamp . ' 5:00PM');
                         }
                     }
                     //Weekdays
                     $this->createPunchPair($user_id, strtotime($date_stamp . ' ' . $first_punch_in), strtotime($date_stamp . ' 11:00AM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE);
                     $this->createPunchPair($user_id, strtotime($date_stamp . ' 11:00AM'), strtotime($date_stamp . ' 1:00PM'), array('in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE);
                     //Calc total time on last punch pair only.
                     $this->createPunchPair($user_id, strtotime($date_stamp . ' 2:00PM'), $last_punch_out, array('in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE);
                 } elseif ($punch_date > $exception_cutoff_date and date('w', $punch_date) == 6 and $i % 10 == 0) {
                     //Sat.
                     $this->createPunchPair($user_id, strtotime($date_stamp . ' 10:00AM'), strtotime($date_stamp . ' 2:30PM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE);
                 }
                 //Recalculate entire day. Performance optimization.
                 //UserDateTotalFactory::reCalculateRange( $user_id, $start_date, $end_date );
                 $punch_date += 86400;
                 $i++;
             }
             unset($punch_options_arr, $punch_date, $user_id);
         }
         //Generate pay stubs for each pay period
         $pplf = new PayPeriodListFactory();
         $pplf->getByCompanyId($company_id);
         if ($pplf->getRecordCount() > 0) {
             foreach ($pplf as $pp_obj) {
                 foreach ($user_ids as $user_id) {
                     $cps = new CalculatePayStub();
                     $cps->setUser($user_id);
                     $cps->setPayPeriod($pp_obj->getId());
                     $cps->calculate();
                 }
             }
         }
         unset($pplf, $pp_obj, $user_id);
     }
     //$cf->FailTransaction();
     $cf->CommitTransaction();
     return FALSE;
 }
 ********************************************************************************/
/*
 * $Revision: 2095 $
 * $Id: fix_hierarchy.php 2095 2008-09-01 07:04:25Z ipso $
 * $Date: 2008-09-01 00:04:25 -0700 (Mon, 01 Sep 2008) $
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'classes/payroll_deduction/PayrollDeduction.class.php';
if ($argc < 2 or in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
    $help_output = "Usage: generate_payroll_deduction_test_csv.php [country_code] [date]\n";
    echo $help_output;
} else {
    $country = strtoupper($argv[1]);
    $effective_date = strtotime($argv[2]);
    $cf = new CompanyFactory();
    $province_arr = $cf->getOptions('province');
    if (!isset($province_arr[$country])) {
        echo "Country does not have any province/states.\n";
    }
    ksort($province_arr[$country]);
    $pay_periods = 26;
    $static_test_data = array('CA' => array('income' => array(192, 384, 961, 1923, 3846, 9615), 'federal_claim' => array(0, 100), 'provincial_claim' => array(0, 100)), 'US' => array('income' => array(192, 384, 961, 1923, 3846, 9615), 'filing_status' => array(10, 20, 30), 'allowance' => array(0, 1, 2, 3, 5)));
    $test_data = array();
    if ($country != '' and isset($province_arr[$country]) and $effective_date != '') {
        foreach ($province_arr[$country] as $province_code => $province) {
            //echo "Province: $province_code\n";
            //Get all tax rates for each province.
            switch ($country) {
                case 'US':
                    $table = 'income_tax_rate_us';
 function setCountry($country)
 {
     $country = trim($country);
     $cf = new CompanyFactory();
     if ($this->Validator->inArrayKey('country', $country, TTi18n::gettext('Invalid Country'), $cf->getOptions('country'))) {
         $this->data['country'] = $country;
         return TRUE;
     }
     return FALSE;
 }
예제 #5
0
    /**
     * Return user records based on advanced filter criteria.
     *
     * @param int $company_id Company ID
     * @param array $filter_data Filter criteria in array('id' => array(1,2), 'last_name' => 'smith' ) format, with possible top level array keys as follows: id, exclude_id, status_id, user_group_id, default_branch_id, default_department_id, title_id, currency_id, permission_control_id, pay_period_schedule_id, policy_group_id, sex_id, first_name, last_name, home_phone, work_phone, country, province, city, address1, address2, postal_code, employee_number, user_name, sin, work_email, home_email, tag, last_login_date, created_by, created_date, updated_by, updated_date
     * @param int $limit Optional. Restrict the number of records returned
     * @param int $page Optional. Specify the page of records to return
     * @param array $where Optional. Additional WHERE clauses in array( 'column' => 'value', 'column' => 'value' ) format.
     * @param array $order Optional. Sort order in array( 'column' => ASC, 'column2' => DESC ) format.
     *
     * @return object $this
     */
    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']);
            }
        }
        if (isset($filter_data['user_status_id'])) {
            $filter_data['status_id'] = $filter_data['user_status_id'];
        }
        if (isset($filter_data['include_user_id'])) {
            $filter_data['id'] = $filter_data['include_user_id'];
        }
        if (isset($filter_data['exclude_user_id'])) {
            $filter_data['exclude_id'] = $filter_data['exclude_user_id'];
        }
        //Some of these are passed from Flex Schedule view.
        if (isset($filter_data['default_branch_ids'])) {
            $filter_data['default_branch_id'] = $filter_data['default_branch_ids'];
        }
        if (isset($filter_data['default_department_ids'])) {
            $filter_data['default_department_id'] = $filter_data['default_department_ids'];
        }
        if (isset($filter_data['group_id'])) {
            $filter_data['user_group_id'] = $filter_data['group_id'];
        }
        if (isset($filter_data['user_title_id'])) {
            $filter_data['title_id'] = $filter_data['user_title_id'];
        }
        if (isset($filter_data['user_tag'])) {
            $filter_data['tag'] = $filter_data['user_tag'];
        }
        //$additional_order_fields = array('b.name', 'c.name', 'd.name', 'e.name');
        $additional_order_fields = array('default_branch', 'default_department', 'default_job', 'default_job_item', 'sex', 'user_group', 'title', 'currency', 'permission_control', 'pay_period_schedule', 'policy_group');
        $sort_column_aliases = array('type' => 'type_id', 'status' => 'status_id', 'sex' => 'sex_id', 'full_name' => 'last_name');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('status_id' => 'asc', 'last_name' => 'asc', 'first_name' => 'asc', 'middle_name' => 'asc');
            $strict = FALSE;
        } else {
            //Do order by column conversions, because if we include these columns in the SQL
            //query, they contaminate the data array.
            //Always try to order by status first so INACTIVE employees go to the bottom.
            if (!isset($order['status_id'])) {
                $order = Misc::prependArray(array('status_id' => 'asc'), $order);
            }
            //Always sort by last name,first name after other columns
            if (!isset($order['last_name'])) {
                $order['last_name'] = 'asc';
            }
            if (!isset($order['first_name'])) {
                $order['first_name'] = 'asc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $compf = new CompanyFactory();
        $bf = new BranchFactory();
        $df = new DepartmentFactory();
        $ugf = new UserGroupFactory();
        $utf = new UserTitleFactory();
        $cf = new CurrencyFactory();
        $pcf = new PermissionControlFactory();
        $puf = new PermissionUserFactory();
        $ppsuf = new PayPeriodScheduleUserFactory();
        $ppsf = new PayPeriodScheduleFactory();
        $pguf = new PolicyGroupUserFactory();
        $pgf = new PolicyGroupFactory();
        $egf = new EthnicGroupFactory();
        if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) {
            $jf = new JobFactory();
            $jif = new JobItemFactory();
        }
        $ph = array('company_id' => $company_id);
        $query = '
					select
							a.*,
							compf.name as company,
							b.name as default_branch,
							c.name as default_department,
							d.name as user_group,
							e.name as title,
							f.name as currency,
							f.conversion_rate as currency_rate,
							g.id as permission_control_id,
							g.name as permission_control,
							h.id as pay_period_schedule_id,
							h.name as pay_period_schedule,
							i.id as policy_group_id,
							i.name as policy_group,
                            egf.name as ethnic_group, ';
        $query .= Permission::getPermissionIsChildIsOwnerSQL(isset($filter_data['permission_current_user_id']) ? $filter_data['permission_current_user_id'] : 0, 'a.id');
        if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) {
            $query .= '	jf.name as default_job,
						jif.name as default_job_item, ';
        }
        $query .= '			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 ' . $compf->getTable() . ' as compf ON ( a.company_id = compf.id AND compf.deleted = 0)
						LEFT JOIN ' . $bf->getTable() . ' as b ON ( a.default_branch_id = b.id AND b.deleted = 0)
						LEFT JOIN ' . $df->getTable() . ' as c ON ( a.default_department_id = c.id AND c.deleted = 0)
						LEFT JOIN ' . $ugf->getTable() . ' as d ON ( a.group_id = d.id AND d.deleted = 0 )
						LEFT JOIN ' . $utf->getTable() . ' as e ON ( a.title_id = e.id AND e.deleted = 0 )
						LEFT JOIN ' . $cf->getTable() . ' as f ON ( a.currency_id = f.id AND f.deleted = 0 )
                        LEFT JOIN ' . $egf->getTable() . ' as egf ON ( a.ethnic_group_id = egf.id AND egf.deleted = 0 ) ';
        if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) {
            $query .= '	LEFT JOIN ' . $jf->getTable() . ' as jf ON a.default_job_id = jf.id';
            $query .= '	LEFT JOIN ' . $jif->getTable() . ' as jif ON a.default_job_item_id = jif.id';
        }
        $query .= '		LEFT JOIN
						(
							SELECT g2.*,g1.user_id
							FROM ' . $puf->getTable() . ' as g1, ' . $pcf->getTable() . ' as g2
							WHERE ( g1.permission_control_id = g2.id AND g2.deleted = 0)
						) as g ON ( a.id = g.user_id )
						LEFT JOIN
						(
							SELECT h2.*, h1.user_id
							FROM ' . $ppsuf->getTable() . ' as h1, ' . $ppsf->getTable() . ' as h2
							WHERE ( h1.pay_period_schedule_id = h2.id AND h2.deleted = 0)
						) as h ON ( a.id = h.user_id )
						LEFT JOIN
						(
							SELECT i2.*, i1.user_id
							FROM ' . $pguf->getTable() . ' as i1, ' . $pgf->getTable() . ' as i2
							WHERE ( i1.policy_group_id = i2.id AND i2.deleted = 0)
						) as i ON ( a.id = i.user_id ) ';
        $query .= Permission::getPermissionHierarchySQL($company_id, isset($filter_data['permission_current_user_id']) ? $filter_data['permission_current_user_id'] : 0, 'a.id');
        $query .= '
						LEFT JOIN ' . $this->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $this->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	a.company_id = ?
					';
        $query .= Permission::getPermissionIsChildIsOwnerFilterSQL($filter_data, 'a.id');
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['include_subgroups']) and (bool) $filter_data['include_subgroups'] == TRUE) {
            $uglf = new UserGroupListFactory();
            $filter_data['user_group_id'] = $uglf->getByCompanyIdAndGroupIdAndSubGroupsArray($company_id, $filter_data['user_group_id'], TRUE);
        }
        $query .= isset($filter_data['user_group_id']) ? $this->getWhereClauseSQL('a.group_id', $filter_data['user_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_group']) ? $this->getWhereClauseSQL('d.name', $filter_data['user_group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_branch_id']) ? $this->getWhereClauseSQL('a.default_branch_id', $filter_data['default_branch_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_branch']) ? $this->getWhereClauseSQL('b.name', $filter_data['default_branch'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_department_id']) ? $this->getWhereClauseSQL('a.default_department_id', $filter_data['default_department_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_department']) ? $this->getWhereClauseSQL('c.name', $filter_data['default_department'], 'text', $ph) : NULL;
        $query .= isset($filter_data['title_id']) ? $this->getWhereClauseSQL('a.title_id', $filter_data['title_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['title']) ? $this->getWhereClauseSQL('e.name', $filter_data['title'], 'text', $ph) : NULL;
        $query .= isset($filter_data['ethnic_group_id']) ? $this->getWhereClauseSQL('a.ethnic_group_id', $filter_data['ethnic_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['ethnic_group']) ? $this->getWhereClauseSQL('egf.name', $filter_data['ethnic_group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['currency_id']) ? $this->getWhereClauseSQL('a.currency_id', $filter_data['currency_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['currency']) ? $this->getWhereClauseSQL('f.name', $filter_data['currency'], 'text', $ph) : NULL;
        $query .= isset($filter_data['permission_control_id']) ? $this->getWhereClauseSQL('g.id', $filter_data['permission_control_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['permission_control']) ? $this->getWhereClauseSQL('g.name', $filter_data['permission_control'], 'text', $ph) : NULL;
        $query .= isset($filter_data['pay_period_schedule_id']) ? $this->getWhereClauseSQL('i.pay_period_schedule_id', $filter_data['pay_period_schedule_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['pay_period_schedule']) ? $this->getWhereClauseSQL('h.name', $filter_data['pay_period_schedule'], 'text', $ph) : NULL;
        $query .= isset($filter_data['policy_group_id']) ? $this->getWhereClauseSQL('k.policy_group_id', $filter_data['policy_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['policy_group']) ? $this->getWhereClauseSQL('i.name', $filter_data['policy_group'], 'text', $ph) : NULL;
        if (isset($filter_data['sex']) and trim($filter_data['sex']) != '' and !isset($filter_data['sex_id'])) {
            $filter_data['sex_id'] = Option::getByFuzzyValue($filter_data['sex'], $this->getOptions('sex'));
        }
        $query .= isset($filter_data['sex_id']) ? $this->getWhereClauseSQL('a.sex_id', $filter_data['sex_id'], 'text_list', $ph) : NULL;
        $query .= isset($filter_data['first_name']) ? $this->getWhereClauseSQL('a.first_name', $filter_data['first_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['last_name']) ? $this->getWhereClauseSQL('a.last_name', $filter_data['last_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['home_phone']) ? $this->getWhereClauseSQL('a.home_phone', $filter_data['home_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['work_phone']) ? $this->getWhereClauseSQL('a.work_phone', $filter_data['work_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['country']) ? $this->getWhereClauseSQL('a.country', $filter_data['country'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['province']) ? $this->getWhereClauseSQL('a.province', $filter_data['province'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['city']) ? $this->getWhereClauseSQL('a.city', $filter_data['city'], 'text', $ph) : NULL;
        $query .= isset($filter_data['address1']) ? $this->getWhereClauseSQL('a.address1', $filter_data['address1'], 'text', $ph) : NULL;
        $query .= isset($filter_data['address2']) ? $this->getWhereClauseSQL('a.address2', $filter_data['address2'], 'text', $ph) : NULL;
        $query .= isset($filter_data['postal_code']) ? $this->getWhereClauseSQL('a.postal_code', $filter_data['postal_code'], 'text', $ph) : NULL;
        $query .= isset($filter_data['employee_number']) ? $this->getWhereClauseSQL('a.employee_number', $filter_data['employee_number'], 'numeric', $ph) : NULL;
        $query .= isset($filter_data['user_name']) ? $this->getWhereClauseSQL('a.user_name', $filter_data['user_name'], 'text', $ph) : NULL;
        $query .= isset($filter_data['sin']) ? $this->getWhereClauseSQL('a.sin', $filter_data['sin'], 'numeric', $ph) : NULL;
        $query .= isset($filter_data['email']) ? 'AND (' . $this->getWhereClauseSQL('a.work_email', $filter_data['email'], 'text', $ph, NULL, FALSE) . ' OR ' . $this->getWhereClauseSQL('a.home_email', $filter_data['email'], 'text', $ph, NULL, FALSE) . ')' : NULL;
        $query .= isset($filter_data['work_email']) ? $this->getWhereClauseSQL('a.work_email', $filter_data['work_email'], 'text', $ph) : NULL;
        $query .= isset($filter_data['home_email']) ? $this->getWhereClauseSQL('a.home_email', $filter_data['home_email'], 'text', $ph) : NULL;
        $query .= isset($filter_data['tag']) ? $this->getWhereClauseSQL('a.id', array('company_id' => $company_id, 'object_type_id' => 200, 'tag' => $filter_data['tag']), 'tag', $ph) : NULL;
        //$query .= ( isset($filter_data['longitude']) ) ? $this->getWhereClauseSQL( 'a.longitude', $filter_data['longitude'], 'numeric', $ph ) : NULL;
        if (isset($filter_data['last_login_date']) and trim($filter_data['last_login_date']) != '') {
            $date_filter = $this->getDateRangeSQL($filter_data['last_login_date'], 'a.last_login_date');
            if ($date_filter != FALSE) {
                $query .= ' AND ' . $date_filter;
            }
            unset($date_filter);
        }
        if (isset($filter_data['created_date']) and trim($filter_data['created_date']) != '') {
            $date_filter = $this->getDateRangeSQL($filter_data['created_date'], 'a.created_date');
            if ($date_filter != FALSE) {
                $query .= ' AND ' . $date_filter;
            }
            unset($date_filter);
        }
        if (isset($filter_data['updated_date']) and trim($filter_data['updated_date']) != '') {
            $date_filter = $this->getDateRangeSQL($filter_data['updated_date'], 'a.updated_date');
            if ($date_filter != FALSE) {
                $query .= ' AND ' . $date_filter;
            }
            unset($date_filter);
        }
        $query .= isset($filter_data['created_by']) ? $this->getWhereClauseSQL(array('a.created_by', 'y.first_name', 'y.last_name'), $filter_data['created_by'], 'user_id_or_name', $ph) : NULL;
        $query .= isset($filter_data['updated_by']) ? $this->getWhereClauseSQL(array('a.updated_by', 'z.first_name', 'z.last_name'), $filter_data['updated_by'], 'user_id_or_name', $ph) : NULL;
        $query .= '
						AND ( a.deleted = 0 )
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        //Debug::Arr($ph, 'Query: '. $query, __FILE__, __LINE__, __METHOD__,10);
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
 function setDistrict($district)
 {
     $district = trim($district);
     Debug::Text('Country: ' . $this->getCountry() . ' District: ' . $district, __FILE__, __LINE__, __METHOD__, 10);
     $cf = new CompanyFactory();
     $options_arr = $cf->getOptions('district');
     if (isset($options_arr[$this->getCountry()][$this->getProvince()])) {
         $options = $options_arr[$this->getCountry()][$this->getProvince()];
     } else {
         $options = array();
     }
     if ($district == '' or $district == '00' or $this->Validator->inArrayKey('district', $district, TTi18n::gettext('Invalid District'), $options)) {
         $this->data['district'] = $district;
         return TRUE;
     }
     return FALSE;
 }
    function getMidDayExceptionsByStartDateAndEndDateAndPayPeriodStatus($start_date, $end_date, $pay_period_status_id)
    {
        if ($start_date == '') {
            return FALSE;
        }
        if ($end_date == '') {
            return FALSE;
        }
        if ($pay_period_status_id == '') {
            return FALSE;
        }
        $epf = new ExceptionPolicyFactory();
        $ef = new ExceptionFactory();
        $epcf = new ExceptionPolicyControlFactory();
        $pgf = new PolicyGroupFactory();
        $pguf = new PolicyGroupUserFactory();
        $uf = new UserFactory();
        $cf = new CompanyFactory();
        $udf = new UserDateFactory();
        $sf = new ScheduleFactory();
        $pcf = new PunchControlFactory();
        $pf = new PunchFactory();
        $ppf = new PayPeriodFactory();
        $current_epoch = time();
        if (strncmp($this->db->databaseType, 'mysql', 5) == 0) {
            $to_timestamp_sql = 'FROM_UNIXTIME';
        } else {
            $to_timestamp_sql = 'to_timestamp';
        }
        $ph = array('current_time1' => $this->db->BindTimeStamp($current_epoch), 'current_time2' => $this->db->BindTimeStamp($current_epoch), 'current_epoch1' => $current_epoch, 'start_date' => $this->db->BindDate($start_date), 'end_date' => $this->db->BindDate($end_date));
        //Exceptions that need to be calculated in the middle of the day:
        //Definitely: In Late, Out Late, Missed CheckIn
        //Possible: Over Daily Scheduled Time, Over Weekly Scheduled Time, Over Daily Time, Over Weekly Time, Long Lunch (can't run this fast enough), Long Break (can't run this fast enough),
        //Optimize calcQuickExceptions:
        // Loop through exception policies where In Late/Out Late/Missed CheckIn are enabled.
        // Loop through ACTIVE users assigned to these exceptions policies.
        // Only find days that are scheduled AND ( NO punch after schedule start time OR NO punch after schedule end time )
        //      For Missed CheckIn they do not need to be scheduled.
        // Exclude days that already have the exceptions triggered on them (?) (What about split shifts?)
        //	- Just exclude exceptions not assigned to punch/punch_control_id, if there is more than one in the day I don't think it helps much anyways.
        //
        //Currently Over Weekly/Daily time exceptions are only triggered on a Out punch.
        $query = '	select distinct udf.*
					FROM ' . $epf->getTable() . ' as epf
					LEFT JOIN ' . $epcf->getTable() . ' as epcf ON ( epf.exception_policy_control_id = epcf.id )
					LEFT JOIN ' . $pgf->getTable() . ' as pgf ON ( epcf.id = pgf.exception_policy_control_id )
					LEFT JOIN ' . $pguf->getTable() . ' as pguf ON ( pgf.id = pguf.policy_group_id )
					LEFT JOIN ' . $uf->getTable() . ' as uf ON ( pguf.user_id = uf.id )
					LEFT JOIN ' . $cf->getTable() . ' as cf ON ( uf.company_id = cf.id )
					LEFT JOIN ' . $udf->getTable() . ' as udf ON ( uf.id = udf.user_id )
					LEFT JOIN ' . $ppf->getTable() . ' as ppf ON ( ppf.id = udf.pay_period_id )
					LEFT JOIN ' . $ef->getTable() . ' as ef ON ( udf.id = ef.user_date_id AND ef.exception_policy_id = epf.id AND ef.type_id != 5 )
					LEFT JOIN ' . $sf->getTable() . ' as sf ON ( udf.id = sf.user_date_id AND ( sf.start_time <= ? OR sf.end_time <= ? ) )
					LEFT JOIN ' . $pcf->getTable() . ' as pcf ON ( udf.id = pcf.user_date_id AND pcf.deleted = 0 )
					LEFT JOIN ' . $pf->getTable() . ' as pf ON 	(
																pcf.id = pf.punch_control_id AND pf.deleted = 0
																AND (
																		( epf.type_id = \'S4\' AND ( pf.time_stamp >= sf.start_time OR pf.time_stamp <= sf.end_time ) )
																		OR
																		( epf.type_id = \'S6\' AND ( pf.time_stamp >= sf.end_time ) )
																		OR
																		( epf.type_id = \'C1\' AND ( pf.status_id = 10 AND pf.time_stamp <= ' . $to_timestamp_sql . '(?-epf.grace) ) )
																	)
																)
					WHERE ( epf.type_id in (\'S4\',\'S6\', \'C1\') AND epf.active = 1 )
						AND ( uf.status_id = 10 AND cf.status_id != 30 )
						AND ( udf.date_stamp >= ? AND udf.date_stamp <= ? )
						AND ppf.status_id in (' . $this->getListSQL($pay_period_status_id, $ph) . ')
						AND ( ( ( epf.type_id in (\'S4\',\'S6\') AND ( sf.id IS NOT NULL AND sf.deleted = 0 ) AND pf.id IS NULL ) OR epf.type_id = \'C1\' ) AND ef.id IS NULL  )
						AND ( epf.deleted = 0 AND epcf.deleted = 0 AND pgf.deleted = 0 AND uf.deleted = 0 AND cf.deleted = 0 AND udf.deleted = 0 )
				';
        //Don't check deleted = 0 on PCF/PF tables, as we need to check IS NULL on them instead.
        //Debug::Arr($ph, 'Query: '. $query, __FILE__, __LINE__, __METHOD__, 10);
        $this->ExecuteSQL($query, $ph);
        return $this;
    }
예제 #8
0
 */
require_once '../../includes/global.inc.php';
//Debug::setVerbosity( 11 );
$authenticate = FALSE;
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
$smarty->assign('title', TTi18n::gettext($title = '5. Company Information'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'id', 'company_data', 'external_installer')));
$install_obj = new Install();
if ($install_obj->isInstallMode() == FALSE) {
    Redirect::Page(URLBuilder::getURL(NULL, 'install.php'));
}
$cf = new CompanyFactory();
$action = Misc::findSubmitButton();
switch ($action) {
    case 'back':
        Debug::Text('Back', __FILE__, __LINE__, __METHOD__, 10);
        Redirect::Page(URLBuilder::getURL(NULL, 'SystemSettings.php'));
        break;
    case 'next':
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        //$cf->setParent($company_data['parent']);
        $cf->setStatus(10);
        $cf->setProductEdition((int) getTTProductEdition());
        $cf->setName($company_data['name']);
        $cf->setShortName($company_data['short_name']);
        $cf->setAddress1($company_data['address1']);
        $cf->setAddress2($company_data['address2']);
예제 #9
0
         $upload->set_acceptable_types(array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png'));
         // comma separated string, or array
         //$upload->set_max_image_size(600, 600);
         $upload->set_overwrite_mode(1);
         $icf = new InvoiceConfigFactory();
         $icf->cleanStoragePath($current_company->getId());
         $dir = $icf->getStoragePath($current_company->getId());
         break;
     case 'company_logo':
         $upload->set_max_filesize(1000000);
         //1mb or less
         $upload->set_acceptable_types(array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png'));
         // comma separated string, or array
         //$upload->set_max_image_size(600, 600);
         $upload->set_overwrite_mode(1);
         $cf = new CompanyFactory();
         $cf->cleanStoragePath($current_company->getId());
         $dir = $cf->getStoragePath($current_company->getId());
         break;
     case 'license':
         $upload->set_max_filesize(20000);
         //1mb or less
         $upload->set_acceptable_types(array('text/plain', 'plain/text', 'application/octet-stream'));
         // comma separated string, or array
         $upload->set_overwrite_mode(1);
         $dir = Environment::getStorageBasePath() . DIRECTORY_SEPARATOR . 'license' . DIRECTORY_SEPARATOR . $current_company->getId();
         break;
 }
 Debug::Text('bUpload... Object Type: ' . $object_type, __FILE__, __LINE__, __METHOD__, 10);
 if (isset($dir)) {
     @mkdir($dir, 0700, TRUE);
예제 #10
0
        }
        if ($branch_data['fax_phone'] != '') {
            $bf->setFaxPhone($branch_data['fax_phone']);
        }
        if ($bf->isValid()) {
            $bf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'BranchList.php'));
            break;
        }
    default:
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $blf = new BranchListFactory();
            $blf->GetByIdAndCompanyId($id, $current_company->getId());
            foreach ($blf as $branch) {
                $branch_data = array('id' => $branch->getId(), 'status' => $branch->getStatus(), 'manual_id' => $branch->getManualID(), 'name' => $branch->getName(), 'address1' => $branch->getAddress1(), 'address2' => $branch->getAddress2(), 'city' => $branch->getCity(), 'province' => $branch->getProvince(), 'country' => $branch->getCountry(), 'postal_code' => $branch->getPostalCode(), 'work_phone' => $branch->getWorkPhone(), 'fax_phone' => $branch->getFaxPhone(), 'created_date' => $branch->getCreatedDate(), 'created_by' => $branch->getCreatedBy(), 'updated_date' => $branch->getUpdatedDate(), 'updated_by' => $branch->getUpdatedBy(), 'deleted_date' => $branch->getDeletedDate(), 'deleted_by' => $branch->getDeletedBy());
            }
        } elseif ($action != 'submit') {
            $next_available_manual_id = BranchListFactory::getNextAvailableManualId($current_company->getId());
            $branch_data = array('country' => $current_company->getCountry(), 'province' => $current_company->getProvince(), 'next_available_manual_id' => $next_available_manual_id);
        }
        //Select box options;
        $branch_data['status_options'] = $bf->getOptions('status');
        $cf = new CompanyFactory();
        $branch_data['country_options'] = $cf->getOptions('country');
        $branch_data['province_options'] = $cf->getOptions('province', $branch_data['country']);
        $smarty->assign_by_ref('branch_data', $branch_data);
        break;
}
$smarty->assign_by_ref('bf', $bf);
$smarty->display('branch/EditBranch.tpl');
예제 #11
0
         $user_data = array('items_per_page' => 10, 'time_zone' => 'GMT', 'country' => 'CA', 'language' => 'en');
     }
 }
 //Select box options;
 $blf = new BranchListFactory();
 $branch_options = $blf->getByCompanyIdArray($current_company->getId());
 $dlf = new DepartmentListFactory();
 $department_options = $dlf->getByCompanyIdArray($current_company->getId());
 $culf = new CurrencyListFactory();
 $culf->getByCompanyId($current_company->getId());
 $currency_options = $culf->getArrayByListFactory($culf, FALSE, TRUE);
 //Select box options;
 $user_data['branch_options'] = $branch_options;
 $user_data['department_options'] = $department_options;
 $user_data['currency_options'] = $currency_options;
 $cf = new CompanyFactory();
 $user_data['country_options'] = $cf->getOptions('country');
 $user_data['province_options'] = $cf->getOptions('province', $user_data['country']);
 $utlf = new UserTitleListFactory();
 $user_titles = $utlf->getByCompanyIdArray($current_company->getId());
 $user_data['title_options'] = $user_titles;
 //Get Permission Groups
 $pclf = new PermissionControlListFactory();
 $pclf->getByCompanyId($current_company->getId());
 $user_data['permission_control_options'] = $pclf->getArrayByListFactory($pclf, FALSE);
 //Get pay period schedules
 $ppslf = new PayPeriodScheduleListFactory();
 $pay_period_schedules = $ppslf->getByCompanyIDArray($current_company->getId());
 $user_data['pay_period_schedule_options'] = $pay_period_schedules;
 $pglf = new PolicyGroupListFactory();
 $policy_groups = $pglf->getByCompanyIDArray($current_company->getId());
예제 #12
0
 function getProvinceDistrictOptions($country, $province)
 {
     if ($country == '') {
         return FALSE;
     }
     if ($province == '') {
         return FALSE;
     }
     Debug::text('Country: ' . $country . ' Province: ' . $province, __FILE__, __LINE__, __METHOD__, 10);
     $cf = new CompanyFactory();
     $district_arr = $cf->getOptions('district');
     if (isset($district_arr[strtoupper($country)][strtoupper($province)])) {
         Debug::Arr($district_arr[strtoupper($country)][strtoupper($province)], 'District Array', __FILE__, __LINE__, __METHOD__, 10);
         return $district_arr[strtoupper($country)][strtoupper($province)];
     }
     return array();
 }
예제 #13
0
 function getCompanyObject()
 {
     $cf = new CompanyFactory();
     return $cf->getGenericObject('CompanyListFactory', $this->company_id, 'company_obj');
 }
예제 #14
0
 function setProvince($province)
 {
     $province = trim($province);
     Debug::Text('Country: ' . $this->getCountry() . ' Province: ' . $province, __FILE__, __LINE__, __METHOD__, 10);
     $cf = new CompanyFactory();
     $options_arr = $cf->getOptions('province');
     if (isset($options_arr[$this->getCountry()])) {
         $options = $options_arr[$this->getCountry()];
     } else {
         $options = array();
     }
     //If country isn't set yet, accept the value and re-validate on save.
     if ($this->getCountry() == FALSE or $this->Validator->inArrayKey('province', $province, TTi18n::gettext('Invalid Province/State'), $options)) {
         $this->data['province'] = $province;
         return TRUE;
     }
     return FALSE;
 }
예제 #15
0
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'Form 940-EZ Report'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'setup_data', 'generic_data', 'filter_data')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('filter_data' => $filter_data));
$pseallf = new PayStubEntryAccountLinkListFactory();
$pseallf->getByCompanyId($current_company->getId());
if ($pseallf->getRecordCount() > 0) {
    $pseal_obj = $pseallf->getCurrent();
}
$cf = new CompanyFactory();
$state_options = $cf->getOptions('province', 'US');
$column_ps_entry_name_map = array('p1_1' => @$setup_data['p1_1_psea_ids'], 'p1_2' => @$setup_data['p1_2_psea_ids']);
$pplf = new PayPeriodListFactory();
$year_options = $pplf->getYearsArrayByCompanyId($current_company->getId());
$quarter_dates = array(1 => array('start' => mktime(0, 0, 0, 1, 1, $filter_data['year']), 'end' => mktime(0, 0, -1, 4, 1, $filter_data['year'])), 2 => array('start' => mktime(0, 0, 0, 4, 1, $filter_data['year']), 'end' => mktime(0, 0, -1, 7, 1, $filter_data['year'])), 3 => array('start' => mktime(0, 0, 0, 7, 1, $filter_data['year']), 'end' => mktime(0, 0, -1, 10, 1, $filter_data['year'])), 4 => array('start' => mktime(0, 0, 0, 10, 1, $filter_data['year']), 'end' => mktime(0, 0, -1, 13, 1, $filter_data['year'])));
$filter_data = Misc::preSetArrayValues($filter_data, array('include_user_ids', 'exclude_user_ids', 'user_status_ids', 'group_ids', 'branch_ids', 'department_ids', 'user_title_ids', 'pay_period_ids', 'column_ids'), array());
$ugdlf = new UserGenericDataListFactory();
$ugdf = new UserGenericDataFactory();
$action = Misc::findSubmitButton();
Debug::Text('Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10);
switch ($action) {
    case 'print_form':
    case 'display_form':
    case 'display_report':
        //Debug::setVerbosity(11);
         } else {
         	$user_ids = array();
         }
         unset($udlf, $ud_obj);
         */
         $data = array('id' => $cd_obj->getId(), 'company_id' => $cd_obj->getCompany(), 'status_id' => $cd_obj->getStatus(), 'type_id' => $cd_obj->getType(), 'name' => $cd_obj->getName(), 'start_date' => $cd_obj->getStartDate(), 'end_date' => $cd_obj->getEndDate(), 'minimum_length_of_service' => $cd_obj->getMinimumLengthOfService(), 'minimum_length_of_service_unit_id' => $cd_obj->getMinimumLengthOfServiceUnit(), 'maximum_length_of_service' => $cd_obj->getMaximumLengthOfService(), 'maximum_length_of_service_unit_id' => $cd_obj->getMaximumLengthOfServiceUnit(), 'calculation_id' => $cd_obj->getCalculation(), 'calculation_order' => $cd_obj->getCalculationOrder(), 'country' => $cd_obj->getCountry(), 'province' => $cd_obj->getProvince(), 'district' => $cd_obj->getDistrict(), 'company_value1' => $cd_obj->getCompanyValue1(), 'company_value2' => $cd_obj->getCompanyValue2(), 'user_value1' => $cd_obj->getUserValue1(), 'user_value2' => $cd_obj->getUserValue2(), 'user_value3' => $cd_obj->getUserValue3(), 'user_value4' => $cd_obj->getUserValue4(), 'user_value5' => $cd_obj->getUserValue5(), 'user_value6' => $cd_obj->getUserValue6(), 'user_value7' => $cd_obj->getUserValue7(), 'user_value8' => $cd_obj->getUserValue8(), 'user_value9' => $cd_obj->getUserValue9(), 'user_value10' => $cd_obj->getUserValue10(), 'lock_user_value1' => $cd_obj->getLockUserValue1(), 'lock_user_value2' => $cd_obj->getLockUserValue2(), 'lock_user_value3' => $cd_obj->getLockUserValue3(), 'lock_user_value4' => $cd_obj->getLockUserValue4(), 'lock_user_value5' => $cd_obj->getLockUserValue5(), 'lock_user_value6' => $cd_obj->getLockUserValue6(), 'lock_user_value7' => $cd_obj->getLockUserValue7(), 'lock_user_value8' => $cd_obj->getLockUserValue8(), 'lock_user_value9' => $cd_obj->getLockUserValue9(), 'lock_user_value10' => $cd_obj->getLockUserValue10(), 'pay_stub_entry_account_id' => $cd_obj->getPayStubEntryAccount(), 'include_pay_stub_entry_account_ids' => $cd_obj->getIncludePayStubEntryAccount(), 'exclude_pay_stub_entry_account_ids' => $cd_obj->getExcludePayStubEntryAccount(), 'include_account_amount_type_id' => $cd_obj->getIncludeAccountAmountType(), 'exclude_account_amount_type_id' => $cd_obj->getExcludeAccountAmountType(), 'user_ids' => $cd_obj->getUser(), 'created_date' => $cd_obj->getCreatedDate(), 'created_by' => $cd_obj->getCreatedBy(), 'updated_date' => $cd_obj->getUpdatedDate(), 'updated_by' => $cd_obj->getUpdatedBy(), 'deleted_date' => $cd_obj->getDeletedDate(), 'deleted_by' => $cd_obj->getDeletedBy());
     }
 } elseif ($action != 'submit') {
     $data = array('country' => 0, 'province' => 0, 'district' => 0, 'user_value1' => 0, 'user_value2' => 0, 'user_value3' => 0, 'user_value4' => 0, 'user_value5' => 0, 'user_value6' => 0, 'user_value7' => 0, 'user_value8' => 0, 'user_value9' => 0, 'user_value10' => 0, 'minimum_length_of_service' => 0, 'maximum_length_of_service' => 0, 'calculation_order' => 100);
 }
 //Select box options;
 $data['status_options'] = $cdf->getOptions('status');
 $data['type_options'] = $cdf->getOptions('type');
 $data['length_of_service_unit_options'] = $cdf->getOptions('length_of_service_unit');
 $data['account_amount_type_options'] = $cdf->getOptions('account_amount_type');
 $cf = new CompanyFactory();
 $data['country_options'] = Misc::prependArray(array(0 => '--'), $cf->getOptions('country'));
 if (isset($data['country'])) {
     $data['province_options'] = $cf->getOptions('province', $data['country']);
 }
 if (isset($data['district'])) {
     $district_options = $cf->getOptions('district', $data['country']);
     if (isset($district_options[$data['province']])) {
         $data['district_options'] = $district_options[$data['province']];
     }
 }
 $data['us_eic_filing_status_options'] = $cdf->getOptions('us_eic_filing_status');
 $data['federal_filing_status_options'] = $cdf->getOptions('federal_filing_status');
 $data['state_filing_status_options'] = $cdf->getOptions('state_filing_status');
 $data['state_ga_filing_status_options'] = $cdf->getOptions('state_ga_filing_status');
 $data['state_nj_filing_status_options'] = $cdf->getOptions('state_nj_filing_status');
예제 #17
0
            $params['cache'] = TRUE;
        }
        break;
    case 'company_logo':
        Debug::Text('Company Logo...', __FILE__, __LINE__, __METHOD__, 10);
        $cf = new CompanyFactory();
        $file_name = $cf->getLogoFileName($current_company->getId());
        Debug::Text('File Name: ' . $file_name, __FILE__, __LINE__, __METHOD__, 10);
        if ($file_name != '' and file_exists($file_name)) {
            $params['file'] = $file_name;
            $params['cache'] = TRUE;
        }
        break;
    case 'primary_company_logo':
        Debug::Text('Primary Company Logo...', __FILE__, __LINE__, __METHOD__, 10);
        $cf = new CompanyFactory();
        $file_name = $cf->getLogoFileName(PRIMARY_COMPANY_ID);
        Debug::Text('File Name: ' . $file_name, __FILE__, __LINE__, __METHOD__, 10);
        if ($file_name != '' and file_exists($file_name)) {
            $params['file'] = $file_name;
            $params['cache'] = TRUE;
        }
        break;
    default:
        break;
}
if (isset($params)) {
    HTTP_Download::staticSend($params);
} else {
    echo "File does not exist, unable to download!<br>\n";
    Debug::writeToLog();
예제 #18
0
                 $udf->setUserValue9($data['user_value9']);
             }
             if (isset($data['user_value10'])) {
                 $udf->setUserValue10($data['user_value10']);
             }
             if ($udf->isValid()) {
                 $udf->Save();
                 $udf->CommitTransaction();
                 Redirect::Page(URLBuilder::getURL(array('user_id' => $data['user_id'], 'saved_search_id' => $saved_search_id), 'UserDeductionList.php'));
                 break;
             }
         }
     }
     $udf->FailTransaction();
 default:
     $cf = new CompanyFactory();
     if (isset($company_deduction_id) and $company_deduction_id != '') {
         Debug::Text('Mass User Deduction Edit!', __FILE__, __LINE__, __METHOD__, 10);
         //Get all employees assigned to this company deduction.
         $cdlf = new CompanyDeductionListFactory();
         $cdlf->getByCompanyIdAndId($current_company->getId(), $company_deduction_id);
         Debug::Text('Company Deduction Records: ' . $cdlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
         if ($cdlf->getRecordCount() > 0) {
             foreach ($cdlf as $cd_obj) {
                 $province_options = $cf->getOptions('province', $cd_obj->getCountry());
                 $tmp_district_options = $cf->getOptions('district', $cd_obj->getCountry());
                 $district_options = array();
                 if (isset($tmp_district_options[$cd_obj->getProvince()])) {
                     $district_options = $tmp_district_options[$cd_obj->getProvince()];
                 }
                 unset($tmp_district_options);
예제 #19
0
 * $Id: EditCompany.php 1634 2008-01-11 20:35:07Z ipso $
 * $Date: 2008-01-11 12:35:07 -0800 (Fri, 11 Jan 2008) $
 */
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
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'])) {
예제 #20
0
     $company_name = $clf->getById($u_obj->getCompany())->getCurrent()->getName();
     $users[] = array('id' => $u_obj->getId(), 'company_id' => $u_obj->getCompany(), 'employee_number' => $u_obj->getEmployeeNumber(), 'status_id' => $u_obj->getStatus(), 'status' => Option::getByKey($u_obj->getStatus(), $u_obj->getOptions('status')), 'user_name' => $u_obj->getUserName(), 'phone_id' => $u_obj->getPhoneID(), 'ibutton_id' => $u_obj->getIButtonID(), 'full_name' => $u_obj->getFullName(TRUE), 'first_name' => $u_obj->getFirstName(), 'middle_name' => $u_obj->getMiddleName(), 'last_name' => $u_obj->getLastName(), 'title' => Option::getByKey($u_obj->getTitle(), $title_options), 'user_group' => Option::getByKey($u_obj->getGroup(), $group_options), 'default_branch' => Option::getByKey($u_obj->getDefaultBranch(), $branch_options), 'default_department' => Option::getByKey($u_obj->getDefaultDepartment(), $department_options), 'sex_id' => $u_obj->getSex(), 'sex' => Option::getByKey($u_obj->getSex(), $u_obj->getOptions('sex')), 'address1' => $u_obj->getAddress1(), 'address2' => $u_obj->getAddress2(), 'city' => $u_obj->getCity(), 'province' => $u_obj->getProvince(), 'country' => $u_obj->getCountry(), 'postal_code' => $u_obj->getPostalCode(), 'work_phone' => $u_obj->getWorkPhone(), 'home_phone' => $u_obj->getHomePhone(), 'mobile_phone' => $u_obj->getMobilePhone(), 'fax_phone' => $u_obj->getFaxPhone(), 'home_email' => $u_obj->getHomeEmail(), 'work_email' => $u_obj->getWorkEmail(), 'birth_date' => TTDate::getDate('DATE', $u_obj->getBirthDate()), 'sin' => $u_obj->getSIN(), 'hire_date' => TTDate::getDate('DATE', $u_obj->getHireDate()), 'termination_date' => TTDate::getDate('DATE', $u_obj->getTerminationDate()), 'is_owner' => $permission->isOwner($u_obj->getCreatedBy(), $u_obj->getId()), 'is_child' => $permission->isChild($u_obj->getId(), $permission_children_ids), 'deleted' => $u_obj->getDeleted());
 }
 //var_dump($users);
 $all_array_option = array('-1' => TTi18n::gettext('-- Any --'));
 //Select box options;
 if ($permission->Check('company', 'view')) {
     $filter_data['company_options'] = Misc::prependArray($all_array_option, $company_options);
 }
 $filter_data['branch_options'] = Misc::prependArray($all_array_option, $branch_options);
 $filter_data['department_options'] = Misc::prependArray($all_array_option, $department_options);
 $filter_data['title_options'] = Misc::prependArray($all_array_option, $title_options);
 $filter_data['group_options'] = Misc::prependArray($all_array_option, $group_options);
 $filter_data['sex_options'] = Misc::prependArray($all_array_option, $ulf->getOptions('sex'));
 $filter_data['status_options'] = Misc::prependArray($all_array_option, $ulf->getOptions('status'));
 $cf = new CompanyFactory();
 $filter_data['country_options'] = Misc::prependArray($all_array_option, $cf->getOptions('country'));
 if (isset($filter_data['country'])) {
     $filter_data['province_options'] = Misc::prependArray($all_array_option, $cf->getOptions('province', $filter_data['country']));
 } else {
     $filter_data['province_options'] = $all_array_option;
 }
 $ppslf = new PayPeriodScheduleListFactory();
 $filter_data['pay_period_schedule_options'] = Misc::prependArray($all_array_option, $ppslf->getByCompanyIDArray($current_company->getId()));
 $pglf = new PolicyGroupListFactory();
 $filter_data['policy_group_options'] = Misc::prependArray($all_array_option, $pglf->getByCompanyIDArray($current_company->getId()));
 $filter_data['saved_search_options'] = $ugdlf->getArrayByListFactory($ugdlf->getByUserIdAndScript($current_user->getId(), $_SERVER['SCRIPT_NAME']), FALSE);
 //Get column list
 $filter_data['src_column_options'] = Misc::arrayDiffByKey((array) $filter_data['columns'], $columns);
 $filter_data['selected_column_options'] = Misc::arrayIntersectByKey((array) $filter_data['columns'], $columns);
 $filter_data['sort_options'] = Misc::trimSortPrefix($columns);