Esempio n. 1
0
 $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);
 $filter_data['selected_user_title_options'] = Misc::arrayIntersectByKey((array) $filter_data['user_title_ids'], $user_title_options);
 //Deduction PSEA accounts
 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);
 }
 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();
     } else {
         //Skip this row.
 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;
 }
Esempio n. 5
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');
                     $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);
 }
 //var_dump($week_rows);
 $smarty->assign_by_ref('data', $data);
 $smarty->assign_by_ref('week_rows', $week_rows);
 break;