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:
<?php
PHPShopObj::loadClass('order');
$PHPShopOrder = new PHPShopOrderFunction();
class PHPShopOrder extends PHPShopCore {
function __construct() {
$this->debug = false;
$this->objBase = $GLOBALS['SysValue']['base']['orders'];
$this->action = array("post" => array('id_edit', 'id_delete'), "get" => "cart", 'nav' => 'index');
parent::__construct();
$format = $this->getValue('my.order_prefix_format');
if (!empty($format))
$this->format = $format;
else
$this->format = 2;
PHPShopObj::loadClass('cart');
$this->PHPShopCart = new PHPShopCart();
}
function index() {
global $PHPShopOrder;
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
$this->import();
$this->SysValue['cache']['last_modified'] = false;
$this->title = $this->lang('order_title') . ' - ' . $this->PHPShopSystem->getValue("title");
if ($PHPShopOrder->default_valuta_iso == 'RUR' or $PHPShopOrder->default_valuta_iso == "RUB")
$this->set('currency', 'p');
else
$this->set('currency', $PHPShopOrder->default_valuta_code);
if ($this->PHPShopCart->getNum() > 0)
$this->order();
else
$this->error();
$PHPShopCartElement = new PHPShopCartElement(true);
$PHPShopCartElement->init('miniCart');
$this->set('productValutaName', $this->get('currency'));
}
function cart() {
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST))
return true;
$this->PHPShopCart->clean();
$this->index();
}
function id_delete() {
global $PHPShopAnalitica;
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST))
return true;
$PHPShopAnalitica->init(__FUNCTION__, $_POST);
$this->PHPShopCart->del($_POST['id_delete']);
$this->index();
}
function id_edit() {
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST))
return true;
if (PHPShopSecurity::true_num($_POST['num_new']))
$this->PHPShopCart->edit($_POST['id_edit'], $_POST['num_new'], $_POST['edit_num']);
$this->index();
}
function product() {
global $PHPShopOrder;
$hook = $this->setHook(__CLASS__, __FUNCTION__, false, 'START');
if ($hook)
return $hook;
$this->set('currency', $this->PHPShopSystem->getValutaIcon(true));
$cart = $this->PHPShopCart->display('ordercartforma');
$this->set('display_cart', $cart);
$this->set('cart_num', $this->PHPShopCart->getNum());
$this->set('discount', $PHPShopOrder->ChekDiscount($this->PHPShopCart->getSum(true), $this->PHPShopCart->getArray()));
$sum_cart = $this->PHPShopCart->getSum(true);
$sum_discount_off = $this->PHPShopCart->getSumNoDiscount(true);
$sum_discount_on = $PHPShopOrder->returnSumma($this->PHPShopCart->getSumPromo(true));
$sum_discount_on += $PHPShopOrder->returnSumma($this->PHPShopCart->getSumWithoutPromo(true), $this->get('discount'));
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->set('discount_sum', number_format($discount_sum * $this->PHPShopSystem->getDefaultValutaKurs(false), $PHPShopOrder->format, '.', ' '));
$this->set('cart_sum', $sum_cart);
$this->set('cart_sum_discount_off', number_format($sum_discount_off, $PHPShopOrder->format, '.', ' '));
$this->set('cart_weight', $this->PHPShopCart->getWeight());
PHPShopObj::loadClass('delivery');
$this->set('delivery_price', PHPShopDelivery::getPriceDefault());
$this->set('total', number_format($sum_cart + $this->get('delivery_price'), $PHPShopOrder->format, '.', ' '));
$this->setHook(__CLASS__, __FUNCTION__, false, 'END');
if (PHPShopParser::checkFile('order/cart.tpl'))
return ParseTemplateReturn('order/cart.tpl');
else
return ParseTemplateReturn('phpshop/lib/templates/order/cart.tpl', true);
}
function delivery() {
$hook = $this->setHook(__CLASS__, __FUNCTION__);
if ($hook)
return $hook;
return $this->doLoadFunction(__CLASS__, __FUNCTION__, @$_GET['d']);
}
function error() {
$message = '<div class="phpshop-empty-cart">' . $this->message($this->lang('bad_cart_1'), $this->lang('bad_order_mesage_2')) . '</div>';
$message .= "<script language='JavaScript'>
document.getElementById('num').innerHTML = '0';
document.getElementById('sum').innerHTML = '0';
document.getElementById('order').style.display = 'none';
</script>";
$this->set('mesageText', $message);
$this->set('orderMesage', ParseTemplateReturn($this->getValue('templates.order_forma_mesage')));
$this->setHook(__CLASS__, __FUNCTION__);
$this->parseTemplate($this->getValue('templates.order_forma_mesage_main'));
}
function message($title, $content) {
$message = PHPShopText::h4($title, 'text-danger');
$message .= PHPShopText::message($content, false, false, false, 'text-muted');
return $message;
}
function payment() {
PHPShopObj::loadClass('payment');
$where['name']='!=""';
if (defined("HostID"))
$where['servers'] = " REGEXP 'i" . HostID . "i'";
elseif (defined("HostMain"))
$where['name'] .= ' and (servers ="" or servers REGEXP "i1000i")';
$PHPShopPayment = new PHPShopPaymentArray($where);
$Payment = $PHPShopPayment->getArray();
if (is_array($Payment))
foreach ($Payment as $val) {
if (!empty($val['enabled']) OR $val['path'] == 'modules') {
$this->value[$val['id']] = array($val['name'], $val['id'], false);
$this->set('paymentIcon', '');
if(!empty($val['icon'])) {
$this->set('paymentIcon', $val['icon']);
}
$this->set('paymentId', $val['id']);
$this->set('paymentId', $val['id']);
$this->set('paymentTitle', $val['name']);
if (PHPShopParser::checkFile('order/payment.tpl'))
$disp .= ParseTemplateReturn('order/payment.tpl');
else
$disp .= ParseTemplateReturn('phpshop/lib/templates/order/payment.tpl', true);
}
if (!empty($val['yur_data_flag'])) {
$showYurDataForPaymentClass .= " showYurDataForPaymentClass" . $val['id'];
}
}
$hook = $this->setHook(__CLASS__, __FUNCTION__, $this->value);
if ($hook)
return $hook;
if (!empty($showYurDataForPaymentClass)) {
$this->set('showYurDataForPaymentClass', $showYurDataForPaymentClass);
if (PHPShopParser::checkFile('payment/showYurDataForPayment.tpl')) {
$this->set('showYurDataForPayment', ParseTemplateReturn('payment/showYurDataForPayment.tpl'));
} else {
$this->set('showYurDataForPayment', ParseTemplateReturn('phpshop/lib/templates/order/nt/showYurDataForPayment.tpl', true));
}
}
$this->set('orderOplata', $disp);
}
function order() {
$this->template_order_forma = $this->getValue('templates.main_order_forma');
$this->template_order_list = $this->getValue('templates.main_order_list');
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
$this->setNum();
$this->set('orderContentCart', $this->product());
$this->set('orderNum', $this->order_num);
$this->set('orderDate', date("d-m-y"));
$cart_min = $this->PHPShopSystem->getSerilizeParam('admoption.cart_minimum');
if ($cart_min <= $this->PHPShopCart->getSum(false)) {
$this->delivery();
$this->payment();
if (!empty($_SESSION['UsersId']) and PHPShopSecurity::true_num($_SESSION['UsersId'])) {
$PHPShopUser = new PHPShopUser($_SESSION['UsersId']);
$this->set('UserMail', $PHPShopUser->getValue('mail'));
$this->set('UserAdresList', $PHPShopUser->getAdresList());
$this->set('UserName', $PHPShopUser->getValue('name'));
$this->set('UserTel', $PHPShopUser->getValue('tel'));
$this->set('UserTelCode', $PHPShopUser->getValue('tel_code'));
$this->set('UserAdres', $PHPShopUser->getValue('adres'));
$this->set('UserComp', $PHPShopUser->getValue('company'));
$this->set('UserInn', $PHPShopUser->getValue('inn'));
$this->set('UserKpp', $PHPShopUser->getValue('kpp'));
$this->set('formaLock', 'readonly=1');
$this->set('ComStartReg', PHPShopText::comment());
$this->set('ComEndReg', PHPShopText::comment('>'));
$this->set('authData', parseTemplateReturn($this->getValue('templates.main_order_forma_auth_data')));
} else {
if (PHPShopParser:: checkFile($this->getValue('templates.main_order_forma_no_auth')))
$this->set('noAuth', parseTemplateReturn($this->getValue('templates.main_order_forma_no_auth')));
else
$this->set('noAuth', parseTemplateReturn($this->getValue('templates.main_order_forma_no_auth_nt'), true));
if (PHPShopParser::checkFile($this->getValue('templates.main_order_forma_no_auth_adr')))
$this->set('noAuthAdr', parseTemplateReturn($this->getValue('templates.main_order_forma_no_auth_adr')));
else
$this->set('noAuthAdr', parseTemplateReturn($this->getValue('templates.main_order_forma_no_auth_adr_nt'), true));
}
$this->setHook(__CLASS__, __FUNCTION__, false, 'MIDDLE');
if (PHPShopParser::check($this->template_order_forma, 'checkLabelForOldTemplatesNoDelete')) {
$this->set('orderContent', parseTemplateReturn($this->template_order_forma));
} else {
$this->temp = true;
$this->set('orderContent', parseTemplateReturn($this->getValue('templates.main_order_forma_nt'), true));
}
$this->setHook(__CLASS__, __FUNCTION__, false, 'MIDDLE-END');
} else {
$this->set('orderContent', $this->message($this->lang('cart_minimum') . ' ' . $cart_min . ' ' . $this->get('currency'), $this->lang('bad_order_mesage_2')));
}
$this->setHook(__CLASS__, __FUNCTION__, false, 'END');
if (empty($this->temp))
$this->parseTemplate($this->template_order_list);
else
$this->parseTemplate($this->getValue('templates.main_order_list_nt'), true);
}
function setNum() {
$row = $this->PHPShopOrm->select(array('uid'), false, array('order' => 'id desc'), array('limit' => 1));
$last = $row['uid'];
$all_num = explode("-", $last);
$ferst_num = $all_num[0];
$order_num = $ferst_num + 1;
if (empty($_SESSION['order_prefix']))
$_SESSION['order_prefix'] = substr(rand(1000, 99999), 0, $this->format);
$this->order_num = $order_num . "-" . $_SESSION['order_prefix'];
$this->setHook(__CLASS__, __FUNCTION__, $row);
}
function import() {
$this->doLoadFunction(__CLASS__, __FUNCTION__, $_GET['from']);
$this->setHook(__CLASS__, __FUNCTION__, $_GET);
}
}
PHPShopObj::loadClass('parser');
function ordercartforma($val, $option) {
global $PHPShopModules, $PHPShopSystem;
$hook = $PHPShopModules->setHookHandler(__FUNCTION__, __FUNCTION__, array(&$val), $option, 'START');
if ($hook)
return $hook;
if (empty($val['parent'])) {
PHPShopParser::set('cart_id', $val['id']);
if (!empty($val['parent_uid']))
$val['uid'] = $val['parent_uid'];
} else {
PHPShopParser::set('cart_id', $val['parent']);
}
PHPShopParser::set('cart_pic_small', $val['pic_small']);
PHPShopParser::set('cart_xid', $option['xid']);
PHPShopParser::set('cart_name', $val['name']);
PHPShopParser::set('cart_art', $val['uid']);
PHPShopParser::set('cart_num', $val['num']);
PHPShopParser::set('cart_price', number_format($val['price'] * $PHPShopSystem->getDefaultValutaKurs(true), $option['format'], '.', ' '));
PHPShopParser::set('cart_price_all', number_format($val['price'] * $val['num'] * $PHPShopSystem->getDefaultValutaKurs(true), $option['format'], '.', ' '));
if ((float) $val['price_n'] > 0)
PHPShopParser::set('cart_price_all_old', number_format($val['price_n'] * $val['num'] * $PHPShopSystem->getDefaultValutaKurs(true), $option['format'], '.', ' ') . '<span class="rubznak">' . PHPShopParser::get('currency') . '</span>');
else
PHPShopParser::set('cart_price_all_old', null);
PHPShopParser::set('cart_izm', $val['ed_izm']);
$PHPShopModules->setHookHandler(__FUNCTION__, __FUNCTION__, array(&$val), $option, 'END');
if (PHPShopParser::checkFile('order/product.tpl'))
return ParseTemplateReturn('order/product.tpl');
else
return ParseTemplateReturn('./phpshop/lib/templates/order/product.tpl', true);
}
?>