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;
 }
示例#2
0
     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.
         $plf = new PunchListFactory();
         $plf->getPreviousPunchByPunchControlID($punch_control_id);
 function isAllowed($user_id = NULL, $current_station_id = NULL, $id = NULL)
 {
     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 ($current_station_id == NULL or $current_station_id == '') {
         global $current_station;
         $current_station_id = $current_station->getStation();
     }
     //Debug::text('Station ID: '. $current_station_id, __FILE__, __LINE__, __METHOD__, 10);
     //Debug::text('Status: '. $this->getStatus(), __FILE__, __LINE__, __METHOD__, 10);
     if ($this->getStatus() != 20) {
         //Enabled
         return FALSE;
     }
     $retval = FALSE;
     Debug::text('User ID: ' . $user_id . ' Station ID: ' . $current_station_id . ' Status: ' . $this->getStatus() . ' Current Station: ' . $this->getStation(), __FILE__, __LINE__, __METHOD__, 10);
     //Handle IP Addresses/Hostnames
     if ($this->getType() == 10 and !in_array(strtolower($this->getSource()), $this->getOptions('source_reserved_word'))) {
         if (strpos($this->getSource(), ',') !== FALSE) {
             //Found list
             $source = explode(',', $this->getSource());
         } else {
             //Found single entry
             $source[] = $this->getSource();
         }
         if (is_array($source)) {
             foreach ($source as $tmp_source) {
                 if ($this->checkSource($tmp_source, $current_station_id) == TRUE) {
                     $retval = TRUE;
                     break;
                 }
             }
             unset($tmp_source);
         }
     } else {
         $source = $this->getSource();
         $retval = $this->checkSource($source, $current_station_id);
     }
     //Debug::text('Retval: '. (int)$retval, __FILE__, __LINE__, __METHOD__, 10);
     //Debug::text('Current Station ID: '. $current_station_id .' Station ID: '. $this->getStation(), __FILE__, __LINE__, __METHOD__, 10);
     if ($retval === TRUE) {
         Debug::text('Station IS allowed! ', __FILE__, __LINE__, __METHOD__, 10);
         //Set last allowed date, so we can track active/inactive stations.
         if ($id != NULL and $id != '') {
             $slf = new StationListFactory();
             $slf->getById($id);
             foreach ($slf as $station_obj) {
                 $station_obj->setAllowedDate();
                 $station_obj->Save();
                 Debug::text('Updating last allowed time for station.', __FILE__, __LINE__, __METHOD__, 10);
             }
             unset($slf, $station_obj);
             TTLog::addEntry($id, 'Allow', TTi18n::getText('Access from station Allowed'), $user_id, $this->getTable());
         }
         return TRUE;
     }
     Debug::text('Station IS NOT allowed! ', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }