$date_f = date_diff_f($time_now, $date); if ($date_f <= 82000 && $date_f >= 0) { //Отправляем смс prepare_sms_master($order_id); prepare_sms_client($order_id, $phone, $client_fio, 3); if (isset($_POST['sms2']) && $_POST['sms2'] == 'on') { prepare_sms_client($order_id, $phone2, $client_fio2, 4); } if (isset($_POST['sms3']) && $_POST['sms3'] == 'on') { prepare_sms_client($order_id, $phone3, $client_fio3, 5); } } } } if ($login_user['rang'] != 'admin' && $login_user['rang'] != 'operator') { prepare_sms_admin($order_id); } if ($master_name_two != '') { $order_id_two = DB::Insert('order', array('user_id' => $login_user['id'], 'time_date' => $date, 'time_time' => $time, 'time_date_hope' => $date_hope, 'time_time_hope' => $time_hope, 'work_type' => intval($work_type), 'master' => intval($master), 'master_name' => intval($master_name_two), 'cost' => intval($cost), 'client_fio' => $client_fio, 'client_fio2' => $client_fio2, 'client_fio3' => $client_fio3, 'phone' => $phone, 'phone2' => $phone2, 'phone3' => $phone3, 'city_id' => $city_id, 'city_id2' => $city_id2, 'street' => $street, 'house' => $house, 'corpus' => $corpus, 'flat' => $flat, 'details' => $detail, 'note' => $note, 'img' => $img, 'img1' => $img1, 'img2' => $img2, 'img3' => $img3, 'img4' => $img4, 'img5' => $img5, 'img6' => $img6, 'img7' => $img7, 'sms2' => $sms2, 'sms3' => $sms3)); $offer = DB::Insert('order_offers', array('order_id' => $order_id_two)); if (isset($date) && isset($time) && isset($master_name_two) && isset($street)) { if ($date != '' && $time != '' && $master_name_two != '' && $street != '') { $time_now = date('d-m-Y'); $date_f = date_diff_f($time_now, $date); if ($date_f <= 82000 && $date_f >= 0) { prepare_sms_client($order_id_two, $phone, $client_fio, 3); //Отправляем смс prepare_sms_master($order_id_two); if (isset($_POST['sms2']) && $_POST['sms2'] == 'on') { prepare_sms_client($order_id_two, $phone2, $client_fio2, 4); }
function check_sms_msg_status($order_id = 0) { $packet_msg_count = 200; $settings = get_settings(); if ($settings['sms_api_username'] == '' || $settings['sms_api_password'] == '') { echo '<p>Не указаны параметры для отправки СМС !</p>'; return false; } $query = "SELECT * FROM `iqsms_msg` WHERE id_status IN (1,9,12)"; if ($order_id > 0) { $query .= " AND order_id = " . $order_id; } // Получим список отправленных СМС $sms_sended = DB::GetQueryResult($query, false); if (!$sms_sended) { return false; } $gate = new iqsms_JsonGate($settings['sms_api_username'], $settings['sms_api_password']); // узнаем текущий баланс //$gate_credits = $gate->credits(); $gate_credits = check_balans_rest(); // Проверим текущий баланс //if ($gate_credits['credits'] == 0) { if ($gate_credits === false || $gate_credits == 0) { //echo '<p>Для отправки СМС необходимо пополнить баланс !</p>'; //return false; } else { if ($gate_credits <= (int) $settings['sms_api_min_balance']) { prepare_sms_admin(0, 'Баланс в сервисе IQSMS достиг минимума, пополните баланс.', 6); } } // получаем список доступных подписей /*$gate_senders = $gate->senders(); // Проверим доступность подписи из настроек if ($settings['sms_api_phone'] != '') { if (!in_array($settings['sms_api_phone'], $gate_senders['senders'])) { echo '<p>Неверная (незарегистрированная) подпись отправителя !</p>'; return false; } }*/ // Проверим статус отправленных сообщений $messages = array(); $message_count = 0; foreach ($sms_sended as $one) { $messages[] = array("clientId" => $one['id'], "smscId" => $one['smscid']); $message_count++; if ($message_count == $packet_msg_count) { $ret_messages = $gate->status($messages); //var_dump($ret_messages); set_sms_msg_status($ret_messages); $messages = array(); $message_count = 0; } } $ret_messages = $gate->status($messages); //var_dump($ret_messages); set_sms_msg_status($ret_messages); }