| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <?php
- if (!defined('IN_ONLINE')) {
- exit('Access Denied');
- }
- /**
- * Description of operation_log
- *
- * @author Administrator
- */
- class tools {
- private static $_tools;
- public static function getInstance() {
- if (!self::$_tools) {
- $c = __CLASS__;
- self::$_tools = new $c;
- }
- return self::$_tools;
- }
- /*
- * update password when login success
- */
- public function updatePassword() {
- if ($_SESSION['ONLINE_USER']['is_demo'] == "t") {
- $str = "DEMO cannot update password.";
- } else {
- $opsw = common::check_input($_POST ['opsw']);
- $npsw = common::check_input($_POST ['npsw']);
- $username = _getLoginName();
- $msg = common::checkPasswordRule($username, $npsw);
- //为空代表验证通过
- if (empty($msg)) {
- $sql = "select ra_password as password from ra_online_user where lower(user_login) = '" . strtolower($username) . "'";
- $rs = common::excuteObjectSql($sql);
- $str = '';
- if (!empty($rs)) {
- if ($rs['password'] == $opsw) {
- $sql = "UPDATE ra_online_user SET ra_password = '" . $npsw . "', last_pwd_change = now() WHERE lower(user_login) = '" . strtolower($username) . "'";
- $rls = common::excuteUpdateSql($sql);
- if (!$rls) {
- $str = "Password modification failed!";
- } else {
- $str = " Your password has been modified!";
- }
- } else {
- $str = "Old password is incorrect!";
- }
- } else {
- $str = "Old password is incorrect!";
- }
- } else {
- $str = $msg;
- }
- }
- $returnData = array("msg" => $str);
- common::echo_json_encode(200, $returnData);
- exit();
- }
- public function markSystem(){
- $operate = utils::_get('operate');
- $operate = strtolower($operate);
- if ($operate == "mark_save") {
- $suggestion = utils::implode(",",$_POST['suggestion']);
- $proposal = common::check_input($_POST['proposal']);
- $expression = common::check_input($_POST['expression']);
- $complete_funtionality = common::check_input($_POST['Complete_funtionality']);
- $accurate_data = common::check_input($_POST['Accurate_data']);
- $clear_information = common::check_input($_POST['Clear_information']);
- $easy_to_use = common::check_input($_POST['Easy_to_use']);
- $system_Performance = common::check_input($_POST['System_Performance']);
- $username = common::check_input($_POST['username']);
- $user_type = _isApexLogin() ? "employee" : "customer";
- if(!isset($_SESSION['ONLINE_USER'])){
- $user_type = "other";
- }
- $loginName = _getLoginName();
- $loginEamil = _getLoginEamil();
- //如果在没有登录前,没有登录信息,指定用户-- 这里逻辑取消,没有登录相当于匿名用户的评价,无法获取用户名
- // if(!isset($_SESSION['ONLINE_USER'])){
- // $user_type = "Customer";
- // if(!empty($username)){
- // $loginName = $username;
- // $loginEamil = common::excuteOneSql("select email from public.ra_online_user u where lower(user_login) = '" . strtolower($username) . "'");
- // }
- // }
- $sql = "INSERT INTO public.customer_service_user_mark(user_type, user_name, suggestion, proposal, expression, complete_funtionality,
- accurate_data, clear_information, easy_to_use, system_performance,
- created_time,email)
- VALUES ('$user_type', '$loginName', '$suggestion', '$proposal', '$expression', '$complete_funtionality',
- '$accurate_data', '$clear_information', '$easy_to_use', '$system_Performance', now(),'$loginEamil')";
- common::excuteUpdateSql($sql);
- $data = array("msg" =>"success");
- common::echo_json_encode(200,$data);
- exit();
- }
- }
- public function user_system_setting(){
- $operate = utils::_get('operate');
- $operate = strtolower($operate);
- if ($operate == "personal_profile_init") {
- // get system config
- $sql = "SELECT lower(ra_name) as ra_name, ra_value from ra_online_config where lower(ra_name) in ('employee_password_change_cycle', 'customer_password_change_cycle')";
- $rs1s = common::excuteListSql($sql);
- foreach ($rs1s as $rs1) {
- if ($rs1['ra_name'] == 'employee_password_change_cycle')
- $EMPLOYEE_PASSWORD_CHANGE_CYCLE = $rs1['ra_value'];
- if ($rs1['ra_name'] == 'customer_password_change_cycle')
- $CUSTOMER_PASSWORD_CHANGE_CYCLE = $rs1['ra_value'];
- }
- $sql="select item_value from config where item='passwordChangePeriod'";
- $pcp = common::excuteObjectSql($sql);
- $passwordChangePeriod = json_decode($pcp["item_value"],true);
- if (_isApexLogin()) {
- $PASSWORD_CHANGE_CYCLE = $EMPLOYEE_PASSWORD_CHANGE_CYCLE;
- //如果有新配置,则采用新配置
- if (!empty($pcp)) {
- $PASSWORD_CHANGE_CYCLE = $passwordChangePeriod["Employee"]["days"];
- }
- } else {
- $PASSWORD_CHANGE_CYCLE = $CUSTOMER_PASSWORD_CHANGE_CYCLE;
- //如果有新配置,则采用新配置
- if (!empty($pcp)) {
- $PASSWORD_CHANGE_CYCLE = $passwordChangePeriod["Customer"]["days"];
- }
- }
-
- $sql = "select u.first_name,u.last_name,u.user_login,u.email,EXTRACT(DAY from (now() - u.last_pwd_change)) as last_pwd_change_date,
- k.date_format,k.numbers_format
- from ra_online_user u
- left join kln_user_extend ue on u.user_login = ue.user_login
- where lower(u.user_login) = '".strtolower(_getLoginName())."' ";
- $data = common::excuteObjectSql($sql);
- $data["expire_day"] = $PASSWORD_CHANGE_CYCLE - $data['last_pwd_change_date'];
- common::echo_json_encode(200,$data);
- exit();
- }
- if ($operate == "personal_profile_save") {
- $save_model = common::check_input($_POST['save_model']);
- if ($save_model == "profile"){
- $user_name = common::check_input($_POST['user_name']);
- $email = common::check_input($_POST['email']);
- $sql = "update public.ra_online_user set user_login = '$user_name',email = '$email' where lower(user_login) = '".strtolower(_getLoginName())."'";
- }else{
- $date_fromat = common::check_input($_POST['date_fromat']);
- $numbers_format = common::check_input($_POST['numbers_format']);
- $exist_kln_user = common::excuteObjectSql("select user_login from public.kln_user_extend where lower(user_login) = '".strtolower(_getLoginName())."'");
- if (!empty($exist_kln_user['user_login'])){
- $sql = "update public.kln_user_extend set date_fromat = '$date_fromat',numbers_format = '$numbers_format' where lower(user_login) = '".strtolower(_getLoginName())."'";
- } else {
- $sql = "INSERT INTO public.kln_user_extend(user_login, date_format, numbers_format, subscribe_hbol)
- VALUES ('"._getLoginName()."', '$date_fromat', '$numbers_format', null);";
- }
- }
- common::excuteUpdateSql($sql);
- $data = array("msg" => "save Successful");
- common::echo_json_encode(200,$data);
- exit();
- }
- if ($operate == "subscribe_notification_init") {
- $subscribur_data =array();
- //Milestone Update的页面初始渲染数据
- $milestones = common::excuteListSql("select * from customer_service_milestone_sno order by type, sno");
- $ocean_milestone = array();
- $air_milestone = array();
- foreach($milestones as $milestone){
- if($milestone['type'] == "air"){
- $air_milestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
- }
- if($milestone['type'] == "ocean"){
- $ocean_milestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
- }
- }
- $subscribur_data["OceanCheckBoxList"] = $ocean_milestone;
- $subscribur_data["AirCheckBoxList"] = $air_milestone;
- $kln_user = common::excuteObjectSql("select * from public.kln_user_extend where lower(user_login) = '".strtolower(_getLoginName())."'");
- //查询用户对应的Rule
- $subscribe_rule_sql = "select * from public.notifications_rules where notifications_type = 'Subscribe' and lower(user_login) = '".strtolower(_getLoginName())."'";
- $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
- foreach($subscribe_rules as $rules){
- if($rules['rules_type'] == "Milestone Update"){
- $ocean_milestone = utils::implode(";",$rules['ocean_milestone']);
- //$rules["OceanCheckedList"] =
- }
- $subscribur_data[$rules['rules_type']] = $rules;
- }
- common::echo_json_encode(200,$subscribur_data);
- exit();
- }
- }
- }
- ?>
|