1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560:
<?php
PHPShopObj::loadClass('order');
PHPShopObj::loadClass('mail');
PHPShopObj::importCore('users');
$PHPShopOrder = new PHPShopOrderFunction();
class PHPShopDone extends PHPShopCore {
public $cart_clean_enabled = true;
public $delivery_mod = false;
public $manager_comment = null;
public $delivery_free = false;
function __construct() {
global $PHPShopOrder;
$this->debug = false;
$this->objBase = $GLOBALS['SysValue']['base']['orders'];
$this->action = array('nav' => 'index', "post" => 'send_to_order');
parent::__construct();
PHPShopObj::loadClass('cart');
$this->PHPShopCart = new PHPShopCart();
$this->PHPShopOrder = $PHPShopOrder;
if (PHPShopSecurity::true_num($_POST['d'])) {
PHPShopObj::loadClass('delivery');
$this->PHPShopDelivery = new PHPShopDelivery($_POST['d']);
}
if (PHPShopSecurity::true_num($_POST['order_metod'])) {
PHPShopObj::loadClass('payment');
$this->PHPShopPayment = new PHPShopPayment($_POST['order_metod']);
}
$this->navigation(false, __(''));
}
function index() {
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
$this->set('mesageText', $this->message($this->lang('bad_cart_1'), $this->lang('bad_order_mesage_2')));
$disp = ParseTemplateReturn($this->getValue('templates.order_forma_mesage'));
$this->set('orderMesage', $disp);
$this->setHook(__CLASS__, __FUNCTION__, false, 'END');
$this->parseTemplate($this->getValue('templates.order_forma_mesage_main'));
}
function message($title, $content) {
$Arg = func_get_args();
$hook = $this->setHook(__CLASS__, __FUNCTION__, $Arg);
if ($hook)
return $hook;
$message = PHPShopText::b(PHPShopText::notice($title, false, '14px')) . PHPShopText::br();
$message .= PHPShopText::message($content, false, '12px', 'black');
return $message;
}
function send_to_order() {
global $SysValue, $link_db, $PHPShopAnalitica, $PHPShopOrder;
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST, 'START'))
return true;
if ($this->PHPShopCart->getNum() > 0) {
if (isset($_SESSION['UsersLogin']) AND ! empty($_SESSION['UsersLogin']))
$_POST['mail'] = ($_SESSION['UsersMail']);
if (!class_exists('PHPShopUsers'))
PHPShopObj::importCore('users');
$PHPShopUsers = new PHPShopUsers();
$this->userId = $PHPShopUsers->add_user_from_order($_POST['mail']);
if (PHPShopSecurity::true_email($_POST['mail']) AND $this->userId) {
$this->ouid = $_POST['ouid'];
$order_metod = intval($_POST['order_metod']);
$PHPShopOrm = new PHPShopOrm($this->getValue('base.payment_systems'));
$row = $PHPShopOrm->select(array('path','company'), array('id' => '=' . $order_metod, 'enabled' => "='1'"), false, array('limit' => 1));
$path = $row['path'];
$this->company = $row['company'];
$LoadItems['System'] = $this->PHPShopSystem->getArray();
$this->sum = $this->PHPShopCart->getSum(false);
$this->num = $this->PHPShopCart->getNum();
$this->weight = $this->PHPShopCart->getWeight();
$this->adminmail = $this->PHPShopSystem->getEmail();
$this->currency = $this->PHPShopOrder->default_valuta_code;
if ($this->PHPShopDelivery) {
$this->PHPShopDelivery->checkMod($this->delivery_mod);
$this->delivery = $this->PHPShopDelivery->getPrice($this->PHPShopCart->getSum(false), $this->PHPShopCart->getWeight());
$this->delivery = intval(str_replace(" ", "", $this->delivery));
} else
$this->delivery = 0;
$this->discount = $this->PHPShopOrder->ChekDiscount($this->sum);
$sum_cart = $this->PHPShopCart->getSum();
$sum_discount_off = $this->PHPShopCart->getSumNoDiscount();
$sum_discount_on = $PHPShopOrder->returnSumma($this->PHPShopCart->getSumPromo(false));
$sum_discount_on += $PHPShopOrder->returnSumma($this->PHPShopCart->getSumWithoutPromo(false), $this->discount);
$this->bonus_minus = $PHPShopOrder->bonus_minus;
$this->bonus_plus = $PHPShopOrder->bonus_plus;
if ($sum_cart > $sum_discount_on)
$discount_sum = $sum_discount_off - $sum_discount_on;
elseif ($sum_discount_off > $sum_cart)
$discount_sum = $sum_discount_off - $sum_cart;
else
$discount_sum = 0;
$this->discount_sum = number_format($discount_sum * $this->PHPShopSystem->getDefaultValutaKurs(true), $PHPShopOrder->format, '.', ' ');
$this->total = $sum_discount_on + $this->delivery;
$this->set('total', $this->total);
$this->setHook(__CLASS__, __FUNCTION__, $_POST, 'MIDDLE');
$PHPShopAnalitica->init(__FUNCTION__, $this);
if (file_exists("./payment/$path/order.php"))
include_once("./payment/$path/order.php");
elseif ($order_metod < 1000)
exit("$path/order.php");
$this->orderId = $this->write();
if ($path == 'bank')
$this->set('account', '//' . $_SERVER['SERVER_NAME'] . '/phpshop/forms/account/forma.html?orderId=' . $this->orderId . '&tip=1&datas=' . $this->datas);
if (!empty($disp))
$this->set('orderMesage', Parser($disp));
$this->mail();
$this->sms();
$this->push();
$this->bonus($this->orderId);
if ($this->cart_clean_enabled)
$this->PHPShopCart->clean();
$PHPShopCartElement = new PHPShopCartElement(true);
$PHPShopCartElement->init('miniCart');
}
else {
$disp = PHPShopText::alert($this->lang('bad_order_mesage_2'), 'danger');
$this->set('orderMesage', $disp);
}
} else {
$disp = PHPShopText::alert($this->lang('bad_order_mesage_2'), 'danger');
$this->set('orderMesage', $disp);
}
$this->setHook(__CLASS__, __FUNCTION__, $_POST, 'END');
$this->parseTemplate($this->getValue('templates.order_forma_mesage_main'));
}
function bonus($orderId){
$PHPShopBonus = new PHPShopBonus($_SESSION['UsersId']);
$PHPShopBonus->updateUserBonus($this->bonus_minus,0);
$PHPShopBonus->updateBonusLog($orderId, $this->ouid, $this->bonus_minus, 0);
}
function mail() {
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST, 'START'))
return true;
$this->set('sum', $this->currencyMultibase($this->sum));
$this->set('cart', $this->PHPShopCart->display('mailcartforma', array('currency' => $this->currency,'rate'=>$this->rate)));
$this->set('currency', $this->currency);
$this->set('discount', $this->discount);
$this->set('discount_sum', $this->discount_sum);
$this->set('deliveryPrice', $this->currencyMultibase($this->delivery));
$this->set('total', $this->currencyMultibase($this->total));
$this->set('shop_name', $this->PHPShopSystem->getName());
$this->set('ouid', $this->ouid);
$this->set('date', date("d-m-y"));
$this->set('adr_name', PHPShopSecurity::CleanStr($_POST['adr_name']));
$this->set('mail', $_POST['mail']);
if ($this->PHPShopPayment)
$this->set('payment', $this->PHPShopPayment->getName());
$this->set('company', $this->PHPShopSystem->getParam('name'));
if ($this->PHPShopDelivery) {
$this->set('deliveryCity', $this->PHPShopDelivery->getCity());
$this->set('adresList', $this->PHPShopDelivery->getAdresListFromOrderData($_POST));
}
$this->set('dos_ot', @$_POST['dos_ot']);
$this->set('dos_do', @$_POST['dos_do']);
$this->set('tel', @$_POST['tel_code'] . "-" . @$_POST['tel_name']);
if (!empty($_SESSION['UsersId']) and PHPShopSecurity::true_num($_SESSION['UsersId']))
$this->set('user_name', $_SESSION['UsersName']);
elseif (!empty($_POST['name_new']))
$this->set('user_name', $_POST['name_new']);
else
$this->set('user_name', $_POST['name_person']);
if (!empty($_POST['dop_info']))
$this->set('dop_info', $_POST['dop_info']);
$title = $this->lang('mail_title_user_start') . $_POST['ouid'] . $this->lang('mail_title_user_end');
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST, 'MIDDLE'))
return true;
$PHPShopMail = new PHPShopMail($_POST['mail'], $this->adminmail, $title, '', true, true);
$content = ParseTemplateReturn('./phpshop/lib/templates/order/usermail.tpl', true);
$PHPShopMail->sendMailNow($content);
$this->set('shop_admin', "http://" . $_SERVER['SERVER_NAME'] . $this->getValue('dir.dir') . "/phpshop/admpanel/");
$this->set('time', date("d-m-y H:i a"));
$this->set('ip', $_SERVER['REMOTE_ADDR']);
$title_adm = $this->lang('mail_title_adm') . $_POST['ouid'] . "/" . date("d-m-y");
$PHPShopMail = new PHPShopMail($this->adminmail, $this->adminmail, $title_adm, '', true, true, array('replyto' => $_POST['mail']));
$content_adm = ParseTemplateReturn('./phpshop/lib/templates/order/adminmail.tpl', true);
if ($this->setHook(__CLASS__, __FUNCTION__, $content_adm, 'END'))
return true;
$PHPShopMail->sendMailNow($content_adm);
}
function push() {
if ($this->setHook(__CLASS__, __FUNCTION__))
return true;
if ($this->PHPShopSystem->ifSerilizeParam('admoption.push_enabled')) {
$msg = $this->lang('mail_title_adm') . $this->ouid . " - " . $this->total . " " . $this->currency;
PHPShopObj::loadClass(array("push"));
$PHPShopPush = new PHPShopPush();
$PHPShopPush->send($msg);
}
}
function sms() {
if ($this->setHook(__CLASS__, __FUNCTION__))
return true;
if ($this->PHPShopSystem->ifSerilizeParam('admoption.sms_enabled')) {
$msg = $this->lang('mail_title_adm') . $this->ouid . " - " . $this->total . " " . $this->currency;
$phone = $this->getValue('sms.phone');
include_once($this->getValue('file.sms'));
SendSMS($msg, $phone);
}
}
function currencyMultibase($sum){
if (defined("HostID")){
$this->rate = $this->PHPShopSystem->getDefaultValutaKurs(true);
$sum = $sum * $this->rate;
$sum = number_format($sum, $this->PHPShopOrder->format, '.', ' ');
$this->currency = $this->PHPShopSystem->getDefaultValutaCode(true);
}
else {
$this->rate=1;
}
return $sum;
}
function ofd($order_id) {
global $_classPath;
$ofd = 'atol';
include_once($_classPath . 'modules/' . substr($ofd, 0, 15) . '/api.php');
if (function_exists('OFDStart')) {
$PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['orders']);
$PHPShopOrm->debug = false;
$data = $PHPShopOrm->select(array('*'), array('id' => '=' . intval($order_id)), false, array('limit' => '1'));
OFDStart($data);
}
}
function write() {
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST, 'START'))
return true;
$person = array(
"ouid" => $this->ouid,
"data" => date("U"),
"time" => date("H:s a"),
"mail" => PHPShopSecurity::TotalClean($_POST['mail'], 3),
"name_person" => PHPShopSecurity::TotalClean($this->get('user_name')),
"dostavka_metod" => intval($_POST['dostavka_metod']),
"discount" => $this->discount,
"user_id" => $this->userId,
"order_metod" => intval($_POST['order_metod']));
$cart = array(
"cart" => $this->PHPShopCart->getArray(),
"num" => $this->num,
"sum" => $this->sum,
"weight" => $this->weight,
"dostavka" => $this->delivery);
if ($this->delivery_free)
$cart['delivery_free'] = true;
$this->status = array(
"maneger" => $this->manager_comment,
"time" => "");
$this->order = serialize(array("Cart" => $cart, "Person" => $person));
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST, 'MIDDLE'))
return true;
$insert = $_POST;
$insert['datas_new'] = $insert['date_new'] = $this->datas = time();
$insert['uid_new'] = $this->ouid;
$insert['orders_new'] = $this->order;
$insert['status_new'] = serialize($this->status);
$insert['user_new'] = $this->userId;
$insert['dop_info_new'] = PHPShopSecurity::CleanStr($_POST['dop_info']);
$insert['sum_new'] = $this->total;
$insert['servers_new'] = HostID;
$insert['admin_new'] = HostAdmin;
$insert['bonus_minus_new']=$this->bonus_minus;
$insert['bonus_plus_new']=$this->bonus_plus;
$insert['company_new']=$this->company;
if (!class_exists('PHPShopUsers'))
PHPShopObj::importCore('users');
$PHPShopUsers = new PHPShopUsers();
$adresData = $PHPShopUsers->update_user_adres();
if(empty($insert['tel_new'])){
$insert['tel_new']=$_SESSION['UsersTel'];
}
if(empty($insert['fio_new'])){
$insert['fio_new']=$_SESSION['UsersName'];
}
if (is_array($adresData))
$insert = array_merge($insert, $adresData);
if ($this->setHook(__CLASS__, __FUNCTION__, $insert, 'END'))
return true;
$result = $this->PHPShopOrm->insert($insert);
$this->error_report($result, array("Cart" => $cart, "Person" => $person, 'insert' => $insert));
return $result;
}
function error_report($result, $var) {
if (!is_int($result)) {
$title = '' . $_POST['ouid'] . '' . $this->PHPShopSystem->getName() . "/" . date("d-m-y");
$content = '' . $result . '
';
ob_start();
print_r($var);
$content .= ob_get_clean();
if ($this->setHook(__CLASS__, __FUNCTION__, $content))
return true;
new PHPShopMail($this->PHPShopSystem->getParam('adminmail2'), $this->PHPShopSystem->getParam('adminmail2'), $title, $content);
}
}
}
function mailcartforma($val, $option) {
global $PHPShopModules,$PHPShopOrder;
if (empty($val['name']))
return true;
$hook = $PHPShopModules->setHookHandler(__FUNCTION__, __FUNCTION__, array(&$val), $option);
if ($hook)
return $hook;
if (!empty($val['parent_uid']))
$val['uid'] = $val['parent_uid'];
$val['price']*=$option['rate'];
$val['price'] = number_format($val['price'], $PHPShopOrder->format, '.', '');
$dis = '<p><img style="max-width:50px;max-height:50px" src="http://'.$_SERVER['SERVER_NAME'].$val['pic_small'].'" align="left" alt="">'.$val['uid'] . " " . $val['name'] . " (" . $val['num'] . " " . $val['ed_izm'] . " * " . $val['price'] . ") -- " . ($val['price'] * $val['num']) . " " . $option['currency'] . "</p>
";
return $dis;
}
?>