function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Recurring Pay Stub Amendment'), NULL, $this->getTable(), $this); }
/** * 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); }
$tsess = TTGenid::getbypid($touser); $ftu = new TTUser($fsess['id']); $ttu = new TTUser($tsess['id']); $att = $tsess['authat']; $ut = $tsess['ut']; $gemd = $tsess['gemd']; if ($link['gift']) { $lg = $link['gift']; } else { $lg = 0; } $new = 0; if ($_REQUEST['new']) { $new = 1; } TTLog::record(array('m' => 'accept_invite', 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $fromuser, 'sp1' => $lg, 'sp2' => $new, 'intp1' => $touser)); //$tudata=$ftu->getf(array('name','icon')); $getted = $link['geted']; $ids = $link['ids']; $got = false; $invite = false; if (strtotime($link['date']) < strtotime('20100906')) { foreach ($ids as $id) { if ($id == $touser) { $invite = true; break; } } foreach ($getted as $u => $v) { if ($u == $touser) { $got = true;
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('Company Deduction'), NULL, $this->getTable()); }
<?php require_once 'ttserver/test_config.php'; //璁板綍鏃ュ織 $m = $_GET['m']; if ($m) { $_GET['tm'] = $_SERVER['REQUEST_TIME']; TTLog::record($_GET); }
/** * 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('Punch - Employee') . ': ' . $this->getUser() . TTi18n::getText(' Timestamp') . ': ' . TTDate::getDate('DATE+TIME', $this->getTimeStamp()), NULL, $this->getTable()); }
/** * 更新帮助获取物品 * @param tag fid * @return one or a array of help open objects */ public function update_help($tag, $fid) { $oid = $this->getoid($tag, 'ho'); $obj = $this->getbyid($oid); $now = $_SERVER['REQUEST_TIME']; $obj['help'][$fid] = $now; $obj['id'] = $oid; TTLog::record(array('s' => 'OK', 'm' => __METHOD__, 'tm' => $now, 'sp1' => $tag, 'intp1' => $fid)); $this->puto($obj); }
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 }
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) { //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) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Ethnic Group: ') . $this->getName(), NULL, $this->getTable(), $this); }
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) { $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 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; }
protected function _handle(&$req) { //just add method map here $method = $req['m']; $mypre = $method; if ($this->_debug) { CrabTools::mydump($req['p'], REQ_DATA_ROOT . $mypre . '.param'); } if (isset(self::$exist_methods[$method])) { $caller =& self::$exist_methods[$method]; $c =& $caller[0]; $m = $caller[1]; } else { $caller = explode('.', $method); $cn = $caller[0]; $m = $caller[1]; $file = CONTROLLER_ROOT . "{$cn}.php"; if (!file_exists($file)) { throw new JsonServerExecption("method {$method} file not exist:(" . CONTROLLER_ROOT . "{$cn}.php)"); } @(require_once $file); $c = new $cn(); if (!method_exists($c, $m)) { throw new JsonServerExecption("{$cn} don't has callable method {$m}"); } } $log_method = array('Achieve.get' => 1, 'Achieve.finish' => 1, 'Advert.buy' => 1, 'Advert.set' => 1, 'Cinema.enter' => 1, 'Cinema.pick' => 1, 'Gift.send' => 1, 'Gift.accept' => 1, 'Man.update' => 1, 'UserController.login' => 1, 'UserController.precheckout' => 1, 'UserController.update_friends' => 1, 'UserController.enlarge_mall' => 1, 'ItemController.buy' => 1, 'ItemController.sale' => 1, 'CarController.buy' => 1, 'CarController.sale' => 1, 'CarController.go_goods' => 1, 'CarController.enlarge_garage' => 1, 'GoodsController.buy' => 1, 'GoodsController.remove' => 1, 'GoodsController.exhibit_goods' => 1, 'GoodsController.checkshop' => 1, 'GoodsController.checkout' => 1, 'TaskController.share' => 1, 'TaskController.request' => 1, 'TaskController.accept' => 1, 'TaskController.update' => 1, 'TaskController.finish' => 1, 'TaskController.get_award' => 1, 'Friend.dis_neighbor' => 1, 'Friend.invite_neighbor' => 1, 'Friend.accept_neighbor' => 1); $ret = $c->{$m}($req['p']); if ($this->_debug) { CrabTools::myprint($ret, REQ_DATA_ROOT . $mypre . '.resp'); } if (!$ret) { $ret['s'] = "KO"; $ret['msg'] = "{$cn}::{$m} return null"; } if ($ret['s'] == 'OK') { if (array_key_exists($method, $log_method)) { TTLog::record(array('m' => $method, 'p' => json_encode($params))); } } return $ret; }
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) { return TTLog::addEntry($this->getRecurringScheduleTemplateControl(), $log_action, TTi18n::getText('Recurring Schedule Week') . ': ' . $this->getWeek(), NULL, $this->getTable(), $this); }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Pay Period Schedule'), NULL, $this->getTable()); }
$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) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Employee Identification - Employee: ' . $this->getUser() . ' Type: ' . $this->getType()), NULL, $this->getTable()); }
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); }
/** * 捡钱并结算 * @param $params * require u -- 玩家id * sid -- shop id 不仅限于cinema * @return * s -- OK */ public function pick($params) { $uid = $params['u']; $sid = $params['sid']; $now = time(); $tu = new TTUser($uid); $shop_obj = $tu->getbyid($sid); // $ret['now'] = $now; //for debug // $ret['fnow'] = date( TM_FORMAT,$now ); //for debug // $ret['bshopobj'] = $shop_obj; //for debug // $ret['fbshopobj'] = date( TM_FORMAT,$shop_obj['ctime'] ); //for debug if (!$shop_obj) { $ret['s'] = 'notexist'; return $ret; } $item = ItemConfig::getItem($shop_obj['tag']); if (!$item) { $ret['s'] = 'itemnotexsit'; return $ret; } if ($shop_obj['tag'] == '60102') { //电影院 if ($now - $shop_obj['ctime'] < $item['selltime'] * 60) { //坐满30个才开映,再过2小时才放映结束 $ret['s'] = 'time'; return $ret; } $money = $item['sellmoney']; $shop_obj['ctime'] = $now; } elseif ($shop_obj['tag'] == '60103' || $shop_obj['tag'] == '60104') { //健身房和按摩店 if ($now - $shop_obj['ctime'] < $item['settletime']) { //开业时间需满足一定条件才可以收钱 $ret['s'] = 'time'; return $ret; } $money = $item['sellmoney']; $shop_obj['ctime'] = $now; } elseif ($shop_obj['tag'] == '60105' || $shop_obj['tag'] == '60106') { //月巴克和8-11便利店 if ($now - $shop_obj['ctime'] < 3600) { //开业1小时后就可以收钱,但最多只能积累6~9小时 $ret['s'] = 'time'; return $ret; } $gap = $now - $shop_obj['ctime']; $factor = floor($gap / 3600); $money = $factor * $item['sellmoney']; $shop_obj['ctime'] += $factor * 3600; if ($gap > $item['settletime']) { $money = floor($item['settletime'] / 3600) * $item['sellmoney']; // $shop_obj['ctime'] += floor( $gap/3600 ) * 3600; $shop_obj['ctime'] = $now; } } $tu->chMoney($money); $tu->puto($shop_obj, TT::CINEMA_GROUP); // $ret['fashopobj'] = date( TM_FORMAT,$shop_obj['ctime'] ); //for debug // $ret['ashopobj'] = $shop_obj; //for debug TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $money, 'sp1' => $shop_obj['ctime'])); $ret['money'] = $money; $ret['s'] = 'OK'; return $ret; }
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; }
protected function _handle(&$req) { //just add method map here $method = $req['m']; $mypre = $method; if ($this->_debug) { CrabTools::mydump($req['p'], REQ_DATA_ROOT . $mypre . '.param'); } if (isset(self::$exist_methods[$method])) { $caller =& self::$exist_methods[$method]; $c =& $caller[0]; $m = $caller[1]; } else { $caller = explode('.', $method); $cn = $caller[0]; $m = $caller[1]; $file = CONTROLLER_ROOT . "{$cn}.php"; if (!file_exists($file)) { throw new JsonServerExecption("method {$method} file not exist:(" . CONTROLLER_ROOT . "{$cn}.php)"); } @(require_once $file); $c = new $cn(); if (!method_exists($c, $m)) { throw new JsonServerExecption("{$cn} don't has callable method {$m}"); } } $log_method = array('Achieve.finish' => 1, 'Advert.buy' => 1, 'Advert.set' => 1, 'Cinema.enter' => 1, 'Cinema.pick' => 1, 'Gift.send' => 1, 'Gift.accept' => 1, 'Man.update' => 1, 'UserController.update_friends' => 1, 'UserController.enlarge_mall' => 1, 'ItemController.buy' => 1, 'ItemController.sale' => 1, 'CarController.buy' => 1, 'CarController.sale' => 1, 'CarController.go_goods' => 1, 'CarController.enlarge_garage' => 1, 'CarController.buy_copolit' => 1, 'CarController.apply_copolit' => 1, 'GoodsController.checkout' => 1, 'Task.share' => 1, 'Task.request' => 1, 'Task.accept' => 1, 'Task.update' => 1, 'Task.finish' => 1, 'Task.get_award' => 1, 'Friend.dis_neighbor' => 1, 'HelpGet.award' => 1); try { $ret = $c->{$m}($req['p']); } catch (Exception $e) { $r['s'] = 'exc'; $r['msg'] = $e->getMessage(); $r['exce'] = $e->getTrace(); error_log($method . ':' . $r['msg']); TTLog::record(array('s' => $ret['s'], 'm' => $method, 'tm' => $_SERVER['REQUEST_TIME'], 'p' => $this->_raw_reg)); } if ($this->_debug) { CrabTools::myprint($ret, REQ_DATA_ROOT . $mypre . '.resp'); } if (!$ret) { $ret['s'] = "KO"; $ret['msg'] = "{$cn}::{$m} return null"; TTLog::record(array('s' => 'rnull', 'm' => $method, 'tm' => $tm, 'p' => $this->_raw_reg)); } $tm = $_SERVER['REQUEST_TIME']; if ($ret['s'] == 'OK') { if (array_key_exists($method, $log_method)) { TTLog::record(array('s' => 'OK', 'm' => $method, 'tm' => $tm, 'p' => $this->_raw_reg)); } } //else{ // TTLog::record(array('s'=>$ret['s'],'m'=>$method,'tm'=>$tm,'p'=>$this->_raw_reg)); //} return $ret; }
/** * update * @param $params * require u -- user * step -- 新手步数 * // v -- view * // d -- do * @return * s -- OK ,or other fail * money -- total money * exp -- total exp * award money exp items(物品对象数组) * d --新的manual对象 */ public function update($params) { $uid = $params['u']; //$da = $params['d']; $step = $params['step']; //$v = ;//$da['v']; $d = 1; //;$da['d']; $ret = array(); $conf = self::getAwardConf($step); if (!$v && !$d) { $ret['s'] = 'noaction'; return $ret; } if (!$conf) { $ret['s'] = 'noconf'; return $ret; } $tu = new TTUser($uid); $id = $tu->getoid('mannual', TT::OTHER_GROUP); $mano = $tu->getbyid($id); $mean_gap = 20; $now = time(); $mano['id'] = $id; $level = $tu->getLevel(); if ($level > $conf['maxlevel']) { $ret['s'] = 'level'; $ret['d'] = $mano; //return $ret; } if ($v && $mano[$step]['vtime'] > 0) { $ret['s'] = 'already'; $ret['d'] = $mano; return $ret; } if ($d && $mano[$step]['dtime'] > 0) { $ret['s'] = 'already'; $ret['d'] = $mano; return $ret; // } $award = array(); if ($v) { $mano[$step]['vtime'] = $now; $m = $conf['v_money']; if ($m > 0) { $ret['money'] = $tu->chMoney($m); $award['money'] = $m; } $m = $conf['v_gem']; if ($m > 0) { $ret['gem'] = $tu->chGem($m); $award['gem'] = $m; } $m = $conf['v_exp']; if ($m > 0) { $ret['exp'] = $tu->addExp($m); $award['exp'] = $m; } $items = $conf['v_items']; if ($items) { foreach ($items as $item) { $config = ItemConfig::getItem($item['tag']); $idp = $item['idp']; // $item['id']=$uid.$idp; unset($item['idp']); $item['pos'] = 's'; if ($config['group'] == 'g') { $item['num'] = $config['unitcout']; $tu->puto($item, TT::GOODS_GROUP); } else { $tu->puto($item, TT::ITEM_GROUP); } $award['items'][] = $item; } } $tu->puto($mano); $ret['award'] = $award; $ret['s'] = 'OK'; return $ret; } $mano[$step]['dtime'] = $now; $m = $conf['d_money']; if ($m > 0) { $ret['money'] = $tu->chMoney($m); $award['money'] = $m; } $m = $conf['d_gem']; if ($m > 0) { $ret['gem'] = $tu->chGem($m); $award['gem'] = $m; } $m = $conf['d_exp']; if ($m > 0) { $ret['exp'] = $tu->addExp($m); $award['exp'] = $m; } $items = $conf['d_items']; if ($items) { foreach ($items as $item) { $config = ItemConfig::getItem($item['tag']); $idp = $item['idp']; // $item['id']=$uid.$idp; unset($item['idp']); $item['pos'] = 's'; if ($config['group'] == 'g') { $item['num'] = $config['unitcout']; $tu->puto($item, TT::GOODS_GROUP); } else { $tu->puto($item, TT::ITEM_GROUP); } $award['items'][] = $item; } } $tu->puto($mano); TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $step)); $ret['s'] = 'OK'; $ret['award'] = $award; return $ret; }
function addLog($log_action) { return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('ROE'), NULL, $this->getTable(), $this); }
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); }