コード例 #1
0
 function setStation($id)
 {
     $id = trim($id);
     $slf = new StationListFactory();
     if ($id != 0 or $this->Validator->isResultSetWithRows('station', $slf->getByID($id), TTi18n::gettext('Station is invalid'))) {
         $this->data['station_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
コード例 #2
0
 function postInstall()
 {
     global $cache;
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     if (is_array($this->station_users) and count($this->station_users) > 0) {
         foreach ($this->station_users as $station_id => $user_ids) {
             //Get station object.
             $slf = new StationListFactory();
             $slf->getById($station_id);
             if ($slf->getRecordCount() > 0) {
                 $s_obj = $slf->getCurrent();
                 if (in_array('-1', $user_ids)) {
                     //All users allowed
                     $s_obj->setGroupSelectionType(10);
                     $s_obj->setBranchSelectionType(10);
                     $s_obj->setDepartmentSelectionType(10);
                 } else {
                     //Only specific users allowed
                     $s_obj->setIncludeUser($user_ids);
                 }
                 if ($s_obj->isValid()) {
                     $s_obj->Save();
                 }
             }
         }
     }
     unset($this->station_users);
     //Add currency updating to cron.
     $maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'maint' . DIRECTORY_SEPARATOR;
     if (PHP_OS == 'WINNT') {
         $cron_job_base_command = 'php-win.exe ' . $maint_base_path;
     } else {
         $cron_job_base_command = 'php ' . $maint_base_path;
     }
     Debug::text('Cron Job Base Command: ' . $cron_job_base_command, __FILE__, __LINE__, __METHOD__, 9);
     $cjf = new CronJobFactory();
     $cjf->setName('TimeClockSync');
     $cjf->setMinute('*');
     $cjf->setHour('*');
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('*');
     $cjf->setCommand($cron_job_base_command . 'TimeClockSync.php');
     $cjf->Save();
     return TRUE;
 }
コード例 #3
0
     TTi18n::setCountry($current_user->getCountry());
     TTi18n::setLocale();
     //Sets master locale
 }
 $profiler->stopTimer("setLocale()");
 if ($current_user->isInformationComplete() == TRUE and $current_user_prefs->isPreferencesComplete() == FALSE and (!stristr($_SERVER['SCRIPT_NAME'], 'permissiondenied') and !stristr($_SERVER['SCRIPT_NAME'], 'logout') and !stristr($_SERVER['SCRIPT_NAME'], 'about') and !stristr($_SERVER['SCRIPT_NAME'], 'punch.php') and !stristr($_SERVER['SCRIPT_NAME'], 'ajax_server') and !stristr($_SERVER['SCRIPT_NAME'], 'global.js') and !stristr($_SERVER['SCRIPT_NAME'], 'menu.js')) and !isset($_GET['incomplete']) and !isset($_POST['incomplete']) and ($permission->Check('user_preference', 'enabled') and ($permission->Check('user_preference', 'edit') or $permission->Check('user_preference', 'edit_child') or $permission->Check('user_preference', 'edit_own')))) {
     Redirect::Page(URLBuilder::getURL(array('incomplete' => 1), Environment::GetBaseURL() . 'users/EditUserPreference.php'));
 }
 //Get all system settings, so they can be used even if the user isn't logged in, such as the login page.
 $sslf = new SystemSettingListFactory();
 $system_settings = $sslf->getAllArray();
 unset($sslf);
 //Handle station functionality
 if (isset($_COOKIE['StationID'])) {
     Debug::text('Station ID Cookie found! ' . $_COOKIE['StationID'], __FILE__, __LINE__, __METHOD__, 10);
     $slf = new StationListFactory();
     $slf->getByStationIdandCompanyId($_COOKIE['StationID'], $current_company->getId());
     $current_station = $slf->getCurrent();
     unset($slf);
     if ($current_station->isNew()) {
         Debug::text('Station ID is NOT IN DB!! ' . $_COOKIE['StationID'], __FILE__, __LINE__, __METHOD__, 10);
     }
 }
 //Debug::Arr($current_station, 'Current Station Object: ', __FILE__, __LINE__, __METHOD__, 10);
 //Debug::text('Current Company: '. $current_company->getName(), __FILE__, __LINE__, __METHOD__, 10);
 //Make sure CronJobs are running correctly.
 $cjlf = new CronJobListFactory();
 $cjlf->getMostRecentlyRun();
 if ($cjlf->getRecordCount() > 0) {
     //Is last run job more then 48hrs old?
     $cj_obj = $cjlf->getCurrent();
 function setOfflinePunch($data)
 {
     Debug::Text('Setting Offline Punches... Rows: ' . count($data), __FILE__, __LINE__, __METHOD__, 10);
     //
     //WHen in Offline mode, default Type/Status to "AUTO"...
     //That way once I get the punches, I can determine what they should be on my end.
     //
     if (!is_array($data) or count($data) == 0) {
         return FALSE;
     }
     ksort($data);
     //Debug::Arr($data, 'offlinePunchDataArr', __FILE__, __LINE__, __METHOD__,10);
     /*
     		//Original
     		$data[] = array(
     						'user_id' => 1,
     						'time_stamp' => '12:00 PM',
     						'date_stamp' => '03-Dec-05',
     						'branch_id' => 1,
     						'department_id' => NULL,
     						'status_id' => 20,
     						'type_id' => 20,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     /*
     		unset($data);
     
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '08:00 AM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 5,
     						'department_id' => 3,
     						'status_id' => 0,
     						'type_id' => 0,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '12:00 PM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 0,
     						'department_id' => 3,
     						'status_id' => 20,
     						'type_id' => 0,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     /*
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '1:00 PM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 6,
     						'department_id' => 0,
     						'status_id' => 0,
     						'type_id' => 20,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     /*
     		$data[] = array(
     						'user_id' => 1001,
     						'time_stamp' => '5:00 PM',
     						'date_stamp' => '05-Dec-05',
     						'branch_id' => 0,
     						'department_id' => 0,
     						'status_id' => 0,
     						'type_id' => 0,
     						'punch_control_id' => 0,
     						'station_id' => '7D00000023352A81'
     						);
     */
     //Debug::Arr($data, 'offlinePunchDataArr', __FILE__, __LINE__, __METHOD__,10);
     //One punch per row
     foreach ($data as $row_key => $punch_row) {
         Debug::Text('--------------------------========================---------------------------', __FILE__, __LINE__, __METHOD__, 10);
         Debug::Text('--------------------------========================---------------------------', __FILE__, __LINE__, __METHOD__, 10);
         Debug::Text('Row Key: ' . $row_key . ' Date: ' . $punch_row['date_stamp'] . ' Time: ' . $punch_row['time_stamp'] . ' Station ID: ' . $punch_row['station_id'], __FILE__, __LINE__, __METHOD__, 10);
         if (isset($punch_row['station_id'])) {
             $slf = new StationListFactory();
             $slf->getByStationId($punch_row['station_id']);
             if ($slf->getRecordCount() > 0) {
                 Debug::Text('Found Station Data...', __FILE__, __LINE__, __METHOD__, 10);
                 $current_station = $slf->getCurrent();
             } else {
                 Debug::Text('DID NOT Find Station Data...', __FILE__, __LINE__, __METHOD__, 10);
                 continue;
             }
             unset($slf);
         }
         if (isset($punch_row['user_id']) and $punch_row['user_id'] != '') {
             $ulf = new UserListFactory();
             $ulf->getById($punch_row['user_id']);
             if ($ulf->getRecordCount() > 0) {
                 $current_user = $ulf->getCurrent();
                 Debug::Text('Valid User ID: ' . $punch_row['user_id'] . ' User Name: ' . $current_user->getFullName(), __FILE__, __LINE__, __METHOD__, 10);
                 //Need to handle timezone somehow. The station should send us the system's timezone
                 //so we can calculate based on that.
                 //Or just use the employees date preference.
                 $current_user->getUserPreferenceObject()->setDateTimePreferences();
             } else {
                 Debug::Text('aInValid User ID: ' . $punch_row['user_id'], __FILE__, __LINE__, __METHOD__, 10);
                 continue;
             }
         } else {
             Debug::Text('bInValid User ID: ' . $punch_row['user_id'], __FILE__, __LINE__, __METHOD__, 10);
             continue;
         }
         //Check to make sure the station is allowed.
         if (is_object($current_station) and is_object($current_user) and $current_station->checkAllowed($current_user->getId(), $current_station->getStation(), $current_station->getType()) == FALSE) {
             Debug::text('Station NOT allowed: Station ID: ' . $current_station->getId() . ' User: '******'date_stamp'] . ' ' . $punch_row['time_stamp']);
         //Make sure time stamp converts properly, otherwise skip this punch.
         if (!is_int($punch_full_time_stamp)) {
             Debug::Text('Failed TimeStamp: ' . $punch_full_time_stamp, __FILE__, __LINE__, __METHOD__, 10);
             continue;
         }
         Debug::Text('Punch Date/Time: ' . $punch_full_time_stamp . ' Offset that was already applied: ' . $punch_row['offset'], __FILE__, __LINE__, __METHOD__, 10);
         $fail_transaction = FALSE;
         $pf = new PunchFactory();
         $pf->StartTransaction();
         $slf = new ScheduleListFactory();
         //Auto Punch
         if (isset($punch_row['status_id']) and $punch_row['status_id'] == 0 or isset($punch_row['type_id']) and $punch_row['type_id'] == 0 or isset($punch_row['branch_id']) and $punch_row['branch_id'] == 0 or isset($punch_row['department_id']) and $punch_row['department_id'] == 0 or isset($punch_row['job_id']) and $punch_row['job_id'] == 0 or isset($punch_row['job_item_id']) and $punch_row['job_item_id'] == 0) {
             $plf = new PunchListFactory();
             $plf->getPreviousPunchByUserIDAndEpoch($punch_row['user_id'], $punch_full_time_stamp);
             if ($plf->getRecordCount() > 0) {
                 Debug::Text(' Found Previous Punch within Continuous Time from now: ', __FILE__, __LINE__, __METHOD__, 10);
                 $prev_punch_obj = $plf->getCurrent();
                 $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();
                 $quantity = $prev_punch_obj->getPunchControlObject()->getQuantity();
                 $bad_quantity = $prev_punch_obj->getPunchControlObject()->getBadQuantity();
                 if ($branch_id == '' or empty($branch_id) or $department_id == '' or empty($department_id)) {
                     Debug::Text(' Branch or department are null. ', __FILE__, __LINE__, __METHOD__, 10);
                     $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($punch_row['user_id'], $punch_full_time_stamp);
                     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();
                         }
                     }
                 }
                 $type_id = $prev_punch_obj->getNextType();
                 $status_id = $prev_punch_obj->getNextStatus();
                 $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($current_user->getId());
                     $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($punch_full_time_stamp));
                     if ($prev_punch_obj->inBreakPolicyWindow($punch_full_time_stamp, $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($current_user->getId());
                     $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($punch_full_time_stamp));
                     if ($prev_punch_obj->inMealPolicyWindow($punch_full_time_stamp, $prev_punch_obj->getTimeStamp()) == TRUE) {
                         Debug::Text(' Setting Type to Lunch: ', __FILE__, __LINE__, __METHOD__, 10);
                         $next_type = 20;
                     }
                 }
             } else {
                 Debug::Text(' DID NOT Find Previous Punch within Continuous Time from now: ', __FILE__, __LINE__, __METHOD__, 10);
                 $branch_id = NULL;
                 $department_id = NULL;
                 $job_id = NULL;
                 $job_item_id = NULL;
                 $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($punch_row['user_id'], $punch_full_time_stamp);
                 if (is_object($s_obj)) {
                     Debug::Text(' Found Schedule!: ', __FILE__, __LINE__, __METHOD__, 10);
                     $branch_id = $s_obj->getBranch();
                     $department_id = $s_obj->getDepartment();
                 } else {
                     $branch_id = $current_user->getDefaultBranch();
                     $department_id = $current_user->getDefaultDepartment();
                     //Check station for default/forced settings.
                     if (is_object($current_station)) {
                         if ($current_station->getDefaultBranch() !== FALSE and $current_station->getDefaultBranch() != 0) {
                             $branch_id = $current_station->getDefaultBranch();
                         }
                         if ($current_station->getDefaultDepartment() !== FALSE and $current_station->getDefaultDepartment() != 0) {
                             $department_id = $current_station->getDefaultDepartment();
                         }
                         if ($current_station->getDefaultJob() !== FALSE and $current_station->getDefaultJob() != 0) {
                             $job_id = $current_station->getDefaultJob();
                         }
                         if ($current_station->getDefaultJobItem() !== FALSE and $current_station->getDefaultJobItem() != 0) {
                             $job_item_id = $current_station->getDefaultJobItem();
                         }
                     }
                 }
                 $status_id = 10;
                 //In
                 $type_id = 10;
                 //Normal
             }
             if (isset($punch_row['status_id']) and $punch_row['status_id'] != 0) {
                 Debug::Text(' Status ID is NOT AUTO: ' . $punch_row['status_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $status_id = $punch_row['status_id'];
             }
             if (isset($punch_row['type_id']) and $punch_row['type_id'] != 0) {
                 Debug::Text(' Type ID is NOT AUTO: ' . $punch_row['type_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $type_id = $punch_row['type_id'];
             }
             if (isset($punch_row['branch_id']) and $punch_row['branch_id'] != 0) {
                 Debug::Text(' Branch ID is NOT AUTO: ' . $punch_row['branch_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $branch_id = $punch_row['branch_id'];
             }
             if (isset($punch_row['department_id']) and $punch_row['department_id'] != 0) {
                 Debug::Text(' Department ID is NOT AUTO: ' . $punch_row['department_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $department_id = $punch_row['department_id'];
             }
             if (isset($punch_row['job_id']) and $punch_row['job_id'] != 0) {
                 Debug::Text(' Job ID is NOT AUTO: ' . $punch_row['job_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $job_id = $punch_row['job_id'];
             }
             if (isset($punch_row['job_item_id']) and $punch_row['job_item_id'] != 0) {
                 Debug::Text(' Job Item ID is NOT AUTO: ' . $punch_row['job_item_id'], __FILE__, __LINE__, __METHOD__, 10);
                 $job_item_id = $punch_row['job_item_id'];
             }
             if (isset($punch_row['quantity'])) {
                 Debug::Text(' Quantity is NOT AUTO: ' . $punch_row['quantity'], __FILE__, __LINE__, __METHOD__, 10);
                 $quantity = $punch_row['quantity'];
             }
             if (isset($punch_row['bad_quantity'])) {
                 Debug::Text(' Bad Quantity is NOT AUTO: ' . $punch_row['bad_quantity'], __FILE__, __LINE__, __METHOD__, 10);
                 $bad_quantity = $punch_row['bad_quantity'];
             }
         } else {
             $status_id = $punch_row['status_id'];
             $type_id = $punch_row['type_id'];
             $branch_id = $punch_row['branch_id'];
             $department_id = $punch_row['department_id'];
             $job_id = $punch_row['job_id'];
             $job_item_id = $punch_row['job_item_id'];
             $quantity = $punch_row['quantity'];
             $bad_quantity = $punch_row['bad_quantity'];
         }
         //Set User before setTimeStamp so rounding can be done properly.
         $pf->setUser($punch_row['user_id']);
         if (isset($punch_row['transfer']) and $punch_row['transfer'] == 1) {
             Debug::Text(' Enabling Transfer!: ', __FILE__, __LINE__, __METHOD__, 10);
             $type_id = 10;
             $status_id = 10;
             $pf->setTransfer(TRUE);
         }
         $pf->setType($type_id);
         $pf->setStatus($status_id);
         $pf->setTimeStamp($punch_full_time_stamp, TRUE);
         //Make sure we round here.
         if (isset($status_id) and $status_id == 20 and isset($punch_row['punch_control_id']) and $punch_row['punch_control_id'] != '' and $punch_row['punch_control_id'] != 0) {
             $pf->setPunchControlID($punch_row['punch_control_id']);
         } else {
             $pf->setPunchControlID($pf->findPunchControlID());
         }
         $pf->setStation($current_station->getId());
         if ($pf->isNew()) {
             $pf->setActualTimeStamp($punch_full_time_stamp);
             $pf->setOriginalTimeStamp($pf->getTimeStamp());
         }
         if ($pf->isValid() == TRUE) {
             if ($pf->Save(FALSE) == TRUE) {
                 $pcf = new PunchControlFactory();
                 $pcf->setId($pf->getPunchControlID());
                 $pcf->setPunchObject($pf);
                 if (isset($branch_id) and $branch_id != '') {
                     $pcf->setBranch($branch_id);
                 }
                 if (isset($department_id) and $department_id != '') {
                     $pcf->setDepartment($department_id);
                 }
                 if (isset($job_id) and $job_id != '') {
                     $pcf->setJob($job_id);
                 }
                 if (isset($job_item_id) and $job_item_id != '') {
                     $pcf->setJobItem($job_item_id);
                 }
                 if (isset($quantity) and $quantity != '') {
                     $pcf->setQuantity($quantity);
                 }
                 if (isset($bad_quantity) and $bad_quantity != '') {
                     $pcf->setBadQuantity($bad_quantity);
                 }
                 if (isset($punch_row['note']) and $punch_row['note'] != '') {
                     $pcf->setNote($punch_row['note']);
                 }
                 if (isset($punch_row['other_id1']) and $punch_row['other_id1'] != '') {
                     $pcf->setOtherID1($punch_row['other_id1']);
                 }
                 if (isset($punch_row['other_id2']) and $punch_row['other_id2'] != '') {
                     $pcf->setOtherID2($punch_row['other_id2']);
                 }
                 if (isset($punch_row['other_id3']) and $punch_row['other_id3'] != '') {
                     $pcf->setOtherID3($punch_row['other_id3']);
                 }
                 if (isset($punch_row['other_id4']) and $punch_row['other_id4'] != '') {
                     $pcf->setOtherID4($punch_row['other_id4']);
                 }
                 if (isset($punch_row['other_id5']) and $punch_row['other_id5'] != '') {
                     $pcf->setOtherID5($punch_row['other_id5']);
                 }
                 $pcf->setEnableStrictJobValidation(TRUE);
                 $pcf->setEnableCalcUserDateID(TRUE);
                 $pcf->setEnableCalcTotalTime(TRUE);
                 $pcf->setEnableCalcSystemTotalTime(TRUE);
                 $pcf->setEnableCalcUserDateTotal(TRUE);
                 $pcf->setEnableCalcException(TRUE);
                 $pcf->setEnablePreMatureException(TRUE);
                 //Enable pre-mature exceptions at this point.
                 if ($pcf->isValid() == TRUE) {
                     Debug::Text(' Punch Control is valid, saving...: ', __FILE__, __LINE__, __METHOD__, 10);
                     if ($pcf->Save(TRUE, TRUE) == TRUE) {
                         //Force isNew() lookup.
                         Debug::text('Saved Punch!', __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                         Debug::text('PCF Save failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
                         $fail_transaction = TRUE;
                     }
                 } else {
                     Debug::text('PCF Validate failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
                     $fail_transaction = TRUE;
                 }
             } else {
                 Debug::text('PF Save failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
                 $fail_transaction = TRUE;
             }
         } else {
             Debug::text('PF Validate failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10);
             $fail_transaction = TRUE;
         }
         if ($fail_transaction == FALSE) {
             $pf->CommitTransaction();
         } else {
             $pf->FailTransaction();
         }
         unset($punch_full_time_stamp, $current_station, $current_user);
         //End Foreach
     }
     return TRUE;
 }
コード例 #5
0
ファイル: EditPunch.php プロジェクト: J-P-Hanafin/TimeTrex-1
     $pclf = new PunchControlListFactory();
     $pclf->getByPunchId($id);
     foreach ($pclf as $pc_obj) {
         //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
         //Get punches
         $plf = new PunchListFactory();
         //$plf->getByPunchControlId( $pc_obj->getId() );
         $plf->getById($id);
         if ($plf->getRecordCount() > 0) {
             $p_obj = $plf->getCurrent();
         } else {
             $punch_data = NULL;
         }
         //Get Station data.
         $station_data = FALSE;
         $slf = new StationListFactory();
         if ($p_obj->getStation() != FALSE) {
             $slf->getById($p_obj->getStation());
             if ($slf->getRecordCount() > 0) {
                 $s_obj = $slf->getCurrent();
                 $station_data = array('id' => $s_obj->getId(), 'type_id' => $s_obj->getType(), 'type' => Option::getByKey($s_obj->getType(), $s_obj->getOptions('type')), 'station_id' => $s_obj->getStation(), 'source' => $s_obj->getSource(), 'description' => Misc::TruncateString($s_obj->getDescription(), 20));
             }
         }
         $pc_data = array('id' => $pc_obj->getId(), 'user_date_id' => $pc_obj->getUserDateId(), 'user_id' => $pc_obj->getUserDateObject()->getUser(), 'user_full_name' => $pc_obj->getUserDateObject()->getUserObject()->getFullName(), 'pay_period_id' => $pc_obj->getUserDateObject()->getPayPeriod(), 'branch_id' => $pc_obj->getBranch(), 'department_id' => $pc_obj->getDepartment(), 'job_id' => $pc_obj->getJob(), 'job_item_id' => $pc_obj->getJobItem(), 'quantity' => (double) $pc_obj->getQuantity(), 'bad_quantity' => (double) $pc_obj->getBadQuantity(), 'note' => $pc_obj->getNote(), 'other_id1' => $pc_obj->getOtherID1(), 'other_id2' => $pc_obj->getOtherID2(), 'other_id3' => $pc_obj->getOtherID3(), 'other_id4' => $pc_obj->getOtherID4(), 'other_id5' => $pc_obj->getOtherID5(), 'punch_id' => $p_obj->getId(), 'status_id' => $p_obj->getStatus(), 'type_id' => $p_obj->getType(), 'station_id' => $p_obj->getStation(), 'station_data' => $station_data, 'time_stamp' => $p_obj->getTimeStamp(), 'date_stamp' => $p_obj->getTimeStamp(), 'original_time_stamp' => $p_obj->getOriginalTimeStamp(), 'actual_time_stamp' => $p_obj->getActualTimeStamp(), 'longitude' => $p_obj->getLongitude(), 'latitude' => $p_obj->getLatitude(), 'created_date' => $p_obj->getCreatedDate(), 'created_by' => $p_obj->getCreatedBy(), 'created_by_name' => (string) $ulf->getFullNameById($p_obj->getCreatedBy()), 'updated_date' => $p_obj->getUpdatedDate(), 'updated_by' => $p_obj->getUpdatedBy(), 'updated_by_name' => (string) $ulf->getFullNameById($p_obj->getUpdatedBy()), 'deleted_date' => $p_obj->getDeletedDate(), 'deleted_by' => $p_obj->getDeletedBy());
     }
 } elseif ($action != 'submit') {
     Debug::Text(' ID was NOT passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     //UserID has to be set at minimum
     if ($punch_control_id != '') {
         Debug::Text(' Punch Control ID was passed: ' . $punch_control_id, __FILE__, __LINE__, __METHOD__, 10);
         //Get previous punch, and default timestamp to that.
コード例 #6
0
     $filter_data['job_item_ids'] = array(-1);
 }
 $epoch = TTDate::getTime();
 $filter_data['start_date'] = $epoch - 86400;
 $filter_data['end_date'] = $epoch + 86400;
 $filter_data['status_id'] = 10;
 $ulf = new UserListFactory();
 $utlf = new UserTitleListFactory();
 $title_options = $utlf->getByCompanyIdArray($current_company->getId());
 $uglf = new UserGroupListFactory();
 $group_options = $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'no_tree_text', TRUE));
 $blf = new BranchListFactory();
 $branch_options = $blf->getByCompanyIdArray($current_company->getId());
 $dlf = new DepartmentListFactory();
 $department_options = $dlf->getByCompanyIdArray($current_company->getId());
 $slf = new StationListFactory();
 $station_type_options = $slf->getOptions('type');
 if ($current_company->getProductEdition() == 20) {
     $jlf = new JobListFactory();
     $job_options = $jlf->getByCompanyIdArray($current_company->getId());
     $jilf = new JobItemListFactory();
     $job_item_options = $jilf->getByCompanyIdArray($current_company->getId());
 } else {
     $job_options = array();
     $job_item_options = array();
 }
 $punch_type_options = $plf->getOptions('type');
 $plf->getLastPunchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
 if ($plf->getRecordCount() > 0) {
     foreach ($plf as $p_obj) {
         //Get user info
コード例 #7
0
 function setStation($source, $station, $description = NULL, $type = 'PHONE')
 {
     Debug::text('Setting Station: (' . $station . ') Source: ' . $source . ' Description: ' . $description . ' Type: ' . $type, __FILE__, __LINE__, __METHOD__, 10);
     if ($type == '') {
         return FALSE;
     }
     //Make sure we don't strtolower() type, as it will cause the lookup to fail.
     $type = trim($type);
     //We using SOAP, we always have the IP address, always set it unless we're using
     //the phone punch in.
     if (strtolower($type) == 'phone' or $type == 20) {
         $source = Misc::parseCallerID($source);
         $station = Misc::parseCallerID($station);
         Debug::text('Filtered Source: ' . $source . ' Station: ' . $station, __FILE__, __LINE__, __METHOD__, 10);
     } else {
         $source = $_SERVER['REMOTE_ADDR'];
     }
     if ($source == '') {
         $source = 'Unavailable';
     }
     if ($description == '') {
         $description = 'N/A';
     }
     if ($source == '') {
         $source = NULL;
     }
     $slf = new StationListFactory();
     $slf->getByStationIdandCompanyId($station, $this->getCompanyObject()->getId());
     $current_station = $slf->getCurrent();
     unset($slf);
     if ($current_station->isNew()) {
         Debug::text('Station not found... Adding new one...', __FILE__, __LINE__, __METHOD__, 10);
         $sf = new StationFactory();
         $sf->setCompany($this->getCompanyObject()->getId());
         $sf->setStatus('ENABLED');
         $sf->setType($type);
         //If this is a new iButton,Fingerprint, or Barcode station, default to 'ANY' for the source, so we aren't restricted by IP.
         if (in_array($sf->getType(), array(30, 40, 50))) {
             $sf->setSource('ANY');
         } else {
             $sf->setSource($source);
         }
         $sf->setStation($station);
         $sf->setDescription($description);
         //If this is a new iButton,Fingerprint, or Barcode station, default to allow all employees.
         if (in_array($sf->getType(), array(30, 40, 50))) {
             $sf->setGroupSelectionType(10);
             $sf->setBranchSelectionType(10);
             $sf->setDepartmentSelectionType(10);
         }
         if ($sf->isValid()) {
             if ($sf->Save(FALSE)) {
                 //return $source;
                 return $sf->getStation();
             }
         }
     } else {
         Debug::text('Station FOUND!', __FILE__, __LINE__, __METHOD__, 10);
         return $current_station->getStation();
     }
     return FALSE;
 }
コード例 #8
0
    case 'delete' or 'undelete':
        if (strtolower($action) == 'delete') {
            $delete = TRUE;
        } else {
            $delete = FALSE;
        }
        $slf = new StationListFactory();
        foreach ($ids as $id) {
            $slf->GetByIdAndCompanyId($id, $current_company->getId());
            foreach ($slf as $station) {
                $station->setDeleted($delete);
                $station->Save();
            }
        }
        Redirect::Page(URLBuilder::getURL(NULL, 'StationList.php'));
        break;
    default:
        $slf = new StationListFactory();
        $slf->getByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
        $pager = new Pager($slf);
        foreach ($slf as $station) {
            $stations[] = array('id' => $station->GetId(), 'type' => Option::getByKey($station->getType(), $station->getOptions('type')), 'status' => Option::getByKey($station->getStatus(), $station->getOptions('status')), 'source' => $station->getSource(), 'station' => $station->getStation(), 'short_station' => Misc::TruncateString($station->getStation(), 15), 'description' => Misc::TruncateString($station->getDescription(), 30), 'deleted' => $station->getDeleted());
            unset($description);
        }
        $smarty->assign_by_ref('stations', $stations);
        $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('station/StationList.tpl');
コード例 #9
0
 static function getOrCreateStation($station_id, $company_id, $type_id = 10)
 {
     Debug::text('Checking for Station ID: ' . $station_id . ' Company ID: ' . $company_id . ' Type: ' . $type_id, __FILE__, __LINE__, __METHOD__, 10);
     $slf = new StationListFactory();
     $slf->getByStationIdandCompanyId($station_id, $company_id);
     if ($slf->getRecordCount() == 1) {
         $retval = $slf->getCurrent()->getStation();
     } else {
         Debug::text('Station ID: ' . $station_id . ' does not exist, creating new station', __FILE__, __LINE__, __METHOD__, 10);
         //Insert new station
         $sf = TTnew('StationFactory');
         $sf->setCompany($company_id);
         $sf->setStatus(20);
         //Enabled
         switch ($type_id) {
             case 10:
                 //PC
                 $station = NULL;
                 $description = substr($_SERVER['HTTP_USER_AGENT'], 0, 250);
                 break;
             case 28:
                 //Phone/Mobile App
                 $station = NULL;
                 //Can't get UDID on iOS5, but we can on Android.
                 $description = TTi18n::getText('Mobile Application') . ': ' . substr($_SERVER['HTTP_USER_AGENT'], 0, 250);
                 break;
         }
         $sf->setType($type_id);
         $sf->setDescription($description);
         $sf->setStation($station);
         $sf->setSource($_SERVER['REMOTE_ADDR']);
         if ($sf->isValid()) {
             if ($sf->Save(FALSE)) {
                 $retval = $sf->getStation();
             }
         } else {
             $retval = $sf;
         }
     }
     Debug::text('Returning Station ID: ' . $station_id, __FILE__, __LINE__, __METHOD__, 10);
     return $retval;
 }
コード例 #10
0
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Copy iButton,Fingerprint,EmployeeNumber (barcode/proximity) fields to new UserIdentification table.
     //Find out if they have both TimeClocks and FingerPrint stations. If they do
     //we need to copy the fingerprint data to both types of UserIdentification rows.
     $clf = new CompanyListFactory();
     $clf->getAll();
     $clf->StartTransaction();
     foreach ($clf as $c_obj) {
         Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
         $max_templates = 4;
         $slf = new StationListFactory();
         $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(30, 40, 50, 100, 110));
         if ($slf->getRecordCount() > 0) {
             $slf_tmp1 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(50));
             $griaule_stations = $slf_tmp1->getRecordCount();
             Debug::text('  Found Griaule Stations: ' . $griaule_stations, __FILE__, __LINE__, __METHOD__, 9);
             unset($slf_tmp1);
             $slf_tmp2 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(100, 110));
             $zk_stations = $slf_tmp2->getRecordCount();
             Debug::text('  Found ZK Stations: ' . $zk_stations, __FILE__, __LINE__, __METHOD__, 9);
             unset($slf_tmp2);
             $slf_tmp3 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(40));
             $barcode_stations = $slf_tmp3->getRecordCount();
             Debug::text('  Found Barcode Stations: ' . $barcode_stations, __FILE__, __LINE__, __METHOD__, 9);
             unset($slf_tmp3);
             //Loop through each user copying their data to the UserIdenfification Table.
             $ulf = new UserListFactory();
             $ulf->getByCompanyID($c_obj->getId());
             if ($ulf->getRecordCount() > 0) {
                 foreach ($ulf as $u_obj) {
                     Debug::text('  User: '******'') {
                         Debug::text('    Converting iButton...', __FILE__, __LINE__, __METHOD__, 9);
                         $uif = new UserIdentificationFactory();
                         $uif->setUser($u_obj->getId());
                         $uif->setType(10);
                         //10=iButton
                         $uif->setNumber(0);
                         $uif->setValue($u_obj->getIButtonID());
                         if ($uif->isValid() == TRUE) {
                             $uif->Save();
                             $u_obj->getIButtonID('');
                         }
                     }
                     if ($u_obj->getRFID() != '') {
                         Debug::text('    Converting RFID...', __FILE__, __LINE__, __METHOD__, 9);
                         $uif = new UserIdentificationFactory();
                         $uif->setUser($u_obj->getId());
                         $uif->setType(40);
                         //40=Proximity
                         $uif->setNumber(0);
                         $uif->setValue($u_obj->getRFID());
                         if ($uif->isValid() == TRUE) {
                             $uif->Save();
                             $u_obj->getRFID('');
                         }
                     }
                     if ($barcode_stations > 0 and $u_obj->getEmployeeNumber() != '') {
                         Debug::text('    Converting EmployeeNumber...', __FILE__, __LINE__, __METHOD__, 9);
                         $uif = new UserIdentificationFactory();
                         $uif->setUser($u_obj->getId());
                         $uif->setType(30);
                         //30=Barcode
                         $uif->setNumber(0);
                         $uif->setValue($u_obj->getEmployeeNumber());
                         if ($uif->isValid() == TRUE) {
                             $uif->Save();
                         }
                     }
                     if ($griaule_stations > 0) {
                         for ($t = 1; $t <= $max_templates; $t++) {
                             $set_fingerprint_function = 'setFingerPrint' . $t;
                             $get_fingerprint_function = 'getFingerPrint' . $t;
                             //Griaule fingerprint templates start with: "p/8B"
                             if ($u_obj->{$get_fingerprint_function}() != '' and substr($u_obj->{$get_fingerprint_function}(), 0, 4) == 'p/8B') {
                                 Debug::text('    Converting Griaule FingerPrint: ' . $t, __FILE__, __LINE__, __METHOD__, 9);
                                 $uif = new UserIdentificationFactory();
                                 $uif->setUser($u_obj->getId());
                                 $uif->setType(20);
                                 //20=Griaule, 100=ZK
                                 $uif->setNumber($t * 10);
                                 $uif->setValue($u_obj->{$get_fingerprint_function}());
                                 if ($uif->isValid() == TRUE) {
                                     $uif->Save();
                                     $u_obj->{$set_fingerprint_function}('');
                                 }
                             }
                         }
                     }
                     if ($zk_stations > 0) {
                         for ($t = 1; $t <= $max_templates; $t++) {
                             $set_fingerprint_function = 'setFingerPrint' . $t;
                             $get_fingerprint_function = 'getFingerPrint' . $t;
                             //ZK fingerprint templates start with: "oco"
                             if ($u_obj->{$get_fingerprint_function}() != '' and substr($u_obj->{$get_fingerprint_function}(), 0, 3) == 'oco') {
                                 Debug::text('    Converting ZK FingerPrint: ' . $t, __FILE__, __LINE__, __METHOD__, 9);
                                 $uif = new UserIdentificationFactory();
                                 $uif->setUser($u_obj->getId());
                                 $uif->setType(100);
                                 //20=Griaule, 100=ZK
                                 $uif->setNumber($t);
                                 $uif->setValue($u_obj->{$get_fingerprint_function}());
                                 if ($uif->isValid() == TRUE) {
                                     $uif->Save();
                                     $u_obj->{$set_fingerprint_function}('');
                                 }
                             }
                         }
                     }
                     if ($u_obj->isValid()) {
                         $u_obj->Save();
                     }
                 }
             }
         }
     }
     $clf->CommitTransaction();
     return TRUE;
 }
コード例 #11
0
     Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($station_data['user_ids'], 'Selected Users', __FILE__, __LINE__, __METHOD__, 10);
     $sf->setId($station_data['id']);
     $sf->setUser($station_data['user_ids']);
     if ($sf->isValid()) {
         $sf->Save(FALSE);
         Redirect::Page(URLBuilder::getURL(NULL, 'StationList.php'));
         break;
     }
 default:
     if (isset($station_data['id'])) {
         $id = $station_data['id'];
     }
     if (isset($id)) {
         BreadCrumb::setCrumb($title);
         $slf = new StationListFactory();
         $sulf = new StationUserListFactory();
         $slf->GetByIdAndCompanyId($id, $current_company->getId());
         foreach ($slf as $station) {
             //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
             if (isset($station_data['user_ids'])) {
                 Debug::Text('Using Selected Users', __FILE__, __LINE__, __METHOD__, 10);
                 //Use selected values
                 $user_ids = $station_data['user_ids'];
             } else {
                 Debug::Text('Grabbing Users from DB', __FILE__, __LINE__, __METHOD__, 10);
                 $sulf->getByStationId($station->getId());
                 $user_ids = array();
                 foreach ($sulf as $station_user) {
                     $user_ids[] = $station_user->getUser();
                 }
コード例 #12
0
ファイル: APIPunch.class.php プロジェクト: alachaum/timetrex
 function getUserPunch($user_id = NULL, $epoch = NULL, $station_id = NULL, $company_id = NULL)
 {
     if ($epoch == '') {
         $epoch = TTDate::getTime();
     }
     if (!is_numeric($user_id)) {
         $user_id = $this->getCurrentUserObject()->getId();
     }
     if (!is_numeric($company_id)) {
         $company_id = $this->getCurrentCompanyObject()->getId();
     }
     if (!is_numeric($station_id)) {
         $station_id = getStationID();
         //API.inc
     }
     //Must call APIStation->getCurrentStation( $station_id = NULL ) first, so the Station ID cookie can be set and passed to this.
     //Check if station is allowed.
     $current_station = FALSE;
     $slf = new StationListFactory();
     $slf->getByStationIdandCompanyId($station_id, $company_id);
     if ($slf->getRecordCount() == 1) {
         $current_station = $slf->getCurrent();
         $station_type = $current_station->getType();
     }
     unset($slf);
     $slf = TTnew('ScheduleListFactory');
     Debug::Text('Station ID: ' . $station_id . ' User ID: ' . $user_id . ' Epoch: ' . $epoch, __FILE__, __LINE__, __METHOD__, 10);
     if (is_object($current_station) and $current_station->checkAllowed($user_id, $station_id, $station_type) == TRUE) {
         Debug::Text('Station Allowed! ID: ' . $station_id . ' User ID: ' . $user_id . ' Epoch: ' . $epoch, __FILE__, __LINE__, __METHOD__, 10);
         //Get user object from ID.
         $ulf = TTNew('UserListFactory');
         $ulf->getByIdAndCompanyId($user_id, $company_id);
         if ($ulf->getRecordCount() == 1) {
             $user_obj = $ulf->getCurrent();
             $plf = TTNew('PunchListFactory');
             $data = $plf->getDefaultPunchSettings($user_obj, $epoch, $current_station, $this->getPermissionObject());
             $data['date_stamp'] = TTDate::getAPIDate('DATE', $epoch);
             $data['time_stamp'] = TTDate::getAPIDate('DATE+TIME', $epoch);
             $data['punch_date'] = TTDate::getAPIDate('DATE', $epoch);
             $data['punch_time'] = TTDate::getAPIDate('TIME', $epoch);
             $data['original_time_stamp'] = TTDate::getAPIDate('DATE+TIME', $epoch);
             $data['actual_time_stamp'] = TTDate::getAPIDate('DATE+TIME', $epoch);
             $data['first_name'] = $user_obj->getFirstName();
             $data['last_name'] = $user_obj->getLastName();
             $data['station_id'] = $current_station->getId();
             if (isset($data)) {
                 Debug::Arr($data, 'Punch Data: ', __FILE__, __LINE__, __METHOD__, 10);
                 return $this->returnHandler($data);
             }
         }
     } else {
         Debug::Text('Station IS NOT Allowed! ID: ' . $station_id . ' User ID: ' . $user_id . ' Epoch: ' . $epoch, __FILE__, __LINE__, __METHOD__, 10);
         $validator_obj = new Validator();
         $validator_stats = array('total_records' => 1, 'valid_records' => 0);
         $error_message = TTi18n::gettext('You are not authorized to punch in or out from this station!');
         $validator_obj->isTrue('user_name', FALSE, $error_message);
         $validator[0] = $validator_obj->getErrorsArray();
         return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
     }
     return FALSE;
 }
コード例 #13
0
 function checkAllowed($user_id = NULL, $station_id = NULL, $type = 'PC')
 {
     if ($user_id == NULL or $user_id == '') {
         global $current_user;
         $user_id = $current_user->getId();
     }
     Debug::text('User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
     if ($station_id == NULL or $station_id == '') {
         global $current_station;
         if (is_object($current_station)) {
             $station_id = $current_station->getStation();
         } elseif ($this->getId() != '') {
             $station_id = $this->getId();
         } else {
             Debug::text('Unable to get Station Object! Station ID: ' . $station_id, __FILE__, __LINE__, __METHOD__, 10);
             return FALSE;
         }
     }
     $slf = new StationListFactory();
     $slf->getByUserIdAndStatusAndType($user_id, 'ENABLED', $type);
     Debug::text('Station ID: ' . $station_id . ' Type: ' . $type . ' Found Stations: ' . $slf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     foreach ($slf as $station) {
         Debug::text('Checking Station ID: ' . $station->getId(), __FILE__, __LINE__, __METHOD__, 10);
         if ($station->isAllowed($user_id, $station_id, $station->getId()) === TRUE) {
             Debug::text('Station IS allowed! ' . $station_id . ' - ID: ' . $station->getId(), __FILE__, __LINE__, __METHOD__, 10);
             return TRUE;
         }
     }
     return FALSE;
 }