Overview

Packages

  • None
  • PHPShopAjaxElements
  • PHPShopAjaxElementsDepricated
  • PHPShopArray
  • PHPShopClass
    • Helper
  • PHPShopCore
  • PHPShopCoreDepricated
  • PHPShopCoreFunction
  • PHPShopDepricated
  • PHPShopElements
  • PHPShopElementsDepricated
  • PHPShopGUI
  • PHPShopInc
  • PHPShopObj
  • PHPShopParser
  • PHPShopShopCore
  • PHPShopTest

Classes

  • AjaxNotice
  • AjaxPricemail
  • AjaxReview
  • fase4_rdf
  • inwords
  • PHPShop404
  • PHPShopAdminRule
  • PHPShopAnalitica
  • PHPShopArray
  • PHPShopBannerElement
  • PHPShopBase
  • PHPShopBaseXml
  • PHPShopBonus
  • PHPShopBrandsElement
  • PHPShopCart
  • PHPShopCartElement
  • PHPShopCategory
  • PHPShopCategoryArray
  • PHPShopClients
  • PHPShopCloudElement
  • PHPShopCommerceML
  • PHPShopCompanyArray
  • PHPShopCompare
  • PHPShopCore
  • PHPShopCoreElement
  • PHPShopCoretest
  • PHPShopCssParser
  • PHPShopCurrencyElement
  • PHPShopDate
  • PHPShopDebug
  • PHPShopDelivery
  • PHPShopDeliveryArray
  • PHPShopDoc
  • PHPShopDone
  • PHPShopElements
  • PHPShopError
  • PHPShopExcel
  • PHPShopFail
  • PHPShopFile
  • PHPShopForma
  • PHPShopFrontInterface
  • PHPShopGbook
  • PHPShopGbookElement
  • PHPShopGUI
  • PHPShopIndex
  • PHPShopInterface
  • PHPShopLang
  • PHPShopLinks
  • PHPShopMail
  • PHPShopMailFile
  • PHPShopMap
  • PHPShopMath
  • PHPShopModules
  • PHPShopNav
  • PHPShopNewprice
  • PHPShopNews
  • PHPShopNewsElement
  • PHPShopNewtip
  • PHPShopObj
  • PHPShopOpros
  • PHPShopOprosElement
  • PHPShopOrder
  • PHPShopOrderDelivery
  • PHPShopOrderFunction
  • PHPShopOrderStatusArray
  • PHPShopOrm
  • PHPShopPage
  • PHPShopPageCatalogElement
  • PHPShopPageCategory
  • PHPShopPageCategoryArray
  • PHPShopPages
  • PHPShopParentNameArray
  • PHPShopParser
  • PHPShopPayment
  • PHPShopPaymentArray
  • PHPShopPaymentResult
  • PHPShopPhoto
  • PHPShopPhotoCategory
  • PHPShopPhotoCategoryArray
  • PHPShopPhotoElement
  • PHPShopPrice
  • PHPShopPricemail
  • PHPShopPrint
  • PHPShopProduct
  • PHPShopProductArray
  • PHPShopProductElements
  • PHPShopProductFunction
  • PHPShopProductIconElements
  • PHPShopProductIndexElements
  • PHPShopPromotions
  • PHPShopPush
  • PHPShopReadCsvNative
  • PHPShopRecaptchaElement
  • PHPShopRestore
  • PHPShopRssParser
  • PHPShopSearch
  • PHPShopSecurity
  • PHPShopSelection
  • PHPShopSelectioncat
  • PHPShopShop
  • PHPShopShopCatalogElement
  • PHPShopShopCore
  • PHPShopSkinElement
  • PHPShopSliderElement
  • PHPShopSort
  • PHPShopSortAjax
  • PHPShopSortArray
  • PHPShopSortCategoryArray
  • PHPShopSortElement
  • PHPShopSortSearch
  • PHPShopSpec
  • PHPShopString
  • PHPShopSuccess
  • PHPShopSystem
  • PHPShopTemplates
  • PHPShopText
  • PHPShopTextElement
  • PHPShopUnsubscribe
  • PHPShopUpdate
  • PHPShopUser
  • PHPShopUserElement
  • PHPShopUserFunction
  • PHPShopUsers
  • PHPShopUserStatus
  • PHPShopUserStatusArray
  • PHPShopValuta
  • PHPShopValutaArray
  • rateForComment
  • XMLparser

