add sendmail in orders
This commit is contained in:
@@ -7,7 +7,7 @@ function bookid_kuri($slug) {
|
|||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT
|
SELECT
|
||||||
`price_id`, `pricename`, `categoryname`, `priceslug`, `categoryslug`, price.category_id AS category_id, `BeginDate`, `priceanons`, `priceimg`, `pricehash`, `price`, `offline_price`, `sub`
|
`price_id`, `pricename`, `categoryname`, `priceslug`, `categoryslug`, price.category_id AS category_id, `BeginDate`, `priceanons`, `priceimg`, `pricehash`, `pieces`, `price`, `offline_price`, `sub`
|
||||||
FROM
|
FROM
|
||||||
`price`
|
`price`
|
||||||
LEFT JOIN `pricecategory`
|
LEFT JOIN `pricecategory`
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ define('YKEY', 'test_7asbXctnircUsmb_DhtYWSfxMiWzPgJBDF7OoZ0XfvQ');
|
|||||||
define('LOGDIR', SITEPATH.'logs/'); // папка куда падают логи
|
define('LOGDIR', SITEPATH.'logs/'); // папка куда падают логи
|
||||||
|
|
||||||
|
|
||||||
|
# отправка писем с клана
|
||||||
|
set('klanmail', [
|
||||||
|
'mail'=>'klan@argumenti.ru',
|
||||||
|
'password'=>'Rt90Fg',
|
||||||
|
'port'=>25,
|
||||||
|
'host'=>'smtp.argumenti.ru'
|
||||||
|
]);
|
||||||
|
|
||||||
/** отправка уведомлений */
|
/** отправка уведомлений */
|
||||||
/*set('noreply',
|
/*set('noreply',
|
||||||
|
|||||||
30
app/helpers/inputform.php
Normal file
30
app/helpers/inputform.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function inputform($items = [], $style = ''){
|
||||||
|
|
||||||
|
$key = $POST[$items['name'];
|
||||||
|
|
||||||
|
$result = '<input';
|
||||||
|
|
||||||
|
if (isset($key)){
|
||||||
|
|
||||||
|
$result .= ' value="'.$key.'" ';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($style !== ''){
|
||||||
|
$result .= " style="'.$style.'"";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($items['required']){
|
||||||
|
$result .= " required";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result .= '>';
|
||||||
|
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
11
app/helpers/post_value.php
Normal file
11
app/helpers/post_value.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function post_value($name, $default = ''){
|
||||||
|
|
||||||
|
if (isset($_POST[$name]))
|
||||||
|
return $_POST[$name];
|
||||||
|
else{
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
require 'confg.php';
|
require 'confg.php';
|
||||||
|
|
||||||
#routes
|
#routes
|
||||||
require 'routes/price.php';
|
require 'routes/price.php';
|
||||||
require 'routes/client.php';
|
require 'routes/client.php';
|
||||||
@@ -13,15 +12,18 @@ require 'routes/email.php';
|
|||||||
require 'routes/books.php';
|
require 'routes/books.php';
|
||||||
require 'routes/order.php';
|
require 'routes/order.php';
|
||||||
require 'routes/anpay.php';
|
require 'routes/anpay.php';
|
||||||
|
require 'routes/sendmail.php';
|
||||||
|
#lib
|
||||||
|
require 'libs/logsave.php';
|
||||||
#api
|
#api
|
||||||
require 'api/apiclient.php';
|
require 'api/apiclient.php';
|
||||||
require 'api/apicontent.php';
|
require 'api/apicontent.php';
|
||||||
require 'api/book.php';
|
require 'api/book.php';
|
||||||
|
|
||||||
#helpers
|
#helpers
|
||||||
require 'helpers/picbook.php';
|
require 'helpers/picbook.php';
|
||||||
require 'helpers/transliturl.php';
|
require 'helpers/transliturl.php';
|
||||||
|
require 'helpers/post_value.php';
|
||||||
|
|
||||||
|
|
||||||
#middleware
|
#middleware
|
||||||
$checklogin = check_login_kuri();
|
$checklogin = check_login_kuri();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use YooKassa\Client;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function anpay_kuri($buy_id){
|
function anpay_kuri($order_id){
|
||||||
|
|
||||||
|
|
||||||
# получаем инфу о заказе
|
# получаем инфу о заказе
|
||||||
@@ -19,7 +19,7 @@ function anpay_kuri($buy_id){
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
`price` ON `anbuy`.`number_id` = `price`.`price_id`
|
`price` ON `anbuy`.`number_id` = `price`.`price_id`
|
||||||
WHERE
|
WHERE
|
||||||
`buy_id` = '$buy_id'
|
`buy_id` = '$order_id'
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
";
|
";
|
||||||
|
|
||||||
@@ -39,8 +39,11 @@ function anpay_kuri($buy_id){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ссылка на статус и номер заказа
|
||||||
|
$return_url = SITE.'status/'.$buy_id['buy_id'];
|
||||||
|
|
||||||
# получить ссылку на оплату
|
# получить ссылку на оплату
|
||||||
$payment = yk_pay($buy_id['currprice'], $buy_id['pricename']);
|
$payment = yk_pay($buy_id['currprice'], $buy_id['pricename'], $return_url);
|
||||||
|
|
||||||
if (isset($payment['confirmation']['confirmation_url'])){
|
if (isset($payment['confirmation']['confirmation_url'])){
|
||||||
$pay_url = $payment['confirmation']['confirmation_url'];
|
$pay_url = $payment['confirmation']['confirmation_url'];
|
||||||
@@ -68,8 +71,13 @@ function anpay_kuri($buy_id){
|
|||||||
function resultpay_kuri(){
|
function resultpay_kuri(){
|
||||||
|
|
||||||
$source = file_get_contents('php://input');
|
$source = file_get_contents('php://input');
|
||||||
//$source = file_get_contents('/vhosts/anpay/app/tests/result.json');
|
//$source = file_get_contents('/thosts/anpdf/app/tests/result.json');
|
||||||
|
|
||||||
|
$fjson = '/thosts/anpdf/app/tests/result.json';
|
||||||
|
|
||||||
|
file_put_contents($fjson, $source);
|
||||||
|
|
||||||
|
// logsave('yk', $source);
|
||||||
|
|
||||||
$result = json_decode($source, true);
|
$result = json_decode($source, true);
|
||||||
|
|
||||||
@@ -77,12 +85,11 @@ function resultpay_kuri(){
|
|||||||
if (isset($result['event'])) {
|
if (isset($result['event'])) {
|
||||||
|
|
||||||
if ($result['event'] == "payment.succeeded"){
|
if ($result['event'] == "payment.succeeded"){
|
||||||
$shop_id = $result['object']['id'];
|
$shop_id = $result['object']['id'];
|
||||||
$find_sql = "SELECT buy_id FROM `anbuy` WHERE `shop_id` = '$shop_id' LIMIT 1";
|
$find_sql = "SELECT `buy_id` FROM `anbuy` WHERE `shop_id` = '$shop_id' LIMIT 1";
|
||||||
|
$find_order = db_get($find_sql);
|
||||||
|
|
||||||
$find_order = db_get($find_sql);
|
if (isset($find_order['buy_id'])) {
|
||||||
|
|
||||||
if (isset($find_order['buy_id'])){
|
|
||||||
|
|
||||||
$currdate = date('Y-m-d H:i:s');
|
$currdate = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
@@ -96,11 +103,11 @@ function resultpay_kuri(){
|
|||||||
WHERE
|
WHERE
|
||||||
`buy_id` = '{$find_order['buy_id']}'";
|
`buy_id` = '{$find_order['buy_id']}'";
|
||||||
|
|
||||||
db_get($supd, 'chitatel');
|
$result = db_get($supd, 'chitatel'); // фисксируем что оплату получил
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -109,7 +116,7 @@ function resultpay_kuri(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logsave('yk', $source);
|
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
|
|
||||||
@@ -117,9 +124,10 @@ function resultpay_kuri(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function yk_pay($price, $name){
|
function yk_pay($price, $name, $return_url = ''){
|
||||||
|
|
||||||
|
|
||||||
|
if ($return_url == '')
|
||||||
|
$return_url = SITE;
|
||||||
|
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
$client->setAuth(YID, YKEY);
|
$client->setAuth(YID, YKEY);
|
||||||
@@ -132,7 +140,7 @@ function resultpay_kuri(){
|
|||||||
),
|
),
|
||||||
'confirmation' => array(
|
'confirmation' => array(
|
||||||
'type' => 'redirect',
|
'type' => 'redirect',
|
||||||
'return_url' => SITE,
|
'return_url' => $return_url,
|
||||||
),
|
),
|
||||||
'capture' => true,
|
'capture' => true,
|
||||||
'description' => $name,
|
'description' => $name,
|
||||||
@@ -152,3 +160,29 @@ function resultpay_kuri(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#оповещаем письмом об успешном заказе
|
||||||
|
function sendstatus_kuri(){
|
||||||
|
|
||||||
|
if (isset($find_order['client_id'])) { # получаем клиента
|
||||||
|
|
||||||
|
$find_client = db_get("SELECT * FROM `clients` WHERE `client_id` = '{$find_order['client_id']}'");
|
||||||
|
|
||||||
|
if (isset($find_client['client_id'])){ # если удалось индефицировать клиента
|
||||||
|
if ($find_order['delivery_id'] == 1) { #электронный платеж отправляем личный кабинет
|
||||||
|
$message = "Ваш заказ выполнен. Он доступен в Вашем личном кабинете.\n
|
||||||
|
Чтобы войти в кабинет перейдите по ссылке - ".SITE.'login';
|
||||||
|
$subject = "Аргументы Недели: заказ выполнен";
|
||||||
|
klanmail($find_order['clientmail'], $subject, $message, set('klanmail'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$message = "Ваш платеж подтвержден. Номер заказа {find_order['order_id']}\n
|
||||||
|
Сообщите его менеджеру при необходимостию";
|
||||||
|
$subject = "Аргументы Недели: платеж подтвержден";
|
||||||
|
klanmail($find_order['clientmail'], $subject, $message, set('klanmail'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,83 +7,227 @@
|
|||||||
|
|
||||||
function checkout_kuri($priceslug, $delivery_id = 1){
|
function checkout_kuri($priceslug, $delivery_id = 1){
|
||||||
|
|
||||||
|
|
||||||
|
$err_critical = false; // true - не введены обязательные поля
|
||||||
|
$add_order = false; //по умолчанию не добавлять заказ
|
||||||
|
$add = []; // массив заполнения заказа
|
||||||
|
$elements = []; //элементы формы
|
||||||
|
|
||||||
|
|
||||||
|
$pay_ids = [
|
||||||
|
'1' => 'Оплата на сайте',
|
||||||
|
'2' => 'Оплата при получении'
|
||||||
|
];
|
||||||
|
|
||||||
|
$pay_id = 2; // по умолчанию оплата при получении
|
||||||
|
|
||||||
|
/** был изменен способ доставки в форме
|
||||||
|
* 1 - электронная
|
||||||
|
* 2 - самовывоз
|
||||||
|
* 3 - курьером
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//print_r($_POST);
|
||||||
|
|
||||||
|
/* ищем есть ли товар */
|
||||||
$price_id = db_get("SELECT * FROM `price` WHERE `priceslug` = '$priceslug' LIMIT 1");
|
$price_id = db_get("SELECT * FROM `price` WHERE `priceslug` = '$priceslug' LIMIT 1");
|
||||||
|
|
||||||
if (isset($price_id['price_id'])) {
|
if (!isset($price_id['price_id'])) {
|
||||||
|
echo 'товар не найден';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($delivery_id == 1){ // тип товара
|
|
||||||
$price = $price_id['price']; // электронная книжка
|
/** определяем цену товара */
|
||||||
|
|
||||||
|
if ($delivery_id == 1){ // тип товара = 1 (только электронная)
|
||||||
|
$price = $price_id['price']; // электронный прайс
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$price = $price_id['offline_price']; // бумажный прайс
|
||||||
|
$delivery = db_get("SELECT * FROM delivery WHERE delivery_id > 1"); // список доставок для бумажной версии
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** фиксируем цену в базу */
|
||||||
|
|
||||||
|
$add['buy_price'] = $price;
|
||||||
|
$add['price'] = $price;
|
||||||
|
|
||||||
|
|
||||||
|
/** если клиент залогинен */
|
||||||
|
if (defined('CLIENT_ID')){
|
||||||
|
|
||||||
|
$client = client_find_id(CLIENT_ID);
|
||||||
|
|
||||||
|
if (isset($client['result']['client_id'])){
|
||||||
|
$client = $client['result'];
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$price = $price_id['offline_price']; // бумажная книжка
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# если пришла форма
|
||||||
|
if (count($_POST) > 0){
|
||||||
|
|
||||||
|
$errors = []; // ошибки которые вернуться в форму
|
||||||
|
|
||||||
|
if (isset($_POST['delivery_id'])){
|
||||||
|
$delivery_id = (int)$_POST['delivery_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['pay_id'])){
|
||||||
|
$pay_id = (int)$_POST['pay_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (defined('CLIENT_ID')){
|
# указан ли в поле email
|
||||||
|
if (isset($_POST['clientmail']) and trim($_POST['clientmail']) !== '') {
|
||||||
$client = client_find_id(CLIENT_ID);
|
|
||||||
|
|
||||||
if (isset($client['result']['client_id'])){
|
|
||||||
$client = $client['result'];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST['clientmail'])){
|
|
||||||
|
|
||||||
$clientmail = $_POST['clientmail'];
|
$clientmail = $_POST['clientmail'];
|
||||||
|
|
||||||
if (!filter_var($clientmail, FILTER_VALIDATE_EMAIL)){
|
if (!filter_var($clientmail, FILTER_VALIDATE_EMAIL)){
|
||||||
$error_mail = True;
|
$error['buy_email'] = 'Не указана электронная почта (обязательна для электронных заказов и оплаты онлайн)';
|
||||||
|
if ($delivery_id == 1 or $pay_id == 1){
|
||||||
|
$err_critical = True; # обязательное поле для цифрового заказа или оплаты онлайн
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# ищем или создаем клиента
|
$client = api_add_client($clientmail); # ищем или создаем клиента
|
||||||
$client = api_add_client($clientmail);
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# указано ли поле имя
|
||||||
|
if (isset($_POST['buy_name']) and trim($_POST['buy_name']) !== '' ) {
|
||||||
|
$add['buy_name'] = trim($_POST['buy_name']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($delivery_id > 1){
|
||||||
|
$err_critical = True; // обязательное поле для физических заказов
|
||||||
|
$errors['buy_name'] = 'Не указано имя. Обязательно для получения самовывозом';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# указано поле телефон
|
||||||
if (isset($client['client_id'])) {
|
if (isset($_POST['buy_tel']) and trim($_POST['buy_tel']) !== '') {
|
||||||
|
$add['buy_tel'] = trim($_POST['buy_tel']);
|
||||||
#создаем заказ
|
}
|
||||||
$add['client_id'] = $client['client_id'];
|
else {
|
||||||
$add['buy_email'] = $client['clientmail'];
|
if ($delivery_id == 3){ // обязательное поле для доставки курьером
|
||||||
$add['buy_price'] = $price;
|
$err_critical = True;
|
||||||
$add['price'] = $price;
|
$errors['buy_tel'] = 'Не указан телефон по которому можно уточнить детали доставки';
|
||||||
$add['buy_status'] = 0;
|
|
||||||
$add['mail_status'] = 0;
|
|
||||||
$add['number_id'] = $price_id['price_id'];
|
|
||||||
$add['pay_id'] = 3; // оплата через Юкассу
|
|
||||||
$add['delivery_id'] = $delivery_id;
|
|
||||||
$add['date_start'] = date('Y-m-d H:i:s');
|
|
||||||
$add['buy_active'] = 0;
|
|
||||||
|
|
||||||
|
|
||||||
$order_id = db_insert('anbuy', $add, 'chitatel'); // добавляем в базу заказ
|
|
||||||
|
|
||||||
if (is_array($order_id)){ // неудалось создать заказ
|
|
||||||
$error_mail = True;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else { // заказ создался
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# указано поле адрес
|
||||||
|
if (isset($_POST['buy_adress']) and trim($_POST['buy_adress']) !== '') {
|
||||||
|
$add['buy_adress'] = trim($_POST['buy_adress']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($delivery_id == 3){
|
||||||
|
$err_critical = True; // обязательное поле для доставки курьером
|
||||||
|
$errors['buy_adress'] = 'Не указан адрес куда доставить товар';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// все поля формы заполнены - пушим заказ
|
||||||
|
if (!$err_critical){
|
||||||
|
$add_order = True;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** фикстируем клиента в базу */
|
||||||
|
if (isset($client['client_id'])) {
|
||||||
|
$add['client_id'] = $client['client_id'];
|
||||||
|
$add['buy_email'] = $client['clientmail'];
|
||||||
|
|
||||||
|
if ($delivery_id == 1) {
|
||||||
|
$add_order = True; // для электронного заказа достаточно активного клиента
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#создаем заказ
|
||||||
|
if ($add_order){
|
||||||
|
|
||||||
|
$add['buy_status'] = 0;
|
||||||
|
$add['mail_status'] = 0;
|
||||||
|
$add['number_id'] = $price_id['price_id'];
|
||||||
|
$add['pay_id'] = 3; // оплата через Юкассу
|
||||||
|
$add['delivery_id'] = $delivery_id;
|
||||||
|
$add['date_start'] = date('Y-m-d H:i:s');
|
||||||
|
$add['buy_active'] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
$order_id = db_insert('anbuy', $add, 'chitatel'); // добавляем в базу заказ
|
||||||
|
$order_url = SITE."status/$order_id";
|
||||||
|
|
||||||
|
if (is_array($order_id)){ // неудалось создать заказ
|
||||||
|
$error_mail = True;
|
||||||
|
$error['no_order'] = 'Не удалось сформировать заказ';
|
||||||
|
}
|
||||||
|
else { # заказ создался
|
||||||
|
if ( $delivery_id == 1 or ($_POST['pay_id']) == 1){
|
||||||
|
echo 'уводим на оплату в Юкассу';
|
||||||
return anpay_kuri($order_id);
|
return anpay_kuri($order_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else { // даем пользователю номер заказа
|
||||||
|
|
||||||
|
|
||||||
|
if (isset($add['buy_email'])) {
|
||||||
|
|
||||||
|
$message = "Ваш платеж подтвержден. Номер заказа $order_id\n
|
||||||
|
Сообщите его менеджеру при необходимости.\n";
|
||||||
|
$subject = "Аргументы Недели: платеж подтвержден";
|
||||||
|
$result = klanmail($add['buy_email'], $subject, $message, set('klanmail'));
|
||||||
|
// echo $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: $order_url"); // переводим на инфу про заказа
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$error_price = True;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$submit_link = SITE."checkout/$priceslug/$buy_type";
|
|
||||||
|
|
||||||
include VIEWPATH.'checkout.phtml';
|
$submit_link = SITE."checkout/$priceslug/$delivery_id";
|
||||||
|
|
||||||
|
|
||||||
|
include VIEWPATH.'checkout.phtml';
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# страница с которой
|
||||||
|
function status_kuri($order_id){
|
||||||
|
|
||||||
|
# получаем инфу о заказе
|
||||||
|
$buy_find = "
|
||||||
|
SELECT
|
||||||
|
`buy_id`,
|
||||||
|
`buy_status`,
|
||||||
|
`delivery_id`,
|
||||||
|
`shop_id`
|
||||||
|
FROM
|
||||||
|
`anbuy`
|
||||||
|
WHERE
|
||||||
|
`buy_id` = '$order_id'
|
||||||
|
LIMIT 1
|
||||||
|
";
|
||||||
|
|
||||||
|
$buy_id = db_get($buy_find);
|
||||||
|
|
||||||
|
|
||||||
|
include(VIEWPATH.'order_status.phtml');
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
80
app/routes/sendmail.php
Normal file
80
app/routes/sendmail.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
use PHPMailer\PHPMailer\Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function testmail_kuri(){
|
||||||
|
|
||||||
|
echo klanmail('ak@argumenti.ru', 'тестовое письмо', 'Это тестовое письмо о заказах', set('klanmail'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function klanmail( $mail, $subject, $message, $frommail ) {
|
||||||
|
|
||||||
|
$mail = mb_strtolower($mail);
|
||||||
|
|
||||||
|
if (isset($frommail['login']) and $frommail['login'] !== '')
|
||||||
|
$login = $frommail['login'];
|
||||||
|
else {
|
||||||
|
$login = $frommail['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$send = new PHPMailer;
|
||||||
|
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||||
|
$send->isSMTP();
|
||||||
|
//$send->SMTPDebug=3; // Set mailer to use SMTP
|
||||||
|
$send->Host = $frommail['host']; // Specify main and backup SMTP servers
|
||||||
|
// Enable SMTP authentication
|
||||||
|
$send->Username = $login; // SMTP username
|
||||||
|
$send->Password = $frommail['password'];
|
||||||
|
if (isset($frommail['secure'])) {
|
||||||
|
$send->SMTPSecure = $frommail['secure'];
|
||||||
|
$send->SMTPAuth = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$mail->SMTPSecure = false;
|
||||||
|
$mail->SMTPAutoTLS = false;
|
||||||
|
}
|
||||||
|
$send->Port = $frommail['port']; // TCP port to connect to
|
||||||
|
$send->setFrom($frommail['mail'], 'Аргументы Недели');
|
||||||
|
$send->addAddress($mail, $mail); // Add a recipient
|
||||||
|
$send->CharSet = 'UTF-8';
|
||||||
|
$send->isHTML(True); // Set email format to HTML
|
||||||
|
$send->Subject = $subject;
|
||||||
|
/*ob_start();
|
||||||
|
include 'mail.phtml';
|
||||||
|
$mailbody = ob_get_contents();
|
||||||
|
ob_end_clean();*/
|
||||||
|
|
||||||
|
$send->Body = $message;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//$headers = "MIME-Version: 1.0\r\n";
|
||||||
|
//$headers .= "Content-type: text/plain; charset=utf-8\r\n";
|
||||||
|
//$headers .= "Content-Transfer-Encoding: 8bit \r\n";
|
||||||
|
//$headers .= "From: nomer@arguments.ru\r\n";
|
||||||
|
//$headers .= 'Reply-To: nomer@arguments.ru'."\r\n";
|
||||||
|
|
||||||
|
//if (mail($mail, $subject, $message, $headers))
|
||||||
|
// $status = 'OK';
|
||||||
|
//else
|
||||||
|
// $status = 'NO';
|
||||||
|
|
||||||
|
|
||||||
|
if($send->send())
|
||||||
|
$status = 'OK';
|
||||||
|
else {
|
||||||
|
$status = 'NO';
|
||||||
|
echo 'Mailer Error: ' . $send->ErrorInfo."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,9 +19,10 @@
|
|||||||
<?if ($book['sub'] == 1):?>
|
<?if ($book['sub'] == 1):?>
|
||||||
<p class="price"><a href="<?=$link_subscript?>">Доступ к библиотеке за 490 руб. в год</a></p>
|
<p class="price"><a href="<?=$link_subscript?>">Доступ к библиотеке за 490 руб. в год</a></p>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
<?if ($book['offline_price'] > 0):?>
|
<?if ($book['offline_price'] > 0 && $book['pieces'] > 0):?>
|
||||||
<p class="price"><a href="<?=$link_offline?>">Бумажная за <?=$book['offline_price']?> руб.</a></p>
|
<p class="price"><a href="<?=$link_offline?>">Бумажная за <?=$book['offline_price']?> руб.</a></p>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
|
|
||||||
<?endif?>
|
<?endif?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,24 +1,106 @@
|
|||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var product_price = <?=$price?>;
|
||||||
|
|
||||||
|
|
||||||
<?if (isset($error_price)):?>
|
function devilery_check(myRadio){
|
||||||
<p style="color: red;">Просим прощения, но такой товар не найден!</p>
|
|
||||||
<?else:?>
|
var itog = product_price;
|
||||||
|
var itog_el = document.getElementById("span_itog");
|
||||||
|
|
||||||
|
if (myRadio.value == 2){
|
||||||
|
itog = product_price;
|
||||||
|
document.getElementById("form_adress").style.visibility='hidden';
|
||||||
|
document.getElementById("form_samo").style.visibility='visible';
|
||||||
|
}
|
||||||
|
else if(myRadio.value == 3){
|
||||||
|
itog = product_price + 300;
|
||||||
|
document.getElementById("form_adress").style.visibility='visible';
|
||||||
|
document.getElementById("form_samo").style.visibility='hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
itog_el.innerHTML = itog + ' руб.';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
<form id="clientform" class="clientform" action="<?=$submit_link?>" method="POST">
|
<form id="clientform" class="clientform" action="<?=$submit_link?>" method="POST">
|
||||||
|
|
||||||
<?if (isset($error_mail)):?>
|
|
||||||
<p style="color: red;">Неверный адрес электронной почты</p>
|
<?if (isset($errors)):?>
|
||||||
|
<div id="errors">
|
||||||
|
<?foreach($errors as $err):?>
|
||||||
|
<p style="color: red;"><?=$err?></p>
|
||||||
|
<?endforeach?>
|
||||||
|
</div>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
|
|
||||||
<p><label for="clientmail">Для покупки этого товара введите свой электронный адрес ниже:</label></p>
|
|
||||||
<p><input type="email" id="clientemail" name="clientmail"></p>
|
<p><label for="clientmail">Ваш электронный адрес:</label><br>
|
||||||
<p><label>Нажимая кнопку «Купить», я соглашаюсь <a href="https://argumenti.ru/subscribe_condition">с условиями подписки</a></label></p>
|
<em>Куда придет информация о заказе</em>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><input type="email" id="clientemail" name="clientmail" value="<?=post_value("clientmail")?>"></p>
|
||||||
|
|
||||||
|
<?if($delivery_id > 1):?>
|
||||||
|
|
||||||
|
<p><label for="buy_adress">Ваше имя:</label><br></p>
|
||||||
|
<p><input id="buy_name" name="buy_name" value="<?=post_value("buy_name")?>"></p>
|
||||||
|
|
||||||
|
<p><label for="buy_tel">Телефон для связи:</label><br>
|
||||||
|
<em>Для подтверждения заказа</em>
|
||||||
|
</p>
|
||||||
|
<p><input id="buy_tel" name="buy_tel" value="<?=post_value("buy_tel")?>"></textarea></p>
|
||||||
|
|
||||||
|
<p><label for="devilery_id">Доставка:</label></p>
|
||||||
|
|
||||||
|
<?foreach($delivery as $ditem):?>
|
||||||
|
<?$dd++;
|
||||||
|
$checked = ($ditem['delivery_id'] == $delivery_id) ? ' checked': '';?>
|
||||||
|
<p><input name="delivery_id" type="radio" id="devilery_id<?=$dd?>" onclick="devilery_check(this);" value="<?=$ditem['delivery_id']?>"<?=$checked?>>
|
||||||
|
<?=$ditem['delivery']?>
|
||||||
|
<?if ($ditem['delivery_price'] > 0):?>
|
||||||
|
+ <?=$ditem['delivery_price']?> руб.
|
||||||
|
<?endif?>
|
||||||
|
</p>
|
||||||
|
<?endforeach?>
|
||||||
|
|
||||||
|
<div id="form_samo" style="visibility: <?= ($delivery_id == 2) ? 'visible' : 'hidden' ?>;">
|
||||||
|
<p>Адрес:</p>
|
||||||
|
<p>Москва, Авиационный переулок, д. 4А</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="form_adress" style="visibility: <?= ($delivery_id == 3 or $delivery_id == 4) ? 'visible' : 'hidden' ?>;">
|
||||||
|
<p><label for="buy_adress">Адрес:</label></p>
|
||||||
|
<p><textarea id="buy_adress" name="buy_adress" placeholder="Адрес в свободной форме" value="<?=post_value("buy_adress")?>"></textarea></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="form_pay">
|
||||||
|
<p><label for="buy_adress">Оплата:</label></p>
|
||||||
|
<?foreach($pay_ids as $pkey=>$pitem):?>
|
||||||
|
<?$p++;
|
||||||
|
$pchecked = ($pkey == $pay_id) ? ' checked': '';?>
|
||||||
|
<p><input name="pay_id" type="radio" value="<?=$pkey?>" id="pay_id<?=$p?>" <?=$pchecked?>><?=$pitem?></p>
|
||||||
|
<?endforeach?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="form_itog">
|
||||||
|
<strong>Общая сумма:</strong> <span id="span_itog"><?=$price?> руб.</span></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
|
<p><label>Нажимая кнопку «Купить», я соглашаюсь <a href="https://argumenti.ru/subscribe_condition">с условиями получения услуги</a></label></p>
|
||||||
<p><input type="submit" id="submit" value="Купить"></p>
|
<p><input type="submit" id="submit" value="Купить"></p>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?endif?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
45
app/views/order_status.phtml
Normal file
45
app/views/order_status.phtml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<h1>Номер заказа <?=$order_id?></h1>
|
||||||
|
|
||||||
|
<?if (isset($buy_id['buy_id'])):?>
|
||||||
|
|
||||||
|
<p>Запомните номер заказа, чтобы при необходимости сообщить его менеджеру</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p> <strong>Статус оплаты:</strong>
|
||||||
|
|
||||||
|
<?if ($buy_id['buy_status'] == 1):?>
|
||||||
|
Спасибо мы получили от Вас оплату.
|
||||||
|
<?else:?>
|
||||||
|
Заказ неоплачен.
|
||||||
|
<?if ($buy_id['delivery_id'] == 1 && $buy_id['shop_id'] !== '' ):?>
|
||||||
|
Свяжитесь с менеджером, чтобы оплатить его.
|
||||||
|
<?else:?>
|
||||||
|
Вы сможете оплатить заказ при получении.
|
||||||
|
<?endif?>
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p> <strong>Доставка:</strong>
|
||||||
|
|
||||||
|
<?if ($buy_id['delivery_id'] == 1):?>
|
||||||
|
Указана электронная почта или личный кабинет
|
||||||
|
<?elseif ($buy_id['delivery_id'] == 2):?>
|
||||||
|
Выбран самовывоз по адресу - Москва, Авиационный переулок, д. 4А
|
||||||
|
<?elseif ($buy_id['delivery_id'] == 3):?>
|
||||||
|
Доставка по указанному адресу. С Вами свяжется наш менеджер.
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?else:?>
|
||||||
|
|
||||||
|
<p>Извините, но такой заказ еще не сформирован</p>
|
||||||
|
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="<?=SITE?>">Перейти в КЛАН</a>
|
||||||
Reference in New Issue
Block a user