diff --git a/CHANGELOG.md b/CHANGELOG.md index e8ffd0c4f..a86eeafa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ CHANGELOG ========= -### v1.3.5 (2019-06-05) +### v1.4.0 (2019-06-15) +* учет по партиям поставщика +* учет платежей + ### v1.3.4 (2019-05-05) * модуль интеграции с опенкарт diff --git a/db/db.sql b/db/db.sql index 0cbe46409..7b40578b6 100644 --- a/db/db.sql +++ b/db/db.sql @@ -19,7 +19,7 @@ CREATE TABLE `customers` ( `email` varchar(64) DEFAULT NULL, `phone` varchar(64) DEFAULT NULL, PRIMARY KEY (`customer_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `customers_view`; /*!50001 DROP VIEW IF EXISTS `customers_view`*/; @@ -40,8 +40,38 @@ CREATE TABLE `docrel` ( `doc2` int(11) DEFAULT NULL, KEY `doc1` (`doc1`), KEY `doc2` (`doc2`) -) DEFAULT CHARSET=utf8 COMMENT='����� ����� �����������'; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `docstatelog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `docstatelog` ( + `log_id` bigint(20) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `document_id` int(11) NOT NULL, + `docstate` smallint(6) NOT NULL, + `createdon` datetime NOT NULL, + `hostname` varchar(64) NOT NULL, + PRIMARY KEY (`log_id`), + KEY `document_id` (`document_id`) +) AUTO_INCREMENT=98 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `docstatelog_view`; +/*!50001 DROP VIEW IF EXISTS `docstatelog_view`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `docstatelog_view` AS SELECT + 1 AS `log_id`, + 1 AS `user_id`, + 1 AS `document_id`, + 1 AS `docstate`, + 1 AS `createdon`, + 1 AS `hostname`, + 1 AS `username`, + 1 AS `document_number`, + 1 AS `meta_desc`, + 1 AS `meta_name`*/; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `documents`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -54,14 +84,14 @@ CREATE TABLE `documents` ( `amount` int(11) DEFAULT NULL, `meta_id` int(11) NOT NULL, `state` tinyint(4) NOT NULL, - `datatag` int(11) DEFAULT NULL, `notes` varchar(255) NOT NULL, `customer_id` int(11) DEFAULT '0', + `payamount` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`document_id`), KEY `document_date` (`document_date`), KEY `customer_id` (`customer_id`), KEY `user_id` (`user_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `documents_view`; /*!50001 DROP VIEW IF EXISTS `documents_view`*/; @@ -80,7 +110,7 @@ SET character_set_client = utf8; 1 AS `customer_name`, 1 AS `state`, 1 AS `notes`, - 1 AS `datatag`, + 1 AS `payamount`, 1 AS `meta_name`, 1 AS `meta_desc`*/; SET character_set_client = @saved_cs_client; @@ -93,7 +123,7 @@ CREATE TABLE `employees` ( `detail` mediumtext, `emp_name` varchar(64) NOT NULL, PRIMARY KEY (`employee_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `entrylist`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -111,7 +141,7 @@ CREATE TABLE `entrylist` ( PRIMARY KEY (`entry_id`), KEY `document_id` (`document_id`), KEY `stock_id` (`stock_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=42 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -122,7 +152,7 @@ CREATE TABLE `entrylist` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50003 TRIGGER `entrylist_after_ins_tr` AFTER INSERT ON `entrylist` +/*!50003 CREATE*/ /*!50017 */ /*!50003 TRIGGER `entrylist_after_ins_tr` AFTER INSERT ON `entrylist` FOR EACH ROW BEGIN @@ -147,7 +177,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50003 TRIGGER `entrylist_after_del_tr` AFTER DELETE ON `entrylist` +/*!50003 CREATE*/ /*!50017 */ /*!50003 TRIGGER `entrylist_after_del_tr` AFTER DELETE ON `entrylist` FOR EACH ROW BEGIN @@ -188,7 +218,7 @@ CREATE TABLE `equipments` ( `detail` mediumtext, `description` text, PRIMARY KEY (`eq_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `eventlist`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -204,7 +234,7 @@ CREATE TABLE `eventlist` ( PRIMARY KEY (`event_id`), KEY `user_id` (`user_id`), KEY `customer_id` (`customer_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `eventlist_view`; /*!50001 DROP VIEW IF EXISTS `eventlist_view`*/; @@ -250,7 +280,7 @@ CREATE TABLE `images` ( `mime` varchar(16) DEFAULT NULL, `thumb` longblob, PRIMARY KEY (`image_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=15 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `item_cat`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -259,7 +289,7 @@ CREATE TABLE `item_cat` ( `cat_id` int(11) NOT NULL AUTO_INCREMENT, `cat_name` varchar(255) NOT NULL, PRIMARY KEY (`cat_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `item_set`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -270,7 +300,7 @@ CREATE TABLE `item_set` ( `pitem_id` int(11) DEFAULT '0', `qty` int(11) DEFAULT '0', PRIMARY KEY (`set_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `item_set_view`; /*!50001 DROP VIEW IF EXISTS `item_set_view`*/; @@ -302,7 +332,7 @@ CREATE TABLE `items` ( KEY `item_code` (`item_code`), KEY `itemname` (`itemname`), KEY `cat_id` (`cat_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `items_view`; /*!50001 DROP VIEW IF EXISTS `items_view`*/; @@ -333,7 +363,7 @@ CREATE TABLE `messages` ( `item_id` int(11) NOT NULL, `item_type` int(11) DEFAULT NULL, PRIMARY KEY (`message_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `messages_view`; /*!50001 DROP VIEW IF EXISTS `messages_view`*/; @@ -356,12 +386,22 @@ CREATE TABLE `metadata` ( `meta_type` tinyint(11) NOT NULL, `description` varchar(255) DEFAULT NULL, `meta_name` varchar(255) NOT NULL, - `menugroup` varchar(255) DEFAULT NULL COMMENT '??????????? ??? ???????', + `menugroup` varchar(255) DEFAULT NULL, `notes` text NOT NULL, `disabled` tinyint(4) NOT NULL, `smartmenu` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`meta_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=53 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `mfund`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mfund` ( + `mf_id` int(11) NOT NULL AUTO_INCREMENT, + `mf_name` varchar(255) NOT NULL, + `description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`mf_id`) +) AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `notifies`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -374,7 +414,7 @@ CREATE TABLE `notifies` ( `message` text NOT NULL, PRIMARY KEY (`notify_id`), KEY `user_id` (`user_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `options`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -392,8 +432,39 @@ CREATE TABLE `parealist` ( `pa_id` int(11) NOT NULL AUTO_INCREMENT, `pa_name` varchar(255) NOT NULL, PRIMARY KEY (`pa_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `paylist`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `paylist` ( + `pl_id` int(11) NOT NULL AUTO_INCREMENT, + `document_id` int(11) NOT NULL, + `amount` int(11) NOT NULL, + `mf_id` int(11) NOT NULL, + `notes` varchar(255) DEFAULT NULL, + `paydate` date DEFAULT NULL, + `user_id` int(11) NOT NULL, + PRIMARY KEY (`pl_id`), + KEY `document_id` (`document_id`) +) AUTO_INCREMENT=49 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `paylist_view`; +/*!50001 DROP VIEW IF EXISTS `paylist_view`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `paylist_view` AS SELECT + 1 AS `pl_id`, + 1 AS `document_id`, + 1 AS `amount`, + 1 AS `mf_id`, + 1 AS `notes`, + 1 AS `user_id`, + 1 AS `paydate`, + 1 AS `document_number`, + 1 AS `username`, + 1 AS `mf_name`*/; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `services`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -402,7 +473,7 @@ CREATE TABLE `services` ( `service_name` varchar(255) NOT NULL, `detail` text, PRIMARY KEY (`service_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_attributes`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -415,7 +486,7 @@ CREATE TABLE `shop_attributes` ( `valueslist` varchar(255) DEFAULT NULL, `showinlist` tinyint(1) DEFAULT NULL, PRIMARY KEY (`attribute_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_attributes_order`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -426,7 +497,7 @@ CREATE TABLE `shop_attributes_order` ( `pg_id` int(11) NOT NULL, `ordern` int(11) NOT NULL, PRIMARY KEY (`order_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_attributes_view`; /*!50001 DROP VIEW IF EXISTS `shop_attributes_view`*/; @@ -451,7 +522,7 @@ CREATE TABLE `shop_attributevalues` ( `attributevalue` varchar(255) NOT NULL, PRIMARY KEY (`attributevalue_id`), KEY `attribute_id` (`attribute_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_manufacturers`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -461,7 +532,7 @@ CREATE TABLE `shop_manufacturers` ( `manufacturername` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, PRIMARY KEY (`manufacturer_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_prod_comments`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -476,7 +547,7 @@ CREATE TABLE `shop_prod_comments` ( `moderated` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`comment_id`), KEY `product_id` (`product_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_productgroups`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -488,7 +559,7 @@ CREATE TABLE `shop_productgroups` ( `mpath` varchar(1024) DEFAULT NULL, `image_id` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`group_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_productgroups_view`; /*!50001 DROP VIEW IF EXISTS `shop_productgroups_view`*/; @@ -522,7 +593,7 @@ CREATE TABLE `shop_products` ( `comments` int(11) DEFAULT '0', PRIMARY KEY (`product_id`), KEY `group_id` (`group_id`) -) DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `shop_products_view`; /*!50001 DROP VIEW IF EXISTS `shop_products_view`*/; @@ -556,9 +627,11 @@ CREATE TABLE `store_stock` ( `partion` int(11) DEFAULT NULL, `store_id` int(11) NOT NULL, `qty` decimal(11,3) DEFAULT '0.000', + `snumber` varchar(64) DEFAULT NULL, + `sdate` date DEFAULT NULL, PRIMARY KEY (`stock_id`), KEY `item_id` (`item_id`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=57 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `store_stock_view`; /*!50001 DROP VIEW IF EXISTS `store_stock_view`*/; @@ -578,6 +651,8 @@ SET character_set_client = utf8; 1 AS `disabled`, 1 AS `storename`, 1 AS `qty`, + 1 AS `snumber`, + 1 AS `sdate`, 1 AS `rqty`, 1 AS `wqty`*/; SET character_set_client = @saved_cs_client; @@ -589,7 +664,7 @@ CREATE TABLE `stores` ( `storename` varchar(64) DEFAULT NULL, `description` varchar(255) DEFAULT NULL, PRIMARY KEY (`store_id`) -) DEFAULT CHARSET=utf8 COMMENT='????? ????????'; +) AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `users`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -606,7 +681,7 @@ CREATE TABLE `users` ( `options` text, PRIMARY KEY (`user_id`), UNIQUE KEY `userlogin` (`userlogin`) -) DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `users_view`; /*!50001 DROP VIEW IF EXISTS `users_view`*/; @@ -636,6 +711,19 @@ SET character_set_client = @saved_cs_client; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +/*!50001 DROP VIEW IF EXISTS `docstatelog_view`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = latin1 */; +/*!50001 SET character_set_results = latin1 */; +/*!50001 SET collation_connection = latin1_swedish_ci */; +/*!50001 CREATE */ +/*!50013 */ +/*!50001 VIEW `docstatelog_view` AS select `dl`.`log_id` AS `log_id`,`dl`.`user_id` AS `user_id`,`dl`.`document_id` AS `document_id`,`dl`.`docstate` AS `docstate`,`dl`.`createdon` AS `createdon`,`dl`.`hostname` AS `hostname`,`u`.`username` AS `username`,`d`.`document_number` AS `document_number`,`d`.`meta_desc` AS `meta_desc`,`d`.`meta_name` AS `meta_name` from ((`docstatelog` `dl` join `users_view` `u` on((`dl`.`user_id` = `u`.`user_id`))) join `documents_view` `d` on((`d`.`document_id` = `dl`.`document_id`))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 DROP VIEW IF EXISTS `documents_view`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -645,7 +733,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE */ /*!50013 */ -/*!50001 VIEW `documents_view` AS select `d`.`document_id` AS `document_id`,`d`.`document_number` AS `document_number`,`d`.`document_date` AS `document_date`,`d`.`user_id` AS `user_id`,`d`.`content` AS `content`,`d`.`amount` AS `amount`,`d`.`meta_id` AS `meta_id`,`u`.`username` AS `username`,`c`.`customer_id` AS `customer_id`,`c`.`customer_name` AS `customer_name`,`d`.`state` AS `state`,`d`.`notes` AS `notes`,`d`.`datatag` AS `datatag`,`metadata`.`meta_name` AS `meta_name`,`metadata`.`description` AS `meta_desc` from (((`documents` `d` join `users_view` `u` on((`d`.`user_id` = `u`.`user_id`))) left join `customers` `c` on((`d`.`customer_id` = `c`.`customer_id`))) join `metadata` on((`metadata`.`meta_id` = `d`.`meta_id`))) */; +/*!50001 VIEW `documents_view` AS select `d`.`document_id` AS `document_id`,`d`.`document_number` AS `document_number`,`d`.`document_date` AS `document_date`,`d`.`user_id` AS `user_id`,`d`.`content` AS `content`,`d`.`amount` AS `amount`,`d`.`meta_id` AS `meta_id`,`u`.`username` AS `username`,`c`.`customer_id` AS `customer_id`,`c`.`customer_name` AS `customer_name`,`d`.`state` AS `state`,`d`.`notes` AS `notes`,`d`.`payamount` AS `payamount`,`metadata`.`meta_name` AS `meta_name`,`metadata`.`description` AS `meta_desc` from (((`documents` `d` join `users_view` `u` on((`d`.`user_id` = `u`.`user_id`))) left join `customers` `c` on((`d`.`customer_id` = `c`.`customer_id`))) join `metadata` on((`metadata`.`meta_id` = `d`.`meta_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -714,6 +802,19 @@ SET character_set_client = @saved_cs_client; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +/*!50001 DROP VIEW IF EXISTS `paylist_view`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = latin1 */; +/*!50001 SET character_set_results = latin1 */; +/*!50001 SET collation_connection = latin1_swedish_ci */; +/*!50001 CREATE */ +/*!50013 */ +/*!50001 VIEW `paylist_view` AS select `pl`.`pl_id` AS `pl_id`,`pl`.`document_id` AS `document_id`,`pl`.`amount` AS `amount`,`pl`.`mf_id` AS `mf_id`,`pl`.`notes` AS `notes`,`pl`.`user_id` AS `user_id`,`pl`.`paydate` AS `paydate`,`d`.`document_number` AS `document_number`,`u`.`username` AS `username`,`m`.`mf_name` AS `mf_name` from (((`paylist` `pl` join `documents_view` `d` on((`pl`.`document_id` = `d`.`document_id`))) join `users_view` `u` on((`pl`.`user_id` = `u`.`user_id`))) join `mfund` `m` on((`pl`.`mf_id` = `m`.`mf_id`))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 DROP VIEW IF EXISTS `shop_attributes_view`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -762,7 +863,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE */ /*!50013 */ -/*!50001 VIEW `store_stock_view` AS select `st`.`stock_id` AS `stock_id`,`st`.`item_id` AS `item_id`,`st`.`partion` AS `partion`,`st`.`store_id` AS `store_id`,`i`.`itemname` AS `itemname`,`i`.`item_code` AS `item_code`,`i`.`cat_id` AS `cat_id`,`i`.`msr` AS `msr`,`i`.`bar_code` AS `bar_code`,`i`.`cat_name` AS `cat_name`,`i`.`disabled` AS `disabled`,`stores`.`storename` AS `storename`,`st`.`qty` AS `qty`,(0 - (select coalesce(sum(`el`.`quantity`),0) from `entrylist_view` `el` where ((`el`.`stock_id` = `st`.`stock_id`) and (`el`.`quantity` < 0) and (`el`.`document_date` > cast(now() as date))))) AS `rqty`,(select coalesce(sum(`el`.`quantity`),0) from `entrylist_view` `el` where ((`el`.`stock_id` = `st`.`stock_id`) and (`el`.`quantity` > 0) and (`el`.`document_date` > cast(now() as date)))) AS `wqty` from ((`store_stock` `st` join `items_view` `i` on(((`i`.`item_id` = `st`.`item_id`) and (`i`.`disabled` <> 1)))) join `stores` on((`stores`.`store_id` = `st`.`store_id`))) */; +/*!50001 VIEW `store_stock_view` AS select `st`.`stock_id` AS `stock_id`,`st`.`item_id` AS `item_id`,`st`.`partion` AS `partion`,`st`.`store_id` AS `store_id`,`i`.`itemname` AS `itemname`,`i`.`item_code` AS `item_code`,`i`.`cat_id` AS `cat_id`,`i`.`msr` AS `msr`,`i`.`bar_code` AS `bar_code`,`i`.`cat_name` AS `cat_name`,`i`.`disabled` AS `disabled`,`stores`.`storename` AS `storename`,`st`.`qty` AS `qty`,`st`.`snumber` AS `snumber`,`st`.`sdate` AS `sdate`,(0 - (select coalesce(sum(`el`.`quantity`),0) from `entrylist_view` `el` where ((`el`.`stock_id` = `st`.`stock_id`) and (`el`.`quantity` < 0) and (`el`.`document_date` > cast(now() as date))))) AS `rqty`,(select coalesce(sum(`el`.`quantity`),0) from `entrylist_view` `el` where ((`el`.`stock_id` = `st`.`stock_id`) and (`el`.`quantity` > 0) and (`el`.`document_date` > cast(now() as date)))) AS `wqty` from ((`store_stock` `st` join `items_view` `i` on(((`i`.`item_id` = `st`.`item_id`) and (`i`.`disabled` <> 1)))) join `stores` on((`stores`.`store_id` = `st`.`store_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; diff --git a/db/initdata.sql b/db/initdata.sql index f70d4a1fa..76900b516 100644 --- a/db/initdata.sql +++ b/db/initdata.sql @@ -7,9 +7,10 @@ INSERT INTO `users` ( `userlogin`, `userpass`, `createdon`, `email`, `acl`, `sma INSERT INTO `stores` ( `storename`, `description`) VALUES( 'Основной склад', ''); +INSERT INTO `mfund` (`mf_id`, `mf_name`, `description`) VALUES(2, 'Касса', 'Основная касса'); -INSERT INTO `options` (`optname`, `optvalue`) VALUES('common', 'a:13:{s:8:"firmname";s:20:"Наша фирма";s:8:"defstore";s:2:"19";s:9:"qtydigits";s:1:"2";s:5:"cdoll";s:1:"2";s:5:"ceuro";s:1:"5";s:4:"crub";s:3:"0.4";s:6:"price1";s:18:"Розничная";s:6:"price2";s:14:"Оптовая";s:6:"price3";s:0:"";s:6:"price4";s:0:"";s:6:"price5";s:0:"";s:6:"useset";b:0;s:6:"useval";b:0;}'); +INSERT INTO `options` (`optname`, `optvalue`) VALUES('common', 'a:14:{s:8:"firmname";s:20:"Наша фирма";s:8:"defstore";s:2:"19";s:9:"qtydigits";s:1:"0";s:5:"cdoll";s:1:"2";s:5:"ceuro";s:1:"5";s:4:"crub";s:3:"0.4";s:6:"price1";s:18:"Розничная";s:6:"price2";s:14:"Оптовая";s:6:"price3";s:0:"";s:6:"price4";s:0:"";s:6:"price5";s:0:"";s:6:"useset";b:0;s:10:"usesnumber";b:0;s:6:"useval";b:0;}'); INSERT INTO `options` (`optname`, `optvalue`) VALUES('shop', 'N;'); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(1, 4, 'Склады', 'StoreList', 'Товары', '', 0, 0); @@ -30,12 +31,10 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(16, 1, 'Возврат от покупателя', 'ReturnIssue', 'Продажи', '', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(18, 3, 'Работы, наряды', 'TaskList', '', '', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(19, 1, 'Наряд', 'Task', 'Производство', 'Наряд на выполнение работы, задачи', 0, 0); -INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(20, 2, 'Оплата по нарядам', 'EmpTask', '', '', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(20, 2, 'Оплата по нарядам', 'EmpTask', 'Платежи', '', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(21, 2, 'Закупки', 'Income', '', '', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(22, 2, 'Продажи', 'Outcome', '', '', 0, 0); -INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(23, 5, 'Бренды', 'Manufacturers', '', '', 0, 0); -INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(24, 5, 'Группы товаров', 'GroupList', '', '', 0, 0); -INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(26, 5, 'Товары', 'ProductList', '', '', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(46, 4, 'Денежные счета', 'MFList', '', 'кассы и банковские счета', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(27, 3, 'Заказы клиентов', 'OrderList', '', '', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(28, 1, 'Заказ', 'Order', 'Продажи', '', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(30, 1, 'Оприходование с производства', 'ProdReceipt', 'Производство', 'Оприходование готовой продукции и полуфабрикатов с производства на склад. ', 0, 0); @@ -52,3 +51,9 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(43, 1, 'Заказ (услуги)', 'ServiceOrder', 'Продажи', '', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(44, 1, 'Перекомплектация ТМЦ', 'TransItem', 'Склад', 'Документ преобразовывает ТМЦ с одной формы упаковки в другую. Например с бочек в литры или ящиков в пачки', 0, 0); INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(45, 3, 'Производство', 'ProdList', '', '', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(47, 3, 'Журнал платежей', 'PayList', '', '', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(48, 2, 'Движение по денежным счетам', 'PayActivity', 'Платежи', '', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(49, 1, 'Перевод денежных средств', 'MoveMoney', 'Платежи', ' ', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(50, 1, 'Приходный ордер', 'IncomeMoney', 'Платежи', '', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(51, 1, 'Расходный ордер', 'OutcomeMoney', 'Платежи', '', 0, 0); +INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `notes`, `disabled`, `smartmenu`) VALUES(52, 3, 'Расчеты с контрагентами', 'PayCustList', '', '', 0, 0); diff --git a/www/app/acl.php b/www/app/acl.php index bc8056b3b..10a401bb3 100644 --- a/www/app/acl.php +++ b/www/app/acl.php @@ -101,8 +101,6 @@ public static function checkShowReg($reg) { return false; } - - //проверка на доступ к документу public static function checkShowDoc($doc, $inreg = false) { $user = System::getUser(); diff --git a/www/app/application.php b/www/app/application.php index 2bd48faf4..4626550f8 100644 --- a/www/app/application.php +++ b/www/app/application.php @@ -101,15 +101,15 @@ public function Route($uri) { $arr = explode('/', $uri); $pages = array( - "shop" => "\\App\\Shop\\Pages\\Main", + "shop" => "\\App\\Modules\\Shop\\Pages\\Main", "store" => "\\App\\Pages\\Main", - "sp" => "\\App\\Shop\\Pages\\ProductView", - "aboutus" => "\\App\\Shop\\Pages\\AboutUs", - "delivery" => "\\App\\Shop\\Pages\\Delivery", - "contact" => "\\App\\Shop\\Pages\\Contact", + "sp" => "\\App\\Modules\\Shop\\Pages\\ProductView", + "aboutus" => "\\App\\Modules\\Shop\\Pages\\AboutUs", + "delivery" => "\\App\\Modules\\Shop\\Pages\\Delivery", + "contact" => "\\App\\Modules\\Shop\\Pages\\Contact", "simage" => "\\App\\Pages\\LoadImage", - "scat" => "\\App\\Shop\\Pages\\Main", - "pcat" => "\\App\\Shop\\Pages\\Catalog" + "scat" => "\\App\\Modules\\Shop\\Pages\\Main", + "pcat" => "\\App\\Modules\\Shop\\Pages\\Catalog" ); if (strlen($pages[$arr[0]]) > 0) { @@ -128,6 +128,4 @@ public function Route($uri) { } } - - } diff --git a/www/app/dataitem.php b/www/app/dataitem.php index 537ca9392..41bd7be6e 100644 --- a/www/app/dataitem.php +++ b/www/app/dataitem.php @@ -27,4 +27,20 @@ public function getID() { return $this->id; } + /** + * возвращает список DataItem заполненый с запроса + * + * @param mixed $sql + */ + public static function query($sql){ + $conn = \ZDB\DB::getConnect(); + $list = array(); + + $rc = $conn->Execute($sql); + foreach($rc as $row){ + $list[] = new DataItem($row); + } + return $list; + } + } diff --git a/www/app/entity/category.php b/www/app/entity/category.php index e48e21cfe..5b0f900c4 100644 --- a/www/app/entity/category.php +++ b/www/app/entity/category.php @@ -3,7 +3,7 @@ namespace App\Entity; /** - * Клас-сущность категория товара + * Класс-сущность категория товара * * @table=item_cat * @keyfield=cat_id @@ -14,4 +14,12 @@ protected function init() { $this->cat_id = 0; } + protected function beforeDelete() { + + $conn = \ZDB\DB::getConnect(); + $sql = " select count(*) from items where cat_id = {$this->cat_id}"; + $cnt = $conn->GetOne($sql); + return ($cnt > 0) ? "Категория используется в товарах" : ""; + } + } diff --git a/www/app/entity/customer.php b/www/app/entity/customer.php index 8c4fcb4ed..58b9aabb0 100644 --- a/www/app/entity/customer.php +++ b/www/app/entity/customer.php @@ -48,13 +48,12 @@ public function beforeDelete() { $sql = " select count(*) from entrylist where customer_id = {$this->customer_id}"; $cnt = $conn->GetOne($sql); if ($cnt > 0) - return false; + return "На контрагента есть ссылки в документах"; $sql = " select count(*) from documents where customer_id = {$this->customer_id} "; $cnt = $conn->GetOne($sql); if ($cnt > 0) - return false; - return true; - ; + return "На контрагента есть ссылки в документах"; + return ""; } /** diff --git a/www/app/entity/doc/document.php b/www/app/entity/doc/document.php index c5e28c1c1..69a29b35f 100644 --- a/www/app/entity/doc/document.php +++ b/www/app/entity/doc/document.php @@ -2,8 +2,8 @@ namespace App\Entity\Doc; -use App\System; -use App\Helper; +use \App\System; +use \App\Helper; /** * Класс-сущность документ @@ -15,20 +15,18 @@ class Document extends \ZCL\DB\Entity { const STATE_NEW = 1; //Новый const STATE_EDITED = 2; //Отредактирован const STATE_CANCELED = 3; //Отменен - const STATE_EXECUTED = 5; // Проведен, выполнен + const STATE_EXECUTED = 5; // Проведен const STATE_APPROVED = 4; // Утвержден const STATE_DELETED = 6; // Удален const STATE_INPROCESS = 7; // в работе const STATE_WA = 8; // ждет подтверждения const STATE_CLOSED = 9; // Закрыт , доставлен, выполнен - const STATE_WP = 10; // Ждет оплату const STATE_INSHIPMENT = 11; // Отгружен - const STATE_PAYED = 12; // оплачен - const STATE_PART_PAYED = 13; // частично оплачен const STATE_DELIVERED = 14; // доставлен const STATE_REFUSED = 15; // отклонен const STATE_SHIFTED = 16; // отложен const STATE_FAIL = 17; // Аннулирован + const STATE_DONE = 18; // Закончен // типы экспорта const EX_WORD = 1; // Word const EX_EXCEL = 2; // Excel @@ -51,17 +49,14 @@ class Document extends \ZCL\DB\Entity { public $detaildata = array(); /** - * массив статусов + * начальная инициализация. Вызывается автоматически в конструкторе Entity * - * @var mixed */ - private $logdata = array(); - protected function init() { $this->document_id = 0; $this->state = 0; $this->customer_id = 0; - $this->datatag = 0; + $this->document_number = ''; $this->notes = ''; @@ -70,11 +65,15 @@ protected function init() { $this->basedoc = ''; $this->headerdata = array(); - $this->headerdata['incredit'] = 0; //оплата в долг - $this->headerdata['inshipment'] = 0; //товары в пути + $this->detaildata = array(); + $this->headerdata['planned'] = 0; //запланированный } + /** + * возвращает метаданные чтобы работало в дочерних классах + * + */ protected static function getMetadata() { return array('table' => 'documents', 'view' => 'documents_view', 'keyfield' => 'document_id'); } @@ -149,19 +148,7 @@ private function packData() { $this->content .= ""; } - $this->content .= " "; - $this->content .= " "; - foreach ($this->logdata as $state) { - $this->content .= ""; - $this->content .= "{$state->state}"; - $this->content .= "{$state->user}"; - $this->content .= "username}]]>"; - $this->content .= "{$state->hostname}"; - $this->content .= "{$state->updatedon}"; - - $this->content .= ""; - } - $this->content .= ""; + $this->content .= " "; } /** @@ -193,20 +180,6 @@ private function unpackData() { } $this->detaildata[] = $_row; } - $this->logdata = array(); - $result = $xml->xpath('//states'); - - if ((bool) (count($result))) { - foreach ($xml->states->children() as $row) { - $state = new \App\DataItem(); - $state->state = (int) $row->stateno; - $state->hostname = (string) $row->statehost; - $state->user = (int) $row->stateuser; - $state->username = (string) $row->stateusername; - $state->updatedon = (int) $row->statedt; - $this->logdata[] = $state; - } - } } /** @@ -222,11 +195,7 @@ public function generateReport() { * */ public function Execute() { - - if (trim(get_class($this), "\\") == 'App\Entity\Doc\Document') { - //если екземпляр базового типа Document приводим к дочернему типу - $this->cast()->Execute(); - } + } /** @@ -236,15 +205,28 @@ public function Execute() { protected function Cancel() { $conn = \ZDB\DB::getConnect(); $conn->StartTrans(); - // если метод не переопределен в наследнике удаляем документ со всех движений - $conn->Execute("delete from entrylist where document_id =" . $this->document_id); - //удаляем освободившиеся стоки - $conn->Execute("delete from store_stock where stock_id not in (select stock_id from entrylist) "); - - $conn->CompleteTrans(); + try { + // если метод не переопределен в наследнике удаляем документ со всех движений + $conn->Execute("delete from entrylist where document_id =" . $this->document_id); + //удаляем освободившиеся стоки + $conn->Execute("delete from store_stock where stock_id not in (select stock_id from entrylist) "); + + //удаляем оплату + if ($this->headerdata['payment'] > 0) { + $conn->Execute("delete from paylist where document_id =" . $this->document_id); + $this->payamount = 0; + } + $conn->CompleteTrans(); + } catch (\Exception $ee) { + global $logger; + $conn->RollbackTrans(); + \App\System::setErrorMsg($ee->getMessage()); + $logger->error($ee->getMessage() . " Документ " . $this->_doc->meta_desc); + return false; + } return true; } @@ -281,13 +263,6 @@ public function cast() { return $doc; } - protected function beforeDelete() { - - - - return true; - } - protected function afterSave($update) { // if ($update == false) { //новый документ @@ -354,6 +329,7 @@ public function updateStatus($state) { $this->state = $state; $this->insertLog($state); + $this->save(); // $conn = \ZDB\DB::getConnect(); @@ -388,16 +364,13 @@ public static function getStateName($state) { return "Утвержден"; case Document::STATE_DELETED: return "Удален"; - case Document::STATE_WP: - return "Ожидает оплату"; + case Document::STATE_WA: return "Ожидает утверждения"; case Document::STATE_INSHIPMENT: return "В доставке"; - case Document::STATE_PAYED: - return "Оплачен"; - case Document::STATE_PART_PAYED: - return "Частично оплачен"; + case Document::STATE_DONE: + return "Выполнен"; case Document::STATE_DELIVERED: return "Доставлен"; case Document::STATE_REFUSED: @@ -415,7 +388,8 @@ public static function getStateName($state) { /** * Возвращает следующий номер при автонумерации - * + * + * @return mixed */ public function nextNumber() { @@ -423,8 +397,13 @@ public function nextNumber() { $class = explode("\\", get_called_class()); $metaname = $class[count($class) - 1]; $doc = Document::getFirst("meta_name='" . $metaname . "'", "document_id desc"); - if ($doc == null) - return ''; + if ($doc == null) { + // $doc = Document::getFirst("", "document_id desc"); + // $id=$doc->document_id ; + return "D" . substr('' . time(), 2); + } + + $prevnumber = $doc->document_number; if (strlen($prevnumber) == 0) return ''; @@ -502,33 +481,49 @@ public static function search($type, $from, $to, $header = array()) { } /** - * может быть удален + * @see \ZDB\Entity * */ - public function canDeleted() { + protected function beforeDelete() { + $conn = \ZDB\DB::getConnect(); $cnt = $conn->GetOne("select count(*) from entrylist where document_id = {$this->document_id} "); if ($cnt > 0) { - System::setErrorMsg("У докуинта есть записи в аналитике"); - return false; + + return "У документа есть записи в аналитике"; + } + $cnt = $conn->GetOne("select count(*) from paylist where document_id = {$this->document_id} "); + if ($cnt > 0) { + + return "У документа есть оплаты"; } $cnt = $conn->GetOne("select count(*) from docrel where doc1 = {$this->document_id} or doc2 = {$this->document_id}"); if ($cnt > 0) { - System::setErrorMsg("Есть связаные документы"); - return false; - } + return "Есть связаные документы, удалите связи"; + } - $f = $this->checkStates(array(Document::STATE_PAYED, Document::STATE_PART_PAYED, Document::STATE_INSHIPMENT, Document::STATE_DELIVERED)); + $f = $this->checkStates(array(Document::STATE_INSHIPMENT, Document::STATE_DELIVERED)); if ($f) { - System::setErrorMsg("У документа были оплаты или доставки"); - return false; + + return "У документа были отправки или доставки"; } - return true; + return ""; + } + + /** + * @see \ZDB\Entity + * + */ + protected function afterDelete() { + + $conn = \ZDB\DB::getConnect(); + $conn->Execute("delete from docstatelog where document_id=" . $this->document_id); + $conn->Execute("delete from paylist where document_id=" . $this->document_id); } /** @@ -536,53 +531,26 @@ public function canDeleted() { * */ public function canCanceled() { - $f = $this->checkStates(array(Document::STATE_CLOSED, Document::STATE_PART_PAYED, Document::STATE_PART_PAYED, Document::STATE_INSHIPMENT, Document::STATE_DELIVERED)); + $f = $this->checkStates(array(Document::STATE_CLOSED, Document::STATE_INSHIPMENT, Document::STATE_DELIVERED)); if ($f) { - System::setWarnMsg("У документа были оплаты или доставки"); + System::setWarnMsg("У документа были отправки или доставки"); return true; } return true; } - //добавляет оплату - public function addPayment($user, $amount, $comment = '') { - $list = $this->getPayments(); - $item = new \App\DataItem(); - $item->user = $user; - $item->amount = $amount; - $item->comment = $comment; - $item->date = time(); - $list[] = $item; - - $this->headerdata['pays'] = base64_encode(serialize($list)); - } - - //возвращает список оплат - public function getPayments() { - if (strlen($this->headerdata['pays']) > 0) { - return @unserialize(base64_decode($this->headerdata['pays'])); - } - - return array(); - } - /** * * запись состояния в лог документа * @param mixed $state */ public function insertLog($state) { - - $host = Document::qstr($_SERVER["REMOTE_ADDR"]); + $conn = \ZDB\DB::getConnect(); + $host = $conn->qstr($_SERVER["REMOTE_ADDR"]); $user = \App\System::getUser(); - $item = new \App\DataItem(); - $item->state = $state; - $item->hostname = $host; - $item->user = $user->user_id; - $item->username = $user->username; - $item->updatedon = time(); - $this->logdata[] = $item; + $sql = "insert into docstatelog (document_id,user_id,createdon,docstate,hostname) values({$this->document_id},{$user->user_id},now(),{$state},{$host})"; + $conn->Execute($sql); } /** @@ -590,10 +558,15 @@ public function insertLog($state) { * */ public function getLogList() { + $conn = \ZDB\DB::getConnect(); + $rc = $conn->Execute("select * from docstatelog_view where document_id={$this->document_id} order by log_id"); + $states = array(); + foreach ($rc as $row) { + $row['createdon'] = strtotime($row['createdon']); + $states[] = new \App\DataItem($row); + } - - - return $this->logdata; + return $states; } /** @@ -602,17 +575,13 @@ public function getLogList() { * @param mixed $states */ public function checkStates(array $states) { + if (count($states) == 0) + return false; + $conn = \ZDB\DB::getConnect(); + $states = implode(',', $states); - - - foreach ($this->logdata as $srow) { - foreach ($states as $state) { - if ($srow->state == $state) - return true; - } - } - - return false; + $cnt = $conn->getOne("select count(*) from docstatelog where docstate in({$states}) and document_id={$this->document_id}"); + return $cnt > 0; } } diff --git a/www/app/entity/doc/goodsissue.php b/www/app/entity/doc/goodsissue.php index 05bce1742..c95414b2a 100644 --- a/www/app/entity/doc/goodsissue.php +++ b/www/app/entity/doc/goodsissue.php @@ -2,9 +2,9 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; -use App\Util; +use \App\Entity\Entry; +use \App\Helper as H; +use \App\Util; /** * Класс-сущность документ расходная накладая @@ -23,8 +23,14 @@ public function generateReport() { if (isset($detail[$value['item_id']])) { $detail[$value['item_id']]['quantity'] += $value['quantity']; } else { + $name = $value['itemname']; + if (strlen($value['snumber']) > 0) { + $name .= ' (' . $value['snumber'] . ',' . date('d.m.Y', $value['sdate']) . ')'; + } + + $detail[] = array("no" => $i++, - "tovar_name" => $value['itemname'], + "tovar_name" => $name, "tovar_code" => $value['item_code'], "quantity" => H::fqty($value['quantity']), "msr" => $value['msr'], @@ -65,7 +71,7 @@ public function generateReport() { public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); + foreach ($this->detaildata as $row) { @@ -76,8 +82,11 @@ public function Execute() { $sc->setCustomer($this->customer_id); $sc->save(); } + if ($this->headerdata['payment'] > 0) { + \App\Entity\Pay::addPayment($this->document_id, $this->amount, $this->headerdata['payment'], $this->headerdata['paynotes']); + $this->payamount = $this->amount; + } - $conn->CompleteTrans(); return true; } diff --git a/www/app/entity/doc/goodsreceipt.php b/www/app/entity/doc/goodsreceipt.php index 1b5ae52ce..2ac7d482d 100644 --- a/www/app/entity/doc/goodsreceipt.php +++ b/www/app/entity/doc/goodsreceipt.php @@ -2,8 +2,8 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; +use \App\Entity\Entry; +use \App\Helper as H; /** * Класс-сущность документ приходная накладая @@ -18,8 +18,14 @@ public function generateReport() { $detail = array(); foreach ($this->detaildata as $value) { + $name = $value['itemname']; + if (strlen($value['snumber']) > 0) { + $name .= ' (' . $value['snumber'] . ',' . date('d.m.Y', $value['sdate']) . ')'; + } + + $detail[] = array("no" => $i++, - "itemname" => $value['itemname'], + "itemname" => $name, "itemcode" => $value['item_code'], "quantity" => H::fqty($value['quantity']), "price" => $value['price'], @@ -32,7 +38,7 @@ public function generateReport() { "_detail" => $detail, "customer_name" => $this->customer_name, "document_number" => $this->document_number, - "total" => $this->headerdata["total"] + "total" => $this->amount ); @@ -49,7 +55,7 @@ public function Execute() { //аналитика foreach ($this->detaildata as $row) { - $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $row['item_id'], $row['price'], true); + $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $row['item_id'], $row['price'], $row['snumber'], $row['sdate'], true); $sc = new Entry($this->document_id, $row['amount'], $row['quantity']); @@ -69,8 +75,11 @@ public function Execute() { $it->save(); } } + if ($this->headerdata['payment'] > 0) { + \App\Entity\Pay::addPayment($this->document_id, $this->amount, $this->headerdata['payment'], $this->headerdata['paynotes']); + $this->payamount = $this->amount; + } - //$total = $this->headerdata['total']; return true; } diff --git a/www/app/entity/doc/incomemoney.php b/www/app/entity/doc/incomemoney.php new file mode 100644 index 000000000..11f9b2d00 --- /dev/null +++ b/www/app/entity/doc/incomemoney.php @@ -0,0 +1,41 @@ +document_id, $this->amount, $this->headerdata['mfto'], notes); + + + return true; + } + + public function generateReport() { + + + $header = array( + 'amount' => $this->amount, + 'date' => date('d.m.Y', $this->document_date), + "notes" => $this->notes, + "to" => $this->headerdata["mftoname"], + "document_number" => $this->document_number + ); + $report = new \App\Report('incomemoney.tpl'); + + $html = $report->generate($header); + + return $html; + } + +} diff --git a/www/app/entity/doc/moveitem.php b/www/app/entity/doc/moveitem.php index 016d0b4d0..96b5830fb 100644 --- a/www/app/entity/doc/moveitem.php +++ b/www/app/entity/doc/moveitem.php @@ -2,10 +2,10 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Entity\Stock; -use App\Entity\Store; -use App\Helper as H; +use \App\Entity\Entry; +use \App\Entity\Stock; +use \App\Entity\Store; +use \App\Helper as H; /** * Класс-сущность локумент перемещения товаров @@ -18,8 +18,6 @@ public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); - foreach ($this->detaildata as $value) { @@ -31,7 +29,7 @@ public function Execute() { $sc->save(); - $stockto = Stock::getStock($this->headerdata['storeto'], $value['item_id'], $value['partion'], true); + $stockto = Stock::getStock($this->headerdata['storeto'], $value['item_id'], $value['partion'], $value['snumber'], $value['sdate'], true); $sc = new Entry($this->document_id, $value['quantity'] * $value['partion'], $value['quantity']); $sc->setStock($stockto->stock_id); @@ -40,7 +38,7 @@ public function Execute() { } - $conn->CompleteTrans(); + return true; } @@ -53,8 +51,13 @@ public function generateReport() { $i = 1; $detail = array(); foreach ($this->detaildata as $value) { + $name = $value['itemname']; + if (strlen($value['snumber']) > 0) { + $name .= ' (' . $value['snumber'] . ',' . date('d.m.Y', $value['sdate']) . ')'; + } + $detail[] = array("no" => $i++, - "item_name" => $value['itemname'], + "item_name" => $name, "price" => $value['partion'], "msr" => $value['msr'], "quantity" => H::fqty($value['quantity'])); @@ -63,8 +66,8 @@ public function generateReport() { $header = array( "_detail" => $detail, 'date' => date('d.m.Y', $this->document_date), - "from" => Store::load($this->headerdata["storefrom"])->storename, - "to" => Store::load($this->headerdata["storeto"])->storename, + "from" => $this->headerdata["storefromname"], + "to" => $this->headerdata["storetoname"], "document_number" => $this->document_number ); $report = new \App\Report('moveitem.tpl'); diff --git a/www/app/entity/doc/movemoney.php b/www/app/entity/doc/movemoney.php new file mode 100644 index 000000000..5ba9ea904 --- /dev/null +++ b/www/app/entity/doc/movemoney.php @@ -0,0 +1,42 @@ +document_id, 0 - $this->amount, $this->headerdata['mffrom'], $this->notes); + Pay::addPayment($this->document_id, $this->amount, $this->headerdata['mfto'], notes); + + + return true; + } + + public function generateReport() { + + + $header = array( + 'amount' => $this->amount, + 'date' => date('d.m.Y', $this->document_date), + "from" => $this->headerdata["mffromname"], + "to" => $this->headerdata["mftoname"], + "document_number" => $this->document_number + ); + $report = new \App\Report('movemoney.tpl'); + + $html = $report->generate($header); + + return $html; + } + +} diff --git a/www/app/entity/doc/order.php b/www/app/entity/doc/order.php index f2e697de0..788ffaf9c 100644 --- a/www/app/entity/doc/order.php +++ b/www/app/entity/doc/order.php @@ -2,9 +2,9 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; -use App\Util; +use \App\Entity\Entry; +use \App\Helper as H; +use \App\Util; /** * Класс-сущность документ расходная накладая diff --git a/www/app/entity/doc/ordercust.php b/www/app/entity/doc/ordercust.php index 9dfa47f3a..19bf6fac4 100644 --- a/www/app/entity/doc/ordercust.php +++ b/www/app/entity/doc/ordercust.php @@ -2,8 +2,8 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; +use \App\Entity\Entry; +use \App\Helper as H; /** * Класс-сущность документ приходная накладая @@ -32,7 +32,7 @@ public function generateReport() { "_detail" => $detail, "customer_name" => $this->customer_name, "document_number" => $this->document_number, - "total" => $this->headerdata["total"] + "total" => $this->amount ); diff --git a/www/app/entity/doc/outcomemoney.php b/www/app/entity/doc/outcomemoney.php new file mode 100644 index 000000000..ddc5ea7a7 --- /dev/null +++ b/www/app/entity/doc/outcomemoney.php @@ -0,0 +1,41 @@ +document_id, 0 - $this->amount, $this->headerdata['mffrom'], notes); + + + return true; + } + + public function generateReport() { + + + $header = array( + 'amount' => $this->amount, + 'date' => date('d.m.Y', $this->document_date), + "notes" => $this->notes, + "from" => $this->headerdata["mffromname"], + "document_number" => $this->document_number + ); + $report = new \App\Report('outcomemoney.tpl'); + + $html = $report->generate($header); + + return $html; + } + +} diff --git a/www/app/entity/doc/prodissue.php b/www/app/entity/doc/prodissue.php index 1e48a9844..3816170e1 100644 --- a/www/app/entity/doc/prodissue.php +++ b/www/app/entity/doc/prodissue.php @@ -2,9 +2,9 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; -use App\Util; +use \App\Entity\Entry; +use \App\Helper as H; +use \App\Util; /** * Класс-сущность документ списание в производство @@ -23,8 +23,14 @@ public function generateReport() { if (isset($detail[$value['item_id']])) { $detail[$value['item_id']]['quantity'] += $value['quantity']; } else { + $name = $value['itemname']; + if (strlen($value['snumber']) > 0) { + $name .= ' (' . $value['snumber'] . ',' . date('d.m.Y', $value['sdate']) . ')'; + } + + $detail[] = array("no" => $i++, - "tovar_name" => $value['itemname'], + "tovar_name" => $name, "tovar_code" => $value['item_code'], "quantity" => H::fqty($value['quantity']), "price" => $value['price'], @@ -42,9 +48,9 @@ public function generateReport() { "firmname" => $firm['firmname'], "pareaname" => $this->headerdata["pareaname"], "document_number" => $this->document_number, - "total" => $this->headerdata["total"], + "total" => amount, "notes" => $this->notes, - "summa" => Util::ucfirst(Util::money2str($this->headerdata["total"])) + "summa" => Util::ucfirst(Util::money2str(amount)) ); $report = new \App\Report('prodissue.tpl'); @@ -56,7 +62,7 @@ public function generateReport() { public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); + foreach ($this->detaildata as $row) { @@ -65,7 +71,7 @@ public function Execute() { $sc->save(); } - $conn->CompleteTrans(); + return true; } diff --git a/www/app/entity/doc/prodreceipt.php b/www/app/entity/doc/prodreceipt.php index b57248a1b..44bc7e813 100644 --- a/www/app/entity/doc/prodreceipt.php +++ b/www/app/entity/doc/prodreceipt.php @@ -2,8 +2,8 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; +use \App\Entity\Entry; +use \App\Helper as H; /** * Класс-сущность документ оприходование с производства @@ -18,8 +18,15 @@ public function generateReport() { $detail = array(); foreach ($this->detaildata as $value) { + + $name = $value['itemname']; + if (strlen($value['snumber']) > 0) { + $name .= ' (' . $value['snumber'] . ',' . date('d.m.Y', $value['sdate']) . ')'; + } + + $detail[] = array("no" => $i++, - "itemname" => $value['itemname'], + "itemname" => $name, "itemcode" => $value['item_code'], "quantity" => H::fqty($value['quantity']), "price" => $value['price'], @@ -32,8 +39,8 @@ public function generateReport() { "_detail" => $detail, "document_number" => $this->document_number, "pareaname" => $this->headerdata["pareaname"], - "notes" => $this->notes, - "total" => $this->headerdata["total"] + "notes" => $this->notes, + "total" => $this->amount ); @@ -50,8 +57,7 @@ public function Execute() { //аналитика foreach ($this->detaildata as $row) { - $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $row['item_id'], $row['price'], true); - + $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $row['item_id'], $row['price'], $row['snumber'], $row['sdate'], true); $sc = new Entry($this->document_id, $row['amount'], $row['quantity']); $sc->setStock($stock->stock_id); @@ -59,7 +65,7 @@ public function Execute() { $sc->save(); } - //$total = $this->headerdata['total']; + return true; } diff --git a/www/app/entity/doc/retcustissue.php b/www/app/entity/doc/retcustissue.php index 74eddf9b2..707c5b1af 100644 --- a/www/app/entity/doc/retcustissue.php +++ b/www/app/entity/doc/retcustissue.php @@ -2,9 +2,9 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; -use App\Util; +use \App\Entity\Entry; +use \App\Helper as H; +use \App\Util; /** * Класс-сущность документ возврат поставщику @@ -23,8 +23,13 @@ public function generateReport() { if (isset($detail[$value['item_id']])) { $detail[$value['item_id']]['quantity'] += $value['quantity']; } else { + $name = $value['itemname']; + if (strlen($value['snumber']) > 0) { + $name .= ' (' . $value['snumber'] . ',' . date('d.m.Y', $value['sdate']) . ')'; + } + $detail[] = array("no" => $i++, - "tovar_name" => $value['itemname'], + "tovar_name" => $name, "tovar_code" => $value['item_code'], "quantity" => H::fqty($value['quantity']), "msr" => $value['msr'], @@ -55,7 +60,7 @@ public function generateReport() { public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); + foreach ($this->detaildata as $row) { @@ -67,7 +72,7 @@ public function Execute() { $sc->save(); } - $conn->CompleteTrans(); + return true; } diff --git a/www/app/entity/doc/returnissue.php b/www/app/entity/doc/returnissue.php index 833a4cc2e..56582747e 100644 --- a/www/app/entity/doc/returnissue.php +++ b/www/app/entity/doc/returnissue.php @@ -2,9 +2,9 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; -use App\Util; +use \App\Entity\Entry; +use \App\Helper as H; +use \App\Util; /** * Класс-сущность документ возвратная накладная @@ -23,8 +23,13 @@ public function generateReport() { if (isset($detail[$value['item_id']])) { $detail[$value['item_id']]['quantity'] += $value['quantity']; } else { + $name = $value['itemname']; + if (strlen($value['snumber']) > 0) { + $name .= ' (' . $value['snumber'] . ',' . date('d.m.Y', $value['sdate']) . ')'; + } + $detail[] = array("no" => $i++, - "tovar_name" => $value['itemname'], + "tovar_name" => $name, "quantity" => H::fqty($value['quantity']), "price" => $value['price'], "msr" => $value['msr'], @@ -41,8 +46,8 @@ public function generateReport() { "firmname" => $firm['firmname'], "customername" => $this->customer_name, "document_number" => $this->document_number, - "total" => $this->headerdata["total"], - "summa" => Util::ucfirst(Util::money2str($this->headerdata["total"])) + "total" => $this->amount, + "summa" => Util::ucfirst(Util::money2str($this->amount)) ); $report = new \App\Report('returnissue.tpl'); @@ -54,7 +59,7 @@ public function generateReport() { public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); + foreach ($this->detaildata as $row) { @@ -66,8 +71,11 @@ public function Execute() { $sc->setCustomer($this->customer_id); $sc->save(); } + if ($this->headerdata['payment'] > 0) { + \App\Entity\Pay::addPayment($this->document_id, 0 - $this->amount, $this->headerdata['payment'], $this->headerdata['paynotes']); + $this->payamount = $this->amount; + } - $conn->CompleteTrans(); return true; } diff --git a/www/app/entity/doc/serviceact.php b/www/app/entity/doc/serviceact.php index 67a86b485..bc02c5db8 100644 --- a/www/app/entity/doc/serviceact.php +++ b/www/app/entity/doc/serviceact.php @@ -2,7 +2,7 @@ namespace App\Entity\Doc; -use App\Entity\Entry; +use \App\Entity\Entry; /** * Класс-сущность локумент акт о выполненных работах @@ -43,7 +43,7 @@ public function generateReport() { public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); + foreach ($this->detaildata as $row) { @@ -55,7 +55,12 @@ public function Execute() { $sc->setCustomer($this->customer_id); $sc->save(); } - $conn->CompleteTrans(); + if ($this->headerdata['payment'] > 0) { + \App\Entity\Pay::addPayment($this->document_id, $this->amount, $this->headerdata['payment'], $this->headerdata['paynotes']); + $this->payamount = $this->amount; + } + + return true; } diff --git a/www/app/entity/doc/serviceorder.php b/www/app/entity/doc/serviceorder.php index 915636b04..c99ddd25d 100644 --- a/www/app/entity/doc/serviceorder.php +++ b/www/app/entity/doc/serviceorder.php @@ -2,7 +2,7 @@ namespace App\Entity\Doc; -use App\Entity\Entry; +use \App\Entity\Entry; /** * Класс-сущность заказ на услуги diff --git a/www/app/entity/doc/task.php b/www/app/entity/doc/task.php index 56e5f42b7..b72902e56 100644 --- a/www/app/entity/doc/task.php +++ b/www/app/entity/doc/task.php @@ -2,8 +2,8 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Helper as H; +use \App\Entity\Entry; +use \App\Helper as H; /** * Класс-сущность наряд @@ -88,7 +88,7 @@ public function generateReport() { public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); + foreach ($this->detaildata as $row) { @@ -122,7 +122,10 @@ public function Execute() { } } - $conn->CompleteTrans(); + if ($this->headerdata['payment'] > 0) { + \App\Entity\Pay::addPayment($this->document_id, $this->amount, $this->headerdata['payment'], $this->headerdata['paynotes']); + $this->payamount = $this->amount; + } return true; } diff --git a/www/app/entity/doc/transitem.php b/www/app/entity/doc/transitem.php index f04c94e14..f5681ad4c 100644 --- a/www/app/entity/doc/transitem.php +++ b/www/app/entity/doc/transitem.php @@ -2,11 +2,11 @@ namespace App\Entity\Doc; -use App\Entity\Entry; -use App\Entity\Stock; -use App\Entity\Store; -use App\Entity\Item; -use App\Helper as H; +use \App\Entity\Entry; +use \App\Entity\Stock; +use \App\Entity\Store; +use \App\Entity\Item; +use \App\Helper as H; /** * Класс-сущность локумент перекомплектация товаров @@ -17,9 +17,6 @@ class TransItem extends Document { public function Execute() { $conn = \ZDB\DB::getConnect(); - $conn->StartTrans(); - - //списываем со склада @@ -32,14 +29,13 @@ public function Execute() { $ti = Item::load($this->headerdata['toitem']); $price = round(($this->amount ) / $this->headerdata["toquantity"]); - $stockto = Stock::getStock($this->headerdata['storefrom'], $ti->item_id, $price, true); + $stockto = Stock::getStock($this->headerdata['storefrom'], $ti->item_id, $price, "", "", true); $sc = new Entry($this->document_id, $this->headerdata["toquantity"] * $price, $this->headerdata["toquantity"]); $sc->setStock($stockto->stock_id); $sc->save(); - $conn->CompleteTrans(); return true; } diff --git a/www/app/entity/doc/warranty.php b/www/app/entity/doc/warranty.php index 64043dfa4..ebe7745ea 100644 --- a/www/app/entity/doc/warranty.php +++ b/www/app/entity/doc/warranty.php @@ -2,7 +2,7 @@ namespace App\Entity\Doc; -use App\Helper as H; +use \App\Helper as H; /** * Класс-сущность документ гарантийного талон diff --git a/www/app/entity/employee.php b/www/app/entity/employee.php index 8ea00f799..9591d0db2 100644 --- a/www/app/entity/employee.php +++ b/www/app/entity/employee.php @@ -12,12 +12,14 @@ class Employee extends \ZCL\DB\Entity { protected function init() { $this->employee_id = 0; + $this->balance = 0; } protected function beforeSave() { parent::beforeSave(); //упаковываем данные в detail $this->detail = "{$this->login}"; + $this->detail .= "{$this->balance}"; $this->detail .= "{$this->email}"; $this->detail .= "{$this->comment}"; @@ -29,6 +31,7 @@ protected function beforeSave() { protected function afterLoad() { //распаковываем данные из detail $xml = simplexml_load_string($this->detail); + $this->balance = (int) ($xml->balance[0]); $this->login = (string) ($xml->login[0]); $this->email = (string) ($xml->email[0]); $this->comment = (string) ($xml->comment[0]); diff --git a/www/app/entity/equipment.php b/www/app/entity/equipment.php index 0fae34898..d4caaa9e6 100644 --- a/www/app/entity/equipment.php +++ b/www/app/entity/equipment.php @@ -43,14 +43,4 @@ protected function afterLoad() { parent::afterLoad(); } - protected function beforeDelete() { - - return $this->checkDelete(); - } - - public function checkDelete() { - - return true; - } - } diff --git a/www/app/entity/item.php b/www/app/entity/item.php index ad4c20554..0c2cfe7a3 100644 --- a/www/app/entity/item.php +++ b/www/app/entity/item.php @@ -17,7 +17,6 @@ protected function init() { $this->curname = ''; $this->currate = 0; $this->price = 0; - } protected function afterLoad() { @@ -33,7 +32,8 @@ protected function afterLoad() { $this->curname = (string) ($xml->curname[0]); $this->currate = doubleval($xml->currate[0]); $this->pricelist = (int) $xml->pricelist[0]; - + $this->term = (int) $xml->term[0]; + @@ -45,7 +45,8 @@ protected function beforeSave() { $this->detail = ""; //упаковываем данные в detail $this->detail .= "{$this->pricelist}"; - + $this->detail .= "{$this->term}"; + $this->detail .= "{$this->price1}"; $this->detail .= "{$this->price2}"; $this->detail .= "{$this->price3}"; @@ -61,16 +62,11 @@ protected function beforeSave() { protected function beforeDelete() { - return $this->checkDelete(); - } - - public function checkDelete() { - $conn = \ZDB\DB::getConnect(); - + //проверка на партии $sql = " select count(*) from store_stock where item_id = {$this->item_id}"; $cnt = $conn->GetOne($sql); - return ($cnt > 0) ? false : true; + return ($cnt > 0) ? "ТМЦ уже используется" : ""; } //Вычисляет отпускную цену diff --git a/www/app/entity/metadata.php b/www/app/entity/metadata.php index 9575bcf4b..b35dcd679 100644 --- a/www/app/entity/metadata.php +++ b/www/app/entity/metadata.php @@ -15,10 +15,6 @@ class MetaData extends \ZCL\DB\Entity { const METATYPE_REF = 3; const METATYPE_REG = 4; - protected function beforeDelete() { - return true; - } - public static function getNames() { $list = array(); $list[1] = "Документ"; diff --git a/www/app/entity/moneyfund.php b/www/app/entity/moneyfund.php new file mode 100644 index 000000000..31efe9585 --- /dev/null +++ b/www/app/entity/moneyfund.php @@ -0,0 +1,51 @@ +mf_id = 0; + } + + protected function beforeDelete() { + + $conn = \ZDB\DB::getConnect(); + + $cnt = $conn->GetOne("select count(*) from paylist where mf_id = {$this->mf_id} "); + if ($cnt > 0) { + return "Нельзя удалять счет с оплатами"; + } + return ""; + } + + /** + * возвращает баланс на денежных счетах + * + */ + public static function Balance() { + + $conn = \ZDB\DB::getConnect(); + $list = array(); + $rc = $conn->Execute("select coalesce(sum(amount),0) as amount,mf_id from paylist group by mf_id "); + foreach ($rc as $row) { + $list[$row["mf_id"]] = $row["amount"]; + } + return $list; + } + + /** + * список счетов для комбо + * + */ + public static function getList() { + return MoneyFund::findArray("mf_name", ""); + } + +} diff --git a/www/app/entity/pay.php b/www/app/entity/pay.php new file mode 100644 index 000000000..830197602 --- /dev/null +++ b/www/app/entity/pay.php @@ -0,0 +1,60 @@ +pl_id = 0; + $this->paydate = time(); + } + + protected function afterLoad() { + $this->paydate = strtotime($this->paydate); + } + + //возвращает список оплат + public static function getPayments($document_id) { + $list = Pay::find("document_id=" . $document_id, "pl_id"); + + return $list; + } + + //возвращает сумму оплат по документу + public static function getPaymentAmount($document_id) { + $conn = \ZDB\DB::getConnect(); + + $sql = "select coalesce(sum(amount),0) from paylist where document_id=" . $document_id; + return $conn->GetOne($sql); + } + + /** + * Добавляет платеж + * + * @param mixed $document_id документ + * @param mixed $amount сумма + * @param mixed $mf денежный счет + * @param mixed $comment коментарий + */ + public static function addPayment($document_id, $amount, $mf, $comment = '') { + if (0 == (int) $amount || 0 == (int) $document_id || 0 == $mf) + return; + $pay = new \App\Entity\Pay(); + $pay->mf_id = $mf; + $pay->document_id = $document_id; + $pay->amount = $amount; + $pay->notes = $comment; + + + $pay->user_id = \App\System::getUser()->user_id; + $pay->save(); + } + +} diff --git a/www/app/entity/prodarea.php b/www/app/entity/prodarea.php index cbd413451..1da8bc05a 100644 --- a/www/app/entity/prodarea.php +++ b/www/app/entity/prodarea.php @@ -14,4 +14,12 @@ protected function init() { $this->pa_id = 0; } + protected function beforeDelete() { + + $conn = \ZDB\DB::getConnect(); + // $sql = " select count(*) from store_stock where store_id = {$this->store_id}"; + // $cnt = $conn->GetOne($sql); + return ($cnt > 0) ? "Нельзя удалять используемый склад" : true; + } + } diff --git a/www/app/entity/service.php b/www/app/entity/service.php index db15bee3c..994ac8a6e 100644 --- a/www/app/entity/service.php +++ b/www/app/entity/service.php @@ -39,4 +39,12 @@ protected function beforeSave() { return true; } + protected function beforeDelete() { + + $conn = \ZDB\DB::getConnect(); + // $sql = " select count(*) from store_stock where store_id = {$this->store_id}"; + // $cnt = $conn->GetOne($sql); + return ($cnt > 0) ? "Нельзя удалять используемую услугу" : ""; + } + } diff --git a/www/app/entity/stock.php b/www/app/entity/stock.php index b4198c7f9..0624adca9 100644 --- a/www/app/entity/stock.php +++ b/www/app/entity/stock.php @@ -13,7 +13,11 @@ class Stock extends \ZCL\DB\Entity { protected function init() { $this->stock_id = 0; - $this->deleted = 0; + } + + protected function afterLoad() { + if (strlen($this->sdate) > 0) + $this->sdate = strtotime($this->sdate); } /** @@ -26,18 +30,19 @@ protected function init() { public static function findArrayAC($store, $partname = "") { - $criteria = "qty <>0 and disabled <> 1 "; + $criteria = "qty <> 0 and disabled <> 1 and store_id=" . $store; if (strlen($partname) > 0) { $partname = self::qstr('%' . $partname . '%'); - $criteria .= " and (itemname like {$partname} or item_code like {$partname} )"; + $criteria .= " and (itemname like {$partname} or item_code like {$partname} or snumber like {$partname} )"; } - - - $entitylist = self::find($criteria, "itemname"); + $entitylist = self::find($criteria, "sdate asc"); $list = array(); foreach ($entitylist as $key => $value) { + if (strlen($value->snumber) > 0) { + $value->itemname .= ' (' . $value->snumber . ',' . date('Y-m-d', $value->sdate) . ')'; + } $list[$key] = $value->itemname . ', ' . \App\Helper::fqty($value->partion); } @@ -52,11 +57,15 @@ public static function findArrayAC($store, $partname = "") { * @param mixed $price Цена * @param mixed $create Создать если не существует */ - public static function getStock($store_id, $item_id, $price, $create = false) { + public static function getStock($store_id, $item_id, $price, $snumber = "", $sdate = 0, $create = false) { + $conn = \ZDB\DB::getConnect(); $where = "store_id = {$store_id} and item_id = {$item_id} and partion = {$price} "; - $conn = \ZDB\DB::getConnect(); + if (strlen($snumber) > 0) { + + $where .= " and snumber = " . self::qstr($snumber); + } //на случай если удален //$conn->Execute("update store_stock set deleted=0 where " . $where); @@ -67,6 +76,9 @@ public static function getStock($store_id, $item_id, $price, $create = false) { $stock->store_id = $store_id; $stock->item_id = $item_id; $stock->partion = $price; + $stock->snumber = $snumber; + if ($sdate > 0) + $stock->sdate = $sdate; $stock->save(); } @@ -101,7 +113,7 @@ public static function getQuantity($stock_id, $date = null) { public static function pickup($store_id, $item_id, $qty) { $res = array(); $where = "store_id = {$store_id} and item_id = {$item_id} and qty >0 "; - $stlist = self::find($where, 'stock_id'); + $stlist = self::find($where, 'sdate,stock_id'); foreach ($stlist as $st) { if ($st->qty >= $qty) { $st->quantity = $qty; diff --git a/www/app/entity/store.php b/www/app/entity/store.php index c5e7038f2..2b1d3fe96 100644 --- a/www/app/entity/store.php +++ b/www/app/entity/store.php @@ -18,9 +18,9 @@ protected function init() { protected function beforeDelete() { $conn = \ZDB\DB::getConnect(); - // $sql = " select count(*) from store_stock where store_id = {$this->store_id}"; - // $cnt = $conn->GetOne($sql); - return ($cnt > 0) ? false : true; + $sql = " select count(*) from store_stock where store_id = {$this->store_id}"; + $cnt = $conn->GetOne($sql); + return ($cnt > 0) ? "Нельзя удалять используемый склад" : true; } /** diff --git a/www/app/entity/user.php b/www/app/entity/user.php index 178054503..7345f6d19 100644 --- a/www/app/entity/user.php +++ b/www/app/entity/user.php @@ -90,7 +90,11 @@ protected function beforeSave() { * */ protected function beforeDelete() { + $conn = \ZDB\DB::getConnect(); + $sql = " select count(*) from documents where user_id = {$this->user_id}"; + $cnt = $conn->GetOne($sql); + return ($cnt > 0) ? "Нельзя удалять пользователя с документами" : true; } /** diff --git a/www/app/helper.php b/www/app/helper.php index d0d0b9645..bf4a51dc5 100644 --- a/www/app/helper.php +++ b/www/app/helper.php @@ -90,9 +90,6 @@ public static function generateMenu($meta_type) { case 4 : $dir = "Pages/Reference"; break; - case 5 : - $dir = "Shop/Pages"; - break; } $textmenu = ""; @@ -145,9 +142,6 @@ public static function generateSmartMenu() { case 4 : $dir = "Pages/Reference"; break; - case 5 : - $dir = "Shop/Pages"; - break; } $textmenu .= " {$item['description']} "; @@ -337,10 +331,30 @@ public static function getDefStore() { return $common['defstore']; } - \App\System::setErrorMsg('Не настроен склад по умолчанию'); - \App\Application::RedirectHome(); + \App\System::setErrorMsg('Не задан склад по умолчанию'); + \App\Application::Redirect("\\App\\Pages\\Options"); } + /** + * Возвращает расчетный счет по умолчанию + * + */ + public static function getDefMF() { + $common = System::getOptions("common"); + if ($common['defmf'] > 0) { + return $common['defmf']; + } + + \App\System::setErrorMsg('Не задан денежный счет по умолчанию'); + \App\Application::Redirect("\\App\\Pages\\Options"); + } + + /** + * Форматирование количества + * + * @param mixed $qty + * @return mixed + */ public static function fqty($qty) { if (strlen($qty) == 0) return ''; diff --git a/www/app/modules/ocstore/helper.php b/www/app/modules/ocstore/helper.php index 57d00813f..ce9e84821 100644 --- a/www/app/modules/ocstore/helper.php +++ b/www/app/modules/ocstore/helper.php @@ -5,11 +5,9 @@ /** * Вспомагательный класс */ -class Helper -{ +class Helper { - public static function do_curl_request($url, $params = array()) - { + public static function do_curl_request($url, $params = array()) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -29,14 +27,15 @@ public static function do_curl_request($url, $params = array()) //execute post $result = curl_exec($ch); - if($result ===false){ - $error=curl_error($ch) ; - \App\System::setErrorMsg($error) ; + if ($result === false) { + $error = curl_error($ch); + \App\System::setErrorMsg($error); } - + //close connection curl_close($ch); return $result; } + } diff --git a/www/app/modules/ocstore/items.php b/www/app/modules/ocstore/items.php index 880b30084..6d542c178 100644 --- a/www/app/modules/ocstore/items.php +++ b/www/app/modules/ocstore/items.php @@ -1,5 +1,4 @@ modules, 'ocstore') === false && System::getUser()->userlogin != 'admin') { @@ -37,216 +34,217 @@ public function __construct() $cats = array(); $this->setWarn('Выполните соединение на странице настроек'); } - + $this->add(new Form('filter'))->onSubmit($this, 'filterOnSubmit'); - + $this->add(new Form('exportform'))->onSubmit($this, 'exportOnSubmit'); - + $this->exportform->add(new DataView('newitemlist', new ArrayDataSource(new Prop($this, '_items')), $this, 'itemOnRow')); $this->exportform->add(new DropDownChoice('ecat', $cats, 0)); - + $this->add(new ClickLink('updateqty'))->onClick($this, 'onUpdateQty'); $this->add(new ClickLink('updateprice'))->onClick($this, 'onUpdatePrice'); $this->add(new ClickLink('getitems'))->onClick($this, 'onGetItems'); - - } - - public function filterOnSubmit($sender) - { + } + + public function filterOnSubmit($sender) { $this->_items = array(); $modules = System::getOptions("modules"); - + $url = $modules['ocsite'] . '/index.php?route=api/zstore/articles&' . System::getSession()->octoken; - $json = Helper::do_curl_request($url ); - if($json ===false) return; - $data = json_decode($json,true); + $json = Helper::do_curl_request($url); + if ($json === false) + return; + $data = json_decode($json, true); if ($data['error'] == "") { - - $items = Item::find ("disabled <> 1","itemname"); - foreach($items as $item){ - if(strlen($item->item_code)==0) continue; - if(in_array($item->item_code,$data['articles'])) continue; //уже в магазине - if(strlen($item->qty)==0)$item->qty=0; + + $items = Item::find("disabled <> 1", "itemname"); + foreach ($items as $item) { + if (strlen($item->item_code) == 0) + continue; + if (in_array($item->item_code, $data['articles'])) + continue; //уже в магазине + if (strlen($item->qty) == 0) + $item->qty = 0; $this->_items[] = $item; - } - - $this->exportform->newitemlist->Reload(); + } + + $this->exportform->newitemlist->Reload(); $this->exportform->ecat->setValue(0); - } else { $this->setError($data['error']); - } - } - - - public function itemOnRow($row) - { + } + } + + public function itemOnRow($row) { $modules = System::getOptions("modules"); - + $item = $row->getDataItem(); - $row->add(new CheckBox('ch', new Prop($item,'ch') )); + $row->add(new CheckBox('ch', new Prop($item, 'ch'))); $row->add(new Label('name', $item->itemname)); $row->add(new Label('code', $item->item_code)); $row->add(new Label('qty', \App\Helper::fqty($item->qty))); $row->add(new Label('price', $item->getPrice($modules['ocpricetype']))); $row->add(new Label('desc', $item->desription)); - - } - + public function exportOnSubmit($sender) { - $modules = System::getOptions("modules"); - $cat=$this->exportform->ecat->getValue(); - if($cat==0) { - $this->setError('Не выбрана категория '); - return; - } - - $elist = array(); - foreach($this->_items as $item) { - if($item->ch == false)continue; - $elist[] = array('name'=>$item->itemname, - 'description'=>$item->description, - 'sku'=>$item->item_code, - 'quantity'=>\App\Helper::fqty($item->qty), - 'price'=>$item->getPrice($modules['ocpricetype']) - ); - } - if(count($elist)==0) { - $this->setError('Не выбран ни один товар'); - return; - } - $data= json_encode($elist); - - + $modules = System::getOptions("modules"); + $cat = $this->exportform->ecat->getValue(); + if ($cat == 0) { + $this->setError('Не выбрана категория '); + return; + } + + $elist = array(); + foreach ($this->_items as $item) { + if ($item->ch == false) + continue; + $elist[] = array('name' => $item->itemname, + 'description' => $item->description, + 'sku' => $item->item_code, + 'quantity' => \App\Helper::fqty($item->qty), + 'price' => $item->getPrice($modules['ocpricetype']) + ); + } + if (count($elist) == 0) { + $this->setError('Не выбран ни один товар'); + return; + } + $data = json_encode($elist); + + $fields = array( 'data' => $data, - 'cat' => $cat + 'cat' => $cat ); - + $url = $modules['ocsite'] . '/index.php?route=api/zstore/addproducts&' . System::getSession()->octoken; $json = Helper::do_curl_request($url, $fields); - if($json ===false) return; - $data = json_decode($json,true); - - + if ($json === false) + return; + $data = json_decode($json, true); + + if ($data['error'] != "") { $this->setError($data['error']); return; } - $this->setSuccess("Экспортировано ".count($elist)." товаров"); - + $this->setSuccess("Экспортировано " . count($elist) . " товаров"); + //обновляем таблицу - $this->filterOnSubmit(null); + $this->filterOnSubmit(null); + } - } - public function onUpdateQty($sender) { - $modules = System::getOptions("modules"); - - - $elist = array(); - $items = Item::find ("disabled <> 1 "); - foreach($items as $item){ - if(strlen($item->item_code)==0)continue; - if(strlen($item->qty)==0)$item->qty=0; - $elist[$item->item_code] = $item->qty; - } - - $data= json_encode($elist) ; - + $modules = System::getOptions("modules"); + + + $elist = array(); + $items = Item::find("disabled <> 1 "); + foreach ($items as $item) { + if (strlen($item->item_code) == 0) + continue; + if (strlen($item->qty) == 0) + $item->qty = 0; + $elist[$item->item_code] = $item->qty; + } + + $data = json_encode($elist); + $fields = array( 'data' => $data ); $url = $modules['ocsite'] . '/index.php?route=api/zstore/updatequantity&' . System::getSession()->octoken; $json = Helper::do_curl_request($url, $fields); - if($json ===false) return; - $data = json_decode($json,true); - + if ($json === false) + return; + $data = json_decode($json, true); + if ($data['error'] != "") { $this->setError($data['error']); return; } - $this->setSuccess("Обновлено "); - - - - - } - - + $this->setSuccess("Обновлено "); + } + public function onUpdatePrice($sender) { - $modules = System::getOptions("modules"); - - - $elist = array(); - $items = Item::find ("disabled <> 1 "); - foreach($items as $item){ - if(strlen($item->item_code)==0)continue; - $elist[$item->item_code] = $item->getPrice($modules['ocpricetype']); - } - - $data= json_encode($elist) ; - + $modules = System::getOptions("modules"); + + + $elist = array(); + $items = Item::find("disabled <> 1 "); + foreach ($items as $item) { + if (strlen($item->item_code) == 0) + continue; + $elist[$item->item_code] = $item->getPrice($modules['ocpricetype']); + } + + $data = json_encode($elist); + $fields = array( 'data' => $data ); $url = $modules['ocsite'] . '/index.php?route=api/zstore/updateprice&' . System::getSession()->octoken; $json = Helper::do_curl_request($url, $fields); - if($json ===false) return; - $data = json_decode($json,true); - + if ($json === false) + return; + $data = json_decode($json, true); + if ($data['error'] != "") { $this->setError($data['error']); return; } - $this->setSuccess("Обновлено "); - - - - - } - + $this->setSuccess("Обновлено "); + } + public function onGetItems($sender) { $modules = System::getOptions("modules"); - + $elist = array(); - + $url = $modules['ocsite'] . '/index.php?route=api/zstore/getproducts&' . System::getSession()->octoken; $json = Helper::do_curl_request($url); - if($json ===false) return; - $data = json_decode($json,true); - + if ($json === false) + return; + $data = json_decode($json, true); + if ($data['error'] != "") { $this->setError($data['error']); return; } - + $i = 0; - foreach($data['products'] as $product){ - - - $cnt = Item::findCnt("item_code=". Item::qstr($product['sku'])); - if($cnt >0) continue; //уже есть с таким аритикулом - + foreach ($data['products'] as $product) { + + + $cnt = Item::findCnt("item_code=" . Item::qstr($product['sku'])); + if ($cnt > 0) + continue; //уже есть с таким аритикулом + $item = new Item(); - $item->item_code= $product['sku']; - $item->itemname= $product['name']; - $item->description= $product['description']; - - if($modules['ocpricetype']=='price1')$item->price1= $product['price']; - if($modules['ocpricetype']=='price2')$item->price2= $product['price']; - if($modules['ocpricetype']=='price3')$item->price3= $product['price']; - if($modules['ocpricetype']=='price4')$item->price4= $product['price']; - if($modules['ocpricetype']=='price5')$item->price5= $product['price']; + $item->item_code = $product['sku']; + $item->itemname = $product['name']; + $item->description = $product['description']; + + if ($modules['ocpricetype'] == 'price1') + $item->price1 = $product['price']; + if ($modules['ocpricetype'] == 'price2') + $item->price2 = $product['price']; + if ($modules['ocpricetype'] == 'price3') + $item->price3 = $product['price']; + if ($modules['ocpricetype'] == 'price4') + $item->price4 = $product['price']; + if ($modules['ocpricetype'] == 'price5') + $item->price5 = $product['price']; $item->save(); $i++; } - - - - - $this->setSuccess("Загружено {$i} товаров") ; - - } + + + + + $this->setSuccess("Загружено {$i} товаров"); + } + } diff --git a/www/app/modules/ocstore/options.php b/www/app/modules/ocstore/options.php index 555b5c545..ea0f32fb5 100644 --- a/www/app/modules/ocstore/options.php +++ b/www/app/modules/ocstore/options.php @@ -10,11 +10,9 @@ use \Zippy\Html\Form\TextInput; use \Zippy\WebApplication as App; -class Options extends \App\Pages\Base -{ +class Options extends \App\Pages\Base { - public function __construct() - { + public function __construct() { parent::__construct(); if (strpos(System::getUser()->modules, 'ocstore') === false && System::getUser()->userlogin != 'admin') { @@ -30,16 +28,14 @@ public function __construct() $form->add(new TextInput('site', $modules['ocsite'])); $form->add(new TextInput('apiname', $modules['ocapiname'])); $form->add(new TextArea('key', $modules['ockey'])); - $form->add(new DropDownChoice('defcust', \App\Entity\Customer::getList(),$modules['occustomer_id'])); - $form->add(new DropDownChoice('defpricetype', \App\Entity\Item::getPriceTypeList(),$modules['ocpricetype'])); + $form->add(new DropDownChoice('defcust', \App\Entity\Customer::getList(), $modules['occustomer_id'])); + $form->add(new DropDownChoice('defpricetype', \App\Entity\Item::getPriceTypeList(), $modules['ocpricetype'])); $form->add(new SubmitButton('save'))->onClick($this, 'saveOnClick'); $form->add(new SubmitButton('check'))->onClick($this, 'checkOnClick'); - } - public function checkOnClick($sender) - { + public function checkOnClick($sender) { $site = $this->cform->site->getText(); $apiname = $this->cform->apiname->getText(); $key = $this->cform->key->getText(); @@ -49,18 +45,18 @@ public function checkOnClick($sender) $fields = array( 'username' => $apiname, - 'key' => $key - + 'key' => $key ); $json = Helper::do_curl_request($url, $fields); - if($json ===false) return; - $data = json_decode($json,true); + if ($json === false) + return; + $data = json_decode($json, true); - if (is_array($data['error']) ) { - $this->setError(implode(' ',$data['error'])); - } else + if (is_array($data['error'])) { + $this->setError(implode(' ', $data['error'])); + } else if (strlen($data['error']) > 0) { $this->setError($data['error']); } @@ -79,31 +75,29 @@ public function checkOnClick($sender) //загружаем список статусов $url = $site . '/index.php?route=api/zstore/statuses&' . System::getSession()->octoken; $json = Helper::do_curl_request($url, array()); - $data = json_decode($json,true); + $data = json_decode($json, true); if ($data['error'] != "") { $this->setError($data['error']); } else { - + System::getSession()->statuses = $data['statuses']; } //загружаем список категорий $url = $site . '/index.php?route=api/zstore/cats&' . System::getSession()->octoken; $json = Helper::do_curl_request($url, array()); - $data = json_decode($json,true); + $data = json_decode($json, true); if ($data['error'] != "") { $this->setError($data['error']); } else { - + System::getSession()->cats = $data['cats']; } - } } - public function saveOnClick($sender) - { + public function saveOnClick($sender) { $site = $this->cform->site->getText(); $apiname = $this->cform->apiname->getText(); $key = $this->cform->key->getText(); @@ -131,4 +125,5 @@ public function saveOnClick($sender) System::setOptions("modules", $modules); $this->setSuccess('Сохранено'); } + } diff --git a/www/app/modules/ocstore/orders.php b/www/app/modules/ocstore/orders.php index 27926c0ee..b563ebb69 100644 --- a/www/app/modules/ocstore/orders.php +++ b/www/app/modules/ocstore/orders.php @@ -15,14 +15,12 @@ use \App\Entity\Item; use \Zippy\Html\Link\ClickLink; -class Orders extends \App\Pages\Base -{ +class Orders extends \App\Pages\Base { public $_neworders = array(); public $_eorders = array(); - public function __construct() - { + public function __construct() { parent::__construct(); if (strpos(System::getUser()->modules, 'ocstore') === false && System::getUser()->userlogin != 'admin') { @@ -38,26 +36,24 @@ public function __construct() $statuses = array(); $this->setWarn('Выполните соединение на странице настроек'); } - + $this->add(new Form('filter'))->onSubmit($this, 'filterOnSubmit'); $this->filter->add(new DropDownChoice('status', $statuses, 0)); $this->add(new DataView('neworderslist', new ArrayDataSource(new Prop($this, '_neworders')), $this, 'noOnRow')); $this->add(new ClickLink('importbtn'))->onClick($this, 'onImport'); - - + + $this->add(new ClickLink('refreshbtn'))->onClick($this, 'onRefresh'); $this->add(new Form('updateform'))->onSubmit($this, 'exportOnSubmit'); $this->updateform->add(new DataView('orderslist', new ArrayDataSource(new Prop($this, '_eorders')), $this, 'expRow')); $this->updateform->add(new DropDownChoice('estatus', $statuses, 0)); - } - public function filterOnSubmit($sender) - { + public function filterOnSubmit($sender) { $modules = System::getOptions("modules"); - + $status = $this->filter->status->getValue(); $this->_neworders = array(); @@ -66,32 +62,33 @@ public function filterOnSubmit($sender) ); $url = $modules['ocsite'] . '/index.php?route=api/zstore/orders&' . System::getSession()->octoken; $json = Helper::do_curl_request($url, $fields); - if($json ===false) return; - $data = json_decode($json,true); + if ($json === false) + return; + $data = json_decode($json, true); if ($data['error'] == "") { - - - + + + foreach ($data['orders'] as $ocorder) { - - //$ocorder =unserialize(base64_decode($o )) ; - - - $isorder = Document::findCnt("meta_name='Order' and content like '%{$ocorder['order_id']}%'"); - if ($isorder > 0) { //уже импортирован - continue; - } - foreach($ocorder['_products_'] as $product) { - $code = trim($product['sku']); - if($code == "") { - $this->setWarn("Не задан артикул товара '{$product['name']}' в заказе номер {$ocorder['order_id']} "); + + //$ocorder =unserialize(base64_decode($o )) ; + + + $isorder = Document::findCnt("meta_name='Order' and content like '%{$ocorder['order_id']}%'"); + if ($isorder > 0) { //уже импортирован + continue; + } + foreach ($ocorder['_products_'] as $product) { + $code = trim($product['sku']); + if ($code == "") { + $this->setWarn("Не задан артикул товара '{$product['name']}' в заказе номер {$ocorder['order_id']} "); } - } - - $order = new \App\DataItem($ocorder); - - - $this->_neworders[] = $order; + } + + $order = new \App\DataItem($ocorder); + + + $this->_neworders[] = $order; } $this->neworderslist->Reload(); @@ -100,135 +97,135 @@ public function filterOnSubmit($sender) } } - - public function noOnRow($row) - { + public function noOnRow($row) { $order = $row->getDataItem(); - - $row->add(new Label('number', $order->order_id)); - $row->add(new Label('customer', $order->firstname.' '.$order->lastname)); - $row->add(new Label('amount', round($order->total))); - $row->add(new Label('comment', $order->comment)); - $row->add(new Label('date', date('Y-m-d H:i',strtotime($order->date_modified)))); + + $row->add(new Label('number', $order->order_id)); + $row->add(new Label('customer', $order->firstname . ' ' . $order->lastname)); + $row->add(new Label('amount', round($order->total))); + $row->add(new Label('comment', $order->comment)); + $row->add(new Label('date', date('Y-m-d H:i', strtotime($order->date_modified)))); } - - public function onImport($sender) - { + + public function onImport($sender) { $modules = System::getOptions("modules"); - - $i=0; + + $i = 0; foreach ($this->_neworders as $shoporder) { - - $neworder = Document::create('Order'); + + $neworder = Document::create('Order'); $neworder->document_number = $neworder->nextNumber(); if (strlen($neworder->document_number) == 0) - $neworder->document_number = 'OC00001'; + $neworder->document_number = 'OC00001'; $neworder->customer_id = $modules['occustomer_id']; - + //товары - - foreach($shoporder->_products_ as $product) { + + foreach ($shoporder->_products_ as $product) { //ищем по артикулу - if(strlen($product['sku'])==0) continue; - $code = Item::qstr($product['sku']) ; - - $tovar = Item::getFirst('item_code='.$code) ; - if($code == "") { - $this->setWarn("Не найден товар с артикулом '{$product['name']}' в заказе номер {$shoporder['order_id']} "); - continue; - } - $tovar->quantity = $product['quantity'] ; - $tovar->price = round($product['price']) ; - $neworder->detaildata[] = $tovar->getData(); + if (strlen($product['sku']) == 0) + continue; + $code = Item::qstr($product['sku']); + + $tovar = Item::getFirst('item_code=' . $code); + if ($code == "") { + $this->setWarn("Не найден товар с артикулом '{$product['name']}' в заказе номер {$shoporder['order_id']} "); + continue; + } + $tovar->quantity = $product['quantity']; + $tovar->price = round($product['price']); + $neworder->detaildata[] = $tovar->getData(); } - - - $neworder->headerdata['ocorder']= $shoporder->order_id; - $neworder->headerdata['ocorderback'] = 0; - $neworder->headerdata['occlient'] .= $shoporder->firstname .' '.$shoporder->lastname ; - $neworder->headerdata['total'] = round($shoporder->total); - $neworder->amount= round($shoporder->total); + + + $neworder->headerdata['ocorder'] = $shoporder->order_id; + $neworder->headerdata['ocorderback'] = 0; + $neworder->headerdata['occlient'] .= $shoporder->firstname . ' ' . $shoporder->lastname; + $neworder->amount = round($shoporder->total); $neworder->notes = "OC номер:{$shoporder->order_id};"; - $neworder->notes .= " Клиент:".$shoporder->firstname .' '.$shoporder->lastname.";"; - if(strlen($shoporder->email) > 0) $neworder->notes .= " Email:".$shoporder->email.";"; - if(strlen($shoporder->telephone) > 0) $neworder->notes .= " Тел:".$shoporder->telephone.";"; - $neworder->notes .= " Адрес:".$shoporder->shipping_city.' '.$shoporder->shipping_address_1.";"; - $neworder->notes .= " Комментарий:".$shoporder->comment.";"; + $neworder->notes .= " Клиент:" . $shoporder->firstname . ' ' . $shoporder->lastname . ";"; + if (strlen($shoporder->email) > 0) + $neworder->notes .= " Email:" . $shoporder->email . ";"; + if (strlen($shoporder->telephone) > 0) + $neworder->notes .= " Тел:" . $shoporder->telephone . ";"; + $neworder->notes .= " Адрес:" . $shoporder->shipping_city . ' ' . $shoporder->shipping_address_1 . ";"; + $neworder->notes .= " Комментарий:" . $shoporder->comment . ";"; $neworder->save(); $neworder->updateStatus(Document::STATE_NEW); - + $i++; } $this->setInfo("Импортировано {$i} заказов"); - + $this->_neworders = array(); $this->neworderslist->Reload(); } - - + public function onRefresh($sender) { - - $this->_eorders = Document::find("meta_name='Order' and content like '%0%' and state <> ". Document::STATE_NEW); - $this->updateform->orderslist->Reload(); + + $this->_eorders = Document::find("meta_name='Order' and content like '%0%' and state <> " . Document::STATE_NEW); + $this->updateform->orderslist->Reload(); } - - - public function expRow($row){ + + public function expRow($row) { $order = $row->getDataItem(); - $row->add(new CheckBox('ch', new Prop($order,'ch') )); + $row->add(new CheckBox('ch', new Prop($order, 'ch'))); $row->add(new Label('number2', $order->document_number)); $row->add(new Label('number3', $order->headerdata['ocorder'])); $row->add(new Label('date2', date('Y-m-d', $order->document_date))); $row->add(new Label('amount2', $order->amount)); $row->add(new Label('customer2', $order->headerdata['occlient'])); $row->add(new Label('state', Document::getStateName($order->state))); - } - - public function exportOnSubmit($sender) { - $modules = System::getOptions("modules"); - - $st=$this->updateform->estatus->getValue(); - if($st==0) { - $this->setError('Не выбран статус'); - return; - } - $elist = array(); - foreach($this->_eorders as $order) { - if($order->ch == false)continue; - $elist[$order->headerdata['ocorder']] =$st; - } - if(count($elist)==0) { - $this->setError('Не выбран ни один ордер'); - return; - } - $data= json_encode($elist) ; - + + public function exportOnSubmit($sender) { + $modules = System::getOptions("modules"); + + $st = $this->updateform->estatus->getValue(); + if ($st == 0) { + $this->setError('Не выбран статус'); + return; + } + $elist = array(); + foreach ($this->_eorders as $order) { + if ($order->ch == false) + continue; + $elist[$order->headerdata['ocorder']] = $st; + } + if (count($elist) == 0) { + $this->setError('Не выбран ни один ордер'); + return; + } + $data = json_encode($elist); + $fields = array( 'data' => $data ); $url = $modules['ocsite'] . '/index.php?route=api/zstore/updateorder&' . System::getSession()->octoken; $json = Helper::do_curl_request($url, $fields); - if($json ===false) return; - $data = json_decode($json,true); - + if ($json === false) + return; + $data = json_decode($json, true); + if ($data['error'] != "") { $this->setError($data['error']); return; } - $this->setSuccess("Обновлено ".count($elist)." заказов"); - - - foreach($this->_eorders as $order) { - if($order->ch == false)continue; - $order->headerdata['ocorderback'] = 1; - $order->save(); - } - - - $this->_eorders = Document::find("meta_name='Order' and content like '%0%' and state <> ". Document::STATE_NEW); - $this->updateform->orderslist->Reload(); - } + $this->setSuccess("Обновлено " . count($elist) . " заказов"); + + + foreach ($this->_eorders as $order) { + if ($order->ch == false) + continue; + $order->headerdata['ocorderback'] = 1; + $order->save(); + } + + + $this->_eorders = Document::find("meta_name='Order' and content like '%0%' and state <> " . Document::STATE_NEW); + $this->updateform->orderslist->Reload(); + } + } diff --git a/www/app/shop/basket.php b/www/app/modules/shop/basket.php similarity index 97% rename from www/app/shop/basket.php rename to www/app/modules/shop/basket.php index 11826877c..33ef1d48a 100644 --- a/www/app/shop/basket.php +++ b/www/app/modules/shop/basket.php @@ -1,6 +1,6 @@ checkDelete(); - } - - public function checkDelete() { - $conn = \ZDB\DB::getConnect(); - $sql = " select count(*) from store_stock where item_id = {$this->item_id}"; + $sql = " select count(*) from shop_products where manufacturer_id = {$this->manufacturer_id}"; $cnt = $conn->GetOne($sql); - return ($cnt > 0) ? false : true; + return ($cnt > 0) ? "Производитель используется в товарах" : ""; } } diff --git a/www/app/shop/entity/order.php b/www/app/modules/shop/entity/order.php similarity index 98% rename from www/app/shop/entity/order.php rename to www/app/modules/shop/entity/order.php index 3eb4e7475..06ac5be4c 100644 --- a/www/app/shop/entity/order.php +++ b/www/app/modules/shop/entity/order.php @@ -1,6 +1,6 @@ checkDelete()) - return false; + $conn = \ZDB\DB::getConnect(); + $sql = " select count(*) from documents_view where meta_name='Order' and content like '%{$this->product_id}%' "; + $cnt = $conn->GetOne($sql); + return ($cnt > 0) ? "Товар уже использован в заказах" : ""; + } + + public function afterDelete() { $conn = \ZCL\DB\DB::getConnect(); $conn->Execute("delete from shop_attributevalues where product_id=" . $this->product_id); \App\Entity\Image::delete($this->image_id); } - public function checkDelete() { - - $conn = \ZDB\DB::getConnect(); - $sql = " select count(*) from documents_view where meta_name='Order' and content like '%{$this->product_id}%' "; - $cnt = $conn->GetOne($sql); - return ($cnt > 0) ? false : true; - } - /** * Возвращает список аттрибутов со значениями * @@ -118,7 +115,7 @@ public function getAttrList() { $conn = \ZCL\DB\DB::getConnect(); //$attrlist = ProductAttribute::find("group_id=" . $this->group_id); - $attrlist = \App\Shop\Helper::getProductAttributeListByGroup($this->group_id); + $attrlist = \App\Modules\Shop\Helper::getProductAttributeListByGroup($this->group_id); $ret = array(); $attrvalues = array(); diff --git a/www/app/shop/entity/productattribute.php b/www/app/modules/shop/entity/productattribute.php similarity index 89% rename from www/app/shop/entity/productattribute.php rename to www/app/modules/shop/entity/productattribute.php index d95e81125..4ead8c131 100644 --- a/www/app/shop/entity/productattribute.php +++ b/www/app/modules/shop/entity/productattribute.php @@ -1,6 +1,6 @@ value = ''; } - protected function beforeDelete() { + protected function afterDelete() { $conn = \ZCL\DB\DB::getConnect(); $conn->Execute("delete from shop_attributevalues where attribute_id=" . $this->attribute_id); $conn->Execute("delete from shop_attributes_order where attr_id=" . $this->attribute_id); diff --git a/www/app/shop/entity/productcomment.php b/www/app/modules/shop/entity/productcomment.php similarity index 93% rename from www/app/shop/entity/productcomment.php rename to www/app/modules/shop/entity/productcomment.php index 3fc3b5504..67c20d958 100644 --- a/www/app/shop/entity/productcomment.php +++ b/www/app/modules/shop/entity/productcomment.php @@ -1,6 +1,6 @@ group_id}"; + $cnt = $conn->GetOne($sql); + return ($cnt > 0) ? "Нельзя удалять используемую группу" : ""; + } + + protected function afterDelete() { $conn = \ZCL\DB\DB::getConnect(); $conn->Execute("delete from shop_attributes where group_id =" . $this->group_id); foreach ($this->images as $image_id) { diff --git a/www/app/shop/helper.php b/www/app/modules/shop/helper.php similarity index 98% rename from www/app/shop/helper.php rename to www/app/modules/shop/helper.php index 79067b1c8..128bf476f 100644 --- a/www/app/shop/helper.php +++ b/www/app/modules/shop/helper.php @@ -1,11 +1,11 @@ _tvars["islogined"] = $user->user_id > 0; - $this->add(new \Zippy\Html\Link\BookmarkableLink('shopcart', "/index.php?p=/App/Shop/Pages/Order"))->setVisible(false); - $this->add(new \Zippy\Html\Link\BookmarkableLink('showcompare', "/index.php?p=/App/Shop/Pages/Compare"))->setVisible(false); + $this->add(new \Zippy\Html\Link\BookmarkableLink('shopcart', "/index.php?p=/App/Modules/Shop/Pages/Order"))->setVisible(false); + $this->add(new \Zippy\Html\Link\BookmarkableLink('showcompare', "/index.php?p=/App/Modules/Shop/Pages/Compare"))->setVisible(false); $this->op = System::getOptions("shop"); @@ -51,8 +51,8 @@ final protected function isError() { } protected function beforeRender() { - $this->shopcart->setVisible(\App\Shop\Basket::getBasket()->isEmpty() == false); - $this->showcompare->setVisible(\App\Shop\CompareList::getCompareList()->isEmpty() == false); + $this->shopcart->setVisible(\App\Modules\Shop\Basket::getBasket()->isEmpty() == false); + $this->showcompare->setVisible(\App\Modules\Shop\CompareList::getCompareList()->isEmpty() == false); } protected function afterRender() { diff --git a/www/app/shop/pages/catalog.php b/www/app/modules/shop/pages/catalog.php similarity index 94% rename from www/app/shop/pages/catalog.php rename to www/app/modules/shop/pages/catalog.php index ebef37024..674d6a578 100644 --- a/www/app/shop/pages/catalog.php +++ b/www/app/modules/shop/pages/catalog.php @@ -1,6 +1,6 @@ sfilter->add(new ClickLink('sclear'))->onClick($this, 'onSClear'); $this->sfilter->add(new ManufacturerList('mlist')); - foreach (\App\Shop\Entity\Manufacturer::find("manufacturer_id in(select manufacturer_id from shop_products where deleted <> 1 and group_id={$this->group_id})", "manufacturername") as $key => $value) { + foreach (\App\Modules\Shop\Entity\Manufacturer::find("manufacturer_id in(select manufacturer_id from shop_products where deleted <> 1 and group_id={$this->group_id})", "manufacturername") as $key => $value) { $this->sfilter->mlist->AddCheckBox($key, false, $value->manufacturername); } $this->sfilter->add(new DataView('attrlist', new ArrayDataSource(Helper::getProductSearchAttributeListByGroup($this->group_id)), $this, 'attrlistOnRow'))->Reload(); @@ -80,7 +80,7 @@ public function __construct($id) { } } $this->add(new Panel("recentlyp"))->setVisible(count($ra) > 0); - $this->recentlyp->add(new DataView('rlist', new EntityDataSource("\\App\\Shop\\Entity\\Product", " product_id in (" . implode(",", $ra) . ")"), $this, 'rOnRow')); + $this->recentlyp->add(new DataView('rlist', new EntityDataSource("\\App\\Modules\\Shop\\Entity\\Product", " product_id in (" . implode(",", $ra) . ")"), $this, 'rOnRow')); if (count($ra) > 0) { $this->recentlyp->rlist->Reload(); } @@ -110,12 +110,12 @@ public function plistOnRow($row) { public function oncartdel($sender) { $item = $sender->getOwner()->getDataItem(); - \App\Shop\Basket::getBasket()->deleteProduct($item->product_id); + \App\Modules\Shop\Basket::getBasket()->deleteProduct($item->product_id); } public function oncompdel($sender) { $item = $sender->getOwner()->getDataItem(); - \App\Shop\CompareList::getCompareList()->deleteProduct($item->product_id); + \App\Modules\Shop\CompareList::getCompareList()->deleteProduct($item->product_id); } public function rOnRow($row) { @@ -138,7 +138,7 @@ public function OnBuy($sender) { $product = $sender->getOwner()->getDataItem(); $product->quantity = 1; - \App\Shop\Basket::getBasket()->addProduct($product); + \App\Modules\Shop\Basket::getBasket()->addProduct($product); $this->setSuccess("Товар добавлен в корзину"); $this->resetURL(); diff --git a/www/app/shop/pages/compare.php b/www/app/modules/shop/pages/compare.php similarity index 94% rename from www/app/shop/pages/compare.php rename to www/app/modules/shop/pages/compare.php index 3b2059476..e56b0275b 100644 --- a/www/app/shop/pages/compare.php +++ b/www/app/modules/shop/pages/compare.php @@ -1,9 +1,9 @@ deleteProduct($params[0]); if ($comparelist->isEmpty()) { $filter = \App\Filter::getFilter("ProductCatalog"); - App::Redirect("\\App\\Shop\\Pages\\Catalog", $filter->group_id); + App::Redirect("\\App\\Modules\\Shop\\Pages\\Catalog", $filter->group_id); } } diff --git a/www/app/shop/pages/contact.php b/www/app/modules/shop/pages/contact.php similarity index 97% rename from www/app/shop/pages/contact.php rename to www/app/modules/shop/pages/contact.php index c61be87f3..fae380e5b 100644 --- a/www/app/shop/pages/contact.php +++ b/www/app/modules/shop/pages/contact.php @@ -1,6 +1,6 @@ modules, 'shop') === false && System::getUser()->userlogin != 'admin'){ - System::setErrorMsg('Нет права доступа к этой странице'); - App::RedirectHome(); + + if (strpos(System::getUser()->modules, 'shop') === false && System::getUser()->userlogin != 'admin') { + System::setErrorMsg('Нет права доступа к этой странице'); + App::RedirectHome(); return; } @@ -161,12 +161,12 @@ public function OnRenameGroup($sender) { } public function OnDelGroup($sender) { - $pcnt = Product::findCnt("group_id=" . $this->group->group_id); - if ($pcnt > 0) { - $this->setError('Граппа с товарами!'); + + $del = ProductGroup::delete($this->group->group_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - ProductGroup::delete($this->group->group_id); $this->group = null; $this->ReloadTree(); } diff --git a/www/app/shop/pages/main.php b/www/app/modules/shop/pages/main.php similarity index 79% rename from www/app/shop/pages/main.php rename to www/app/modules/shop/pages/main.php index 75e42f953..241f26377 100644 --- a/www/app/shop/pages/main.php +++ b/www/app/modules/shop/pages/main.php @@ -1,15 +1,15 @@ add(new Panel("subcatlistp")); $this->subcatlistp->setVisible($id > 0); - $this->subcatlistp->add(new DataView("subcatlist", new EntityDataSource("\\App\\Shop\\Entity\\ProductGroup", "parent_id=" . $id), $this, 'OnCatRow')); + $this->subcatlistp->add(new DataView("subcatlist", new EntityDataSource("\\App\\Modules\\Shop\\Entity\\ProductGroup", "parent_id=" . $id), $this, 'OnCatRow')); if ($id > 0) $this->subcatlistp->subcatlist->Reload(); $this->add(new Panel("newlistp")); - $this->newlistp->add(new DataView("newlist", new EntityDataSource("\\App\\Shop\\Entity\\Product", "", "product_id desc", 12), $this, 'OnNewRow'))->Reload(); + $this->newlistp->add(new DataView("newlist", new EntityDataSource("\\App\\Modules\\Shop\\Entity\\Product", "", "product_id desc", 12), $this, 'OnNewRow'))->Reload(); } public function OnCatRow($datarow) { diff --git a/www/app/shop/pages/manufacturers.php b/www/app/modules/shop/pages/manufacturers.php similarity index 86% rename from www/app/shop/pages/manufacturers.php rename to www/app/modules/shop/pages/manufacturers.php index d3a478f0c..3a35a7042 100644 --- a/www/app/shop/pages/manufacturers.php +++ b/www/app/modules/shop/pages/manufacturers.php @@ -1,12 +1,12 @@ modules, 'shop') === false && System::getUser()->userlogin != 'admin'){ - System::setErrorMsg('Нет права доступа к этой странице'); - App::RedirectHome(); + if (strpos(System::getUser()->modules, 'shop') === false && System::getUser()->userlogin != 'admin') { + System::setErrorMsg('Нет права доступа к этой странице'); + App::RedirectHome(); return; } $panellist = $this->add(new \Zippy\Html\Panel('list')); - $panellist->add(new DataView("manufacturerslist", new \ZCL\DB\EntityDataSource('\App\Shop\Entity\Manufacturer'), $this, 'OnAddRow')); + $panellist->add(new DataView("manufacturerslist", new \ZCL\DB\EntityDataSource('\App\Modules\Shop\Entity\Manufacturer'), $this, 'OnAddRow')); $panellist->add(new \Zippy\Html\Link\ClickLink('addnew', $this, 'OnAddClick')); @@ -41,11 +41,12 @@ public function __construct() { public function OnDeleteClick($sender) { $item = $sender->getOwner()->getDataItem(); - if (false == $item->checkDelete()) { - $this->setError("Этот бренд уже используется"); + + $del = Manufacturer::delete($item->manufacturer_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - Manufacturer::delete($item->manufacturer_id); $this->list->manufacturerslist->Reload(); } diff --git a/www/app/shop/pages/options.php b/www/app/modules/shop/pages/options.php similarity index 94% rename from www/app/shop/pages/options.php rename to www/app/modules/shop/pages/options.php index c63a57869..49c3df2c0 100644 --- a/www/app/shop/pages/options.php +++ b/www/app/modules/shop/pages/options.php @@ -1,6 +1,6 @@ modules, 'shop') === false && System::getUser()->userlogin != 'admin'){ - System::setErrorMsg('Нет права доступа к этой странице'); - App::RedirectHome(); + if (strpos(System::getUser()->modules, 'shop') === false && System::getUser()->userlogin != 'admin') { + System::setErrorMsg('Нет права доступа к этой странице'); + App::RedirectHome(); return; } diff --git a/www/app/shop/pages/order.php b/www/app/modules/shop/pages/order.php similarity index 95% rename from www/app/shop/pages/order.php rename to www/app/modules/shop/pages/order.php index 6df30360b..aea18ac7b 100644 --- a/www/app/shop/pages/order.php +++ b/www/app/modules/shop/pages/order.php @@ -1,6 +1,6 @@ basketlist = Basket::getBasket()->list; if (Basket::getBasket()->isEmpty()) { - App::Redirect("\\App\\Shop\\Pages\\Catalog", 0); + App::Redirect("\\App\\Modules\\Shop\\Pages\\Catalog", 0); } else { $this->OnUpdate($this); } @@ -164,7 +164,7 @@ public function OnSave($sender) { public function OnAddRow(\Zippy\Html\DataList\DataRow $datarow) { $item = $datarow->getDataItem(); $datarow->setDataItem($item); - $datarow->add(new \Zippy\Html\Link\RedirectLink('pname', '\App\Shop\Pages\ProductView', $item->product_id))->setValue($item->productname); + $datarow->add(new \Zippy\Html\Link\RedirectLink('pname', '\App\Modules\Shop\Pages\ProductView', $item->product_id))->setValue($item->productname); $datarow->add(new Label('price', $item->price)); $datarow->add(new TextInput('quantity', new \Zippy\Binding\PropertyBinding($item, 'quantity'))); $datarow->add(new \Zippy\Html\Link\ClickLink('delete', $this, 'OnDelete')); diff --git a/www/app/shop/pages/productlist.php b/www/app/modules/shop/pages/productlist.php similarity index 95% rename from www/app/shop/pages/productlist.php rename to www/app/modules/shop/pages/productlist.php index 24cdf491c..f8cc83907 100644 --- a/www/app/shop/pages/productlist.php +++ b/www/app/modules/shop/pages/productlist.php @@ -1,6 +1,6 @@ modules, 'shop') === false && System::getUser()->userlogin != 'admin'){ - System::setErrorMsg('Нет права доступа к этой странице'); - App::RedirectHome(); + if (strpos(System::getUser()->modules, 'shop') === false && System::getUser()->userlogin != 'admin') { + System::setErrorMsg('Нет права доступа к этой странице'); + App::RedirectHome(); return; } @@ -61,7 +61,7 @@ public function __construct() { $this->listpanel->add(new Form('searchform'))->onSubmit($this, 'searchformOnSubmit'); $this->listpanel->searchform->add(new TextInput('skeyword')); $this->listpanel->searchform->add(new CheckBox('sstatus')); - $this->listpanel->searchform->add(new DropDownChoice('smanuf', \App\Shop\Entity\Manufacturer::findArray('manufacturername', '', 'manufacturername'))); + $this->listpanel->searchform->add(new DropDownChoice('smanuf', \App\Modules\Shop\Entity\Manufacturer::findArray('manufacturername', '', 'manufacturername'))); $this->listpanel->searchform->add(new ClickLink('sclear'))->onClick($this, 'onSClear'); $this->listpanel->add(new Form('sortform')); $this->listpanel->sortform->add(new DropDownChoice('sorting'))->onChange($this, 'sortingOnChange'); @@ -84,8 +84,8 @@ public function __construct() { $editform->add(new TextArea('edescshort')); $editform->add(new TextArea('edescdet')); - $editform->add(new DropDownChoice('emanuf', \App\Shop\Entity\Manufacturer::findArray('manufacturername', '', 'manufacturername'))); - $editform->add(new DropDownChoice('egroup', \App\Shop\Entity\ProductGroup::findArray('groupname', 'group_id not in (select parent_id from shop_productgroups)', 'groupname'))); + $editform->add(new DropDownChoice('emanuf', \App\Modules\Shop\Entity\Manufacturer::findArray('manufacturername', '', 'manufacturername'))); + $editform->add(new DropDownChoice('egroup', \App\Modules\Shop\Entity\ProductGroup::findArray('groupname', 'group_id not in (select parent_id from shop_productgroups)', 'groupname'))); @@ -310,11 +310,12 @@ public function bcancelOnClick($sender) { } public function bdeleteOnClick($sender) { - if ($this->product->checkDelete() == false) { - $this->setError('Продукт уже используется'); + + $del = Product::delete($this->product->product_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - Product::delete($this->product->product_id); $this->listpanel->plist->Reload(); $this->editpanel->setVisible(false); $this->listpanel->setVisible(true); diff --git a/www/app/shop/pages/productview.php b/www/app/modules/shop/pages/productview.php similarity index 94% rename from www/app/shop/pages/productview.php rename to www/app/modules/shop/pages/productview.php index d8d8ae54f..17a572ba0 100644 --- a/www/app/shop/pages/productview.php +++ b/www/app/modules/shop/pages/productview.php @@ -1,16 +1,16 @@ add(new \Zippy\Html\DataList\DataView('attributelist', new \Zippy\Html\DataList\ArrayDataSource($list), $this, 'OnAddAttributeRow'))->Reload(); $this->add(new ClickLink('buy', $this, 'OnBuy')); $this->add(new ClickLink('addtocompare', $this, 'OnAddCompare')); - $this->add(new RedirectLink('compare', "\\App\\Shop\\Pages\\Compare"))->setVisible(false); + $this->add(new RedirectLink('compare', "\\App\\Modules\\Shop\\Pages\\Compare"))->setVisible(false); $form = $this->add(new \Zippy\Html\Form\Form('formcomment')); $form->onSubmit($this, 'OnComment'); @@ -125,7 +125,7 @@ public function OnAddAttributeRow(\Zippy\Html\DataList\DataRow $datarow) { public function OnBuy($sender) { $product = Product::load($this->product_id); $product->quantity = 1; - \App\Shop\Basket::getBasket()->addProduct($product); + \App\Modules\Shop\Basket::getBasket()->addProduct($product); $this->setSuccess("Товар добавлен в корзину"); //$this->resetURL(); App::RedirectURI('/pcat/' . $product->group_id); @@ -134,7 +134,7 @@ public function OnBuy($sender) { //добавить к форме сравнения public function OnAddCompare($sender) { $product = Product::load($this->product_id); - $comparelist = \App\Shop\CompareList::getCompareList(); + $comparelist = \App\Modules\Shop\CompareList::getCompareList(); if (false == $comparelist->addProduct($product)) { $this->setWarn('Добавлять можно только товары с одинаковой категорией'); return; @@ -146,7 +146,7 @@ public function OnAddCompare($sender) { public function OnComment($sender) { - $comment = new \App\Shop\Entity\ProductComment(); + $comment = new \App\Modules\Shop\Entity\ProductComment(); $comment->product_id = $this->product_id; $comment->author = $this->formcomment->nick->getText(); $comment->comment = $this->formcomment->comment->getText(); @@ -172,7 +172,7 @@ protected function beforeRender() { App::addJavaScript("openComments();", true); $this->gotocomment = false; } - if (\App\Shop\CompareList::getCompareList()->hasProsuct($this->product_id)) { + if (\App\Modules\Shop\CompareList::getCompareList()->hasProsuct($this->product_id)) { $this->compare->setVisible(true); $this->addtocompare->setVisible(false); } else { diff --git a/www/app/pages/base.php b/www/app/pages/base.php index 1cfccb011..27dac54fb 100644 --- a/www/app/pages/base.php +++ b/www/app/pages/base.php @@ -2,14 +2,14 @@ namespace App\Pages; -use Zippy\Binding\PropertyBinding; -use Zippy\Html\Label; -use Zippy\Html\Panel; -use Zippy\Html\Link\ClickLink; -use App\Helper; -use App\Application as App; -use App\System; -use App\Entity\User; +use \Zippy\Binding\PropertyBinding; +use \Zippy\Html\Label; +use \Zippy\Html\Panel; +use \Zippy\Html\Link\ClickLink; +use \App\Helper; +use \App\Application as App; +use \App\System; +use \App\Entity\User; class Base extends \Zippy\Html\WebPage { @@ -54,15 +54,17 @@ public function __construct($params = null) { $options = System::getOptions('common'); $this->_tvars["useset"] = $options['useset'] == 1; + $this->_tvars["usesnumber"] = $options['usesnumber'] == 1; $this->_tvars["smart"] = Helper::generateSmartMenu(); $this->_tvars["picontent"] = $pi; - - - + + + $this->_tvars["shop"] = $_config['modules']['shop'] == 1; $this->_tvars["ocstore"] = $_config['modules']['ocstore'] == 1; - + //если включен хоть один модуль + $this->_tvars["modules"] = $this->_tvars["shop"] || $this->_tvars["ocstore"]; } public function LogoutClick($sender) { diff --git a/www/app/pages/doc/goodsissue.php b/www/app/pages/doc/goodsissue.php index 4f6c43368..1ab013efd 100644 --- a/www/app/pages/doc/goodsissue.php +++ b/www/app/pages/doc/goodsissue.php @@ -19,6 +19,7 @@ use \App\Entity\Item; use \App\Entity\Stock; use \App\Entity\Store; +use \App\Entity\MoneyFund; use \App\Helper as H; use \App\System; use \App\Application as App; @@ -45,7 +46,9 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new Date('sent_date')); $this->docform->add(new Date('delivery_date')); $this->docform->add(new CheckBox('planned')); - $this->docform->add(new CheckBox('payed')); + $this->docform->add(new DropDownChoice('payment', MoneyFund::getList(), H::getDefMF()))->onChange($this, "onMF"); + $this->docform->add(new TextInput('paynotes')); + $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore()))->onChange($this, 'OnChangeStore'); @@ -100,7 +103,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editcust->add(new SubmitButton('savecust'))->onClick($this, 'savecustOnClick'); if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->planned->setChecked($this->_doc->headerdata['planned']); @@ -113,6 +116,8 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->ship_address->setText($this->_doc->headerdata['ship_address']); $this->docform->emp->setValue($this->_doc->headerdata['emp_id']); $this->docform->delivery->setValue($this->_doc->headerdata['delivery']); + $this->docform->payment->setValue($this->_doc->headerdata['payment']); + $this->docform->paynotes->setText($this->_doc->headerdata['paynotes']); $this->docform->store->setValue($this->_doc->headerdata['store']); $this->docform->customer->setKey($this->_doc->customer_id); @@ -186,13 +191,18 @@ public function __construct($docid = 0, $basedocid = 0) { } } } - $this->calcTotal(); + $this->calcTotal(); $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_tovarlist')), $this, 'detailOnRow'))->Reload(); if (false == \App\ACL::checkShowDoc($this->_doc)) return; - $this->docform->payed->setChecked($this->_doc->datatag == $this->_doc->amount); $this->calcTotal(); $this->OnDelivery($this->docform->delivery); + $this->onMF($this->docform->payment); + } + + public function onMF($sender) { + $mf = $sender->getValue(); + $this->docform->paynotes->setVisible($mf > 0); } public function detailOnRow($row) { @@ -202,6 +212,8 @@ public function detailOnRow($row) { $row->add(new Label('partion', $item->partion)); $row->add(new Label('code', $item->item_code)); $row->add(new Label('msr', $item->msr)); + $row->add(new Label('snumber', $item->snumber)); + $row->add(new Label('sdate', $item->sdate > 0 ? date('Y-m-d', $item->sdate) : '')); $row->add(new Label('quantity', H::fqty($item->quantity))); $row->add(new Label('price', $item->price)); @@ -261,8 +273,8 @@ public function saverowOnClick($sender) { $stock = Stock::load($id); $stock->quantity = $this->editdetail->editquantity->getText(); - $qstock=$this->editdetail->qtystock->getText(); - if($stock->quantity > $qstock) { + $qstock = $this->editdetail->qtystock->getText(); + if ($stock->quantity > $qstock) { $this->setWarn('Недостаточное количество на складе'); } $stock->price = $this->editdetail->editprice->getText(); @@ -311,34 +323,32 @@ public function savedocOnClick($sender) { $order = Document::load($this->_order_id); $this->calcTotal(); - $old = $this->_doc->cast(); - - $this->_doc->headerdata = array( - 'order' => $this->docform->order->getText(), - 'ship_address' => $this->docform->ship_address->getText(), - 'ship_number' => $this->docform->ship_number->getText(), - 'delivery' => $this->docform->delivery->getValue(), - 'planned' => $this->docform->planned->isChecked() ? 1 : 0, - 'store' => $this->docform->store->getValue(), - 'emp_id' => $this->docform->emp->getValue(), - 'emp_name' => $this->docform->emp->getValueName(), - 'pricetype' => $this->docform->pricetype->getValue(), - 'pricetypename' => $this->docform->pricetype->getValueName(), - 'delivery_date' => $this->docform->delivery_date->getDate(), - 'sent_date' => $this->docform->sent_date->getDate(), - 'order_id' => $this->_order_id - ); + + + $this->_doc->headerdata['order'] = $this->docform->order->getText(); + $this->_doc->headerdata['ship_address'] = $this->docform->ship_address->getText(); + $this->_doc->headerdata['ship_number'] = $this->docform->ship_number->getText(); + $this->_doc->headerdata['delivery'] = $this->docform->delivery->getValue(); + $this->_doc->headerdata['planned'] = $this->docform->planned->isChecked() ? 1 : 0; + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + $this->_doc->headerdata['emp_id'] = $this->docform->emp->getValue(); + $this->_doc->headerdata['emp_name'] = $this->docform->emp->getValueName(); + $this->_doc->headerdata['pricetype'] = $this->docform->pricetype->getValue(); + $this->_doc->headerdata['pricetypename'] = $this->docform->pricetype->getValueName(); + $this->_doc->headerdata['delivery_date'] = $this->docform->delivery_date->getDate(); + $this->_doc->headerdata['sent_date'] = $this->docform->sent_date->getDate(); + $this->_doc->headerdata['order_id'] = $this->_order_id; + $this->_doc->headerdata['payment'] = $this->docform->payment->getValue(); + $this->_doc->headerdata['paynotes'] = $this->docform->paynotes->getText(); + + $this->_doc->detaildata = array(); foreach ($this->_tovarlist as $tovar) { $this->_doc->detaildata[] = $tovar->getData(); } $this->_doc->amount = $this->docform->total->getText(); - if ($this->docform->payed->isChecked() == true && $this->_doc->datatag < $this->_doc->amount) { - $this->_doc->addPayment(System::getUser()->user_id, $this->_doc->amount - $this->_doc->datatag); - $this->_doc->datatag = $this->_doc->amount; - } $isEdited = $this->_doc->document_id > 0; diff --git a/www/app/pages/doc/goodsreceipt.php b/www/app/pages/doc/goodsreceipt.php index 498f97d02..72cd2dc63 100644 --- a/www/app/pages/doc/goodsreceipt.php +++ b/www/app/pages/doc/goodsreceipt.php @@ -2,25 +2,26 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Customer; -use App\Entity\Doc\Document; -use App\Entity\Item; -use App\Entity\Store; -use App\Helper as H; -use App\System; -use App\Application as App; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Customer; +use \App\Entity\Doc\Document; +use \App\Entity\Item; +use \App\Entity\Store; +use \App\Entity\MoneyFund; +use \App\Helper as H; +use \App\System; +use \App\Application as App; /** * Страница ввода приходной накладной @@ -36,10 +37,8 @@ class GoodsReceipt extends \App\Pages\Base { public function __construct($docid = 0, $basedocid = 0) { parent::__construct(); - $common = System::getOptions("common"); - $this->add(new Form('docform')); $this->docform->add(new TextInput('document_number')); $this->docform->add(new Date('document_date'))->setDate(time()); @@ -48,14 +47,15 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())); $this->docform->add(new TextInput('notes')); $this->docform->add(new CheckBox('planned')); - $this->docform->add(new CheckBox('payed')); + + $this->docform->add(new DropDownChoice('payment', MoneyFund::getList(), H::getDefMF()))->onChange($this, "onMF"); + $this->docform->add(new TextInput('paynotes')); $this->docform->add(new DropDownChoice('val', array(1 => 'Гривна', 2 => 'Доллар', 3 => 'Евро', 4 => 'Рубль')))->onChange($this, "onVal", true); $this->docform->add(new Label('course', 'Курс 1')); $this->docform->val->setVisible($common['useval'] == true); $this->docform->course->setVisible($common['useval'] == true); - $this->docform->add(new SubmitLink('addrow'))->onClick($this, 'addrowOnClick'); $this->docform->add(new Button('backtolist'))->onClick($this, 'backtolistOnClick'); $this->docform->add(new SubmitButton('savedoc'))->onClick($this, 'savedocOnClick'); @@ -68,6 +68,8 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editdetail->add(new SubmitLink('addnewitem'))->onClick($this, 'addnewitemOnClick'); $this->editdetail->add(new TextInput('editquantity'))->setText("1"); $this->editdetail->add(new TextInput('editprice')); + $this->editdetail->add(new TextInput('editsnumber')); + $this->editdetail->add(new Date('editsdate')); $this->editdetail->add(new Button('cancelrow'))->onClick($this, 'cancelrowOnClick'); $this->editdetail->add(new SubmitButton('saverow'))->onClick($this, 'saverowOnClick'); @@ -79,10 +81,8 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editnewitem->add(new Button('cancelnewitem'))->onClick($this, 'cancelnewitemOnClick'); $this->editnewitem->add(new SubmitButton('savenewitem'))->onClick($this, 'savenewitemOnClick'); - - if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->planned->setChecked($this->_doc->headerdata['planned']); @@ -93,6 +93,8 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->customer->setText($this->_doc->customer_name); $this->docform->store->setValue($this->_doc->headerdata['store']); + $this->docform->payment->setValue($this->_doc->headerdata['payment']); + $this->docform->paynotes->setText($this->_doc->headerdata['paynotes']); foreach ($this->_doc->detaildata as $item) { $item = new Item($item); @@ -135,17 +137,21 @@ public function __construct($docid = 0, $basedocid = 0) { $item = new Item($_item); $this->_itemlist[$item->item_id] = $item; } - } } } } - $this->calcTotal(); + $this->calcTotal(); $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_itemlist')), $this, 'detailOnRow'))->Reload(); if (false == \App\ACL::checkShowDoc($this->_doc)) return; - $this->docform->payed->setChecked($this->_doc->datatag == $this->_doc->amount); + $this->onMF($this->docform->payment); + } + + public function onMF($sender) { + $mf = $sender->getValue(); + $this->docform->paynotes->setVisible($mf > 0); } public function onVal($sender) { @@ -167,12 +173,13 @@ public function onVal($sender) { public function detailOnRow($row) { $item = $row->getDataItem(); - $row->add(new Label('item', $item->itemname)); $row->add(new Label('code', $item->item_code)); $row->add(new Label('quantity', H::fqty($item->quantity))); $row->add(new Label('price', $item->price)); $row->add(new Label('msr', $item->msr)); + $row->add(new Label('snumber', $item->snumber)); + $row->add(new Label('sdate', $item->sdate > 0 ? date('Y-m-d', $item->sdate) : '')); $row->add(new Label('amount', round($item->quantity * $item->price))); $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); @@ -188,6 +195,8 @@ public function editOnClick($sender) { $this->editdetail->editquantity->setText($item->quantity); $this->editdetail->editprice->setText($item->price); + $this->editdetail->editsnumber->setText($item->snumber); + $this->editdetail->editsdate->setDate($item->sdate); $this->editdetail->edititem->setKey($item->item_id); @@ -230,11 +239,18 @@ public function saverowOnClick($sender) { $item->quantity = $this->editdetail->editquantity->getText(); $item->price = $this->editdetail->editprice->getText(); + if ($item->price == 0) { $this->setWarn("Не указана цена"); } - - + $item->snumber = $this->editdetail->editsnumber->getText(); + $item->sdate = $this->editdetail->editsdate->getDate(); + if ($item->sdate == false) + $item->sdate = ''; + if (strlen($item->snumber) > 0 && strlen($item->sdate) == 0) { + $this->setError("К серии должна быть введена дата"); + return; + } unset($this->_itemlist[$this->_rowid]); $this->_itemlist[$item->item_id] = $item; $this->editdetail->setVisible(false); @@ -248,6 +264,8 @@ public function saverowOnClick($sender) { $this->editdetail->editquantity->setText("1"); $this->editdetail->editprice->setText(""); + $this->editdetail->editsnumber->setText(""); + $this->editdetail->editsdate->setText(""); } public function cancelrowOnClick($sender) { @@ -265,7 +283,7 @@ public function savedocOnClick($sender) { if ($this->checkForm() == false) { return; } - $old = $this->_doc->cast(); + $this->calcTotal(); $common = System::getOptions("common"); @@ -293,13 +311,15 @@ public function savedocOnClick($sender) { } - $this->_doc->headerdata = array( - 'order' => $this->docform->order->getText(), - 'store' => $this->docform->store->getValue(), - 'planned' => $this->docform->planned->isChecked() ? 1 : 0, - 'total' => $this->docform->total->getText(), - 'order_id' => $this->_order_id - ); + $this->_doc->headerdata['order'] = $this->docform->order->getText(); + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + $this->_doc->headerdata['payment'] = $this->docform->payment->getValue(); + $this->_doc->headerdata['paynotes'] = $this->docform->paynotes->getText(); + $this->_doc->headerdata['planned'] = $this->docform->planned->isChecked() ? 1 : 0; + + $this->_doc->headerdata['order_id'] = $this->_order_id; + + $this->_doc->detaildata = array(); foreach ($this->_itemlist as $item) { $this->_doc->detaildata[] = $item->getData(); @@ -309,14 +329,6 @@ public function savedocOnClick($sender) { $isEdited = $this->_doc->document_id > 0; - - if ($this->docform->payed->isChecked() == true && $this->_doc->datatag < $this->_doc->amount) { - - $this->_doc->addPayment(System::getUser()->getUserName(), $this->_doc->amount); - $this->_doc->datatag = $this->_doc->amount; - } - - $conn = \ZDB\DB::getConnect(); $conn->BeginTrans(); try { @@ -337,9 +349,6 @@ public function savedocOnClick($sender) { } - - - if ($this->_basedocid > 0) { $this->_doc->AddConnectedDoc($this->_basedocid); $this->_basedocid = 0; diff --git a/www/app/pages/doc/incomemoney.php b/www/app/pages/doc/incomemoney.php new file mode 100644 index 000000000..e2d387560 --- /dev/null +++ b/www/app/pages/doc/incomemoney.php @@ -0,0 +1,120 @@ +add(new Form('docform')); + $this->docform->add(new TextInput('document_number')); + $this->docform->add(new Date('document_date', time())); + + $this->docform->add(new DropDownChoice('mfto', MoneyFund::getList(), H::getDefMF())); + $this->docform->add(new TextInput('notes')); + $this->docform->add(new TextInput('amount')); + + $this->docform->add(new SubmitButton('savedoc'))->onClick($this, 'savedocOnClick'); + $this->docform->add(new SubmitButton('execdoc'))->onClick($this, 'savedocOnClick'); + $this->docform->add(new Button('backtolist'))->onClick($this, 'backtolistOnClick'); + + + if ($docid > 0) { //загружаем содержимок документа на страницу + $this->_doc = Document::load($docid)->cast(); + $this->docform->document_number->setText($this->_doc->document_number); + $this->docform->document_date->setDate($this->_doc->document_date); + + $this->docform->mfto->setValue($this->_doc->headerdata['mfto']); + $this->docform->notes->setText($this->_doc->notes); + $this->docform->amount->setText($this->_doc->amount); + } else { + $this->_doc = Document::create('IncomeMoney'); + $this->docform->document_number->setText($this->_doc->nextNumber()); + } + + + if (false == \App\ACL::checkShowDoc($this->_doc)) + return; + } + + public function savedocOnClick($sender) { + + $this->_doc->notes = $this->docform->notes->getText(); + + $this->_doc->headerdata['mfto'] = $this->docform->mfto->getValue(); + $this->_doc->headerdata['mftoname'] = $this->docform->mfto->getValueName(); + + $this->_doc->amount = $this->docform->amount->getText(); + $this->_doc->document_number = trim($this->docform->document_number->getText()); + $this->_doc->document_date = strtotime($this->docform->document_date->getText()); + + if ($this->checkForm() == false) { + return; + } + + $isEdited = $this->_doc->document_id > 0; + + $conn = \ZDB\DB::getConnect(); + $conn->BeginTrans(); + try { + + $this->_doc->save(); + if ($sender->id == 'execdoc') { + if (!$isEdited) + $this->_doc->updateStatus(Document::STATE_NEW); + $this->_doc->updateStatus(Document::STATE_EXECUTED); + } else { + $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW); + } + $conn->CommitTrans(); + App::RedirectBack(); + } catch (\Exception $ee) { + global $logger; + $conn->RollbackTrans(); + $this->setError($ee->getMessage()); + + $logger->error($ee->getMessage() . " Документ " . $this->_doc->meta_desc); + + return; + } + } + + /** + * Валидация формы + * + */ + private function checkForm() { + + if (strlen($this->_doc->document_number) == 0) { + $this->setError("Не введен номер документа"); + } + + if (($this->_doc->amount > 0) == false) { + $this->setError("Не введена сумма"); + } + + return !$this->isError(); + } + +} diff --git a/www/app/pages/doc/moveitem.php b/www/app/pages/doc/moveitem.php index 3fa5da13e..f4cc3800b 100644 --- a/www/app/pages/doc/moveitem.php +++ b/www/app/pages/doc/moveitem.php @@ -2,24 +2,24 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; use \Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Doc\Document; -use App\Entity\Item; -use App\Entity\Stock; -use App\Entity\Store; -use App\Application as App; -use App\Helper as H; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Doc\Document; +use \App\Entity\Item; +use \App\Entity\Stock; +use \App\Entity\Store; +use \App\Application as App; +use \App\Helper as H; /** * Страница ввода перемещения товаров @@ -58,7 +58,7 @@ public function __construct($docid = 0) { $this->editdetail->add(new Button('cancelrow'))->onClick($this, 'cancelrowOnClick'); if ($docid > 0) { //загружаем содержимок документа на страницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->document_date->setDate($this->_doc->document_date); $this->docform->storefrom->setValue($this->_doc->headerdata['storefrom']); @@ -85,6 +85,8 @@ public function detailOnRow($row) { $row->add(new Label('item', $item->itemname)); $row->add(new Label('msr', $item->msr)); + $row->add(new Label('snumber', $item->snumber)); + $row->add(new Label('sdate', $item->sdate > 0 ? date('Y-m-d', $item->sdate) : '')); $row->add(new Label('quantity', H::fqty($item->quantity))); @@ -175,10 +177,12 @@ public function savedocOnClick($sender) { $this->_doc->notes = $this->docform->notes->getText(); - $this->_doc->headerdata = array( - 'storefrom' => $this->docform->storefrom->getValue(), - 'storeto' => $this->docform->storeto->getValue() - ); + $this->_doc->headerdata['storefrom'] = $this->docform->storefrom->getValue(); + $this->_doc->headerdata['storefromname'] = $this->docform->storefrom->getValueName(); + $this->_doc->headerdata['storeto'] = $this->docform->storeto->getValue(); + $this->_doc->headerdata['storetoname'] = $this->docform->storeto->getValueName(); + + $this->_doc->detaildata = array(); foreach ($this->_itemlist as $item) { $this->_doc->detaildata[] = $item->getData(); diff --git a/www/app/pages/doc/movemoney.php b/www/app/pages/doc/movemoney.php new file mode 100644 index 000000000..1e5ac2354 --- /dev/null +++ b/www/app/pages/doc/movemoney.php @@ -0,0 +1,126 @@ +add(new Form('docform')); + $this->docform->add(new TextInput('document_number')); + $this->docform->add(new Date('document_date', time())); + + $this->docform->add(new DropDownChoice('mffrom', MoneyFund::getList(), H::getDefMF())); + $this->docform->add(new DropDownChoice('mfto', MoneyFund::getList(), H::getDefMF())); + $this->docform->add(new TextInput('notes')); + $this->docform->add(new TextInput('amount')); + + $this->docform->add(new SubmitButton('savedoc'))->onClick($this, 'savedocOnClick'); + $this->docform->add(new SubmitButton('execdoc'))->onClick($this, 'savedocOnClick'); + $this->docform->add(new Button('backtolist'))->onClick($this, 'backtolistOnClick'); + + + if ($docid > 0) { //загружаем содержимок документа на страницу + $this->_doc = Document::load($docid)->cast(); + $this->docform->document_number->setText($this->_doc->document_number); + $this->docform->document_date->setDate($this->_doc->document_date); + $this->docform->mffrom->setValue($this->_doc->headerdata['mffrom']); + $this->docform->mfto->setValue($this->_doc->headerdata['mfto']); + $this->docform->notes->setText($this->_doc->notes); + $this->docform->amount->setText($this->_doc->amount); + } else { + $this->_doc = Document::create('MoveMoney'); + $this->docform->document_number->setText($this->_doc->nextNumber()); + } + + + if (false == \App\ACL::checkShowDoc($this->_doc)) + return; + } + + public function savedocOnClick($sender) { + + $this->_doc->notes = $this->docform->notes->getText(); + + $this->_doc->headerdata['mffrom'] = $this->docform->mffrom->getValue(); + $this->_doc->headerdata['mffromname'] = $this->docform->mffrom->getValueName(); + $this->_doc->headerdata['mfto'] = $this->docform->mfto->getValue(); + $this->_doc->headerdata['mftoname'] = $this->docform->mfto->getValueName(); + + $this->_doc->amount = $this->docform->amount->getText(); + $this->_doc->document_number = trim($this->docform->document_number->getText()); + $this->_doc->document_date = strtotime($this->docform->document_date->getText()); + + if ($this->checkForm() == false) { + return; + } + + $isEdited = $this->_doc->document_id > 0; + + $conn = \ZDB\DB::getConnect(); + $conn->BeginTrans(); + try { + + $this->_doc->save(); + if ($sender->id == 'execdoc') { + if (!$isEdited) + $this->_doc->updateStatus(Document::STATE_NEW); + $this->_doc->updateStatus(Document::STATE_EXECUTED); + } else { + $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW); + } + $conn->CommitTrans(); + App::RedirectBack(); + } catch (\Exception $ee) { + global $logger; + $conn->RollbackTrans(); + $this->setError($ee->getMessage()); + + $logger->error($ee->getMessage() . " Документ " . $this->_doc->meta_desc); + + return; + } + } + + /** + * Валидация формы + * + */ + private function checkForm() { + + if (strlen($this->_doc->document_number) == 0) { + $this->setError("Не введен номер документа"); + } + + if ($this->docform->mfto->getValue() == $this->docform->mffrom->getValue()) { + $this->setError("Выбран тот же счет получатель"); + } + if (($this->_doc->amount > 0) == false) { + $this->setError("Не введена сумма"); + } + + return !$this->isError(); + } + +} diff --git a/www/app/pages/doc/order.php b/www/app/pages/doc/order.php index 301ed03f1..85972ba92 100644 --- a/www/app/pages/doc/order.php +++ b/www/app/pages/doc/order.php @@ -91,7 +91,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editcust->add(new SubmitButton('savecust'))->onClick($this, 'savecustOnClick'); if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->document_date->setDate($this->_doc->document_date); @@ -232,24 +232,24 @@ public function savedocOnClick($sender) { } $this->calcTotal(); - $old = $this->_doc->cast(); - - $this->_doc->headerdata['delivery'] = $this->docform->delivery->getValue(); - $this->_doc->headerdata['delivery_name'] = $this->docform->delivery->getValueName(); - $this->_doc->headerdata['address'] = $this->docform->address->getText(); - $this->_doc->headerdata['email'] = $this->docform->email->getText(); - $this->_doc->headerdata['pricetype'] = $this->docform->pricetype->getValue(); - $this->_doc->headerdata['store'] = $this->docform->store->getValue(); - $this->_doc->headerdata['total'] = $this->docform->total->getText(); - - + + + $this->_doc->headerdata['delivery'] = $this->docform->delivery->getValue(); + $this->_doc->headerdata['delivery_name'] = $this->docform->delivery->getValueName(); + $this->_doc->headerdata['address'] = $this->docform->address->getText(); + $this->_doc->headerdata['email'] = $this->docform->email->getText(); + $this->_doc->headerdata['pricetype'] = $this->docform->pricetype->getValue(); + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + + + $this->_doc->detaildata = array(); foreach ($this->_tovarlist as $tovar) { $this->_doc->detaildata[] = $tovar->getData(); } $this->_doc->amount = $this->docform->total->getText(); - //$this->_doc->datatag = $this->_doc->amount; + $isEdited = $this->_doc->document_id > 0; $conn = \ZDB\DB::getConnect(); diff --git a/www/app/pages/doc/ordercust.php b/www/app/pages/doc/ordercust.php index f75799140..34b22ffc5 100644 --- a/www/app/pages/doc/ordercust.php +++ b/www/app/pages/doc/ordercust.php @@ -2,25 +2,25 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Customer; -use App\Entity\Doc\Document; -use App\Entity\Item; -use App\Entity\Store; -use App\Helper as H; -use App\System; -use App\Application as App; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Customer; +use \App\Entity\Doc\Document; +use \App\Entity\Item; +use \App\Entity\Store; +use \App\Helper as H; +use \App\System; +use \App\Application as App; /** * Страница ввода заявки поставщику @@ -74,7 +74,7 @@ public function __construct($docid = 0, $basedocid = 0) { if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->notes->setText($this->_doc->notes); @@ -223,7 +223,7 @@ public function savedocOnClick($sender) { if ($this->checkForm() == false) { return; } - $old = $this->_doc->cast(); + $this->calcTotal(); $common = System::getOptions("common"); @@ -235,9 +235,6 @@ public function savedocOnClick($sender) { } - $this->_doc->headerdata = array( - 'total' => $this->docform->total->getText() - ); $this->_doc->detaildata = array(); foreach ($this->_itemlist as $item) { $this->_doc->detaildata[] = $item->getData(); diff --git a/www/app/pages/doc/outcomemoney.php b/www/app/pages/doc/outcomemoney.php new file mode 100644 index 000000000..d8ca6572e --- /dev/null +++ b/www/app/pages/doc/outcomemoney.php @@ -0,0 +1,120 @@ +add(new Form('docform')); + $this->docform->add(new TextInput('document_number')); + $this->docform->add(new Date('document_date', time())); + + $this->docform->add(new DropDownChoice('mffrom', MoneyFund::getList(), H::getDefMF())); + $this->docform->add(new TextInput('notes')); + $this->docform->add(new TextInput('amount')); + + $this->docform->add(new SubmitButton('savedoc'))->onClick($this, 'savedocOnClick'); + $this->docform->add(new SubmitButton('execdoc'))->onClick($this, 'savedocOnClick'); + $this->docform->add(new Button('backtolist'))->onClick($this, 'backtolistOnClick'); + + + if ($docid > 0) { //загружаем содержимок документа на страницу + $this->_doc = Document::load($docid)->cast(); + $this->docform->document_number->setText($this->_doc->document_number); + $this->docform->document_date->setDate($this->_doc->document_date); + + $this->docform->mfto->setValue($this->_doc->headerdata['mfto']); + $this->docform->notes->setText($this->_doc->notes); + $this->docform->amount->setText($this->_doc->amount); + } else { + $this->_doc = Document::create('OutcomeMoney'); + $this->docform->document_number->setText($this->_doc->nextNumber()); + } + + + if (false == \App\ACL::checkShowDoc($this->_doc)) + return; + } + + public function savedocOnClick($sender) { + + $this->_doc->notes = $this->docform->notes->getText(); + + $this->_doc->headerdata['mffrom'] = $this->docform->mffrom->getValue(); + $this->_doc->headerdata['mffromname'] = $this->docform->mffrom->getValueName(); + + $this->_doc->amount = $this->docform->amount->getText(); + $this->_doc->document_number = trim($this->docform->document_number->getText()); + $this->_doc->document_date = strtotime($this->docform->document_date->getText()); + + if ($this->checkForm() == false) { + return; + } + + $isEdited = $this->_doc->document_id > 0; + + $conn = \ZDB\DB::getConnect(); + $conn->BeginTrans(); + try { + + $this->_doc->save(); + if ($sender->id == 'execdoc') { + if (!$isEdited) + $this->_doc->updateStatus(Document::STATE_NEW); + $this->_doc->updateStatus(Document::STATE_EXECUTED); + } else { + $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW); + } + $conn->CommitTrans(); + App::RedirectBack(); + } catch (\Exception $ee) { + global $logger; + $conn->RollbackTrans(); + $this->setError($ee->getMessage()); + + $logger->error($ee->getMessage() . " Документ " . $this->_doc->meta_desc); + + return; + } + } + + /** + * Валидация формы + * + */ + private function checkForm() { + + if (strlen($this->_doc->document_number) == 0) { + $this->setError("Не введен номер документа"); + } + + if (($this->_doc->amount > 0) == false) { + $this->setError("Не введена сумма"); + } + + return !$this->isError(); + } + +} diff --git a/www/app/pages/doc/prodissue.php b/www/app/pages/doc/prodissue.php index dc9da9dfe..58be986b6 100644 --- a/www/app/pages/doc/prodissue.php +++ b/www/app/pages/doc/prodissue.php @@ -40,7 +40,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new Date('document_date'))->setDate(time()); $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore()))->onChange($this, 'OnChangeStore'); - $this->docform->add(new DropDownChoice('parea', \App\Entity\Prodarea::findArray("pa_name", ""), 0)); + $this->docform->add(new DropDownChoice('parea', \App\Entity\Prodarea::findArray("pa_name", ""), 0)); $this->docform->add(new TextInput('notes')); $this->docform->add(new CheckBox('planned')); @@ -67,14 +67,14 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editdetail->add(new SubmitButton('submitrow'))->onClick($this, 'saverowOnClick'); if ($docid > 0) { //загружаем содержимое документа на страницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->planned->setChecked($this->_doc->headerdata['planned']); $this->docform->document_date->setDate($this->_doc->document_date); $this->docform->store->setValue($this->_doc->headerdata['store']); - $this->docform->parea->setValue($this->_doc->headerdata['parea']); + $this->docform->parea->setValue($this->_doc->headerdata['parea']); $this->docform->notes->setText($this->_doc->notes); @@ -101,6 +101,8 @@ public function detailOnRow($row) { $row->add(new Label('quantity', H::fqty($item->quantity))); $row->add(new Label('price', $item->price)); + $row->add(new Label('snumber', $item->snumber)); + $row->add(new Label('sdate', $item->sdate > 0 ? date('Y-m-d', $item->sdate) : '')); $row->add(new Label('amount', round($item->quantity * $item->price))); $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); @@ -152,11 +154,11 @@ public function saverowOnClick($sender) { $this->setError("Не выбран товар"); return; } - + $stock = Stock::load($id); $stock->quantity = $this->editdetail->editquantity->getText(); - $qstock=$this->editdetail->qtystock->getText(); - if($stock->quantity > $qstock) { + $qstock = $this->editdetail->qtystock->getText(); + if ($stock->quantity > $qstock) { $this->setWarn('Недостаточное количество на складе'); } @@ -199,22 +201,22 @@ public function savedocOnClick($sender) { } $this->calcTotal(); - $old = $this->_doc->cast(); - - $this->_doc->headerdata = array( - 'parea' => $this->docform->parea->getValue(), - 'pareaname' => $this->docform->parea->getValueName(), - 'store' => $this->docform->store->getValue(), - 'planned' => $this->docform->planned->isChecked() ? 1 : 0, - 'total' => $this->docform->total->getText() - ); + + + + $this->_doc->headerdata['parea'] = $this->docform->parea->getValue(); + $this->_doc->headerdata['pareaname'] = $this->docform->parea->getValueName(); + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + $this->_doc->headerdata['planned'] = $this->docform->planned->isChecked() ? 1 : 0; + + $this->_doc->detaildata = array(); foreach ($this->_tovarlist as $tovar) { $this->_doc->detaildata[] = $tovar->getData(); } $this->_doc->amount = $this->docform->total->getText(); - $this->_doc->datatag = $this->_doc->amount; + $this->_doc->payamount = $this->_doc->amount; $isEdited = $this->_doc->document_id > 0; $conn = \ZDB\DB::getConnect(); diff --git a/www/app/pages/doc/prodreceipt.php b/www/app/pages/doc/prodreceipt.php index 7260c0dc4..dddd6a44a 100644 --- a/www/app/pages/doc/prodreceipt.php +++ b/www/app/pages/doc/prodreceipt.php @@ -2,24 +2,24 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Doc\Document; -use App\Entity\Item; -use App\Entity\Store; -use App\Helper as H; -use App\System; -use App\Application as App; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Doc\Document; +use \App\Entity\Item; +use \App\Entity\Store; +use \App\Helper as H; +use \App\System; +use \App\Application as App; /** * Страница ввода оприходование с производства @@ -62,18 +62,20 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editdetail->add(new TextInput('editquantity'))->setText("1"); $this->editdetail->add(new TextInput('editprice')); + $this->editdetail->add(new TextInput('editsnumber')); + $this->editdetail->add(new Date('editsdate')); $this->editdetail->add(new Button('cancelrow'))->onClick($this, 'cancelrowOnClick'); $this->editdetail->add(new SubmitButton('saverow'))->onClick($this, 'saverowOnClick'); if ($docid > 0) { //загружаем содержимое документа на страницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->planned->setChecked($this->_doc->headerdata['planned']); $this->docform->notes->setText($this->_doc->notes); $this->docform->document_date->setDate($this->_doc->document_date); - $this->docform->parea->setValue($this->_doc->headerdata['parea']); + $this->docform->parea->setValue($this->_doc->headerdata['parea']); $this->docform->store->setValue($this->_doc->headerdata['store']); @@ -101,6 +103,8 @@ public function detailOnRow($row) { $row->add(new Label('msr', $item->msr)); $row->add(new Label('quantity', H::fqty($item->quantity))); $row->add(new Label('price', $item->price)); + $row->add(new Label('snumber', $item->snumber)); + $row->add(new Label('sdate', $item->sdate > 0 ? date('Y-m-d', $item->sdate) : '')); $row->add(new Label('amount', round($item->quantity * $item->price))); $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); @@ -116,6 +120,8 @@ public function editOnClick($sender) { $this->editdetail->editquantity->setText($item->quantity); $this->editdetail->editprice->setText($item->price); + $this->editdetail->editsnumber->setText($item->snumber); + $this->editdetail->editsdate->setDate($item->sdate); $this->editdetail->edititem->setKey($item->item_id); @@ -169,7 +175,14 @@ public function saverowOnClick($sender) { if ($item->price == 0) { $this->setWarn("Не указана цена"); } - + $item->snumber = $this->editdetail->editsnumber->getText(); + $item->sdate = $this->editdetail->editsdate->getDate(); + if ($item->sdate == false) + $item->sdate = ''; + if (strlen($item->snumber) > 0 && strlen($item->sdate) == 0) { + $this->setError("К серии должна быть введена дата"); + return; + } unset($this->_itemlist[$this->_rowid]); @@ -185,6 +198,8 @@ public function saverowOnClick($sender) { $this->editdetail->editquantity->setText("1"); $this->editdetail->editprice->setText(""); + $this->editdetail->editsnumber->setText(""); + $this->editdetail->editsdate->setText(""); } public function cancelrowOnClick($sender) { @@ -199,19 +214,15 @@ public function savedocOnClick($sender) { if ($this->checkForm() == false) { return; } - $old = $this->_doc->cast(); - $this->calcTotal(); + $this->calcTotal(); + $this->_doc->headerdata['parea'] = $this->docform->parea->getValue(); + $this->_doc->headerdata['pareaname'] = $this->docform->parea->getValueName(); + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + $this->_doc->headerdata['planned'] = $this->docform->planned->isChecked() ? 1 : 0; - $this->_doc->headerdata = array( - 'parea' => $this->docform->parea->getValue(), - 'pareaname' => $this->docform->parea->getValueName(), - 'store' => $this->docform->store->getValue(), - 'planned' => $this->docform->planned->isChecked() ? 1 : 0, - 'total' => $this->docform->total->getText() - ); $this->_doc->detaildata = array(); foreach ($this->_itemlist as $item) { $this->_doc->detaildata[] = $item->getData(); @@ -219,7 +230,7 @@ public function savedocOnClick($sender) { $this->_doc->amount = $this->docform->total->getText(); $isEdited = $this->_doc->document_id > 0; - $this->_doc->datatag = $this->_doc->amount; + $this->_doc->payamount = $this->_doc->amount; $conn = \ZDB\DB::getConnect(); diff --git a/www/app/pages/doc/retcustissue.php b/www/app/pages/doc/retcustissue.php index cca772407..059949e21 100644 --- a/www/app/pages/doc/retcustissue.php +++ b/www/app/pages/doc/retcustissue.php @@ -76,7 +76,7 @@ public function __construct($docid = 0, $basedocid = 0) { if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); @@ -110,7 +110,7 @@ public function __construct($docid = 0, $basedocid = 0) { foreach ($basedoc->detaildata as $item) { - $stock = \App\Entity\Stock::getStock($basedoc->headerdata['store'], $item['item_id'], $item['price']); + $stock = \App\Entity\Stock::getStock($basedoc->headerdata['store'], $item['item_id'], $item['price'], $item['snumber']); $stock->quantity = $item['quantity']; $stock->price = $item['price']; $this->_tovarlist[$stock->stock_id] = $stock; @@ -132,6 +132,8 @@ public function detailOnRow($row) { $row->add(new Label('tovar', $item->itemname)); $row->add(new Label('code', $item->item_code)); $row->add(new Label('msr', $item->msr)); + $row->add(new Label('snumber', $item->snumber)); + $row->add(new Label('sdate', $item->sdate > 0 ? date('Y-m-d', $item->sdate) : '')); $row->add(new Label('quantity', H::fqty($item->quantity))); $row->add(new Label('price', $item->price)); @@ -237,11 +239,11 @@ public function savedocOnClick($sender) { } $this->calcTotal(); - $old = $this->_doc->cast(); - $this->_doc->headerdata = array( - 'store' => $this->docform->store->getValue() - ); + + + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + $this->_doc->detaildata = array(); foreach ($this->_tovarlist as $tovar) { $this->_doc->detaildata[] = $tovar->getData(); diff --git a/www/app/pages/doc/returnissue.php b/www/app/pages/doc/returnissue.php index e7f730119..2c92a3b47 100644 --- a/www/app/pages/doc/returnissue.php +++ b/www/app/pages/doc/returnissue.php @@ -19,6 +19,7 @@ use \App\Entity\Item; use \App\Entity\Stock; use \App\Entity\Store; +use \App\Entity\MoneyFund; use \App\Helper as H; use \App\Application as App; @@ -46,6 +47,8 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new AutocompleteTextInput('customer'))->onText($this, 'OnAutoCustomer'); $this->docform->add(new TextInput('notes')); + $this->docform->add(new DropDownChoice('payment', MoneyFund::getList(), H::getDefMF()))->onChange($this, "onMF"); + $this->docform->add(new TextInput('paynotes')); $this->docform->add(new SubmitLink('addrow'))->onClick($this, 'addrowOnClick'); @@ -68,7 +71,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editdetail->add(new SubmitButton('submitrow'))->onClick($this, 'saverowOnClick'); if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); @@ -79,6 +82,8 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->customer->setText($this->_doc->customer_name); $this->docform->notes->setText($this->_doc->notes); + $this->docform->payment->setValue($this->_doc->headerdata['payment']); + $this->docform->paynotes->setText($this->_doc->headerdata['paynotes']); foreach ($this->_doc->detaildata as $item) { $it = new Stock($item); @@ -111,6 +116,12 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_tovarlist')), $this, 'detailOnRow'))->Reload(); if (false == \App\ACL::checkShowDoc($this->_doc)) return; + $this->onMF($this->docform->payment); + } + + public function onMF($sender) { + $mf = $sender->getValue(); + $this->docform->paynotes->setVisible($mf > 0); } public function detailOnRow($row) { @@ -118,6 +129,8 @@ public function detailOnRow($row) { $row->add(new Label('tovar', $item->itemname)); $row->add(new Label('msr', $item->msr)); + $row->add(new Label('snumber', $item->snumber)); + $row->add(new Label('sdate', $item->sdate > 0 ? date('Y-m-d', $item->sdate) : '')); $row->add(new Label('quantity', H::fqty($item->quantity))); @@ -216,12 +229,13 @@ public function savedocOnClick($sender) { } $this->calcTotal(); - $old = $this->_doc->cast(); - $this->_doc->headerdata = array( - 'store' => $this->docform->store->getValue(), - 'total' => $this->docform->total->getText() - ); + + + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + $this->_doc->headerdata['payment'] = $this->docform->payment->getValue(); + $this->_doc->headerdata['paynotes'] = $this->docform->paynotes->getText(); + $this->_doc->detaildata = array(); foreach ($this->_tovarlist as $tovar) { $this->_doc->detaildata[] = $tovar->getData(); diff --git a/www/app/pages/doc/serviceact.php b/www/app/pages/doc/serviceact.php index ad6490fbe..ddf7cfd99 100644 --- a/www/app/pages/doc/serviceact.php +++ b/www/app/pages/doc/serviceact.php @@ -2,23 +2,26 @@ namespace App\Pages\Doc; -use App\Application as App; -use App\Entity\Customer; -use App\Entity\Doc\Document; -use App\Entity\Service; -use App\System; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextArea; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; +use \App\Application as App; +use \App\Entity\Customer; +use \App\Entity\Doc\Document; +use \App\Entity\Service; +use \App\System; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextArea; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\MoneyFund; +use \App\Helper as H; /** * Страница ввода акта выполненных работ @@ -44,7 +47,9 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new TextInput('notes')); $this->docform->add(new TextInput('gar')); $this->docform->add(new CheckBox('planned')); - $this->docform->add(new CheckBox('payed')); + $this->docform->add(new DropDownChoice('payment', MoneyFund::getList(), H::getDefMF()))->onChange($this, "onMF"); + $this->docform->add(new TextInput('paynotes')); + $this->docform->add(new Label('discount'))->setVisible(false); $this->docform->add(new TextInput('order')); @@ -75,13 +80,15 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editcust->add(new SubmitButton('savecust'))->onClick($this, 'savecustOnClick'); if ($docid > 0) { //загружаем содержимок документа на страницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->notes->setText($this->_doc->headerdata['notes']); $this->docform->gar->setText($this->_doc->headerdata['gar']); $this->docform->planned->setChecked($this->_doc->headerdata['planned']); $this->docform->order->setText($this->_doc->headerdata['order']); $this->_order_id = $this->_doc->headerdata['order_id']; + $this->docform->payment->setValue($this->_doc->headerdata['payment']); + $this->docform->paynotes->setText($this->_doc->headerdata['paynotes']); $this->docform->document_date->setDate($this->_doc->document_date); $this->docform->customer->setKey($this->_doc->customer_id); @@ -129,7 +136,6 @@ public function __construct($docid = 0, $basedocid = 0) { } } } - $this->docform->payed->setChecked($this->_doc->datatag == $this->_doc->amount); $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_servicelist')), $this, 'detailOnRow'))->Reload(); $this->calcTotal(); @@ -140,6 +146,12 @@ public function __construct($docid = 0, $basedocid = 0) { if ($this->_order_id) { $this->docform->inprocdoc->setVisible(false); //Прячем если есть заказ чтобы не дублировать } + $this->onMF($this->docform->payment); + } + + public function onMF($sender) { + $mf = $sender->getValue(); + $this->docform->paynotes->setVisible($mf > 0); } public function detailOnRow($row) { @@ -237,15 +249,14 @@ public function savedocOnClick($sender) { $this->calcTotal(); - $old = $this->_doc->cast(); - $this->_doc->headerdata = array( - 'order' => $this->docform->order->getText(), - 'order_id' => $this->_order_id, - 'planned' => $this->docform->planned->isChecked() ? 1 : 0, - 'gar' => $this->docform->gar->getText(), - 'total' => $this->docform->total->getText(), - ); + $this->_doc->headerdata['order'] = $this->docform->order->getText(); + $this->_doc->headerdata['order_id'] = $this->_order_id; + $this->_doc->headerdata['planned'] = $this->docform->planned->isChecked() ? 1 : 0; + $this->_doc->headerdata['gar'] = $this->docform->gar->getText(); + $this->_doc->headerdata['payment'] = $this->docform->payment->getValue(); + $this->_doc->headerdata['paynotes'] = $this->docform->paynotes->getText(); + $this->_doc->detaildata = array(); foreach ($this->_servicelist as $item) { $this->_doc->detaildata[] = $item->getData(); @@ -253,11 +264,7 @@ public function savedocOnClick($sender) { $isEdited = $this->_doc->document_id > 0; $this->_doc->amount = $this->docform->total->getText(); - if ($this->docform->payed->isChecked() == true && $this->_doc->datatag < $this->_doc->amount) { - $this->_doc->addPayment(System::getUser()->user_id, $this->_doc->amount - $this->_doc->datatag); - $this->_doc->datatag = $this->_doc->amount; - } $conn = \ZDB\DB::getConnect(); $conn->BeginTrans(); diff --git a/www/app/pages/doc/serviceorder.php b/www/app/pages/doc/serviceorder.php index 068c2ed7e..1f4151fcc 100644 --- a/www/app/pages/doc/serviceorder.php +++ b/www/app/pages/doc/serviceorder.php @@ -2,24 +2,24 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\TextArea; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Customer; -use App\Entity\Doc\Document; -use App\Entity\Service; -use App\Application as App; -use App\System; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\TextArea; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Customer; +use \App\Entity\Doc\Document; +use \App\Entity\Service; +use \App\Application as App; +use \App\System; /** * Страница ввода заказа на услуги @@ -80,7 +80,7 @@ public function __construct($docid = 0, $basedocid = 0) { if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->notes->setText($this->_doc->headerdata['notes']); @@ -197,11 +197,9 @@ public function savedocOnClick($sender) { $this->calcTotal(); - $old = $this->_doc->cast(); - $this->_doc->headerdata = array( - 'total' => $this->docform->total->getText() - ); + + $this->_doc->detaildata = array(); foreach ($this->_servicelist as $item) { $this->_doc->detaildata[] = $item->getData(); diff --git a/www/app/pages/doc/task.php b/www/app/pages/doc/task.php index 4a7f93273..279d19812 100644 --- a/www/app/pages/doc/task.php +++ b/www/app/pages/doc/task.php @@ -2,29 +2,30 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Customer; -use App\Entity\Doc\Document; -use App\Entity\Service; -use App\Entity\Store; -use App\Entity\Stock; -use App\Entity\Prodarea; -use App\Entity\Item; -use App\Entity\Employee; -use App\Entity\Equipment; -use App\Application as App; -use App\Helper as H; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Customer; +use \App\Entity\Doc\Document; +use \App\Entity\Service; +use \App\Entity\Store; +use \App\Entity\Stock; +use \App\Entity\Prodarea; +use \App\Entity\Item; +use \App\Entity\Employee; +use \App\Entity\Equipment; +use \App\Application as App; +use \App\Helper as H; +use \App\Entity\MoneyFund; /** * Страница ввода наряда на работу @@ -57,6 +58,8 @@ public function __construct($docid = 0) { $this->docform->add(new DropDownChoice('store', Store::getList(), \App\Helper::getDefStore())); $this->docform->add(new DropDownChoice('parea', Prodarea::findArray("pa_name", ""), 0)); $this->docform->add(new DropDownChoice('pricetype', Item::getPriceTypeList())); + $this->docform->add(new DropDownChoice('payment', MoneyFund::getList(), H::getDefMF()))->onChange($this, "onMF"); + $this->docform->add(new TextInput('paynotes')); $this->docform->add(new SubmitLink('addservice'))->onClick($this, 'addserviceOnClick'); $this->docform->add(new SubmitLink('additem'))->onClick($this, 'additemOnClick'); @@ -126,7 +129,7 @@ public function __construct($docid = 0) { if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->notes->setText($this->_doc->notes); $this->docform->hours->setText($this->_doc->headerdata['hours']); @@ -134,8 +137,10 @@ public function __construct($docid = 0) { $this->docform->start_date->setDate($this->_doc->headerdata['start_date']); $this->docform->pricetype->setValue($this->_doc->headerdata['pricetype']); $this->docform->store->setValue($this->_doc->headerdata['store']); + $this->docform->payment->setValue($this->_doc->headerdata['payment']); + $this->docform->paynotes->setText($this->_doc->headerdata['paynotes']); - $this->docform->document_date->setDate($this->_doc->headerdata['end_date']); + $this->docform->document_date->setDate($this->_doc->document_date); $this->docform->parea->setValue($this->_doc->headerdata['parea']); $this->docform->customer->setKey($this->_doc->customer_id); $this->docform->customer->setText($this->_doc->customer_name); @@ -179,6 +184,13 @@ public function __construct($docid = 0) { if (false == \App\ACL::checkShowDoc($this->_doc)) return; + + $this->onMF($this->docform->payment); + } + + public function onMF($sender) { + $mf = $sender->getValue(); + $this->docform->paynotes->setVisible($mf > 0); } public function cancelrowOnClick($sender) { @@ -483,19 +495,19 @@ public function savedocOnClick($sender) { $this->calcTotal(); - $old = $this->_doc->cast(); - - $this->_doc->headerdata = array( - 'parea' => $this->docform->parea->getValue(), - 'pareaname' => $this->docform->parea->getValueName(), - 'pricetype' => $this->docform->pricetype->getValue(), - 'pricetypename' => $this->docform->pricetype->getValueName(), - 'store' => $this->docform->store->getValue(), - 'hours' => $this->docform->hours->getText(), - 'start_date' => $this->docform->start_date->getDate(), - 'end_date' => $this->docform->document_date->getDate(), - 'total' => $this->docform->total->getText() - ); + + $this->_doc->headerdata['parea'] = $this->docform->parea->getValue(); + $this->_doc->headerdata['pareaname'] = $this->docform->parea->getValueName(); + $this->_doc->headerdata['pricetype'] = $this->docform->pricetype->getValue(); + $this->_doc->headerdata['pricetypename'] = $this->docform->pricetype->getValueName(); + $this->_doc->headerdata['store'] = $this->docform->store->getValue(); + $this->_doc->headerdata['hours'] = $this->docform->hours->getText(); + $this->_doc->headerdata['start_date'] = $this->docform->start_date->getDate(); + $this->_doc->document_date = $this->docform->document_date->getDate(); + $this->_doc->headerdata['payment'] = $this->docform->payment->getValue(); + $this->_doc->headerdata['paynotes'] = $this->docform->paynotes->getText(); + + $this->_doc->detaildata = array(); foreach ($this->_servicelist as $item) { $this->_doc->detaildata[] = $item->getData(); diff --git a/www/app/pages/doc/transitem.php b/www/app/pages/doc/transitem.php index 0baaafa33..7ea8b5c00 100644 --- a/www/app/pages/doc/transitem.php +++ b/www/app/pages/doc/transitem.php @@ -2,24 +2,24 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; use \Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Doc\Document; -use App\Entity\Item; -use App\Entity\Stock; -use App\Entity\Store; -use App\Application as App; -use App\Helper as H; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Doc\Document; +use \App\Entity\Item; +use \App\Entity\Stock; +use \App\Entity\Store; +use \App\Application as App; +use \App\Helper as H; /** * Страница ввода перекомплектация товаров @@ -52,7 +52,7 @@ public function __construct($docid = 0) { if ($docid > 0) { //загружаем содержимок документа на страницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->document_date->setDate($this->_doc->document_date); $this->docform->storefrom->setValue($this->_doc->headerdata['storefrom']); @@ -69,7 +69,7 @@ public function __construct($docid = 0) { $this->_doc = Document::create('TransItem'); $this->docform->document_number->setText($this->_doc->nextNumber()); } - + if (false == \App\ACL::checkShowDoc($this->_doc)) return; @@ -84,13 +84,12 @@ public function savedocOnClick($sender) { $this->_doc->notes = $this->docform->notes->getText(); - $this->_doc->headerdata = array( - 'storefrom' => $this->docform->storefrom->getValue(), - 'fromitem' => $this->docform->fromitem->getKey(), - 'toitem' => $this->docform->toitem->getKey(), - 'fromquantity' => $this->docform->fromquantity->getText(), - 'toquantity' => $this->docform->toquantity->getText() - ); + $this->_doc->headerdata['storefrom'] = $this->docform->storefrom->getValue(); + $this->_doc->headerdata['fromitem'] = $this->docform->fromitem->getKey(); + $this->_doc->headerdata['toitem'] = $this->docform->toitem->getKey(); + $this->_doc->headerdata['fromquantity'] = $this->docform->fromquantity->getText(); + $this->_doc->headerdata['toquantity'] = $this->docform->toquantity->getText(); + if ($this->checkForm() == false) { return; diff --git a/www/app/pages/doc/warranty.php b/www/app/pages/doc/warranty.php index 9ba0c56e5..405c0ab9c 100644 --- a/www/app/pages/doc/warranty.php +++ b/www/app/pages/doc/warranty.php @@ -2,23 +2,23 @@ namespace App\Pages\Doc; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Label; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\SubmitLink; -use App\Entity\Doc\Document; -use App\Entity\Item; -use App\Entity\Stock; -use App\Entity\Store; -use App\Helper as H; -use App\Application as App; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Label; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\SubmitLink; +use \App\Entity\Doc\Document; +use \App\Entity\Item; +use \App\Entity\Stock; +use \App\Entity\Store; +use \App\Helper as H; +use \App\Application as App; /** * Страница ввода гарантийного талона @@ -64,7 +64,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editdetail->add(new SubmitButton('submitrow'))->onClick($this, 'saverowOnClick'); if ($docid > 0) { //загружаем содержимок документа настраницу - $this->_doc = Document::load($docid); + $this->_doc = Document::load($docid)->cast(); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->customer->setKey($this->_doc->customer_id); @@ -101,7 +101,7 @@ public function __construct($docid = 0, $basedocid = 0) { } } } - + $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_tovarlist')), $this, 'detailOnRow'))->Reload(); if (false == \App\ACL::checkShowDoc($this->_doc)) return; @@ -212,10 +212,10 @@ public function savedocOnClick($sender) { $this->_doc->customer_id = $this->docform->customer->getKey(); - $this->_doc->headerdata = array( - 'pricetypename' => $this->docform->pricetype->getValueName(), - 'pricetype' => $this->docform->pricetype->getValue(), - ); + + $this->_doc->headerdata['pricetype'] = $this->docform->pricetype->getValue(); + $this->_doc->headerdata['pricetypename'] = $this->docform->pricetype->getValueName(); + $this->_doc->detaildata = array(); foreach ($this->_tovarlist as $tovar) { $this->_doc->detaildata[] = $tovar->getData(); diff --git a/www/app/pages/import.php b/www/app/pages/import.php index 7970ea7c5..5573726b4 100644 --- a/www/app/pages/import.php +++ b/www/app/pages/import.php @@ -2,18 +2,18 @@ namespace App\Pages; -use Zippy\Html\DataList\DataView; -use App\Entity\User; -use App\Entity\Item; -use App\Entity\Store; -use App\Entity\Category; -use App\Helper as H; -use App\System; -use Zippy\WebApplication as App; +use \Zippy\Html\DataList\DataView; +use \App\Entity\User; +use \App\Entity\Item; +use \App\Entity\Store; +use \App\Entity\Category; +use \App\Helper as H; +use \App\System; +use \Zippy\WebApplication as App; use \ZCL\DB\EntityDataSource; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; use \Zippy\Html\Form\DropDownChoice; use \Zippy\Html\Form\Form; use \Zippy\Html\Form\CheckBox; @@ -188,7 +188,7 @@ public function onImport($sender) { } $doc->amount = $amount; $doc->headerdata['store'] = $store; - $doc->headerdata['total'] = $amount; + $doc->save(); $doc->updateStatus(\App\Entity\Doc\Document::STATE_NEW); $doc->updateStatus(\App\Entity\Doc\Document::STATE_EXECUTED); diff --git a/www/app/pages/main.php b/www/app/pages/main.php index 4f568a43a..83181020b 100644 --- a/www/app/pages/main.php +++ b/www/app/pages/main.php @@ -16,10 +16,14 @@ public function __construct() { $this->add(new \App\Widgets\WPlannedDocs("wplanned")); $this->add(new \App\Widgets\WDebitors("wdebitors")); - + $this->add(new \App\Widgets\WNoliq("wnoliq")); - + $this->add(new \App\Widgets\WMinQty("wminqty")); + + $this->add(new \App\Widgets\Wsdate("wsdate"))->setVisible($this->_tvars["usesnumber"]); + + $this->add(new \App\Widgets\WRDoc("wrdoc")); } public function getPageInfo() { diff --git a/www/app/pages/notifylist.php b/www/app/pages/notifylist.php index e6451344b..87e262e73 100644 --- a/www/app/pages/notifylist.php +++ b/www/app/pages/notifylist.php @@ -2,14 +2,14 @@ namespace App\Pages; -use Zippy\Html\DataList\DataView; -use App\Entity\User; -use App\System; -use Zippy\WebApplication as App; +use \Zippy\Html\DataList\DataView; +use \App\Entity\User; +use \App\System; +use \Zippy\WebApplication as App; use \ZCL\DB\EntityDataSource; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; class NotifyList extends \App\Pages\Base { diff --git a/www/app/pages/options.php b/www/app/pages/options.php index b2258a0fa..460389111 100644 --- a/www/app/pages/options.php +++ b/www/app/pages/options.php @@ -13,8 +13,8 @@ use \Zippy\Html\Label; use \Zippy\Html\Link\ClickLink; use \Zippy\Html\Panel; -use App\System; -use App\Application as App; +use \App\System; +use \App\Application as App; class Options extends \App\Pages\Base { @@ -32,10 +32,12 @@ public function __construct() { $this->add(new Form('common'))->onSubmit($this, 'saveCommonOnClick'); $this->common->add(new TextInput('firmname')); $this->common->add(new DropDownChoice('defstore', \App\Entity\Store::getList())); + $this->common->add(new DropDownChoice('defmf', \App\Entity\MoneyFund::getList())); $this->common->add(new DropDownChoice('qtydigits')); + $this->common->add(new CheckBox('usesnumber')); $this->common->add(new CheckBox('useset')); $this->common->add(new CheckBox('useval'))->onChange($this, "onVal"); $this->common->add(new TextInput('cdoll')); @@ -48,7 +50,7 @@ public function __construct() { $this->common->add(new TextInput('price5')); // $this->common->add(new Date('closeddate')); - + $common = System::getOptions("common"); @@ -57,6 +59,7 @@ public function __construct() { $this->common->firmname->setText($common['firmname']); $this->common->defstore->setValue($common['defstore']); + $this->common->defmf->setValue($common['defmf']); $this->common->qtydigits->setValue($common['qtydigits']); $this->common->cdoll->setText($common['cdoll']); $this->common->ceuro->setText($common['ceuro']); @@ -67,6 +70,7 @@ public function __construct() { $this->common->price4->setText($common['price4']); $this->common->price5->setText($common['price5']); $this->common->useset->setChecked($common['useset']); + $this->common->usesnumber->setChecked($common['usesnumber']); $this->common->useval->setChecked($common['useval']); // $this->common->closeddate->setDate($common['closeddate']); @@ -75,7 +79,7 @@ public function __construct() { $this->onVal($this->common->useval); - + $this->metadatads = new \ZCL\DB\EntityDataSource("\\App\\Entity\\MetaData", "", "description"); @@ -85,7 +89,7 @@ public function __construct() { $this->listpan->filter->add(new CheckBox('fdic'))->setChecked(true); $this->listpan->filter->add(new CheckBox('frep'))->setChecked(true); $this->listpan->filter->add(new CheckBox('freg'))->setChecked(true); - $this->listpan->filter->add(new CheckBox('fshop'))->setChecked(true); + $this->listpan->add(new ClickLink('addnew'))->onClick($this, 'addnewOnClick'); $this->listpan->add(new DataView('metarow', $this->metadatads, $this, 'metarowOnRow'))->Reload(); @@ -119,6 +123,7 @@ public function saveCommonOnClick($sender) { $common = array(); $common['firmname'] = $this->common->firmname->getText(); $common['defstore'] = $this->common->defstore->getValue(); + $common['defmf'] = $this->common->defmf->getValue(); $common['qtydigits'] = $this->common->qtydigits->getValue(); $common['cdoll'] = $this->common->cdoll->getText(); $common['ceuro'] = $this->common->ceuro->getText(); @@ -129,6 +134,7 @@ public function saveCommonOnClick($sender) { $common['price4'] = $this->common->price4->getText(); $common['price5'] = $this->common->price5->getText(); $common['useset'] = $this->common->useset->isChecked(); + $common['usesnumber'] = $this->common->usesnumber->isChecked(); $common['useval'] = $this->common->useval->isChecked(); // $common['closeddate'] = $this->common->closeddate->getDate(); @@ -139,7 +145,6 @@ public function saveCommonOnClick($sender) { $this->setSuccess('Сохранено'); } - public function filterOnSubmit($sender) { $where = "1<>1 "; @@ -155,9 +160,7 @@ public function filterOnSubmit($sender) { if ($this->listpan->filter->freg->isChecked()) { $where .= " or meta_type = 3"; } - if ($this->listpan->filter->fshop->isChecked()) { - $where .= " or meta_type = 5"; - } + $this->metadatads->setWhere($where); diff --git a/www/app/pages/reference/categorylist.php b/www/app/pages/reference/categorylist.php index c591d6e70..fa420defb 100644 --- a/www/app/pages/reference/categorylist.php +++ b/www/app/pages/reference/categorylist.php @@ -2,16 +2,19 @@ namespace App\Pages\Reference; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; -use App\Entity\Category; - +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; +use \App\Entity\Category; + +/** + * справочник категорийтоваров + */ class CategoryList extends \App\Pages\Base { private $_category; @@ -44,12 +47,13 @@ public function deleteOnClick($sender) { $cat_id = $sender->owner->getDataItem()->cat_id; - $cnt = \App\Entity\Item::findCnt(" disabled <> 1 and cat_id=" . $cat_id); - if ($cnt > 0) { - $this->setError('Нельзя удалить категорию с товарами'); + + $del = Category::delete($cat_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - Category::delete($cat_id); + $this->categorytable->categorylist->Reload(); } diff --git a/www/app/pages/reference/customerlist.php b/www/app/pages/reference/customerlist.php index d33c9ed59..f2ab28daa 100644 --- a/www/app/pages/reference/customerlist.php +++ b/www/app/pages/reference/customerlist.php @@ -2,24 +2,24 @@ namespace App\Pages\Reference; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\ArrayDataSource; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\TextArea; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; -use App\Helper; -use App\Entity\Customer; -use Zippy\Binding\PropertyBinding as Bind; -use App\System; -use Zippy\Html\Link\BookmarkableLink; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\ArrayDataSource; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\TextArea; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; +use \App\Helper; +use \App\Entity\Customer; +use \Zippy\Binding\PropertyBinding as Bind; +use \App\System; +use \Zippy\Html\Link\BookmarkableLink; /** * Страница контрагентов @@ -139,11 +139,12 @@ public function deleteOnClick($sender) { return; - if (false == Customer::delete($sender->owner->getDataItem()->customer_id)) { - $this->setError("Нельзя удалить контрагента"); + $del = Customer::delete($sender->owner->getDataItem()->customer_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - ; + $this->customertable->customerlist->Reload(); } diff --git a/www/app/pages/reference/employeelist.php b/www/app/pages/reference/employeelist.php index 484986734..cd29964b2 100644 --- a/www/app/pages/reference/employeelist.php +++ b/www/app/pages/reference/employeelist.php @@ -3,19 +3,19 @@ namespace App\Pages\Reference; use ZCL\DB\EntityDataSource as EDS; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\TextArea; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; -use App\Entity\Employee; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\TextArea; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; +use \App\Entity\Employee; class EmployeeList extends \App\Pages\Base { diff --git a/www/app/pages/reference/eqlist.php b/www/app/pages/reference/eqlist.php index c5834b73e..e38ba4295 100644 --- a/www/app/pages/reference/eqlist.php +++ b/www/app/pages/reference/eqlist.php @@ -25,6 +25,7 @@ class EqList extends \App\Pages\Base { private $_item; + public $_uselist = array(); public function __construct() { parent::__construct(); @@ -35,9 +36,11 @@ public function __construct() { $this->filter->add(new TextInput('searchkey')); $this->filter->add(new DropDownChoice('searchemp', Employee::findArray("emp_name", "", "emp_name"), 0)); + $this->add(new Panel('itemtable'))->setVisible(true); $this->itemtable->add(new DataView('eqlist', new EQDS($this), $this, 'eqlistOnRow')); $this->itemtable->add(new ClickLink('addnew'))->onClick($this, 'addOnClick'); + $this->itemtable->eqlist->setPageSize(25); $this->itemtable->add(new \Zippy\Html\DataList\Paginator('pag', $this->itemtable->eqlist)); $this->itemtable->eqlist->setSelectedClass('table-success'); @@ -55,6 +58,11 @@ public function __construct() { $this->itemdetail->add(new SubmitButton('save'))->onClick($this, 'OnSubmit'); $this->itemdetail->add(new Button('cancel'))->onClick($this, 'cancelOnClick'); + + $this->add(new Panel('usetable'))->setVisible(false); + $this->usetable->add(new Label('usename')); + $this->usetable->add(new ClickLink('back'))->onClick($this, 'cancelOnClick'); + $this->usetable->add(new DataView('uselist', new ArrayDataSource($this, '_uselist'), $this, 'uselistOnRow')); } public function eqlistOnRow($row) { @@ -63,6 +71,7 @@ public function eqlistOnRow($row) { $row->add(new Label('code', $item->code)); $row->add(new Label('serial', $item->serial)); + $row->add(new ClickLink('use'))->onClick($this, 'useOnClick'); $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); } @@ -85,6 +94,38 @@ public function deleteOnClick($sender) { $this->itemtable->eqlist->Reload(); } + public function useOnClick($sender) { + $this->itemtable->setVisible(false); + $this->usetable->setVisible(true); + $item = $sender->getOwner()->getDataItem(); + $this->usetable->usename->setText($item->eq_name); + $this->_uselist = array(); + + $list = \App\Entity\Doc\Document::find("meta_name='task' and state not in(2,3,1,9) ", "document_date desc"); + + + foreach ($list as $task) { + foreach ($task->detaildata as $value) { + if ($value['eq_id'] > 0) { + + $it = new \App\DataItem(array( + "usetask" => $task->document_number, + "useplace" => $value['eq_name'] + )); + $this->_uselist[] = $it; + } + } + } + + $this->usetable->uselist->Reload(); + } + + public function uselistOnRow($row) { + $item = $row->getDataItem(); + $row->add(new Label('usetask', $item->usetask)); + $row->add(new Label('useplace', $item->useplace)); + } + public function editOnClick($sender) { $this->_item = $sender->owner->getDataItem(); $this->itemtable->setVisible(false); @@ -110,6 +151,7 @@ public function addOnClick($sender) { public function cancelOnClick($sender) { $this->itemtable->setVisible(true); $this->itemdetail->setVisible(false); + $this->usetable->setVisible(false); } public function OnFilter($sender) { diff --git a/www/app/pages/reference/itemlist.php b/www/app/pages/reference/itemlist.php index 624a5938d..0eebd2307 100644 --- a/www/app/pages/reference/itemlist.php +++ b/www/app/pages/reference/itemlist.php @@ -4,7 +4,7 @@ use \Zippy\Html\DataList\DataView; use \Zippy\Html\DataList\ArrayDataSource; -use Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\AutocompleteTextInput; use \Zippy\Html\Form\DropDownChoice; use \Zippy\Html\Form\Form; use \Zippy\Html\Form\TextInput; @@ -83,6 +83,7 @@ public function __construct($add = false) { } $this->itemdetail->add(new TextInput('editbarcode')); $this->itemdetail->add(new TextInput('editminqty')); + $this->itemdetail->add(new TextInput('editterm')); $this->itemdetail->add(new TextInput('editmsr')); $this->itemdetail->add(new DropDownChoice('editcat', Category::findArray("cat_name", "", "cat_name"), 0)); $this->itemdetail->add(new TextInput('editcode')); @@ -144,16 +145,14 @@ public function deleteOnClick($sender) { return; $item = $sender->owner->getDataItem(); - //проверка на партии - if ($item->checkDelete()) { - Item::delete($item->item_id); - } else { - $this->setError("Нельзя удалить товар"); + + $del = Item::delete($item->item_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - $this->itemtable->itemlist->Reload(); } @@ -174,7 +173,8 @@ public function editOnClick($sender) { $this->itemdetail->editcode->setText($this->_item->item_code); $this->itemdetail->editbarcode->setText($this->_item->bar_code); $this->itemdetail->editmsr->setText($this->_item->msr); - $this->itemdetail->editminqty->setText( \App\Helper::fqty($this->_item->minqty)); + $this->itemdetail->editterm->setText($this->_item->term); + $this->itemdetail->editminqty->setText(\App\Helper::fqty($this->_item->minqty)); $this->itemdetail->editdisabled->setChecked($this->_item->disabled); $this->itemdetail->editpricelist->setChecked($this->_item->pricelist); } @@ -215,27 +215,28 @@ public function OnSubmit($sender) { $this->_item->bar_code = trim($this->itemdetail->editbarcode->getText()); $this->_item->msr = $this->itemdetail->editmsr->getText(); + $this->_item->term = $this->itemdetail->editterm->getText(); $this->_item->minqty = $this->itemdetail->editminqty->getText(); $this->_item->description = $this->itemdetail->editdescription->getText(); $this->_item->disabled = $this->itemdetail->editdisabled->isChecked() ? 1 : 0; - ; + $this->_item->pricelist = $this->itemdetail->editpricelist->isChecked() ? 1 : 0; - + //проверка уникальности артикула - if(strlen($this->_item->item_code) >0){ - $code = Item::qstr($this->_item->item_code); - $cnt=Item::findCnt("item_id <> {$this->_item->item_id} and item_code={$code} "); - if($cnt > 0){ - $this->setError('Такой артикул уже существует'); - return; - } + if (strlen($this->_item->item_code) > 0) { + $code = Item::qstr($this->_item->item_code); + $cnt = Item::findCnt("item_id <> {$this->_item->item_id} and item_code={$code} "); + if ($cnt > 0) { + $this->setError('Такой артикул уже существует'); + return; + } } $this->_item->Save(); $this->itemtable->itemlist->Reload(); - + $this->itemtable->setVisible(true); - $this->itemdetail->setVisible(false); + $this->itemdetail->setVisible(false); } //комплекты diff --git a/www/app/pages/reference/mflist.php b/www/app/pages/reference/mflist.php new file mode 100644 index 000000000..3128f007e --- /dev/null +++ b/www/app/pages/reference/mflist.php @@ -0,0 +1,105 @@ +add(new Panel('mftable'))->setVisible(true); + $this->mftable->add(new DataView('mflist', new \ZCL\DB\EntityDataSource('\App\Entity\MoneyFund'), $this, 'mflistOnRow'))->Reload(); + $this->mftable->add(new ClickLink('addnew'))->onClick($this, 'addOnClick'); + $this->add(new Form('mfdetail'))->setVisible(false); + $this->mfdetail->add(new TextInput('editmf_name')); + $this->mfdetail->add(new TextArea('editmf_description')); + $this->mfdetail->add(new SubmitButton('save'))->onClick($this, 'saveOnClick'); + $this->mfdetail->add(new Button('cancel'))->onClick($this, 'cancelOnClick'); + + $this->_balance = MoneyFund::Balance(); + } + + public function mflistOnRow($row) { + $item = $row->getDataItem(); + + $row->add(new Label('mf_name', $item->mf_name)); + $row->add(new Label('description', $item->description)); + $row->add(new Label('amount', $this->_balance[$item->mf_id])); + $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); + $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); + } + + public function deleteOnClick($sender) { + if (false == \App\ACL::checkEditRef('MFList')) + return; + + + $mf_id = $sender->owner->getDataItem()->mf_id; + + $del = MoneyFund::delete($mf_id); + if (strlen($del) > 0) { + $this->setError($del); + return; + } + $this->mftable->mflist->Reload(); + } + + public function editOnClick($sender) { + $this->_mf = $sender->owner->getDataItem(); + $this->mftable->setVisible(false); + $this->mfdetail->setVisible(true); + $this->mfdetail->editmf_name->setText($this->_mf->mf_name); + $this->mfdetail->editmf_description->setText($this->_mf->mf_description); + } + + public function addOnClick($sender) { + $this->mftable->setVisible(false); + $this->mfdetail->setVisible(true); + // Очищаем форму + $this->mfdetail->clean(); + + $this->_mf = new MoneyFund(); + } + + public function saveOnClick($sender) { + if (false == \App\ACL::checkEditRef('MFList')) + return; + + $this->_mf->mf_name = $this->mfdetail->editmf_name->getText(); + $this->_mf->description = $this->mfdetail->editmf_description->getText(); + if ($this->_mf->mf_name == '') { + $this->setError("Введите наименование"); + return; + } + + $this->_mf->Save(); + $this->mfdetail->setVisible(false); + $this->mftable->setVisible(true); + $this->mftable->mflist->Reload(); + } + + public function cancelOnClick($sender) { + $this->mftable->setVisible(true); + $this->mfdetail->setVisible(false); + } + +} diff --git a/www/app/pages/reference/prodarealist.php b/www/app/pages/reference/prodarealist.php index 39204ce65..fe33b5b6f 100644 --- a/www/app/pages/reference/prodarealist.php +++ b/www/app/pages/reference/prodarealist.php @@ -2,15 +2,15 @@ namespace App\Pages\Reference; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; -use App\Entity\ProdArea; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; +use \App\Entity\ProdArea; //роизводственные участвки class ProdAreaList extends \App\Pages\Base { @@ -44,13 +44,11 @@ public function deleteOnClick($sender) { return; - $pa_id = $sender->owner->getDataItem()->pa_id; - // $cnt = \App\Entity\Item::findCnt(" disabled <> 1 and cat_id=" . $pa_id); - if ($cnt > 0) { - $this->setError('Нельзя удалить участок '); + $del = ProdArea::delete($pa_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - ProdArea::delete($pa_id); $this->patable->palist->Reload(); } diff --git a/www/app/pages/reference/servicelist.php b/www/app/pages/reference/servicelist.php index 2a7f8d194..fefdde293 100644 --- a/www/app/pages/reference/servicelist.php +++ b/www/app/pages/reference/servicelist.php @@ -2,15 +2,15 @@ namespace App\Pages\Reference; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; -use App\Entity\Service; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; +use \App\Entity\Service; class ServiceList extends \App\Pages\Base { @@ -50,12 +50,12 @@ public function deleteOnClick($sender) { return; $service_id = $sender->owner->getDataItem()->service_id; - // $cnt= \App\Entity\Item::findCnt(" disabled <> 1 and cat_id=".$cat_id); - if ($cnt > 0) { - // $this->setError('Нельзя удалить категорию с товарами'); - // return; + + $del = Service::delete($service_id); + if (strlen($del) > 0) { + $this->setError($del); + return; } - Service::delete($service_id); $this->servicetable->servicelist->Reload(); } diff --git a/www/app/pages/reference/storelist.php b/www/app/pages/reference/storelist.php index 1df41d063..7774f7564 100644 --- a/www/app/pages/reference/storelist.php +++ b/www/app/pages/reference/storelist.php @@ -2,19 +2,19 @@ namespace App\Pages\Reference; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\Paginator; -use Zippy\Html\Form\Button; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextArea; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; -use App\Entity\Store; -use App\Helper as H; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\Paginator; +use \Zippy\Html\Form\Button; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextArea; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; +use \App\Entity\Store; +use \App\Helper as H; class StoreList extends \App\Pages\Base { @@ -57,11 +57,12 @@ public function storedeleteOnClick($sender) { if (false == \App\ACL::checkEditRef('StoreList')) return; - if (false == Store::delete($sender->owner->getDataItem()->store_id)) { - $this->setError("Нельзя удалить цей склад"); + + $del = Store::delete($sender->owner->getDataItem()->store_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - $this->storetable->storelist->Reload(); } diff --git a/www/app/pages/register/doclist.php b/www/app/pages/register/doclist.php index eaddf9b6b..ff7f565eb 100644 --- a/www/app/pages/register/doclist.php +++ b/www/app/pages/register/doclist.php @@ -2,23 +2,23 @@ namespace App\Pages\Register; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\Paginator; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Panel; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use App\Entity\Doc\Document; -use App\Entity\Customer; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\Paginator; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Panel; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \App\Entity\Doc\Document; +use \App\Entity\Customer; use \Zippy\Html\Form\AutocompleteTextInput; -use App\Filter; -use App\Helper as H; -use App\Application as App; -use App\System; +use \App\Filter; +use \App\Helper as H; +use \App\Application as App; +use \App\System; /** * журнал докуметов @@ -71,8 +71,11 @@ public function __construct($docid = 0) { $this->add(new \App\Widgets\DocView('docview'))->setVisible(false); if ($docid > 0) { $this->docview->setVisible(true); - $this->docview->setDoc(Document::load($docid)); + $dc = Document::load($docid); + $this->docview->setDoc($dc); //$this->doclist->setSelectedRow($docid); + $filter->searchnumber = $dc->document_number; + $this->filter->searchnumber->setText($dc->document_number); $doclist->Reload(); } @@ -195,12 +198,11 @@ public function deleteOnClick($sender) { if (false == \App\ACL::checkEditDoc($doc, true)) return; - $doc = $doc->cast(); - if ($doc->canDeleted() == false) { - + $del = Document::delete($doc->document_id); + if (strlen($del) > 0) { + $this->setError($del); return; } - Document::delete($doc->document_id); $this->doclist->Reload(true); $this->resetURL(); } @@ -223,7 +225,7 @@ public function cancelOnClick($sender) { public function OnAutoCustomer($sender) { $text = Customer::qstr('%' . $sender->getText() . '%'); - return Customer::findArray("customer_name", "Customer_name like " . $text); + return Customer::findArray("customer_name", "customer_name like " . $text); } public function oncsv($sender) { diff --git a/www/app/pages/register/gilist.php b/www/app/pages/register/gilist.php index 3d19f0f4a..8457a479d 100644 --- a/www/app/pages/register/gilist.php +++ b/www/app/pages/register/gilist.php @@ -2,23 +2,23 @@ namespace App\Pages\Register; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\Paginator; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\Paginator; use \Zippy\Html\DataList\ArrayDataSource; use \Zippy\Binding\PropertyBinding as Prop; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Panel; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use App\Entity\Doc\Document; -use App\Helper as H; -use App\Application as App; -use App\System; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Panel; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \App\Entity\Doc\Document; +use \App\Helper as H; +use \App\Application as App; +use \App\System; /** * журнал продаж @@ -26,7 +26,7 @@ class GIList extends \App\Pages\Base { private $_doc = null; - public $_pays = array(); + /** * @@ -70,23 +70,14 @@ public function __construct() { $this->statuspan->add(new \App\Widgets\DocView('docview')); - $this->add(new Panel("paypan"))->setVisible(false); - $this->paypan->add(new Label("pname")); - $this->paypan->add(new Form('payform'))->onSubmit($this, 'payOnSubmit'); - - $this->paypan->payform->add(new TextInput('pamount')); - $this->paypan->payform->add(new TextInput('pcomment')); - $this->paypan->payform->add(new SubmitButton('bpay'))->onClick($this, 'payOnSubmit'); - - $this->paypan->add(new DataView('paylist', new ArrayDataSource(new Prop($this, '_pays')), $this, 'payOnRow'))->Reload(); - + $this->doclist->Reload(); $this->add(new ClickLink('csv', $this, 'oncsv')); } public function filterOnSubmit($sender) { - $this->paypan->setVisible(false); + $this->statuspan->setVisible(false); $this->doclist->Reload(false); @@ -102,8 +93,7 @@ public function doclistOnRow($row) { $row->add(new Label('amount', $doc->amount)); $row->add(new Label('order', $doc->headerdata['order'])); $row->add(new Label('customer', $doc->customer_name)); - $row->add(new Label('spay', $doc->amount - $doc->datatag)); - + $row->add(new Label('state', Document::getStateName($doc->state))); $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); @@ -114,8 +104,7 @@ public function doclistOnRow($row) { $row->edit->setVisible(false); } - $row->add(new ClickLink('pay'))->onClick($this, 'payOnClick'); - } + } public function statusOnSubmit($sender) { @@ -150,7 +139,7 @@ public function statusOnSubmit($sender) { if ($order instanceof Document) { $order = $order->cast(); - if ($order->state != Document::STATE_CLOSED && $this->_doc->amount == $this->_doc->datatag) { //если все доставлено и оплачено закрываем заказ + if ($order->state != Document::STATE_CLOSED && $this->_doc->amount == $this->_doc->payamount) { //если все доставлено и оплачено закрываем заказ $order->updateStatus(Document::STATE_CLOSED); $msg .= " Заказ {$order->document_number} закрыт"; } @@ -173,7 +162,7 @@ public function statusOnSubmit($sender) { $this->_doc->updateStatus(Document::STATE_CLOSED); if ($order instanceof Document) { $order = $order->cast(); - if ($order->state != Document::STATE_CLOSED && $this->_doc->amount == $this->_doc->datatag) { //если все выполнено и оплачено закрываем заказ + if ($order->state != Document::STATE_CLOSED && $this->_doc->amount == $this->_doc->payamount) { //если все выполнено и оплачено закрываем заказ $order->updateStatus(Document::STATE_CLOSED); $msg .= " Заказ {$order->document_number} закрыт"; } @@ -254,7 +243,7 @@ public function showOnClick($sender) { $this->_doc = $sender->owner->getDataItem(); if (false == \App\ACL::checkShowDoc($this->_doc, true)) return; - $this->paypan->setVisible(false); + $this->statuspan->setVisible(true); $this->statuspan->docview->setDoc($this->_doc); $this->doclist->setSelectedRow($sender->getOwner()); @@ -273,72 +262,7 @@ public function editOnClick($sender) { } //оплаты - public function payOnClick($sender) { - $this->statuspan->setVisible(false); - - - $this->_doc = $sender->owner->getDataItem(); - - - $this->paypan->setVisible(true); - - $this->statuspan->setVisible(false); - $this->doclist->setSelectedRow($sender->getOwner()); - $this->doclist->Reload(true); - - $this->goAnkor('dankor'); - - $this->paypan->payform->pamount->setText($this->_doc->amount - $this->_doc->datatag); - ; - $this->paypan->payform->pcomment->setText(""); - ; - $this->paypan->pname->setText($this->_doc->document_number); - ; - - $this->_pays = $this->_doc->getPayments(); - $this->paypan->paylist->Reload(); - } - - public function payOnRow($row) { - $pay = $row->getDataItem(); - $row->add(new Label('plamount', $pay->amount)); - $row->add(new Label('pluser', $pay->user)); - $row->add(new Label('pldate', date('Y-m-d', $pay->date))); - $row->add(new Label('plcomment', $pay->comment)); - } - - public function payOnSubmit($sender) { - $form = $this->paypan->payform; - $amount = $form->pamount->getText(); - if ($amount == 0) - return; - $amount = $form->pamount->getText(); - if ($amount == 0) - return; - - $this->_doc->addPayment(System::getUser()->getUserName(), $amount, $form->pcomment->getText()); - $this->_doc->datatag += $amount; - if ($this->_doc->datatag > $this->_doc->amount) { - $this->setWarn('Сумма больше необходимой оплаты'); - } - - $this->_doc->save(); - if ($this->_doc->datatag < $this->_doc->amount) { - //$this->_doc->updateStatus(Document::STATE_PART_PAYED); - } - if ($this->_doc->datatag == $this->_doc->amount) { - //$this->_doc->updateStatus(Document::STATE_PAYED); - } - $this->setSuccess('Оплата добавлена'); - - - - - $this->doclist->Reload(false); - ; - $this->paypan->setVisible(false); - } - + public function oncsv($sender) { $list = $this->doclist->getDataSource()->getItems(-1, -1, 'document_id'); $csv = ""; @@ -397,7 +321,7 @@ private function getWhere() { $where .= " and state = " . Document::STATE_INSHIPMENT; } if ($status == 4) { - $where .= " and amount > datatag"; + $where .= " and amount > payamount"; } if ($status == 5) { $where .= " and state = " . Document::STATE_INPROCESS; diff --git a/www/app/pages/register/grlist.php b/www/app/pages/register/grlist.php index 07e9f818a..ef4a9d8c4 100644 --- a/www/app/pages/register/grlist.php +++ b/www/app/pages/register/grlist.php @@ -2,23 +2,23 @@ namespace App\Pages\Register; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\Paginator; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\Paginator; use \Zippy\Html\DataList\ArrayDataSource; use \Zippy\Binding\PropertyBinding as Prop; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Panel; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use App\Entity\Doc\Document; -use App\Helper as H; -use App\Application as App; -use App\System; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Panel; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \App\Entity\Doc\Document; +use \App\Helper as H; +use \App\Application as App; +use \App\System; /** * журнал закупок @@ -26,7 +26,7 @@ class GRList extends \App\Pages\Base { private $_doc = null; - public $_pays = array(); + /** * @@ -66,23 +66,14 @@ public function __construct() { $this->statuspan->add(new \App\Widgets\DocView('docview')); - $this->add(new Panel("paypan"))->setVisible(false); - $this->paypan->add(new Label("pname")); - $this->paypan->add(new Form('payform'))->onSubmit($this, 'payOnSubmit'); - - $this->paypan->payform->add(new TextInput('pamount')); - $this->paypan->payform->add(new TextInput('pcomment')); - $this->paypan->payform->add(new SubmitButton('bpay'))->onClick($this, 'payOnSubmit'); - - $this->paypan->add(new DataView('paylist', new ArrayDataSource(new Prop($this, '_pays')), $this, 'payOnRow'))->Reload(); - + $this->doclist->Reload(); $this->add(new ClickLink('csv', $this, 'oncsv')); } public function filterOnSubmit($sender) { - $this->paypan->setVisible(false); + $this->statuspan->setVisible(false); $this->doclist->Reload(false); @@ -96,8 +87,7 @@ public function doclistOnRow($row) { $row->add(new Label('date', date('d-m-Y', $doc->document_date))); $row->add(new Label('onotes', $doc->notes)); $row->add(new Label('amount', $doc->amount)); - $row->add(new Label('spay', $doc->amount - $doc->datatag)); - $row->add(new Label('customer', $doc->customer_name)); + $row->add(new Label('customer', $doc->customer_name)); $row->add(new Label('state', Document::getStateName($doc->state))); @@ -108,8 +98,7 @@ public function doclistOnRow($row) { } else { $row->edit->setVisible(false); } - $row->add(new ClickLink('pay'))->onClick($this, 'payOnClick'); - } + } public function statusOnSubmit($sender) { @@ -138,7 +127,7 @@ public function showOnClick($sender) { $this->_doc = $sender->owner->getDataItem(); if (false == \App\ACL::checkShowDoc($this->_doc, true)) return; - $this->paypan->setVisible(false); + $this->statuspan->setVisible(true); $this->statuspan->docview->setDoc($this->_doc); $this->doclist->setSelectedRow($sender->getOwner()); @@ -156,77 +145,7 @@ public function editOnClick($sender) { App::Redirect("\\App\\Pages\\Doc\\GoodsReceipt", $doc->document_id); } - //оплаты - public function payOnClick($sender) { - $this->statuspan->setVisible(false); - - - $this->_doc = $sender->owner->getDataItem(); - - - $this->paypan->setVisible(true); - - $this->statuspan->setVisible(false); - $this->doclist->setSelectedRow($sender->getOwner()); - $this->doclist->Reload(false); - - $this->goAnkor('dankor'); - - $this->paypan->payform->pamount->setText($this->_doc->amount - $this->_doc->datatag); - ; - $this->paypan->payform->pcomment->setText(""); - ; - $this->paypan->pname->setText($this->_doc->document_number); - ; - - $this->_pays = $this->_doc->getPayments(); - $this->paypan->paylist->Reload(); - } - - public function payOnRow($row) { - $pay = $row->getDataItem(); - $row->add(new Label('plamount', $pay->amount)); - $row->add(new Label('pluser', $pay->user)); - $row->add(new Label('pldate', date('Y-m-d', $pay->date))); - $row->add(new Label('plcomment', $pay->comment)); - } - - public function payOnSubmit($sender) { - $form = $this->paypan->payform; - $amount = $form->pamount->getText(); - if ($amount == 0) - return; - $amount = $form->pamount->getText(); - if ($amount == 0) - return; - - $this->_doc->addPayment(System::getUser()->getUserName(), $amount, $form->pcomment->getText()); - $this->_doc->datatag += $amount; - if ($this->_doc->datatag > $this->_doc->amount) { - $this->setWarn('Сумма больше необходимой оплаты'); - } - - $this->_doc->save(); - if ($this->_doc->datatag < $this->_doc->amount) { - //$this->_doc->updateStatus(Document::STATE_PART_PAYED); - } - if ($this->_doc->datatag == $this->_doc->amount) { - $this->_doc->updateStatus(Document::STATE_PAYED); - } - $this->setSuccess('Оплата добавлена'); - if ($this->_doc->datatag == $this->_doc->amount) { - - //закрываем если есть домтавка - //$this->_doc->updateStatus(Document::STATE_CLOSED); - //$this->setSuccess('Наряд оплаче и закрыт'); - } - - - - $this->doclist->Reload(false); - $this->paypan->setVisible(false); - } - + public function oncsv($sender) { $list = $this->doclist->getDataSource()->getItems(-1, -1, 'document_id'); $csv = ""; @@ -282,7 +201,7 @@ private function getWhere() { $where .= " and state <>" . Document::STATE_EXECUTED; } if ($status == 2) { - $where .= " and amount > datatag"; + $where .= " and amount > payamount"; } if ($status == 3) { diff --git a/www/app/pages/register/ordercustlist.php b/www/app/pages/register/ordercustlist.php index 47ffd57f1..dc00001f5 100644 --- a/www/app/pages/register/ordercustlist.php +++ b/www/app/pages/register/ordercustlist.php @@ -2,23 +2,23 @@ namespace App\Pages\Register; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\Paginator; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\Paginator; use \Zippy\Html\DataList\ArrayDataSource; use \Zippy\Binding\PropertyBinding as Prop; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Panel; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use App\Entity\Doc\Document; -use App\Helper as H; -use App\Application as App; -use App\System; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Panel; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \App\Entity\Doc\Document; +use \App\Helper as H; +use \App\Application as App; +use \App\System; /** * журнал заявок @@ -34,7 +34,7 @@ class OrderCustList extends \App\Pages\Base { */ public function __construct() { parent::__construct(); - if (false == \App\ACL::checkShowReg('OrderList')) + if (false == \App\ACL::checkShowReg('OrderCustList')) return; $this->add(new Form('filter'))->onSubmit($this, 'filterOnSubmit'); @@ -106,7 +106,7 @@ public function doclistOnRow($row) { public function statusOnSubmit($sender) { $state = $this->_doc->state; - $payed = $this->_doc->datatag >= $this->_doc->amount; //оплачен + $payed = $this->_doc->payamount >= $this->_doc->amount; //оплачен $ttn = false; //проверяем что есть ТТН $list = $this->_doc->ConnectedDocList(); @@ -137,7 +137,7 @@ public function statusOnSubmit($sender) { } if ($sender->id == "bclose") { - $this->_doc->datatag = $this->_doc->amount; + $this->_doc->payamount = $this->_doc->amount; $this->_doc->save(); $this->_doc->updateStatus(Document::STATE_CLOSED); @@ -157,7 +157,7 @@ public function updateStatusButtons() { $state = $this->_doc->state; - $payed = $this->_doc->datatag >= $this->_doc->amount; //оплачен + $payed = $this->_doc->payamount >= $this->_doc->amount; //оплачен //доставлен $sent = $this->_doc->checkStates(array(Document::STATE_DELIVERED)); @@ -174,7 +174,7 @@ public function updateStatusButtons() { $this->statuspan->statusform->bttn->setVisible(!$ttn); //отмена если не было оплат и доставки - if ($this->_doc->datatag == 0) { + if ($this->_doc->payamount == 0) { $this->statuspan->statusform->bcancel->setVisible(false); } else { $this->statuspan->statusform->bcancel->setVisible(true); diff --git a/www/app/pages/register/orderlist.php b/www/app/pages/register/orderlist.php index 8830a6306..61ac79146 100644 --- a/www/app/pages/register/orderlist.php +++ b/www/app/pages/register/orderlist.php @@ -2,19 +2,19 @@ namespace App\Pages\Register; -use App\Application as App; -use App\Entity\Doc\Document; -use App\System; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\Paginator; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Panel; +use \App\Application as App; +use \App\Entity\Doc\Document; +use \App\System; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\Paginator; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Panel; /** * журнал заказов @@ -136,7 +136,7 @@ public function statusOnSubmit($sender) { if ($sender->id == "bclose") { - $this->_doc->datatag = $this->_doc->amount; + $this->_doc->payamount = $this->_doc->amount; $this->_doc->save(); $this->_doc->updateStatus(Document::STATE_CLOSED); @@ -302,7 +302,7 @@ private function getWhere() { $where .= " and state =1 "; } if ($status == 2) { - $where .= " and amount > datatag"; + $where .= " and amount > payamount"; } if ($status == 3) { diff --git a/www/app/pages/register/paycustlist.php b/www/app/pages/register/paycustlist.php new file mode 100644 index 000000000..cc84de02d --- /dev/null +++ b/www/app/pages/register/paycustlist.php @@ -0,0 +1,346 @@ +add(new Panel("clist")) ; + + $this->clist->add(new DataView('custlist', new ArrayDataSource($this,'_custlist'), $this, 'custlistOnRow')); + + $this->clist->add(new ClickLink('csv', $this, 'oncsv')); + + $this->add(new Panel("plist"))->setVisible(false); + $this->plist->add(new Label("cname")) ; + $this->plist->add(new ClickLink("back",$this,"onBack")) ; + + $doclist = $this->plist->add(new DataView('doclist', new ArrayDataSource($this,'_doclist'), $this, 'doclistOnRow')); + $doclist->setSelectedClass('table-success'); + + $this->add(new \App\Widgets\DocView('docview'))->setVisible(false); + + + $this->add(new Panel("paypan"))->setVisible(false); + $this->paypan->add(new Label("pname")); + $this->paypan->add(new Form('payform'))->onSubmit($this, 'payOnSubmit'); + $this->paypan->payform->add(new DropDownChoice('payment', \App\Entity\MoneyFund::getList(), H::getDefMF())); + $this->paypan->payform->add(new TextInput('pamount')); + $this->paypan->payform->add(new TextInput('pcomment')); + $this->paypan->payform->add(new SubmitButton('bpay'))->onClick($this, 'payOnSubmit'); + + $this->paypan->add(new DataView('paylist', new ArrayDataSource($this, '_pays'), $this, 'payOnRow'))->Reload(); + + + + $this->updateCust(); + + } + + + public function updateCust() { + + $sql = "select customer_name,fl,coalesce(sum(am),0) as sam from ( + select customer_name, ( amount - payamount) as am ,(case when meta_name in('GoodsReceipt') then -1 else 1 end) as fl + from `documents_view` where amount > 0 and amount <> payamount and state not in (1,2,3,17) and meta_name in('GoodsReceipt','GoodsIssue','Task','ServiceAct') + + ) t group by customer_name ,fl order by (sam) desc"; + $this->_custlist = \App\DataItem::query($sql); + $this->clist->custlist->Reload(); + } + + public function custlistOnRow($row) { + $cust = $row->getDataItem(); + $row->add(new Label('customer_name', $cust->customer_name)); + $row->add(new Label('credit',$cust->fl==-1 ? $cust->sam : "")); + $row->add(new Label('debet', $cust->fl==1 ? $cust->sam : "")); + + $row->add(new ClickLink('showdocs'))->onClick($this, 'showdocsOnClick'); + + } + + //список документов + public function showdocsOnClick($sender) { + + $this->_cust = $sender->owner->getDataItem(); + $this->plist->cname->setText($this->_cust->customer_name); + $this->updateDocs(); + + $this->clist->setVisible(false); + $this->plist->setVisible(true); + + } + + public function updateDocs() { + + if($this->_cust->fl == -1){ + $docs="'GoodsReceipt'"; + } + if($this->_cust->fl == 1){ + $docs="'GoodsIssue','Task','ServiceAct'"; + } + + + $sql = "select * from ( + select d.* ,(amount - payamount) as am + from `documents_view` where amount > 0 and amount <> payamount and state not in (1,2,3,17) and meta_name in({$docs}) + + ) t order by am desc "; + $this->_doclist = \App\Entity\Doc\Document::find("amount > 0 and amount <> payamount and state not in (1,2,3,17) and meta_name in({$docs})","(amount - payamount) desc"); + + $this->plist->doclist->Reload(); + } + + public function doclistOnRow($row) { + $doc = $row->getDataItem(); + + $row->add(new Label('name', $doc->meta_desc)); + $row->add(new Label('number', $doc->document_number)); + $row->add(new Label('date', date('d.m.Y',$doc->document_date))); + + + $row->add(new Label('amount', $doc->amount)); + $row->add(new Label('payamount', $doc->amount - $doc->payamount)); + + + + $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); + $row->add(new ClickLink('pay'))->onClick($this, 'payOnClick'); + + } + + //просмотр + public function showOnClick($sender) { + + $this->_doc = $sender->owner->getDataItem(); + if (false == \App\ACL::checkShowDoc($this->_doc, true)) + return; + $this->plist->doclist->setSelectedRow($sender->getOwner()); + $this->plist->doclist->Reload(false); + $this->docview->setVisible(true); + $this->paypan->setVisible(false); + $this->docview->setDoc($this->_doc); + $this->goAnkor('dankor'); + } + + public function onBack($sender) { + $this->clist->setVisible(true); + $this->plist->setVisible(false); + $this->docview->setVisible(false); + $this->paypan->setVisible(false); + $this->updateCust(); + } + //оплаты + public function payOnClick($sender) { + $this->docview->setVisible(false); + + + $this->_doc = $sender->owner->getDataItem(); + + + $this->paypan->setVisible(true); + + + $this->plist->doclist->setSelectedRow($sender->getOwner()); + $this->plist->doclist->Reload(false); + + $this->goAnkor('dankor'); + + $this->paypan->payform->pamount->setText($this->_doc->amount - $this->_doc->payamount); + ; + $this->paypan->payform->pcomment->setText(""); + ; + $this->paypan->pname->setText($this->_doc->document_number); + ; + + $this->_pays = \App\Entity\Pay::getPayments($this->_doc->document_id); + $this->paypan->paylist->Reload(); + } + + public function payOnRow($row) { + $pay = $row->getDataItem(); + $row->add(new Label('plamount', 0 - $pay->amount)); + $row->add(new Label('pluser', $pay->username)); + $row->add(new Label('pldate', date('Y-m-d', $pay->paydate))); + $row->add(new Label('plmft', $pay->mf_name)); + $row->add(new Label('plcomment', $pay->notes)); + } + + public function payOnSubmit($sender) { + $form = $this->paypan->payform; + $amount = $form->pamount->getText(); + if ($amount == 0) + return; + $amount = $form->pamount->getText(); + if ($amount == 0) + return; + + if ($amount > $this->_doc->amount) { + $this->setError('Сумма больше необходимой оплаты'); + return; + } + + + //закупки + if($this->_doc->meta_name == 'GoodsReceipt'){ + $amount = 0 - $amount; + } + + \App\Entity\Pay::addPayment($this->_doc->document_id, $amount, $form->payment->getValue(), $form->pcomment->getText()); + $this->_doc->payamount = abs(\App\Entity\Pay::getPaymentAmount($this->_doc->document_id)); + + + $this->_doc->save(); + + + $this->setSuccess('Оплата добавлена'); + + + $this->updateDocs(); + $this->paypan->setVisible(false); + } + + public function oncsv($sender) { + $list = $this->doclist->getDataSource()->getItems(-1, -1, 'document_id'); + $csv = ""; + + foreach ($list as $d) { + $csv .= date('Y.m.d', $d->document_date) . ';'; + $csv .= $d->document_number . ';'; + $csv .= $d->headerdata["pareaname"] . ';'; + $csv .= $d->amount . ';'; + $csv .= $d->notes . ';'; + $csv .= "\n"; + } + $csv = mb_convert_encoding($csv, "windows-1251", "utf-8"); + + + header("Content-type: text/csv"); + header("Content-Disposition: attachment;Filename=baylist.csv"); + header("Content-Transfer-Encoding: binary"); + + echo $csv; + flush(); + die; + } + +} + + + +class PayCustDataSource implements \Zippy\Interfaces\DataSource { + + private $page; + + public function __construct($page) { + $this->page = $page; + } + + + + public function getItemCount() { + + $conn = \ZDB\DB::getConnect(); + + return $conn->GetOne($sql); + } + + public function getItems($start, $count, $sortfield = null, $asc = null) { + $docs = Document::find($this->getWhere(), "document_date desc,document_id desc", $count, $start); + + + return $docs; + } + + public function getItem($id) { + + } + +} + +class PayCustDocDataSource implements \Zippy\Interfaces\DataSource { + + private $page; + + public function __construct($page) { + $this->page = $page; + } + + private function getWhere() { + $user = System::getUser(); + + $conn = \ZDB\DB::getConnect(); + + $where = " date(document_date) >= " . $conn->DBDate($this->page->filter->from->getDate()) . " and date(document_date) <= " . $conn->DBDate($this->page->filter->to->getDate()); + + $where .= " and meta_name in ('Task','ProdIssue','ProdReceipt') "; + + + + + $parea = $this->page->filter->parea->getValue(); + if ($parea > 0) { + $where .= " and content like '%{$parea}%' "; + } + + + + if ($user->acltype == 2) { + + + $where .= " and meta_id in({$user->aclview}) "; + } + return $where; + } + + public function getItemCount() { + return Document::findCnt($this->getWhere()); + } + + public function getItems($start, $count, $sortfield = null, $asc = null) { + $docs = Document::find($this->getWhere(), "document_date desc,document_id desc", $count, $start); + + return $docs; + } + + public function getItem($id) { + + } + +} diff --git a/www/app/pages/register/paylist.php b/www/app/pages/register/paylist.php new file mode 100644 index 000000000..68a8db7ea --- /dev/null +++ b/www/app/pages/register/paylist.php @@ -0,0 +1,199 @@ +add(new Form('filter'))->onSubmit($this, 'filterOnSubmit'); + $this->filter->add(new Date('from', time() - (7 * 24 * 3600))); + $this->filter->add(new Date('to', time() + (1 * 24 * 3600))); + $this->filter->add(new DropDownChoice('fmfund', \App\Entity\MoneyFund::getList(), 0)); + $this->filter->add(new DropDownChoice('fuser', \App\Entity\User::findArray('username', '', 'username'), 0)); + $this->filter->add(new AutocompleteTextInput('fcustomer'))->onText($this, 'OnAutoCustomer'); + + $doclist = $this->add(new DataView('doclist', new PayListDataSource($this), $this, 'doclistOnRow')); + + + $this->add(new Paginator('pag', $doclist)); + $doclist->setPageSize(25); + + + $this->add(new \App\Widgets\DocView('docview'))->setVisible(false); + + + $this->doclist->Reload(); + $this->add(new ClickLink('csv', $this, 'oncsv')); + } + + public function filterOnSubmit($sender) { + + + $this->docview->setVisible(false); + $this->doclist->Reload(); + } + + public function OnAutoCustomer($sender) { + $text = Customer::qstr('%' . $sender->getText() . '%'); + return Customer::findArray("customer_name", "customer_name like " . $text); + } + + public function doclistOnRow($row) { + $doc = $row->getDataItem(); + + $row->add(new Label('number', $doc->document_number)); + + $row->add(new Label('date', date('d-m-Y', strtotime($doc->paydate)))); + $row->add(new Label('notes', $doc->notes)); + $row->add(new Label('amountp', $doc->amount > 0 ? $doc->amount : "")); + $row->add(new Label('amountm', $doc->amount < 0 ? 0 - $doc->amount : "")); + + $row->add(new Label('mf_name', $doc->mf_name)); + $row->add(new Label('username', $doc->username)); + $row->add(new Label('customer_name', $doc->customer_name)); + + + + + $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); + } + + //просмотр + public function showOnClick($sender) { + + + $this->_doc = Document::load($sender->owner->getDataItem()->document_id); + + if (false == \App\ACL::checkShowDoc($this->_doc, true)) + return; + + $this->docview->setVisible(true); + $this->docview->setDoc($this->_doc); + } + + public function oncsv($sender) { + $list = $this->doclist->getDataSource()->getItems(-1, -1); + + $csv = "Дата;Счет;Приход;Расход;Документ;Создал;Контрагент;Примечание;"; + $csv .= "\n\n"; + + foreach ($list as $doc) { + + $csv .= date('Y.m.d', strtotime($doc->paydate)) . ';'; + $csv .= $doc->mf_name . ';'; + $csv .= ($doc->amount > 0 ? $doc->amount : "") . ';'; + $csv .= ($doc->amount < 0 ? 0 - $doc->amount : "" ) . ';'; + $csv .= $doc->document_number . ';'; + $csv .= $doc->username . ';'; + $csv .= $doc->customer_name . ';'; + $csv .= $doc->notes . ';'; + $csv .= "\n"; + } + $csv = mb_convert_encoding($csv, "windows-1251", "utf-8"); + + + header("Content-type: text/csv"); + header("Content-Disposition: attachment;Filename=baylist.csv"); + header("Content-Transfer-Encoding: binary"); + + echo $csv; + flush(); + die; + } + +} + +/** + * Источник данных для списка документов + */ +class PayListDataSource implements \Zippy\Interfaces\DataSource { + + private $page; + + public function __construct($page) { + $this->page = $page; + } + + private function getWhere() { + $user = System::getUser(); + + $conn = \ZDB\DB::getConnect(); + + $where = " date(paydate) >= " . $conn->DBDate($this->page->filter->from->getDate()) . " and date(paydate) <= " . $conn->DBDate($this->page->filter->to->getDate()); + + $author = $this->page->filter->fuser->getValue(); + $cust = $this->page->filter->fcustomer->getKey(); + $mf = $this->page->filter->fmfund->getValue(); + + + if ($cust > 0) { + $where .= " and d.customer_id=" . $cust; + } + if ($mf > 0) { + $where .= " and p.mf_id=" . $mf; + } + if ($author > 0) { + $where .= " and p.user_id=" . $author; + } + if ($user->acltype == 2) { + $where .= " and d.meta_id in({$user->aclview}) "; + } + return $where; + } + + public function getItemCount() { + $conn = \ZDB\DB::getConnect(); + $sql = "select coalesce(count(*),0) from documents_view d join `paylist_view` p on d.`document_id` = p.`document_id` where " . $this->getWhere(); + return $conn->GetOne($sql); + } + + public function getItems($start, $count, $sortfield = null, $asc = null) { + + $conn = \ZDB\DB::getConnect(); + $sql = "select p.*,d.`customer_name`,d.`meta_id` from documents_view d join `paylist_view` p on d.`document_id` = p.`document_id` where " . $this->getWhere() . " order by pl_id desc "; + if ($count > 0) + $sql .= " limit {$start},{$count}"; + + $docs = Document::findBySql($sql); + + return $docs; + } + + public function getItem($id) { + + } + +} diff --git a/www/app/pages/register/prodlist.php b/www/app/pages/register/prodlist.php index b6ce64bfb..a61efc023 100644 --- a/www/app/pages/register/prodlist.php +++ b/www/app/pages/register/prodlist.php @@ -2,23 +2,23 @@ namespace App\Pages\Register; -use Zippy\Html\DataList\DataView; -use Zippy\Html\DataList\Paginator; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\DataList\Paginator; use \Zippy\Html\DataList\ArrayDataSource; use \Zippy\Binding\PropertyBinding as Prop; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\SubmitButton; -use Zippy\Html\Panel; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use App\Entity\Doc\Document; -use App\Helper as H; -use App\Application as App; -use App\System; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\SubmitButton; +use \Zippy\Html\Panel; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \App\Entity\Doc\Document; +use \App\Helper as H; +use \App\Application as App; +use \App\System; /** * журнал закупок @@ -26,7 +26,6 @@ class ProdList extends \App\Pages\Base { private $_doc = null; - /** * @@ -35,7 +34,7 @@ class ProdList extends \App\Pages\Base { */ public function __construct() { parent::__construct(); - if (false == \App\ACL::checkShowReg('GRList')) + if (false == \App\ACL::checkShowReg('ProdList')) return; $this->add(new Form('filter'))->onSubmit($this, 'filterOnSubmit'); @@ -43,8 +42,8 @@ public function __construct() { $this->filter->add(new Date('to', time() + (1 * 24 * 3600))); $this->filter->add(new DropDownChoice('parea', \App\Entity\Prodarea::findArray("pa_name", ""), 0)); - - + + $doclist = $this->add(new DataView('doclist', new ProdDataSource($this), $this, 'doclistOnRow')); $doclist->setSelectedClass('table-success'); @@ -54,17 +53,17 @@ public function __construct() { $this->add(new \App\Widgets\DocView('docview'))->setVisible(false); - - + + $this->doclist->Reload(); $this->add(new ClickLink('csv', $this, 'oncsv')); } public function filterOnSubmit($sender) { - - $this->docview->setVisible(false); + + $this->docview->setVisible(false); $this->doclist->Reload(); } @@ -76,18 +75,15 @@ public function doclistOnRow($row) { $row->add(new Label('date', date('d-m-Y', $doc->document_date))); $row->add(new Label('onotes', $doc->notes)); $row->add(new Label('amount', $doc->amount)); - + $row->add(new Label('pareaname', $doc->headerdata["pareaname"])); - + $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); - } - - //просмотр public function showOnClick($sender) { @@ -96,7 +92,7 @@ public function showOnClick($sender) { return; $this->doclist->setSelectedRow($sender->getOwner()); $this->doclist->Reload(false); - $this->docview->setVisible(true); + $this->docview->setVisible(true); $this->docview->setDoc($this->_doc); } @@ -106,11 +102,9 @@ public function editOnClick($sender) { return; - App::Redirect("\\App\\Pages\\Doc\\".$doc->meta_name, $doc->document_id); + App::Redirect("\\App\\Pages\\Doc\\" . $doc->meta_name, $doc->document_id); } - - public function oncsv($sender) { $list = $this->doclist->getDataSource()->getItems(-1, -1, 'document_id'); $csv = ""; @@ -161,13 +155,12 @@ private function getWhere() { $parea = $this->page->filter->parea->getValue(); - if($parea >0){ - $where .= " and content like '%{$parea}%' "; - + if ($parea > 0) { + $where .= " and content like '%{$parea}%' "; } - - + + if ($user->acltype == 2) { diff --git a/www/app/pages/register/stocklist.php b/www/app/pages/register/stocklist.php index e8d54029d..e689d4fc0 100644 --- a/www/app/pages/register/stocklist.php +++ b/www/app/pages/register/stocklist.php @@ -22,6 +22,7 @@ class StockList extends \App\Pages\Base { public $_item; + public function __construct() { parent::__construct(); if (false == \App\ACL::checkShowReg('StockList')) @@ -30,9 +31,9 @@ public function __construct() { $this->add(new Form('filter'))->onSubmit($this, 'OnFilter'); $this->filter->add(new TextInput('searchkey')); $this->filter->add(new DropDownChoice('searchcat', Category::findArray("cat_name", "", "cat_name"), 0)); - - $this->add(new Panel('itempanel')) ; + + $this->add(new Panel('itempanel')); $this->itempanel->add(new DataView('itemlist', new ItemDataSource($this), $this, 'itemlistOnRow')); $this->itempanel->itemlist->setPageSize(25); @@ -42,42 +43,50 @@ public function __construct() { $this->itempanel->itemlist->Reload(); $this->itempanel->add(new ClickLink('csv', $this, 'oncsv')); - - + + $this->add(new Panel('detailpanel'))->setVisible(false); $this->detailpanel->add(new ClickLink('back'))->onClick($this, 'backOnClick'); $this->detailpanel->add(new Label('itemdetname')); $this->detailpanel->add(new DataView('stocklist', new DetailDataSource($this), $this, 'detailistOnRow')); - } public function itemlistOnRow($row) { $item = $row->getDataItem(); - + $row->add(new Label('itemname', $item->itemname)); $row->add(new Label('code', $item->item_code)); $row->add(new Label('msr', $item->msr)); - - $row->add(new Label('qty',H::fqty($item->qty))); - - + + $row->add(new Label('qty', H::fqty($item->qty))); + + $row->add(new Label('cat_name', $item->cat_name)); $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); - - - } - + public function OnFilter($sender) { $this->itempanel->itemlist->Reload(); } - - + public function detailistOnRow($row) { $stock = $row->getDataItem(); $row->add(new Label('storename', $stock->storename)); - + $row->add(new Label('snumber', $stock->snumber)); + $row->add(new Label('sdate', '')); + + $row->add(new Label('sedate', '')); + + + + if (strlen($stock->snumber) > 0) { + $row->sdate->setText(date('Y-m-d', $stock->sdate)); + if ($this->_item->term > 0) { + $term = strtotime("+{$this->_item->term} month", $stock->sdate); + $row->sedate->setText(date('Y-m-d', $term)); + } + } $row->add(new Label('partion', $stock->partion)); $stock->qty = $stock->qty - $stock->wqty + $stock->rqty; $q = "" . H::fqty($stock->qty) . ""; @@ -96,7 +105,7 @@ public function detailistOnRow($row) { $row->add(new Label('amount', round($stock->qty * $stock->partion))); $item = Item::load($stock->item_id); - + $plist = array(); if ($item->price1 > 0) @@ -114,33 +123,32 @@ public function detailistOnRow($row) { } public function backOnClick($sender) { - - $this->itempanel->setVisible(true); - $this->detailpanel->setVisible(false); - + + $this->itempanel->setVisible(true); + $this->detailpanel->setVisible(false); } + public function showOnClick($sender) { - $this->_item = $sender->getOwner()->getDataItem(); - $this->itempanel->setVisible(false); - $this->detailpanel->setVisible(true); - $this->detailpanel->itemdetname->setText($this->_item->itemname); - $this->detailpanel->stocklist->Reload(); + $this->_item = $sender->getOwner()->getDataItem(); + $this->itempanel->setVisible(false); + $this->detailpanel->setVisible(true); + $this->detailpanel->itemdetname->setText($this->_item->itemname); + $this->detailpanel->stocklist->Reload(); } - public function oncsv($sender) { $list = $this->itempanel->itemlist->getDataSource()->getItems(-1, -1, 'itemname'); $csv = ""; foreach ($list as $st) { - + $csv .= $st->itemname . ';'; $csv .= $st->item_code . ';'; - + $csv .= $st->msr . ';'; $csv .= $st->cat_name . ';'; $csv .= H::fqty($st->qty) . ';'; - + $csv .= "\n"; } $csv = mb_convert_encoding($csv, "windows-1251", "utf-8"); @@ -157,7 +165,6 @@ public function oncsv($sender) { } - class ItemDataSource implements \Zippy\Interfaces\DataSource { private $page; @@ -172,8 +179,8 @@ private function getWhere() { $form = $this->page->filter; $where = " qty>0 and disabled <> 1 "; - - + + $cat = $form->searchcat->getValue(); @@ -184,20 +191,20 @@ private function getWhere() { if (strlen($text) > 0) { $form->searchcat->setValue(0); //поиск независимо от категории $text = Stock::qstr('%' . $text . '%'); - $where = " (itemname like {$text} or item_code like {$text} ) "; + $where = " (itemname like {$text} or item_code like {$text} ) "; } - - + + return $where; } - public function getItemCount() { + public function getItemCount() { return Item::findCnt($this->getWhere()); } public function getItems($start, $count, $sortfield = null, $asc = null) { - return Item::find($this->getWhere(), "itemname asc", $count, $start); + return Item::find($this->getWhere(), "itemname asc", $count, $start); } public function getItem($id) { @@ -215,21 +222,21 @@ public function __construct($page) { } private function getWhere() { - + $form = $this->page->filter; $where = "item_id = {$this->page->_item->item_id} and (qty <> 0 or rqty <> 0 or wqty <> 0) "; - - + + return $where; } - public function getItemCount() { + public function getItemCount() { return Stock::findCnt($this->getWhere()); } public function getItems($start, $count, $sortfield = null, $asc = null) { - return Stock::find($this->getWhere(), "", $count, $start); + return Stock::find($this->getWhere(), "", $count, $start); } public function getItem($id) { diff --git a/www/app/pages/register/tasklist.php b/www/app/pages/register/tasklist.php index 26c791da3..e8d187685 100644 --- a/www/app/pages/register/tasklist.php +++ b/www/app/pages/register/tasklist.php @@ -39,9 +39,9 @@ class TaskList extends \App\Pages\Base { public $_store_id = 0; public $_discount = 0; private $_taskscnt = array(); - public $_pays = array(); + public $_tamount = 0; - public $_tdebet = 0; + public function __construct() { @@ -69,18 +69,9 @@ public function __construct() { $this->add(new Label("tamount")); - $this->add(new Label("tdebet")); - - $this->add(new Panel("paypan"))->setVisible(false); - $this->paypan->add(new Label("pname")); - $this->paypan->add(new Form('payform'))->onSubmit($this, 'payOnSubmit'); - - $this->paypan->payform->add(new TextInput('pamount')); - $this->paypan->payform->add(new TextInput('pcomment')); - $this->paypan->payform->add(new SubmitButton('bpay'))->onClick($this, 'payOnSubmit'); - - $this->paypan->add(new DataView('paylist', new ArrayDataSource(new Prop($this, '_pays')), $this, 'payOnRow'))->Reload(); + + $this->add(new Panel("statuspan"))->setVisible(false); @@ -118,10 +109,6 @@ public function tasklistOnRow($row) { $row->taskstatus->setText('Выполняется', true); if ($task->state == Document::STATE_SHIFTED) $row->taskstatus->setText('Отложена', true); - if ($task->state == Document::STATE_WP) - $row->taskstatus->setText('Ожидает оплату', true); - if ($task->state == Document::STATE_PART_PAYED) - $row->taskstatus->setText('Ожидает оплату', true); if ($task->state == Document::STATE_CLOSED) $row->taskstatus->setText('Закончено', true); @@ -141,14 +128,14 @@ public function tasklistOnRow($row) { $row->add(new Label('taskemps', implode(', ', $emps))); $row->add(new Label('taskclient', $task->customer_name)); $row->add(new Label('taskamount', $task->amount)); - $row->add(new Label('taskdebet', $task->amount - $task->datatag)); - + $this->_tamount = $this->_tamount + $task->amount; - $this->_tdebet = $this->_tdebet + $task->amount - $task->datatag; - + $row->add(new ClickLink('taskshow'))->onClick($this, 'taskshowOnClick'); $row->add(new ClickLink('taskedit'))->onClick($this, 'taskeditOnClick'); - $row->add(new ClickLink('taskpay'))->onClick($this, 'taskpayOnClick'); + if ($task->state == Document::STATE_CLOSED) { + $row->taskedit->setVisible(false); + } } //панель кнопок @@ -157,7 +144,7 @@ public function taskshowOnClick($sender) { if (false == \App\ACL::checkShowDoc($this->_task, true)) return; - $this->paypan->setVisible(false); + $this->statuspan->setVisible(true); // if ($this->_task->checkStates(array(Document::STATE_EXECUTED)) == false || $this->_task->status == Document::STATE_EDITED || $this->_task->status == Document::STATE_NEW) { @@ -181,8 +168,6 @@ public function taskshowOnClick($sender) { } - - $this->statuspan->docview->setDoc($this->_task); $this->tasklist->setSelectedRow($sender->getOwner()); $this->tasklist->Reload(false); @@ -208,16 +193,9 @@ public function onStatus($sender) { } if ($sender->id == 'bclosed') { $this->_task->updateStatus(Document::STATE_EXECUTED); - if ($this->_task->amount == $this->_task->datatag) { //если оплачен + if ($this->_task->amount == $this->_task->payamount) { //если оплачен $this->_task->updateStatus(Document::STATE_CLOSED); $this->setSuccess('Наряд закрыт'); - } else { - if ($this->_task->datatag == 0) { - $this->_task->updateStatus(Document::STATE_WP); - } - if ($this->_task->datatag > 0) { - // $this->_task->updateStatus(Document::STATE_PART_PAYED); - } } } @@ -226,72 +204,8 @@ public function onStatus($sender) { $this->tasklist->Reload(false); } - //панель оплат - public function taskpayOnClick($sender) { - $this->_task = $sender->getOwner()->getDataItem(); - - $this->paypan->setVisible(true); - - $this->statuspan->setVisible(false); - $this->tasklist->setSelectedRow($sender->getOwner()); - $this->tasklist->Reload(false); - - $this->goAnkor('dankor'); - - $this->paypan->payform->pamount->setText($this->_task->amount - $this->_task->datatag); - ; - $this->paypan->payform->pcomment->setText(""); - ; - $this->paypan->pname->setText($this->_task->document_number); - ; - - $this->_pays = $this->_task->getPayments(); - $this->paypan->paylist->Reload(); - } - - public function payOnRow($row) { - $pay = $row->getDataItem(); - $row->add(new Label('plamount', $pay->amount)); - $row->add(new Label('pluser', $pay->user)); - $row->add(new Label('pldate', date('Y-m-d', $pay->date))); - $row->add(new Label('plcomment', $pay->comment)); - } - - public function payOnSubmit($sender) { - $form = $this->paypan->payform; - $amount = $form->pamount->getText(); - if ($amount == 0) - return; - $amount = $form->pamount->getText(); - if ($amount == 0) - return; - - $this->_task->addPayment(System::getUser()->getUserName(), $amount, $form->pcomment->getText()); - $this->_task->datatag += $amount; - if ($this->_task->datatag > $this->_task->amount) { - $this->setWarn('Сумма больше необходимой оплаты'); - } - - $this->_task->save(); - if ($this->_task->datatag < $this->_task->amount) { - // $this->_task->updateStatus(Document::STATE_PART_PAYED); - } - if ($this->_task->datatag == $this->_task->amount) { - $this->_task->updateStatus(Document::STATE_PAYED); - } - $this->setSuccess('Оплата добавлена'); - if ($this->_task->datatag == $this->_task->amount && $this->_task->checkStates(array(Document::STATE_EXECUTED))) { - //закрываем если был выполнен - $this->_task->updateStatus(Document::STATE_CLOSED); - $this->setSuccess('Наряд оплаче и закрыт'); - } - - - - $this->updateTasks(); - $this->paypan->setVisible(false); - } - + + public function updateTasks() { $user = System::getUser(); @@ -319,17 +233,17 @@ public function updateTasks() { $sql .= " and meta_id in({$user->aclview}) "; } $this->_tamount = 0; - $this->_tdebet = 0; + $this->_taskds->setWhere($sql); $this->tasklist->Reload(); $this->tamount->setText($this->_tamount); - $this->tdebet->setText($this->_tdebet); + $this->updateCal(); $this->statuspan->setVisible(false); - $this->paypan->setVisible(false); + } //обновить календар @@ -347,7 +261,7 @@ public function updateCal() { $col = "#ffc107"; if ($item->state == Document::STATE_CLOSED) $col = "#dddddd"; - if ($item->state == Document::STATE_CLOSED && $item->amount > $task->datatag) + if ($item->state == Document::STATE_CLOSED && $item->amount > $task->payamount) $col = "#ff0000"; diff --git a/www/app/pages/report/abc.php b/www/app/pages/report/abc.php index 31598962f..c62aef4bb 100644 --- a/www/app/pages/report/abc.php +++ b/www/app/pages/report/abc.php @@ -2,12 +2,12 @@ namespace App\Pages\Report; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Label; -use Zippy\Html\Link\RedirectLink; -use Zippy\Html\Panel; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Label; +use \Zippy\Html\Link\RedirectLink; +use \Zippy\Html\Panel; /** * АВС анализ diff --git a/www/app/pages/report/emptask.php b/www/app/pages/report/emptask.php index b43cba870..870f0b675 100644 --- a/www/app/pages/report/emptask.php +++ b/www/app/pages/report/emptask.php @@ -2,16 +2,16 @@ namespace App\Pages\Report; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\RedirectLink; -use Zippy\Html\Panel; -use App\Entity\Employee; -use App\Entity\Doc\Document; -use App\Helper as H; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\RedirectLink; +use \Zippy\Html\Panel; +use \App\Entity\Employee; +use \App\Entity\Doc\Document; +use \App\Helper as H; /** * Движение товара diff --git a/www/app/pages/report/income.php b/www/app/pages/report/income.php index 64ab97d82..db6465488 100644 --- a/www/app/pages/report/income.php +++ b/www/app/pages/report/income.php @@ -2,16 +2,16 @@ namespace App\Pages\Report; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\RedirectLink; -use Zippy\Html\Panel; -use App\Entity\Item; -use App\Entity\Store; -use App\Helper as H; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\RedirectLink; +use \Zippy\Html\Panel; +use \App\Entity\Item; +use \App\Entity\Store; +use \App\Helper as H; /** * Отчет по закупкам diff --git a/www/app/pages/report/itemactivity.php b/www/app/pages/report/itemactivity.php index b81241124..8b4890a40 100644 --- a/www/app/pages/report/itemactivity.php +++ b/www/app/pages/report/itemactivity.php @@ -6,13 +6,15 @@ use \Zippy\Html\Form\DropDownChoice; use \Zippy\Html\Form\Form; use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\TextInput; use \Zippy\Html\Label; use \Zippy\Html\Link\RedirectLink; use \Zippy\Html\Panel; use \App\Entity\Item; use \App\Entity\Store; +use \App\Entity\Stock; use \App\Helper as H; -use App\Application as App; +use \App\Application as App; /** * Движение товара @@ -27,9 +29,9 @@ public function __construct() { $this->add(new Form('filter'))->onSubmit($this, 'OnSubmit'); $this->filter->add(new Date('from', time() - (7 * 24 * 3600))); $this->filter->add(new Date('to', time())); + $this->filter->add(new TextInput('snumber'))->setVisible(false); $this->filter->add(new DropDownChoice('store', Store::getList(), H::getDefStore())); - $this->filter->add(new AutocompleteTextInput('item'))->onText($this, 'OnAutoItem'); $this->add(new \Zippy\Html\Link\ClickLink('autoclick'))->onClick($this, 'OnAutoLoad', true); @@ -90,14 +92,19 @@ private function generateReport() { $storeid = $this->filter->store->getValue(); $itemid = $this->filter->item->getKey(); + $snumber = $this->filter->snumber->getText(); + + $it = "1=1"; + if ($itemid > 0) { + $it .= " and st.item_id=" . $itemid; + } + if (strlen($snumber) > 0) { + $it .= " and st.snumber=" . Stock::qstr($snumber); + } - $it = $itemid > 0 ? "st.item_id=" . $itemid : "1=1"; $from = $this->filter->from->getDate(); $to = $this->filter->to->getDate(); - - - $i = 1; $detail = array(); $conn = \ZDB\DB::getConnect(); @@ -130,7 +137,7 @@ private function generateReport() { date(sc.document_date) AS dt, SUM(CASE WHEN quantity > 0 THEN quantity ELSE 0 END) AS obin, SUM(CASE WHEN quantity < 0 THEN 0 - quantity ELSE 0 END) AS obout, - GROUP_CONCAT(dc.document_number) AS docs + GROUP_CONCAT(distinct dc.document_number) AS docs FROM entrylist_view sc JOIN store_stock_view st ON sc.stock_id = st.stock_id @@ -152,7 +159,7 @@ private function generateReport() { $detail[] = array( "code" => $row['item_code'], "name" => $row['itemname'], - "date" => date("d.m.Y", strtotime($row['dt'])), + "date" => date("Y-m-d", strtotime($row['dt'])), "documents" => $row['docs'], "in" => H::fqty(strlen($row['begin_quantity']) > 0 ? $row['begin_quantity'] : 0), "obin" => H::fqty($row['obin']), diff --git a/www/app/pages/report/outcome.php b/www/app/pages/report/outcome.php index 2d1d69631..8e5e0faa1 100644 --- a/www/app/pages/report/outcome.php +++ b/www/app/pages/report/outcome.php @@ -2,16 +2,16 @@ namespace App\Pages\Report; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\RedirectLink; -use Zippy\Html\Panel; -use App\Entity\Item; -use App\Entity\Store; -use App\Helper as H; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\RedirectLink; +use \Zippy\Html\Panel; +use \App\Entity\Item; +use \App\Entity\Store; +use \App\Helper as H; /** * Отчет по продажам @@ -105,9 +105,9 @@ private function generateReport() { order by i.`itemname` "; } - if ($type == 2) { //по постащикам + if ($type == 2) { //по покупателям $sql = " - select c.`customer_name` as itemname,c.`customer_id`, sum(0-e.`amount`) as summa + select c.`customer_name` as itemname,c.`customer_id`, sum(0-e.`amount`) as summa, sum(e.extcode*(0-e.`quantity`)) as navar from `entrylist_view` e join `customers` c on c.`customer_id` = e.`customer_id` diff --git a/www/app/pages/report/payactivity.php b/www/app/pages/report/payactivity.php new file mode 100644 index 000000000..fc88dbb5a --- /dev/null +++ b/www/app/pages/report/payactivity.php @@ -0,0 +1,178 @@ +add(new Form('filter'))->onSubmit($this, 'OnSubmit'); + $this->filter->add(new Date('from', time() - (7 * 24 * 3600))); + $this->filter->add(new Date('to', time())); + $this->filter->add(new DropDownChoice('mf', MoneyFund::getList(), H::getDefMF())); + + + $this->add(new \Zippy\Html\Link\ClickLink('autoclick'))->onClick($this, 'OnAutoLoad', true); + + $this->add(new Panel('detail'))->setVisible(false); + $this->detail->add(new RedirectLink('print', "mfreport")); + $this->detail->add(new RedirectLink('html', "mfreport")); + $this->detail->add(new RedirectLink('word', "mfreport")); + $this->detail->add(new RedirectLink('excel', "mfreport")); + $this->detail->add(new RedirectLink('pdf', "mfreport")); + $this->detail->add(new Label('preview')); + \App\Session::getSession()->issubmit = false; + } + + public function OnSubmit($sender) { + + + + $html = $this->generateReport(); + $this->detail->preview->setText($html, true); + \App\Session::getSession()->printform = "" . $html . ""; + + // \ZippyERP\System\Session::getSession()->storereport = "" . $html . ""; + $reportpage = "App/Pages/ShowReport"; + $reportname = "mfreport"; + + + $this->detail->print->pagename = $reportpage; + $this->detail->print->params = array('print', $reportname); + $this->detail->html->pagename = $reportpage; + $this->detail->html->params = array('html', $reportname); + $this->detail->word->pagename = $reportpage; + $this->detail->word->params = array('doc', $reportname); + $this->detail->excel->pagename = $reportpage; + $this->detail->excel->params = array('xls', $reportname); + $this->detail->pdf->pagename = $reportpage; + $this->detail->pdf->params = array('pdf', $reportname); + + $this->detail->setVisible(true); + + $this->detail->preview->setText("Загрузка...", true); + \App\Session::getSession()->printform = ""; + \App\Session::getSession()->issubmit = true; + } + + private function generateReport() { + + $mf_id = $this->filter->mf->getValue(); + + + $from = $this->filter->from->getDate(); + $to = $this->filter->to->getDate(); + + $i = 1; + $detail = array(); + $conn = \ZDB\DB::getConnect(); + + $sql = " + SELECT t.*, + + ( + SELECT + + COALESCE(SUM(sc2.`amount`), 0) + FROM paylist_view sc2 + + WHERE + sc2.mf_id = {$mf_id} + + AND sc2.paydate < t.dt + + + ) as begin_amount + + from ( + select + + date(sc.paydate) AS dt, + SUM(CASE WHEN amount > 0 THEN amount ELSE 0 END) AS obin, + SUM(CASE WHEN amount < 0 THEN 0 - amount ELSE 0 END) AS obout, + GROUP_CONCAT(distinct sc.document_number) AS docs + FROM paylist_view sc + WHERE + sc.mf_id = {$mf_id} + AND DATE(sc.paydate) >= " . $conn->DBDate($from) . " + AND DATE(sc.paydate) <= " . $conn->DBDate($to) . " + GROUP BY + DATE(sc.paydate) ) t + ORDER BY t.dt + "; + + + $rs = $conn->Execute($sql); + + $tend = 0; + $tin = 0; + $tout = 0; + foreach ($rs as $row) { + + + $detail[] = array( + "date" => date("Y-m-d", strtotime($row['dt'])), + "documents" => $row['docs'], + "in" => strlen($row['begin_amount']) > 0 ? $row['begin_amount'] : 0, + "obin" => $row['obin'], + "obout" => $row['obout'], + "out" => $row['begin_amount'] + $row['obin'] - $row['obout'] + ); + $tend = $row['begin_amount'] + $row['obin'] - $row['obout']; + $tin += $row['obin']; + $tout += $row['obout']; + } + $tb = $tend - $tin + $tout; + + $header = array('datefrom' => date('d.m.Y', $from), + "_detail" => $detail, + 'tb' => $tb, + 'tin' => $tin, + 'tout' => $tout, + 'tend' => $tend, + 'dateto' => date('d.m.Y', $to), + "mf_name" => MoneyFund::load($mf_id)->mf_name + ); + $report = new \App\Report('payactivity.tpl'); + + $html = $report->generate($header); + + return $html; + } + + public function OnAutoLoad($sender) { + + if (\App\Session::getSession()->issubmit === true) { + $html = $this->generateReport(); + \App\Session::getSession()->printform = "" . $html . ""; + $this->detail->preview->setText($html, true); + $this->updateAjax(array('preview')); + } + } + + public function beforeRender() { + parent::beforeRender(); + + App::addJavaScript("\$('#autoclick').click()", true); + } + +} diff --git a/www/app/pages/report/prod.php b/www/app/pages/report/prod.php index 900e9a48b..2c1ebebd6 100644 --- a/www/app/pages/report/prod.php +++ b/www/app/pages/report/prod.php @@ -2,16 +2,16 @@ namespace App\Pages\Report; -use Zippy\Html\Form\Date; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\RedirectLink; -use Zippy\Html\Panel; -use App\Entity\Employee; -use App\Entity\Doc\Document; -use App\Helper as H; +use \Zippy\Html\Form\Date; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\RedirectLink; +use \Zippy\Html\Panel; +use \App\Entity\Employee; +use \App\Entity\Doc\Document; +use \App\Helper as H; /** * отчет по производству @@ -26,7 +26,7 @@ public function __construct() { $this->add(new Form('filter'))->onSubmit($this, 'OnSubmit'); $this->filter->add(new Date('from', time() - (7 * 24 * 3600))); $this->filter->add(new Date('to', time())); - $this->filter->add(new DropDownChoice('parea', \App\Entity\Prodarea::findArray("pa_name", ""), 0)); + $this->filter->add(new DropDownChoice('parea', \App\Entity\Prodarea::findArray("pa_name", ""), 0)); $this->add(new Panel('detail'))->setVisible(false); $this->detail->add(new RedirectLink('print', "movereport")); @@ -78,11 +78,11 @@ private function generateReport() { $sum2 = 0; $conn = \ZDB\DB::getConnect(); - $wparea = ""; - if($parea >0){ - $wparea = " and content like '%{$parea}%' "; + $wparea = ""; + if ($parea > 0) { + $wparea = " and content like '%{$parea}%' "; } - + $sql = " select i.`itemname`,i.`item_code`,0-sum(e.`quantity`) as qty, 0-sum(e.`amount`) as summa from `entrylist_view` e @@ -145,8 +145,8 @@ private function generateReport() { 'sum1' => $sum1, 'sum2' => $sum2 ); - if($parea >0){ - $header['parea'] = $this->filter->parea->getValueName() ; + if ($parea > 0) { + $header['parea'] = $this->filter->parea->getValueName(); } $report = new \App\Report('prod.tpl'); diff --git a/www/app/pages/showdoc.php b/www/app/pages/showdoc.php index 01588efe4..9f678d303 100644 --- a/www/app/pages/showdoc.php +++ b/www/app/pages/showdoc.php @@ -2,7 +2,7 @@ namespace App\Pages; -use App\Entity\Doc\Document; +use \App\Entity\Doc\Document; //страница для загрузки файла экпорта class ShowDoc extends \Zippy\Html\WebPage { diff --git a/www/app/pages/userprofile.php b/www/app/pages/userprofile.php index 8189d9cdc..2c4eaa193 100644 --- a/www/app/pages/userprofile.php +++ b/www/app/pages/userprofile.php @@ -2,13 +2,13 @@ namespace App\Pages; -use Zippy\Binding\PropertyBinding as Bind; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Form\CheckBox; -use Zippy\Html\Form\DropDownChoice; -use Zippy\Html\Form\Form; -use Zippy\Html\Label; -use App\System; +use \Zippy\Binding\PropertyBinding as Bind; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Form\CheckBox; +use \Zippy\Html\Form\DropDownChoice; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Label; +use \App\System; use \Zippy\Html\DataList\DataView; class UserProfile extends \App\Pages\Base { diff --git a/www/app/pages/users.php b/www/app/pages/users.php index eb3a67942..9eb37eee7 100644 --- a/www/app/pages/users.php +++ b/www/app/pages/users.php @@ -51,10 +51,11 @@ public function __construct() { $this->editpan->editform->add(new CheckBox('editwdebitors')); $this->editpan->editform->add(new CheckBox('editwnoliq')); $this->editpan->editform->add(new CheckBox('editwminqty')); + $this->editpan->editform->add(new CheckBox('editwsdate')); //модули $this->editpan->editform->add(new CheckBox('editocstore')); $this->editpan->editform->add(new CheckBox('editshop')); - + @@ -99,13 +100,15 @@ public function onEdit($sender) { $this->editpan->editform->editwnoliq->setChecked(true); if (strpos($this->user->widgets, 'wminqty') !== false) $this->editpan->editform->editwminqty->setChecked(true); + if (strpos($this->user->widgets, 'wsdate') !== false) + $this->editpan->editform->editwsdate->setChecked(true); + if (strpos($this->user->widgets, 'wrdoc') !== false) + $this->editpan->editform->editwrdoc->setChecked(true); if (strpos($this->user->modules, 'ocstore') !== false) $this->editpan->editform->editocstore->setChecked(true); if (strpos($this->user->modules, 'shop') !== false) $this->editpan->editform->editshop->setChecked(true); - - } public function saveOnClick($sender) { @@ -166,18 +169,22 @@ public function saveOnClick($sender) { $widgets = $widgets . ',wnoliq'; if ($this->editpan->editform->editwminqty->isChecked()) $widgets = $widgets . ',wminqty'; + if ($this->editpan->editform->editwsdate->isChecked()) + $widgets = $widgets . ',wsdate'; + if ($this->editpan->editform->editwrdoc->isChecked()) + $widgets = $widgets . ',wrdoc'; $this->user->widgets = trim($widgets, ','); - + $modules = ""; if ($this->editpan->editform->editshop->isChecked()) $modules = $modules . ',shop'; if ($this->editpan->editform->editocstore->isChecked()) $modules = $modules . ',ocstore'; - + $this->user->modules = trim($modules, ','); - + $this->user->save(); $this->listpan->userrow->Reload(); $this->listpan->setVisible(true); @@ -199,7 +206,12 @@ public function onAcl($sender) { //удаление юзера public function OnRemove($sender) { $user = $sender->getOwner()->getDataItem(); - User::delete($user->user_id); + $del = User::delete($user->user_id); + if (strlen($del) > 0) { + $this->setError($del); + return; + } + $this->listpan->userrow->Reload(); } diff --git a/www/app/widgets/docview.php b/www/app/widgets/docview.php index c5f90df17..63567b3a8 100644 --- a/www/app/widgets/docview.php +++ b/www/app/widgets/docview.php @@ -2,20 +2,20 @@ namespace App\Widgets; -use Zippy\Binding\PropertyBinding as Prop; -use Zippy\Html\DataList\ArrayDataSource; -use Zippy\Html\DataList\DataView; -use Zippy\Html\Form\AutocompleteTextInput; -use Zippy\Html\Form\Form; -use Zippy\Html\Form\TextArea; -use Zippy\Html\Form\TextInput; -use Zippy\Html\Label; -use Zippy\Html\Link\ClickLink; -use Zippy\Html\Link\RedirectLink; -use App\Entity\Doc\Document; -use App\Helper; -use App\Application as App; -use App\System; +use \Zippy\Binding\PropertyBinding as Prop; +use \Zippy\Html\DataList\ArrayDataSource; +use \Zippy\Html\DataList\DataView; +use \Zippy\Html\Form\AutocompleteTextInput; +use \Zippy\Html\Form\Form; +use \Zippy\Html\Form\TextArea; +use \Zippy\Html\Form\TextInput; +use \Zippy\Html\Label; +use \Zippy\Html\Link\ClickLink; +use \Zippy\Html\Link\RedirectLink; +use \App\Entity\Doc\Document; +use \App\Helper; +use \App\Application as App; +use \App\System; /** * Виджет для просмотра документов @@ -65,8 +65,6 @@ public function setDoc(\App\Entity\Doc\Document $doc) { $this->_doc = $doc; $doc = $this->_doc->cast(); - - $html = $doc->generateReport(); $this->preview->setText($html, true); // проверяем поддержку экспорта @@ -98,7 +96,7 @@ public function setDoc(\App\Entity\Doc\Document $doc) { $this->dw_statelist->Reload(); //оплаты - $this->_paylist = $this->_doc->getPayments(); + $this->_paylist = \App\Entity\Pay::getPayments($this->_doc->document_id); $this->dw_paylist->Reload(); //список приатаченных файлов @@ -138,18 +136,20 @@ public function detailDocOnClick($sender) { public function stateListOnRow($row) { $item = $row->getDataItem(); $row->add(new Label('statehost', $item->hostname)); - $row->add(new Label('statedate', date('Y.m.d H:i', $item->updatedon))); + $row->add(new Label('statedate', date('Y.m.d H:i', $item->createdon))); $row->add(new Label('stateuser', $item->username)); - $row->add(new Label('statename', Document::getStateName($item->state))); + $row->add(new Label('statename', Document::getStateName($item->docstate))); } //вывод строки оплат public function payListOnRow($row) { $item = $row->getDataItem(); - $row->add(new Label('paydate', date('Y-m-d', $item->date))); - $row->add(new Label('payamount', $item->amount)); - $row->add(new Label('payuser', $item->user)); - $row->add(new Label('paycomment', $item->comment)); + $row->add(new Label('paydate', date('Y-m-d', $item->paydate))); + $row->add(new Label('payamountp', $item->amount > 0 ? $item->amount : "")); + $row->add(new Label('payamountm', $item->amount < 0 ? 0 - $item->amount : "")); + $row->add(new Label('payuser', $item->username)); + $row->add(new Label('paycomment', $item->notes)); + $row->add(new Label('paymf', $item->mf_name)); } /** diff --git a/www/app/widgets/wdebitors.php b/www/app/widgets/wdebitors.php index b4f7423de..28b3c58eb 100644 --- a/www/app/widgets/wdebitors.php +++ b/www/app/widgets/wdebitors.php @@ -27,10 +27,10 @@ public function __construct($id) { $conn = $conn = \ZDB\DB::getConnect(); $sql = "select * from ( - select meta_desc,document_number, customer_name, ( datatag-amount) as am - from `documents_view` where meta_name in ('GoodsIssue','GoodsReceipt','Task','ServiceAct') and amount > datatag + select meta_desc,document_number, customer_name, abs( amount - payamount) as am + from `documents_view` where amount > 0 and amount <> payamount and state not in (1,2,3,17) and meta_name in('GoodsReceipt','GoodsIssue','Task','ServiceAct') - ) t order by am "; + ) t order by am desc "; if ($visible) { @@ -43,7 +43,7 @@ public function __construct($id) { $list = $this->add(new DataView('ddoclist', new ArrayDataSource($data), $this, 'OnRow')); $list->Reload(); - $list->setPageSize(10); + $list->setPageSize(10); $this->add(new \Zippy\Html\DataList\Paginator("wdpag", $list)); $list->Reload(); if (count($data) == 0 || $visible == false) { @@ -55,7 +55,7 @@ public function OnRow($row) { $item = $row->getDataItem(); $row->add(new Label('cust', $item->customer_name)); - $row->add(new Label('amount', 0 - ($item->am))); + $row->add(new Label('amount', $item->am)); $row->add(new Label('type', $item->meta_desc)); $row->add(new Label('number', $item->document_number)); } diff --git a/www/app/widgets/wminqty.php b/www/app/widgets/wminqty.php index 86be5084b..3bdbea8fb 100644 --- a/www/app/widgets/wminqty.php +++ b/www/app/widgets/wminqty.php @@ -16,8 +16,7 @@ /** * Виджет для минимального количества на складе */ -class WMinQty extends \Zippy\Html\PageFragment -{ +class WMinQty extends \Zippy\Html\PageFragment { public function __construct($id) { parent::__construct($id); @@ -39,10 +38,10 @@ public function __construct($id) { foreach ($rs as $row) { $data[$row['item_id']] = new DataItem($row); - } + } } - $mqlist = $this->add(new DataView('mqlist', new ArrayDataSource($data), $this, 'noliqlistOnRow')); + $mqlist = $this->add(new DataView('mqlist', new ArrayDataSource($data), $this, 'mqlistOnRow')); $mqlist->setPageSize(10); $this->add(new \Zippy\Html\DataList\Paginator("mqpag", $mqlist)); $mqlist->Reload(); @@ -53,7 +52,7 @@ public function __construct($id) { }; } - public function noliqlistOnRow($row) { + public function mqlistOnRow($row) { $item = $row->getDataItem(); $row->add(new Label('itemname', $item->itemname)); diff --git a/www/app/widgets/wnoliq.php b/www/app/widgets/wnoliq.php index 21b56988f..1a47a2bb4 100644 --- a/www/app/widgets/wnoliq.php +++ b/www/app/widgets/wnoliq.php @@ -16,8 +16,7 @@ /** * Виджет для просмотра неликвидных товаров */ -class WNoliq extends \Zippy\Html\PageFragment -{ +class WNoliq extends \Zippy\Html\PageFragment { public function __construct($id) { parent::__construct($id); diff --git a/www/app/widgets/wplanneddocs.php b/www/app/widgets/wplanneddocs.php index 95eec6d6a..af5059d3e 100644 --- a/www/app/widgets/wplanneddocs.php +++ b/www/app/widgets/wplanneddocs.php @@ -29,7 +29,7 @@ public function __construct($id) { // список запланированных документов $where = "state not in( " . Document::STATE_CANCELED . "," . Document::STATE_EDITED . "," . Document::STATE_NEW . ") "; $where = $where . " and document_date >= " . $conn->DBDate(strtotime('-5 days')); - $where = $where . " and meta_name in ('ServiceAct','GoodsIssue','GoodsReceipt') "; + // $where = $where . " and meta_name in ('ServiceAct','GoodsIssue','GoodsReceipt') "; $where = $where . " and content like '%1%'"; if ($visible) { $data = Document::find($where, "document_date desc"); @@ -49,7 +49,8 @@ public function doclistOnRow($row) { $item = $row->getDataItem(); $item = $item->cast(); $dt = date('d-m-Y', $item->document_date); - $row->add(new Label('number', $item->document_number)); + $row->add(new \Zippy\Html\Link\RedirectLink("number", "\\App\\Pages\\Register\\DocList", $item->document_id))->setValue($item->document_number); + $row->add(new Label('date', $dt)); $row->add(new Label('type', $item->meta_desc)); @@ -59,12 +60,12 @@ public function doclistOnRow($row) { $end = $date->endOfDay()->timestamp; if (time() < $start) { - $row->number->setAttribute('class', 'badge '); + $row->date->setAttribute('class', 'badge '); } else if (time() > $end) { - $row->number->setAttribute('class', 'badge badge-danger'); + $row->date->setAttribute('class', 'badge badge-danger'); } else { - $row->number->setAttribute('class', 'badge badge-warning'); + $row->date->setAttribute('class', 'badge badge-warning'); } } diff --git a/www/app/widgets/wrdoc.php b/www/app/widgets/wrdoc.php new file mode 100644 index 000000000..ee7e4602f --- /dev/null +++ b/www/app/widgets/wrdoc.php @@ -0,0 +1,60 @@ +widgets, 'wrdoc') !== false || System::getUser()->userlogin == 'admin'); + + $conn = $conn = \ZDB\DB::getConnect(); + $data = array(); + + if ($visible) { + $sql = "select distinct document_id,meta_desc,document_number from docstatelog_view where user_id={$user->user_id} and createdon > " . $conn->DBDate(strtotime("-1 month", time())) . " order by log_id desc"; + + + $rc = $conn->Execute($sql); + + foreach ($rc as $row) { + $data[] = new \App\DataItem($row); + } + } + + $doclist = $this->add(new DataView('rdoclist', new ArrayDataSource($data), $this, 'doclistOnRow')); + + + $doclist->Reload(); + + if (count($data) == 0 || $visible == false) { + $this->setVisible(false); + }; + } + + public function doclistOnRow($row) { + $item = $row->getDataItem(); + + + + + $row->add(new Label('type', $item->meta_desc)); + $row->add(new \Zippy\Html\Link\RedirectLink("number", "\\App\\Pages\\Register\\DocList", $item->document_id))->setValue($item->document_number); + } + +} diff --git a/www/app/widgets/wsdate.php b/www/app/widgets/wsdate.php new file mode 100644 index 000000000..8dcb8f22e --- /dev/null +++ b/www/app/widgets/wsdate.php @@ -0,0 +1,75 @@ +widgets, 'wsdate') !== false || System::getUser()->userlogin == 'admin'); + + $conn = $conn = \ZDB\DB::getConnect(); + $data = array(); + + + + + + if ($visible) { + $items = Item::find("item_id in(select item_id from store_stock where sdate is not null)"); + + $stock = Stock::find("sdate is not null"); + + + foreach ($stock as $st) { + $item = $items[$st->item_id]; + if ($item->term > 0) { + $edate = strtotime("+{$item->term} month", $st->sdate); + if ($edate < time()) { + $st->edate = $edate; + $data[$row['item_id']] = $st; + } + } + } + } + + $sdlist = $this->add(new DataView('sdlist', new ArrayDataSource($data), $this, 'sdlistOnRow')); + $sdlist->setPageSize(10); + $this->add(new \Zippy\Html\DataList\Paginator("sdpag", $sdlist)); + $sdlist->Reload(); + + unset($items); + unset($stock); + + if (count($data) == 0 || $visible == false) { + $this->setVisible(false); + }; + } + + public function sdlistOnRow($row) { + $stock = $row->getDataItem(); + + $row->add(new Label('storename', $stock->storename)); + $row->add(new Label('itemname', $stock->itemname)); + $row->add(new Label('snumber', $stock->snumber)); + $row->add(new Label('edate', date('Y-m-d', $stock->edate))); + $row->add(new Label('qty', Helper::fqty($stock->qty))); + } + +} diff --git a/www/composer.json b/www/composer.json index b986c6d8b..9b36c0459 100644 --- a/www/composer.json +++ b/www/composer.json @@ -10,6 +10,6 @@ "dompdf/dompdf": "v0.8.2", "roave/security-advisories": "dev-master", "rmccue/requests": ">=1.0", - "leon-mbs/zippy": "2.1.7" + "leon-mbs/zippy": "2.1.8" } } \ No newline at end of file diff --git a/www/composer.lock b/www/composer.lock index 166d54134..7c2c20012 100644 --- a/www/composer.lock +++ b/www/composer.lock @@ -4,20 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "4828ee45d50ee19724725fae2e83aec1", + "hash": "828dd5b9b513945e650d70e2504ae247", + "content-hash": "fb37ffb4f3bfe6b2bf59f1d02871c1d4", "packages": [ { "name": "adodb/adodb-php", - "version": "v5.20.12", + "version": "v5.20.14", "source": { "type": "git", "url": "https://github.com/ADOdb/ADOdb.git", - "reference": "0e5243790c5a02a88b0dfe78c390fe795ad2d672" + "reference": "a32113c6b3e4e2cb8ae6b49752527d5668a9d7a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ADOdb/ADOdb/zipball/0e5243790c5a02a88b0dfe78c390fe795ad2d672", - "reference": "0e5243790c5a02a88b0dfe78c390fe795ad2d672", + "url": "https://api.github.com/repos/ADOdb/ADOdb/zipball/a32113c6b3e4e2cb8ae6b49752527d5668a9d7a6", + "reference": "a32113c6b3e4e2cb8ae6b49752527d5668a9d7a6", "shasum": "" }, "require": { @@ -58,7 +59,7 @@ "library", "php" ], - "time": "2018-03-30T17:31:04+00:00" + "time": "2019-01-05 23:16:44" }, { "name": "dompdf/dompdf", @@ -120,7 +121,7 @@ ], "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", "homepage": "https://github.com/dompdf/dompdf", - "time": "2017-11-26T14:49:08+00:00" + "time": "2017-11-26 14:49:08" }, { "name": "electrolinux/phpquery", @@ -160,7 +161,7 @@ ], "description": "phpQuery is a server-side, chainable, CSS3 selector driven Document Object Model (DOM) API based on jQuery JavaScript Library", "homepage": "http://code.google.com/p/phpquery/", - "time": "2013-03-21T12:39:33+00:00" + "time": "2013-03-21 12:39:33" }, { "name": "ircmaxell/password-compat", @@ -202,7 +203,7 @@ "hashing", "password" ], - "time": "2014-11-20T16:49:30+00:00" + "time": "2014-11-20 16:49:30" }, { "name": "jbzoo/data", @@ -266,7 +267,7 @@ "params", "yml" ], - "time": "2017-11-17T15:20:26+00:00" + "time": "2017-11-17 15:20:26" }, { "name": "jbzoo/image", @@ -336,7 +337,7 @@ "thumbnail", "watermark" ], - "time": "2016-06-08T14:21:19+00:00" + "time": "2016-06-08 14:21:19" }, { "name": "jbzoo/utils", @@ -426,24 +427,24 @@ "utility", "utils" ], - "time": "2017-07-19T21:25:44+00:00" + "time": "2017-07-19 21:25:44" }, { "name": "leon-mbs/zdb", - "version": "1.1.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/leon-mbs/zdb.git", - "reference": "d756d6bf5172dfefcc0f18dcca524d1a6747a68f" + "reference": "5e45065f0f14dff6ec82ea255edb7fcf8632f03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/leon-mbs/zdb/zipball/d756d6bf5172dfefcc0f18dcca524d1a6747a68f", - "reference": "d756d6bf5172dfefcc0f18dcca524d1a6747a68f", + "url": "https://api.github.com/repos/leon-mbs/zdb/zipball/5e45065f0f14dff6ec82ea255edb7fcf8632f03c", + "reference": "5e45065f0f14dff6ec82ea255edb7fcf8632f03c", "shasum": "" }, "require": { - "adodb/adodb-php": "v5.20.12", + "adodb/adodb-php": "v5.20.14", "php": ">=5.4.0" }, "type": "library", @@ -468,25 +469,25 @@ "database", "php" ], - "time": "2018-11-08T23:38:18+00:00" + "time": "2019-06-13 11:05:37" }, { "name": "leon-mbs/zippy", - "version": "2.1.7", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/leon-mbs/zippy.git", - "reference": "d3f01409831afa16393925baef435005c18c1654" + "reference": "c6e81df4f0ab0532a049009f2b10856cb130e05d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/leon-mbs/zippy/zipball/d3f01409831afa16393925baef435005c18c1654", - "reference": "d3f01409831afa16393925baef435005c18c1654", + "url": "https://api.github.com/repos/leon-mbs/zippy/zipball/c6e81df4f0ab0532a049009f2b10856cb130e05d", + "reference": "c6e81df4f0ab0532a049009f2b10856cb130e05d", "shasum": "" }, "require": { "electrolinux/phpquery": ">=0.9.6", - "leon-mbs/zdb": ">=1.0.8", + "leon-mbs/zdb": "1.2.0", "mustache/mustache": "v2.12.0", "php": ">=5.4.0" }, @@ -512,7 +513,7 @@ "framework", "php" ], - "time": "2019-06-06T09:34:14+00:00" + "time": "2019-06-13 11:11:56" }, { "name": "monolog/monolog", @@ -590,7 +591,7 @@ "logging", "psr-3" ], - "time": "2017-06-19T01:22:40+00:00" + "time": "2017-06-19 01:22:40" }, { "name": "mustache/mustache", @@ -636,7 +637,7 @@ "mustache", "templating" ], - "time": "2017-07-11T12:54:05+00:00" + "time": "2017-07-11 12:54:05" }, { "name": "nesbot/carbon", @@ -684,7 +685,7 @@ "datetime", "time" ], - "time": "2018-05-29T15:23:46+00:00" + "time": "2018-05-29 15:23:46" }, { "name": "nikic/php-parser", @@ -735,7 +736,7 @@ "parser", "php" ], - "time": "2018-02-28T20:30:58+00:00" + "time": "2018-02-28 20:30:58" }, { "name": "phenx/php-font-lib", @@ -772,7 +773,7 @@ ], "description": "A library to read, parse, export and make subsets of different types of font files.", "homepage": "https://github.com/PhenX/php-font-lib", - "time": "2017-09-13T16:14:37+00:00" + "time": "2017-09-13 16:14:37" }, { "name": "phenx/php-svg-lib", @@ -812,7 +813,7 @@ ], "description": "A library to read, parse and export to PDF SVG files.", "homepage": "https://github.com/PhenX/php-svg-lib", - "time": "2018-06-03T10:10:03+00:00" + "time": "2018-06-03 10:10:03" }, { "name": "phpmailer/phpmailer", @@ -889,7 +890,7 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", - "time": "2018-11-15T22:32:31+00:00" + "time": "2018-11-15 22:32:31" }, { "name": "psr/log", @@ -936,7 +937,7 @@ "psr", "psr-3" ], - "time": "2018-11-20T15:27:04+00:00" + "time": "2018-11-20 15:27:04" }, { "name": "rmccue/requests", @@ -985,7 +986,7 @@ "iri", "sockets" ], - "time": "2016-10-13T00:11:37+00:00" + "time": "2016-10-13 00:11:37" }, { "name": "roave/security-advisories", @@ -993,12 +994,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "4c0ba8a35f1f12dd9236452e9fae4346b0bf2a56" + "reference": "acc661e72817c7030b7b2af7d2f226bee9b93094" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/4c0ba8a35f1f12dd9236452e9fae4346b0bf2a56", - "reference": "4c0ba8a35f1f12dd9236452e9fae4346b0bf2a56", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/acc661e72817c7030b7b2af7d2f226bee9b93094", + "reference": "acc661e72817c7030b7b2af7d2f226bee9b93094", "shasum": "" }, "conflict": { @@ -1093,7 +1094,10 @@ "shopware/shopware": "<5.3.7", "silverstripe/cms": ">=3,<=3.0.11|>=3.1,<3.1.11", "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", - "silverstripe/framework": ">=3,<3.6.7|>=3.7,<3.7.3|>=4,<4.0.7|>=4.1,<4.1.5|>=4.2,<4.2.4|>=4.3,<4.3.1", + "silverstripe/framework": ">=3,<3.6.7|>=3.7,<3.7.3|>=4,<4.4", + "silverstripe/graphql": ">=2,<2.0.5|>=3,<3.1.2", + "silverstripe/registry": ">=2.1,<2.1.2|>=2.2,<2.2.1", + "silverstripe/restfulserver": ">=1,<1.0.9|>=2,<2.0.4", "silverstripe/userforms": "<3", "simple-updates/phpwhois": "<=1", "simplesamlphp/saml2": "<1.10.6|>=2,<2.3.8|>=3,<3.1.4", @@ -1196,7 +1200,7 @@ } ], "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2019-05-23T20:42:12+00:00" + "time": "2019-06-11 05:51:05" }, { "name": "sabberworm/php-css-parser", @@ -1240,7 +1244,7 @@ "parser", "stylesheet" ], - "time": "2016-07-19T19:14:21+00:00" + "time": "2016-07-19 19:14:21" }, { "name": "symfony/polyfill-mbstring", @@ -1299,7 +1303,7 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-02-06 07:57:58" }, { "name": "symfony/translation", @@ -1369,7 +1373,7 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2019-05-01T11:10:09+00:00" + "time": "2019-05-01 11:10:09" }, { "name": "timetoogo/pinq", @@ -1417,7 +1421,7 @@ "pinq", "query" ], - "time": "2017-09-06T06:27:03+00:00" + "time": "2017-09-06 06:27:03" } ], "packages-dev": [], diff --git a/www/index.php b/www/index.php index 912eec57b..6eabbd4d4 100644 --- a/www/index.php +++ b/www/index.php @@ -29,8 +29,8 @@ $app = new \App\Application(); - if($_config['common']['shop'] == 1){ - $app->Run('\App\Shop\Pages\Main'); + if($_config['modules']['shop'] == 1){ + $app->Run('\App\Modules\Shop\Pages\Main'); } else { $app->Run('\App\Pages\Main'); } diff --git a/www/templates/index.html b/www/templates/index.html index 7292b29ac..f81e9ddd4 100644 --- a/www/templates/index.html +++ b/www/templates/index.html @@ -1,12 +1,12 @@ - - - + + + - - Страница не найдена. Перейдите на главную - + + Страница не найдена. Перейдите на главную + \ No newline at end of file diff --git a/www/templates/modules/ocstore/items.html b/www/templates/modules/ocstore/items.html index 3791f36de..631a149f7 100644 --- a/www/templates/modules/ocstore/items.html +++ b/www/templates/modules/ocstore/items.html @@ -1,110 +1,110 @@ - - - -
+ + + +