Functions

  • __
  • __hide
  • _e
  • action_order_info
  • allowedFunctions
  • array2iconv
  • avg_rate
  • calendar
  • catalog_meta
  • CheckCanGzip
  • comment_rate
  • debug
  • delivery
  • DispComment
  • evalstr
  • GetDeliveryPrice
  • getExcelInfoUid
  • GetFile
  • getFotoIconPodrobno
  • getfullname
  • getgoodname
  • getLicense
  • GetVoteValue
  • getYandexSearchSql
  • GzDocOut
  • image_gallery
  • import
  • json_encode
  • json_fix_cyr
  • json_fix_utf
  • mailcartforma
  • makeCalendar
  • message_activation
  • message_register_success
  • MessageList
  • moname
  • Nav_comment
  • Nav_messages
  • notice_add
  • notice_list
  • notice_mail
  • NumFrom
  • option_check
  • option_select
  • option_select_add
  • order_list
  • ordercartforma
  • Page_comment
  • Page_messages
  • parse_ini_file_true
  • parseDatabase
  • Parser
  • ParseTemplate
  • ParseTemplateReturn
  • PHPShopAutoLoadClass
  • phpshopparserevalstr
  • preExtractCallBack
  • product_meta
  • query_filter
  • query_multibase
  • rating
  • ratingshort
  • ratingtop
  • readDatabase
  • returnSmile
  • search_base
  • set_meta
  • setAutokeyword
  • ShowStars
  • ShowStars2
  • sort_table
  • sorttemplateexample
  • stripslashes_deep
  • SysValueReturn
  • timer
  • tmpGetFile
  • user_message
  • usercartforma
  • userdeleveryforma
  • userfiles
  • userorderdoclink
  • userorderfiles
  • userorderpaymentlink
  • utf8_win1251
  • writeLangFile
  • xml2array
  • Overview
  • Package
  • Class
  • Tree
  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: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 
<?php

if (!defined("OBJENABLED"))
    require_once(dirname(__FILE__) . "/obj.class.php");

/**

 * @author PHPShop Software
 * @version 1.3
 * @package PHPShopObj
 */
class PHPShopOrderFunction extends PHPShopObj {

    var $objID;
    var $productID;
    var $default_valuta_iso;
    var $default_valuta_name;
    var $default_valuta_code;

    /**



     */
    function __construct($objID = false, $import_data = null) {
        global $PHPShopSystem;

        if ($objID) {
            $this->objID = $objID;
            $this->objBase = $GLOBALS['SysValue']['base']['orders'];
            parent::__construct('id', $import_data);

            //
            $paramOrder = parent::unserializeParam("orders");
            $this->order_metod_id = $paramOrder['Person']['order_metod'];
        }

        parent::loadClass("system");
        parent::loadClass("delivery");

        //
        if (!$PHPShopSystem)
            $this->PHPShopSystem = new PHPShopSystem();
        else
            $this->PHPShopSystem = &$PHPShopSystem;

        $this->format = intval($this->PHPShopSystem->getSerilizeParam("admoption.price_znak"));

        //
        $this->getDefaultValutaObj();
    }

    /**


     */
    function import($data) {
        $this->objRow = $data;

        //
        $paramOrder = parent::unserializeParam("orders");
        $this->order_metod_id = $paramOrder['Person']['order_metod'];
    }

    /**

     * @return int
     */
    function getOplataMetodId() {
        return $this->order_metod_id;
    }

    /**

     * @return string
     */
    function getOplataMetodName() {
        parent::loadClass("payment");

        //
        $Payment = new PHPShopPayment($this->order_metod_id);
        $this->order_metod_name = $Payment->getName();
        return $this->order_metod_name;
    }

    /**

     * @return string
     */
    function getStatus() {
        global $PHPShopOrderStatusArray;

        if (empty($PHPShopOrderStatusArray))
            $PHPShopOrderStatusArray = new PHPShopOrderStatusArray();

        $status = $this->getParam('statusi');
        if (!empty($status))
            return $PHPShopOrderStatusArray->getParam($this->getParam('statusi') . '.name');
        else
            return __('');
    }

    /**

     * @return string
     */
    function getStatusColor() {
        global $PHPShopOrderStatusArray;

        if (empty($PHPShopOrderStatusArray))
            $PHPShopOrderStatusArray = new PHPShopOrderStatusArray();

        $status = $this->getParam('statusi');
        if (!empty($status))
            return $PHPShopOrderStatusArray->getParam($this->getParam('statusi') . '.color');
    }

