From: Alexander Smirnov Date: Wed, 28 Feb 2024 08:41:33 +0000 (+0300) Subject: new way of including old project files X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=672d9460a961037f2c564f8e0d717e8e0217b7dc;p=yii-erp24%2F.git new way of including old project files --- diff --git a/erp24/actions/bonus/SexAction.php b/erp24/actions/bonus/SexAction.php new file mode 100644 index 0000000..4e2c174 --- /dev/null +++ b/erp24/actions/bonus/SexAction.php @@ -0,0 +1,12 @@ +controller->render('sex'); + } +} \ No newline at end of file diff --git a/erp24/controllers/BonusController.php b/erp24/controllers/BonusController.php index 27babf4..6dea281 100644 --- a/erp24/controllers/BonusController.php +++ b/erp24/controllers/BonusController.php @@ -15,6 +15,7 @@ class BonusController extends \yii\web\Controller 'ajax-user-add-stop-list' => \yii_app\actions\bonus\AjaxUserAddStopListAction::class, 'ajax-user-remove-stop-list' => \yii_app\actions\bonus\AjaxUserRemoveStopListAction::class, 'ajax-bonus-remove' => \yii_app\actions\bonus\AjaxBonusRemoveAction::class, + 'sex' => \yii_app\actions\bonus\SexAction::class, ]; } } \ No newline at end of file diff --git a/erp24/controllers/SalesChecksController.php b/erp24/controllers/SalesChecksController.php new file mode 100644 index 0000000..0456731 --- /dev/null +++ b/erp24/controllers/SalesChecksController.php @@ -0,0 +1,12 @@ +render('index'); + } +} \ No newline at end of file diff --git a/erp24/controllers/ShipmentController.php b/erp24/controllers/ShipmentController.php old mode 100755 new mode 100644 index 9ba0173..182cbbb --- a/erp24/controllers/ShipmentController.php +++ b/erp24/controllers/ShipmentController.php @@ -1,36 +1,12 @@ \yii_app\actions\shipment\IndexAction::class, - 'add' => \yii_app\actions\shipment\AddAction::class, - 'fields' => \yii_app\actions\shipment\FieldsAction::class, - 'division' => \yii_app\actions\shipment\DivisionAction::class, - 'ajax-division' => \yii_app\actions\shipment\AjaxDivisionAction::class, - 'ajax-admin-online' => \yii_app\actions\shipment\AjaxAdminOnlineAction::class, - 'fields-data2' => \yii_app\actions\shipment\FieldsData2Action::class, - 'ajax-update-fields-data' => \yii_app\actions\shipment\AjaxUpdateFieldsDataAction::class, - 'ajax-update-step' => \yii_app\actions\shipment\AjaxUpdateStepAction::class, - 'ajax-edit-field-value' => \yii_app\actions\shipment\AjaxEditFieldValueAction::class, - 'fields-data' => \yii_app\actions\shipment\FieldsDataAction::class, - 'ajax-update-fields-data-test' => \yii_app\actions\shipment\AjaxUpdateFieldsDataTestAction::class, - 'division-print' => \yii_app\actions\shipment\DivisionPrintAction::class, - 'division-print-edit2' => \yii_app\actions\shipment\DivisionPrintEdit2Action::class, - 'division-print-edit' => \yii_app\actions\shipment\DivisionPrintEditAction::class, - 'set-division-priority' => \yii_app\actions\shipment\SetDivisionPriorityAction::class, - 'store-products-fact' => \yii_app\actions\shipment\StoreProductsFactAction::class, - 'store-products-fact-edit' => \yii_app\actions\shipment\StoreProductsFactEditAction::class, - 'polnogramm' => \yii_app\actions\shipment\PolnogrammAction::class, - 'store-planogram-logi' => \yii_app\actions\shipment\StorePlanogramLogiAction::class, - 'write_off' => \yii_app\actions\shipment\WriteOffAction::class, - ]; +class ShipmentController extends Controller +{ + public function actionIndex() { + return $this->render('index'); } - -} +} \ No newline at end of file diff --git a/erp24/controllers/ShipmentController_old.php b/erp24/controllers/ShipmentController_old.php new file mode 100755 index 0000000..b22711a --- /dev/null +++ b/erp24/controllers/ShipmentController_old.php @@ -0,0 +1,36 @@ + \yii_app\actions\shipment\IndexAction::class, + 'add' => \yii_app\actions\shipment\AddAction::class, + 'fields' => \yii_app\actions\shipment\FieldsAction::class, + 'division' => \yii_app\actions\shipment\DivisionAction::class, + 'ajax-division' => \yii_app\actions\shipment\AjaxDivisionAction::class, + 'ajax-admin-online' => \yii_app\actions\shipment\AjaxAdminOnlineAction::class, + 'fields-data2' => \yii_app\actions\shipment\FieldsData2Action::class, + 'ajax-update-fields-data' => \yii_app\actions\shipment\AjaxUpdateFieldsDataAction::class, + 'ajax-update-step' => \yii_app\actions\shipment\AjaxUpdateStepAction::class, + 'ajax-edit-field-value' => \yii_app\actions\shipment\AjaxEditFieldValueAction::class, + 'fields-data' => \yii_app\actions\shipment\FieldsDataAction::class, + 'ajax-update-fields-data-test' => \yii_app\actions\shipment\AjaxUpdateFieldsDataTestAction::class, + 'division-print' => \yii_app\actions\shipment\DivisionPrintAction::class, + 'division-print-edit2' => \yii_app\actions\shipment\DivisionPrintEdit2Action::class, + 'division-print-edit' => \yii_app\actions\shipment\DivisionPrintEditAction::class, + 'set-division-priority' => \yii_app\actions\shipment\SetDivisionPriorityAction::class, + 'store-products-fact' => \yii_app\actions\shipment\StoreProductsFactAction::class, + 'store-products-fact-edit' => \yii_app\actions\shipment\StoreProductsFactEditAction::class, + 'polnogramm' => \yii_app\actions\shipment\PolnogrammAction::class, + 'store-planogram-logi' => \yii_app\actions\shipment\StorePlanogramLogiAction::class, + 'write_off' => \yii_app\actions\shipment\WriteOffAction::class, + ]; + } + +} diff --git a/erp24/inc/amo.php b/erp24/inc/amo.php index b9070c0..03db602 100644 --- a/erp24/inc/amo.php +++ b/erp24/inc/amo.php @@ -1,4 +1,4 @@ -baseURL, '?') === FALSE) ? '?p=' : '&p='; $this->baseURL = $this->baseURL.$query_string_sep; // Определяем текущую страницу - $this->currentPage = $_GET[$this->queryStringSegment]; + $this->currentPage = @$_GET[$this->queryStringSegment]; if (!is_numeric($this->currentPage) || $this->currentPage == 0){ $this->currentPage = 1; @@ -724,8 +724,27 @@ $str = strtolower($str); */ } -// функция генерирует GUID с префиксом и берет дату текущую и рандом 0000d701-7914-4640-8172-bc1f8c969ad8 -function create_guid_my() { - $str= "er".date("ymd")."-".date("Hi")."-".date("hs")."-".bin2hex(random_bytes(2))."-".bin2hex(random_bytes(6)).""; +// функция генерирует GUID с префиксом и берет дату текущую и рандом 0000d701-7914-4640-8172-bc1f8c969ad8 +function create_guid_my_old($prefix="01",$id_db="") { + $str= "$prefix".date("ym")."-".date("di")."-".date("hs")."-".bin2hex(random_bytes(2))."-".bin2hex(random_bytes(6)).""; + //abcdef-7b73-42c0-0001-000000001123 + return strtolower($str); +} + + +/* $prefix +01 - создание чека +02 - возврат чека +03 - add накладной +04 - add перемещение +06 - списание +$id_db - уникальный номер заказа или номер AUTOINCRIMENT документа из БД +*/ +function create_guid_my($prefix="01",$id_db="") { + if(empty($id_db)) $id_db=rand(0,99999999); + $id_db=100000000000+$id_db; + $str= "$prefix".date("Ym")."-".date("di")."-".date("hs")."-".bin2hex(random_bytes(2))."-".$id_db.""; return strtolower($str); -} \ No newline at end of file +} + + diff --git a/erp24/inc/bonus.php b/erp24/inc/bonus.php index 0a2ad35..6d54d65 100644 --- a/erp24/inc/bonus.php +++ b/erp24/inc/bonus.php @@ -1,4 +1,4 @@ -НЕ удаляем cтарую информацию id=". $row["id"] .""; $summ=0; +/* $data2 = $db2::getRows("SELECT * FROM site_order_items_sostav WHERE tip='1' AND guid!='' AND lid_id=?",[$row["id"]]); foreach ($data2 as $row2) { $items2[]=array("product_id"=>$row2["guid"], "seller_id"=>$seller_id, "quantity"=>$row2["kol"], "price"=>$row2["price"], "discount"=>0); //,"color"=>$row2["color_id"] $summ=$summ+$row2["price"]*$row2["kol"]; } - +*/ $param=array(); $upper=array("id","price","pay","delivery","store_id","payment_type_id","status_id","florist_id","dostavka_povtor_tip"); foreach($upper as $pole) $param[$pole]=$row[$pole]; $param["price"]=$summ; //$param["istochnik_id"]=1; //$uopdet="UPDATE orders_amo SET $sql0 WHERE id=:id "; -$db2::update("orders_amo", $where="id=:id LIMIT 1", $param); +$db::update("orders_amo", $where="id=:id LIMIT 1", $param); mess("Обновили заказ "); - -$sid=$db2::getValue("SELECT sid FROM site_orders WHERE id=? LIMIT 1",[$row["id"]]); +/* +$sid=$db::getValue("SELECT sid FROM site_orders WHERE id=? LIMIT 1",[$row["id"]]); //echo" cid=$sid"; $lid_id=$row["id"]; @@ -236,7 +237,7 @@ $db2::sql($sql); } /////// - +*/ @@ -279,24 +280,27 @@ return $row["id"]; //создаем чек по заказу function create_checks($lid_id){ -global $db; +global $db,$db2; if(!empty($lid_id)) { + +$lid_id=preg_replace('/[^0-9]/', '',$lid_id); + // пароверяем сделки на самовывоз и передано курьеру ставим статус положено в папку $data = $db::getRows("SELECT * FROM orders_amo WHERE delivery!='Самовывоз' AND delivery!='Доставка из магазина' AND id=? LIMIT 1",[$lid_id]); $seller_id="3d8f7db1-8d67-11eb-bf83-b42e991aff6c"; // продавец $store_id="dbd70103-2c7b-11e9-9b87-c85b76f0e893"; // аэродромная $kkm_id="d0d6c742-4db8-11ea-b917-0018f353130f"; //Мочалина Г. М. ИП(Центральный склад) ?? -$payments_type_id="5ee4c07a-36f5-11ec-8900-fc349715dc38"; // оплата на сайте - старый 5ee4c07a-36f5-11ec-8900-fc349715dc38 +$payments_type_id="cd891514-855f-11ea-a625-40618658b055"; // оплата на сайте - старый cd891514-855f-11ea-a625-40618658b055 // Оплата на карту ?? // оплата наличными курьеру ??? $terminal_id="7909401c-703b-11ea-8b4b-0018f353130f"; //Сбербанк ПАО/Мочалина Г. М. ИП 7909401c-703b-11ea-8b4b-0018f353130f $payments_array=[ - "Оплата на сайте (Visa, Mastercard, Мир)"=>array("payments_type_id" =>"5ee4c07a-36f5-11ec-8900-fc349715dc38", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f", "terminal_id"=>"7909401c-703b-11ea-8b4b-0018f353130f" ), // 09 Доставка Букетов + "Оплата на сайте (Visa, Mastercard, Мир)"=>array("payments_type_id" =>"cd891514-855f-11ea-a625-40618658b055", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f", "terminal_id"=>"7909401c-703b-11ea-8b4b-0018f353130f" ), // 09 Доставка Букетов "Перевод на карту Сбербанк"=>array("payments_type_id" =>"a69ea4d1-feff-11e8-8ae7-1c6f659fb563", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f" ), //, "terminal_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38" //payments_type_id = наличные. kkm_id 09 Доставка "Наличными курьеру (+100 руб.)"=>array("payments_type_id" =>"a69ea4d1-feff-11e8-8ae7-1c6f659fb563", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f" ), - "PayPal"=>array("payments_type_id" =>"5ee4c07a-36f5-11ec-8900-fc349715dc38", "kkm_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38", "terminal_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38" ) + "PayPal"=>array("payments_type_id" =>"cd891514-855f-11ea-a625-40618658b055", "kkm_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38", "terminal_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38" ) ]; @@ -311,7 +315,7 @@ $seller_id=$db::getValue("SELECT export_val FROM export_import_table WHERE entit //echo" Вид оплаты ".$row["payment_type_id"]." ".$row["pay"]." ".$row["pay_text"]." florist_id=".$row["florist_id"]." seller_id =$seller_id "; // ставим в соответствие вид оплаты - +if(empty($seller_id)) $seller_id="00000000-0000-0000-0000-000000000000"; $date = $db::getValue("SELECT UNIX_TIMESTAMP(date) as date FROM create_checks WHERE order_id=? AND type='Продажа' order by date desc LIMIT 1",[$lid_id]); @@ -326,6 +330,7 @@ $payments_type_id=$payments_array[$data["payment_type_id"]]["payments_type_id"]; $summ=0; $items2=array(); $payments2=array(); +/* $data2 = $db::getRows("SELECT * FROM site_order_items_sostav WHERE tip='1' AND guid!='' AND lid_id=?",[$row["id"]]); foreach ($data2 as $row2) { @@ -333,6 +338,21 @@ $items2=array(); $payments2=array(); $items2[]=array("product_id"=>$row2["guid"], "seller_id"=>$seller_id, "quantity"=>$row2["kol"], "price"=>$row2["price"], "discount"=>0); $summ=$summ+$row2["price"]*$row2["kol"]; } + + +*/ + +$products_json = $db::getValue("SELECT products_json FROM orders_amo WHERE amo_id=? order by created_at DESC LIMIT 1 ",[$lid_id]); +$products_json = json_decode($products_json, true); + + +print_r($products_json); + +exit(); + + + + if(empty($items2)) $items2[]=array("seller_id"=>$seller_id, "product_id"=>"bdd17583-09d8-11e5-bd74-1c6f659fb563", "quantity"=>1, "price"=>1); //, "discount"=>0 if(empty($summ)) $summ=1; @@ -346,8 +366,17 @@ $payments2[]=$pays_arr; $payments2 = json_encode($payments2, JSON_UNESCAPED_UNICODE); $items2 = json_encode($items2, JSON_UNESCAPED_UNICODE); +try{ $db::sql("INSERT IGNORE INTO create_checks (date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (NOW(),?,?,?,?,?,?,?)", [$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); +} +catch (Exception $e0) { + echo 'Выброшено исключение: ', $e0->getMessage(), "\n"; + file_put_contents('modul/orders/error_create_order.txt', PHP_EOL . $e0->getMessage(), FILE_APPEND); +} + + + @@ -393,16 +422,19 @@ if(empty($error)) { $param["seller_id"]=$data["seller_id"]; $param["store_id"]=$data["store_id"]; $param["order_id"]=$data["order_id"]; - $param["check_id"]=create_guid(); + $param["check_id"]=create_guid_my("11","$id"); $param["sales_check"]=$data["check_id"]; $param["items"]=$data["items"]; - $param["payments"]=$data["payments"]; + $param["payments"]=$data["payments"]; + + if(!empty($param["sales_check"])) { $sql="INSERT INTO create_checks (`date`,`status`,type,kkm_id,seller_id,store_id,order_id, check_id,sales_check,items, payments) VALUES (NOW(), '0', 'Возврат',:kkm_id,:seller_id,:store_id,:order_id,:check_id,:sales_check,:items,:payments)"; - // echo $sql; + echo $sql; $db::sql($sql,$param); mess("Чек на возврат создан"); + } else echo("Чек на возврат не создан так как нет GUID чека продажи"); } @@ -422,27 +454,28 @@ if(empty($error)) { //создаем чек по заказу function create_check($lid_id){ global $db,$db2; -if(!empty($lid_id)) { +if(!empty($lid_id)) { +$lid_id=preg_replace('/[^0-9]/', '',$lid_id); // пароверяем сделки на самовывоз и передано курьеру ставим статус положено в папку $seller_id="3d8f7db1-8d67-11eb-bf83-b42e991aff6c"; // продавец $store_id="dbd70103-2c7b-11e9-9b87-c85b76f0e893"; // аэродромная $kkm_id="d0d6c742-4db8-11ea-b917-0018f353130f"; //Мочалина Г. М. ИП(Центральный склад) ?? -$payments_type_id="5ee4c07a-36f5-11ec-8900-fc349715dc38"; // оплата на сайте - старый 5ee4c07a-36f5-11ec-8900-fc349715dc38 +$payments_type_id="cd891514-855f-11ea-a625-40618658b055"; // оплата на сайте - старый cd891514-855f-11ea-a625-40618658b055 // Оплата на карту ?? // оплата наличными курьеру ??? $terminal_id="7909401c-703b-11ea-8b4b-0018f353130f"; //Сбербанк ПАО/Мочалина Г. М. ИП 7909401c-703b-11ea-8b4b-0018f353130f $payments_array=[ - "Оплата на сайте (Visa, Mastercard, Мир)"=>array("payments_type_id" =>"5ee4c07a-36f5-11ec-8900-fc349715dc38", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f", "terminal_id"=>"7909401c-703b-11ea-8b4b-0018f353130f" ), // 09 Доставка Букетов + "Оплата на сайте (Visa, Mastercard, Мир)"=>array("payments_type_id" =>"cd891514-855f-11ea-a625-40618658b055", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f", "terminal_id"=>"7909401c-703b-11ea-8b4b-0018f353130f" ), // 09 Доставка Букетов "Перевод на карту Сбербанк"=>array("payments_type_id" =>"a69ea4d1-feff-11e8-8ae7-1c6f659fb563", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f" ), //, "terminal_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38" //payments_type_id = наличные. kkm_id 09 Доставка "Наличными курьеру (+100 руб.)"=>array("payments_type_id" =>"a69ea4d1-feff-11e8-8ae7-1c6f659fb563", "kkm_id"=>"d0d6c742-4db8-11ea-b917-0018f353130f" ), - "PayPal"=>array("payments_type_id" =>"5ee4c07a-36f5-11ec-8900-fc349715dc38", "kkm_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38", "terminal_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38" ) + "PayPal"=>array("payments_type_id" =>"cd891514-855f-11ea-a625-40618658b055", "kkm_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38", "terminal_id"=>"a22aeb16-1c6a-11ec-88f6-fc349715dc38" ) ]; -$row = $db2::getRow("SELECT * FROM orders_amo WHERE id=? LIMIT 1",[$lid_id]); +$row = $db::getRow("SELECT * FROM orders_amo WHERE id=? LIMIT 1",[$lid_id]); if(!empty($row) and !in_array($row["delivery"],array("Самовывоз","Доставка из магазина"))) { @@ -466,14 +499,14 @@ echo" Вид оплаты ".$row["payment_type_id"]." ".$row["pay"]." ".$row[ if(!empty($payments_array[$row["payment_type_id"]])) { $payments_type_id=$payments_array[$row["payment_type_id"]]["payments_type_id"]; - - $summ=0; $items2=array(); $payments2=array(); $empty_guid=0; $tov=0; + +/* $data2 = $db2::getRows("SELECT * FROM site_order_items_sostav WHERE tip='1' AND guid!='' AND lid_id=?",[$row["id"]]); foreach ($data2 as $row2) { if(empty($row2["guid"])) $empty_guid=1; @@ -484,6 +517,41 @@ $tov=0; } } + */ + + + + +$products_json = $db::getValue("SELECT products_json FROM orders_amo WHERE amo_id=? order by created_at DESC LIMIT 1 ",[$lid_id]); +$products_json = json_decode($products_json, true); +$tov=0; + +/* + +[{"id":8415,"name":"Букет цветов Красный глянец","url":"https://bazacvetov24.ru/flowers/buket-tsvetov-krasniy-glyanets/","selection":"","count":1,"items":[{"id":786,"name":"Гиперикум","guid":"56c5f37b-0f3b-11e5-bdc0-1c6f659fb563","price":269,"quantity":"2.00","color_id":null},{"id":457,"name":"Альстромерия","guid":"e88a4b1a-11a0-11e5-a4cf-1c6f659fb563","price":209,"quantity":"3.00","color_id":null},{"id":759,"name":"Хризантема Сантини","guid":"b469db90-37fb-11e8-bc38-1c6f659fb563","price":199,"quantity":"2.00","color_id":null},{"id":787,"name":"розы 50 эквадор","guid":"bdd1757d-09d8-11e5-bd74-1c6f659fb563","price":199,"quantity":"5.00","color_id":null},{"id":792,"name":"пленка лист","guid":"440276d6-56e3-11e9-82cb-0018f353130f","price":50,"quantity":"4.00","color_id":null},{"id":788,"name":"лента атласная","guid":"bca06e47-0dff-11e7-959c-1c6f659fb563","price":20,"quantity":"2.00","color_id":null},{"id":805,"name":"Сборка букета без упак","guid":"bca06e43-0dff-11e7-959c-1c6f659fb563","price":50,"quantity":"2.00","color_id":null},{"id":833,"name":"Илекс","guid":"b546566a-98ed-11e5-81bd-1c6f659fb563","price":550,"quantity":"1.00","color_id":null},{"id":8020,"name":"Кермек (м.пучок)","guid":"e3ec2258-4310-11ed-9336-b42e991aff6c","price":1000,"quantity":"0.10","color_id":null}]}] +*/ +$summ=0; +foreach($products_json as $array){ + echo"
Комплект ".$array["name"]." "; + + foreach($array["items"] as $row){ + $tov++; + echo"
".$array["name"]." кол-во".$row["quantity"]." цена ".$row["price"]; + $items2[]=array("product_id"=>$row["guid"],"seller_id"=>$seller_id, "quantity"=>$row["quantity"], "price"=>$row["price"]); + $summ = $summ + $row["price"] * $row["quantity"]; + } + + +} + +//print_r($products_json); + +//exit(); + + + + + if(empty($items2)) $items2[]=array("seller_id"=>$seller_id, "product_id"=>"bdd17583-09d8-11e5-bd74-1c6f659fb563", "quantity"=>1, "price"=>1); //, "discount"=>0 if(empty($summ)) $summ=1; @@ -507,11 +575,11 @@ $error .="В составе нет товаров"; elseif(empty($empty_guid)) { if(!empty($_POST["create_check"]) and $_POST["create_check"]==2) { -$check_id=create_guid(); +$check_id=create_guid_my("01","$lid_id"); $db::sql("INSERT IGNORE INTO create_checks (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (?,NOW(),?,?,?,?,?,?,?)",[$check_id,$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); //$db::sql("INSERT IGNORE INTO create_checks2 (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (?,NOW(),?,?,?,?,?,?,?)",[$check_id,$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); //$db2::sql("INSERT IGNORE INTO create_checks (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (?,NOW(),?,?,?,?,?,?,?)",[$check_id,$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); -mess("Чек добавлен"); +mess("Чек добавлен Сумма чека $summ "); } //echo"INSERT IGNORE INTO create_checks (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES ('$check_id',NOW(), '$kkm_id', '$seller_id' ,'$store_id', 'Продажа', '$lid_id','$items2', '$payments2' )"; diff --git a/erp24/inc/cloudpayments.php b/erp24/inc/cloudpayments.php index a6cdbef..39cbe68 100644 --- a/erp24/inc/cloudpayments.php +++ b/erp24/inc/cloudpayments.php @@ -1,11 +1,17 @@ -
".$z; + echo "
+"; $db::sql($z,$param); } catch (Exception $e1) { diff --git a/erp24/inc/compress.php b/erp24/inc/compress.php index 9851fea..80a792c 100644 --- a/erp24/inc/compress.php +++ b/erp24/inc/compress.php @@ -128,7 +128,7 @@ file_compress('js.js',array( //exit(); // write new timestamp file compress_timestamp.php for php execution code -$infofile=''.PHP_EOL; file_put_contents ('compress_timestamp.php',$infofile,LOCK_EX); //file loaded by ThreeColTemplate1.php to get unique stamp id diff --git a/erp24/inc/compress_timestamp.php b/erp24/inc/compress_timestamp.php index ff1cc49..a7b6012 100644 --- a/erp24/inc/compress_timestamp.php +++ b/erp24/inc/compress_timestamp.php @@ -1,3 +1,3 @@ - diff --git a/erp24/inc/crmconf.php b/erp24/inc/crmconf.php index d25fdb1..33f9596 100644 --- a/erp24/inc/crmconf.php +++ b/erp24/inc/crmconf.php @@ -1,4 +1,4 @@ - $value ) { + if ( isset( $config2[ $property ] ) ) { + $this->$property = $config2[ $property ]; + } + } + } + + + + if (self::$instance2 === null){ + try { + self::$db2 = new PDO( + 'mysql:host='.$config2['DB_HOST'].';dbname='.$config2['DB_NAME'], + $config2['DB_USER'], + $config2['DB_PASSWORD'], + $options = [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES ".$config2['CHARSET'] + ] + ); + } catch (PDOException $e) { + throw new Exception ($e->getMessage()); + } + } + return self::$instance2; + } + + /** + * @param $stmt + * @return PDOStatement + */ + public static function query($stmt) { + + return self::$db2->query($stmt); + } + + /** + * @param $stmt + * @return PDOStatement + */ + public static function prepare($stmt) { + return self::$db2->prepare($stmt); + } + + /** + * @param $query + * @return int + */ + static public function exec($query) { + return self::$db2->exec($query); + } + + /** + * @return string + */ + static public function lastInsertId() { + return self::$db2->lastInsertId(); + } + + /** + * @param $query + * @param array $args + * @return PDOStatement + * @throws Exception + */ + public static function run($query, $args = []) { + try{ + if (!$args) { + return self::query($query); + } + $stmt = self::prepare($query); + $stmt->execute($args); + return $stmt; + } catch (PDOException $e) { + throw new Exception($e->getMessage()); + } + } + + /** + * @param $query + * @param array $args + * @return mixed + */ + public static function getRow($query, $args = []) { + $GLOBALS["sql_cnt"]++; + return self::run($query, $args)->fetch(); + } + + /** + * @param $query + * @param array $args + * @return array + */ + public static function getRows($query, $args = []) { + $GLOBALS["sql_cnt"]++; + return self::run($query, $args)->fetchAll(); + } + + /** + * @param $query + * @param array $args + * @return mixed + */ + public static function getValue($query, $args = []) { + $GLOBALS["sql_cnt"]++; + $result = self::getRow($query, $args); + if (!empty($result)) { + $result = array_shift($result); + } + return $result; + } + + /** + * @param $query + * @param array $args + * @return array + */ + public static function getColumn($query, $args = []) { + $GLOBALS["sql_cnt"]++; + return self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN); + } + + public static function getCol($query, $args = []) { + $GLOBALS["sql_cnt"]++; + return self::run($query, $args)->fetch(PDO::FETCH_NAMED); + } + + + + public static function sql($query, $args = []) + { $GLOBALS["sql_cnt"]++; + self::run($query, $args); + } + + + public static function update($table, $where="id=:id LIMIT 1", $args = []) + { + $query="UPDATE $table SET "; + $i=0; + $param_sql=array(); + foreach($args as $pole =>$val) { + if($i!=0) $query .=","; + $query .=" `$pole`=:$pole"; + $param_sql[$pole]=$val; + $i++; + } + $query .=" WHERE $where"; + self::run($query, $param_sql); + } + + + +} + +global $db,$config2; + +$config2 = [ + 'DB_HOST' => '127.0.0.1', + 'DB_USER' => 'erp24_api_test', + 'DB_PASSWORD' => 'yX2hF4mO2omY7x', + 'DB_NAME' =>'erp24_api_test', + 'CHARSET' => 'utf8', +]; + + +$db = new DB2($config2); + + diff --git a/erp24/inc/db.php b/erp24/inc/db.php index a10ec44..da9a1af 100644 --- a/erp24/inc/db.php +++ b/erp24/inc/db.php @@ -1,4 +1,4 @@ -fetch(); } @@ -120,7 +120,7 @@ protected $config = ''; * @return array */ public static function getRows($query, $args = []) { - $GLOBALS["sql_cnt"] = ($GLOBALS["sql_cnt"] ?? 0) + 1; + @$GLOBALS["sql_cnt"]++; return self::run($query, $args)->fetchAll(); } @@ -130,7 +130,7 @@ protected $config = ''; * @return mixed */ public static function getValue($query, $args = []) { - $GLOBALS["sql_cnt"] = ($GLOBALS["sql_cnt"] ?? 0) + 1; + @$GLOBALS["sql_cnt"]++; $result = self::getRow($query, $args); if (!empty($result)) { $result = array_shift($result); @@ -144,20 +144,19 @@ protected $config = ''; * @return array */ public static function getColumn($query, $args = []) { - $GLOBALS["sql_cnt"] = ($GLOBALS["sql_cnt"] ?? 0) + 1; + @$GLOBALS["sql_cnt"]++; return self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN); } public static function getCol($query, $args = []) { - $GLOBALS["sql_cnt"] = ($GLOBALS["sql_cnt"] ?? 0) + 1; + $GLOBALS["sql_cnt"]++; return self::run($query, $args)->fetch(PDO::FETCH_NAMED); } public static function sql($query, $args = []) - { - $GLOBALS["sql_cnt"] = ($GLOBALS["sql_cnt"] ?? 0) + 1; + { $GLOBALS["sql_cnt"]++; self::run($query, $args); } @@ -173,14 +172,38 @@ protected $config = ''; $i++; } $query .=" WHERE $where"; + $GLOBALS["sql_cnt"]++; self::run($query, $param_sql); } + public static function insert($table, $args = []) + { + $query="INSERT INTO $table "; + $i=0; + $values=""; $fields=""; + $param_sql=array(); + foreach($args as $pole =>$val) { + if($i!=0) { $values .=","; $fields .=","; } + $values .=":$pole"; + $fields .=" `$pole` "; + $param_sql[$pole]=$val; + $i++; + } + $GLOBALS["sql_cnt"]++; + $query .=" ($fields) VALUES ($values)"; + try { + self::run($query, $param_sql); + } catch (Exception $e) { + echo '
Выброшено исключение: ', $e->getMessage(), "\n"; + } + } + + public static function mapping($query, $args = []) { $ret_arr=array(); $data= self::run($query, $args)->fetchAll(); - $GLOBALS["sql_cnt"] = ($GLOBALS["sql_cnt"] ?? 0) + 1;; + @$GLOBALS["sql_cnt"]++; foreach($data as $row) $ret_arr[$row["id"]]=$row["name"]; return $ret_arr; } @@ -191,7 +214,7 @@ protected $config = ''; global $db,$config; $config = [ - 'DB_HOST' => getenv('MODE') === 'dev' ? 'db' : '127.0.0.1', + 'DB_HOST' => getenv('MODE') === 'dev' ? 'db-yii_erp24' : '127.0.0.1', 'DB_USER' => $_CONFIG_SITE["mysql_user"], 'DB_PASSWORD' => $_CONFIG_SITE["mysql_pass"], 'DB_NAME' =>$_CONFIG_SITE["mysql_db"], diff --git a/erp24/inc/db2.php b/erp24/inc/db2.php index f23a6b9..74109f0 100644 --- a/erp24/inc/db2.php +++ b/erp24/inc/db2.php @@ -1,4 +1,4 @@ - 'db-yii_erp24', // '127.0.0.1', + 'DB_HOST' => '127.0.0.1', 'DB_USER' => 'bazacvetov24', - 'DB_PASSWORD' => 'JVJruro_Xdg456o3ir', - 'DB_NAME' => 'erp24', // 'bazacvetov24', + 'DB_PASSWORD' => 'JVJruro_Xdg456o3ir', + 'DB_NAME' =>'bazacvetov24', 'CHARSET' => 'utf8', ]; diff --git a/erp24/inc/db_bz24.php b/erp24/inc/db_bz24.php index 2bde44d..a5f2665 100644 --- a/erp24/inc/db_bz24.php +++ b/erp24/inc/db_bz24.php @@ -1,4 +1,4 @@ - '127.0.0.1', 'DB_USER' => 'bazacvetov24', diff --git a/erp24/inc/design.php b/erp24/inc/design.php index 1463833..3728057 100644 --- a/erp24/inc/design.php +++ b/erp24/inc/design.php @@ -1,4 +1,4 @@ - -<?php if(empty($_CRM_TITLE)) echo"ERP BioWork"; else echo $_CRM_TITLE; ?> +<? if(empty($_CRM_TITLE)) echo"ERP BioWork"; else echo $_CRM_TITLE; ?> -'; ?> /"/> - -$time_cache)){ } - +} //echo''; /* - */ -?> - + */ +?> + + + +echo'
diff --git a/erp24/inc/design_new.php b/erp24/inc/design_new.php index d2f8876..78db7f4 100644 --- a/erp24/inc/design_new.php +++ b/erp24/inc/design_new.php @@ -1,4 +1,4 @@ - -<?php if(empty($_CRM_TITLE)) echo"CRM BioWork"; else echo $_CRM_TITLE; ?> +<? if(empty($_CRM_TITLE)) echo"CRM BioWork"; else echo $_CRM_TITLE; ?> -"; @@ -92,7 +92,7 @@ $fp = @fopen($crc_page, "w+"); echo''; ?> /"/> - $_SESSION["admin_id"]]); } @@ -113,11 +113,11 @@ $manager_id=(int)$_SESSION['manager_id']; -'; /* - */ + */ ?> - + + - @@ -403,7 +405,7 @@ $tm="Время: ".$totaltime."сек."; echo' -