Экспорт новых товаров

- +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
НаименованиеАртикулКол.Цена Описание
-
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
НаименованиеАртикулКол.Цена Описание
+
+ + - +   - -
- + +
+

Обновление цен и количеств

- +
- -
+ +

Загрузка товаров с магазина

- +
-
- - +
+ + diff --git a/www/templates/modules/ocstore/options.html b/www/templates/modules/ocstore/options.html index 268625b91..0d9924e11 100644 --- a/www/templates/modules/ocstore/options.html +++ b/www/templates/modules/ocstore/options.html @@ -1,59 +1,59 @@ - + - +

Настройки соединения

-
- - -
-
- - -
-
- - -
+
+ + +
+
+ + +
+
+ + +
- - - Условный контрагент от имени котрого будут формироватся заказы - + + Условный контрагент от имени котрого будут формироватся заказы +
- - - + + +
-
- - - - -
+
+ + + + +
-
- - - +
+ + + diff --git a/www/templates/modules/ocstore/orders.html b/www/templates/modules/ocstore/orders.html index 4b77fea95..b96178866 100644 --- a/www/templates/modules/ocstore/orders.html +++ b/www/templates/modules/ocstore/orders.html @@ -1,8 +1,8 @@ - - - -
+ + + +

Импорт заказов

