function setBranch($id)
 {
     $id = trim($id);
     $blf = new BranchListFactory();
     if ($this->Validator->isResultSetWithRows('branch', $blf->getByID($id), TTi18n::gettext('Selected Branch is invalid'))) {
         $this->data['branch_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
Example #2
0
 /**
  * Get default branch data for creating new branches.
  * @return array
  */
 function getBranchDefaultData()
 {
     $company_obj = $this->getCurrentCompanyObject();
     Debug::Text('Getting branch default data...', __FILE__, __LINE__, __METHOD__, 10);
     $next_available_manual_id = BranchListFactory::getNextAvailableManualId($company_obj->getId());
     $data = array('company_id' => $company_obj->getId(), 'status_id' => 10, 'manual_id' => $next_available_manual_id, 'city' => $company_obj->getCity(), 'country' => $company_obj->getCountry(), 'province' => $company_obj->getProvince(), 'work_phone' => $company_obj->getWorkPhone(), 'fax_phone' => $company_obj->getFaxPhone());
     return $this->returnHandler($data);
 }
 function getScheduleArray($filter_data)
 {
     global $current_user, $current_user_prefs;
     //Get all schedule data by general filter criteria.
     Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__, 10);
     if (!isset($filter_data['start_date']) or $filter_data['start_date'] == '') {
         return FALSE;
     }
     if (!isset($filter_data['end_date']) or $filter_data['end_date'] == '') {
         return FALSE;
     }
     $filter_data['start_date'] = TTDate::getBeginDayEpoch($filter_data['start_date']);
     $filter_data['end_date'] = TTDate::getEndDayEpoch($filter_data['end_date']);
     $blf = new BranchListFactory();
     $branch_options = $blf->getByCompanyIdArray($current_user->getCompany(), FALSE);
     $dlf = new DepartmentListFactory();
     $department_options = $dlf->getByCompanyIdArray($current_user->getCompany(), FALSE);
     $slf = new ScheduleListFactory();
     $slf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data);
     Debug::text('Found Scheduled Rows: ' . $slf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     if ($slf->getRecordCount() > 0) {
         foreach ($slf as $s_obj) {
             Debug::text('Schedule ID: ' . $s_obj->getId() . ' User ID: ' . $s_obj->getColumn('user_id') . ' Start Time: ' . $s_obj->getStartTime(), __FILE__, __LINE__, __METHOD__, 10);
             if (is_object($s_obj->getAbsencePolicyObject())) {
                 $absence_policy_name = (string) $s_obj->getAbsencePolicyObject()->getName();
             } else {
                 $absence_policy_name = 'N/A';
             }
             $iso_date_stamp = TTDate::getISODateStamp($s_obj->getStartTime());
             $schedule_shifts[$iso_date_stamp][$s_obj->getColumn('user_id') . $s_obj->getStartTime()] = array('id' => (int) $s_obj->getID(), 'user_id' => (int) $s_obj->getColumn('user_id'), 'user_created_by' => (int) $s_obj->getColumn('user_created_by'), 'user_full_name' => Misc::getFullName($s_obj->getColumn('first_name'), NULL, $s_obj->getColumn('last_name'), FALSE, FALSE), 'first_name' => $s_obj->getColumn('first_name'), 'last_name' => $s_obj->getColumn('last_name'), 'status_id' => (int) $s_obj->getStatus(), 'date_stamp' => TTDate::getAPIDate('DATE', TTDate::parseDateTime($s_obj->getColumn('date_stamp'))), 'start_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'start_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'total_time' => $s_obj->getTotalTime(), 'schedule_policy_id' => (int) $s_obj->getSchedulePolicyID(), 'absence_policy_id' => (int) $s_obj->getAbsencePolicyID(), 'absence_policy' => $absence_policy_name, 'branch_id' => (int) $s_obj->getBranch(), 'branch' => Option::getByKey($s_obj->getBranch(), $branch_options, NULL), 'department_id' => (int) $s_obj->getDepartment(), 'department' => Option::getByKey($s_obj->getDepartment(), $department_options, NULL));
             $schedule_shifts_index[$iso_date_stamp][$s_obj->getColumn('user_id')][] = $s_obj->getColumn('user_id') . $s_obj->getStartTime();
             unset($absence_policy_name);
         }
         //Debug::Arr($schedule_shifts, 'Committed Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10);
         //Debug::Arr($schedule_shifts_index, 'Committed Schedule Shifts Index: ', __FILE__, __LINE__, __METHOD__, 10);
     } else {
         $schedule_shifts = array();
     }
     unset($slf);
     //Get holidays
     //FIXME: What if there are two holiday policies, one that defaults to working, and another that defaults to not working, and they are assigned
     //to two different groups of employees? For that matter what if the holiday policy isn't assigned to a specific user at all.
     $holiday_data = array();
     $hlf = new HolidayListFactory();
     $hlf->getByCompanyIdAndStartDateAndEndDate($current_user->getCompany(), $filter_data['start_date'], $filter_data['end_date']);
     Debug::text('Found Holiday Rows: ' . $hlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     foreach ($hlf as $h_obj) {
         if (is_object($h_obj->getHolidayPolicyObject()) and is_object($h_obj->getHolidayPolicyObject()->getAbsencePolicyObject())) {
             $holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => (int) $h_obj->getHolidayPolicyObject()->getDefaultScheduleStatus(), 'absence_policy_id' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyID(), 'absence_policy' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyObject()->getName());
         } else {
             $holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => 10);
             //Working
         }
     }
     unset($hlf);
     $recurring_schedule_shifts = array();
     $recurring_schedule_shifts_index = array();
     $rstlf = new RecurringScheduleTemplateListFactory();
     $rstlf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data);
     Debug::text('Found Recurring Schedule Template Rows: ' . $rstlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     if ($rstlf->getRecordCount() > 0) {
         foreach ($rstlf as $rst_obj) {
             //Debug::text('Recurring Schedule Template ID: '. $rst_obj->getID() , __FILE__, __LINE__, __METHOD__, 10);
             $rst_obj->getShifts($filter_data['start_date'], $filter_data['end_date'], $holiday_data, $branch_options, $department_options, &$schedule_shifts, &$schedule_shifts_index);
         }
     } else {
         Debug::text('DID NOT find Recurring Schedule for this time period: ', __FILE__, __LINE__, __METHOD__, 10);
     }
     //Debug::Arr($schedule_shifts, 'Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10);
     unset($schedule_shifts_index, $recurring_schedule_shifts_index);
     if (isset($schedule_shifts)) {
         return $schedule_shifts;
     }
     return FALSE;
 }
Example #4
0
     //Check to see if branch exists or not.
     if (array_search(parse_default_branch_id($mapped_row['default_branch_id']), $branch_options) === FALSE) {
         //Create branch
         $bf = new BranchFactory();
         $bf->setCompany($mapped_row['company_id']);
         $bf->setStatus(10);
         if (strtolower($filtered_import_map['default_branch_id']['parse_hint']) == 'parse_manual_id') {
             //Parse out any digits from the branch name and use them as the manual_id.
             $bf->setName($bf->Validator->stripNumeric($mapped_row['default_branch_id']));
             $bf->setManualId($bf->Validator->stripNonNumeric($mapped_row['default_branch_id']));
             $tmp_branch = $bf->getName();
         } elseif (strtolower($filtered_import_map['default_branch_id']['parse_hint']) == 'manual_id') {
             $bf->setName($mapped_row['default_branch_id']);
             $bf->setManualId($mapped_row['default_branch_id']);
         } else {
             $next_available_manual_id = BranchListFactory::getNextAvailableManualId($mapped_row['company_id']);
             $bf->setName($mapped_row['default_branch_id']);
             $bf->setManualId($next_available_manual_id);
         }
         $bf->setCity('NA');
         if ($bf->isValid()) {
             echo "[CB: " . $mapped_row['default_branch_id'] . "]";
             $new_branch_id = $bf->Save(FALSE);
             $branch_options[$new_branch_id] = $bf->getName();
             $branch_manual_id_options[$new_branch_id] = $bf->getManualId();
         }
         unset($bf, $new_branch_id, $next_available_manual_id);
     }
 }
 $uf->setDefaultBranch($tmp_branch);
 unset($tmp_branch);
