// Включение вывода всех ошибок и предупреждений ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); require_once dirname(__FILE__) . '/app.php'; require_once dirname(__FILE__) . '/lib/ksk_functions.php'; require_once dirname(__FILE__) . '/include/classes/jqGridPHP/jqGridLoader.php'; need_login(true); if ($login_user['rang'] != 'admin') { Utility::Redirect(WEB_ROOT . '/'); } $d_end = date('t'); $d_start = '01'; $y_now = date('Y'); $m_now = date('m'); $sms_api_options = get_sms_api_options(); $settings = get_settings(); $start_time = mysql_real_escape_string($d_start . '.' . $m_now . '.' . $y_now); $end_time = mysql_real_escape_string($d_end . '.' . $m_now . '.' . $y_now); $user_man = DB::GetQueryResult("SELECT * FROM `user` WHERE rang = 'manager'", false); $user_mas = DB::GetQueryResult("SELECT * FROM `user` WHERE rang = 'master'", false); $array_man = array(); $array_mas = array(); $zp = 0; foreach ($user_man as $one) { $sum = DB::GetQueryResult("SELECT SUM(cost) AS summ FROM `order` WHERE STR_TO_DATE(time_date, '%d.%m.%Y') BETWEEN STR_TO_DATE('" . $start_time . "', '%d.%m.%Y') AND STR_TO_DATE('" . $end_time . "', '%d.%m.%Y') AND user_id =" . $one['id'], true); $zp = $sum['summ'] * $one['stavka'] / 100; $array_man[$one['id']]['id'] = $one['id']; $array_man[$one['id']]['name'] = $one['realname'] . '(' . $one['username'] . ')'; $array_man[$one['id']]['zp'] = $zp; }
function send_sms_admin($order_id) { $sms_api_options = get_sms_api_options(); if (count($sms_api_options) > 0) { //$from_sms_send = '79224717444'; $from_sms_send = $sms_api_options['sms_api_phone']; $user_for_send = DB::GetQueryResult("SELECT * FROM `user` WHERE `rang` = 'admin' OR `rang` = 'operator' AND sms = 1", false); $send = new Sms($sms_api_options['sms_api_username'], $sms_api_options['sms_api_password']); foreach ($user_for_send as $one) { if ($one['phone'] != '' && strlen($one['phone']) > 5) { $sms_body = 'В системе заказов новый необработанный заказ или сообщение'; $text_master_send = iconv('utf-8', 'utf-8', $sms_body); //Отправляем смс если она не была отправлена ранее $result = $send->send_sms($text_master_send, $one['phone'], $from_sms_send); } } } }