src/Controller/SoapApiController.php line 273

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Configs\Constants;
  4. use App\Service\HelloService;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Config\Definition\Exception\Exception;
  7. use Symfony\Component\HttpFoundation\RedirectResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpFoundation\Session\Session;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Twig\Environment;
  13. use Symfony\Component\HttpFoundation\Cookie;
  14. class SoapApiController extends AbstractController
  15. {
  16.     var $session;
  17.     var $twig_values;
  18.     var $respond;
  19.     var $db;
  20.     //private $wsdl = "http://flx.2bp.ru/itt/WS/api.1cws?wsdl";    //Рабочий
  21.     private $wsdl "http://api.i-t-trade.ru:8585/itt/WS/api.1cws?wsdl";    //Рабочий
  22.     private $client;
  23.     function __construct()
  24.     {
  25.         $this->session = new Session();
  26.         $this->twig_values = new TwigValuesController();
  27.         $this->db = new DBController();
  28.         //$this->session->start();
  29.         try{
  30.             //ini_set("soap.wsdl_cache_ttl", 43200);
  31.             ini_set("soap.wsdl_cache_ttl"43200);
  32.             try{
  33.                 $this->client = new \SoapClient($this->wsdl, array('login' => "api",
  34.                     'password'  => "0ne@P1@1Tt_dEX"));
  35.             }catch (\Exception $e){
  36.                 $this->session->set('error'$e->getMessage());
  37.                 //return $this->getSoapErr($twig);
  38.                 dump($e->getMessage());
  39.                 exit();
  40.             }
  41.         }catch (\Exception $e){
  42.             dump($e);
  43.             exit();
  44.         }
  45.     }
  46.     function getSoapErr(Environment $twig)
  47.     {
  48.         return new Response($twig->render('flex/login.html',[
  49.             "error" => $this->session->get('error'),]
  50.         ));
  51.     }
  52.     /**
  53.      * @Route("/auth")
  54.      */
  55.     function auth(Request $requestEnvironment $twig){
  56.         $login $request->request->get('login') ?? "";
  57.         $password $request->request->get('password') ?? "";
  58.         $remember $request->request->get('remember') ?? "off";
  59.         if($login == "" || $password == "") {
  60.             $login "test";
  61.             $password "test";
  62.         }
  63.         $response $this->authentication($login$password"""");
  64.         if($this->getError($response)) {
  65.             return new Response($twig->render('flex/login.html',
  66.                 $this->twig_values->getTwigTemplate($request),
  67.             ));
  68.         }
  69.         if(!isset($response["return"]["Token"]) || !isset($response["return"]["CustomerGuid"]))
  70.         {
  71.             return new Response($twig->render('flex/login.html',
  72.                 $this->twig_values->getTwigTemplate($request),
  73.             ));
  74.         }
  75.         $Token $response["return"]["Token"];
  76.         $CustomerGUID $response["return"]["CustomerGuid"];
  77.         $ChangePasswordAtFirstLogon $response["return"]["ChangePasswordAtFirstLogon"];
  78.         $AccessLevel $response["return"]["AccessLevel"] ?? 1;
  79.         if($login == "Bot0ne" || strtolower($login) == "e.panova@i-t-trade.ru"){
  80.             $AccessLevel "admin";
  81.         }
  82.         $this->session->set("AccessLevel"$AccessLevel);
  83.         $bonus_list $this->getBonusList($Token$CustomerGUID);
  84.         if(isset($bonus_list["return"]["Companys"])){
  85.             if(isset($bonus_list["return"]["Companys"]["GUID"])){
  86.                 $bonus_list = [$bonus_list["return"]["Companys"]];
  87.             }else{
  88.                 $bonus_list $bonus_list["return"]["Companys"];
  89.             }
  90.             $bonus_list_bool 'true';
  91.         }else{
  92.             $bonus_list = [];
  93.             $bonus_list_bool 'false';
  94.         }
  95.         $this->session->set("bonus_list"$bonus_list);
  96.         $this->session->set("bonus_list_bool"$bonus_list_bool);
  97.         $contact_info $this->getContactInfo($Token$CustomerGUID);
  98.         $persons = [];
  99.         $address = [];
  100.         if(isset($contact_info["return"]["ContactInfo"]["Person"])){
  101.             if(isset($contact_info["return"]["ContactInfo"]["Person"]["GUID"])){
  102.                 $temp_contact_info[0] = $contact_info["return"]["ContactInfo"]["Person"];
  103.                 $persons $temp_contact_info;
  104.             }else{
  105.                 $persons $contact_info["return"]["ContactInfo"]["Person"];
  106.             }
  107.         }else{
  108.             $persons = [];
  109.         }
  110.         if(isset($contact_info["return"]["ContactInfo"]["Address"])){
  111.             if(isset($contact_info["return"]["ContactInfo"]["Address"]["GUID"])){
  112.                 $temp_contact_info[0] = $contact_info["return"]["ContactInfo"]["Address"];
  113.                 $address $temp_contact_info;
  114.             }else{
  115.                 $address $contact_info["return"]["ContactInfo"]["Address"];
  116.             }
  117.         }else{
  118.             $address = [];
  119.         }
  120.         $contacts["Person"] = $persons;
  121.         $contacts["Address"] = $address;
  122.         $this->session->set("contact_info"$contacts);
  123.         $get_manager $this->getManager($Token$CustomerGUID);
  124.         if(isset($get_manager["return"]["ManagerInfo"]["GUID"])){
  125.             $temp_get_manager_info[0] = $get_manager["return"]["ManagerInfo"];
  126.             $get_manager $temp_get_manager_info;
  127.         }else{
  128.             $get_manager $get_manager["return"]["ManagerInfo"] ?? "false";
  129.         }
  130.         //ToDo this is a hard fix photo link
  131.         if($get_manager != "false"){
  132.             if(isset($get_manager["FIO"])){
  133.                 $get_manager = [$get_manager];
  134.             }
  135.             $i 0;
  136.             foreach ($get_manager as $manager){
  137.                 $get_manager[$i]["Photo"] = str_replace("http://""https://"$get_manager[$i]["Photo"]);
  138.                 if($get_manager[$i]["Photo"] == ""){
  139.                     $get_manager[$i]["Photo"] = "/img/non_img_manager.png";
  140.                 }
  141.                 $i++;
  142.             }
  143.         }
  144.         $this->session->set("manager_info"$get_manager);
  145.         $this->session->set("Token"$Token);
  146.         $this->session->set("Login"$login);
  147.         $this->session->set("CustomerGUID"$CustomerGUID);
  148.         $response $this->getCompanysList($Token$CustomerGUID);
  149.         if($this->getError($response)) {
  150.             return new Response($twig->render('flex/login.html',
  151.                 $this->twig_values->getTwigTemplate($request),
  152.             ));
  153.         }
  154.         $CompanysList $response["return"]["Companys"];
  155.         if(isset($CompanysList["GUID"])){
  156.             $CompanysList = [$CompanysList];
  157.         }
  158.         $this->session->set("CompanyGUID"$CompanysList[0]["GUID"]);
  159.         $this->session->set("CompanyDescription"$CompanysList[0]["Description"]);
  160.         $this->session->set("CompanysList"$CompanysList);
  161.         $this->getCustomerMessage();
  162.         $user_db $this->db->getOneWhereArr(["login" => $login], "users");
  163.         if($user_db == null){
  164.             $this->db->insert("users", ["login" => $login"company_guid" => $CompanysList[0]["GUID"]]);
  165.         }else{
  166.             if($user_db["company_guid"] != null && $user_db["company_guid"] != ""){
  167.                 $this->session->set("CompanyGUID"$user_db["company_guid"]);
  168.                 foreach ($CompanysList as $value){
  169.                     if($value["GUID"] == $user_db["company_guid"]){
  170.                         $this->session->set("CompanyDescription"$value["Description"]);
  171.                     }
  172.                 }
  173.             }
  174.         }
  175.         $page_number $user_db["main_page"] ?? 0;
  176.         $this->session->set("user_main_page"$page_number);
  177.         $page_name $this->getUserMainPage($page_number);
  178.         $date = new \DateTime();
  179.         $date->modify('-1 month');
  180.         $DateBegin $date->format('Y-m-d');
  181.         $date = new \DateTime();
  182.         $DateEnd $date->format('Y-m-d');
  183.         $delivery $this->getCustomerAttributes($Token$CustomerGUID);
  184.         if(isset($delivery["return"]["DeliveryLimit"])){
  185.             $this->session->set("DeliveryLimit"$delivery["return"]["DeliveryLimit"]);
  186.             //$this->session->set("DeliveryLimit", ["FreeDeliveryMin" => "500", "DeliveryPrice" => "500"]);
  187.         }else{
  188.             $this->session->set("DeliveryLimit", ["FreeDeliveryMin" => "0""DeliveryPrice" => "0"]);
  189.         }
  190.         $response $this->getAccountingInformation($Token$CustomerGUID$CompanysList[0]["GUID"], $DateBegin$DateEnd);
  191.         $this->session->set("SumDebit"0);
  192.         if(isset($response["return"]["AccountingInformation"]["AccountingInformationCompanys"])){
  193.             if(isset($response["return"]["AccountingInformation"]["AccountingInformationCompanys"]["DebtAtTheEnd"])){
  194.                 $account = [$response["return"]["AccountingInformation"]["AccountingInformationCompanys"]];
  195.             }else{
  196.                 $account $response["return"]["AccountingInformation"]["AccountingInformationCompanys"];
  197.             }
  198.             foreach ($account as $acc){
  199.                 if($acc["СompanyGUID"] == $CompanysList[0]["GUID"]){
  200.                     $this->session->set("SumDebit"$acc["DebtAtTheEnd"]);
  201.                 }
  202.             }
  203.         }
  204. //        return new Response($twig->render('flex/index.html', $this->twig_values->getTwigTemplate($request) +
  205. //            ["page_name" => $page_name]
  206. //        ));
  207.         $account_info $this->getLoginProperties($Token);
  208.         $LoginProperties $account_info["return"]["LoginProperties"] ?? false;
  209.         $this->session->set("LoginProperties"$LoginProperties);
  210.         if($ChangePasswordAtFirstLogon){
  211.             $response = new Response($twig->render('flex/change_pass_first.html'$this->twig_values->getTwigTemplate($request) +
  212.                 ["page_name" => $page_name"password" => $password"Reg" => ["status" => "true""reg" => ""]]
  213.             ));
  214.             if($remember == "on"){
  215.                 $response->headers->setCookie(Cookie::create('login'$login));
  216.                 $response->headers->setCookie(Cookie::create('password'$password));
  217.             }
  218.             return $response;
  219.         }else{
  220.             $response $this->redirect("/".$page_name301);
  221.             if($remember == "on"){
  222.                 $response->headers->setCookie(Cookie::create('login'$login));
  223.                 $response->headers->setCookie(Cookie::create('password'$password));
  224.             }
  225.             return $response;
  226.         }
  227.         return new Response($twig->render('flex/'.$page_name.'.html',
  228.             $this->twig_values->getTwigTemplate($request)
  229.         ));
  230.     }
  231.     /**
  232.      * @Route("/auth_demo", name="demo")
  233.      */
  234.     function auth_demo(Request $requestEnvironment $twig){
  235.         $login Constants::DEMO_LOGIN;
  236.         $password Constants::DEMO_PASSWORD;
  237.         $response $this->authentication($login$password"""");
  238.         if($this->getError($response)) {
  239.             return new Response($twig->render('flex/login.html',
  240.                 $this->twig_values->getTwigTemplate($request),
  241.             ));
  242.         }
  243.         if(!isset($response["return"]["Token"]) || !isset($response["return"]["CustomerGuid"]))
  244.         {
  245.             return new Response($twig->render('flex/login.html',
  246.                 $this->twig_values->getTwigTemplate($request),
  247.             ));
  248.         }
  249.         $Token $response["return"]["Token"];
  250.         $CustomerGUID $response["return"]["CustomerGuid"];
  251.         $ChangePasswordAtFirstLogon $response["return"]["ChangePasswordAtFirstLogon"];
  252.         $AccessLevel "demo";
  253.         $this->session->set("AccessLevel"$AccessLevel);
  254.         $bonus_list $this->getBonusList($Token$CustomerGUID);
  255.         if(isset($bonus_list["return"]["Companys"])){
  256.             if(isset($bonus_list["return"]["Companys"]["GUID"])){
  257.                 $temp_bonus_list[0] = $bonus_list["return"]["Companys"];
  258.                 $bonus_list $temp_bonus_list;
  259.             }else{
  260.                 $bonus_list $bonus_list["return"]["Companys"];
  261.             }
  262.         }else{
  263.             $bonus_list = [];
  264.         }
  265.         $this->session->set("bonus_list"$bonus_list);
  266.         $contact_info $this->getContactInfo($Token$CustomerGUID);
  267.         $persons = [];
  268.         $address = [];
  269.         if(isset($contact_info["return"]["ContactInfo"]["Person"])){
  270.             if(isset($contact_info["return"]["ContactInfo"]["Person"]["GUID"])){
  271.                 $temp_contact_info[0] = $contact_info["return"]["ContactInfo"]["Person"];
  272.                 $persons $temp_contact_info;
  273.             }else{
  274.                 $persons $contact_info["return"]["ContactInfo"]["Person"];
  275.             }
  276.         }else{
  277.             $persons = [];
  278.         }
  279.         if(isset($contact_info["return"]["ContactInfo"]["Address"])){
  280.             if(isset($contact_info["return"]["ContactInfo"]["Address"]["GUID"])){
  281.                 $temp_contact_info[0] = $contact_info["return"]["ContactInfo"]["Address"];
  282.                 $address $temp_contact_info;
  283.             }else{
  284.                 $address $contact_info["return"]["ContactInfo"]["Address"];
  285.             }
  286.         }else{
  287.             $address = [];
  288.         }
  289.         $contacts["Person"] = $persons;
  290.         $contacts["Address"] = $address;
  291.         $this->session->set("contact_info"$contacts);
  292.         $get_manager = [];
  293.         $get_manager[0] = [];
  294.         $get_manager[0]["Photo"] = "/img/boss.png";
  295.         $get_manager[0]["FIO"] = "demo";
  296.         $get_manager[0]["Phone"] = "demo";
  297.         $get_manager[0]["Mail"] = "demo";
  298.         $get_manager[0]["ChatID"] = "demo";
  299.         $this->session->set("manager_info"$get_manager);
  300.         $this->session->set("Token"$Token);
  301.         $this->session->set("Login"$login);
  302.         $this->session->set("CustomerGUID"$CustomerGUID);
  303.         $response $this->getCompanysList($Token$CustomerGUID);
  304.         if($this->getError($response)) {
  305.             return new Response($twig->render('flex/login.html',
  306.                 $this->twig_values->getTwigTemplate($request),
  307.             ));
  308.         }
  309.         $CompanysList $response["return"]["Companys"];
  310.         if(isset($CompanysList["GUID"])){
  311.             $arr[0]= $CompanysList;
  312.             $CompanysList $arr;
  313.         }
  314.         $this->session->set("CompanyGUID"$CompanysList[0]["GUID"]);
  315.         $this->session->set("CompanyDescription"$CompanysList[0]["Description"]);
  316.         $this->session->set("CompanysList"$CompanysList);
  317.         $this->getCustomerMessage();
  318.         $user_db $this->db->getOneWhereArr(["login" => $login], "users");
  319.         if($user_db == null){
  320.             $this->db->insert("users", ["login" => $login]);
  321.         }
  322.         $page_number $user_db["main_page"] ?? 0;
  323.         $this->session->set("user_main_page"$page_number);
  324.         $page_name $this->getUserMainPage($page_number);
  325.         $date = new \DateTime();
  326.         $date->modify('-1 month');
  327.         $DateBegin $date->format('Y-m-d');
  328.         $date = new \DateTime();
  329.         $DateEnd $date->format('Y-m-d');
  330.         //$response = $this->getCustomerAttributes($Token, $CustomerGUID);
  331.         $response $this->getAccountingInformation($Token$CustomerGUID$CompanysList[0]["GUID"], $DateBegin$DateEnd);
  332.         $this->session->set("SumDebit"0);
  333.         if(isset($response["return"]["AccountingInformation"]["AccountingInformationCompanys"])){
  334.             if(isset($response["return"]["AccountingInformation"]["AccountingInformationCompanys"]["DebtAtTheEnd"])){
  335.                 $account = [$response["return"]["AccountingInformation"]["AccountingInformationCompanys"]];
  336.             }else{
  337.                 $account $response["return"]["AccountingInformation"]["AccountingInformationCompanys"];
  338.             }
  339.             foreach ($account as $acc){
  340.                 if($acc["СompanyGUID"] == $CompanysList[0]["GUID"]){
  341.                     $this->session->set("SumDebit"$acc["DebtAtTheEnd"]);
  342.                 }
  343.             }
  344.         }
  345. //        return new Response($twig->render('flex/index.html', $this->twig_values->getTwigTemplate($request) +
  346. //            ["page_name" => $page_name]
  347. //        ));
  348.         $account_info $this->getLoginProperties($Token);
  349.         $LoginProperties $account_info["return"]["LoginProperties"] ?? false;
  350.         $this->session->set("LoginProperties"$LoginProperties);
  351.         if($ChangePasswordAtFirstLogon){
  352.             return new Response($twig->render('flex/change_pass_first.html'$this->twig_values->getTwigTemplate($request) +
  353.                 ["page_name" => $page_name"password" => $password"Reg" => ["status" => "true""reg" => ""]]
  354.             ));
  355.         }else{
  356.             return $this->redirect("/".$page_name301);
  357.         }
  358.         return new Response($twig->render('flex/'.$page_name.'.html',
  359.             $this->twig_values->getTwigTemplate($request)
  360.         ));
  361.     }
  362.     function getUserMainPage($page_number 0){
  363.         $page_name "";
  364.         switch ($page_number){
  365.             case 0:
  366.                 $page_name "";
  367.                 break;
  368.             case 1:
  369.                 $page_name "catalog";
  370.                 break;
  371.             case 2:
  372.                 $page_name "news";
  373.                 break;
  374.             default:
  375.                 break;
  376.         }
  377.         return $page_name;
  378.     }
  379.     /**
  380.      * @Route("/soap")
  381.      */
  382.     function getRequest(Request $requestEnvironment $twig){
  383.         $method $request->request->get('method');
  384.         switch ($method){
  385.             case "getItemList":
  386.                 $CompanyGUID $this->session->get("CompanyGUID");
  387.                 $Token $this->session->get('Token');
  388.                 $CustomerGUID $this->session->get("CustomerGUID");
  389.                 $OnlyAvailable $request->request->get("OnlyAvailable") ?? 0;
  390.                 $GroupGUID $request->request->get('GUID') ?? "";
  391.                 $this->session->set("search_guid"$GroupGUID);
  392.                 $this->session->set("Checked"$request->request->get("Checked"));
  393.                 $Property $request->request->get('Property') ?? "";
  394.                 $search_select $request->request->get('search_select') ?? "Description";
  395.                 $click $request->request->get('click') ?? "group";
  396.                 $search_item_guid $request->request->get('search_item_guid') ?? "";
  397.                 $last_page $request->request->get('last_page') ?? 1;
  398.                 if($last_page 1){
  399.                     $last_page 1;
  400.                 }
  401.                 $VendorGUID $request->request->get('VendorGUID') ?? "";
  402.                 $VendorGUIDList "";
  403.                 $Code "";
  404.                 $Description $request->request->get('Description') ?? "";
  405.                 $Description trim($Description);
  406.                 if($Description == "" && $VendorGUID == ""){
  407.                     $click "group";
  408.                 }
  409.                 $PartNumber "";
  410.                 $NumberOfItems $request->request->get('NumberOfItems') ?? 20;
  411.                 if($NumberOfItems == ""){
  412.                     $NumberOfItems 20;
  413.                 }
  414.                 $Offset = ($last_page 1) * $NumberOfItems;
  415.                 $price_range $request->request->get('price_range') ?? "500 ₽ - 1500 ₽";
  416.                 $price_range str_replace(" """$price_range);
  417.                 $price_range str_replace("₽"""$price_range);
  418.                 $price_range explode("-"$price_range);
  419.                 if($click == "search"){
  420.                     $price_range[0] = 0;
  421.                     $price_range[1] = 1000000000;
  422.                     //$price_range = [];
  423.                 }
  424.                 $Sorting $request->request->get('Sorting') ?? "ASC_Description";
  425.                 $sort_arr explode("_"$Sorting);
  426.                 $sort_method $sort_arr[0];
  427.                 $sort_field $sort_arr[1];
  428.                 $FoundProdsCount 0;
  429.                 //$vendor_list = [];
  430.                 $elastic = new ElasticController();
  431.                 if($GroupGUID != ""){
  432.                     $group_guids $elastic->get_doc("group_tree"$GroupGUID);
  433.                     if(isset($group_guids["_source"]["GUID"])){
  434.                         $group_guids $group_guids["_source"]["GUID"];
  435.                     }else{
  436.                         $group_guids $GroupGUID;
  437.                     }
  438.                 }else{
  439.                     $group_guids $GroupGUID;
  440.                 }
  441. //                if($sort_field == "Description"){
  442. //                    $sort_field = "Description.key_word";
  443. //                }
  444.                 if ($search_select != "All" && $Description != ""){
  445.                     $sort_field $search_select;
  446.                 }
  447.                 $sort = [$sort_field => $sort_method];
  448.                 if($click == "search"){
  449.                     $sort = [];
  450.                 }
  451. //                $Property = [];
  452. //                $Property["GUIDS"] = ["57f85d51-c875-11eb-8156-001b21bc2180"];
  453.                 $query = [];
  454.                 $query["bool"] = [];
  455.                 if($click == "search"){
  456.                     $query["bool"]["minimum_should_match"] = 1;
  457.                 }
  458.                 $query["bool"]["must"] = [];
  459.                 $query["bool"]["filter"] = [];
  460.                 $query["bool"]["should"] = [];
  461.                 if($group_guids != ""){
  462.                     //$query["bool"]["must"][0] = ["terms" => ["GUIDGroup" => $group_guids]];
  463.                     array_push($query["bool"]["must"], ["terms" => ["GUIDGroup" => $group_guids]]);
  464.                 }
  465.                 if($VendorGUID != ""){
  466.                     array_push($query["bool"]["must"], ["term" => ["VendorGUID" => $VendorGUID]]);
  467.                 }
  468.                 if($search_item_guid != ""){
  469.                     array_push($query["bool"]["must"], ["term" => ["GUID" => $search_item_guid]]);
  470.                 }
  471.                 if($Description != ""){
  472.                     //$query["bool"]["must"][1] = ["term" => [$search_select => $Description]];
  473.                     if($search_select != "All"){
  474.                         array_push($query["bool"]["must"], ["term" => [$search_select => $Description]]);
  475.                     }else{
  476. //                        array_push($query["bool"]["must"], ["term" => ["Description" => $Description,
  477. //                            "Code" => $Description, "PartNumber" => $Description]]);
  478. //                        array_push($query["bool"]["must"], ["multi_match" => ["query" => $Description,
  479. //                            "fields" => ["Description", "Code", "PartNumber"]]]);
  480.                         array_push($query["bool"]["should"], ["term" => ["Description2" => $Description]]);
  481.                         array_push($query["bool"]["should"], ["term" => ["Code" => $Description]]);
  482.                         array_push($query["bool"]["should"], ["term" => ["PartNumber" => $Description]]);
  483.                     }
  484.                 }
  485.                 if($OnlyAvailable 0){
  486.                     $query["bool"]["must_not"] = ["term" => ["Available" => 0]];
  487.                 }
  488. //                if($Description != ""){
  489. //                    $query = [
  490. //                        "bool" => [
  491. //                            "must" => [
  492. //                                [
  493. //                                    "terms" => [
  494. //                                        "GUIDGroup" => $group_guids
  495. //                                    ],
  496. //                                ],
  497. //                                [
  498. //                                    "range" => [
  499. //                                        "Price" => [
  500. //                                            "gte" => floatval($price_range[0]),
  501. //                                            "lte" => floatval($price_range[1])
  502. //                                        ]
  503. //                                    ]
  504. //                                ]
  505. //
  506. //                            ],
  507. //                        ],
  508. //                    ];
  509. //                }else{
  510. //                    $query = [
  511. //                        "bool" => [
  512. //                            "must" => [
  513. //                                [
  514. //                                    "terms" => [
  515. //                                        "GUIDGroup" => $group_guids
  516. //                                    ],
  517. //                                ],
  518. //                                [
  519. //                                    "range" => [
  520. //                                        "Price" => [
  521. //                                            "gte" => floatval($price_range[0]),
  522. //                                            "lte" => floatval($price_range[1])
  523. //                                        ]
  524. //                                    ]
  525. //                                ]
  526. //
  527. //                            ],
  528. //                        ],
  529. //                    ];
  530. //                }
  531.                 if($Property != ""){
  532.                     $query = [
  533.                         "nested" => [
  534.                             "path" => "Property",
  535.                             "query" => [
  536.                                 "bool" => [
  537.                                     "must" => [
  538.                                         "terms" => [
  539.                                             "Property.SpecificationGUID" => $Property,
  540.                                         ],
  541.                                     ],
  542.                                 ],
  543.                             ],
  544.                         ],
  545.                     ];
  546.                 }
  547. //                $query["nested"]["query"]["bool"]["must"][3] = ["term" => ["Property.SpecificationGUID" => "57f85d51-c875-11eb-8156-001b21bc2180"]];
  548. //                if($click !== "group" && $click == "All" && $Description !== ""){
  549. //                    $elastic_result = $elastic->search_doc_query_string("item_tree", "*".$Description."*",
  550. //                        "Description2", 0, $NumberOfItems);
  551. //                    dump($elastic_result);
  552. //                }else{
  553. //                    $elastic_result = $elastic->search_doc_custom("item_tree", $query, $sort, $Offset, $NumberOfItems);
  554. //                    dump($elastic_result);
  555. //                }
  556.             if($search_select == "All"){
  557.                 $fields = ["Description2""Code""PartNumber"];
  558.             }else{
  559.                 if($search_select == "Description"){
  560.                     $fields = [$search_select."2"];
  561.                 }else{
  562.                     $fields = [$search_select];
  563.                 }
  564.             }
  565.             if($Description == ""){
  566. //                $elastic_result = $elastic->search_doc_query_string("item_tree", addslashes("*".$Description."*"),
  567. //                    $search_select, $Offset, $NumberOfItems, $sort);
  568.                 $aggs $elastic->search_doc_custom("item_tree"$query$sort$Offset,
  569.                     $NumberOfItems);
  570.                 if(isset($aggs["aggregations"]["max_price"]["value"]) &&
  571.                     $aggs["aggregations"]["max_price"]["value"] != null){
  572.                     $max_price intval($aggs["aggregations"]["max_price"]["value"]) + 1;
  573.                 }else{
  574.                     $max_price 25000;
  575.                 }
  576.                 array_push($query["bool"]["must"], ["range" => ["Price" => [
  577.                     "gte" => floatval($price_range[0]),
  578.                     "lte" => floatval($price_range[1])
  579.                 ]]]);
  580.                 $elastic_result $elastic->search_doc_custom("item_tree"$query$sort$Offset,
  581.                     $NumberOfItems);
  582.             }else{
  583.                 $aggs $elastic->search_doc_query_string_free("item_tree"$group_guids$fields,
  584.                     $Description, [], $VendorGUID$sort$Offset$NumberOfItems$OnlyAvailable);
  585.                 if(isset($aggs["aggregations"]["max_price"]["value"]) &&
  586.                     $aggs["aggregations"]["max_price"]["value"] != null){
  587.                     $max_price ceil($aggs["aggregations"]["max_price"]["value"]) + 1;
  588.                 }else{
  589.                     $max_price 25000;
  590.                 }
  591.                 $elastic_result $elastic->search_doc_query_string_free("item_tree"$group_guids$fields,
  592.                     $Description$price_range$VendorGUID$sort$Offset$NumberOfItems$OnlyAvailable);
  593.                 //$elastic_result = $elastic->search_doc_custom("item_tree", $query, $sort, $Offset, $NumberOfItems);
  594.             }
  595.                 //Поиск
  596. //                if($Description == ""){
  597. //                    $group_guids = $elastic->get_doc("group_tree", $GroupGUID);
  598. //                    if(isset($group_guids["_source"]["GUID"])){
  599. //                        //$vendor_list = $group_guids["_source"]["Vendors"];
  600. //                        $group_guids = $group_guids["_source"]["GUID"];
  601. //                        $elastic_result = $elastic->search_doc_terms("item_tree", $group_guids, "GUIDGroup", $Offset, $NumberOfItems);
  602. //                    }else{
  603. //                        $elastic_result = $elastic->search_doc_term("item_tree", $GroupGUID, "GUIDGroup", $Offset, $NumberOfItems);
  604. //                    }
  605. //                }else{
  606. //                    $elastic_result = $elastic->search_doc_query_string("item_tree", "*".$Description."*", "Description", $Offset, $NumberOfItems);
  607. //                }
  608.                 $total_count $elastic_result["hits"]["total"]["value"] ?? 0;
  609.                 if($total_count 0){
  610.                     $temp_items array_column($elastic_result["hits"]["hits"], "_source");
  611.                     $ItemGuidList array_column($temp_items"GUID");
  612.                     $Items_source array_column($temp_items"AdditionalItemGUID""GUID");
  613.                     $ItemImagesList array_column($temp_items"Images""GUID");
  614.                     $ItemList $this->getItems($Token$CompanyGUID$CustomerGUID$ItemGuidList);
  615.                     //$this->getError($ItemList);
  616.                     if(isset($ItemList["return"]["Items"]))
  617.                     {
  618.                         if(isset($ItemList["return"]["Items"]["GUID"]))
  619.                         {
  620.                             $ItemList["return"]["Items"] = [$ItemList["return"]["Items"]];
  621.                         }
  622.                         $ItemList $ItemList["return"]["Items"];
  623.                         $ItemList array_column($ItemListnull"GUID");
  624.                         //Сортировка
  625.                         foreach ($ItemGuidList as $k=>$v) {
  626.                             if(!isset($ItemList[$v])){
  627.                                 continue;
  628.                             }
  629.                             $ItemGuidList[$k] = $ItemList[$v];
  630.                             $ItemGuidList[$k]["Images"] = [];
  631.                             if(isset($ItemImagesList[$v])){
  632.                                 $ItemGuidList[$k]["Images"] = $ItemImagesList[$v];
  633.                             }
  634.                             $ItemGuidList[$k]["AdditionalItemGUID"] = [];
  635.                             $ItemGuidList[$k]["AdditionalItems"] = [];
  636.                             if(isset($Items_source[$v]) && $Items_source[$v] != []){
  637.                                 $ItemGuidList[$k]["AdditionalItemGUID"] = $Items_source[$v];
  638.                                 $elastic_ad_item $this->getItems($Token,
  639.                                     $CompanyGUID$CustomerGUID$ItemGuidList[$k]["AdditionalItemGUID"]);
  640.                                 if(isset($elastic_ad_item["return"]["Items"])) {
  641.                                     if(isset($elastic_ad_item["return"]["Items"]["GUID"])){
  642.                                         $elastic_ad_item = [$elastic_ad_item["return"]["Items"]];
  643.                                     }else{
  644.                                         $elastic_ad_item $elastic_ad_item["return"]["Items"];
  645.                                     }
  646.                                     $elastic_ad_item[1] = $elastic_ad_item[0];
  647.                                     $elastic_ad_item[2] = $elastic_ad_item[0];
  648.                                 }else{
  649.                                     $elastic_ad_item = [];
  650.                                 }
  651.                                 $ItemGuidList[$k]["AdditionalItems"] = $elastic_ad_item;
  652. //                                foreach ($Items_source[$v] as $ad_item){
  653. //                                    dump($ad_item);
  654. //                                    $elastic_ad_item = $elastic->get_doc("item_tree", $ad_item);
  655. //                                    dump($elastic_ad_item);
  656. //                                    if(isset($elastic_ad_item["_source"])){
  657. //                                        $ItemGuidList[$k]["AdditionalItems"][$ad_item] = $elastic_ad_item["_source"];
  658. //                                    }
  659. //                                }
  660.                             }
  661. //                            if($ItemGuidList[$k]["AdditionalItems"] == []){
  662. //                                $ItemGuidList[$k]["AdditionalItems"] = [$ItemGuidList[$k]];
  663. //                            }
  664.                             $ItemGuidList[$k]["countAdditionalItems"] = count($ItemGuidList[$k]["AdditionalItems"]);
  665.                         }
  666.                         $ItemList $ItemGuidList;
  667.                         $FoundProdsCount $total_count;
  668.                         $pagination["max_item"] = $NumberOfItems;
  669.                         $pagination["last_page"] = $last_page;
  670.                         $pagination["all_page"] = round($FoundProdsCount $pagination["max_item"]) ?? 1;
  671.                         $pagination["arr_page"] = [$pagination["last_page"] - 1$pagination["last_page"], $pagination["all_page"] - 1$pagination["all_page"]];
  672.                         //Разрезать массив
  673.                         //$ItemList = array_slice($ItemList, ($pagination["last_page"] - 1)*$NumberOfItems, $NumberOfItems);
  674.                     }else{
  675.                         return new Response($twig->render('flex/ajax/products_table.html'$this->twig_values->getTwigTemplate($request)+[
  676.                                 "error" => $this->session->get('error'),
  677.                                 "ItemList" => $ItemList,
  678.                                 "CountItemList" => count($ItemList),
  679.                                 "GroupGUID" => $GroupGUID,
  680.                                 "PageTitle" => Constants::SITENAME,
  681.                                 "MaxPrice" => $max_price,
  682.                                 "FoundProdsCount" => $FoundProdsCount,
  683.                                 "Checked" => $request->request->get('Checked'),
  684.                                 "search_item_guid" => $search_item_guid,
  685.                                 "search_vendor_guid" => "",
  686.                                 "search_vendor_name" => "",
  687.                             ]));
  688.                     }
  689.                 }else{
  690.                     $ItemList = [];
  691.                     return new Response($twig->render('flex/ajax/products_table.html'$this->twig_values->getTwigTemplate($request)+[
  692.                             "error" => $this->session->get('error'),
  693.                             "ItemList" => [$ItemList],
  694.                             "CountItemList" => count($ItemList),
  695.                             "GroupGUID" => $GroupGUID,
  696.                             "PageTitle" => Constants::SITENAME,
  697.                             "MaxPrice" => $max_price,
  698.                             "FoundProdsCount" => $FoundProdsCount,
  699.                             "Checked" => $request->request->get('Checked'),
  700.                             "search_item_guid" => $search_item_guid,
  701.                             "search_vendor_guid" => "",
  702.                             "search_vendor_name" => "",
  703.                         ]));
  704.                     $ItemList $this->getItemList($Token$CompanyGUID$CustomerGUID$OnlyAvailable$GroupGUID$VendorGUIDList,
  705.                         $Code$Description$PartNumber$NumberOfItems$Offset$Sorting);
  706.                     $this->getError($ItemList);
  707.                     if(isset($ItemList["return"]["Items"]))
  708.                     {
  709. //                        if(isset($ItemList["return"]["Items"]["GUID"]))
  710. //                        {
  711. //                            $array[0] = $ItemList["return"]["Items"];
  712. //                            $ItemList["return"]["Items"] = $array;
  713. //                        }
  714. //
  715. //                        $ItemList = $ItemList["return"]["Items"];
  716. //                        $FoundProdsCount = count($ItemList) ?? 0;
  717. //
  718. //                        $pagination["max_item"] = $NumberOfItems;
  719. //                        $pagination["last_page"] = $last_page;
  720. //                        $pagination["all_page"] = round($FoundProdsCount / $pagination["max_item"]) ?? 1;
  721. //                        $pagination["arr_page"] = [$pagination["last_page"] - 1, $pagination["last_page"], $pagination["all_page"] - 1, $pagination["all_page"]];
  722. //
  723. //                        //Разрезать массив
  724. //                        $ItemList = array_slice($ItemList, ($pagination["last_page"] - 1)*$NumberOfItems, $NumberOfItems);
  725.                         return new Response($twig->render('flex/ajax/products_table.html'$this->twig_values->getTwigTemplate($request)+[
  726.                                 "error" => $this->session->get('error'),
  727.                                 "ItemList" => $ItemList,
  728.                                 "CountItemList" => count($ItemList),
  729.                                 "GroupGUID" => $GroupGUID,
  730.                                 "PageTitle" => Constants::SITENAME,
  731.                                 "MaxPrice" => $max_price,
  732.                                 "FoundProdsCount" => $FoundProdsCount,
  733.                                 "Checked" => $request->request->get('Checked'),
  734.                                 "search_item_guid" => $search_item_guid,
  735.                                 "search_vendor_guid" => "",
  736.                                 "search_vendor_name" => "",
  737.                             ]));
  738.                     }
  739.                     else
  740.                     {
  741.                         return new Response($twig->render('flex/ajax/products_table.html'$this->twig_values->getTwigTemplate($request)+[
  742.                                 "error" => $this->session->get('error'),
  743.                                 "ItemList" => $ItemList,
  744.                                 "CountItemList" => count($ItemList),
  745.                                 "GroupGUID" => $GroupGUID,
  746.                                 "PageTitle" => Constants::SITENAME,
  747.                                 "MaxPrice" => $max_price,
  748.                                 "FoundProdsCount" => $FoundProdsCount,
  749.                                 "Checked" => $request->request->get('Checked'),
  750.                                 "search_item_guid" => $search_item_guid,
  751.                                 "search_vendor_guid" => "",
  752.                                 "search_vendor_name" => "",
  753.                             ]));
  754.                     }
  755.                 }
  756.                 return new Response($twig->render('flex/ajax/products_table.html'$this->twig_values->getTwigTemplate($request)+[
  757.                     "error" => $this->session->get('error'),
  758.                     "ItemList" => $ItemList,
  759.                     "CountItemList" => count($ItemList),
  760.                     "pagination" => $pagination,
  761.                     "GroupGUID" => $GroupGUID,
  762.                     "MaxPrice" => $max_price,
  763.                     "PageTitle" => Constants::SITENAME,
  764.                     "FoundProdsCount" => $FoundProdsCount,
  765.                         "Checked" => $request->request->get('Checked'),
  766.                         "search_item_guid" => $search_item_guid,
  767.                         "search_vendor_guid" => "",
  768.                         "search_vendor_name" => "",
  769.                 ]));
  770.                 break;
  771.             default:
  772.                 if ($request->isXMLHttpRequest()) {
  773.                     $parametersAsArray = [];
  774.                     if ($content $request->getContent()) {
  775.                         $parametersAsArray json_decode($contenttrue);
  776.                     }
  777.                 }
  778.                 return new Response($request->getContent());
  779.         }
  780.     }
  781.     /**
  782.      * @Route ("/get_manager", name="get_manager")
  783.      */
  784.     function get_manager(Environment $twigRequest $request){
  785.         $AccessLevel $this->session->get("AccessLevel");
  786.         if($AccessLevel === "demo"){
  787.             $this->respond["status"] = "false";
  788.             $this->respond["error"] = "У демо-доступа ограничены права";
  789.             return new Response($twig->render('flex/respond.html', ["Respond" => $this->getRespond()]));
  790.         }
  791.         $Token $this->session->get('Token');
  792.         $CustomerGUID $this->session->get("CustomerGUID");
  793.         $result $this->getManager($Token$CustomerGUID);
  794.         $this->respond["status"] = "true";
  795.         $this->respond["result"] = $result;
  796.         return new Response($twig->render('flex/respond.html', ["Respond" => $this->getRespond()]));
  797.     }
  798.     /**
  799.      * @Route ("/get_deadline", name="get_deadline")
  800.      */
  801.     function get_deadline(Environment $twigRequest $request){
  802.         $Token $this->session->get('Token');
  803.         $CustomerGUID $this->session->get("CustomerGUID");
  804.         $dead_pop $this->session->get("dead_pop") ?? "false";
  805.         $this->respond["dead_pop"] = "false";
  806.         $result $this->getApprovingDeadLine($Token$CustomerGUID);
  807.         if(isset($result["return"]["DeadLineTS"])){
  808.             $this->respond["status"] = "true";
  809.             $date_end = new \DateTime();
  810.             $date_end->setTimestamp($result["return"]["DeadLineTS"]);
  811.             $date1 date_create($date_end->format("Y-m-d H:i:s"));
  812.             $date_now = new \DateTime();
  813.             $date2 date_create($date_now->format("Y-m-d H:i:s"));
  814.             
  815.             if($date2<$date1) {
  816.                 $diff date_diff($date1,$date2);
  817.                 $this->respond["result"] = ["day" => $diff->d"hour" => $diff->h"minutes" => $diff->i];
  818.                 if($this->respond["result"]["day"] == "0" && $this->respond["result"]["hour"] == "0" && $this->respond["result"]["minutes"] <= "30"){
  819.                     if($dead_pop == "false"){
  820.                         $this->session->set("dead_pop""true");
  821.                         $this->respond["dead_pop"] = "true";
  822.                     }else{
  823.                         $this->respond["dead_pop"] = "false";
  824.                     }
  825.                 }else{
  826.                     $this->respond["dead_pop"] = "false";
  827.                 }
  828.             }else{
  829.                  $this->respond["result"] = [ "finished" => "true" ];
  830.             }
  831.         }else{
  832.             $this->respond["status"] = "false";
  833.             $this->respond["result"] = ["day" => "0""hour" => "0""minutes" => "00"];
  834.         }
  835. //        $this->respond["result"]["day"] = "0";
  836. //        $this->respond["result"]["hour"] = "0";
  837. //        $this->respond["result"]["minutes"] = "29";
  838.         return new Response($twig->render('flex/respond.html', ["Respond" => $this->getRespond()]));
  839.     }
  840.     /**
  841.      * @Route ("/get_delivery_dates", name="get_delivery_dates")
  842.      */
  843.     function get_delivery_dates(Environment $twigRequest $request){
  844.         $Token $this->session->get('Token');
  845.         $ShippingAddress $request->request->get("ShippingAddress") ?? ["GUID" => """Address" => ""];
  846.         $result $this->getDeliveryDates($Token$ShippingAddress);
  847.         if(isset($result['return']["Error"]['ErrorCode']) && $result['return']["Error"]['ErrorCode'] != 0) {
  848.             $this->respond["status"] = "false";
  849.         } else {
  850.             if(isset($result['return']['DeliveryDates']['Lines'])){
  851.                 if(isset($result['return']['DeliveryDates']['Lines']['Data'])){
  852.                     $result['return']['DeliveryDates']['Lines'] = [$result['return']['DeliveryDates']['Lines']];
  853.                 }
  854.                 $this->respond['Lines'] = $result['return']['DeliveryDates']['Lines'];
  855.                 $this->respond["status"] = "true";
  856.             }else{
  857.                 $this->respond["status"] = "false";
  858.             }
  859.         }
  860.         return new Response($twig->render('flex/ajax/delivery_date.html',
  861.             $this->twig_values->getTwigTemplate($request) + ["Dates" => $this->respond]));
  862. //        return new Response($twig->render('flex/respond.html', ["Respond" => $this->getRespond()]));
  863.     }
  864.     function getBonusList($Token$CustomerGUID){
  865.         try{
  866.             $name "GetBonusList";
  867.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  868.             $response $this->soapCall($name$params);
  869.             $response $this->objectToArray($response);
  870.             return $response;
  871.         }catch (\Exception $e){
  872.             dump($e);
  873.         }
  874.     }
  875.     function getDeliveryDates($Token$ShippingAddress){
  876.         try{
  877.             $name "GetDeliveryDates";
  878.             $params = ["Token" => $Token"ShippingAdress" => $ShippingAddress];
  879.             $response $this->soapCall($name$params);
  880.             $response $this->objectToArray($response);
  881.             return $response;
  882.         }catch (\Exception $e){
  883.             dump($e);
  884.         }
  885.     }
  886.     function updateOrder($Token$Order$CompanyGUID$CustomerGUID)
  887.     {
  888.         try{
  889.             $name "UpdateOrder";
  890.             $params = ["Token" => $Token"Order" => $Order"CustomerGUID" => $CustomerGUID"CompanyGUID" => $CompanyGUID];
  891. //            var_dump($params);
  892. //            dump($params);
  893.         $response $this->soapCall($name$params);
  894.             //var_dump($response);
  895.         $response $this->objectToArray($response);
  896.             return $response;
  897.         }catch (\Exception $e){
  898.             dump($e);
  899.         }
  900.     }
  901.     function getOrder($Token$GUID)
  902.     {
  903.         try{
  904.             $name "GetOrder";
  905.             $params = ["Token" => $Token"OrderGUID" => $GUID];
  906. //        var_dump($params);
  907.         $response $this->soapCall($name$params);
  908.             
  909. //        var_dump($response);
  910.         
  911.         $response $this->objectToArray($response);
  912.             return $response;
  913.         }catch (\Exception $e){
  914.             dump($e);
  915.         }
  916.     }
  917.     function getWishList($Token$CustomerGUID$GUID)
  918.     {
  919.         try{
  920.             $name "GetWishList";
  921.             $params = ["Token" => $Token"WishListGUID" => $GUID"CustomerGUID" => $CustomerGUID];
  922.             $response $this->soapCall($name$params);
  923.             $response $this->objectToArray($response);
  924.             return $response;
  925.         }catch (\Exception $e){
  926.             dump($e);
  927.         }
  928.     }
  929.     function updateWishList($Token$CustomerGUID$CompanyGUID$WishList$GUID "")
  930.     {
  931.         try{
  932.             $name "UpdateWishList";
  933.             $params = ["Token" => $Token"WishList" => $WishList"CustomerGUID" => $CustomerGUID,
  934.                 "CompanyGUID" => $CompanyGUID"GUID" => $GUID];
  935.             $response $this->soapCall($name$params);
  936.             $response $this->objectToArray($response);
  937.             return $response;
  938.         }catch (\Exception $e){
  939.             dump($e);
  940.         }
  941.     }
  942.     function getItemList($Token$CompanyGUID$CustomerGUID$OnlyAvailable$GroupGUID$VendorGUIDList$Code,
  943.                          $Description$PartNumber$NumberOfItems$Offset$Sorting)
  944.     {
  945.         try{
  946.             $name "GetItemListVersion2";
  947.             $params = ["Token" => $Token"СompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  948.                 "OnlyAvailable" => $OnlyAvailable"GroupGUID" => $GroupGUID"VendorGUIDList" => $VendorGUIDList,
  949.                 "Code" => $Code"Description" => $Description"PartNumber" => $PartNumber,
  950.                 "NumberOfItems" => $NumberOfItems"Offset" => $Offset"Sorting" => $Sorting];
  951.             $response $this->soapCall($name$params);
  952.             $response $this->objectToArray($response);
  953.             return $response;
  954.         }catch (\Exception $e){
  955.             dump($e);
  956.         }
  957.     }
  958.     function getItem($Token$CompanyGUID$CustomerGUID$ItemGUID)
  959.     {
  960.         try{
  961.             $name "GetItem";
  962.             $params = ["Token" => $Token"СompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  963.                "ItemGUID" => $ItemGUID];
  964.             $response $this->soapCall($name$params);
  965.             $response $this->objectToArray($response);
  966.             return $response;
  967.         }catch (\Exception $e){
  968.             dump($e);
  969.         }
  970.     }
  971.     function getItems($Token$CompanyGUID$CustomerGUID$ItemGuidList)
  972.     {
  973.         try{
  974.             $name "GetItems";
  975.             $params = ["Token" => $Token"СompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  976.                 "ItemGuidList" => $ItemGuidList];
  977.             $response $this->soapCall($name$params);
  978.             $response $this->objectToArray($response);
  979.             return $response;
  980.         }catch (\Exception $e){
  981.             dump($e);
  982.         }
  983.     }
  984.     function getBoundedItems($Token$CompanyGUID$CustomerGUID){
  985.         try{
  986.             $name "GetBoundedItems";
  987.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID"CompanyGUID" => $CompanyGUID];
  988.             $response $this->soapCall($name$params);
  989.             $response $this->objectToArray($response);
  990.             return $response;
  991.         }catch (\Exception $e){
  992.             dump($e);
  993.         }
  994.     }
  995.     function getBundles($Token){
  996.         try{
  997.             $name "GetBundles";
  998.             $params = ["Token" => $Token];
  999.             $response $this->soapCall($name$params);
  1000.             $response $this->objectToArray($response);
  1001.             return $response;
  1002.         }catch (\Exception $e){
  1003.             dump($e);
  1004.         }
  1005.     }
  1006.     function getItemsSpecification($Token$ItemGuidList)
  1007.     {
  1008.         try{
  1009.             $name "GetItemsSpecification";
  1010.             $params = ["Token" => $Token"ItemGuidList" => $ItemGuidList];
  1011.             $response $this->soapCall($name$params);
  1012.             $response $this->objectToArray($response);
  1013.             return $response;
  1014.         }catch (\Exception $e){
  1015.             dump($e);
  1016.         }
  1017.     }
  1018.     function getCustomerMessages($Token$CustomerGUID$OnlyNew 0)
  1019.     {
  1020.         try{
  1021.             $name "GetCustomerMessages";
  1022.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID"OnlyNew" => $OnlyNew];
  1023.             $response $this->soapCall($name$params);
  1024.             $response $this->objectToArray($response);
  1025.             return $response;
  1026.         }catch (\Exception $e){
  1027.             dump($e);
  1028.         }
  1029.     }
  1030.     function getSpecificationList($Token)
  1031.     {
  1032.         try{
  1033.             $name "GetSpecificationList";
  1034.             $params = ["Token" => $Token];
  1035.             $response $this->soapCall($name$params);
  1036.             $response $this->objectToArray($response);
  1037.             return $response;
  1038.         }catch (\Exception $e){
  1039.             dump($e);
  1040.         }
  1041.     }
  1042.     function getLoginProperties($Token)
  1043.     {
  1044.         try{
  1045.             $name "GetLoginProperties";
  1046.             $params = ["Token" => $Token];
  1047.             $response $this->soapCall($name$params);
  1048.             $response $this->objectToArray($response);
  1049.             return $response;
  1050.         }catch (\Exception $e){
  1051.             dump($e);
  1052.         }
  1053.     }
  1054.     function setLoginProperties($Token$LoginProperties)
  1055.     {
  1056.         try{
  1057.             $name "SetLoginProperties";
  1058.             $params = ["Token" => $Token"LoginProperties" => $LoginProperties];
  1059.             $response $this->soapCall($name$params);
  1060.             $response $this->objectToArray($response);
  1061.             return $response;
  1062.         }catch (\Exception $e){
  1063.             dump($e);
  1064.         }
  1065.     }
  1066.     function getApprovingDeadLine($Token$CustomerGUID)
  1067.     {
  1068.         try{
  1069.             $name "GetApprovingDeadLine";
  1070.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  1071.             $response $this->soapCall($name$params);
  1072.             $response $this->objectToArray($response);
  1073.             return $response;
  1074.         }catch (\Exception $e){
  1075.             dump($e);
  1076.         }
  1077.     }
  1078.     function resetPassword($Login$Mail)
  1079.     {
  1080.         try{
  1081.             $name "ResetPassword";
  1082.             $params = ["Login" => $Login"Mail" => $Mail];
  1083.             $response $this->soapCall($name$params);
  1084.             $response $this->objectToArray($response);
  1085.             return $response;
  1086.         }catch (\Exception $e){
  1087.             dump($e);
  1088.         }
  1089.     }
  1090.     function getPricesDefinition($Token$CustomerGUID)
  1091.     {
  1092.         try{
  1093.             $name "GetPricesDefinition";
  1094.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  1095.             $response $this->soapCall($name$params);
  1096.             $response $this->objectToArray($response);
  1097.             return $response;
  1098.         }catch (\Exception $e){
  1099.             dump($e);
  1100.         }
  1101.     }
  1102.     function itemsInWarranty($Token$CustomerGUID)
  1103.     {
  1104.         try{
  1105.             $name "ItemsInWarranty";
  1106.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  1107.             $response $this->soapCall($name$params);
  1108.             $response $this->objectToArray($response);
  1109.             return $response;
  1110.         }catch (\Exception $e){
  1111.             dump($e);
  1112.         }
  1113.     }
  1114.     function setContactInfo($Token$ContactPerson)
  1115.     {
  1116.         try{
  1117.             $name "SetContactInfo";
  1118.             $params = ["Token" => $Token"ContactPerson" => $ContactPerson];
  1119.             $response $this->soapCall($name$params);
  1120.             $response $this->objectToArray($response);
  1121.             return $response;
  1122.         }catch (\Exception $e){
  1123.             dump($e);
  1124.         }
  1125.     }
  1126.     function getPicturesList($Token$ItemGUID)
  1127.     {
  1128.         try{
  1129.             $name "GetPicturesList";
  1130.             $params = ["Token" => $Token"ItemGUID" => $ItemGUID];
  1131.             $response $this->soapCall($name$params);
  1132.             //$response = $this->objectToArray($response);
  1133.             return $response;
  1134.         }catch (\Exception $e){
  1135.             dump($e);
  1136.         }
  1137.     }
  1138.     function getOrderList($Token$CustomerGUID$CompanyGUID$FillOrderLines$Mode$DateBegin$DateEnd,
  1139.                           $DeletionMark$OrderStatusForCustomer$ModeForCustomer)
  1140.     {
  1141.         try{
  1142.             $name "GetOrderList";
  1143.             $params = ["Token" => $Token"CompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  1144.                 "Mode" => $Mode"DateBegin" => $DateBegin"DateEnd" => $DateEnd,
  1145.                 "FillOrderLines" => $FillOrderLines"DeletionMark" => $DeletionMark,
  1146.                 "OrderStatusForCustomer" => intval($OrderStatusForCustomer), "ModeForCustomer" => intval($ModeForCustomer)];
  1147. //        var_dump($params);
  1148. //        die(0);
  1149.             $response $this->soapCall($name$params);
  1150.             $response $this->objectToArray($response);
  1151.             return $response;
  1152.         }catch (\Exception $e){
  1153.             dump($e);
  1154.         }
  1155.     }
  1156.     function getFilteredOrderList($Token$CustomerGUID$CompanyGUID$FillOrderLines$Mode$DateBegin$DateEnd,
  1157.                           $DeletionMark$OrderStatusForCustomer$ModeForCustomer$NumberString$GoodsString)
  1158.     {
  1159.         $order_status = ["1" => "New""2" => "Reserved""3" => "ReservedPartly""4" => "NotAvailable",
  1160.             "5" => "WaitingForShipment""6" => "Shipped""7" => "Canceled""8" => "Confirmed"];
  1161.         $order_status $order_status[$OrderStatusForCustomer] ?? "All";
  1162.         try{
  1163.             $name "GetFilteredOrderList";
  1164.             $params = ["Token" => $Token"CompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  1165.                 "Mode" => $Mode"DateBegin" => $DateBegin"DateEnd" => $DateEnd,
  1166.                 "FillOrderLines" => $FillOrderLines"DeletionMark" => $DeletionMark,
  1167.                 "ModeForCustomer" => intval($ModeForCustomer), "NumberString" => $NumberString,
  1168.                 "GoodsString" => $GoodsString];
  1169.             if($order_status != "All"){
  1170.                 $params["Status"] = $order_status;
  1171.             }else{
  1172.         $params["Status"] = "ALL";
  1173.         }
  1174. //            var_dump($params);
  1175. //            die(0);
  1176.             $response $this->soapCall($name$params);
  1177.         
  1178. //        var_dump($response);
  1179. //        die(0);
  1180.             $response $this->objectToArray($response);
  1181.             return $response;
  1182.         }catch (\Exception $e){
  1183.             dump($e);
  1184.         }
  1185.     }
  1186.     function getAccountingInformation($Token$CustomerGUID$CompanyGUID$DateBegin$DateEnd)
  1187.     {
  1188.         try{
  1189.             $name "GetAccountingInformation";
  1190.             $params = ["Token" => $Token"CompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  1191.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd,];
  1192.             $response $this->soapCall($name$params);
  1193.             $response $this->objectToArray($response);
  1194.             return $response;
  1195.         }catch (\Exception $e){
  1196.             dump($e);
  1197.         }
  1198.     }
  1199.     function getBalance($Token$CustomerGUID$CompanyGUID$DateBegin$DateEnd)
  1200.     {
  1201.         try{
  1202.             $name "GetBalance";
  1203.             $params = ["Token" => $Token"CompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  1204.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd,];
  1205.             $response $this->soapCall($name$params);
  1206.             $response $this->objectToArray($response);
  1207.             return $response;
  1208.         }catch (\Exception $e){
  1209.             dump($e);
  1210.         }
  1211.     }
  1212.     function getShipmentsList($Token$CustomerGUID$CompanyGUID$FillOrderLines$DateBegin$DateEnd,
  1213.                           $DeletionMark)
  1214.     {
  1215.         try{
  1216.             $name "GetShipmentsList";
  1217.             $params = ["Token" => $Token"CompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  1218.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd,
  1219.                 "FillOrderLines" => $FillOrderLines"DeletionMark" => $DeletionMark,];
  1220.             $response $this->soapCall($name$params);
  1221.             $response $this->objectToArray($response);
  1222.             return $response;
  1223.         }catch (\Exception $e){
  1224.             dump($e);
  1225.         }
  1226.     }
  1227.     function getFilteredShipmentsList($Token$CustomerGUID$CompanyGUID$FillOrderLines$DateBegin$DateEnd,
  1228.                               $DeletionMark$NumberString$GoodsString)
  1229.     {
  1230.         try{
  1231.             $name "GetFilteredShipmentsList";
  1232.             $params = ["Token" => $Token"CompanyGUID" => $CompanyGUID"CustomerGUID" => $CustomerGUID,
  1233.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd,
  1234.                 "FillOrderLines" => $FillOrderLines"DeletionMark" => $DeletionMark,
  1235.                 "NumberString" => $NumberString"GoodsString" => $GoodsString];
  1236.             $response $this->soapCall($name$params);
  1237.             $response $this->objectToArray($response);
  1238.             return $response;
  1239.         }catch (\Exception $e){
  1240.             dump($e);
  1241.         }
  1242.     }
  1243.     function getReturnList2($Token$CustomerGUID$DateBegin$DateEnd,
  1244.                               $WithLines 1)
  1245.     {
  1246.         try{
  1247.             $name "GetReturnList2";
  1248.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID,
  1249.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd"WithLines" => $WithLines,];
  1250.             $response $this->soapCall($name$params);
  1251.             $response $this->objectToArray($response);
  1252.             return $response;
  1253.         }catch (\Exception $e){
  1254.             dump($e);
  1255.         }
  1256.     }
  1257.     function getReturnPrintForms($Token$ReturnGUID$FormNumber "")
  1258.     {
  1259.         try{
  1260.             $name "GetReturnPrintForms";
  1261.             $params = ["Token" => $Token"ReturnGUID" => $ReturnGUID,
  1262.                 "FormNumber" => $FormNumber];
  1263.             $response $this->soapCall($name$params);
  1264.             //$response = $this->objectToArray($response);
  1265.             return $response;
  1266.         }catch (\Exception $e){
  1267.             dump($e);
  1268.         }
  1269.     }
  1270.     function getFilteredReturnList2($Token$CustomerGUID$DateBegin$DateEnd$NumberString$GoodsString)
  1271.     {
  1272.         try{
  1273.             $name "GetFilteredReturnList";
  1274.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID,
  1275.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd"WithLines" => 1,
  1276.                 "NumberString" => $NumberString"GoodsString" => $GoodsString];
  1277.             $response $this->soapCall($name$params);
  1278.             $response $this->objectToArray($response);
  1279.             return $response;
  1280.         }catch (\Exception $e){
  1281.             dump($e);
  1282.         }
  1283.     }
  1284.     function getReturn($Token$ReturnGUID)
  1285.     {
  1286.         try{
  1287.             $name "GetReturn";
  1288.             $params = ["Token" => $Token"ReturnGUID" => $ReturnGUID];
  1289.             $response $this->soapCall($name$params);
  1290.             $response $this->objectToArray($response);
  1291.             return $response;
  1292.         }catch (\Exception $e){
  1293.             dump($e);
  1294.         }
  1295.     }
  1296.     function getReturn2($Token$CustomerGUID$ReturnGUID)
  1297.     {
  1298.         try{
  1299.             $name "GetReturn2";
  1300.             $params = ["Token" => $Token"ReturnGUID" => $ReturnGUID"CustomerGUID" => $CustomerGUID];
  1301.             $response $this->soapCall($name$params);
  1302.             $response $this->objectToArray($response);
  1303.             return $response;
  1304.         }catch (\Exception $e){
  1305.             dump($e);
  1306.         }
  1307.     }
  1308.     function updateReturn2($Token$CustomerGUID$Return)
  1309.     {
  1310.         try{
  1311.             $name "UpdateReturn2";
  1312.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID,
  1313.                 "Return" => $Return];
  1314.             $response $this->soapCall($name$params);
  1315.             $response $this->objectToArray($response);
  1316.             return $response;
  1317.         }catch (\Exception $e){
  1318.             dump($e);
  1319.         }
  1320.     }
  1321.     function getItemR2($Token$CustomerGUID$SerialNumber$Code$PartNumber)
  1322.     {
  1323.         try{
  1324.             $name "GetItemR2";
  1325.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID,
  1326.                 'SerialNumber' => $SerialNumber'Code' => $Code'PartNumber' => $PartNumber];
  1327.             $response $this->soapCall($name$params);
  1328.             $response $this->objectToArray($response);
  1329.             return $response;
  1330.         }catch (\Exception $e){
  1331.             dump($e);
  1332.         }
  1333.     }
  1334.     function mergeOrders($Token$OrderGUIDList)
  1335.     {
  1336.         try{
  1337.             $name "MergeOrders";
  1338.             $params = ["Token" => $Token"OrderGUIDList" => $OrderGUIDList];
  1339.             $response $this->soapCall($name$params);
  1340.             $response $this->objectToArray($response);
  1341.             return $response;
  1342.         }catch (\Exception $e){
  1343.             dump($e);
  1344.         }
  1345.     }
  1346.     function getManager($Token$CustomerGUID)
  1347.     {
  1348.         try{
  1349.             $name "GetManager";
  1350.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  1351.             $response $this->soapCall($name$params);
  1352.             $response $this->objectToArray($response);
  1353.             return $response;
  1354.         }catch (\Exception $e){
  1355.             dump($e);
  1356.         }
  1357.     }
  1358.     function getWishLists($Token$CustomerGUID$CompanyGUID$DateBegin$DateEnd$FillLines 1)
  1359.     {
  1360.         try{
  1361.             $name "GetWishLists";
  1362.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID"CompanyGUID" => $CompanyGUID,
  1363.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd"FillLines" => $FillLines];
  1364.             $response $this->soapCall($name$params);
  1365.             $response $this->objectToArray($response);
  1366.             return $response;
  1367.         }catch (\Exception $e){
  1368.             dump($e);
  1369.         }
  1370.     }
  1371.     function getFilteredWishLists($Token$CustomerGUID$CompanyGUID$DateBegin$DateEnd$FillLines,
  1372.                                   $NumberString$GoodsString)
  1373.     {
  1374.         try{
  1375.             $name "GetFilteredWishLists";
  1376.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID"CompanyGUID" => $CompanyGUID,
  1377.                 "DateBegin" => $DateBegin"DateEnd" => $DateEnd"FillLines" => $FillLines,
  1378.                 "NumberString" => $NumberString"GoodsString" => $GoodsString];
  1379.             $response $this->soapCall($name$params);
  1380.             $response $this->objectToArray($response);
  1381.             return $response;
  1382.         }catch (\Exception $e){
  1383.             dump($e);
  1384.         }
  1385.     }
  1386.     function getChatWishList($Token$CustomerGUID$GUID)
  1387.     {
  1388.         try{
  1389.             $name "GetChatWishList";
  1390.             $params = ["Token" => $Token"WishListGUID" => $GUID"CustomerGUID" => $CustomerGUID];
  1391.             $response $this->soapCall($name$params);
  1392.             $response $this->objectToArray($response);
  1393.             return $response;
  1394.         }catch (\Exception $e){
  1395.             dump($e);
  1396.         }
  1397.     }
  1398.     function getChat($Token$CustomerGUID$DocumentGUID$DocumentType "wishlist")
  1399.     {
  1400.         try{
  1401.             $name "GetChat";
  1402.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID,
  1403.                 "DocumentType" => $DocumentType"DocumentGUID" => $DocumentGUID];
  1404.             $response $this->soapCall($name$params);
  1405.             $response $this->objectToArray($response);
  1406.             return $response;
  1407.         }catch (\Exception $e){
  1408.             dump($e);
  1409.         }
  1410.     }
  1411.     function sendChatWishList($Token$CustomerGUID$DocGUID$Answer)
  1412.     {
  1413.         try{
  1414.             $name "SendChatWishList";
  1415.             $params = ["Token" => $Token"Chat" => ["DocGUID" => $DocGUID"Answer" => $Answer],
  1416.                 "CustomerGUID" => $CustomerGUID];
  1417.             $response $this->soapCall($name$params);
  1418.             $response $this->objectToArray($response);
  1419.             return $response;
  1420.         }catch (\Exception $e){
  1421.             dump($e);
  1422.         }
  1423.     }
  1424.     function getOrderPrintForm($Token$OrderGUID$DataFormat "PDF")
  1425.     {
  1426.         try{
  1427.             $name "GetOrderPrintForm";
  1428.             $params = ["Token" => $Token"OrderGUID" => $OrderGUID"DataFormat" => $DataFormat];
  1429.             $response $this->soapCall($name$params);
  1430.             $response $this->objectToArray($response);
  1431.             return $response;
  1432.         }catch (\Exception $e){
  1433.             dump($e);
  1434.         }
  1435.     }
  1436.     function getOrderPrintGoods($Token$OrderGUID$DataFormat "PDF")
  1437.     {
  1438.         try{
  1439.             $name "GetOrderPrintGoods";
  1440.             $params = ["Token" => $Token"OrderGUID" => $OrderGUID"DataFormat" => $DataFormat];
  1441.             $response $this->soapCall($name$params);
  1442.             //$response = $this->objectToArray($response);
  1443.             return $response;
  1444.         }catch (\Exception $e){
  1445.             dump($e);
  1446.         }
  1447.     }
  1448.     function getShipmentPrintForms($Token$ShipmentGUID$DataFormat "PDF"$FormNumber "")
  1449.     {
  1450.         try{
  1451.             $name "GetShipmentPrintForms";
  1452.             $params = ["Token" => $Token"ShipmentGUID" => $ShipmentGUID"FormNumber" => $FormNumber,
  1453.                 "DataFormat" => $DataFormat];
  1454.             $response $this->soapCall($name$params);
  1455.             //$response = $this->objectToArray($response);
  1456.             return $response;
  1457.         }catch (\Exception $e){
  1458.             dump($e);
  1459.         }
  1460.     }
  1461.     function getContactInfo($Token$CustomerGUID){
  1462.         try{
  1463.             $name "GetContactInfo";
  1464.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  1465.             $response $this->soapCall($name$params);
  1466.             $response $this->objectToArray($response);
  1467.             return $response;
  1468.         }catch (\Exception $e){
  1469.             dump($e);
  1470.         }
  1471.     }
  1472.     function getGroupTree($Token)
  1473.     {
  1474.         try{
  1475.             $name "GetGroupTree";
  1476.             $params = ["Token" => $Token];
  1477.             $response $this->soapCall($name$params);
  1478.             $response $this->objectToArray($response);
  1479.             return $response;
  1480.         }catch (\Exception $e){
  1481.             dump($e);
  1482.         }
  1483.     }
  1484.     function getCompanysList($Token$CustomerGUID)
  1485.     {
  1486.         try{
  1487.             $name "GetCompanysList";
  1488.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  1489.             $response $this->soapCall($name$params);
  1490.             $response $this->objectToArray($response);
  1491.             return $response;
  1492.         }catch (\Exception $e){
  1493.             dump($e);
  1494.         }
  1495.     }
  1496.     function selectionGoods($Token$CustomerGUID$CompanyGUID$SearchString)
  1497.     {
  1498.         try{
  1499.             $name "SelectionGoods";
  1500.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID"CompanyGUID" => $CompanyGUID,
  1501.                 "SearchString" => $SearchString];
  1502. //        var_dump($params);
  1503. //        die(0);
  1504.             $response $this->soapCall($name$params);
  1505.             $response $this->objectToArray($response);
  1506.             return $response;
  1507.         }catch (\Exception $e){
  1508.             dump($e);
  1509.         }
  1510.     }
  1511.     function setModeOrder($Token$OrderGUID$Mode)
  1512.     {
  1513.         try{
  1514.             $name "SetModeOrder";
  1515.             $params = ["Token" => $Token"OrderGUID" => $OrderGUID"Mode" => $Mode];
  1516.             $response $this->soapCall($name$params);
  1517.             $response $this->objectToArray($response);
  1518.             return $response;
  1519.         }catch (\Exception $e){
  1520.             dump($e);
  1521.         }
  1522.     }
  1523.     function changePassword($Token$Login$OldPassword$NewPassword)
  1524.     {
  1525.         try{
  1526.             $name "ChangePassword";
  1527.             $params = ["Token" => $Token"Login" => $Login,
  1528.                 "OldPassword" => $OldPassword"NewPassword" => $NewPassword];
  1529.             $response $this->soapCall($name$params);
  1530.             $response $this->objectToArray($response);
  1531.             return $response;
  1532.         }catch (\Exception $e){
  1533.             dump($e);
  1534.         }
  1535.     }
  1536.     function getPasswordSample()
  1537.     {
  1538.         try{
  1539.             $name "GetPasswordSample";
  1540.             $params = [];
  1541.             $response $this->soapCall($name$params);
  1542.             $response $this->objectToArray($response);
  1543.             return $response;
  1544.         }catch (\Exception $e){
  1545.             dump($e);
  1546.         }
  1547.     }
  1548.     function confirmOrder($Token$OrderGUID$Mode$AccessLevel 0)
  1549.     {
  1550.         try{
  1551.             $name "ConfirmOrder";
  1552.         // vassa
  1553.             //$params = ["Token" => $Token, "OrderGUID" => $OrderGUID, "Mode" => $Mode,
  1554.             //    "CustomerGUID" => $AccessLevel];
  1555.             $params = ["Token" => $Token"OrderGUID" => $OrderGUID"Mode" => $Mode,
  1556.                 "AccessLevel" => $AccessLevel];
  1557. //        var_dump($params);
  1558.             $response $this->soapCall($name$params);
  1559.         
  1560. //        var_dump($response);
  1561.             
  1562.         $response $this->objectToArray($response);
  1563.             return $response;
  1564.         }catch (\Exception $e){
  1565.             dump($e);
  1566.         }
  1567.     }
  1568.     function getVendorList($Token)
  1569.     {
  1570.         try{
  1571.             $name "GetVendorList";
  1572.             $params = ["Token" => $Token];
  1573.             $response $this->soapCall($name$params);
  1574.             $response $this->objectToArray($response);
  1575.             return $response;
  1576.         }catch (\Exception $e){
  1577.             dump($e);
  1578.         }
  1579.     }
  1580.     function getCustomerAttributes($Token$CustomerGUID)
  1581.     {
  1582.         try{
  1583.             $name "GetCustomerAttributes";
  1584.             $params = ["Token" => $Token"CustomerGuid" => $CustomerGUID];
  1585.             $response $this->soapCall($name$params);
  1586.             $response $this->objectToArray($response);
  1587.             return $response;
  1588.         }catch (\Exception $e){
  1589.             dump($e);
  1590.         }
  1591.     }
  1592.     function getPrices($Token$CustomerGUID)
  1593.     {
  1594.         try{
  1595.             $name "GetPrices";
  1596.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID];
  1597.             $response $this->soapCall($name$params);
  1598.             //$response = $this->objectToArray($response);
  1599.             //$response["source"] = $params;
  1600.             return $response;
  1601.         }catch (\Exception $e){
  1602.             dump($e);
  1603.         }
  1604.     }
  1605.     function confirmViewingMessage($Token$CustomerGUID$Number)
  1606.     {
  1607.         try{
  1608.             $name "ConfirmViewingMessage";
  1609.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID"Number" => $Number];
  1610.             $response $this->soapCall($name$params);
  1611.             $response $this->objectToArray($response);
  1612.             return $response;
  1613.         }catch (\Exception $e){
  1614.             dump($e);
  1615.         }
  1616.     }
  1617.     function confirmViewingChatMessage($Token$CustomerGUID$DocumentGUID$DocumentType "wishlist"$Number "")
  1618.     {
  1619.         try{
  1620.             $name "ConfirmViewingChatMessage";
  1621.             $params = ["Token" => $Token"CustomerGUID" => $CustomerGUID"DocumentGUID" => $DocumentGUID,
  1622.                 "DocumentType" => $DocumentType"Number" => $Number];
  1623.             $response $this->soapCall($name$params);
  1624.             $response $this->objectToArray($response);
  1625.             return $response;
  1626.         }catch (\Exception $e){
  1627.             dump($e);
  1628.         }
  1629.     }
  1630.     function authentication($login$password$ip$browser_info)
  1631.     {
  1632.         try{
  1633.             $name "Authentication";
  1634.             $params = ["Login" => $login"Password" => $password"IPAddress" => $ip"BrowserInfo" => $browser_info];
  1635.             $response $this->soapCall($name$params);
  1636.             $response $this->objectToArray($response);
  1637.             return $response;
  1638.         }catch (\Exception $e){
  1639.             dump($e);
  1640.         }
  1641.     }
  1642.     function soapCall($name$params)
  1643.     {
  1644.         try
  1645.         {
  1646.             $response $this->client->__soapCall($name, array($params));
  1647.         }
  1648.         catch (\Exception $e)
  1649.         {
  1650.             $response["Error"] = $e->getMessage();
  1651.         }
  1652.         return $response;
  1653.     }
  1654.     function objectToArray($object) {
  1655.         //$arr = json_decode(json_encode($object), true);
  1656.         $json json_encode($object);
  1657.         $arr json_decode($json,true);
  1658.         return $arr;
  1659.     }
  1660.     function getError($response)
  1661.     {
  1662.         if(is_array($response) && isset($response["Error"]))
  1663.         {
  1664.             $this->session->set('error'$response["Error"]);
  1665.             return true;
  1666.         }
  1667. //        if(!is_object($response))
  1668. //        {
  1669. //            return false;
  1670. //        }
  1671.         if(isset($response['return']['Error']['ErrorCode']) && $response['return']['Error']['ErrorCode'] != 0) {
  1672.             $this->session->set('error'$response['return']['Error']['ErrorDescription']);
  1673.             return true;
  1674.         } else {
  1675.             $this->session->set('error'"");
  1676.             return false;
  1677.         }
  1678.     }
  1679.     function getRespond()
  1680.     {
  1681.         $respond json_encode($this->respondJSON_UNESCAPED_SLASHES JSON_UNESCAPED_UNICODE JSON_FORCE_OBJECT);
  1682.         echo $respond;
  1683.     }
  1684.     function getCustomerMessage($type "main"){
  1685.         $Items = [];
  1686.         $Token $this->session->get("Token");
  1687.         $CustomerGUID $this->session->get("CustomerGUID");
  1688.         $CustomerMessage $this->session->get("CustomerMessage") ?? "";
  1689.         $CustomerMessage_count $this->session->get("CustomerMessage_count") ?? 0;
  1690.         $CustomerMessage_count_unread $this->session->get("CustomerMessage_count_unread") ?? 0;
  1691.         if($CustomerMessage == "" || $type == "renew"){
  1692.             $result $this->getCustomerMessages($Token$CustomerGUID);
  1693.             
  1694.             if(isset($result['return']['Error']['ErrorCode']) && $result['return']['Error']['ErrorCode'] != 0) {
  1695.                 $this->session->set("CustomerMessage""false");
  1696.                 $this->session->set("CustomerMessage_count"0);
  1697.                 $this->session->set("CustomerMessage_count_unread"0);
  1698. //                $Items['error'] = $result['return']['Error']['ErrorDescription'];
  1699. //                $Items["message_count"] = 'false';
  1700.             } else {
  1701.                 $messages_arr = [];
  1702.                 //Приватные сообщения
  1703.                 $CustomerMessagesPrivate $result['return']['CustomerMessagesPrivate'] ?? [];
  1704.                 if(isset($CustomerMessagesPrivate["Number"])){
  1705.                     $CustomerMessagesPrivate = [$CustomerMessagesPrivate];
  1706.                 }
  1707.                 foreach ($CustomerMessagesPrivate as $value){
  1708.                     array_push($messages_arr$value);
  1709.                 }
  1710.                 //Публичные сообщения
  1711.                 $CustomerMessagesPublic $result['return']['CustomerMessagesPublic'] ?? [];
  1712.                 if(isset($CustomerMessagesPublic["Number"])){
  1713.                     $CustomerMessagesPublic = [$CustomerMessagesPublic];
  1714.                 }
  1715.                 foreach ($CustomerMessagesPublic as $value){
  1716.                     array_push($messages_arr$value);
  1717.                 }
  1718.                 if($messages_arr == []){
  1719.                     $CustomerMessage 'false';
  1720.                     $CustomerMessage_count 0;
  1721.                 }else{
  1722.                     $CustomerMessage $messages_arr;
  1723.                     $CustomerMessage_count count($CustomerMessage);
  1724.                 }
  1725.                 $this->session->set("CustomerMessage"$CustomerMessage);
  1726.                 $this->session->set("CustomerMessage_count"$CustomerMessage_count);
  1727.                 $CustomerMessage_count_unread 0;
  1728.                 if(is_array($CustomerMessage)){
  1729.                     foreach ($CustomerMessage as $value){
  1730.                         if(isset($value["DateOfConfirmingView"]) && $value["DateOfConfirmingView"] != ""){
  1731.                         }else{
  1732.                             $CustomerMessage_count_unread++;
  1733.                         }
  1734.                     }
  1735.                 }
  1736.                 $this->session->set("CustomerMessage_count_unread"$CustomerMessage_count_unread);
  1737. //                $Items['error'] = "";
  1738. //                $Items["status"] = 'true';
  1739. //                $Items["item"] = $result['return']['Item'];
  1740.             }
  1741.         }
  1742. //        return ["CustomerMessage_count" => $CustomerMessage_count,
  1743. //            "CustomerMessage_count_unread" => $CustomerMessage_count_unread];
  1744.     }
  1745.     function reLogin($request){
  1746.         if($this->session->get("Token") != "" && $this->session->get("CompanyGUID") != ""){
  1747.             return true;
  1748.         }
  1749.         $login $request->cookies->get('login');
  1750.         $password $request->cookies->get('password');
  1751.         if($login == "" || $password == "") {
  1752.             return false;
  1753.         }
  1754.         $response $this->authentication($login$password"""");
  1755.         if($this->getError($response)) {
  1756.             return false;
  1757.         }
  1758.         if(!isset($response["return"]["Token"]) || !isset($response["return"]["CustomerGuid"]))
  1759.         {
  1760.             return false;
  1761.         }
  1762.         $Token $response["return"]["Token"];
  1763.         $CustomerGUID $response["return"]["CustomerGuid"];
  1764.         $ChangePasswordAtFirstLogon $response["return"]["ChangePasswordAtFirstLogon"];
  1765.         $AccessLevel $response["return"]["AccessLevel"] ?? 1;
  1766.         if($login == "vassa" || strtolower($login) == "e.panova@i-t-trade.ru"){
  1767.             $AccessLevel "admin";
  1768.         }
  1769.         $this->session->set("AccessLevel"$AccessLevel);
  1770.         $bonus_list $this->getBonusList($Token$CustomerGUID);
  1771.         if(isset($bonus_list["return"]["Companys"])){
  1772.             if(isset($bonus_list["return"]["Companys"]["GUID"])){
  1773.                 $bonus_list = [$bonus_list["return"]["Companys"]];
  1774.             }else{
  1775.                 $bonus_list $bonus_list["return"]["Companys"];
  1776.             }
  1777.             $bonus_list_bool 'true';
  1778.         }else{
  1779.             $bonus_list = [];
  1780.             $bonus_list_bool 'false';
  1781.         }
  1782.         $this->session->set("bonus_list"$bonus_list);
  1783.         $this->session->set("bonus_list_bool"$bonus_list_bool);
  1784.         $contact_info $this->getContactInfo($Token$CustomerGUID);
  1785.         $persons = [];
  1786.         $address = [];
  1787.         if(isset($contact_info["return"]["ContactInfo"]["Person"])){
  1788.             if(isset($contact_info["return"]["ContactInfo"]["Person"]["GUID"])){
  1789.                 $temp_contact_info[0] = $contact_info["return"]["ContactInfo"]["Person"];
  1790.                 $persons $temp_contact_info;
  1791.             }else{
  1792.                 $persons $contact_info["return"]["ContactInfo"]["Person"];
  1793.             }
  1794.         }else{
  1795.             $persons = [];
  1796.         }
  1797.         if(isset($contact_info["return"]["ContactInfo"]["Address"])){
  1798.             if(isset($contact_info["return"]["ContactInfo"]["Address"]["GUID"])){
  1799.                 $temp_contact_info[0] = $contact_info["return"]["ContactInfo"]["Address"];
  1800.                 $address $temp_contact_info;
  1801.             }else{
  1802.                 $address $contact_info["return"]["ContactInfo"]["Address"];
  1803.             }
  1804.         }else{
  1805.             $address = [];
  1806.         }
  1807.         $contacts["Person"] = $persons;
  1808.         $contacts["Address"] = $address;
  1809.         $this->session->set("contact_info"$contacts);
  1810.         $get_manager $this->getManager($Token$CustomerGUID);
  1811.         if(isset($get_manager["return"]["ManagerInfo"]["GUID"])){
  1812.             $temp_get_manager_info[0] = $get_manager["return"]["ManagerInfo"];
  1813.             $get_manager $temp_get_manager_info;
  1814.         }else{
  1815.             $get_manager $get_manager["return"]["ManagerInfo"] ?? "false";
  1816.         }
  1817.         //ToDo this is a hard fix photo link
  1818.         if($get_manager != "false"){
  1819.             if(isset($get_manager["FIO"])){
  1820.                 $get_manager = [$get_manager];
  1821.             }
  1822.             $i 0;
  1823.             foreach ($get_manager as $manager){
  1824.                 $get_manager[$i]["Photo"] = str_replace("http://""https://"$get_manager[$i]["Photo"]);
  1825.                 if($get_manager[$i]["Photo"] == ""){
  1826.                     $get_manager[$i]["Photo"] = "/img/non_img_manager.png";
  1827.                 }
  1828.                 $i++;
  1829.             }
  1830.         }
  1831.         $this->session->set("manager_info"$get_manager);
  1832.         $this->session->set("Token"$Token);
  1833.         $this->session->set("Login"$login);
  1834.         $this->session->set("CustomerGUID"$CustomerGUID);
  1835.         $response $this->getCompanysList($Token$CustomerGUID);
  1836.         if($this->getError($response)) {
  1837.             return false;
  1838.         }
  1839.         $CompanysList $response["return"]["Companys"];
  1840.         if(isset($CompanysList["GUID"])){
  1841.             $arr[0]= $CompanysList;
  1842.             $CompanysList $arr;
  1843.         }
  1844.         $this->session->set("CompanyGUID"$CompanysList[0]["GUID"]);
  1845.         $this->session->set("CompanyDescription"$CompanysList[0]["Description"]);
  1846.         $this->session->set("CompanysList"$CompanysList);
  1847.         $this->getCustomerMessage();
  1848.         $user_db $this->db->getOneWhereArr(["login" => $login], "users");
  1849.         if($user_db == null){
  1850.             $this->db->insert("users", ["login" => $login]);
  1851.         }
  1852.         $page_number $user_db["main_page"] ?? 0;
  1853.         $this->session->set("user_main_page"$page_number);
  1854.         $page_name $this->getUserMainPage($page_number);
  1855.         $date = new \DateTime();
  1856.         $date->modify('-1 month');
  1857.         $DateBegin $date->format('Y-m-d');
  1858.         $date = new \DateTime();
  1859.         $DateEnd $date->format('Y-m-d');
  1860.         $delivery $this->getCustomerAttributes($Token$CustomerGUID);
  1861.         if(isset($delivery["return"]["DeliveryLimit"])){
  1862.             $this->session->set("DeliveryLimit"$delivery["return"]["DeliveryLimit"]);
  1863.             //$this->session->set("DeliveryLimit", ["FreeDeliveryMin" => "500", "DeliveryPrice" => "500"]);
  1864.         }else{
  1865.             $this->session->set("DeliveryLimit", ["FreeDeliveryMin" => "0""DeliveryPrice" => "0"]);
  1866.         }
  1867.         $response $this->getAccountingInformation($Token$CustomerGUID$CompanysList[0]["GUID"], $DateBegin$DateEnd);
  1868.         $this->session->set("SumDebit"0);
  1869.         if(isset($response["return"]["AccountingInformation"]["AccountingInformationCompanys"])){
  1870.             if(isset($response["return"]["AccountingInformation"]["AccountingInformationCompanys"]["DebtAtTheEnd"])){
  1871.                 $account = [$response["return"]["AccountingInformation"]["AccountingInformationCompanys"]];
  1872.             }else{
  1873.                 $account $response["return"]["AccountingInformation"]["AccountingInformationCompanys"];
  1874.             }
  1875.             foreach ($account as $acc){
  1876.                 if($acc["СompanyGUID"] == $CompanysList[0]["GUID"]){
  1877.                     $this->session->set("SumDebit"$acc["DebtAtTheEnd"]);
  1878.                 }
  1879.             }
  1880.         }
  1881. //        return new Response($twig->render('flex/index.html', $this->twig_values->getTwigTemplate($request) +
  1882. //            ["page_name" => $page_name]
  1883. //        ));
  1884.         $account_info $this->getLoginProperties($Token);
  1885.         $LoginProperties $account_info["return"]["LoginProperties"] ?? false;
  1886.         $this->session->set("LoginProperties"$LoginProperties);
  1887.         return true;
  1888.     }
  1889. }