Example #5
0
            foreach ($ids as $id) {
                $blf->getByIdAndCompanyId($id, $current_company->getId());
                foreach ($blf as $branch) {
                    $branch->setDeleted($delete);
                    $branch->Save();
                }
            }
        }
        Redirect::Page(URLBuilder::getURL(NULL, 'BranchList.php'));
        break;
    default:
        $sort_array = NULL;
        if ($sort_column != '') {
            $sort_array = array(Misc::trimSortPrefix($sort_column) => $sort_order);
        }
        $blf = new BranchListFactory();
        $blf->GetByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
        $pager = new Pager($blf);
        $branches = array();
        if ($blf->getRecordCount() > 0) {
            foreach ($blf as $branch) {
                $branches[] = array('id' => $branch->GetId(), 'status_id' => $branch->getStatus(), 'manual_id' => $branch->getManualID(), 'name' => $branch->getName(), 'city' => $branch->getCity(), 'province' => $branch->getProvince(), 'deleted' => $branch->getDeleted());
            }
        }
        $smarty->assign_by_ref('branches', $branches);
        $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;
}
$smarty->display('branch/BranchList.tpl');
Example #6
0
     }
     if ($branch_data['work_phone'] != '') {
         $bf->setWorkPhone($branch_data['work_phone']);
     }
     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;
Example #7
0
         	$prev_punch_obj = $plf->getCurrent();
         	$time_stamp = $prev_punch_obj->getTimeStamp()+3600;
         } else {
         	$time_stamp = $date_stamp;
         }
         */
         $ulf = new UserListFactory();
         $ulf->getByIdAndCompanyId($user_id, $current_company->getId());
         if ($ulf->getRecordCount() > 0) {
             $user_obj = $ulf->getCurrent();
             $pc_data = array('user_id' => $user_obj->getId(), 'user_full_name' => $user_obj->getFullName(), 'date_stamp' => $date_stamp, 'time_stamp' => $time_stamp, 'status_id' => $status_id, 'branch_id' => $user_obj->getDefaultBranch(), 'department_id' => $user_obj->getDefaultDepartment(), 'quantity' => 0, 'bad_quantity' => 0);
         }
         unset($time_stamp, $plf);
     }
 }
 $blf = new BranchListFactory();
 $branch_options = $blf->getByCompanyIdArray($current_company->getId());
 $dlf = new DepartmentListFactory();
 $department_options = $dlf->getByCompanyIdArray($current_company->getId());
 if ($current_company->getProductEdition() == 20) {
     $jlf = new JobListFactory();
     $jlf->getByCompanyIdAndUserIdAndStatus($current_company->getId(), $pc_data['user_id'], array(10, 20, 30, 40));
     $pc_data['job_options'] = $jlf->getArrayByListFactory($jlf, TRUE, TRUE);
     $pc_data['job_manual_id_options'] = $jlf->getManualIDArrayByListFactory($jlf, TRUE);
     $jilf = new JobItemListFactory();
     $jilf->getByCompanyId($current_company->getId());
     $pc_data['job_item_options'] = $jilf->getArrayByListFactory($jilf, TRUE, TRUE);
     $pc_data['job_item_manual_id_options'] = $jilf->getManualIdArrayByListFactory($jilf, TRUE);
 }
 //Select box options;
 $pc_data['status_options'] = $pf->getOptions('status');
 $rsclf = new RecurringScheduleControlListFactory();
 $ulf = new UserListFactory();
 if ($permission->Check('recurring_schedule', 'view') == FALSE) {
     if ($permission->Check('recurring_schedule', 'view_child')) {
         $filter_data['permission_children_ids'] = $permission_children_ids;
     }
     if ($permission->Check('recurring_schedule', 'view_own')) {
         $filter_data['permission_children_ids'][] = $current_user->getId();
     }
 }
 $rsclf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
 $pager = new Pager($rsclf);
 $utlf = new UserTitleListFactory();
 $utlf->getByCompanyId($current_company->getId());
 $title_options = $utlf->getArrayByListFactory($utlf, FALSE, TRUE);
 $blf = new BranchListFactory();
 $blf->getByCompanyId($current_company->getId());
 $branch_options = $blf->getArrayByListFactory($blf, FALSE, TRUE);
 $dlf = new DepartmentListFactory();
 $dlf->getByCompanyId($current_company->getId());
 $department_options = $dlf->getArrayByListFactory($dlf, FALSE, TRUE);
 $uglf = new UserGroupListFactory();
 $group_options = $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE));
 $rstclf = new RecurringScheduleTemplateControlListFactory();
 $template_options = $rstclf->getByCompanyIdArray($current_company->getId(), FALSE, TRUE);
 foreach ($rsclf as $rsc_obj) {
     $user_id = $rsc_obj->getColumn('user_id');
     $ulf = new UserListFactory();
     $ulf->getByID($user_id);
     if ($ulf->getRecordCount() == 1) {
         $u_obj = $ulf->getCurrent();
Example #9
0
         if (is_numeric($ulf->getCurrent()->getEmployeeNumber()) == TRUE) {
             $user_data['next_available_employee_number'] = $ulf->getCurrent()->getEmployeeNumber() + 1;
         } else {
             Debug::Text('Highest Employee Number is not an integer.', __FILE__, __LINE__, __METHOD__, 10);
             $user_data['next_available_employee_number'] = NULL;
         }
     } else {
         $user_data['next_available_employee_number'] = 1;
     }
     if (!isset($user_data['hire_date']) or $user_data['hire_date'] == '') {
         $user_data['hire_date'] = time();
     }
 }
 //var_dump($user_data);
 //Select box options;
 $blf = new BranchListFactory();
 $branch_options = $blf->getByCompanyIdArray($company_id);
 $dlf = new DepartmentListFactory();
 $department_options = $dlf->getByCompanyIdArray($company_id);
 $culf = new CurrencyListFactory();
 $culf->getByCompanyId($company_id);
 $currency_options = $culf->getArrayByListFactory($culf, FALSE, TRUE);
 $hotf = new HierarchyObjectTypeFactory();
 $hierarchy_object_type_options = $hotf->getOptions('object_type');
 $hclf = new HierarchyControlListFactory();
 $hclf->getObjectTypeAppendedListByCompanyID($company_id);
 $hierarchy_control_options = $hclf->getArrayByListFactory($hclf, TRUE, TRUE);
 //Select box options;
 $user_data['branch_options'] = $branch_options;
 $user_data['department_options'] = $department_options;
 $user_data['currency_options'] = $currency_options;
 function preSave()
 {
     if ($this->getStatus() == FALSE) {
         $this->setStatus(10);
     }
     if ($this->getManualID() == FALSE) {
         $this->setManualID(BranchListFactory::getNextAvailableManualId($this->getCompany()));
     }
     return TRUE;
 }
 function setBranch($ids)
 {
     Debug::text('Setting IDs...', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($ids, 'Setting Branch IDs...', __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($ids)) {
         $tmp_ids = array();
         if (!$this->isNew()) {
             //If needed, delete mappings first.
             $lf_a = new PremiumPolicyBranchListFactory();
             $lf_a->getByPremiumPolicyId($this->getId());
             foreach ($lf_a as $obj) {
                 $id = $obj->getBranch();
                 Debug::text('Branch ID: ' . $obj->getBranch() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                 //Delete users that are not selected.
                 if (!in_array($id, $ids)) {
                     Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $obj->Delete();
                 } else {
                     //Save ID's that need to be updated.
                     Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $tmp_ids[] = $id;
                 }
             }
             unset($id, $obj);
         }
         //Insert new mappings.
         $lf_b = new BranchListFactory();
         foreach ($ids as $id) {
             if (isset($ids) and $id > 0 and !in_array($id, $tmp_ids)) {
                 $f = new PremiumPolicyBranchFactory();
                 $f->setPremiumPolicy($this->getId());
                 $f->setBranch($id);
                 $obj = $lf_b->getById($id)->getCurrent();
                 if ($this->Validator->isTrue('branch', $f->Validator->isValid(), TTi18n::gettext('Selected Branch is invalid') . ' (' . $obj->getName() . ')')) {
                     $f->save();
                 }
             }
         }
         return TRUE;
     }
     Debug::text('No IDs to set.', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
Example #12
0
            $df->Save(FALSE);
            if (isset($department_data['branch_list'])) {
                $df->setBranch($department_data['branch_list']);
                $df->Save(TRUE);
            }
            Redirect::Page(URLBuilder::getURL(NULL, 'DepartmentList.php'));
            break;
        }
    default:
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $dlf = new DepartmentListFactory();
            $dlf->GetByIdAndCompanyId($id, $current_company->getId());
            foreach ($dlf as $department) {
                Debug::Arr($department, 'Department', __FILE__, __LINE__, __METHOD__, 10);
                $department_data = array('id' => $department->getId(), 'company_name' => $current_company->getName(), 'status' => $department->getStatus(), 'name' => $department->getName(), 'manual_id' => $department->getManualID(), 'branch_list' => $department->getBranch(), 'created_date' => $department->getCreatedDate(), 'created_by' => $department->getCreatedBy(), 'updated_date' => $department->getUpdatedDate(), 'updated_by' => $department->getUpdatedBy(), 'deleted_date' => $department->getDeletedDate(), 'deleted_by' => $department->getDeletedBy());
            }
        } elseif ($action != 'submit') {
            $next_available_manual_id = DepartmentListFactory::getNextAvailableManualId($current_company->getId());
            $department_data = array('next_available_manual_id' => $next_available_manual_id);
        }
        //Select box options;
        $department_data['status_options'] = $df->getOptions('status');
        $blf = new BranchListFactory();
        $blf->getByCompanyId($current_company->getId());
        $department_data['branch_list_options'] = $blf->getArrayByListFactory($blf, FALSE);
        $smarty->assign_by_ref('department_data', $department_data);
        break;
}
$smarty->assign_by_ref('df', $df);
$smarty->display('department/EditDepartment.tpl');
Example #13
0
        }
        if ($bf->isValid()) {
            $bf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'BranchList.php'));
            break;
        }
    default:
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $blf = TTnew('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(), 'other_id1' => $branch->getOtherID1(), 'other_id2' => $branch->getOtherID2(), 'other_id3' => $branch->getOtherID3(), 'other_id4' => $branch->getOtherID4(), 'other_id5' => $branch->getOtherID5(), '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 = TTnew('CompanyFactory');
        $branch_data['country_options'] = $cf->getOptions('country');
        $branch_data['province_options'] = $cf->getOptions('province', $branch_data['country']);
        //Get other field names
        $oflf = TTnew('OtherFieldListFactory');
        $branch_data['other_field_names'] = $oflf->getByCompanyIdAndTypeIdArray($current_company->getID(), 4);
        $smarty->assign_by_ref('branch_data', $branch_data);
        break;
}
$smarty->assign_by_ref('bf', $bf);
$smarty->display('branch/EditBranch.tpl');
Example #14
0
 echo "  Importing Punch: {$i}. " . str_pad($user_identifer, 30, '.', STR_PAD_RIGHT) . "... ";
 $ulf = new UserListFactory();
 if (isset($mapped_row['user_id']) and $mapped_row['user_id'] != '') {
     $ulf->getById($mapped_row['user_id']);
 } elseif (isset($mapped_row['employee_number']) and $mapped_row['employee_number'] != '' and isset($mapped_row['company_id']) and $mapped_row['company_id'] != '') {
     $ulf->getByCompanyIDAndEmployeeNumber($mapped_row['company_id'], $mapped_row['employee_number']);
 } elseif (isset($mapped_row['user_name']) and $mapped_row['user_name'] != '') {
     $ulf->getByUserName($mapped_row['user_name']);
 }
 if ($ulf->getRecordCount() == 1) {
     $u_obj = $ulf->getCurrent();
     //Set user timezone before parsing.
     $u_obj->getUserPreferenceObject()->setDateTimePreferences();
     if (!isset($branch_options)) {
         //Get all branches
         $blf = new BranchListFactory();
         $blf->getByCompanyId($u_obj->getCompany());
         $branch_options = $blf->getArrayByListFactory($blf, FALSE, TRUE);
         unset($blf);
     }
     if (!isset($department_options)) {
         //Get departments
         $dlf = new DepartmentListFactory();
         $dlf->getByCompanyId($u_obj->getCompany());
         $department_options = $dlf->getArrayByListFactory($dlf, FALSE, TRUE);
         unset($dlf);
     }
     if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL and !isset($job_options)) {
         //Get jobs
         $jlf = new JobListFactory();
         $jlf->getByCompanyId($u_obj->getCompany());
 function setBranch($id)
 {
     $id = trim($id);
     if ($id == FALSE or $id == 0 or $id == '') {
         $id = 0;
     }
     $blf = new BranchListFactory();
     if ($id == 0 or $this->Validator->isResultSetWithRows('branch', $blf->getByID($id), TTi18n::gettext('Branch does not exist'))) {
         $this->data['branch_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
                Debug::Text('DepartmentBranchId: ' . $branch_id, __FILE__, __LINE__, __METHOD__, 10);
                if (isset($id)) {
                    //Get User ID's from database.
                    $dbulf = TTnew('DepartmentBranchUserListFactory');
                    $dbulf->getByDepartmentBranchId($department_branch->getId());
                    $department_branch_user_ids = array();
                    foreach ($dbulf as $department_branch_user) {
                        $department_branch_user_ids[] = $department_branch_user->getUser();
                        Debug::Text('DepartmentBranchUser: '******'s.
                    $department_branch_user_ids = $department_data['branch_data'][$branch_id];
                }
                $blf = TTnew('BranchListFactory');
                $blf->getById($branch_id);
                $branch = $blf->getIterator()->current();
                $branch_data[$branch_id] = array('id' => $branch->getId(), 'name' => $branch->getName(), 'user_ids' => $department_branch_user_ids);
            }
            $department_data = array('id' => $department->getId(), 'company_name' => $current_company->getName(), 'status' => $department->getStatus(), 'name' => $department->getName(), 'branch_list' => $department->getBranch(), 'branch_data' => $branch_data, 'created_date' => $department->getCreatedDate(), 'created_by' => $department->getCreatedBy(), 'updated_date' => $department->getUpdatedDate(), 'updated_by' => $department->getUpdatedBy(), 'deleted_date' => $department->getDeletedDate(), 'deleted_by' => $department->getDeletedBy());
        }
        //Select box options;
        $department_data['branch_list_options'] = BranchListFactory::getByCompanyIdArray($current_company->getId());
        //$ulf = new UserListFactory;
        $department_data['user_options'] = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE);
        //var_dump($te);
        $smarty->assign_by_ref('department_data', $department_data);
        break;
}
$smarty->assign_by_ref('dbuf', $dbuf);
$smarty->display('department/EditDepartmentBranchUser.tpl');
 function setDefaultBranch($id)
 {
     $id = trim($id);
     Debug::Text('Branch ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     $blf = new BranchListFactory();
     if ($id == 0 or $this->Validator->isResultSetWithRows('default_branch', $blf->getByID($id), TTi18n::gettext('Invalid Default Branch'))) {
         $this->data['default_branch_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
                $branch_id = $department_branch->getBranch();
                Debug::Text('DepartmentBranchId: ' . $branch_id, __FILE__, __LINE__, __METHOD__, 10);
                if (isset($id)) {
                    //Get User ID's from database.
                    $dbulf = new DepartmentBranchUserListFactory();
                    $dbulf->getByDepartmentBranchId($department_branch->getId());
                    $department_branch_user_ids = array();
                    foreach ($dbulf as $department_branch_user) {
                        $department_branch_user_ids[] = $department_branch_user->getUser();
                        Debug::Text('DepartmentBranchUser: '******'s.
                    $department_branch_user_ids = $department_data['branch_data'][$branch_id];
                }
                $blf = new BranchListFactory();
                $blf->getById($branch_id);
                $branch = $blf->getIterator()->current();
                $branch_data[$branch_id] = array('id' => $branch->getId(), 'name' => $branch->getName(), 'user_ids' => $department_branch_user_ids);
            }
            $department_data = array('id' => $department->getId(), 'company_name' => $current_company->getName(), 'status' => $department->getStatus(), 'name' => $department->getName(), 'branch_list' => $department->getBranch(), 'branch_data' => $branch_data, 'created_date' => $department->getCreatedDate(), 'created_by' => $department->getCreatedBy(), 'updated_date' => $department->getUpdatedDate(), 'updated_by' => $department->getUpdatedBy(), 'deleted_date' => $department->getDeletedDate(), 'deleted_by' => $department->getDeletedBy());
        }
        //Select box options;
        $department_data['branch_list_options'] = BranchListFactory::getByCompanyIdArray($current_company->getId());
        //$ulf = new UserListFactory;
        $department_data['user_options'] = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE);
        //var_dump($te);
        $smarty->assign_by_ref('department_data', $department_data);
        break;
}
$smarty->assign_by_ref('dbuf', $dbuf);
 static function getByCompanyIdArray($company_id, $include_blank = TRUE, $include_disabled = TRUE)
 {
     $blf = new BranchListFactory();
     $blf->getByCompanyId($company_id);
     return $blf->getArrayByListFactory($blf, $include_blank, $include_disabled);
 }
 function getByCompanyIdArray($company_id)
 {
     if ($company_id == '') {
         return FALSE;
     }
     $blf = new BranchListFactory();
     $blf->getByCompanyId($company_id);
     $branch_list[0] = '--';
     foreach ($blf as $branch) {
         $branch_list[$branch->getID()] = $branch->getName();
     }
     return $branch_list;
 }
Example #21
0
 $filter_data['selected_include_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['include_user_ids'], $user_options);
 //Get exclude employee list
 $exclude_user_options = Misc::prependArray($all_array_option, $ulf->getArrayByListFactory($ulf, FALSE, TRUE));
 $filter_data['src_exclude_user_options'] = Misc::arrayDiffByKey((array) $filter_data['exclude_user_ids'], $user_options);
 $filter_data['selected_exclude_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['exclude_user_ids'], $user_options);
 //Get employee status list.
 $user_status_options = Misc::prependArray($all_array_option, $ulf->getOptions('status'));
 $filter_data['src_user_status_options'] = Misc::arrayDiffByKey((array) $filter_data['user_status_ids'], $user_status_options);
 $filter_data['selected_user_status_options'] = Misc::arrayIntersectByKey((array) $filter_data['user_status_ids'], $user_status_options);
 //Get Employee Groups
 $uglf = new UserGroupListFactory();
 $group_options = Misc::prependArray($all_array_option, $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE)));
 $filter_data['src_group_options'] = Misc::arrayDiffByKey((array) $filter_data['group_ids'], $group_options);
 $filter_data['selected_group_options'] = Misc::arrayIntersectByKey((array) $filter_data['group_ids'], $group_options);
 //Get branches
 $blf = new BranchListFactory();
 $blf->getByCompanyId($current_company->getId());
 $branch_options = Misc::prependArray($all_array_option, $blf->getArrayByListFactory($blf, FALSE, TRUE));
 $filter_data['src_branch_options'] = Misc::arrayDiffByKey((array) $filter_data['branch_ids'], $branch_options);
 $filter_data['selected_branch_options'] = Misc::arrayIntersectByKey((array) $filter_data['branch_ids'], $branch_options);
 //Get departments
 $dlf = new DepartmentListFactory();
 $dlf->getByCompanyId($current_company->getId());
 $department_options = Misc::prependArray($all_array_option, $dlf->getArrayByListFactory($dlf, FALSE, TRUE));
 $filter_data['src_department_options'] = Misc::arrayDiffByKey((array) $filter_data['department_ids'], $department_options);
 $filter_data['selected_department_options'] = Misc::arrayIntersectByKey((array) $filter_data['department_ids'], $department_options);
 //Get employee titles
 $utlf = new UserTitleListFactory();
 $utlf->getByCompanyId($current_company->getId());
 $user_title_options = Misc::prependArray($all_array_option, $utlf->getArrayByListFactory($utlf, FALSE, TRUE));
 $filter_data['src_user_title_options'] = Misc::arrayDiffByKey((array) $filter_data['user_title_ids'], $user_title_options);
 function getPunchData()
 {
     if ($this->StationCheckAllowed() !== TRUE) {
         Debug::text('Station NOT allowed: ', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $epoch = TTDate::getTime();
     $slf = new ScheduleListFactory();
     //Get last punch for this day, for this user.
     $plf = new PunchListFactory();
     $plf->getPreviousPunchByUserIDAndEpoch($this->getUserObject()->getId(), $epoch);
     if ($plf->getRecordCount() > 0) {
         $prev_punch_obj = $plf->getCurrent();
         Debug::Text(' Found Previous Punch within Continuous Time from now, ID: ' . $prev_punch_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
         $branch_id = $prev_punch_obj->getPunchControlObject()->getBranch();
         $department_id = $prev_punch_obj->getPunchControlObject()->getDepartment();
         $job_id = $prev_punch_obj->getPunchControlObject()->getJob();
         $job_item_id = $prev_punch_obj->getPunchControlObject()->getJobItem();
         //Don't enable transfer by default if the previous punch was any OUT punch.
         //Transfer does the OUT punch for them, so if the previous punch is an OUT punch
         //we don't gain anything anyways.
         if ($this->getPermissionObject()->Check('punch', 'default_transfer') and $prev_punch_obj->getStatus() == 10) {
             $transfer = TRUE;
         } else {
             $transfer = FALSE;
         }
         if ($branch_id == '' or empty($branch_id) or $department_id == '' or empty($department_id) or $job_id == '' or empty($job_id) or $job_item_id == '' or empty($job_item_id)) {
             Debug::Text(' Branch or department are null. ', __FILE__, __LINE__, __METHOD__, 10);
             $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($this->getUserObject()->getId(), $epoch);
             if (is_object($s_obj)) {
                 Debug::Text(' Found Schedule!: ', __FILE__, __LINE__, __METHOD__, 10);
                 if ($branch_id == '' or empty($branch_id)) {
                     Debug::Text(' overrriding branch: ' . $s_obj->getBranch(), __FILE__, __LINE__, __METHOD__, 10);
                     $branch_id = $s_obj->getBranch();
                 }
                 if ($department_id == '' or empty($department_id)) {
                     Debug::Text(' overrriding department: ' . $s_obj->getDepartment(), __FILE__, __LINE__, __METHOD__, 10);
                     $department_id = $s_obj->getDepartment();
                 }
                 if ($job_id == '' or empty($job_id)) {
                     Debug::Text(' overrriding job: ' . $s_obj->getJob(), __FILE__, __LINE__, __METHOD__, 10);
                     $job_id = $s_obj->getJob();
                 }
                 if ($job_item_id == '' or empty($job_item_id)) {
                     Debug::Text(' overrriding job item: ' . $s_obj->getJobItem(), __FILE__, __LINE__, __METHOD__, 10);
                     $job_item_id = $s_obj->getJobItem();
                 }
             }
         }
         $next_type = $prev_punch_obj->getNextType();
         //Check for break policy window.
         if ($next_type != 30 and ($prev_punch_obj->getStatus() != 30 and $prev_punch_obj->getType() != 30)) {
             $prev_punch_obj->setUser($this->getUserObject()->getId());
             $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($epoch));
             if ($prev_punch_obj->inBreakPolicyWindow($epoch, $prev_punch_obj->getTimeStamp()) == TRUE) {
                 Debug::Text(' Setting Type to Break: ', __FILE__, __LINE__, __METHOD__, 10);
                 $next_type = 30;
             }
         }
         //Check for meal policy window.
         if ($next_type != 20 and ($prev_punch_obj->getStatus() != 20 and $prev_punch_obj->getType() != 20)) {
             $prev_punch_obj->setUser($this->getUserObject()->getId());
             $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($epoch));
             if ($prev_punch_obj->inMealPolicyWindow($epoch, $prev_punch_obj->getTimeStamp()) == TRUE) {
                 Debug::Text(' Setting Type to Lunch: ', __FILE__, __LINE__, __METHOD__, 10);
                 $next_type = 20;
             }
         }
         Debug::Text(' cJob Item ID: ' . $job_item_id, __FILE__, __LINE__, __METHOD__, 10);
         $note = '';
         if ((int) $prev_punch_obj->getNextStatus() == 20) {
             $note = $prev_punch_obj->getPunchControlObject()->getNote();
         }
         $data = array('user_id' => (int) $this->getUserObject()->getId(), 'user_full_name' => $this->getUserObject()->getFullName(), 'time_stamp' => TTDate::getDate('TIME', $epoch), 'date_stamp' => TTDate::getDate('DATE', $epoch), 'full_time_stamp' => $epoch, 'iso_time_stamp' => TTDate::getDBTimeStamp($epoch, FALSE), 'transfer' => $transfer, 'branch_id' => (int) $branch_id, 'department_id' => (int) $department_id, 'job_id' => $job_id, 'job_item_id' => $job_item_id, 'quantity' => $prev_punch_obj->getPunchControlObject()->getQuantity(), 'bad_quantity' => $prev_punch_obj->getPunchControlObject()->getBadQuantity(), 'note' => (string) $note, 'other_id1' => $prev_punch_obj->getPunchControlObject()->getOtherID1(), 'other_id2' => $prev_punch_obj->getPunchControlObject()->getOtherID2(), 'other_id3' => $prev_punch_obj->getPunchControlObject()->getOtherID3(), 'other_id4' => $prev_punch_obj->getPunchControlObject()->getOtherID4(), 'other_id5' => $prev_punch_obj->getPunchControlObject()->getOtherID5(), 'status_id' => (int) $prev_punch_obj->getNextStatus(), 'type_id' => (int) $next_type, 'punch_control_id' => (int) $prev_punch_obj->getNextPunchControlID());
         unset($note);
     } else {
         Debug::Text(' DID NOT Find Previous Punch within Continuous Time from now: ', __FILE__, __LINE__, __METHOD__, 10);
         //These used to be NULLs, but as of TT v3.0 they cause deserilizer errors with a Java client.
         $branch_id = '';
         $department_id = '';
         $job_id = '';
         $job_item_id = '';
         $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($this->getUserObject()->getId(), $epoch);
         if (is_object($s_obj)) {
             Debug::Text(' Found Schedule! ID:' . $s_obj->getID() . ' Job ID: ' . $s_obj->getJob(), __FILE__, __LINE__, __METHOD__, 10);
             $branch_id = $s_obj->getBranch();
             $department_id = $s_obj->getDepartment();
             $job_id = $s_obj->getJob();
             $job_item_id = $s_obj->getJobItem();
         } else {
             //Check for defaults
             $branch_id = $this->getUserObject()->getDefaultBranch();
             $department_id = $this->getUserObject()->getDefaultDepartment();
             //Check station for default/forced settings.
             if (is_object($this->getStationObject())) {
                 if ($this->getStationObject()->getDefaultBranch() !== FALSE and $this->getStationObject()->getDefaultBranch() != 0) {
                     $branch_id = $this->getStationObject()->getDefaultBranch();
                 }
                 if ($this->getStationObject()->getDefaultDepartment() !== FALSE and $this->getStationObject()->getDefaultDepartment() != 0) {
                     $department_id = $this->getStationObject()->getDefaultDepartment();
                 }
                 if ($this->getStationObject()->getDefaultJob() !== FALSE and $this->getStationObject()->getDefaultJob() != 0) {
                     $job_id = $this->getStationObject()->getDefaultJob();
                 }
                 if ($this->getStationObject()->getDefaultJobItem() !== FALSE and $this->getStationObject()->getDefaultJobItem() != 0) {
                     $job_item_id = $this->getStationObject()->getDefaultJobItem();
                 }
             }
         }
         $data = array('user_id' => (int) $this->getUserObject()->getId(), 'user_full_name' => $this->getUserObject()->getFullName(), 'time_stamp' => TTDate::getDate('TIME', $epoch), 'date_stamp' => TTDate::getDate('DATE', $epoch), 'full_time_stamp' => $epoch, 'iso_time_stamp' => TTDate::getDBTimeStamp($epoch, FALSE), 'transfer' => FALSE, 'branch_id' => (int) $branch_id, 'department_id' => (int) $department_id, 'job_id' => $job_id, 'job_item_id' => $job_item_id, 'status_id' => 10, 'type_id' => 10);
     }
     //Get options.
     $blf = new BranchListFactory();
     $blf->getByCompanyId($this->getCompanyObject()->getId());
     $branch_options = $blf->getArrayByListFactory($blf, TRUE, FALSE);
     $dlf = new DepartmentListFactory();
     $dlf->getByCompanyId($this->getCompanyObject()->getId());
     $department_options = $dlf->getArrayByListFactory($dlf, TRUE, FALSE);
     $job_options = array();
     $job_item_options = array();
     if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL) {
         $jlf = new JobListFactory();
         $job_options = $jlf->getByCompanyIdAndUserIdAndStatusArray($this->getCompanyObject()->getId(), $this->getUserObject()->getId(), array(10), TRUE);
         $jilf = new JobItemListFactory();
         $job_item_options = $jilf->getByCompanyIdArray($this->getCompanyObject()->getId(), TRUE);
     }
     $pf = new PunchFactory();
     //Select box options;
     $data['status_options'] = $pf->getOptions('status');
     $data['type_options'] = $pf->getOptions('type');
     $data['branch_options'] = $branch_options;
     $data['department_options'] = $department_options;
     $data['job_options'] = $job_options;
     $data['job_item_options'] = $job_item_options;
     //Hack for PHP v5.0.4 shotty SOAP.
     //If it can cast the first array key to a INT, it rekeys the entire array.
     //02-Nov-09: Using NULL values causes the Java client to throw a deserlizer error. Using '' causes blank entries.
     /*
     $data['status_options'] = Misc::prependArray( array('_' => FALSE ), $data['status_options'] );
     $data['type_options'] = Misc::prependArray( array('_' => FALSE ), $data['type_options'] );
     $data['branch_options'] = Misc::prependArray( array('_' => FALSE ), $data['branch_options'] );
     $data['department_options'] = Misc::prependArray( array('_' => FALSE ), $data['department_options'] );
     $data['job_options'] = Misc::prependArray( array('_' => FALSE ), $data['job_options'] );
     $data['job_item_options'] = Misc::prependArray( array('_' => FALSE ), $data['job_item_options'] );
     */
     $data['timeout'] = 5;
     $data['date_format_example'] = (string) $this->getUserObject()->getUserPreferenceObject()->getDateFormatExample();
     $data['time_format_example'] = (string) $this->getUserObject()->getUserPreferenceObject()->getTimeFormatExample();
     //Debug::Arr($data, 'punchDataArray', __FILE__, __LINE__, __METHOD__,10);
     if (!$this->getPermissionObject()->Check('job', 'enabled')) {
         unset($data['job_options']);
         unset($data['job_item_options']);
     }
     //Debug::Arr($data, 'Return Data: ', __FILE__, __LINE__, __METHOD__,10);
     return $data;
 }
 function getBranches($station_id)
 {
     Debug::Text('Getting Branches for Station ID: ' . $station_id, __FILE__, __LINE__, __METHOD__, 10);
     if ($station_id == '') {
         return FALSE;
     }
     //Gets all users allowed to punch in/out from this station
     $slf = new StationListFactory();
     $slf->getByStationID($station_id);
     if ($slf->getRecordCount() > 0) {
         $s_obj = $slf->getCurrent();
         $company_id = $s_obj->getCompany();
         if ($company_id != FALSE) {
             $blf = new BranchListFactory();
             $blf->getByCompanyIdAndStatus($company_id, 10);
             if ($blf->getRecordCount() > 0) {
                 $x = 0;
                 foreach ($blf as $b_obj) {
                     $branch_list["'{$x}'"] = array('id' => (int) $b_obj->getId(), 'manual_id' => (int) $b_obj->getManualID(), 'name' => $b_obj->getName());
                     $x++;
                 }
                 if (isset($branch_list)) {
                     return $branch_list;
                 }
             }
         }
     }
     return FALSE;
 }
 */
extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'pay_period_id')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('pay_period_id' => $pay_period_id, 'sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page));
switch ($action) {
    case 'Submit':
    default:
        $pplf = new PayPeriodListFactory();
        $slf = new ShiftListFactory();
        if (!isset($pay_period_id)) {
            Debug::text(' Pay Period ID NOT SET: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10);
            $pay_period_id = $pplf->getByCompanyId($current_company->getId(), 1, 2, NULL, array('start_date' => 'desc'))->getCurrent()->getId();
        }
        Debug::text(' Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10);
        $psenlf = new PayStubEntryNameListFactory();
        $ulf = new UserListFactory();
        $blf = new BranchListFactory();
        //Get all pay stubs for this pay period
        $pslf = new PayStubListFactory();
        $pslf->getByPayPeriodId($pay_period_id, NULL, array('advance' => '= \'f\''));
        $pager = new Pager($pslf);
        $entry_name_ids = array(10, 22);
        foreach ($pslf as $pay_stub_obj) {
            Debug::text(' Pay Stub ID: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
            $pself = new PayStubEntryListFactory();
            //Order is very important here. We want the "last" entries to go last, as they should
            //have the most up to date YTD values.
            $pself->getByPayStubId($pay_stub_obj->getId());
            $entries = NULL;
            foreach ($pself as $pay_stub_entry_obj) {
                $pay_stub_entry_name_obj = $psenlf->getById($pay_stub_entry_obj->getPayStubEntryNameId())->getCurrent();
                if (in_array($pay_stub_entry_obj->getPayStubEntryNameId(), $entry_name_ids)) {