    /**


     * @return int
     */
    function getValutaId($productID) {
        parent::loadClass("product");

        //
        $Product = new PHPShopProduct($productID);
        $this->valutaID = $Product->getValutaID();

        return $this->valutaID;
    }

    /**


     * @return string
     */
    function getValutaIso($productID) {
        $this->getValutaId($productID);
        parent::loadClass("valuta");
        $valutaID = $this->valutaID;

        //
        $Valuta = new PHPShopValuta($valutaID);
        $this->ValutaIso = $Valuta->getIso();

        if (empty($this->ValutaIso)) {
            return $this->default_valuta_iso;
        }
        return $Valuta->getIso();
    }

    /**


     */
    function getDefaultValutaObj() {

        $this->default_valuta_id = $this->PHPShopSystem->getDefaultValutaId();
        parent::loadClass("valuta");

        $PHPShopValuta = new PHPShopValuta($this->default_valuta_id);
        $this->default_valuta_iso = $PHPShopValuta->getIso();
        $this->default_valuta_name = $PHPShopValuta->getName();
        $this->default_valuta_code = $PHPShopValuta->getCode();
        $this->default_valuta_kurs = $PHPShopValuta->getKurs();
        $this->default_valuta_kurs_beznal = $this->default_valuta_kurs;
    }

    /**




     * @return float
     */
    function returnSumma($sum, $disc = 0, $def = '', $delivery = 0) {
        global $PHPShopSystem;

        if (!$PHPShopSystem) {
            $kurs = $this->default_valuta_kurs;
            $this->format = 0;
        } else {
            $kurs = $PHPShopSystem->getDefaultValutaKurs(false);
        }

        $sum *= $kurs;
        $sum = $sum - ($sum * $disc / 100);

        //
        PHPShopObj::loadClass('bonus');
        $PHPShopBonus = new PHPShopBonus($_SESSION['UsersId']);
        $this->bonus_minus = $PHPShopBonus->getUserBonus($sum);
        $this->bonus_plus = $PHPShopBonus->setUserBonus($sum);

        $sum = $sum - $this->bonus_minus;

        return number_format($sum + $delivery, $this->format, ".", $def);
    }


    /**



     * @return float
     */
    function returnSummaBeznal($sum, $disc) {
        $kurs = $this->default_valuta_kurs_beznal;
        $sum *= $kurs;
        $sum = $sum - ($sum * $disc / 100);
        return number_format($sum, $this->format, ".", "");
    }

    /**



     * @return float
     */
    function ChekDiscount($mysum, $cart = null) {

        if (!class_exists('PHPShopUserStatus'))
            PHPShopObj::loadClass("user");

        if (!class_exists('PHPShopOrm'))
            PHPShopObj::loadClass("orm");

        if (!class_exists('PHPShopSecurity'))
            PHPShopObj::loadClass("security");

        if (!class_exists('PHPShopCart'))
            PHPShopObj::loadClass("cart");

        $maxsum = 0;
        $maxdiscount = 0;
        $PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['discount']);
        $row = $PHPShopOrm->select(array('*'), array('sum' => "<='$mysum'", 'enabled' => "='1'"), array('order' => 'sum desc'), array('limit' => 1));
        if (is_array($row)) {
            $sum = $row['sum'];
            if ($sum > $maxsum) {
                $PHPShopCart = new PHPShopCart();
                //
                if(!is_null($cart) && is_array($cart)) {
                    foreach ($cart as $key => $product) {
                        unset($PHPShopCart->_CART[$key]['promo_price']);
                        unset($PHPShopCart->_CART[$key]['order_discount_disabled']);

                        if(isset($row['block_old_price']) && (int) $row['block_old_price'] === 1 && (int) $product['price_n'] > 0) {
                            $PHPShopCart->_CART[$key]['promo_price'] = $product['price'];
                            $PHPShopCart->_CART[$key]['order_discount_disabled'] = true;
                        }

                        $category_ar = array_diff(explode(',', $row['block_categories']), ['']);
                        if(in_array($product['category'], $category_ar)) {
                            $PHPShopCart->_CART[$key]['promo_price'] = $product['price'];
                            $PHPShopCart->_CART[$key]['order_discount_disabled'] = true;
                        }
                    }
                }

                $maxsum = $sum;
                $action = $row['action'];
                $maxdiscount = $row['discount'];
            }
        }

        //
        if (!empty($_SESSION['UsersStatus']) and PHPShopSecurity::true_num($_SESSION['UsersStatus'])) {
            $PHPShopUserStatus = new PHPShopUserStatus($_SESSION['UsersStatus']);
            $userdiscount = $PHPShopUserStatus->getDiscount();

            //
            if ($action == 1) {

                if ($userdiscount > $maxdiscount)
                    $maxdiscount = $userdiscount;
            }
            //
            else {
                $maxdiscount = $maxdiscount + $userdiscount;
            }
        }

        return $maxdiscount;
    }

    /**



     * @return string
     */
    function cart($function, $option = false) {
        $list = null;
        $order = $this->unserializeParam('orders');
        if (is_array($order['Cart']['cart'])) {
            $cart = $order['Cart']['cart'];
            foreach ($order['Cart']['cart'] as $key => $val) {
                $cart[$key]['price'] = $this->ReturnSummaBeznal($val['price'], 0);
                $cart[$key]['total'] = $this->ReturnSummaBeznal($val['price'] * $val['num'], 0);
            }
        }

        if (is_array($cart))
            foreach ($cart as $v)
                if (function_exists($function)) {
                    $list .= call_user_func_array($function, array($v, $option));
                }

        return $list;
    }

    /**


     * @return string
     */
    function yurData($row) {
        $fielsName = array(
            "org_name" => "",
            "org_inn" => "",
            "org_kpp" => "",
            "org_yur_adres" => "",
            "org_fakt_adres" => "",
            "org_ras" => "",
            "org_bank" => "",
            "org_kor" => "",
            "org_bik" => "",
            "org_city" => "",
        );

        $disp = "";
        foreach ($fielsName as $key => $value) {
            if (!empty($row[$key]))
                $disp .= PHPShopText::b($value . ": ") . $row[$key] . "<br>";
        }

        return $disp;
    }

    /**



     * @return string
     */
    function delivery($function, $option = false) {
        $list = null;
        $i = 0;
        $order = $this->unserializeParam('orders');

        $PHPShopDelivery = new PHPShopDelivery($order['Person']['dostavka_metod']);
        $delivery['id'] = $order['Person']['dostavka_metod'];
        $name = $PHPShopDelivery->getCity();

        if (empty($order['Cart']['dostavka']))
            $delivery['price'] = number_format($PHPShopDelivery->getPrice($order['Cart']['sum'], $order['Cart']['weight']), $this->format, '.', '');
        else
            $delivery['price'] = number_format($order['Cart']['dostavka'], $this->format, '.', '');
        $delivery['data_fields'] = $PHPShopDelivery->getParam('data_fields');

        $PID = $PHPShopDelivery->getParam('PID');
        while ($PID AND $i < 5) {
            $PHPShopDeliveryTemp = new PHPShopDelivery($PID);
            $PID = $PHPShopDeliveryTemp->getParam('PID');
            $name = $PHPShopDeliveryTemp->getCity() . ", $name";
            $i++;
        }

        $delivery['name'] = $name;

        if (function_exists($function)) {
            $list = call_user_func_array($function, array($delivery, $option));
            return $list;
        } else
            return $delivery;
    }

    /**

     * @return float
     */
    function getCartSumma() {
        $order = $this->unserializeParam('orders');
        if (!empty($order['Person']['discount']))
            $discount = $order['Person']['discount'];
        else
            $discount = 0;

        if (!empty($order['Cart']['sum'])) {
            $sum = $this->ReturnSumma($order['Cart']['sum'], $discount);
            return number_format($sum, $this->format, '.', '');
        }
    }

    /**

     * @return float
     */
    function getDeliverySumma() {
        $order = $this->unserializeParam('orders');

        if (isset($order['Cart']['dostavka']))
            return (float) $order['Cart']['dostavka'];

        if (!empty($order['Person']['discount']))
            $discount = $order['Person']['discount'];
        else
            $discount = 0;
        if (!empty($order['Cart']['sum']))
            $sum = $this->ReturnSumma($order['Cart']['sum'], $discount);
        else
            $sum = 0;
        if (!empty($order['Person']['dostavka_metod']) and ! empty($sum)) {
            $PHPShopDelivery = new PHPShopDelivery($order['Person']['dostavka_metod']);
            return (float) $PHPShopDelivery->getPrice($sum, $order['Cart']['weight']);
        }
    }

    /**

     * @return float
     */
    function getDiscount() {
        $order = $this->unserializeParam('orders');
        if (!empty($order['Person']['discount']))
            return $order['Person']['discount'];
        else
            return 0;
    }

    /**

     * @return int
     */
    function getNum() {
        $order = $this->unserializeParam('orders');
        if (!empty($order['Cart']['num']))
            return $order['Cart']['num'];
        else
            return 0;
    }

    /**

     * @return string
     */
    function getMail() {
        $order = $this->unserializeParam('orders');
        return $order['Person']['mail'];
    }

    /**


     * @return float
     */
    function getTotal($nds = false, $def = '') {

        if ($this->getValue('sum') > 0)
            $total = $this->getValue('sum');
        else {
            $cart = $this->getCartSumma();
            $delivery = $this->getDeliverySumma();
            $total = $cart + $delivery;
        }
        if (!empty($nds))
            $total = $total * $this->PHPShopSystem->getParam('nds') / (100 + $this->PHPShopSystem->getParam('nds'));
        else
            $total = $total;

        $total = number_format($total, $this->format, '.', $def);
        return $total;
    }

    /**

     * @return string
     */
    function getStatusTime() {
        return $this->getSerilizeParam('status.time');
    }

    /**

     * @param string $param
     * @return string
     */
    function getSerilizeParam($param) {
        $param = explode(".", $param);
        $val = parent::unserializeParam($param[0]);
        if (count($param) > 2)
            return $val[$param[1]][$param[2]];
        return $val[$param[1]];
    }

    /**


     */
    function checkPay() {
        $PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['payment']);
        $data = $PHPShopOrm->select(array('*'), array('uid' => "=" . intval(str_replace('-', '', $this->getParam('uid'))), 'sum' => '=' . $this->getParam('sum')), array('order' => 'datas desc'), array('limit' => 1));
        if (is_array($data))
            return $data['datas'];
    }

    public function changePaymentStatus($paymentStatus) {
        $orm = new PHPShopOrm($this->objBase);

        $orm->update(array('paid_new' => (int) $paymentStatus), array('id' => "='" . $this->objID . "'"));
    }

    public function changeStatus($statusId, $oldStatus)
    {
        global $PHPShopBase, $_classPath;

        $order = $this->unserializeParam('orders');
        $statusObj = new PHPShopOrderStatusArray();
        $statuses = $statusObj->getArray();
        $DeliveryArray = (new PHPShopDeliveryArray())->getArray();
        $warehouseID = $DeliveryArray[$order['Person']['dostavka_metod']]['warehouse'];

        //
        if(!is_array($order['Cart']['cart']) || $oldStatus === $statusId) {
            return;
        }

        $PHPShopSystem = new PHPShopSystem();

        //
        if ((int) $oldStatus != 0 && $statusId == 1) {
            if ((int) $PHPShopSystem->getSerilizeParam('admoption.sklad_status') > 1) {
                foreach ($order['Cart']['cart'] as $val) {
                    $product = new PHPShopProduct((int) $val['id']);
                    if(is_array($product->objRow)) {
                        $product->addToWarehouse($val['num'], (int) $val['parent'], $warehouseID);
                    }
                }
            }
        } else if ($statuses[$statusId]['sklad_action'] == 1 and $statuses[$oldStatus]['sklad_action'] != 1) {
            foreach ($order['Cart']['cart'] as $val) {
                $product = new PHPShopProduct((int) $val['id']);
                if(is_array($product->objRow)) {
                    $product->removeFromWarehouse($val['num'], (int) $val['parent'], $warehouseID);
                }
            }
        }

        //
        if (!empty($statuses[$statusId]['sms_action'])) {

            $this->objRow['tel'];

            $msg = strtoupper(PHPShopString::check_idna($_SERVER['SERVER_NAME'], true)) . ': ' . $PHPShopBase->getParam('lang.sms_user') . $this->objRow['uid'] . " - " . $statuses[$statusId]['name'];

            $phone = trim(str_replace(array('(', ')', '-', '+', '&#43;'), '', $this->objRow['tel']));
            //
            $first_d = substr($phone, 0, 1);
            if ($first_d != 8 and $first_d != 7)
                $phone = '7' . $phone;

            $lib = str_replace('./phpshop/', $_classPath, $PHPShopBase->getParam('file.sms'));
            include_once $lib;
            SendSMS($msg, $phone);
        }

        //
        if((int) $statusObj->getParam($statusId . '.mail_action') === 1) {
            $this->sendStatusChangedMail();
        }

        $PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['orders']);
        $PHPShopOrm->debug = false;

        $update = ['statusi_new' => $statusId];
        //
        if($statusId === 101) {
            $update['paid_new'] = 1;
        }

        $PHPShopOrm->update($update, ['id' => '=' . $this->objID]);
        $this->objRow['statusi'] = $statusId;
    }

    /**

     */
    private function sendStatusChangedMail() {
        $PHPShopOrderStatusArray = new PHPShopOrderStatusArray();
        $PHPShopSystem = new PHPShopSystem();

        PHPShopObj::loadClass("parser");
        PHPShopObj::loadClass("mail");
        PHPShopParser::set('ouid', $this->getParam('uid'));
        PHPShopParser::set('date', PHPShopDate::dataV($this->getParam('datas')));
        PHPShopParser::set('status', $this->getStatus());
        PHPShopParser::set('fio', $this->getParam('fio'));
        PHPShopParser::set('sum', $this->getParam('sum'));
        PHPShopParser::set('company', $PHPShopSystem->getParam('name'));
        PHPShopParser::set('manager', $this->getSerilizeParam('status.maneger'));
        PHPShopParser::set('tracking', $this->getParam('tracking'));

        $protocol = 'http://';
        if(!empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS'])) {
            $protocol = 'https://';
        }
        PHPShopParser::set('account', $protocol . $_SERVER['SERVER_NAME'] . 'phpshop/forms/account/forma.html?orderId=' . $this->objID . '&tip=2&datas=' . $this->getParam('datas'));
        PHPShopParser::set('bonus', $this->getParam('bonus_plus'));

        $title = __('') . ' ' . $this->getParam('uid') . ' ' . __('') . ' ' .$this->getStatus();

        $message = $PHPShopOrderStatusArray->getParam($this->getParam('statusi') . '.mail_message');

        if (strlen($message) < 7)
            $message = '<h3>' . __('') . '  &#8470;' . $this->getParam('uid') . '  ' . __('') . ' "' . $this->getStatus() . '"</h3>';

        PHPShopParser::set('message', preg_replace_callback("/@([a-zA-Z0-9_]+)@/", 'PHPShopParser::SysValueReturn', $message));
        $PHPShopMail = new PHPShopMail($this->getMail(), $PHPShopSystem->getValue('adminmail2'), $title, '', true, true);

        //
        if((int) $this->getParam('servers') > 0) {
            $orm = new PHPShopOrm($GLOBALS['SysValue']['base']['servers']);
            $showcaseData = $orm->getOne(['*'], ['id' => sprintf("='%s'", (int) $this->getParam('servers'))]);

            if(is_array($showcaseData)) {
                PHPShopParser::set('serverPath', $showcaseData['host'] . "/" . $GLOBALS['SysValue']['dir']['dir']);

                if (!empty($showcaseData['name']))
                    PHPShopParser::set('shopName', $showcaseData['name']);
                if (!empty($showcaseData['logo']))
                    PHPShopParser::set('logo', $showcaseData['logo']);
                if (!empty($showcaseData['company']))
                    PHPShopParser::set('org_name', $showcaseData['company']);
                if (!empty($showcaseData['adres']))
                    PHPShopParser::set('org_adres', $showcaseData['adres']);
                if (!empty($showcaseData['tel']))
                    PHPShopParser::set('telNum', $showcaseData['tel']);
                if (!empty($showcaseData['adminmail']))
                    PHPShopParser::set('adminMail', $showcaseData['adminmail']);

                $PHPShopMail->mail->setFrom($PHPShopMail->from, $showcaseData['name']);
            }
        }
        $content = PHPShopParser::file(dirname(__DIR__) . '/lib/templates/order/status.tpl', true);
        if (!empty($content)) {
            $PHPShopMail->sendMailNow($content);
        }
    }
}

PHPShopObj::loadClass('array');

/**


 * @author PHPShop Software
 * @version 1.2
 * @package PHPShopObj
 */
class PHPShopOrderStatusArray extends PHPShopArray {

    /**

     */
    function __construct() {
        $this->objBase = $GLOBALS['SysValue']['base']['order_status'];
        $this->order = array('order' => 'num');
        parent::__construct('id', 'name', 'color', 'sklad_action', 'cumulative_action', 'mail_action', 'mail_message', 'sms_action','num');
    }

}

?>
PHPShop 6.X API documentation generated by ApiGen