@@ -14,46 +14,46 @@

Импорт заказов

- + - + - - + +
- + - + - + - - - + + + - + - + - - + + @@ -61,67 +61,67 @@

Импорт заказов

Номер ДатаКлиент Сумма Комментарий
-
+

Экспорт статусов в магазин

-
- - - - - - - - - - - - - - - - - - - - - - - + +
НомерOC НомерДатаКлиентСумма Статус
+ + + + + - + + + + + + + + + + + + + + + + + + + +
НомерOC НомерДата
КлиентСумма Статус
+ + +
+ - - - -
- - - + - -
- - + +
+ +
- + - + diff --git a/www/templates/shop/pages/aboutus.html b/www/templates/modules/shop/pages/aboutus.html similarity index 100% rename from www/templates/shop/pages/aboutus.html rename to www/templates/modules/shop/pages/aboutus.html diff --git a/www/templates/shop/pages/base.html b/www/templates/modules/shop/pages/base.html similarity index 99% rename from www/templates/shop/pages/base.html rename to www/templates/modules/shop/pages/base.html index aa3e7c7ce..80f71b6f7 100644 --- a/www/templates/shop/pages/base.html +++ b/www/templates/modules/shop/pages/base.html @@ -62,9 +62,9 @@
- + - + + diff --git a/www/templates/pages/register/stocklist.html b/www/templates/pages/register/stocklist.html index 174533891..84ddad355 100644 --- a/www/templates/pages/register/stocklist.html +++ b/www/templates/pages/register/stocklist.html @@ -11,61 +11,65 @@

