function getByCompanyId($company_id, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } $sf = new StationFactory(); $ph = array('company_id' => $company_id); $query = ' select a.* from ' . $this->getTable() . ' as a, ' . $sf->getTable() . ' as b where b.id = a.station_id AND b.company_id = ? '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order); $this->ExecuteSQL($query, $ph); return $this; }
/** * Get or create current PC/Phone station. * @return string */ function getCurrentStation($station_id = NULL, $type_id = 10) { $retval = StationFactory::getOrCreateStation($station_id, $this->getCurrentCompanyObject()->getID(), $type_id); if (is_object($retval) and isset($retval->Validator) and $retval->Validator->isValid() == FALSE) { return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $retval->Validator->getErrorsArray(), array('total_records' => 1, 'valid_records' => 0)); } else { Debug::text('Returning Station ID: ' . $station_id, __FILE__, __LINE__, __METHOD__, 10); return $this->returnHandler($retval); } }
function createStation($company_id) { $sf = new StationFactory(); $sf->setCompany($company_id); $sf->setStatus(20); $sf->setType(10); $sf->setSource('ANY'); $sf->setStation('ANY'); $sf->setDescription('All stations'); $sf->setGroupSelectionType(10); $sf->setBranchSelectionType(10); $sf->setDepartmentSelectionType(10); if ($sf->isValid()) { $insert_id = $sf->Save(); Debug::Text('Station ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); } $sf = new StationFactory(); $sf->setCompany($company_id); $sf->setStatus(20); $sf->setType(25); $sf->setSource('ANY'); $sf->setStation('ANY'); $sf->setDescription('All stations'); $sf->setGroupSelectionType(10); $sf->setBranchSelectionType(10); $sf->setDepartmentSelectionType(10); if ($sf->isValid()) { //$insert_id = $sf->Save(FALSE); //$sf->setUser( array(-1) ); $insert_id = $sf->Save(); Debug::Text('Station ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); return $insert_id; } Debug::Text('Failed Creating Station!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
function postSave() { $this->removeCache($this->getId()); $this->remoteSave(); if ($this->getDeleted() == FALSE) { //Add base currency for this new company. if ($this->getEnableAddCurrency() == TRUE) { $clf = new CurrencyListFactory(); $clf->getByCompanyId($this->getId()); if ($clf->getRecordCount() == 0) { Debug::text('Adding Default Currency', __FILE__, __LINE__, __METHOD__, 9); $cf = new CurrencyFactory(); $country_to_currency_map_arr = $cf->getOptions('country_currency'); if (isset($country_to_currency_map_arr[$this->getCountry()])) { $base_currency = $country_to_currency_map_arr[$this->getCountry()]; Debug::text('Found Base Currency For Country: ' . $this->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9); } else { Debug::text('DID NOT Find Base Currency For Country: ' . $this->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9); $base_currency = 'USD'; } $cf->setCompany($this->getId()); $cf->setStatus(10); $cf->setName($base_currency); $cf->setISOCode($base_currency); $cf->setConversionRate('1.000000000'); $cf->setAutoUpdate(FALSE); $cf->setBase(TRUE); $cf->setDefault(TRUE); if ($cf->isValid()) { $cf->Save(); } } } if ($this->getEnableAddPermissionGroupPreset() == TRUE) { Debug::text('Adding Preset Permission Groups', __FILE__, __LINE__, __METHOD__, 9); $pf = new PermissionFactory(); $pf->StartTransaction(); if ($this->getProductEdition() == 20) { $preset_flags = array('job' => 1, 'invoice' => 1, 'document' => 1); } else { $preset_flags = array(); } $preset_options = $pf->getOptions('preset'); foreach ($preset_options as $preset_id => $preset_name) { $pcf = new PermissionControlFactory(); $pcf->setCompany($this->getId()); $pcf->setName($preset_name); $pcf->setDescription(''); if ($pcf->isValid()) { $pcf_id = $pcf->Save(FALSE); $pf->applyPreset($pcf_id, $preset_id, $preset_flags); } } //$pf->FailTransaction(); $pf->CommitTransaction(); } if ($this->getEnableAddStation() == TRUE) { Debug::text('Adding Default Station', __FILE__, __LINE__, __METHOD__, 9); //Enable punching in from all stations $sf = new StationFactory(); $sf->setCompany($this->getId()); $sf->setStatus(20); $sf->setType(10); $sf->setSource('ANY'); $sf->setStation('ANY'); $sf->setDescription('All stations'); $sf->setGroupSelectionType(10); $sf->setBranchSelectionType(10); $sf->setDepartmentSelectionType(10); if ($sf->isValid()) { $sf->Save(); } } if ($this->getEnableAddPayStubEntryAccountPreset() == TRUE) { Debug::text('Adding Pay Stub Entry Account Presets', __FILE__, __LINE__, __METHOD__, 9); PayStubEntryAccountFactory::addPresets($this->getId()); } if ($this->getEnableAddCompanyDeductionPreset() == TRUE) { Debug::text('Adding Company Deduction Presets', __FILE__, __LINE__, __METHOD__, 9); CompanyDeductionFactory::addPresets($this->getId()); } if ($this->getEnableAddRecurringHolidayPreset() == TRUE) { Debug::text('Adding Recurring Holiday Presets', __FILE__, __LINE__, __METHOD__, 9); RecurringHolidayFactory::addPresets($this->getId(), $this->getCountry()); } } if ($this->getDeleted() == TRUE) { $ulf = new UserListFactory(); $ulf->getByCompanyId($this->getID()); if ($ulf->getRecordCount() > 0) { $ulf->StartTransaction(); foreach ($ulf as $u_obj) { Debug::text('Deleting User ID: ' . $u_obj->getId(), __FILE__, __LINE__, __METHOD__, 9); $u_obj->setDeleted(TRUE); if ($u_obj->isValid()) { $u_obj->Save(); } } $ulf->CommitTransaction(); } } return TRUE; }
function getLastPunchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } if (!is_array($order)) { //Use Filter Data ordering if its set. if (isset($filter_data['sort_column']) and $filter_data['sort_order']) { $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']); } } //$additional_order_fields = array('b.name', 'c.name', 'd.name', 'e.name'); $additional_order_fields = array('b.branch_id', 'c.date_stamp', 'd.last_name', 'a.time_stamp', 'a.status_id', 'b.branch_id', 'b.department_id', 'e.type_id'); if ($order == NULL) { $order = array('b.branch_id' => 'asc', 'd.last_name' => 'asc', 'a.time_stamp' => 'desc', 'a.punch_control_id' => 'asc', 'a.status_id' => 'asc'); $strict = FALSE; } else { $strict = TRUE; } //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10); if (isset($filter_data['exclude_user_ids'])) { $filter_data['exclude_id'] = $filter_data['exclude_user_ids']; } if (isset($filter_data['include_user_ids'])) { $filter_data['id'] = $filter_data['include_user_ids']; } if (isset($filter_data['user_status_ids'])) { $filter_data['status_id'] = $filter_data['user_status_ids']; } if (isset($filter_data['user_title_ids'])) { $filter_data['title_id'] = $filter_data['user_title_ids']; } if (isset($filter_data['group_ids'])) { $filter_data['group_id'] = $filter_data['group_ids']; } if (isset($filter_data['branch_ids'])) { $filter_data['default_branch_id'] = $filter_data['branch_ids']; } if (isset($filter_data['department_ids'])) { $filter_data['default_department_id'] = $filter_data['department_ids']; } if (isset($filter_data['punch_branch_ids'])) { $filter_data['punch_branch_id'] = $filter_data['punch_branch_ids']; } if (isset($filter_data['punch_department_ids'])) { $filter_data['punch_department_id'] = $filter_data['punch_department_ids']; } if (isset($filter_data['exclude_job_ids'])) { $filter_data['exclude_id'] = $filter_data['exclude_job_ids']; } if (isset($filter_data['include_job_ids'])) { $filter_data['include_job_id'] = $filter_data['include_job_ids']; } if (isset($filter_data['job_group_ids'])) { $filter_data['job_group_id'] = $filter_data['job_group_ids']; } if (isset($filter_data['job_item_ids'])) { $filter_data['job_item_id'] = $filter_data['job_item_ids']; } $uf = new UserFactory(); $udf = new UserDateFactory(); $pcf = new PunchControlFactory(); $sf = new StationFactory(); if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) { $jf = new JobFactory(); $jif = new JobItemFactory(); } $ph = array('company_id' => $company_id); $query = ' select a.id as punch_id, a.punch_control_id as punch_control_id, a.type_id as type_id, a.status_id as status_id, a.time_stamp as time_stamp, a.actual_time_stamp as actual_time_stamp, b.user_date_id as user_date_id, c.date_stamp as date_stamp, b.branch_id as branch_id, b.department_id as department_id, b.job_id as job_id, b.job_item_id as job_item_id, b.note as note, c.user_id as user_id, e.type_id as station_type_id, e.station_id as station_station_id, e.source as station_source, e.description as station_description from ' . $this->getTable() . ' as a LEFT JOIN ' . $pcf->getTable() . ' as b ON a.punch_control_id = b.id LEFT JOIN ' . $udf->getTable() . ' as c ON b.user_date_id = c.id LEFT JOIN ' . $uf->getTable() . ' as d ON c.user_id = d.id LEFT JOIN ' . $sf->getTable() . ' as e ON a.station_id = e.id LEFT JOIN ( select tmp2_d.id, max(tmp2_a.time_stamp) as max_punch_time_stamp from ' . $this->getTable() . ' as tmp2_a LEFT JOIN ' . $pcf->getTable() . ' as tmp2_b ON tmp2_a.punch_control_id = tmp2_b.id LEFT JOIN ' . $udf->getTable() . ' as tmp2_c ON tmp2_b.user_date_id = tmp2_c.id LEFT JOIN ' . $uf->getTable() . ' as tmp2_d ON tmp2_c.user_id = tmp2_d.id WHERE tmp2_d.company_id = ?'; if (isset($filter_data['start_date']) and trim($filter_data['start_date']) != '') { $ph[] = $this->db->BindDate($filter_data['start_date']); $query .= ' AND tmp2_c.date_stamp >= ?'; } if (isset($filter_data['end_date']) and trim($filter_data['end_date']) != '') { $ph[] = $this->db->BindDate($filter_data['end_date']); $query .= ' AND tmp2_c.date_stamp <= ?'; } $query .= ' AND tmp2_a.time_stamp is not null AND ( tmp2_a.deleted = 0 AND tmp2_b.deleted = 0 AND tmp2_c.deleted = 0 ) group by tmp2_d.id ) as tmp2 ON c.user_id = tmp2.id AND a.time_stamp = tmp2.max_punch_time_stamp '; if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) { $query .= ' LEFT JOIN ' . $jf->getTable() . ' as x ON b.job_id = x.id'; $query .= ' LEFT JOIN ' . $jif->getTable() . ' as y ON b.job_item_id = y.id'; } $ph[] = $company_id; $query .= ' WHERE tmp2.id IS NOT NULL AND d.company_id = ?'; if (isset($filter_data['permission_children_ids']) and isset($filter_data['permission_children_ids'][0]) and !in_array(-1, (array) $filter_data['permission_children_ids'])) { $query .= ' AND d.id in (' . $this->getListSQL($filter_data['permission_children_ids'], $ph) . ') '; } if (isset($filter_data['id']) and isset($filter_data['id'][0]) and !in_array(-1, (array) $filter_data['id'])) { $query .= ' AND d.id in (' . $this->getListSQL($filter_data['id'], $ph) . ') '; } if (isset($filter_data['exclude_id']) and isset($filter_data['exclude_id'][0]) and !in_array(-1, (array) $filter_data['exclude_id'])) { $query .= ' AND d.id not in (' . $this->getListSQL($filter_data['exclude_id'], $ph) . ') '; } if (isset($filter_data['status_id']) and isset($filter_data['status_id'][0]) and !in_array(-1, (array) $filter_data['status_id'])) { $query .= ' AND d.status_id in (' . $this->getListSQL($filter_data['status_id'], $ph) . ') '; } if (isset($filter_data['group_id']) and isset($filter_data['group_id'][0]) and !in_array(-1, (array) $filter_data['group_id'])) { if (isset($filter_data['include_subgroups']) and (bool) $filter_data['include_subgroups'] == TRUE) { $uglf = new UserGroupListFactory(); $filter_data['group_id'] = $uglf->getByCompanyIdAndGroupIdAndSubGroupsArray($company_id, $filter_data['group_id'], TRUE); } $query .= ' AND d.group_id in (' . $this->getListSQL($filter_data['group_id'], $ph) . ') '; } if (isset($filter_data['default_branch_id']) and isset($filter_data['default_branch_id'][0]) and !in_array(-1, (array) $filter_data['default_branch_id'])) { $query .= ' AND d.default_branch_id in (' . $this->getListSQL($filter_data['default_branch_id'], $ph) . ') '; } if (isset($filter_data['default_department_id']) and isset($filter_data['default_department_id'][0]) and !in_array(-1, (array) $filter_data['default_department_id'])) { $query .= ' AND d.default_department_id in (' . $this->getListSQL($filter_data['default_department_id'], $ph) . ') '; } if (isset($filter_data['title_id']) and isset($filter_data['title_id'][0]) and !in_array(-1, (array) $filter_data['title_id'])) { $query .= ' AND d.title_id in (' . $this->getListSQL($filter_data['title_id'], $ph) . ') '; } if (isset($filter_data['punch_branch_id']) and isset($filter_data['punch_branch_id'][0]) and !in_array(-1, (array) $filter_data['punch_branch_id'])) { $query .= ' AND b.branch_id in (' . $this->getListSQL($filter_data['punch_branch_id'], $ph) . ') '; } if (isset($filter_data['punch_department_id']) and isset($filter_data['punch_department_id'][0]) and !in_array(-1, (array) $filter_data['punch_department_id'])) { $query .= ' AND b.department_id in (' . $this->getListSQL($filter_data['punch_department_id'], $ph) . ') '; } //Use the job_id in the punch_control table so we can filter by '0' or No Job if (isset($filter_data['include_job_id']) and isset($filter_data['include_job_id'][0]) and !in_array(-1, (array) $filter_data['include_job_id'])) { $query .= ' AND b.job_id in (' . $this->getListSQL($filter_data['include_job_id'], $ph) . ') '; } if (isset($filter_data['exclude_job_id']) and isset($filter_data['exclude_job_id'][0]) and !in_array(-1, (array) $filter_data['exclude_job_id'])) { $query .= ' AND b.job_id not in (' . $this->getListSQL($filter_data['exclude_job_id'], $ph) . ') '; } if (isset($filter_data['job_group_id']) and isset($filter_data['job_group_id'][0]) and !in_array(-1, (array) $filter_data['job_group_id'])) { if (isset($filter_data['include_job_subgroups']) and (bool) $filter_data['include_job_subgroups'] == TRUE) { $uglf = new UserGroupListFactory(); $filter_data['job_group_id'] = $uglf->getByCompanyIdAndGroupIdAndjob_subgroupsArray($company_id, $filter_data['job_group_id'], TRUE); } $query .= ' AND x.group_id in (' . $this->getListSQL($filter_data['job_group_id'], $ph) . ') '; } if (isset($filter_data['job_item_id']) and isset($filter_data['job_item_id'][0]) and !in_array(-1, (array) $filter_data['job_item_id'])) { $query .= ' AND b.job_item_id in (' . $this->getListSQL($filter_data['job_item_id'], $ph) . ') '; } if (isset($filter_data['start_date']) and trim($filter_data['start_date']) != '') { /* $ph[] = $this->db->BindDate($filter_data['start_date']); $query .= ' AND c.date_stamp >= ?'; */ $ph[] = $this->db->BindTimeStamp($filter_data['start_date']); $query .= ' AND a.time_stamp >= ?'; } if (isset($filter_data['end_date']) and trim($filter_data['end_date']) != '') { $ph[] = $this->db->BindTimeStamp($filter_data['end_date']); $query .= ' AND a.time_stamp <= ?'; } //The Transfer where clause is an attempt to keep transferred punches from appearing twice. $query .= ' AND ( a.transfer = 0 OR ( a.transfer = 1 AND a.status_id = 10) ) AND ( a.deleted = 0 AND b.deleted =0 AND c.deleted = 0 AND d.deleted = 0 ) '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict, $additional_order_fields); $this->ExecuteSQL($query, $ph, $limit, $page); return $this; }
function getByCompanyIDAndStationIDAndStatusAndEmployeeNumber($company_id, $station_id, $status_id, $employee_number, $limit = NULL, $page = NULL, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } if ($station_id == '') { return FALSE; } if ($status_id == '') { return FALSE; } if ($order == NULL) { $order = array('a.id' => 'asc'); $strict = FALSE; } else { $strict = TRUE; } $sf = new StationFactory(); $sugf = new StationUserGroupFactory(); $sbf = new StationBranchFactory(); $sdf = new StationDepartmentFactory(); $siuf = new StationIncludeUserFactory(); $seuf = new StationExcludeUserFactory(); $uif = new UserIdentificationFactory(); $ph = array('company_id' => $company_id, 'station_id' => $station_id, 'status_id' => $status_id, 'employee_number' => $employee_number); //Also include users with user_identifcation rows that have been *created* after the given date //so the first supervisor/admin enrolled on a timeclock is properly updated to lock the menu. $query = ' select a.* from ' . $this->getTable() . ' as a LEFT JOIN ' . $sf->getTable() . ' as z ON (1=1) where a.company_id = ? AND z.id = ? AND a.status_id = ? AND a.employee_number = ? AND ( ( ( ( ( z.user_group_selection_type_id = 10 OR ( z.user_group_selection_type_id = 20 AND a.group_id in ( select b.group_id from ' . $sugf->getTable() . ' as b WHERE z.id = b.station_id ) ) OR ( z.user_group_selection_type_id = 30 AND a.group_id not in ( select b.group_id from ' . $sugf->getTable() . ' as b WHERE z.id = b.station_id ) ) ) AND ( z.branch_selection_type_id = 10 OR ( z.branch_selection_type_id = 20 AND a.default_branch_id in ( select c.branch_id from ' . $sbf->getTable() . ' as c WHERE z.id = c.station_id ) ) OR ( z.branch_selection_type_id = 30 AND a.default_branch_id not in ( select c.branch_id from ' . $sbf->getTable() . ' as c WHERE z.id = c.station_id ) ) ) AND ( z.department_selection_type_id = 10 OR ( z.department_selection_type_id = 20 AND a.default_department_id in ( select d.department_id from ' . $sdf->getTable() . ' as d WHERE z.id = d.station_id ) ) OR ( z.department_selection_type_id = 30 AND a.default_department_id not in ( select d.department_id from ' . $sdf->getTable() . ' as d WHERE z.id = d.station_id ) ) ) AND a.id not in ( select f.user_id from ' . $seuf->getTable() . ' as f WHERE z.id = f.station_id ) ) OR a.id in ( select e.user_id from ' . $siuf->getTable() . ' as e WHERE z.id = e.station_id ) ) ) ) '; $query .= ' AND ( a.deleted = 0 AND z.deleted = 0 )'; //Debug::Arr($ph, 'Query: '. $query, __FILE__, __LINE__, __METHOD__,10); $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict); $this->ExecuteSQL($query, $ph, $limit, $page); return $this; }
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; }
function getByCompanyIDAndStationIDAndStatusAndDate($company_id, $station_id, $status_id, $date = NULL, $limit = NULL, $page = NULL, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } if ($station_id == '') { return FALSE; } if ($status_id == '') { return FALSE; } if ($date == '') { $date = 0; } if ($order == NULL) { $order = array('a.last_name' => 'asc'); $strict = FALSE; } else { $strict = TRUE; } $sf = new StationFactory(); $sugf = new StationUserGroupFactory(); $sbf = new StationBranchFactory(); $sdf = new StationDepartmentFactory(); $siuf = new StationIncludeUserFactory(); $seuf = new StationExcludeUserFactory(); $ph = array('company_id' => $company_id, 'station_id' => $station_id, 'status_id' => $status_id, 'date' => $date, 'date2' => $date); $query = ' select a.* from ' . $this->getTable() . ' as a, ' . $sf->getTable() . ' as z where a.company_id = ? AND z.id = ? AND a.status_id = ? AND ( ( ( z.user_group_selection_type_id = 10 OR ( z.user_group_selection_type_id = 20 AND a.group_id in ( select b.group_id from ' . $sugf->getTable() . ' as b WHERE z.id = b.station_id ) ) OR ( z.user_group_selection_type_id = 30 AND a.group_id not in ( select b.group_id from ' . $sugf->getTable() . ' as b WHERE z.id = b.station_id ) ) ) AND ( z.branch_selection_type_id = 10 OR ( z.branch_selection_type_id = 20 AND a.default_branch_id in ( select c.branch_id from ' . $sbf->getTable() . ' as c WHERE z.id = c.station_id ) ) OR ( z.branch_selection_type_id = 30 AND a.default_branch_id not in ( select c.branch_id from ' . $sbf->getTable() . ' as c WHERE z.id = c.station_id ) ) ) AND ( z.department_selection_type_id = 10 OR ( z.department_selection_type_id = 20 AND a.default_department_id in ( select d.department_id from ' . $sdf->getTable() . ' as d WHERE z.id = d.station_id ) ) OR ( z.department_selection_type_id = 30 AND a.default_department_id not in ( select d.department_id from ' . $sdf->getTable() . ' as d WHERE z.id = d.station_id ) ) ) AND a.id not in ( select f.user_id from ' . $seuf->getTable() . ' as f WHERE z.id = f.station_id ) ) OR a.id in ( select e.user_id from ' . $siuf->getTable() . ' as e WHERE z.id = e.station_id ) ) AND ( a.created_date >= ? OR a.updated_date >= ? ) AND ( a.deleted = 0 AND z.deleted = 0 )'; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict); //Debug::text('Query: '. $query, __FILE__, __LINE__, __METHOD__, 10); if ($limit == NULL) { $this->rs = $this->db->Execute($query, $ph); } else { $this->rs = $this->db->PageExecute($query, $limit, $page, $ph); } return $this; }
function postSave() { $this->removeCache($this->getId()); if ($this->getDeleted() == TRUE) { Debug::Text('UnAssign Hours from Branch: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10); //Unassign hours from this branch. $pcf = new PunchControlFactory(); $udtf = new UserDateTotalFactory(); $uf = new UserFactory(); $sf = new StationFactory(); $sf_b = new ScheduleFactory(); $udf = new UserDefaultFactory(); $rstf = new RecurringScheduleTemplateFactory(); $query = 'update ' . $pcf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId(); $this->db->Execute($query); $query = 'update ' . $udtf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId(); $this->db->Execute($query); $query = 'update ' . $sf_b->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId(); $this->db->Execute($query); $query = 'update ' . $uf->getTable() . ' set default_branch_id = 0 where company_id = ' . $this->getCompany() . ' AND default_branch_id = ' . $this->getId(); $this->db->Execute($query); $query = 'update ' . $udf->getTable() . ' set default_branch_id = 0 where company_id = ' . $this->getCompany() . ' AND default_branch_id = ' . $this->getId(); $this->db->Execute($query); $query = 'update ' . $sf->getTable() . ' set branch_id = 0 where company_id = ' . $this->getCompany() . ' AND branch_id = ' . $this->getId(); $this->db->Execute($query); $query = 'update ' . $rstf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId(); $this->db->Execute($query); } return TRUE; }
* $Id: EditStationUser.php 1246 2007-09-14 23:47:42Z ipso $ * $Date: 2007-09-14 16:47:42 -0700 (Fri, 14 Sep 2007) $ */ require_once '../../includes/global.inc.php'; require_once Environment::getBasePath() . 'includes/Interface.inc.php'; if (!$permission->Check('station', 'enabled') or !$permission->Check('station', 'assign')) { $permission->Redirect(FALSE); //Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Edit Station')); // See index.php /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'id', 'station_data'))); $sf = new StationFactory(); $action = Misc::findSubmitButton(); switch ($action) { case 'submit': 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'];
* $Id: EditStation.php 2904 2009-10-16 18:04:09Z ipso $ * $Date: 2009-10-16 11:04:09 -0700 (Fri, 16 Oct 2009) $ */ require_once '../../includes/global.inc.php'; require_once Environment::getBasePath() . 'includes/Interface.inc.php'; if (!$permission->Check('station', 'enabled') or !($permission->Check('station', 'edit') or $permission->Check('station', 'edit_own'))) { $permission->Redirect(FALSE); //Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Edit Station')); // See index.php /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'id', 'data'))); $sf = new StationFactory(); $action = Misc::findSubmitButton(); switch ($action) { case 'submit': //Debug::setVerbosity(11); Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); $sf->StartTransaction(); $sf->setId($data['id']); $sf->setCompany($current_company->getId()); $sf->setStatus($data['status']); $sf->setType($data['type']); $sf->setSource($data['source']); $sf->setStation($data['station']); $sf->setDescription($data['description']); if (isset($data['port'])) { $sf->setPort($data['port']);
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); $create_new_station = TRUE; } } else { $create_new_station = TRUE; } if ($create_new_station == TRUE) { //Insert new station $sf = new StationFactory(); $sf->setCompany($current_company->getId()); $sf->setStatus('ENABLED'); $sf->setType('PC'); $sf->setSource($_SERVER['REMOTE_ADDR']); $sf->setStation(); $sf->setDescription(substr($_SERVER['HTTP_USER_AGENT'], 0, 250)); if ($sf->Save(FALSE)) { $sf->setCookie(); } } Redirect::Page(URLBuilder::getURL(NULL, 'index.php')); } else { $error_message = TTi18n::gettext('User Name or Password is incorrect'); //Get company status from user_name, so we can display messages for ONHOLD/Cancelled accounts. $clf = new CompanyListFactory();