function setDepartment($id)
 {
     $id = trim($id);
     $dlf = new DepartmentListFactory();
     if ($id != 0 or $this->Validator->isResultSetWithRows('company', $dlf->getByID($id), TTi18n::gettext('Company is invalid'))) {
         $this->data['department_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
 /**
  * Get default department data for creating new departmentes.
  * @return array
  */
 function getDepartmentDefaultData()
 {
     $company_obj = $this->getCurrentCompanyObject();
     Debug::Text('Getting department default data...', __FILE__, __LINE__, __METHOD__, 10);
     $next_available_manual_id = DepartmentListFactory::getNextAvailableManualId($company_obj->getId());
     $data = array('company_id' => $company_obj->getId(), 'status_id' => 10, 'manual_id' => $next_available_manual_id);
     Debug::Arr($data, 'Getting department default data...', __FILE__, __LINE__, __METHOD__, 10);
     return $this->returnHandler($data);
 }
Beispiel #3
0
                $df->Save(TRUE);
            }
            Redirect::Page(URLBuilder::getURL(NULL, 'DepartmentList.php'));
            break;
        }
    default:
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $dlf = TTnew('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(), 'other_id1' => $department->getOtherID1(), 'other_id2' => $department->getOtherID2(), 'other_id3' => $department->getOtherID3(), 'other_id4' => $department->getOtherID4(), 'other_id5' => $department->getOtherID5(), '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 = TTnew('BranchListFactory');
        $blf->getByCompanyId($current_company->getId());
        $department_data['branch_list_options'] = $blf->getArrayByListFactory($blf, FALSE);
        //Get other field names
        $oflf = TTnew('OtherFieldListFactory');
        $department_data['other_field_names'] = $oflf->getByCompanyIdAndTypeIdArray($current_company->getID(), 5);
        $smarty->assign_by_ref('department_data', $department_data);
        break;
}
$smarty->assign_by_ref('df', $df);
$smarty->display('department/EditDepartment.tpl');
 function setDefaultDepartment($id)
 {
     $id = trim($id);
     Debug::Text('Department ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     $dlf = new DepartmentListFactory();
     if ($id == 0 or $this->Validator->isResultSetWithRows('default_department', $dlf->getByID($id), TTi18n::gettext('Invalid Default Department'))) {
         $this->data['default_department_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
 function setDepartment($ids)
 {
     Debug::text('Setting IDs...', __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($ids)) {
         $tmp_ids = array();
         if (!$this->isNew()) {
             //If needed, delete mappings first.
             $lf_a = new PremiumPolicyDepartmentListFactory();
             $lf_a->getByPremiumPolicyId($this->getId());
             foreach ($lf_a as $obj) {
                 $id = $obj->getDepartment();
                 Debug::text('Department ID: ' . $obj->getDepartment() . ' 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 DepartmentListFactory();
         foreach ($ids as $id) {
             if (isset($ids) and $id > 0 and !in_array($id, $tmp_ids)) {
                 $f = new PremiumPolicyDepartmentFactory();
                 $f->setPremiumPolicy($this->getId());
                 $f->setDepartment($id);
                 $obj = $lf_b->getById($id)->getCurrent();
                 if ($this->Validator->isTrue('department', $f->Validator->isValid(), TTi18n::gettext('Selected Department is invalid') . ' (' . $obj->getName() . ')')) {
                     $f->save();
                 }
             }
         }
         return TRUE;
     }
     Debug::text('No IDs to set.', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
 function setDepartment($id)
 {
     $id = trim($id);
     if ($id == FALSE or $id == 0 or $id == '') {
         $id = 0;
     }
     $dlf = new DepartmentListFactory();
     if ($id == 0 or $this->Validator->isResultSetWithRows('department', $dlf->getByID($id), TTi18n::gettext('Department does not exist'))) {
         $this->data['department_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
 function getByCompanyIdArray($company_id, $include_blank = TRUE, $include_disabled = TRUE)
 {
     $dlf = new DepartmentListFactory();
     $dlf->getByCompanyId($company_id);
     return $dlf->getArrayByListFactory($dlf, $include_blank, $include_disabled);
 }
Beispiel #8
0
 $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);
 $filter_data['selected_user_title_options'] = Misc::arrayIntersectByKey((array) $filter_data['user_title_ids'], $user_title_options);
 //Deduction PSEA accounts
 $psealf = new PayStubEntryAccountListFactory();
 $filter_data['deduction_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(20, 30, 40), TRUE);
 $filter_data['earning_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 40), TRUE);
 $filter_data['income_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 30, 40), TRUE);
        $dlf = new DepartmentListFactory();
        foreach ($ids as $id) {
            $dlf->GetByIdAndCompanyId($id, $current_company->getId());
            foreach ($dlf as $department) {
                $department->setDeleted($delete);
                $department->Save();
            }
        }
        Redirect::Page(URLBuilder::getURL(NULL, 'DepartmentList.php'));
        break;
    default:
        $sort_array = NULL;
        if ($sort_column != '') {
            $sort_array = array(Misc::trimSortPrefix($sort_column) => $sort_order);
        }
        $dlf = new DepartmentListFactory();
        $dlf->GetByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
        $pager = new Pager($dlf);
        $departments = array();
        if ($dlf->getRecordCount() > 0) {
            foreach ($dlf as $department) {
                $departments[] = array('id' => $department->GetId(), 'status_id' => $department->getStatus(), 'manual_id' => $department->getManualID(), 'name' => $department->getName(), 'deleted' => $department->getDeleted());
            }
        }
        $smarty->assign_by_ref('departments', $departments);
        $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('department/DepartmentList.tpl');
 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;
 }
                 Debug::Text('Mapping User: '******' To DepartmentBranchID: ' . $department_branch_id, __FILE__, __LINE__, __METHOD__, 10);
                 $dbuf->setDepartmentBranch($department_branch_id);
                 $dbuf->setUser($user_id);
                 if ($dbuf->isValid()) {
                     $dbuf->Save();
                 }
             }
         }
     }
     if ($dbuf->isValid()) {
         Redirect::Page(URLBuilder::getURL(NULL, 'DepartmentList.php'));
         break;
     }
 default:
     BreadCrumb::setCrumb($title);
     $dlf = new DepartmentListFactory();
     $dlf->GetByIdAndCompanyId($id, $current_company->getId());
     foreach ($dlf as $department) {
         //Debug::Arr($department,'Department', __FILE__, __LINE__, __METHOD__,10);
         $branch_data = array();
         $dblf = new DepartmentBranchListFactory();
         $dblf->getByDepartmentId($department->getId());
         foreach ($dblf as $department_branch) {
             $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) {
 function preSave()
 {
     if ($this->getStatus() == FALSE) {
         $this->setStatus(10);
     }
     if ($this->getManualID() == FALSE) {
         $this->setManualID(DepartmentListFactory::getNextAvailableManualId($this->getCompany()));
     }
     return TRUE;
 }
Beispiel #13
0
         } 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;
 $user_data['sex_options'] = $uf->getOptions('sex');
 $user_data['status_options'] = $uf->getOptions('status');
     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();
     } else {
         //Skip this row.
         Debug::Text('Skipping Row: User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
Beispiel #15
0
         //Check to see if department exists or not.
         if (array_search(parse_default_department_id($mapped_row['default_department_id']), $department_options) === FALSE) {
             //Create department
             $df = new DepartmentFactory();
             $df->setCompany($mapped_row['company_id']);
             $df->setStatus(10);
             if (strtolower($filtered_import_map['default_department_id']['parse_hint']) == 'parse_manual_id') {
                 //Parse out any digits from the department name and use them as the manual_id.
                 $df->setName($df->Validator->stripNumeric($mapped_row['default_department_id']));
                 $df->setManualId($df->Validator->stripNonNumeric($mapped_row['default_department_id']));
                 $tmp_department = $df->getName();
             } elseif (strtolower($filtered_import_map['default_department_id']['parse_hint']) == 'manual_id') {
                 $df->setName($mapped_row['default_department_id']);
                 $df->setManualId($mapped_row['default_department_id']);
             } else {
                 $next_available_manual_id = DepartmentListFactory::getNextAvailableManualId($mapped_row['company_id']);
                 $df->setName($mapped_row['default_department_id']);
                 $df->setManualId($next_available_manual_id);
             }
             if ($df->isValid()) {
                 echo "[CD: " . $mapped_row['default_department_id'] . "]";
                 $new_department_id = $df->Save(FALSE);
                 $department_options[$new_department_id] = $df->getName();
                 $department_manual_id_options[$new_department_id] = $df->getManualId();
             }
             unset($df, $new_department_id, $next_available_manual_id);
         }
     }
     $uf->setDefaultDepartment($tmp_department);
     unset($tmp_department);
 }
Beispiel #16
0
         } 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');
 $pc_data['type_options'] = $pf->getOptions('type');
 $pc_data['branch_options'] = $branch_options;
 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;
 }
 function getDepartments($station_id)
 {
     Debug::Text('Getting Departments 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) {
             $dlf = new DepartmentListFactory();
             $dlf->getByCompanyIdAndStatus($company_id, 10);
             if ($dlf->getRecordCount() > 0) {
                 $x = 0;
                 foreach ($dlf as $d_obj) {
                     $department_list["'{$x}'"] = array('id' => (int) $d_obj->getId(), 'manual_id' => (int) $d_obj->getManualID(), 'name' => $d_obj->getName());
                     $x++;
                 }
                 if (isset($department_list)) {
                     return $department_list;
                 }
             }
         }
     }
     return FALSE;
 }
     $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());
         $job_options = $jlf->getArrayByListFactory($jlf, FALSE, TRUE);
         unset($jlf);
     }
     if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL and !isset($job_item_options)) {
         //Get tasks
         $jilf = new JobItemListFactory();
         $jilf->getByCompanyId($u_obj->getCompany());