Товары на складе

- + - + - + Скачать CSV - - - + + + - + - - + + - + - + - +
НазваниеНазваниеАртикул Категория Ед.Кол.
- + -
- К списку -

- +
- + {{#usesnumber}} + + + + {{/usesnumber}} @@ -76,7 +80,11 @@

- + {{#usesnumber}} + + + + {{/usesnumber}} @@ -85,7 +93,7 @@

СкладСерияДата серииГоден до Зак. цена Кол. На сумму
-
+ diff --git a/www/templates/pages/register/tasklist.html b/www/templates/pages/register/tasklist.html index edf5b6022..0b76f5e27 100644 --- a/www/templates/pages/register/tasklist.html +++ b/www/templates/pages/register/tasklist.html @@ -88,14 +88,8 @@

Журнал нарядов

Исполнители Статус Сумма - К оплате - - - - - - - + + @@ -109,7 +103,7 @@

Журнал нарядов

- + @@ -117,8 +111,7 @@

Журнал нарядов

-    -    +    @@ -126,39 +119,14 @@

Журнал нарядов

Всего - +
-
-
- - - Оплаты ( )
- - - - - - - - - -
  
-
+
diff --git a/www/templates/pages/report/itemactivity.html b/www/templates/pages/report/itemactivity.html index 9b67c1788..4cc5dddc2 100644 --- a/www/templates/pages/report/itemactivity.html +++ b/www/templates/pages/report/itemactivity.html @@ -21,6 +21,9 @@

Движение по складу

+ + + diff --git a/www/templates/pages/report/payactivity.html b/www/templates/pages/report/payactivity.html new file mode 100644 index 000000000..015fb6530 --- /dev/null +++ b/www/templates/pages/report/payactivity.html @@ -0,0 +1,47 @@ + + + + + +
+
+

Движение по счетам

+ + + +
+
+ + + + + + +
+ + + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/www/templates/pages/report/prod.html b/www/templates/pages/report/prod.html index fb6d88b8a..ba6fe609f 100644 --- a/www/templates/pages/report/prod.html +++ b/www/templates/pages/report/prod.html @@ -15,12 +15,12 @@

Отчет по производству

- + - + diff --git a/www/templates/pages/userlogin.html b/www/templates/pages/userlogin.html index e828d9fef..5e521c72d 100644 --- a/www/templates/pages/userlogin.html +++ b/www/templates/pages/userlogin.html @@ -1,81 +1,74 @@ - - - - Zippy Склад - - - - - + + + + Zippy Склад + + + + + - - - - + + + + - - + + - + - - - + + + - + - + + +
+
+
+
+ +
+
+ +
+
-
- -
- - -
- -
-
- -
- -
- - - -
-
-
+
+ -
- - - - - - +
+ + +
+
+
+ v1.4.0 © zippy.com.ua +
-
-
- v1.3.5 © zippy.com.ua -
-
- +