From f74fe6f6960a88a693f7fab4fcb099cfe74922f9 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:33:01 +0300 Subject: [PATCH 01/12] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D0=B8=D1=84=D0=B8?= =?UTF-8?q?=D1=86=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D1=8B=20=D1=81=D0=BA?= =?UTF-8?q?=D1=80=D0=B8=D0=BF=D1=82=D1=8B=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B7=D1=8B=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85,=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=BD=D1=83=D0=BC=D0=B5=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B2=20=D0=BF=D0=BE=D1=80=D1=8F=D0=B4=D0=BA?= =?UTF-8?q?=D0=B5=20=D0=B8=D1=85=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B8=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=B2=D0=B5=D1=80=D1=82=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/{init.sql => 0_init.sql} | 9 ++++-- sql/{pr_ed_izm.sql => 1_pr_ed_izm.sql} | 0 ...getBasePrice.sql => 2_pr_getBasePrice.sql} | 0 sql/{receipt_ddl.sql => 3_receipt_ddl.sql} | 4 +-- sql/4_products.sql | 30 +++++++++++++++++++ sql/pr_products_main_clsf.sql | 2 -- sql/pr_shops_main_clsf.sql | 2 -- 7 files changed, 39 insertions(+), 8 deletions(-) rename sql/{init.sql => 0_init.sql} (95%) mode change 100755 => 100644 rename sql/{pr_ed_izm.sql => 1_pr_ed_izm.sql} (100%) mode change 100755 => 100644 rename sql/{pr_getBasePrice.sql => 2_pr_getBasePrice.sql} (100%) rename sql/{receipt_ddl.sql => 3_receipt_ddl.sql} (95%) create mode 100644 sql/4_products.sql delete mode 100755 sql/pr_products_main_clsf.sql delete mode 100755 sql/pr_shops_main_clsf.sql diff --git a/sql/init.sql b/sql/0_init.sql old mode 100755 new mode 100644 similarity index 95% rename from sql/init.sql rename to sql/0_init.sql index 1fab395..958df96 --- a/sql/init.sql +++ b/sql/0_init.sql @@ -111,9 +111,14 @@ CREATE TABLE `pr_product_offers` ( CREATE TABLE `pr_consumption_clsf` ( `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, - `creator` int(11), + `creator` int(11) DEFAULT NULL, `name` text COLLATE utf8_unicode_ci NOT NULL, - `id_hi` int(11), + `id_hi` int(11) DEFAULT NULL, + `photo` text COLLATE utf8_unicode_ci, + `text` text COLLATE utf8_unicode_ci, + `ed_izm_id` int(11) DEFAULT NULL, + `in_box` double DEFAULT NULL, + `date_change` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, CONSTRAINT `pr_consumption_clsf_creator` FOREIGN KEY (`creator`) REFERENCES `pr_users` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `pr_consumption_clsf_id_hi` FOREIGN KEY (`id_hi`) REFERENCES `pr_consumption_clsf` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/sql/pr_ed_izm.sql b/sql/1_pr_ed_izm.sql old mode 100755 new mode 100644 similarity index 100% rename from sql/pr_ed_izm.sql rename to sql/1_pr_ed_izm.sql diff --git a/sql/pr_getBasePrice.sql b/sql/2_pr_getBasePrice.sql similarity index 100% rename from sql/pr_getBasePrice.sql rename to sql/2_pr_getBasePrice.sql diff --git a/sql/receipt_ddl.sql b/sql/3_receipt_ddl.sql similarity index 95% rename from sql/receipt_ddl.sql rename to sql/3_receipt_ddl.sql index 46df71b..a2533af 100644 --- a/sql/receipt_ddl.sql +++ b/sql/3_receipt_ddl.sql @@ -3,7 +3,7 @@ CREATE TABLE `rcp_receipt` ( `buyerAddress` text, `totalSum` int(11) DEFAULT NULL, `addressToCheckFiscalSign` text, - `fiscalDriveNumber` int(20), + `fiscalDriveNumber` text, `rawData` text, `kktRegId` text, `user` text, @@ -25,7 +25,7 @@ CREATE TABLE `rcp_receipt` ( `dateTime` DATETIME DEFAULT NULL, `ndsNo` int(11) DEFAULT NULL, `user_id` int(11) NOT NULL, - CONSTRAINT `rcp_receipt_uk` UNIQUE KEY (`dateTime`, `totalSum`, `fiscalDriveNumber`, `fiscalDocumentNumber`, `fiscalSign`), + CONSTRAINT `rcp_receipt_uk` UNIQUE KEY (`dateTime`, `totalSum`, `fiscalDocumentNumber`, `fiscalSign`), CONSTRAINT `rcp_receipt_user_id` FOREIGN KEY (`user_id`) REFERENCES `pr_users` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/sql/4_products.sql b/sql/4_products.sql new file mode 100644 index 0000000..0e3f40d --- /dev/null +++ b/sql/4_products.sql @@ -0,0 +1,30 @@ +CREATE TABLE `pr_ids` ( + `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, + `prod_id` int(11) NOT NULL, + `inn` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + UNIQUE KEY `name_inn` (`inn`,`name`) USING BTREE, + CONSTRAINT `pr_ids_ibfk_1` FOREIGN KEY (`prod_id`) REFERENCES `pr_consumption_clsf` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +CREATE VIEW `pr_items_unknown` AS +select distinct + `i`.`name` AS `name`, + `r`.`userInn` AS `inn`, + `r`.`dateTime` AS `date`, + `r`.`retailPlaceAddress` AS `address` +from `rcp_item` `i` + join `rcp_receipt` `r` on`i`.`receipt_id` = `r`.`id` + left join `pr_ids` `p` on `r`.`userInn` = `p`.`inn` and `i`.`name` = `p`.`name` +where `p`.`inn` IS NULL; + +CREATE VIEW `pr_purchases` AS +select + `a`.`sum` AS `sum`, + `b`.`dateTime` AS `date`, + `c`.`id` AS `buyer_id`, + `d`.`prod_id` AS `item_id` +from `rcp_item` `a` + join `rcp_receipt` `b` on `a`.`receipt_id` = `b`.`id` + join `pr_users` `c` on `b`.`user_id` = `c`.`id` + join `pr_ids` `d` on `b`.`userInn` = `d`.`inn` and `a`.`name` = `d`.`name`; \ No newline at end of file diff --git a/sql/pr_products_main_clsf.sql b/sql/pr_products_main_clsf.sql deleted file mode 100755 index f57961a..0000000 --- a/sql/pr_products_main_clsf.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO pr_products_main_clsf (name) VALUES -('Главный классификатор товаров'); diff --git a/sql/pr_shops_main_clsf.sql b/sql/pr_shops_main_clsf.sql deleted file mode 100755 index 4f93561..0000000 --- a/sql/pr_shops_main_clsf.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO pr_shops_main_clsf (name) VALUES -('Главный классификатор магазинов'); From e464773c088aa5258442ae8a50591d70f5cec2b0 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:41:36 +0300 Subject: [PATCH 02/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D0=BE=D0=BB=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=B2=20JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/template/oft_table.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pr/template/oft_table.php b/pr/template/oft_table.php index ed60043..15c7470 100644 --- a/pr/template/oft_table.php +++ b/pr/template/oft_table.php @@ -13,7 +13,7 @@ static function header($h){ static function row($r){ echo ""; foreach ($r as $i => $value) { - echo "$value"; + echo "$value"; } echo ""; } @@ -31,3 +31,17 @@ static function addCol($a,$num,$value){ }; ?> + + From 7296c2112194bc61b2dfe68ae60d5e17ebe2c3fa Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:43:06 +0300 Subject: [PATCH 03/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20JSTree=20=D0=B2=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=81=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D1=83=D0=BA=D1=82=D1=83=D1=80=D0=BE=D0=B9=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=86=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/template/jstree/basetree.php | 95 ++++++++++++++++----------------- pr/template/jstree/jstree.php | 59 +++++++++++++------- 2 files changed, 87 insertions(+), 67 deletions(-) diff --git a/pr/template/jstree/basetree.php b/pr/template/jstree/basetree.php index 073c075..123df6e 100755 --- a/pr/template/jstree/basetree.php +++ b/pr/template/jstree/basetree.php @@ -7,83 +7,80 @@ function checkRights(){ throw new Exception('Требуется авторизация'); } - function doTreeOperation($tbl_dir, $tbl_term, $showTerm){ + function doTreeOperation($tbl_dir, $tbl_term, $showTerm, $rootText = 'Корень'){ global $db; $res = array(); + $id = $_GET['id']; + if($id == '-1') + $id = NULL; + try { switch($_GET['operation']){ case "get_node": if($_GET['id']=="#"){ - // $res[] = array('text' => 'Мои товары', 'children' => true, 'id' => '2', 'icon' => 'folder'); - foreach($db->query("select id, name from $tbl_dir where id_hi is null".(($tbl_term == null)?" and creator=".$_SESSION['user']['id']:"")) as $v){ - $res[] = array('text' => $v['name'], 'children' => true, 'id' => $v['id'], 'icon' => 'folder', 'state' => array('opened' => 'true')); - } + $qres = $db->query("select `id` from `$tbl_term`"); + $res[] = array('text' => $rootText, + 'children' => $qres->rowCount() != 0, + 'id' => '-1', + 'icon' => 'folder', + 'state' => array('opened' => 'true')); }else{ $stmt = $db->prepare( - "select id, name, - (".(($tbl_term != null) - ?"select count(*) from $tbl_term tt where tt.main_clsf_id = t1.id" - :"0" - ). - ") termCnt, - ( - select count(*) - from $tbl_dir t2 - where t2.id_hi = t1.id - ) childCnt - from $tbl_dir t1 - where id_hi=? - order by name"); - $stmt->execute(array($_GET['id'])); - while($v = $stmt->fetch()){ - $res[] = array('text' => $v['name'], 'children' => ($v['termCnt'] + $v['childCnt'] > 0), 'id' => $v['id'], 'icon' => 'folder'); - } - if ($tbl_term != null) { - $stmt = $db->prepare("select id, name from $tbl_term where main_clsf_id=? order by name"); - $stmt->execute(array($_GET['id'])); - while($v = $stmt->fetch()){ - $res[] = array('text' => $v['name'], 'children' => false, 'id' => 'f'.$v['id'], 'type' => 'file', 'icon' => 'file'); - } - } + "SELECT + `a`.`id` AS `id`, + `a`.`name` AS `name`, + ( + SELECT COUNT(*) != 0 + FROM `$tbl_term` `b` + WHERE `b`.`id_hi` = `a`.`id` + ) `is_group` + FROM `$tbl_term` `a`" . + ($id == NULL ? "WHERE `a`.`id_hi` IS NULL" : "WHERE `a`.`id_hi` = ?")); + $stmt->execute(array($id)); + foreach($stmt as $v) + $res[] = array('text' => $v['name'], + 'children' => $v['is_group'] == 1 ? true : false, + 'id' => $v['id'], + 'icon' => $v['is_group'] ? 'folder' : 'file'); } break; case "create_node": checkRights(); - $stmt = $db->prepare("insert into $tbl_dir(name, id_hi)values(?, ?)"); - $stmt->execute(array($_GET['text'], $_GET['id'])); + $stmt = $db->prepare("insert into $tbl_term(name, id_hi)values(?, ?)"); + $id = $_GET['id']; + if($id == '-1') + $id = null; + $stmt->execute(array($_GET['text'], $id)); $res = array('id' => $db->lastInsertId()); break; case "rename_node": checkRights(); - $stmt = $db->prepare("update $tbl_dir set name=? where id=?"); + $stmt = $db->prepare("update $tbl_term set name=? where id=?"); $stmt->execute(array($_GET['text'], $_GET['id'])); break; default: - $is_file = (substr($_GET['id'], 0, 1) == 'f'); - $id = $is_file?substr($_GET['id'], 1):$_GET['id']; switch($_GET['operation']){ case "copy_node": checkRights(); - $stmt = $db->prepare($is_file? - "insert into pr_products(name, ed_izm_id, in_box, main_clsf_id, creator) - select name, ed_izm_id, in_box, ?, ? from pr_products where id=?" - :"insert into $tbl_dir(name, id_hi) select name, ? from pr_products_main_clsf where id=?"); - $stmt->execute($is_file? - array($_GET['parent'], $_SESSION['user']['id'], $id) - :array($_GET['parent'], $id)); + $parent = $_GET['parent']; + if($parent == '-1') + $parent = NULL; + $stmt = $db->prepare("insert into $tbl_term(name, ed_izm_id, in_box, id_hi, creator) + select name, ed_izm_id, in_box, ?, ? from $tbl_term where id=?"); + $stmt->execute(array($parent, $_SESSION['user']['id'], $id)); break; case "move_node": checkRights(); - $stmt = $db->prepare($is_file? - "update $tbl_term set main_clsf_id=? where id=?" - :"update $tbl_dir set id_hi=? where id=?"); - $stmt->execute(array($_GET['parent'], $id)); + $parent = $_GET['parent']; + if($parent == '-1') + $parent = NULL; + + $stmt = $db->prepare("update $tbl_term set id_hi=? where id=?"); + $stmt->execute(array($parent, $id)); break; case "delete_node": checkRights(); - $stmt = $db->prepare($is_file? - "delete from $tbl_term where id=?" - :"delete from $tbl_dir where id=?"); + $stmt = $db->prepare("delete from $tbl_term where id=?"); if(!$stmt->execute(array($id))){ throw new Exception('Ошибка удаления '.$stmt->errorInfo()); } diff --git a/pr/template/jstree/jstree.php b/pr/template/jstree/jstree.php index f32aceb..e0deb3a 100644 --- a/pr/template/jstree/jstree.php +++ b/pr/template/jstree/jstree.php @@ -44,28 +44,50 @@ function putTree($suf, $path){ 'contextmenu' : { 'items' : function(node) { var tmp = $.jstree.defaults.contextmenu.items(); - - tmp.remove.label = "Удалить"; - tmp.ccp.label = "Редактирование"; - tmp.ccp.submenu.copy.label = "Копировать"; - tmp.ccp.submenu.cut.label = "Вырезать"; - - if(this.get_type(node) === "file") { - delete tmp.create; + if(node.id == '-1') { + delete tmp.remove; delete tmp.rename; - delete tmp.ccp.submenu.paste; - }else{ - tmp.create.action = function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - inst.create_node(obj, { type : "default" }, "last", function (new_node) { - setTimeout(function () { inst.edit(new_node); },0); - }); + delete tmp.ccp.submenu.copy; + delete tmp.ccp.submenu.cut; + } + else{ + tmp.remove.label = "Удалить"; + tmp.remove.action = function(data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference), + parent = inst.get_node(inst.get_parent(obj)); + + if(inst.delete_node(obj)) { + if(parent.id != '-1' && !parent.children.length == 1) { + inst.set_type(parent, "file"); + inst.set_icon(parent, "file"); + } } - tmp.create.label = "Добавить каталог"; + } + tmp.rename.label = "Переименовать"; - tmp.ccp.submenu.paste.label = "Вставить"; + + tmp.ccp.submenu.copy.label = "Копировать"; + tmp.ccp.submenu.cut.label = "Вырезать"; } + + tmp.create.action = function (data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference); + + if(obj.id != '-1') { + inst.set_type(obj, "default"); + inst.set_icon(obj, "folder"); + } + inst.create_node(obj, { type : "file" }, "last", function (new_node) { + setTimeout(function () { inst.edit(new_node); },0); + }); + + } + tmp.create.label = "Добавить товар"; + + tmp.ccp.label = "Редактирование"; + tmp.ccp.submenu.paste.label = "Вставить"; return tmp; } }, @@ -85,6 +107,7 @@ function putTree($suf, $path){ $.get('tree.php?operation=create_node', { 'type' : data.node.type, 'id' : data.node.parent, 'text' : data.node.text }) .done(function (d) { data.instance.set_id(data.node, d.id); + }) .fail(function () { data.instance.refresh(); From 08517c6d216f3244035ea2c03e4ae761f7585313 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:53:36 +0300 Subject: [PATCH 04/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=20=D0=BF=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B0=20=D0=BD=D0=BE=D0=B2=D1=83=D1=8E,=20?= =?UTF-8?q?=D0=B2=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D1=82=D0=B0=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=83=D0=B4=D0=BE=D0=B1=D1=81=D1=82=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/products/save.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pr/products/save.php b/pr/products/save.php index 47f5b01..cfa8216 100644 --- a/pr/products/save.php +++ b/pr/products/save.php @@ -1,4 +1,8 @@ prepare("SELECT id FROM pr_products WHERE name = ? and id != ?"); +$stmt = $db->prepare("SELECT id FROM " . PRODUCTS_TABLE_NAME . " WHERE name = ? and id != ?"); $stmt->execute(array($_REQUEST['product_name'], $_REQUEST['id'])); if($stmt->fetch()){ echo json_encode(array('result' => 'Товар с таким названием уже есть', 'error' => '1')); die(); } if (isset($_REQUEST['id'])) { - $stmt = $db->prepare("UPDATE pr_products SET name = ?, ed_izm_id = ?, in_box = ? WHERE id = ?"); + $stmt = $db->prepare("UPDATE " . PRODUCTS_TABLE_NAME . " SET name = ?, ed_izm_id = ?, in_box = ? WHERE id = ?"); if(!$stmt->execute(array($_REQUEST['product_name'], $_REQUEST['ed_izm'], doKolvo($_REQUEST['in_box']), $_REQUEST['id']))){ echo json_encode(array('result' => 'Ошибка изменения товара.', 'error' => '1')); //echo 'Ошибка изменения товара'; print_r($stmt->errorInfo()); @@ -40,7 +44,7 @@ function doKolvo($s){ echo json_encode(array('result' => 'Ошибка при загрузке изображения', 'error' => '1')); die(); } - $photoFileName = '/pricer/uploaded/'.$_FILES['image']['name']; + $photoFileName = UPLOADS_FOLDER_PATH . $_FILES['image']['name']; $fullPath = $_SERVER['DOCUMENT_ROOT'].$photoFileName; if(file_exists($fullPath)){ function on_file_exist($path){ @@ -76,7 +80,7 @@ function on_file_exist($path){ if(move_uploaded_file($_FILES['image']['tmp_name'], $fullPath)){ $pieces = explode("/", $fullPath); $photoFileName = array_pop($pieces); - $stmt = $db->prepare("UPDATE pr_products SET photo = ? WHERE id = ?"); + $stmt = $db->prepare("UPDATE " . PRODUCTS_TABLE_NAME . " SET photo = ? WHERE id = ?"); if(!$stmt->execute(array($photoFileName, $_REQUEST['id']))){ echo json_encode(array('result' => 'Ошибка изменения фото товара.', 'error' => '1')); //echo 'Ошибка изменения фото товара'; print_r($stmt->errorInfo()); @@ -91,8 +95,8 @@ function on_file_exist($path){ echo json_encode($result); exit(); } else { - $stmt = $db->prepare("INSERT pr_products(name, ed_izm_id, in_box, main_clsf_id, creator) values(?, ?, ?, ?, ?)"); - if(!$stmt->execute(array($_REQUEST['product_name'], $_REQUEST['ed_izm'], doKolvo($_REQUEST['in_box']), $_REQUEST['main_clsf_id'], $_SESSION['user']['id']))){ + $stmt = $db->prepare("INSERT INTO " . PRODUCTS_TABLE_NAME . " (name, ed_izm_id, in_box, id_hi, creator) values(?, ?, ?, ?, ?)"); + if(!$stmt->execute(array($_REQUEST['product_name'], $_REQUEST['ed_izm'], doKolvo($_REQUEST['in_box']), $_REQUEST['id_hi'], $_SESSION['user']['id']))){ echo json_encode(array('result' => 'Ошибка добавления товара.', 'error' => '1')); //echo 'Ошибка добавления товара'; print_r($stmt->errorInfo()); exit(); From c8e5dd1579b591e566aa9438e63930b6c1a81140 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:55:22 +0300 Subject: [PATCH 05/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B4=D0=B5=D1=80=D0=B5=D0=B2=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BD=D0=BE=D0=B2=D1=83=D1=8E,=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B2=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20=D1=81=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=20=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83?= =?UTF-8?q?=D1=80=D0=BE=D0=B9=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/products/tree.php | 83 ++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/pr/products/tree.php b/pr/products/tree.php index 56c0df2..45d8110 100644 --- a/pr/products/tree.php +++ b/pr/products/tree.php @@ -1,46 +1,42 @@ ЦенаМагазинДата'; - $stmt = $db->prepare( - "SELECT s.name, po1.date_buy, min(price) pr - FROM pr_product_offers po1, pr_shops s - WHERE po1.product = ? - and (po1.shop, po1.date_buy) in ( - SELECT shop, max(date_buy) - FROM pr_product_offers - WHERE product = ? - GROUP BY shop - ) - and po1.shop = s.id - GROUP BY s.name, po1.date_buy - ORDER BY pr" - ); - $stmt->execute(array($id, $id)); - while($price = $stmt->fetch()){ - $r .= ''.$price['pr'].''.$price['name'].''.$price['date_buy']; - } - $r .= ''; + $r .= '
ЦенаМагазинДата'; + $stmt = $db->prepare( + "SELECT s.name, po1.date_buy, min(price) pr + FROM pr_product_offers po1, pr_shops s + WHERE po1.product = ? + and (po1.shop, po1.date_buy) in ( + SELECT shop, max(date_buy) + FROM pr_product_offers + WHERE product = ? + GROUP BY shop + ) + and po1.shop = s.id + GROUP BY s.name, po1.date_buy + ORDER BY pr" + ); + $stmt->execute(array($id, $id)); + while($price = $stmt->fetch()){ + $r .= '
'.$price['pr'].''.$price['name'].''.$price['date_buy']; } + $r .= '
'; }else{ $readonly = ($_SESSION['user']['id']==null); - if($is_file){ - $stmt = $db->prepare( - "SELECT pr_products.name, photo, pr_ed_izm.name as ed_izm, ed_izm_id, in_box - FROM pr_products - LEFT JOIN pr_ed_izm on pr_ed_izm.id = pr_products.ed_izm_id - WHERE pr_products.id = ?" - ); - $stmt->execute(array($id)); - if(!($product = $stmt->fetch())){ - return array('content' => 'Товар не найден'); - } - }else{ - if($readonly) - return array('content' => ''); + + $stmt = $db->prepare( + "SELECT `a`.name, photo, `b`.name as ed_izm, ed_izm_id, in_box + FROM " . PRODUCTS_TABLE_NAME . " `a`" . + "LEFT JOIN `pr_ed_izm` `b` on `b`.id = `a`.ed_izm_id + WHERE `a`.id = ?" + ); + $stmt->execute(array($id)); + if(!($product = $stmt->fetch())){ + return array('content' => 'Товар не найден'); } $r = '
' .'Название товара*
' - .'

'; + .'

'; if($product['photo']){ $ph = '/pricer/uploaded/'.$product['photo']; }else{ @@ -92,21 +88,16 @@ function showProduct($is_file, $id){ } $r .= '

Количество единиц измерения в товаре
'; - if($is_file) $r .= '

Перейти к ценам'; if(!$readonly){ - $r .= '

'; - if($is_file) - $r .= ''; - else - $r .= ''; + $r .= '

'; + + $r .= ''; } $r .= '
'; } - return ($is_file)? - array('content' => $r, 'product_id' => $id) - :array('content' => $r, 'product_id' => ''); + return array('content' => $r, 'product_id' => $id); } - doTreeOperation('pr_products_main_clsf', 'pr_products', 'showProduct'); + doTreeOperation('', PRODUCTS_TABLE_NAME, 'showProduct'); ?> From 9feafee189f6ed65f72f71039641f8a37431b875 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:57:53 +0300 Subject: [PATCH 06/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=86=D0=B5=D0=B9=20=D1=82=D1=80=D0=B0=D0=BD=D1=81?= =?UTF-8?q?=D0=BB=D1=8F=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/products/translation_table.php | 308 ++++++++++++++++++++++++++++++ 1 file changed, 308 insertions(+) create mode 100644 pr/products/translation_table.php diff --git a/pr/products/translation_table.php b/pr/products/translation_table.php new file mode 100644 index 0000000..8f4a32b --- /dev/null +++ b/pr/products/translation_table.php @@ -0,0 +1,308 @@ +prepare('SELECT `a`.`id` AS `id`, + `a`.`prod_id` AS `cl_id`, + `a`.`name` AS `name`, + `a`.`inn` AS `inn`, + `b`.`name` AS `cl_name` + FROM `pr_ids` `a` + JOIN `pr_consumption_clsf` `b` ON `a`.`prod_id` = `b`.`id` + WHERE ' . ($id ? "`a`.`prod_id` = ?" : '1')); + $params = array(); + if($id) + $params[] = $id; + + if($stmt->execute($params)) { + + $n = $stmt->rowCount(); + $arr = array(); + foreach($stmt as $row) { + $arr[] = array('id' => $row['id'], + 'cl_id' => $row['cl_id'], + 'name' => $row['name'], + 'inn' => $row['inn'], + 'cl_name' => $row['cl_name']); + } + + print json_encode($arr); + } + else + print ERROR; + + } + else if($op == 'get_path') { + + if(isset($_POST['id'])) { + $id = $_POST['id']; + $stmt = $db->prepare('select `pr_get_product_path`(?) AS `path`'); + + if($stmt->execute(array($id))) { + $path = $stmt->fetch()['path']; + if(empty($path)) + print '"path":[]'; + else { + $path .= $id; + $arr = explode('/', $path); + + $pathArr = array('path' => $arr); + print json_encode($pathArr); + } + } + else + print ERROR; + } + else + print ERROR; + + } + else if($op == 'item_remove') { + + if(isset($_POST['id'])) { + + $id = $_POST['id']; + $stmt = $db->prepare('DELETE FROM `pr_ids` WHERE id=?'); + + if($stmt->execute(array($id))) + print OK; + else + print ERROR; + } + else + print ERROR; + } + else if($op == 'item_add') { + + if(isset($_POST['id']) && isset($_POST['name']) && isset($_POST['inn'])) { + $id = (int)$_POST['id']; + $name = $_POST['name']; + $inn = $_POST['inn']; + + $stmt = $db->prepare('INSERT INTO `pr_ids` (`prod_id`, `name`, `inn`) VALUES (?, ?, ?)'); + $exec_prms = array($_POST['id'], $_POST['name'], $_POST['inn']); + + if($stmt->execute($exec_prms)) + print OK; + else + print ERROR; + } + else + print ERROR; + + } + else + print ERROR; + + exit; +} + +include '../template/header.php'; +include '../template/oft_table.php'; +include '../template/jstree/jstree.php'; + +headerOut('Соответствие товара', array('prod')); + +?> + + + + + + +
+ + + + + + +
+ + + + + From e6681801961da706545da85af6f08d668422e35e Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:58:30 +0300 Subject: [PATCH 07/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=86=D0=B5=D0=B9=20=D0=BD=D0=B5=D0=B8=D0=B7=D0=B2?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=BD=D1=8B=D1=85=20=D0=BA=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D1=80=D1=83=20?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/products/unknown_products.php | 143 +++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 pr/products/unknown_products.php diff --git a/pr/products/unknown_products.php b/pr/products/unknown_products.php new file mode 100644 index 0000000..0c493f3 --- /dev/null +++ b/pr/products/unknown_products.php @@ -0,0 +1,143 @@ +query('SELECT `name`, `inn`, `address`, `date` FROM `pr_items_unknown`'); + if($stmt) { + $n = $stmt->rowCount(); + $arr = array(); + foreach($stmt as $row) { + $arr[] = array('name' => $row['name'], + 'inn' => $row['inn'], + 'address' => $row['address'], + 'date' => $row['date']); + } + + print json_encode($arr); + } + else + print ERROR; + + exit; + } + + include '../template/header.php'; + + headerOut('Неизвестные товары', array('prod')); + + if($_SESSION['user']['id']) { + + include '../template/oft_table.php'; + include '../template/jstree/jstree.php'; + +?> + + + + + + +
+ + + +
+ + + + \ No newline at end of file From 784825fc44649ffa4c8ff7251d7629ead47663f8 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 14:59:15 +0300 Subject: [PATCH 08/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81?= =?UTF-8?q?=D0=BE=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=81=D1=82=D0=B8=D0=BA?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=BF=D0=BE=D0=BA=D1=83=D0=BF=D0=B0=D0=B5=D0=BC?= =?UTF-8?q?=D1=8B=D1=85=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/products/stats.php | 370 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 370 insertions(+) create mode 100644 pr/products/stats.php diff --git a/pr/products/stats.php b/pr/products/stats.php new file mode 100644 index 0000000..703d5f5 --- /dev/null +++ b/pr/products/stats.php @@ -0,0 +1,370 @@ +prepare($req); + if($stmt->execute($params)) { + + $res = array(); + + $root = array( + 'name' => 'Всего', + 'pr_id' => '-1', + 'buyer' => null, + 'date' => null, + 'buy_num' => 0, + 'buyers_num' => 0, + 'buyers' => [], + 'sum' => 0, + 'children' => []); + + $i = 0; + foreach($stmt as $row) { + $empty = $row['buyer_id'] === null; + $res[] = array( + 'name' => $row['name'], + 'pr_id' => $row['pr_id'], + 'buyer' => $row['buyer'], + 'date' => $row['date'], + 'group_id' => $row['group_id'], + 'buy_num' => $empty ? 0 : 1, + 'buyers_num' => 0, + 'buyers' => ($empty ? [] : + array($row['buyer_id'] => false)), + 'sum' => $row['sum'], + 'children' => []); + } + + $arr = array(); + foreach($res as &$val) { + $id = $val['pr_id']; + $empty = count($val['buyers']) == 0; + + if(array_key_exists($id, $arr)) { + + if(!$empty) + $arr[$id]['buyers'][key($val['buyers'])] = true; + + $arr[$id]['buy_num'] += $val['buy_num']; + $arr[$id]['sum'] += $val['sum']; + } + else + $arr[$id] = $val; + } + + if($itemId) { + + foreach($arr as &$val) { + $par = $val['group_id']; + if($par === null) { + $root['children'][] = &$val; + $val['group_id'] = '-1'; + } + else + $arr[$par]['children'][] = &$val; + } + + $ids = array(); + getChildrenIds($root, $itemId, $ids); + $n = count($res); + for($i = 0; $i < $n; $i++) { + unset($res[$i]['children'], + $res[$i]['buyers'], + $res[$i]['group_id']); + if($res[$i]['sum'] == 0 || !array_key_exists($res[$i]['pr_id'], $ids)) { + array_splice($res, $i, 1); + $i--; $n--; + } + } + } + else { + $res = array(); + foreach($arr as &$val) { + $par = $val['group_id']; + if($par === null) { + $root['children'][] = &$val; + $val['group_id'] = '-1'; + } + else + $arr[$par]['children'][] = &$val; + + $res[] = &$val; + } + countNodeSums($root); + for($i = 0; $i < $n; $i++) { + unset($res[$i]['children'], + $res[$i]['buyers'], + $res[$i]['group_id']); + } + array_unshift($res, $root); + } + + print json_encode($res); + } + else + print ERROR; + } + else + print ERROR; + + exit; +} + +function getChildrenIds(&$node, $id, &$res) { + + if($node['pr_id'] === $id) { + $res[$id] = true; + foreach($node['children'] as &$val) + getChildrenIds($val, $val['pr_id'], $res); + } + else { + foreach($node['children'] as &$val) + getChildrenIds($val, $id, $res); + } +} + +function countNodeSums(&$node) { + foreach($node['children'] as &$val) { + countNodeSums($val); + $node['sum'] += $val['sum']; + + foreach($val['buyers'] as $usrId => $checked) + $node['buyers'][$usrId] = true; + $node['buy_num'] += $val['buy_num']; + } + $node['buyers_num'] = count($node['buyers']); +} + + include '../template/header.php'; + include '../template/oft_table.php'; + + headerOut('Статистика покупок товаров', array('prod')); + + if($_SESSION['user']['id']) { + +?> + + + + + + + + + + +
+ + Период:  + + от  +  до  + +
+ + +
+ +
+ + + + \ No newline at end of file From 0a999fe832a820151a195188cb8607f8a665aff6 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 16:11:03 +0300 Subject: [PATCH 09/12] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20ER-=D0=B4=D0=B8=D0=B0=D0=B3=D1=80=D0=B0=D0=BC=D0=BC?= =?UTF-8?q?=D0=B0=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=20=D1=87=D0=B5?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2.=20=D0=9E=D0=BD=D0=B0=20=D0=B1=D1=83=D0=B4?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B2=20=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D0=BE=D0=B1=D1=89=D1=83=D1=8E=20ER-=D0=B4?= =?UTF-8?q?=D0=B8=D0=B0=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлена общая ER-диаграмма базы данных --- doc/db.dia | 2803 ++++++++++++++++++++++++++++++++++++++++++++ doc/receipt_db.dia | 1247 -------------------- 2 files changed, 2803 insertions(+), 1247 deletions(-) create mode 100644 doc/db.dia delete mode 100644 doc/receipt_db.dia diff --git a/doc/db.dia b/doc/db.dia new file mode 100644 index 0000000..f101b8a --- /dev/null +++ b/doc/db.dia @@ -0,0 +1,2803 @@ + + + + + + + + + + + + + #A4# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #pr_purchases (view)# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #item_id# + + + #int# + + + ## + + + + + + + + + + + + + + #date# + + + #datetime# + + + ## + + + + + + + + + + + + + + #buyer_id# + + + #int# + + + ## + + + + + + + + + + + + + + #sum# + + + #int# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #pr_ids# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #prod_id# + + + #int# + + + ## + + + + + + + + + + + + + + #inn# + + + #text# + + + ## + + + + + + + + + + + + + + #name# + + + #text# + + + ## + + + + + + + + + + + + + + #id# + + + #int# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #pr_items_unknown (view)# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #address# + + + #text# + + + ## + + + + + + + + + + + + + + #inn# + + + #text# + + + ## + + + + + + + + + + + + + + #date# + + + #datetime# + + + ## + + + + + + + + + + + + + + #name# + + + #text# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #pr_consumption_clsf# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #id# + + + #int# + + + ## + + + + + + + + + + + + + + #creator# + + + #int# + + + ## + + + + + + + + + + + + + + #name# + + + #text# + + + ## + + + + + + + + + + + + + + #id_hi# + + + #int# + + + ## + + + + + + + + + + + + + + #photo# + + + #text# + + + ## + + + + + + + + + + + + + + #text# + + + #text# + + + ## + + + + + + + + + + + + + + #ed_izm_id# + + + #int# + + + ## + + + + + + + + + + + + + + #in_box# + + + #double# + + + ## + + + + + + + + + + + + + + #date_change# + + + #timestamp# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #∞# + + + #1# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #rcp_receipt# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #buyerAddress# + + + #string# + + + ## + + + + + + + + + + + + + + #totalSum# + + + #integer# + + + ## + + + + + + + + + + + + + + #addressToCheckFiscalSign# + + + #string# + + + ## + + + + + + + + + + + + + + #fiscalDriveNumber# + + + #string# + + + ## + + + + + + + + + + + + + + #rawData# + + + #string# + + + ## + + + + + + + + + + + + + + #kktRegId# + + + #string# + + + ## + + + + + + + + + + + + + + #user# + + + #string# + + + ## + + + + + + + + + + + + + + #operationType# + + + #integer# + + + ## + + + + + + + + + + + + + + #shiftNumber# + + + #integer# + + + ## + + + + + + + + + + + + + + #ecashTotalSum# + + + #integer# + + + ## + + + + + + + + + + + + + + #nds18# + + + #integer# + + + ## + + + + + + + + + + + + + + #retailPlaceAddress# + + + #string# + + + ## + + + + + + + + + + + + + + #userInn# + + + #string# + + + ## + + + + + + + + + + + + + + #taxationType# + + + #integer# + + + ## + + + + + + + + + + + + + + #cashTotalSum# + + + #integer# + + + ## + + + + + + + + + + + + + + #operator# + + + #string# + + + ## + + + + + + + + + + + + + + #senderAddress# + + + #string# + + + ## + + + + + + + + + + + + + + #receiptCode# + + + #integer# + + + ## + + + + + + + + + + + + + + #fiscalSign# + + + #integer# + + + ## + + + + + + + + + + + + + + #nds10# + + + #integer# + + + ## + + + + + + + + + + + + + + #fiscalDocumentNumber# + + + #integer# + + + ## + + + + + + + + + + + + + + #requestNumber# + + + #integer# + + + ## + + + + + + + + + + + + + + #dateTime# + + + #datetime# + + + ## + + + + + + + + + + + + + + #id# + + + #integer# + + + ## + + + + + + + + + + + + + + #user_id# + + + #int# + + + #id пользователя в системе# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #rcp_item# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #name# + + + #string# + + + ## + + + + + + + + + + + + + + #receiptID# + + + #integer# + + + ## + + + + + + + + + + + + + + #sum# + + + #integer# + + + ## + + + + + + + + + + + + + + #nds10# + + + #integer# + + + ## + + + + + + + + + + + + + + #quantity# + + + #integer# + + + ## + + + + + + + + + + + + + + #price# + + + #integer# + + + ## + + + + + + + + + + + + + + #nds18# + + + #integer# + + + ## + + + + + + + + + + + + + + #id# + + + #integer# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #modifier# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #discountName# + + + #string# + + + ## + + + + + + + + + + + + + + #markupName# + + + #string# + + + ## + + + + + + + + + + + + + + #discountSum# + + + #integer# + + + ## + + + + + + + + + + + + + + #itemID# + + + #integer# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #1# + + + #∞# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #1# + + + #∞# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #Ищем(добавляем) запись в pr_ids +согласно связанным rcp_item и + rcp_receipt# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #pr_users# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #id# + + + #int# + + + ## + + + + + + + + + + + + + + #name# + + + #text# + + + ## + + + + + + + + + + + + + + #login# + + + #text# + + + ## + + + + + + + + + + + + + + #password# + + + #text# + + + ## + + + + + + + + + + + + + + #text# + + + #text# + + + ## + + + + + + + + + + + + + + #photo# + + + #text# + + + ## + + + + + + + + + + + + + + #email# + + + #text# + + + ## + + + + + + + + + + + + + + #date_change# + + + #timestamp# + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #∞# + + + #1# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #∞# + + + #1# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #∞# + + + #1# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #1# + + + #∞# + + + + + + + + + + + + + + + + + + + + + + #pr_user# + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/receipt_db.dia b/doc/receipt_db.dia deleted file mode 100644 index 7028cb9..0000000 --- a/doc/receipt_db.dia +++ /dev/null @@ -1,1247 +0,0 @@ - - - - - - - - - - - - - #A4# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #receipt# - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #buyerAddress# - - - #string# - - - ## - - - - - - - - - - - - - - #totalSum# - - - #integer# - - - ## - - - - - - - - - - - - - - #addressToCheckFiscalSign# - - - #string# - - - ## - - - - - - - - - - - - - - #fiscalDriveNumber# - - - #string# - - - ## - - - - - - - - - - - - - - #rawData# - - - #string# - - - ## - - - - - - - - - - - - - - #kktRegId# - - - #string# - - - ## - - - - - - - - - - - - - - #user# - - - #string# - - - ## - - - - - - - - - - - - - - #operationType# - - - #integer# - - - ## - - - - - - - - - - - - - - #shiftNumber# - - - #integer# - - - ## - - - - - - - - - - - - - - #ecashTotalSum# - - - #integer# - - - ## - - - - - - - - - - - - - - #nds18# - - - #integer# - - - ## - - - - - - - - - - - - - - #retailPlaceAddress# - - - #string# - - - ## - - - - - - - - - - - - - - #userInn# - - - #string# - - - ## - - - - - - - - - - - - - - #taxationType# - - - #integer# - - - ## - - - - - - - - - - - - - - #cashTotalSum# - - - #integer# - - - ## - - - - - - - - - - - - - - #operator# - - - #string# - - - ## - - - - - - - - - - - - - - #senderAddress# - - - #string# - - - ## - - - - - - - - - - - - - - #receiptCode# - - - #integer# - - - ## - - - - - - - - - - - - - - #fiscalSign# - - - #integer# - - - ## - - - - - - - - - - - - - - #nds10# - - - #integer# - - - ## - - - - - - - - - - - - - - #fiscalDocumentNumber# - - - #integer# - - - ## - - - - - - - - - - - - - - #requestNumber# - - - #integer# - - - ## - - - - - - - - - - - - - - #dateTime# - - - #datetime# - - - ## - - - - - - - - - - - - - - #id# - - - #integer# - - - ## - - - - - - - - - - - - - - #user_id# - - - #integer# - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #item# - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #sum# - - - #integer# - - - ## - - - - - - - - - - - - - - #nds10# - - - #integer# - - - ## - - - - - - - - - - - - - - #name# - - - #string# - - - ## - - - - - - - - - - - - - - #quantity# - - - #integer# - - - ## - - - - - - - - - - - - - - #price# - - - #integer# - - - ## - - - - - - - - - - - - - - #nds18# - - - #integer# - - - ## - - - - - - - - - - - - - - #receiptID# - - - #integer# - - - ## - - - - - - - - - - - - - - #id# - - - #integer# - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #modifier# - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #discountName# - - - #string# - - - ## - - - - - - - - - - - - - - #markupName# - - - #string# - - - ## - - - - - - - - - - - - - - #discountSum# - - - #integer# - - - ## - - - - - - - - - - - - - - #itemID# - - - #integer# - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #1# - - - #∞# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #1# - - - #∞# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #1# - - - #∞# - - - - - - - - - - - - - - - - - - - - - - #pr_user# - - - - - - - - - - - - - - - - - - - - - - - - From bb9ac49b4e25da6728e45e90ea62f1f9f8ef1cb2 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 16:14:28 +0300 Subject: [PATCH 10/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B8=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D0=91=D0=94?= =?UTF-8?q?=20=D0=B8=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD=D0=B8=D1=8E=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=B0=D0=BB=D0=BE=D0=B3=D0=B0=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\202\321\213\320\262\320\260\320\275\320\270\320\265.txt" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/doc/\321\200\320\260\320\267\320\262\320\265\321\200\321\202\321\213\320\262\320\260\320\275\320\270\320\265.txt" "b/doc/\321\200\320\260\320\267\320\262\320\265\321\200\321\202\321\213\320\262\320\260\320\275\320\270\320\265.txt" index 6f94324..951828a 100755 --- "a/doc/\321\200\320\260\320\267\320\262\320\265\321\200\321\202\321\213\320\262\320\260\320\275\320\270\320\265.txt" +++ "b/doc/\321\200\320\260\320\267\320\262\320\265\321\200\321\202\321\213\320\262\320\260\320\275\320\270\320\265.txt" @@ -1,6 +1,6 @@ -Скрипты для инициализации базы данных находятся в каталоге sql. В MySQL выполнить скрипт создания таблиц init.sql, а затем остальные скрипты для заполнения таблиц базовыми данными. Создать пользователя - прописать логин и пароль в таблице pr_users. +Скрипты для инициализации базы данных находятся в каталоге sql. В MySQL выполнить все скрипты по порядку. Они пронумерованы. Создать пользователя - прописать логин и пароль в таблице pr_users. -Скопировать содержимое каталога pr на HTTP-сервер. Скорректировать файл pr/template/connect.php, указав там логин, пароль, имя БД и ip сервера MySQL. Создать каталог для загружаемых изображений и установить на него правильные права на запись. При необходимости скорректировать файл pr/products/save.php, указав там правильный путь для сохранения загружаемых изображений в переменной photoFileName. +Скопировать содержимое каталога pr на HTTP-сервер. Скорректировать файл pr/template/connect.php, указав там логин, пароль, имя БД и ip сервера MySQL. Создать каталог для загружаемых изображений и установить на него правильные права на запись. При необходимости скорректировать файл pr/products/save.php, указав там правильный путь для сохранения загружаемых изображений в константе UPLOADS_FOLDER_PATH. Название проекта "Ценовичок" - в 6 местах в файле pr/template/header.php From 7f46ce174b83041991033f6c0795e34f37f1e267 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Thu, 18 Jan 2018 16:56:33 +0300 Subject: [PATCH 11/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BF=D1=83=D1=82?= =?UTF-8?q?=D0=B8=20=D0=BA=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/4_products.sql | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sql/4_products.sql b/sql/4_products.sql index 0e3f40d..7f1d100 100644 --- a/sql/4_products.sql +++ b/sql/4_products.sql @@ -27,4 +27,24 @@ select from `rcp_item` `a` join `rcp_receipt` `b` on `a`.`receipt_id` = `b`.`id` join `pr_users` `c` on `b`.`user_id` = `c`.`id` - join `pr_ids` `d` on `b`.`userInn` = `d`.`inn` and `a`.`name` = `d`.`name`; \ No newline at end of file + join `pr_ids` `d` on `b`.`userInn` = `d`.`inn` and `a`.`name` = `d`.`name`; + +DELIMITER $$ +CREATE FUNCTION `pr_get_product_path`(`id` INT(11) UNSIGNED) RETURNS text CHARSET utf8 + READS SQL DATA +BEGIN + DECLARE cur INT DEFAULT NULL; + DECLARE res TEXT DEFAULT ''; + + SELECT `a`.`id_hi` INTO cur FROM `pr_consumption_clsf` `a` + WHERE `a`.`id` = id; + + WHILE cur IS NOT NULL DO + SET res := CONCAT(cur, '/', res); + SELECT `a`.`id_hi` INTO cur FROM `pr_consumption_clsf` `a` + WHERE `a`.`id` = cur; + END WHILE; + + RETURN res; +END$$ +DELIMITER ; \ No newline at end of file From b63c44af3d4518ca4b3193c986cdd3f7bf5e9e90 Mon Sep 17 00:00:00 2001 From: Hrombel Date: Fri, 19 Jan 2018 11:27:11 +0300 Subject: [PATCH 12/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=82=D0=B8=D0=BF=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D0=BF=D0=BE=D0=BB=D1=8F=20fiscalDriveNumber.=20=D0=94?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=B2=20?= =?UTF-8?q?=D0=B8=D0=BD=D0=B4=D0=B5=D0=BA=D1=81=20rcp=5Freceipt=5Fuk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/3_receipt_ddl.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/3_receipt_ddl.sql b/sql/3_receipt_ddl.sql index a2533af..efda18c 100644 --- a/sql/3_receipt_ddl.sql +++ b/sql/3_receipt_ddl.sql @@ -3,7 +3,7 @@ CREATE TABLE `rcp_receipt` ( `buyerAddress` text, `totalSum` int(11) DEFAULT NULL, `addressToCheckFiscalSign` text, - `fiscalDriveNumber` text, + `fiscalDriveNumber` varchar(100), `rawData` text, `kktRegId` text, `user` text, @@ -25,7 +25,7 @@ CREATE TABLE `rcp_receipt` ( `dateTime` DATETIME DEFAULT NULL, `ndsNo` int(11) DEFAULT NULL, `user_id` int(11) NOT NULL, - CONSTRAINT `rcp_receipt_uk` UNIQUE KEY (`dateTime`, `totalSum`, `fiscalDocumentNumber`, `fiscalSign`), + CONSTRAINT `rcp_receipt_uk` UNIQUE KEY (`dateTime`, `totalSum`, `fiscalDocumentNumber`, `fiscalSign`, `fiscalDriveNumber`), CONSTRAINT `rcp_receipt_user_id` FOREIGN KEY (`user_id`) REFERENCES `pr_users` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;