コード例 #1
0
         $data['deduction_options'] = $cdlf->getByCompanyIdAndStatusIdArray($current_company->getId(), 10, FALSE);
         $udlf = new UserDeductionListFactory();
         $udlf->getByCompanyIdAndUserId($current_company->getId(), $user_id);
         if ($udlf->getRecordCount() > 0) {
             //Remove deductions from select box that are already assigned to user.
             $deduction_ids = array_keys($data['deduction_options']);
             foreach ($udlf as $ud_obj) {
                 if (in_array($ud_obj->getCompanyDeduction(), $deduction_ids)) {
                     unset($data['deduction_options'][$ud_obj->getCompanyDeduction()]);
                 }
             }
         }
     }
     //Get user full name
     $ulf = new UserListFactory();
     $ulf->getByIdAndCompanyId($data['user_id'], $current_company->getId());
     if ($ulf->getRecordCount() > 0) {
         $data['user_full_name'] = $ulf->getCurrent()->getFullName();
     }
 }
 //Select box options;
 $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');
 $data['state_nc_filing_status_options'] = $cdf->getOptions('state_nc_filing_status');
 $data['state_ma_filing_status_options'] = $cdf->getOptions('state_ma_filing_status');
 $data['state_al_filing_status_options'] = $cdf->getOptions('state_al_filing_status');
 $data['state_ct_filing_status_options'] = $cdf->getOptions('state_ct_filing_status');
 $data['state_wv_filing_status_options'] = $cdf->getOptions('state_wv_filing_status');
コード例 #2
0
            $utlf = new UserTaxListFactory();
            //$uwlf->GetByUserIdAndCompanyId($current_user->getId(), $current_company->getId() );
            $utlf->GetByUserId($user_id);
            foreach ($utlf as $tax) {
                //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
                //$user_id = $tax->getUser();
                $tax_data = array('id' => $tax->getId(), 'user_id' => $tax->getUser(), 'country' => $user_obj->getCountry(), 'federal_claim' => $tax->getFederalClaim(), 'provincial_claim' => $tax->getProvincialClaim(), 'federal_additional_deduction' => $tax->getFederalAdditionalDeduction(), 'wcb_rate' => $tax->getWCBRate(), 'vacation_rate' => $tax->getVacationRate(), 'release_vacation' => $tax->getReleaseVacation(), 'ei_exempt' => $tax->getEIExempt(), 'cpp_exempt' => $tax->getCPPExempt(), 'federal_tax_exempt' => $tax->getFederalTaxExempt(), 'provincial_tax_exempt' => $tax->getProvincialTaxExempt(), 'federal_filing_status_id' => $tax->getFederalFilingStatus(), 'state_filing_status_id' => $tax->getStateFilingStatus(), 'federal_allowance' => $tax->getFederalAllowance(), 'state_allowance' => $tax->getStateAllowance(), 'state_additional_deduction' => $tax->getStateAdditionalDeduction(), 'state_ui_rate' => $tax->getStateUIRate(), 'state_ui_wage_base' => $tax->getStateUIWageBase(), 'social_security_exempt' => $tax->getSocialSecurityExempt(), 'ui_exempt' => $tax->getUIExempt(), 'medicare_exempt' => $tax->getMedicareExempt(), 'created_date' => $tax->getCreatedDate(), 'created_by' => $tax->getCreatedBy(), 'updated_date' => $tax->getUpdatedDate(), 'updated_by' => $tax->getUpdatedBy(), 'deleted_date' => $tax->getDeletedDate(), 'deleted_by' => $tax->getDeletedBy());
            }
            if (!isset($tax_data)) {
                $tax_data = array('country' => $user_obj->getCountry(), 'wcb_rate' => 0, 'vacation_rate' => 0, 'federal_claim' => 0, 'provincial_claim' => 0, 'federal_additional_deduction' => 0, 'federal_allowance' => 0, 'state_allowance' => 0, 'state_additional_deduction' => 0, 'state_ui_rate' => 0, 'state_ui_wage_base' => 0);
            }
        } else {
            if ($tax_data['user_id'] != '') {
                $user_id = $tax_data['user_id'];
            }
        }
        $tax_data['user_options'] = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE);
        $tax_data['federal_filing_status_options'] = $utf->getOptions('federal_filing_status');
        $tax_data['state_filing_status_options'] = $utf->getOptions('state_filing_status');
        //var_dump($tax_data);
        $smarty->assign_by_ref('tax_data', $tax_data);
        $smarty->assign_by_ref('user_id', $user_id);
        $ulf = new UserListFactory();
        $ulf->getByIdAndCompanyId($user_id, $current_company->getId());
        $user_data = $ulf->getCurrent();
        $smarty->assign_by_ref('full_name', $user_data->getFullName());
        $smarty->assign_by_ref('data_saved', $data_saved);
        break;
}
$smarty->assign_by_ref('utf', $utf);
$smarty->display('users/EditUserTax.tpl');
コード例 #3
0
 function getSchedule($filter_data, $start_week_day = 0, $group_schedule = FALSE)
 {
     global $current_user, $current_user_prefs;
     //Individual is one schedule per employee, or all on one schedule.
     if (!is_array($filter_data)) {
         return FALSE;
     }
     $current_epoch = time();
     //Debug::Text('Start Date: '. TTDate::getDate('DATE', $start_date) .' End Date: '. TTDate::getDate('DATE', $end_date) , __FILE__, __LINE__, __METHOD__,10);
     Debug::text(' Start Date: ' . TTDate::getDate('DATE+TIME', $filter_data['start_date']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $filter_data['end_date']) . ' Start Week Day: ' . $start_week_day, __FILE__, __LINE__, __METHOD__, 10);
     $pdf = new TTPDF('L', 'pt', 'Letter');
     $left_margin = 20;
     $top_margin = 20;
     $pdf->setMargins($left_margin, $top_margin);
     $pdf->SetAutoPageBreak(TRUE, 30);
     //$pdf->SetAutoPageBreak(FALSE);
     $pdf->SetFont('freesans', '', 10);
     $border = 0;
     $adjust_x = 0;
     $adjust_y = 0;
     if ($group_schedule == FALSE) {
         $valid_schedules = 0;
         $sf = new ScheduleFactory();
         $tmp_schedule_shifts = $sf->getScheduleArray($filter_data);
         //Re-arrange array by user_id->date
         if (is_array($tmp_schedule_shifts)) {
             foreach ($tmp_schedule_shifts as $day_epoch => $day_schedule_shifts) {
                 foreach ($day_schedule_shifts as $day_schedule_shift) {
                     $raw_schedule_shifts[$day_schedule_shift['user_id']][$day_epoch][] = $day_schedule_shift;
                 }
             }
         }
         unset($tmp_schedule_shifts);
         //Debug::Arr($raw_schedule_shifts, 'Raw Schedule Shifts: ', __FILE__, __LINE__, __METHOD__,10);
         if (is_array($raw_schedule_shifts)) {
             foreach ($raw_schedule_shifts as $user_id => $day_schedule_shifts) {
                 foreach ($day_schedule_shifts as $day_epoch => $day_schedule_shifts) {
                     foreach ($day_schedule_shifts as $day_schedule_shift) {
                         //Debug::Arr($day_schedule_shift, 'aDay Schedule Shift: ', __FILE__, __LINE__, __METHOD__,10);
                         $tmp_schedule_shifts[$day_epoch][$day_schedule_shift['branch']][$day_schedule_shift['department']][] = $day_schedule_shift;
                         if (isset($schedule_shift_totals[$day_epoch]['total_shifts'])) {
                             $schedule_shift_totals[$day_epoch]['total_shifts']++;
                         } else {
                             $schedule_shift_totals[$day_epoch]['total_shifts'] = 1;
                         }
                         //$week_of_year = TTDate::getWeek( strtotime($day_epoch) );
                         $week_of_year = TTDate::getWeek(strtotime($day_epoch), $start_week_day);
                         if (!isset($schedule_shift_totals[$day_epoch]['labels'])) {
                             $schedule_shift_totals[$day_epoch]['labels'] = 0;
                         }
                         if ($day_schedule_shift['branch'] != '--' and !isset($schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']])) {
                             $schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']] = TRUE;
                             $schedule_shift_totals[$day_epoch]['labels']++;
                         }
                         if ($day_schedule_shift['department'] != '--' and !isset($schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']])) {
                             $schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']] = TRUE;
                             $schedule_shift_totals[$day_epoch]['labels']++;
                         }
                         if (!isset($max_week_data[$week_of_year]['shift'])) {
                             Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to 0', __FILE__, __LINE__, __METHOD__, 10);
                             $max_week_data[$week_of_year]['shift'] = 1;
                             $max_week_data[$week_of_year]['labels'] = 0;
                         }
                         if (isset($max_week_data[$week_of_year]['shift']) and $schedule_shift_totals[$day_epoch]['total_shifts'] + $schedule_shift_totals[$day_epoch]['labels'] > $max_week_data[$week_of_year]['shift'] + $max_week_data[$week_of_year]['labels']) {
                             Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to: ' . $schedule_shift_totals[$day_epoch]['total_shifts'] . ' Labels: ' . $schedule_shift_totals[$day_epoch]['labels'], __FILE__, __LINE__, __METHOD__, 10);
                             $max_week_data[$week_of_year]['shift'] = $schedule_shift_totals[$day_epoch]['total_shifts'];
                             $max_week_data[$week_of_year]['labels'] = $schedule_shift_totals[$day_epoch]['labels'];
                         }
                         //Debug::Arr($schedule_shift_totals, ' Schedule Shift Totals: ', __FILE__, __LINE__, __METHOD__,10);
                         //Debug::Arr($max_week_data, ' zMaxWeekData: ', __FILE__, __LINE__, __METHOD__,10);
                     }
                 }
                 if (isset($tmp_schedule_shifts)) {
                     //Sort Branches/Departments first
                     foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                         ksort($day_tmp_schedule_shift);
                         $tmp_schedule_shifts[$day_epoch] = $day_tmp_schedule_shift;
                         foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                             ksort($tmp_schedule_shifts[$day_epoch][$branch]);
                         }
                     }
                     //Sort each department by start time.
                     foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                         foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                             foreach ($department_schedule_shifts as $department => $department_schedule_shift) {
                                 $department_schedule_shift = Sort::multiSort($department_schedule_shift, 'start_time');
                                 $this->schedule_shifts[$day_epoch][$branch][$department] = $department_schedule_shift;
                             }
                         }
                     }
                 }
                 unset($day_tmp_schedule_shift, $department_schedule_shifts, $department_schedule_shift, $tmp_schedule_shifts, $branch, $department);
                 $calendar_array = TTDate::getCalendarArray($filter_data['start_date'], $filter_data['end_date'], $start_week_day);
                 //var_dump($calendar_array);
                 if (!is_array($calendar_array) or !isset($this->schedule_shifts) or !is_array($this->schedule_shifts)) {
                     continue;
                     //Skip to next user.
                 }
                 $ulf = new UserListFactory();
                 $ulf->getByIdAndCompanyId($user_id, $current_user->getCompany());
                 if ($ulf->getRecordCount() != 1) {
                     continue;
                 } else {
                     $user_obj = $ulf->getCurrent();
                     $pdf->AddPage();
                     $pdf->setXY(670, $top_margin);
                     $pdf->SetFont('freesans', '', 10);
                     $pdf->Cell(100, 15, TTDate::getDate('DATE+TIME', $current_epoch), $border, 0, 'R');
                     $pdf->setXY($left_margin, $top_margin);
                     $pdf->SetFont('freesans', 'B', 25);
                     $pdf->Cell(0, 25, $user_obj->getFullName() . ' - ' . TTi18n::getText('Schedule'), $border, 0, 'C');
                     $pdf->Ln();
                 }
                 $pdf->SetFont('freesans', 'B', 16);
                 $pdf->Cell(0, 15, TTDate::getDate('DATE', $filter_data['start_date']) . ' - ' . TTDate::getDate('DATE', $filter_data['end_date']), $border, 0, 'C');
                 //$pdf->Ln();
                 $pdf->Ln();
                 $pdf->Ln();
                 $pdf->SetFont('freesans', '', 8);
                 $cell_width = floor(($pdf->GetPageWidth() - $left_margin * 2) / 7);
                 $cell_height = 100;
                 $i = 0;
                 $total_days = count($calendar_array) - 1;
                 $boader = 1;
                 foreach ($calendar_array as $calendar) {
                     if ($i == 0) {
                         //Calendar Header
                         $pdf->SetFont('freesans', 'B', 8);
                         $calendar_header = TTDate::getDayOfWeekArrayByStartWeekDay($start_week_day);
                         foreach ($calendar_header as $header_name) {
                             $pdf->Cell($cell_width, 15, $header_name, 1, 0, 'C');
                         }
                         $pdf->Ln();
                         unset($calendar_header, $header_name);
                     }
                     $month_name = NULL;
                     if ($i == 0 or $calendar['isNewMonth'] == TRUE) {
                         $month_name = $calendar['month_name'];
                     }
                     if ($i > 0 and $i % 7 == 0) {
                         $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day);
                         unset($week_date_stamps);
                     }
                     $pdf->SetFont('freesans', 'B', 8);
                     $pdf->Cell($cell_width / 2, 15, $month_name, 'LT', 0, 'L');
                     $pdf->Cell($cell_width / 2, 15, $calendar['day_of_month'], 'RT', 0, 'R');
                     $week_date_stamps[] = $calendar['date_stamp'];
                     $i++;
                 }
                 $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day, TRUE);
                 $valid_schedules++;
                 unset($this->schedule_shifts, $calendar_array, $week_date_stamps, $max_week_data, $day_epoch, $day_schedule_shifts, $day_schedule_shift, $schedule_shift_totals);
             }
         }
         unset($raw_schedule_shifts);
     } else {
         $valid_schedules = 1;
         $sf = new ScheduleFactory();
         $raw_schedule_shifts = $sf->getScheduleArray($filter_data);
         if (is_array($raw_schedule_shifts)) {
             foreach ($raw_schedule_shifts as $day_epoch => $day_schedule_shifts) {
                 foreach ($day_schedule_shifts as $day_schedule_shift) {
                     //Debug::Arr($day_schedule_shift, 'bDay Schedule Shift: ', __FILE__, __LINE__, __METHOD__,10);
                     $tmp_schedule_shifts[$day_epoch][$day_schedule_shift['branch']][$day_schedule_shift['department']][] = $day_schedule_shift;
                     if (isset($schedule_shift_totals[$day_epoch]['total_shifts'])) {
                         $schedule_shift_totals[$day_epoch]['total_shifts']++;
                     } else {
                         $schedule_shift_totals[$day_epoch]['total_shifts'] = 1;
                     }
                     //$week_of_year = TTDate::getWeek( strtotime($day_epoch) );
                     $week_of_year = TTDate::getWeek(strtotime($day_epoch), $start_week_day);
                     Debug::text(' Date: ' . TTDate::getDate('DATE', strtotime($day_epoch)) . ' Week: ' . $week_of_year . ' TMP: ' . TTDate::getWeek(strtotime('20070721'), $start_week_day), __FILE__, __LINE__, __METHOD__, 10);
                     if (!isset($schedule_shift_totals[$day_epoch]['labels'])) {
                         $schedule_shift_totals[$day_epoch]['labels'] = 0;
                     }
                     if ($day_schedule_shift['branch'] != '--' and !isset($schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']])) {
                         $schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']] = TRUE;
                         $schedule_shift_totals[$day_epoch]['labels']++;
                     }
                     if ($day_schedule_shift['department'] != '--' and !isset($schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']])) {
                         $schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']] = TRUE;
                         $schedule_shift_totals[$day_epoch]['labels']++;
                     }
                     if (!isset($max_week_data[$week_of_year]['shift'])) {
                         Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to 0', __FILE__, __LINE__, __METHOD__, 10);
                         $max_week_data[$week_of_year]['shift'] = 1;
                         $max_week_data[$week_of_year]['labels'] = 0;
                     }
                     if (isset($max_week_data[$week_of_year]['shift']) and $schedule_shift_totals[$day_epoch]['total_shifts'] + $schedule_shift_totals[$day_epoch]['labels'] > $max_week_data[$week_of_year]['shift'] + $max_week_data[$week_of_year]['labels']) {
                         Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to: ' . $schedule_shift_totals[$day_epoch]['total_shifts'] . ' Labels: ' . $schedule_shift_totals[$day_epoch]['labels'], __FILE__, __LINE__, __METHOD__, 10);
                         $max_week_data[$week_of_year]['shift'] = $schedule_shift_totals[$day_epoch]['total_shifts'];
                         $max_week_data[$week_of_year]['labels'] = $schedule_shift_totals[$day_epoch]['labels'];
                     }
                 }
             }
         }
         //print_r($tmp_schedule_shifts);
         //print_r($max_week_data);
         if (isset($tmp_schedule_shifts)) {
             //Sort Branches/Departments first
             foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                 ksort($day_tmp_schedule_shift);
                 $tmp_schedule_shifts[$day_epoch] = $day_tmp_schedule_shift;
                 foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                     ksort($tmp_schedule_shifts[$day_epoch][$branch]);
                 }
             }
             //Sort each department by start time.
             foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                 foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                     foreach ($department_schedule_shifts as $department => $department_schedule_shift) {
                         $sort = new arr_multisort();
                         $sort->setArray($department_schedule_shift);
                         $sort->addColumn('start_time', 1);
                         $department_schedule_shift = $sort->Sort();
                         unset($sort);
                         $this->schedule_shifts[$day_epoch][$branch][$department] = $department_schedule_shift;
                     }
                 }
             }
         }
         //print_r($this->schedule_shifts);
         $calendar_array = TTDate::getCalendarArray($filter_data['start_date'], $filter_data['end_date'], $start_week_day);
         //var_dump($calendar_array);
         if (!is_array($calendar_array) or !isset($this->schedule_shifts) or !is_array($this->schedule_shifts)) {
             return FALSE;
         }
         $pdf->AddPage();
         $pdf->setXY(670, $top_margin);
         $pdf->SetFont('freesans', '', 10);
         $pdf->Cell(100, 15, TTDate::getDate('DATE+TIME', $current_epoch), $border, 0, 'R');
         $pdf->setXY($left_margin, $top_margin);
         $pdf->SetFont('freesans', 'B', 25);
         $pdf->Cell(0, 25, 'Employee Schedule', $border, 0, 'C');
         $pdf->Ln();
         $pdf->SetFont('freesans', 'B', 10);
         $pdf->Cell(0, 15, TTDate::getDate('DATE', $filter_data['start_date']) . ' - ' . TTDate::getDate('DATE', $filter_data['end_date']), $border, 0, 'C');
         $pdf->Ln();
         $pdf->Ln();
         $pdf->SetFont('freesans', '', 8);
         $cell_width = floor(($pdf->GetPageWidth() - $left_margin * 2) / 7);
         $cell_height = 100;
         $i = 0;
         $total_days = count($calendar_array) - 1;
         $boader = 1;
         foreach ($calendar_array as $calendar) {
             if ($i == 0) {
                 //Calendar Header
                 $pdf->SetFont('freesans', 'B', 8);
                 $calendar_header = TTDate::getDayOfWeekArrayByStartWeekDay($start_week_day);
                 foreach ($calendar_header as $header_name) {
                     $pdf->Cell($cell_width, 15, $header_name, 1, 0, 'C');
                 }
                 $pdf->Ln();
                 unset($calendar_header, $header_name);
             }
             $month_name = NULL;
             if ($i == 0 or $calendar['isNewMonth'] == TRUE) {
                 $month_name = $calendar['month_name'];
             }
             if ($i > 0 and $i % 7 == 0) {
                 $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day);
                 unset($week_date_stamps);
             }
             $pdf->SetFont('freesans', 'B', 8);
             $pdf->Cell($cell_width / 2, 15, $month_name, 'LT', 0, 'L');
             $pdf->Cell($cell_width / 2, 15, $calendar['day_of_month'], 'RT', 0, 'R');
             $week_date_stamps[] = $calendar['date_stamp'];
             $i++;
         }
         $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day, TRUE);
     }
     if ($valid_schedules > 0) {
         $output = $pdf->Output('', 'S');
         return $output;
     }
     return FALSE;
 }
