$user_full_name = NULL; $user_default_branch = NULL; $user_default_department = NULL; $pay_period_is_locked = FALSE; $time_stamp = $start_date_stamp = $end_date_stamp = TTDate::getBeginDayEpoch(TTDate::getTime()) + 3600 * 12; //Noon $data = array('start_date_stamp' => $start_date_stamp, 'end_date_stamp' => $end_date_stamp, 'start_time' => strtotime('08:00 AM'), 'parsed_start_time' => strtotime('08:00 AM'), 'end_time' => strtotime('05:00 PM'), 'parsed_end_time' => strtotime('05:00 PM'), 'total_time' => 3600 * 9, 'branch_id' => $user_default_branch, 'department_id' => $user_default_department, 'dow' => array(1 => TRUE, 2 => TRUE, 3 => TRUE, 4 => TRUE, 5 => TRUE)); } //var_dump($data); $ulf = new UserListFactory(); $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); $src_user_options = UserListFactory::getArrayByListFactory($ulf, FALSE, FALSE); $user_options = Misc::arrayDiffByKey((array) $filter_user_id, $src_user_options); $filter_user_options = Misc::arrayIntersectByKey((array) $filter_user_id, $src_user_options); $prepend_array_option = array(0 => '--', -1 => TTi18n::gettext('-- Default --')); $splf = new SchedulePolicyListFactory(); $schedule_policy_options = $splf->getByCompanyIdArray($current_company->getId()); $aplf = new AbsencePolicyListFactory(); $absence_policy_options = $aplf->getByCompanyIdArray($current_company->getId()); $blf = new BranchListFactory(); $blf->getByCompanyId($current_company->getId()); $branch_options = Misc::prependArray($prepend_array_option, $blf->getArrayByListFactory($blf, FALSE, TRUE)); $dlf = new DepartmentListFactory(); $dlf->getByCompanyId($current_company->getId()); $department_options = Misc::prependArray($prepend_array_option, $dlf->getArrayByListFactory($dlf, FALSE, TRUE)); if ($current_company->getProductEdition() == 20) { $jlf = new JobListFactory(); $jlf->getByStatusIdAndCompanyId(array(10, 20, 30, 40), $current_company->getId()); //$jlf->getByCompanyIdAndUserIdAndStatus( $current_company->getId(), $data['user_id'], array(10,20,30,40) ); $data['job_options'] = $jlf->getArrayByListFactory($jlf, TRUE, TRUE); $data['job_manual_id_options'] = $jlf->getManualIDArrayByListFactory($jlf, TRUE);
function getByCompanyIdArray($company_id, $include_blank = TRUE) { $splf = new SchedulePolicyListFactory(); $splf->getByCompanyId($company_id); if ($include_blank == TRUE) { $list[0] = '--'; } foreach ($splf as $sp_obj) { $list[$sp_obj->getID()] = $sp_obj->getName(); } if (isset($list)) { return $list; } return FALSE; }
function setSchedulePolicyID($id) { $id = trim($id); if ($id == '' or empty($id)) { $id = NULL; } $splf = new SchedulePolicyListFactory(); if ($id == NULL or $this->Validator->isResultSetWithRows('schedule_policy', $splf->getByID($id), TTi18n::gettext('Schedule Policy is invalid'))) { $this->data['schedule_policy_id'] = $id; return TRUE; } return FALSE; }
$delete = FALSE; } $splf = new SchedulePolicyListFactory(); foreach ($ids as $id) { $splf->getByIdAndCompanyId($id, $current_company->getId()); foreach ($splf as $sp_obj) { $sp_obj->setDeleted($delete); if ($sp_obj->isValid()) { $sp_obj->Save(); } } } Redirect::Page(URLBuilder::getURL(NULL, 'SchedulePolicyList.php')); break; default: $splf = new SchedulePolicyListFactory(); $splf->getByCompanyId($current_company->getId()); $pager = new Pager($splf); $aplf = new AbsencePolicyListFactory(); $absence_options = $aplf->getByCompanyIDArray($current_company->getId(), TRUE); $mplf = new MealPolicyListFactory(); $meal_options = $mplf->getByCompanyIDArray($current_company->getId(), TRUE); foreach ($splf as $sp_obj) { $policies[] = array('id' => $sp_obj->getId(), 'name' => $sp_obj->getName(), 'meal_policy_id' => $sp_obj->getMealPolicyID(), 'meal_policy' => Option::getByKey($sp_obj->getMealPolicyID(), $meal_options), 'absence_policy_id' => $sp_obj->getAbsencePolicyID(), 'absence_policy' => Option::getByKey($sp_obj->getAbsencePolicyID(), $absence_options), 'start_stop_window' => $sp_obj->getStartStopWindow(), 'deleted' => $sp_obj->getDeleted()); } $smarty->assign_by_ref('policies', $policies); $smarty->assign_by_ref('sort_column', $sort_column); $smarty->assign_by_ref('sort_order', $sort_order); $smarty->assign_by_ref('paging_data', $pager->getPageVariables()); break; }
$rstf->setSchedulePolicyID($week_row['schedule_policy_id']); $rstf->preSave(); $week_rows[$week_row_id]['total_time'] = $rstf->getTotalTime(); if ($week_row_id == $lowest_id) { $next_total_time = $week_rows[$week_row_id]['total_time']; } } } } $week_rows[$next_blank_id] = array('id' => $next_blank_id, 'week' => $last_week + 1, 'start_time' => $week_rows[$lowest_id]['start_time'], 'end_time' => $week_rows[$lowest_id]['end_time'], 'total_time' => $next_total_time, 'schedule_policy_id' => $week_rows[$lowest_id]['schedule_policy_id'], 'branch_id' => $week_rows[$lowest_id]['branch_id'], 'department_id' => $week_rows[$lowest_id]['department_id'], 'mon' => @$week_rows[$lowest_id]['mon'], 'tue' => @$week_rows[$lowest_id]['tue'], 'wed' => @$week_rows[$lowest_id]['wed'], 'thu' => @$week_rows[$lowest_id]['thu'], 'fri' => @$week_rows[$lowest_id]['fri'], 'sat' => @$week_rows[$lowest_id]['sat'], 'sun' => @$week_rows[$lowest_id]['sun']); } elseif ($action != 'submit' and $action != 'delete') { $week_rows[-1] = array('id' => -1, 'week' => 1, 'mon' => TRUE, 'tue' => TRUE, 'wed' => TRUE, 'thu' => TRUE, 'fri' => TRUE, 'start_time' => strtotime('08:00'), 'end_time' => strtotime('17:00'), 'total_time' => 9 * 3600, 'branch_id' => -1, 'department_id' => -1, 'schedule_policy_id' => 0); } $prepend_array_option = array(0 => '--', -1 => TTi18n::gettext('-- Default --')); //Select box options; $splf = new SchedulePolicyListFactory(); $data['schedule_options'] = $splf->getByCompanyIdArray($current_company->getId()); $blf = new BranchListFactory(); $blf->getByCompanyId($current_company->getId()); $data['branch_options'] = Misc::prependArray($prepend_array_option, $blf->getArrayByListFactory($blf, FALSE, TRUE)); //$data['branch_options'] = Misc::prependArray( array( -1 => '-- Default --' ), $blf->getByCompanyIdArray( $current_company->getId(), FALSE, FALSE ) ); $dlf = new DepartmentListFactory(); $dlf->getByCompanyId($current_company->getId()); $data['department_options'] = Misc::prependArray($prepend_array_option, $dlf->getArrayByListFactory($dlf, FALSE, TRUE)); //$data['department_options'] = $dlf->getByCompanyIdArray( $current_company->getId() ); if ($current_company->getProductEdition() == 20) { $jlf = new JobListFactory(); $data['job_options'] = $jlf->getByCompanyIdAndStatusArray($current_company->getId(), array(10, 20, 30, 40), TRUE); $jilf = new JobItemListFactory(); $data['job_item_options'] = $jilf->getByCompanyIdArray($current_company->getId(), TRUE); }
$spf->setAbsencePolicyID($data['absence_policy_id']); $spf->setStartStopWindow($data['start_stop_window']); if ($spf->isValid()) { $spf->Save(FALSE); if (isset($data['break_policy_ids'])) { $spf->setBreakPolicy($data['break_policy_ids']); } else { $spf->setBreakPolicy(array()); } Redirect::Page(URLBuilder::getURL(NULL, 'SchedulePolicyList.php')); break; } default: if (isset($id)) { BreadCrumb::setCrumb($title); $splf = new SchedulePolicyListFactory(); $splf->getByIdAndCompanyID($id, $current_company->getID()); foreach ($splf as $sp_obj) { //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10); $data = array('id' => $sp_obj->getId(), 'name' => $sp_obj->getName(), 'over_time_policy_id' => $sp_obj->getOverTimePolicyID(), 'absence_policy_id' => $sp_obj->getAbsencePolicyID(), 'meal_policy_id' => $sp_obj->getMealPolicyID(), 'break_policy_ids' => $sp_obj->getBreakPolicy(), 'start_stop_window' => $sp_obj->getStartStopWindow(), 'created_date' => $sp_obj->getCreatedDate(), 'created_by' => $sp_obj->getCreatedBy(), 'updated_date' => $sp_obj->getUpdatedDate(), 'updated_by' => $sp_obj->getUpdatedBy(), 'deleted_date' => $sp_obj->getDeletedDate(), 'deleted_by' => $sp_obj->getDeletedBy()); } } elseif ($action != 'submit') { $data = array('start_stop_window' => 3600); } $aplf = new AbsencePolicyListFactory(); $absence_options = $aplf->getByCompanyIDArray($current_company->getId(), TRUE); $otplf = new OverTimePolicyListFactory(); $over_time_options = $otplf->getByCompanyIDArray($current_company->getId(), TRUE, array('type_id' => '= 200')); $mplf = new MealPolicyListFactory(); $meal_options = $mplf->getByCompanyIDArray($current_company->getId(), TRUE); $bplf = new BreakPolicyListFactory();