function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Absence Policy'), NULL, $this->getTable()); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Employee Identification - Employee: ' . $this->getUser() . ' Type: ' . $this->getType()), NULL, $this->getTable()); }
/** * Allows currently logged in user to change their password. * @param string $current_password * @param string $new_password * @param string $new_password2 * @param string $type * @return bool */ function changePassword($current_password, $new_password, $new_password2, $type = 'web') { $ulf = TTnew('UserListFactory'); $ulf->getByIdAndCompanyId($this->getCurrentUserObject()->getId(), $this->getCurrentCompanyObject()->getId()); if ($ulf->getRecordCount() == 1) { $uf = $ulf->getCurrent(); switch (strtolower($type)) { case 'quick_punch': case 'phone': if ($this->getPermissionObject()->Check('user', 'edit_own_phone_password') == FALSE) { return $this->getPermissionObject()->PermissionDenied(); } $log_description = TTi18n::getText('Password - Phone'); if ($current_password != '') { if ($uf->checkPhonePassword($current_password) !== TRUE) { Debug::Text('Password check failed!', __FILE__, __LINE__, __METHOD__, 10); $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect')); } } else { Debug::Text('Current password not specified', __FILE__, __LINE__, __METHOD__, 10); $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect')); } if ($new_password != '' or $new_password2 != '') { if ($new_password == $new_password2) { $uf->setPhonePassword($new_password); } else { $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match')); } } else { $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match')); } break; case 'web': if ($this->getPermissionObject()->Check('user', 'edit_own_password') == FALSE) { return $this->getPermissionObject()->PermissionDenied(); } $log_description = TTi18n::getText('Password - Web'); if ($current_password != '') { if ($uf->checkPassword($current_password) !== TRUE) { Debug::Text('Password check failed!', __FILE__, __LINE__, __METHOD__, 10); $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect')); } } else { Debug::Text('Current password not specified', __FILE__, __LINE__, __METHOD__, 10); $uf->Validator->isTrue('current_password', FALSE, TTi18n::gettext('Current password is incorrect')); } if ($new_password != '' or $new_password2 != '') { if ($new_password == $new_password2) { $uf->setPassword($new_password); } else { $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match')); } } else { $uf->Validator->isTrue('password', FALSE, TTi18n::gettext('Passwords don\'t match')); } break; } if ($uf->isValid()) { if (DEMO_MODE == TRUE) { //Return TRUE even in demo mode, but nothing happens. return $this->returnHandler(TRUE); } else { TTLog::addEntry($this->getCurrentUserObject()->getId(), 20, $log_description, NULL, $uf->getTable()); return $this->returnHandler($uf->Save()); //Single valid record } } else { return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $uf->Validator->getErrorsArray(), array('total_records' => 1, 'valid_records' => 0)); } } return $this->returnHandler(FALSE); }
function addLog($log_action) { return TTLog::addEntry($this->getRecurringScheduleTemplateControl(), $log_action, TTi18n::getText('Recurring Schedule Week') . ': ' . $this->getWeek(), NULL, $this->getTable(), $this); }
$total_days = TTDate::getDays($end_date - $start_date); $offset = 86400 / 2; $init_progress_bar = TRUE; if ($init_progress_bar == TRUE) { InitProgressBar(); $init_progress_bar = FALSE; } $progress_bar->setValue(0); $progress_bar->display(); $apf = TTnew('AccrualPolicyFactory'); $aplf = TTnew('AccrualPolicyListFactory'); $aplf->getByIdAndCompanyId((int) $data['accrual_policy_id'], $current_company->getId()); if ($aplf->getRecordCount() > 0) { foreach ($aplf as $ap_obj) { $aplf->StartTransaction(); TTLog::addEntry($current_user->getId(), 500, 'Recalculate Accrual Policy: ' . $ap_obj->getName() . ' Start Date: ' . TTDate::getDate('TIME', $data['start_date']) . ' End Date: ' . TTDate::getDate('TIME', $data['end_date']) . ' Total Days: ' . round($total_days), $current_user->getId(), $ap_obj->getTable()); $x = 0; for ($i = $start_date; $i < $end_date; $i += 86400) { //$i = TTDate::getBeginDayEpoch( $i ); //This causes infinite loops during DST transitions. Debug::Text('Recalculating Accruals for Date: ' . TTDate::getDate('DATE+TIME', TTDate::getBeginDayEpoch($i)), __FILE__, __LINE__, __METHOD__, 10); $ap_obj->addAccrualPolicyTime(TTDate::getBeginDayEpoch($i), $offset); $progress_bar->setValue(Misc::calculatePercent($x, $total_days)); $progress_bar->display(); $x++; } //$aplf->FailTransaction(); $aplf->CommitTransaction(); } } $progress_bar->setValue(100); $progress_bar->display();
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Employee Default Information'), NULL, $this->getTable()); }
function addLog($log_action) { $u_obj = $this->getUserObject(); if (is_object($u_obj)) { return TTLog::addEntry($this->getHierarchyControl(), $log_action, TTi18n::getText('Suborindate') . ': ' . $u_obj->getFullName(FALSE, TRUE), NULL, $this->getTable()); } return FALSE; }
function generatePayStubs($pay_period_ids, $user_ids = NULL, $enable_correction = FALSE) { global $profiler; Debug::Text('Generate Pay Stubs!', __FILE__, __LINE__, __METHOD__, 10); if (!$this->getPermissionObject()->Check('pay_period_schedule', 'enabled') or !($this->getPermissionObject()->Check('pay_period_schedule', 'edit') or $this->getPermissionObject()->Check('pay_period_schedule', 'edit_own'))) { return $this->getPermissionObject()->PermissionDenied(); } if (!is_array($pay_period_ids)) { $pay_period_ids = array($pay_period_ids); } if ($user_ids !== NULL and !is_array($user_ids) and $user_ids > 0) { $user_ids = array($user_ids); } elseif (is_array($user_ids) and isset($user_ids[0]) and $user_ids[0] == 0) { $user_ids = NULL; } foreach ($pay_period_ids as $pay_period_id) { Debug::text('Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10); $pplf = TTnew('PayPeriodListFactory'); $pplf->getByIdAndCompanyId($pay_period_id, $this->getCurrentCompanyObject()->getId()); $epoch = TTDate::getTime(); foreach ($pplf as $pay_period_obj) { Debug::text('Pay Period Schedule ID: ' . $pay_period_obj->getPayPeriodSchedule(), __FILE__, __LINE__, __METHOD__, 10); if ($pay_period_obj->isPreviousPayPeriodClosed() == TRUE) { //Grab all users for pay period $ppsulf = TTnew('PayPeriodScheduleUserListFactory'); if (is_array($user_ids) and count($user_ids) > 0) { Debug::text('Generating pay stubs for specific users...', __FILE__, __LINE__, __METHOD__, 10); TTLog::addEntry($this->getCurrentCompanyObject()->getId(), 500, TTi18n::gettext('Calculating Company Pay Stubs for Pay Period') . ': ' . $pay_period_id, $this->getCurrentUserObject()->getId(), 'pay_stub'); //Notice $ppsulf->getByCompanyIDAndPayPeriodScheduleIdAndUserID($this->getCurrentCompanyObject()->getId(), $pay_period_obj->getPayPeriodSchedule(), $user_ids); } else { TTLog::addEntry($this->getCurrentCompanyObject()->getId(), 500, TTi18n::gettext('Calculating Employee Pay Stub for Pay Period') . ': ' . $pay_period_id, $this->getCurrentUserObject()->getId(), 'pay_stub'); $ppsulf->getByCompanyIDAndPayPeriodScheduleId($this->getCurrentCompanyObject()->getId(), $pay_period_obj->getPayPeriodSchedule()); } $total_pay_stubs = $ppsulf->getRecordCount(); $this->getProgressBarObject()->start($this->getAMFMessageID(), $total_pay_stubs, NULL, TTi18n::getText('Generating Paystubs...')); //Delete existing pay stub. Make sure we only //delete pay stubs that are the same as what we're creating. $pslf = TTnew('PayStubListFactory'); $pslf->getByPayPeriodId($pay_period_obj->getId()); foreach ($pslf as $pay_stub_obj) { if (is_array($user_ids) and count($user_ids) > 0 and in_array($pay_stub_obj->getUser(), $user_ids) == FALSE) { continue; //Only generating pay stubs for individual employees, skip ones not in the list. } Debug::text('Existing Pay Stub: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); //Check PS End Date to match with PP End Date //So if an ROE was generated, it won't get deleted when they generate all other Pay Stubs //later on. if ($pay_stub_obj->getStatus() <= 25 and $pay_stub_obj->getTainted() === FALSE and TTDate::getMiddleDayEpoch($pay_stub_obj->getEndDate()) == TTDate::getMiddleDayEpoch($pay_period_obj->getEndDate())) { Debug::text('Deleting pay stub: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); $pay_stub_obj->setDeleted(TRUE); $pay_stub_obj->Save(); } else { Debug::text('Pay stub does not need regenerating, or it is LOCKED! ID: ' . $pay_stub_obj->getID() . ' Status: ' . $pay_stub_obj->getStatus() . ' Tainted: ' . (int) $pay_stub_obj->getTainted() . ' Pay Stub End Date: ' . $pay_stub_obj->getEndDate() . ' Pay Period End Date: ' . $pay_period_obj->getEndDate(), __FILE__, __LINE__, __METHOD__, 10); } } $i = 1; foreach ($ppsulf as $pay_period_schdule_user_obj) { Debug::text('Pay Period User ID: ' . $pay_period_schdule_user_obj->getUser(), __FILE__, __LINE__, __METHOD__, 10); Debug::text('Total Pay Stubs: ' . $total_pay_stubs . ' - ' . ceil(1 / (100 / $total_pay_stubs)), __FILE__, __LINE__, __METHOD__, 10); $profiler->startTimer('Calculating Pay Stub'); //Calc paystubs. $cps = new CalculatePayStub(); $cps->setEnableCorrection((bool) $enable_correction); $cps->setUser($pay_period_schdule_user_obj->getUser()); $cps->setPayPeriod($pay_period_obj->getId()); $cps->calculate(); unset($cps); $profiler->stopTimer('Calculating Pay Stub'); $this->getProgressBarObject()->set($this->getAMFMessageID(), $i); //sleep(1); /////////////////////////////// FOR TESTING ONLY ////////////////// $i++; } unset($ppsulf); $this->getProgressBarObject()->stop($this->getAMFMessageID()); } else { UserGenericStatusFactory::queueGenericStatus(TTi18n::gettext('ERROR'), 10, TTi18n::gettext('Pay period prior to %1 is not closed, please close all previous pay periods and try again...', array(TTDate::getDate('DATE', $pay_period_obj->getStartDate()) . ' -> ' . TTDate::getDate('DATE', $pay_period_obj->getEndDate()))), NULL); } } } if (UserGenericStatusFactory::isStaticQueue() == TRUE) { $ugsf = TTnew('UserGenericStatusFactory'); $ugsf->setUser($this->getCurrentUserObject()->getId()); $ugsf->setBatchID($ugsf->getNextBatchId()); $ugsf->setQueue(UserGenericStatusFactory::getStaticQueue()); $ugsf->saveQueue(); $user_generic_status_batch_id = $ugsf->getBatchID(); } else { $user_generic_status_batch_id = FALSE; } unset($ugsf); return $this->returnHandler(TRUE, TRUE, FALSE, FALSE, FALSE, $user_generic_status_batch_id); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Recurring Pay Stub Amendment'), NULL, $this->getTable(), $this); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('TimeSheet Verify'), NULL, $this->getTable()); }
function emailMessage() { Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10); $email_to_arr = $this->getEmailMessageAddresses(); if ($email_to_arr == FALSE) { return FALSE; } //Get from User Object so we can include more information in the message. if (is_object($this->getFromUserObject())) { $u_obj = $this->getFromUserObject(); } else { Debug::Text('From object does not exist: ' . $this->getFromUserID(), __FILE__, __LINE__, __METHOD__, 10); return FALSE; } $from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE); global $current_user, $config_vars; if (is_object($current_user) and $current_user->getWorkEmail() != '') { $reply_to = $current_user->getWorkEmail(); } Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10); $to = array_shift($email_to_arr); Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10); if (is_array($email_to_arr) and count($email_to_arr) > 0) { $bcc = implode(',', $email_to_arr); } else { $bcc = NULL; } Debug::Text('Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10); //Define subject/body variables here. $search_arr = array('#from_employee_first_name#', '#from_employee_last_name#', '#from_employee_default_branch#', '#from_employee_default_department#', '#from_employee_group#', '#from_employee_title#', '#company_name#', '#link#'); $replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL); $email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME; $email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n"; $email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n"; $email_body .= $this->getSubject() != '' ? TTi18n::gettext('Subject') . ': ' . $this->getSubject() . "\n" : NULL; $email_body .= TTi18n::gettext('From') . ': #from_employee_first_name# #from_employee_last_name#' . "\n"; $email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #from_employee_default_branch#' . "\n" : NULL; $email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #from_employee_default_department#' . "\n" : NULL; $email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #from_employee_group#' . "\n" : NULL; $email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #from_employee_title#' . "\n" : NULL; $email_body .= TTi18n::gettext('Link:') . ' <a href="http://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>'; $email_body .= $replace_arr[6] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL; //Always put at the end $subject = str_replace($search_arr, $replace_arr, $email_subject); Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10); $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to); $body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>'; Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10); $mail = new TTMail(); $mail->setTo($to); $mail->setHeaders($headers); @$mail->getMIMEObject()->setHTMLBody($body); $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config)); $retval = $mail->Send(); if ($retval == TRUE) { TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable()); return TRUE; } return TRUE; //Always return true }
function addLog($log_action) { if ($this->getValue() == TRUE) { $value_display = TTi18n::getText('ALLOW'); } else { $value_display = TTi18n::getText('DENY'); } return TTLog::addEntry($this->getPermissionControl(), $log_action, TTi18n::getText('Section') . ': ' . Option::getByKey($this->getSection(), $this->getOptions('section')) . ' Name: ' . Option::getByKey($this->getName(), $this->getOptions('name', $this->getSection())) . ' Value: ' . $value_display, NULL, $this->getTable()); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('System Setting - Name') . ': ' . $this->getName() . ' ' . TTi18n::getText('Value') . ': ' . $this->getValue(), NULL, $this->getTable()); }
function emailException($u_obj, $user_date_obj, $punch_obj = NULL, $schedule_obj = NULL, $ep_obj = NULL) { global $config_vars; if (!is_object($u_obj)) { return FALSE; } if (!is_object($user_date_obj)) { return FALSE; } if (!is_object($ep_obj)) { $ep_obj = $this->getExceptionPolicyObject(); } //Only email on active exceptions. if ($this->getType() != 50) { return FALSE; } $email_to_arr = $this->getEmailExceptionAddresses($u_obj, $ep_obj); if ($email_to_arr == FALSE) { return FALSE; } $from = 'DoNotReply@' . Misc::getHostName(FALSE); $to = array_shift($email_to_arr); if (is_array($email_to_arr) and count($email_to_arr) > 0) { $bcc = implode(',', $email_to_arr); } else { $bcc = NULL; } Debug::Text('To: ' . $to . ' Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10); $protocol = 'http'; if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) { $protocol .= 's'; } //Define subject/body variables here. $search_arr = array('#employee_first_name#', '#employee_last_name#', '#employee_default_branch#', '#employee_default_department#', '#employee_group#', '#employee_title#', '#exception_code#', '#exception_name#', '#exception_severity#', '#date#', '#company_name#', '#link#', '#schedule_start_time#', '#schedule_end_time#', '#schedule_branch#', '#schedule_department#', '#punch_time#'); $replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, $ep_obj->getType(), Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')), Option::getByKey($ep_obj->getSeverity(), $ep_obj->getOptions('severity')), TTDate::getDate('DATE', $user_date_obj->getDateStamp()), is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getStartTime()) : NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getEndTime()) : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getBranchObject())) ? $schedule_obj->getBranchObject()->getName() : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getDepartmentObject())) ? $schedule_obj->getDepartmentObject()->getName() : NULL, is_object($punch_obj) ? TTDate::getDate('TIME', $punch_obj->getTimeStamp()) : NULL); $exception_email_subject = ' #exception_name# (#exception_code#) ' . TTi18n::gettext('exception for') . ' #employee_first_name# #employee_last_name# ' . TTi18n::gettext('on') . ' #date#'; $exception_email_body = TTi18n::gettext('Employee') . ': #employee_first_name# #employee_last_name#' . "\n"; $exception_email_body .= TTi18n::gettext('Date') . ': #date#' . "\n"; $exception_email_body .= TTi18n::gettext('Exception') . ': #exception_name# (#exception_code#)' . "\n"; $exception_email_body .= TTi18n::gettext('Severity') . ': #exception_severity#' . "\n"; $exception_email_body .= ($replace_arr[12] != '' or $replace_arr[13] != '' or $replace_arr[14] != '' or $replace_arr[15] != '' or $replace_arr[16] != '') ? "\n" : NULL; $exception_email_body .= ($replace_arr[12] != '' and $replace_arr[13] != '') ? TTi18n::gettext('Schedule') . ': #schedule_start_time# - #schedule_end_time#' . "\n" : NULL; $exception_email_body .= $replace_arr[14] != '' ? TTi18n::gettext('Schedule Branch') . ': #schedule_branch#' . "\n" : NULL; $exception_email_body .= $replace_arr[15] != '' ? TTi18n::gettext('Schedule Department') . ': #schedule_department#' . "\n" : NULL; if ($replace_arr[16] != '') { $exception_email_body .= TTi18n::gettext('Punch') . ': #punch_time#' . "\n"; } elseif ($replace_arr[12] != '' and $replace_arr[13] != '') { $exception_email_body .= TTi18n::gettext('Punch') . ': ' . TTi18n::gettext('None') . "\n"; } $exception_email_body .= ($replace_arr[2] != '' or $replace_arr[3] != '' or $replace_arr[4] != '' or $replace_arr[5] != '') ? "\n" : NULL; $exception_email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #employee_default_branch#' . "\n" : NULL; $exception_email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #employee_default_department#' . "\n" : NULL; $exception_email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #employee_group#' . "\n" : NULL; $exception_email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #employee_title#' . "\n" : NULL; $exception_email_body .= "\n"; $exception_email_body .= TTi18n::gettext('Link:') . ' <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>'; $exception_email_body .= $replace_arr[10] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL; //Always put at the end $exception_email_body .= "\n\n" . TTi18n::gettext('Email sent') . ': ' . TTDate::getDate('DATE+TIME', time()) . "\n"; $subject = str_replace($search_arr, $replace_arr, $exception_email_subject); //Debug::Text('Subject: '. $subject, __FILE__, __LINE__, __METHOD__,10); $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to); $body = '<pre>' . str_replace($search_arr, $replace_arr, $exception_email_body) . '</pre>'; Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10); $mail = new TTMail(); $mail->setTo($to); $mail->setHeaders($headers); @$mail->getMIMEObject()->setHTMLBody($body); $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config)); $retval = $mail->Send(); if ($retval == TRUE) { TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Exception') . ': ' . Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')) . ' To: ' . $to . ' Bcc: ' . $headers['Bcc'], $u_obj->getID(), $this->getTable()); //Make sure this log entry is assigned to the user triggering the exception so it can be viewed in the audit log. } return TRUE; }
function addLog($log_action) { $object_type = Option::getByKey($this->getObjectType(), Misc::TrimSortPrefix($this->getOptions('object_type'))); return TTLog::addEntry($this->getHierarchyControl(), $log_action, TTi18n::getText('Object') . ': ' . $object_type, NULL, $this->getTable()); }
function addLog($log_action) { $obj = $this->getUserObject(); if (is_object($obj)) { return TTLog::addEntry($this->getCompanyDeduction(), $log_action, TTi18n::getText('Employee Deduction') . ': ' . $obj->getFullName(), NULL, $this->getTable(), $this); } }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Pay Period Schedule'), NULL, $this->getTable()); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Ethnic Group: ') . $this->getName(), NULL, $this->getTable(), $this); }
function addLog($log_action) { if ($this->getUser() == '') { $log_description = TTi18n::getText('Company'); } else { $log_description = TTi18n::getText('Employee'); $u_obj = $this->getUserObject(); if (is_object($u_obj)) { $log_description .= ': ' . $u_obj->getFullName(FALSE, TRUE); } } return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Bank Account') . ' - ' . $log_description, NULL, $this->getTable(), $this); }
function addLog($log_action) { //Don't do detail logging for this, as it will store entire figerprints in the log table. return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Employee Identification - Employee') . ': ' . UserListFactory::getFullNameById($this->getUser()) . ' ' . TTi18n::getText('Type') . ': ' . Option::getByKey($this->getType(), $this->getOptions('type')), NULL, $this->getTable()); }
function addLog($log_action) { $u_obj = $this->getUserObject(); if (is_object($u_obj)) { return TTLog::addEntry($this->getHierarchyControl(), $log_action, TTi18n::getText('Superior') . ': ' . $u_obj->getFullName() . ' ' . TTi18n::getText('Level') . ': ' . $this->getLevel(), NULL, $this->getTable(), $this); } return FALSE; }
function emailMessage() { Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10); $email_to_arr = $this->getEmailMessageAddresses(); if ($email_to_arr == FALSE) { return FALSE; } $from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE); global $current_user, $config_vars; if (is_object($current_user) and $current_user->getWorkEmail() != '') { $reply_to = $current_user->getWorkEmail(); } Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10); $to = array_shift($email_to_arr); Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10); if (is_array($email_to_arr) and count($email_to_arr) > 0) { $bcc = implode(',', $email_to_arr); } else { $bcc = NULL; } $email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME; $email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n"; $email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n"; if ($this->getSubject() != '') { $email_body .= TTi18n::gettext('Subject:') . ' ' . $this->getSubject() . "\n"; } $protocol = 'http'; if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) { $protocol .= 's'; } $email_body .= TTi18n::gettext('Link') . ': <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::getText('Login') . '</a>'; //Define subject/body variables here. $search_arr = array('#employee_first_name#', '#employee_last_name#'); $replace_arr = array(NULL, NULL); $subject = str_replace($search_arr, $replace_arr, $email_subject); Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10); $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to); $body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>'; Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10); $mail = new TTMail(); $mail->setTo($to); $mail->setHeaders($headers); @$mail->getMIMEObject()->setHTMLBody($body); $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config)); $retval = $mail->Send(); if ($retval == TRUE) { TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable()); return TRUE; } return TRUE; //Always return true }
/** * Run manual commands on timeclocks * @param string $command command name * @param array $data station IDs * @return array */ function runManualCommand($command, $data) { if (is_numeric($data)) { $data = array($data); } if (!is_array($data)) { return $this->returnHandler(FALSE); } Debug::Text('Time Clock Command: ' . $command, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Received data for: ' . count($data) . ' Stations', __FILE__, __LINE__, __METHOD__, 10); Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10); $src_rows = $this->stripReturnHandler($this->getStation(array('filter_data' => array('id' => $data)), TRUE)); if (is_array($src_rows) and count($src_rows) > 0) { Debug::Arr($src_rows, 'SRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($src_rows as $key => $row) { //Skip any non-timeclock types. if ($row['type_id'] < 100) { continue; } Debug::Text(' Type: ' . $row['type_id'] . ' Source: ' . $row['source'] . ' Port: ' . $row['port'] . ' Password: '******'password'], __FILE__, __LINE__, __METHOD__, 10); $tc = new TimeClock($row['type_id']); $tc->setIPAddress($row['source']); $tc->setPort($row['port']); //$tc->setUsername( $row['user_name'] ); $tc->setPassword($row['password']); $slf = TTnew('StationListFactory'); $slf->getByIdAndCompanyId($row['id'], $this->getCurrentCompanyObject()->getId()); if ($slf->getRecordCount() == 1) { $s_obj = $slf->getCurrent(); } $s_obj->setLastPunchTimeStamp($s_obj->getLastPunchTimeStamp()); if ($s_obj->getTimeZone() != '' and !is_numeric($s_obj->getTimeZone())) { Debug::text('Setting Station TimeZone To: ' . $s_obj->getTimeZone(), __FILE__, __LINE__, __METHOD__, 10); TTDate::setTimeZone($s_obj->getTimeZone()); } $result_str = NULL; switch ($command) { case 'test_connection': if ($tc->testConnection() == TRUE) { $result_str = TTi18n::gettext('Connection Succeeded!'); } else { $result_str = TTi18n::gettext('Connection Failed!'); } break; case 'set_date': TTDate::setTimeZone($row['time_zone_id'], $s_obj->getTimeZone()); if ($tc->setDate(time()) == TRUE) { $result_str = TTi18n::gettext('Date Successfully Set To: ') . TTDate::getDate('DATE+TIME', time()); } else { $result_str = TTi18n::gettext('Setting Date Failed!'); } break; case 'download': if (isset($s_obj) and $tc->Poll($this->getCurrentCompanyObject(), $s_obj) == TRUE) { $result_str = TTi18n::gettext('Download Data Succeeded!'); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } } else { $result_str = TTi18n::gettext('Download Data Failed!'); } break; case 'upload': if (isset($s_obj) and $tc->Push($this->getCurrentCompanyObject(), $s_obj) == TRUE) { $result_str = TTi18n::gettext('Upload Data Succeeded!'); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } } else { $result_str = TTi18n::gettext('Upload Data Failed!'); } break; case 'update_config': if (isset($s_obj) and $tc->setModeFlag($s_obj->getModeFlag()) == TRUE) { $result_str = TTi18n::gettext('Update Configuration Succeeded'); } else { $result_str = TTi18n::gettext('Update Configuration Failed'); } break; case 'delete_data': if (isset($s_obj) and $tc->DeleteAllData($s_obj) == TRUE) { $result_str = TTi18n::gettext('Delete Data Succeeded!'); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } } else { $result_str = TTi18n::gettext('Delete Data Failed!'); } break; case 'reset_last_punch_time_stamp': $s_obj->setLastPunchTimeStamp(time()); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } $result_str = TTi18n::gettext('Reset Last Punch Time Succeeded!'); break; case 'clear_last_punch_time_stamp': $s_obj->setLastPunchTimeStamp(1); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } $result_str = TTi18n::gettext('Clear Last Punch Time Succeeded!'); break; case 'restart': $tc->restart(); $result_str = TTi18n::gettext('Restart Succeeded!'); break; case 'firmware': if ($tc->setFirmware() == TRUE) { $result_str = TTi18n::gettext('Firmware Update Succeeded!'); } else { $result_str = TTi18n::gettext('Firmware Update Failed!'); } break; default: $result_str = TTi18n::gettext('Invalid manual command!'); break; } TTLog::addEntry($s_obj->getId(), 500, TTi18n::getText('TimeClock Manual Command') . ': ' . ucwords(str_replace('_', ' ', $command)) . ' ' . TTi18n::getText('Result') . ': ' . $result_str, NULL, $s_obj->getTable()); if (isset($s_obj)) { $row['last_poll_date'] = $s_obj->getLastPollDate(); $row['last_push_date'] = $s_obj->getLastPushDate(); } unset($s_obj, $slf); } return $this->returnHandler($result_str); } return $this->returnHandler(FALSE); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Pay Stub Amendment - User ID') . ': ' . $this->getUser() . ' ' . TTi18n::getText('Amount') . ': ' . $this->getAmount(), NULL, $this->getTable()); }
function addLog($log_action) { $u_obj = $this->getUserObject(); if (is_object($u_obj)) { return TTLog::addEntry($this->getStation(), $log_action, TTi18n::getText('Employee') . ': ' . $u_obj->getFullName(FALSE, TRUE), NULL, $this->getTable()); } return FALSE; }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Punch - Employee') . ': ' . $this->getUser() . TTi18n::getText(' Timestamp') . ': ' . TTDate::getDate('DATE+TIME', $this->getTimeStamp()), NULL, $this->getTable()); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Company Deduction'), NULL, $this->getTable()); }
function addLog($log_action) { $kpi_obj = $this->getKPIObject(); if (is_object($kpi_obj)) { return TTLog::addEntry($this->getUserReviewControl(), $log_action, TTi18n::getText('Employee Review KPI') . ' - ' . TTi18n::getText('KPI') . ': ' . $kpi_obj->getName(), NULL, $this->getTable(), $this); } return FALSE; }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('ROE'), NULL, $this->getTable(), $this); }
function addLog($log_action) { $obj = $this->getPayStubEntryAccountObject(); if (is_object($obj)) { $type = Option::getByKey($this->getType(), Misc::TrimSortPrefix($this->getOptions('type'))); return TTLog::addEntry($this->getCompanyDeduction(), $log_action, $type . ' ' . TTi18n::getText('Pay Stub Account') . ': ' . $obj->getName(), NULL, $this->getTable()); } }