コード例 #4
0
     }
     $baf->setTransit($bank_data['transit']);
     $baf->setAccount($bank_data['account']);
     if ($baf->isValid()) {
         $baf->Save();
         Redirect::Page(URLBuilder::getURL(array('user_id' => $user_id, 'company_id' => $company_id, 'data_saved' => TRUE), Environment::getBaseURL() . '/bank_account/EditBankAccount.php'));
         break;
     }
 default:
     $balf = new BankAccountListFactory();
     $ulf = new UserListFactory();
     if ($user_id == '' and $company_id == '' and $permission->Check('user', 'edit_own_bank')) {
         //Current user
         $balf->getUserAccountByCompanyIdAndUserId($current_company->getId(), $current_user->getId());
         $user_id = $current_user->getId();
         $user_obj = $ulf->getByIdAndCompanyId($user_id, $current_company->getId())->getCurrent();
         $country = $user_obj->getCountry();
     } elseif ($user_id != '' and $permission->Check('user', 'edit_bank')) {
         //Specified User
         $balf->getUserAccountByCompanyIdAndUserId($current_company->getId(), $user_id);
         $user_obj = $ulf->getByIdAndCompanyId($user_id, $current_company->getId())->getCurrent();
         $country = $user_obj->getCountry();
     } elseif ($company_id != '' and $permission->Check('company', 'edit_own_bank')) {
         //Company bank.
         $balf->getCompanyAccountByCompanyId($current_company->getId());
         $country = $current_company->getCountry();
     } else {
         $permission->Redirect(FALSE);
     }
     if (!isset($action)) {
         BreadCrumb::setCrumb($title);
コード例 #5
0
 function enroll($user_id, $id, $type = 'iButton', $number = 0, $extra_value = NULL)
 {
     Debug::text('Client Version: ' . $this->getClientVersion() . ' User ID : ' . $user_id . ' ID: ' . substr($id, 0, 100) . ' Type: ' . $type . ' Number: ' . $number, __FILE__, __LINE__, __METHOD__, 10);
     $user_id = trim($user_id);
     $id = trim($id);
     $type = strtolower($type);
     $number = trim($number);
     $ulf = new UserListFactory();
     if (version_compare($this->getClientVersion(), '2.7.0', '<')) {
         Debug::text('aVersion: ' . $this->getClientVersion(), __FILE__, __LINE__, __METHOD__, 10);
         //Fingerprints can send $id=NULL to clear an enrollment.
         if (strpos($type, 'finger_print') === FALSE and $id == '') {
             Debug::text('ID is not valid: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
             return FALSE;
         }
         //Check to make sure the logged in user has edit_advance permissions
         if ($this->getPermissionObject()->Check('user', 'enroll') or $this->getPermissionObject()->Check('user', 'enroll_child')) {
             Debug::text('User : '******' has Enroll permission', __FILE__, __LINE__, __METHOD__, 10);
             switch ($type) {
                 case 'finger_print_1':
                 case 'finger_print_2':
                 case 'finger_print_3':
                 case 'finger_print_4':
                     $enroll_user_obj = $ulf->getByIdAndCompanyId($user_id, $this->getUserObject()->getCompany());
                     if ($enroll_user_obj->getRecordCount() == 1) {
                         Debug::text('Enroller User ID : ' . $user_id . ' FOUND', __FILE__, __LINE__, __METHOD__, 10);
                         $enroll_user_obj = $enroll_user_obj->getCurrent();
                         switch ($type) {
                             case 'finger_print_1':
                                 $number = 10;
                                 break;
                             case 'finger_print_2':
                                 $number = 20;
                                 break;
                             case 'finger_print_3':
                                 $number = 30;
                                 break;
                             case 'finger_print_4':
                                 $number = 40;
                                 break;
                         }
                         $uilf = new UserIdentificationListFactory();
                         $uilf->getByUserIdAndTypeIdAndNumber($enroll_user_obj->getID(), 20, $number);
                         if ($uilf->getRecordCount() > 0) {
                             $uif = $uilf->getCurrent();
                         } else {
                             $uif = new UserIdentificationFactory();
                         }
                         if ($id == '' and $uilf->getRecordCount() > 0) {
                             Debug::text('Deleting Fingerprint...', __FILE__, __LINE__, __METHOD__, 10);
                             $uif->setDeleted(TRUE);
                             if ($uif->isValid()) {
                                 if ($uif->save()) {
                                     return TRUE;
                                 }
                             }
                         } elseif ($id != '') {
                             $uif->setUser($enroll_user_obj->getId());
                             $uif->setType(20);
                             //Griaule
                             $uif->setNumber($number);
                             $uif->setValue($id);
                             if ($uif->isValid()) {
                                 if ($uif->save()) {
                                     return TRUE;
                                 }
                             }
                         }
                         Debug::text('Enroll User Object not valid : ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                         Debug::text('User ID : ' . $user_id . ' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     break;
                 case 'ibutton':
                     //Remove ibutton from current user.
                     $uilf = new UserIdentificationListFactory();
                     $uilf->getByCompanyIdAndTypeIdAndValue($this->getUserObject()->getCompany(), 10, $id);
                     if ($uilf->getRecordCount() > 0) {
                         foreach ($uilf as $ui_obj) {
                             Debug::text('Removing iButton ID from User: '******'Didnt find current user with iButton assigned...', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     $enroll_user_obj = $ulf->getByIdAndCompanyId($user_id, $this->getUserObject()->getCompany());
                     if ($enroll_user_obj->getRecordCount() == 1) {
                         Debug::text('Enroller User ID : ' . $user_id . ' FOUND', __FILE__, __LINE__, __METHOD__, 10);
                         $enroll_user_obj = $enroll_user_obj->getCurrent();
                         $uilf = new UserIdentificationListFactory();
                         $uilf->getByUserIdAndTypeIdAndNumber($enroll_user_obj->getID(), 10, 0);
                         if ($uilf->getRecordCount() > 0) {
                             $uif = $uilf->getCurrent();
                         } else {
                             $uif = new UserIdentificationFactory();
                         }
                         $uif->setUser($enroll_user_obj->getId());
                         $uif->setType(10);
                         //iButton
                         $uif->setNumber(0);
                         $uif->setValue($id);
                         if ($uif->isValid()) {
                             if ($uif->save()) {
                                 return TRUE;
                             }
                         }
                         Debug::text('Enroll User Object not valid : ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                         Debug::text('User ID : ' . $user_id . ' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     /*
                     $ulf->getByCompanyIDAndIButtonId( $this->getUserObject()->getCompany(), $id );
                     if ( $ulf->getRecordCount() > 0 ) {
                     	$old_user_obj = $ulf->getCurrent();
                     
                     	Debug::text('Removing iButton ID from User: '******'Didnt find current user with iButton assigned...', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     
                     //$enroll_user_obj = $ulf->getByUserNameAndCompanyId( $user_name, $this->getUserObject()->getCompany() );
                     $enroll_user_obj = $ulf->getByIdAndCompanyId( $user_id, $this->getUserObject()->getCompany() );
                     
                     if ( $enroll_user_obj->getRecordCount() == 1 ) {
                     	Debug::text('Enroller User ID : '. $user_id .' FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     
                     	$enroll_user_obj = $enroll_user_obj->getCurrent();
                     
                     	//Update ibutton id.
                     	$enroll_user_obj->setIButtonID( $id );
                     	if ( $enroll_user_obj->isValid() ) {
                     		if ( $enroll_user_obj->save() ) {
                     			return TRUE;
                     		}
                     	}
                     
                     	Debug::text('Enroll User Object not valid : '. $user_id, __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                     	Debug::text('User ID : '. $user_id .' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     */
                     break;
             }
         } else {
             Debug::text('User : '******' DOES NOT HAVE edit advance permission', __FILE__, __LINE__, __METHOD__, 10);
         }
     } else {
         //This code path needs to handle re-enrolling iButtons, proximity cards, etc... for a different employees.
         Debug::text('bVersion: ' . $this->getClientVersion(), __FILE__, __LINE__, __METHOD__, 10);
         $ulf->getByIdAndCompanyId($user_id, $this->getUserObject()->getCompany());
         if ($ulf->getRecordCount() == 1) {
             Debug::text('Enroller User ID : ' . $user_id . ' FOUND', __FILE__, __LINE__, __METHOD__, 10);
             //Checking to see if value is enrolled for a different user first.
             $uilf = new UserIdentificationListFactory();
             $uilf->getByCompanyIdAndTypeIdAndValue($this->getUserObject()->getCompany(), $type, $id);
             if ($uilf->getRecordCount() > 0) {
                 foreach ($uilf as $ui_obj) {
                     Debug::text('Removing enolled value from User: '******'Didnt find current user with enrolled value assigned...', __FILE__, __LINE__, __METHOD__, 10);
             }
             $enroll_user_obj = $ulf->getCurrent();
             $uilf = new UserIdentificationListFactory();
             $uilf->getByUserIdAndTypeIdAndNumber($enroll_user_obj->getID(), $type, $number);
             if ($uilf->getRecordCount() > 0) {
                 $uif = $uilf->getCurrent();
             } else {
                 $uif = new UserIdentificationFactory();
             }
             if ($id == '' and $uilf->getRecordCount() > 0) {
                 Debug::text('Deleting User Identification...', __FILE__, __LINE__, __METHOD__, 10);
                 $uif->setDeleted(TRUE);
                 if ($uif->isValid()) {
                     if ($uif->save()) {
                         return TRUE;
                     }
                 }
             } elseif ($id != '') {
                 Debug::text('Adding/Modifying User Identification...', __FILE__, __LINE__, __METHOD__, 10);
                 $uif->setUser($enroll_user_obj->getId());
                 $uif->setType($type);
                 $uif->setNumber($number);
                 $uif->setValue($id);
                 //Primarily used to store raw fingerprint images during enroll.
                 if ($extra_value != '') {
                     $uif->setExtraValue($extra_value);
                 }
                 if ($uif->isValid()) {
                     if ($uif->save()) {
                         return TRUE;
                     }
                 }
             }
             Debug::text('Enroll User Object not valid : ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
         } else {
             Debug::text('User ID : ' . $user_id . ' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
         }
     }
     return FALSE;
 }
コード例 #6
0
ファイル: EditUser.php プロジェクト: J-P-Hanafin/TimeTrex-1
         Debug::Text('Login as different user: '******'Login', TTi18n::getText('Switch User') . ': ' . TTi18n::getText('SourceIP') . ': ' . $authentication->getIPAddress() . ' ' . TTi18n::getText('SessionID') . ': ' . $authentication->getSessionID() . ' ' . TTi18n::getText('UserID') . ': ' . $id, $current_user->getId(), 'authentication');
         Redirect::Page(URLBuilder::getURL(NULL, '../index.php'));
     }
     break;
 case 'submit':
     //Debug::setVerbosity( 11 );
     Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
     unset($id);
     //Do this so it doesn't reload the data from the DB.
     //Additional permission checks.
     if ($permission->Check('company', 'view')) {
         $ulf->getById($user_data['id']);
     } else {
         $ulf->getByIdAndCompanyId($user_data['id'], $current_company->getId());
     }
     if ($ulf->getRecordCount() > 0) {
         $user = $ulf->getCurrent();
         $is_owner = $permission->isOwner($user->getCreatedBy(), $user->getID());
         $is_child = $permission->isChild($user->getId(), $permission_children_ids);
         if ($permission->Check('user', 'edit') or $permission->Check('user', 'edit_child') and $is_child === TRUE or $permission->Check('user', 'edit_own') and $is_owner === TRUE) {
             // Security measure.
             if (!empty($user_data['id'])) {
                 if ($permission->Check('company', 'view')) {
                     $uf = $ulf->getById($user_data['id'])->getCurrent();
                 } else {
                     $uf = $ulf->getByIdAndCompanyId($user_data['id'], $current_company->getId())->getCurrent();
                 }
             }
         } else {
コード例 #7
0
ファイル: UserList.php プロジェクト: J-P-Hanafin/TimeTrex-1
     break;
 case 'delete':
 case 'undelete':
     //Debug::setVerbosity( 11 );
     if (strtolower($action) == 'delete') {
         $delete = TRUE;
     } else {
         $delete = FALSE;
     }
     if (DEMO_MODE == FALSE and ($permission->Check('user', 'delete') or $permission->Check('user', 'delete_own') or $permission->Check('user', 'delete_child'))) {
         if (is_array($ids)) {
             $ulf = new UserListFactory();
             $ulf->StartTransaction();
             foreach ($ids as $id) {
                 if ($id != $current_user->getId()) {
                     $ulf->getByIdAndCompanyId($id, $current_company->getID());
                     foreach ($ulf as $user) {
                         $is_owner = $permission->isOwner($user->getCreatedBy(), $user->getID());
                         $is_child = $permission->isChild($user->getId(), $permission_children_ids);
                         if ($permission->Check('user', 'delete') or $permission->Check('user', 'delete_child') and $is_child === TRUE or $permission->Check('user', 'delete_own') and $is_owner === TRUE) {
                             $user->setDeleted($delete);
                             $user->Save();
                         }
                     }
                 }
             }
             $ulf->CommitTransaction();
         }
     }
     Redirect::Page(URLBuilder::getURL(array('saved_search_id' => $saved_search_id), 'UserList.php'));
     break;