diff --git a/1.jpg b/1.jpg new file mode 100644 index 000000000..101f112e5 Binary files /dev/null and b/1.jpg differ diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bb055ab4..3958d0642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ CHANGELOG ========= +### v4.9.0 (2021-04-03) +* Упрощена работа с онлайн-каталогом +* Добавлена иерархия категорий товаров (используется в онлайн-каталоге) +* Настройка в справочнике ТМЦ автоматического пориходования и списания на производство согласно комплектации. +* Исправления и мелкие дополнения + +Для обновления версии обновить папки app, templates, templates_ua, + выполнить update485to490.sql + ### v4.8.5 (2021-03-12) * В справочник контрагентов добавлена возможность работы с лидами * Обновление календаря в нарядах и табеле diff --git a/db/db.sql b/db/db.sql index 65b96f43c..9291dec82 100644 --- a/db/db.sql +++ b/db/db.sql @@ -60,8 +60,11 @@ CREATE TABLE `customers` ( `phone` varchar(64) DEFAULT NULL, `status` smallint(4) NOT NULL DEFAULT '0', `city` varchar(255) DEFAULT NULL, + `leadstatus` varchar(255) DEFAULT NULL, + `leadsource` varchar(255) DEFAULT NULL, + `createdon` date DEFAULT NULL, PRIMARY KEY (`customer_id`) -) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `customers_view`; /*!50001 DROP VIEW IF EXISTS `customers_view`*/; @@ -75,6 +78,8 @@ SET character_set_client = utf8; 1 AS `phone`, 1 AS `status`, 1 AS `city`, + 1 AS `leadsource`, + 1 AS `leadstatus`, 1 AS `mcnt`, 1 AS `fcnt`, 1 AS `ecnt`*/; @@ -91,7 +96,7 @@ CREATE TABLE `docstatelog` ( `hostname` varchar(64) NOT NULL, PRIMARY KEY (`log_id`), KEY `document_id` (`document_id`) -) ENGINE=InnoDB AUTO_INCREMENT=1521 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1667 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `docstatelog_view`; /*!50001 DROP VIEW IF EXISTS `docstatelog_view`*/; @@ -135,7 +140,7 @@ CREATE TABLE `documents` ( KEY `user_id` (`user_id`), KEY `branch_id` (`branch_id`), CONSTRAINT `documents_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=417 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=462 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `documents_view`; /*!50001 DROP VIEW IF EXISTS `documents_view`*/; @@ -175,7 +180,7 @@ CREATE TABLE `employees` ( `emp_name` varchar(64) NOT NULL, `branch_id` int(11) DEFAULT '0', PRIMARY KEY (`employee_id`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `entrylist`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -185,7 +190,7 @@ CREATE TABLE `entrylist` ( `document_id` int(11) NOT NULL, `amount` decimal(11,2) NOT NULL DEFAULT '0.00', `quantity` decimal(11,3) DEFAULT '0.000', - `extcode` int(11) DEFAULT '0', + `extcode` decimal(11,2) DEFAULT '0.00', `stock_id` int(11) DEFAULT NULL, `service_id` int(11) DEFAULT NULL, PRIMARY KEY (`entry_id`), @@ -193,9 +198,10 @@ CREATE TABLE `entrylist` ( KEY `stock_id` (`stock_id`), CONSTRAINT `entrylist_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`document_id`), CONSTRAINT `entrylist_ibfk_2` FOREIGN KEY (`stock_id`) REFERENCES `store_stock` (`stock_id`) -) ENGINE=InnoDB AUTO_INCREMENT=908 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=973 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - /*!50003 SET @saved_cs_client = @@character_set_client */ ; + +/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; @@ -220,7 +226,9 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; - /*!50003 SET @saved_cs_client = @@character_set_client */ ; + + +/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; @@ -244,6 +252,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; + DROP TABLE IF EXISTS `entrylist_view`; /*!50001 DROP VIEW IF EXISTS `entrylist_view`*/; SET @saved_cs_client = @@character_set_client; @@ -345,7 +354,7 @@ CREATE TABLE `images` ( `mime` varchar(16) DEFAULT NULL, `thumb` longblob, PRIMARY KEY (`image_id`) -) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `issue_history`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -442,7 +451,7 @@ CREATE TABLE `issue_time` ( `notes` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), KEY `issue_id` (`issue_id`) -) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `issue_time_view`; /*!50001 DROP VIEW IF EXISTS `issue_time_view`*/; @@ -467,8 +476,9 @@ CREATE TABLE `item_cat` ( `cat_id` int(11) NOT NULL AUTO_INCREMENT, `cat_name` varchar(255) NOT NULL, `detail` longtext, + `parent_id` int(11) DEFAULT '0', PRIMARY KEY (`cat_id`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=9 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 */; @@ -479,7 +489,7 @@ CREATE TABLE `item_set` ( `pitem_id` int(11) DEFAULT '0', `qty` decimal(11,3) DEFAULT '0.000', PRIMARY KEY (`set_id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=8 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`*/; @@ -513,7 +523,7 @@ CREATE TABLE `items` ( KEY `item_code` (`item_code`), KEY `itemname` (`itemname`), KEY `cat_id` (`cat_id`) -) ENGINE=InnoDB AUTO_INCREMENT=589 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=593 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `items_view`; /*!50001 DROP VIEW IF EXISTS `items_view`*/; @@ -693,7 +703,7 @@ CREATE TABLE `notifies` ( `sender_name` varchar(255) DEFAULT NULL, PRIMARY KEY (`notify_id`), KEY `user_id` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=134 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=139 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `options`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -729,7 +739,7 @@ CREATE TABLE `paylist` ( PRIMARY KEY (`pl_id`), KEY `document_id` (`document_id`), CONSTRAINT `paylist_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`document_id`) -) ENGINE=InnoDB AUTO_INCREMENT=381 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=419 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `paylist_view`; /*!50001 DROP VIEW IF EXISTS `paylist_view`*/; @@ -815,12 +825,11 @@ DROP TABLE IF EXISTS `shop_attributes`; CREATE TABLE `shop_attributes` ( `attribute_id` int(11) NOT NULL AUTO_INCREMENT, `attributename` varchar(64) NOT NULL, - `group_id` int(11) NOT NULL, + `cat_id` int(11) NOT NULL, `attributetype` tinyint(4) NOT NULL, - `valueslist` varchar(255) DEFAULT NULL, - `showinlist` tinyint(1) DEFAULT NULL, + `valueslist` text, PRIMARY KEY (`attribute_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=16 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 */; @@ -831,7 +840,7 @@ CREATE TABLE `shop_attributes_order` ( `pg_id` int(11) NOT NULL, `ordern` int(11) NOT NULL, PRIMARY KEY (`order_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=14 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`*/; @@ -840,10 +849,9 @@ SET character_set_client = utf8; /*!50001 CREATE VIEW `shop_attributes_view` AS SELECT 1 AS `attribute_id`, 1 AS `attributename`, - 1 AS `group_id`, + 1 AS `cat_id`, 1 AS `attributetype`, 1 AS `valueslist`, - 1 AS `showinlist`, 1 AS `ordern`*/; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `shop_attributevalues`; @@ -852,120 +860,48 @@ DROP TABLE IF EXISTS `shop_attributevalues`; CREATE TABLE `shop_attributevalues` ( `attributevalue_id` int(11) NOT NULL AUTO_INCREMENT, `attribute_id` int(11) NOT NULL, - `product_id` int(11) NOT NULL, + `item_id` int(11) NOT NULL, `attributevalue` varchar(255) NOT NULL, PRIMARY KEY (`attributevalue_id`), KEY `attribute_id` (`attribute_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `shop_images`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `shop_images` ( - `image_id` int(11) NOT NULL AUTO_INCREMENT, - `content` longblob NOT NULL, - `mime` varchar(16) DEFAULT NULL, - `thumb` longblob, - PRIMARY KEY (`image_id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 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 */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `shop_manufacturers` ( - `manufacturer_id` int(11) NOT NULL AUTO_INCREMENT, - `manufacturername` varchar(255) NOT NULL, - `url` varchar(255) NOT NULL, - PRIMARY KEY (`manufacturer_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=64 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 */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `shop_prod_comments` ( `comment_id` int(11) NOT NULL AUTO_INCREMENT, - `product_id` int(11) NOT NULL, + `item_id` int(11) NOT NULL, `author` varchar(64) NOT NULL, `comment` text NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `rating` tinyint(4) NOT NULL DEFAULT '0', `moderated` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`comment_id`), - KEY `product_id` (`product_id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 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 */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `shop_productgroups` ( - `group_id` int(11) NOT NULL AUTO_INCREMENT, - `parent_id` int(11) NOT NULL DEFAULT '0', - `groupname` varchar(128) NOT NULL, - `mpath` varchar(1024) DEFAULT NULL, - `image_id` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`group_id`) -) ENGINE=InnoDB AUTO_INCREMENT=10 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`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `shop_productgroups_view` AS SELECT - 1 AS `group_id`, - 1 AS `parent_id`, - 1 AS `groupname`, - 1 AS `mpath`, - 1 AS `image_id`, - 1 AS `gcnt`, - 1 AS `pcnt`*/; -SET character_set_client = @saved_cs_client; -DROP TABLE IF EXISTS `shop_products`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `shop_products` ( - `product_id` int(11) NOT NULL AUTO_INCREMENT, - `group_id` int(11) NOT NULL DEFAULT '0', - `productname` varchar(255) NOT NULL, - `manufacturer_id` int(11) NOT NULL DEFAULT '0', - `price` int(11) NOT NULL DEFAULT '0', - `sold` int(1) NOT NULL DEFAULT '0', - `deleted` tinyint(1) NOT NULL DEFAULT '0', - `sef` varchar(64) DEFAULT NULL, - `item_id` int(11) NOT NULL, - `created` date NOT NULL, - `detail` longtext, - `rating` smallint(6) DEFAULT '0', - `comments` int(11) DEFAULT '0', - PRIMARY KEY (`product_id`), - KEY `group_id` (`group_id`), - KEY `item_id` (`item_id`), - CONSTRAINT `shop_products_fk` FOREIGN KEY (`group_id`) REFERENCES `shop_productgroups` (`group_id`), - CONSTRAINT `shop_products_fk1` FOREIGN KEY (`item_id`) REFERENCES `items` (`item_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + KEY `product_id` (`item_id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 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`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `shop_products_view` AS SELECT - 1 AS `product_id`, - 1 AS `group_id`, - 1 AS `productname`, - 1 AS `manufacturer_id`, - 1 AS `price`, - 1 AS `sold`, - 1 AS `deleted`, - 1 AS `sef`, 1 AS `item_id`, - 1 AS `created`, + 1 AS `itemname`, + 1 AS `description`, 1 AS `detail`, - 1 AS `rating`, 1 AS `item_code`, - 1 AS `novelty`, + 1 AS `bar_code`, + 1 AS `cat_id`, + 1 AS `msr`, + 1 AS `disabled`, + 1 AS `minqty`, + 1 AS `item_type`, + 1 AS `manufacturer`, + 1 AS `cat_name`, + 1 AS `qty`, 1 AS `comments`, - 1 AS `groupname`, - 1 AS `manufacturername`, - 1 AS `qty`*/; + 1 AS `ratings`*/; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `store_stock`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -983,7 +919,7 @@ CREATE TABLE `store_stock` ( KEY `store_id` (`store_id`), CONSTRAINT `store_stock_fk` FOREIGN KEY (`store_id`) REFERENCES `stores` (`store_id`), CONSTRAINT `store_stock_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `items` (`item_id`) -) ENGINE=InnoDB AUTO_INCREMENT=593 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=603 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`*/; @@ -1030,7 +966,7 @@ CREATE TABLE `subscribes` ( `detail` longtext, `disabled` int(1) DEFAULT '0', PRIMARY KEY (`sub_id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `timesheet`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -1045,7 +981,7 @@ CREATE TABLE `timesheet` ( `t_break` smallint(6) DEFAULT '0', PRIMARY KEY (`time_id`), KEY `emp_id` (`emp_id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `timesheet_view`; /*!50001 DROP VIEW IF EXISTS `timesheet_view`*/; @@ -1122,8 +1058,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `contracts_view` AS select `co`.`contract_id` AS `contract_id`,`co`.`customer_id` AS `customer_id`,`co`.`firm_id` AS `firm_id`,`co`.`createdon` AS `createdon`,`co`.`contract_number` AS `contract_number`,`co`.`disabled` AS `disabled`,`co`.`details` AS `details`,`cu`.`customer_name` AS `customer_name`,`f`.`firm_name` AS `firm_name` from ((`contracts` `co` join `customers` `cu` on((`co`.`customer_id` = `cu`.`customer_id`))) left join `firms` `f` on((`co`.`firm_id` = `f`.`firm_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1135,9 +1071,9 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ -/*!50001 VIEW `customers_view` AS select `customers`.`customer_id` AS `customer_id`,`customers`.`customer_name` AS `customer_name`,`customers`.`detail` AS `detail`,`customers`.`email` AS `email`,`customers`.`phone` AS `phone`,`customers`.`status` AS `status`,`customers`.`city` AS `city`,(select count(0) from `messages` `m` where ((`m`.`item_id` = `customers`.`customer_id`) and (`m`.`item_type` = 2))) AS `mcnt`,(select count(0) from `files` `f` where ((`f`.`item_id` = `customers`.`customer_id`) and (`f`.`item_type` = 2))) AS `fcnt`,(select count(0) from `eventlist` `e` where ((`e`.`customer_id` = `customers`.`customer_id`) and (`e`.`eventdate` >= now()))) AS `ecnt` from `customers` */; +/*!50001 CREATE */ +/*!50013 */ +/*!50001 VIEW `customers_view` AS select `customers`.`customer_id` AS `customer_id`,`customers`.`customer_name` AS `customer_name`,`customers`.`detail` AS `detail`,`customers`.`email` AS `email`,`customers`.`phone` AS `phone`,`customers`.`status` AS `status`,`customers`.`city` AS `city`,`customers`.`leadsource` AS `leadsource`,`customers`.`leadstatus` AS `leadstatus`,(select count(0) from `messages` `m` where ((`m`.`item_id` = `customers`.`customer_id`) and (`m`.`item_type` = 2))) AS `mcnt`,(select count(0) from `files` `f` where ((`f`.`item_id` = `customers`.`customer_id`) and (`f`.`item_type` = 2))) AS `fcnt`,(select count(0) from `eventlist` `e` where ((`e`.`customer_id` = `customers`.`customer_id`) and (`e`.`eventdate` >= now()))) AS `ecnt` from `customers` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -1148,8 +1084,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!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 */; @@ -1161,8 +1097,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!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`.`payamount` AS `payamount`,`d`.`payed` AS `payed`,`d`.`parent_id` AS `parent_id`,`d`.`branch_id` AS `branch_id`,`b`.`branch_name` AS `branch_name`,`d`.`firm_id` AS `firm_id`,`f`.`firm_name` AS `firm_name`,`metadata`.`meta_name` AS `meta_name`,`metadata`.`description` AS `meta_desc` from (((((`documents` `d` left 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`))) left join `branches` `b` on((`d`.`branch_id` = `b`.`branch_id`))) left join `firms` `f` on((`d`.`firm_id` = `f`.`firm_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1174,8 +1110,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `entrylist_view` AS select `entrylist`.`entry_id` AS `entry_id`,`entrylist`.`document_id` AS `document_id`,`entrylist`.`amount` AS `amount`,`entrylist`.`quantity` AS `quantity`,`documents`.`customer_id` AS `customer_id`,`entrylist`.`extcode` AS `extcode`,`entrylist`.`stock_id` AS `stock_id`,`entrylist`.`service_id` AS `service_id`,`store_stock`.`item_id` AS `item_id`,`documents`.`document_date` AS `document_date` from ((`entrylist` left join `store_stock` on((`entrylist`.`stock_id` = `store_stock`.`stock_id`))) join `documents` on((`entrylist`.`document_id` = `documents`.`document_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1187,8 +1123,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `eventlist_view` AS select `e`.`user_id` AS `user_id`,`e`.`eventdate` AS `eventdate`,`e`.`title` AS `title`,`e`.`description` AS `description`,`e`.`notify_id` AS `notify_id`,`e`.`event_id` AS `event_id`,`e`.`customer_id` AS `customer_id`,`c`.`customer_name` AS `customer_name` from (`eventlist` `e` left join `customers` `c` on((`e`.`customer_id` = `c`.`customer_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1200,8 +1136,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `issue_issuelist_view` AS select `i`.`issue_id` AS `issue_id`,`i`.`issue_name` AS `issue_name`,`i`.`details` AS `details`,`i`.`status` AS `status`,`i`.`priority` AS `priority`,`i`.`user_id` AS `user_id`,`i`.`lastupdate` AS `lastupdate`,`i`.`project_id` AS `project_id`,`u`.`username` AS `username`,`p`.`project_name` AS `project_name` from ((`issue_issuelist` `i` left join `users_view` `u` on((`i`.`user_id` = `u`.`user_id`))) join `issue_projectlist` `p` on((`i`.`project_id` = `p`.`project_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1213,8 +1149,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `issue_projectlist_view` AS select `p`.`project_id` AS `project_id`,`p`.`project_name` AS `project_name`,`p`.`details` AS `details`,`p`.`customer_id` AS `customer_id`,`p`.`status` AS `status`,`c`.`customer_name` AS `customer_name`,(select coalesce(sum((case when (`i`.`status` = 0) then 1 else 0 end)),0) from `issue_issuelist` `i` where (`i`.`project_id` = `p`.`project_id`)) AS `inew`,(select coalesce(sum((case when (`i`.`status` > 1) then 1 else 0 end)),0) from `issue_issuelist` `i` where (`i`.`project_id` = `p`.`project_id`)) AS `iproc`,(select coalesce(sum((case when (`i`.`status` = 1) then 1 else 0 end)),0) from `issue_issuelist` `i` where (`i`.`project_id` = `p`.`project_id`)) AS `iclose` from (`issue_projectlist` `p` left join `customers` `c` on((`p`.`customer_id` = `c`.`customer_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1226,8 +1162,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `issue_time_view` AS select `t`.`id` AS `id`,`t`.`issue_id` AS `issue_id`,`t`.`createdon` AS `createdon`,`t`.`user_id` AS `user_id`,`t`.`duration` AS `duration`,`t`.`notes` AS `notes`,`u`.`username` AS `username`,`i`.`issue_name` AS `issue_name`,`i`.`project_id` AS `project_id`,`i`.`project_name` AS `project_name` from ((`issue_time` `t` join `users_view` `u` on((`t`.`user_id` = `u`.`user_id`))) join `issue_issuelist_view` `i` on((`t`.`issue_id` = `i`.`issue_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1239,8 +1175,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = utf8mb4 */; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `item_set_view` AS select `item_set`.`set_id` AS `set_id`,`item_set`.`item_id` AS `item_id`,`item_set`.`pitem_id` AS `pitem_id`,`item_set`.`qty` AS `qty`,`items`.`itemname` AS `itemname`,`items`.`item_code` AS `item_code` from (`item_set` join `items` on((`item_set`.`item_id` = `items`.`item_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1252,8 +1188,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = utf8mb4 */; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `items_view` AS select `items`.`item_id` AS `item_id`,`items`.`itemname` AS `itemname`,`items`.`description` AS `description`,`items`.`detail` AS `detail`,`items`.`item_code` AS `item_code`,`items`.`bar_code` AS `bar_code`,`items`.`cat_id` AS `cat_id`,`items`.`msr` AS `msr`,`items`.`disabled` AS `disabled`,`items`.`minqty` AS `minqty`,`items`.`item_type` AS `item_type`,`items`.`manufacturer` AS `manufacturer`,`item_cat`.`cat_name` AS `cat_name` from (`items` left join `item_cat` on((`items`.`cat_id` = `item_cat`.`cat_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1265,8 +1201,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `messages_view` AS select `messages`.`message_id` AS `message_id`,`messages`.`user_id` AS `user_id`,`messages`.`created` AS `created`,`messages`.`message` AS `message`,`messages`.`item_id` AS `item_id`,`messages`.`item_type` AS `item_type`,`users_view`.`username` AS `username` from (`messages` join `users_view` on((`messages`.`user_id` = `users_view`.`user_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1278,8 +1214,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `note_nodesview` AS select `note_nodes`.`node_id` AS `node_id`,`note_nodes`.`pid` AS `pid`,`note_nodes`.`title` AS `title`,`note_nodes`.`mpath` AS `mpath`,`note_nodes`.`user_id` AS `user_id`,`note_nodes`.`ispublic` AS `ispublic`,(select count(`note_topicnode`.`topic_id`) AS `Count(topic_id)` from `note_topicnode` where (`note_topicnode`.`node_id` = `note_nodes`.`node_id`)) AS `tcnt` from `note_nodes` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1291,8 +1227,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `note_topicnodeview` AS select `note_topicnode`.`topic_id` AS `topic_id`,`note_topicnode`.`node_id` AS `node_id`,`note_topicnode`.`tn_id` AS `tn_id`,`note_topics`.`title` AS `title`,`note_nodes`.`user_id` AS `user_id`,`note_topics`.`content` AS `content` from ((`note_topics` join `note_topicnode` on((`note_topics`.`topic_id` = `note_topicnode`.`topic_id`))) join `note_nodes` on((`note_nodes`.`node_id` = `note_topicnode`.`node_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1304,8 +1240,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `note_topicsview` AS select `t`.`topic_id` AS `topic_id`,`t`.`title` AS `title`,`t`.`content` AS `content`,`t`.`acctype` AS `acctype`,`t`.`user_id` AS `user_id` from `note_topics` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1317,8 +1253,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!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`,`pl`.`paytype` AS `paytype`,`pl`.`detail` AS `detail`,`d`.`document_number` AS `document_number`,`u`.`username` AS `username`,`m`.`mf_name` AS `mf_name`,`d`.`customer_id` AS `customer_id`,`d`.`customer_name` AS `customer_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 */; @@ -1330,8 +1266,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = utf8mb4 */; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `roles_view` AS select `roles`.`role_id` AS `role_id`,`roles`.`rolename` AS `rolename`,`roles`.`acl` AS `acl`,(select coalesce(count(0),0) from `users` where (`users`.`role_id` = `roles`.`role_id`)) AS `cnt` from `roles` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1343,22 +1279,9 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ -/*!50001 VIEW `shop_attributes_view` AS select `shop_attributes`.`attribute_id` AS `attribute_id`,`shop_attributes`.`attributename` AS `attributename`,`shop_attributes`.`group_id` AS `group_id`,`shop_attributes`.`attributetype` AS `attributetype`,`shop_attributes`.`valueslist` AS `valueslist`,`shop_attributes`.`showinlist` AS `showinlist`,`shop_attributes_order`.`ordern` AS `ordern` from (`shop_attributes` join `shop_attributes_order` on(((`shop_attributes`.`attribute_id` = `shop_attributes_order`.`attr_id`) and (`shop_attributes`.`group_id` = `shop_attributes_order`.`pg_id`)))) order by `shop_attributes_order`.`ordern` */; -/*!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_productgroups_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 `shop_productgroups_view` AS select `g`.`group_id` AS `group_id`,`g`.`parent_id` AS `parent_id`,`g`.`groupname` AS `groupname`,`g`.`mpath` AS `mpath`,`g`.`image_id` AS `image_id`,(select count(`sg`.`group_id`) AS `cnt` from `shop_productgroups` `sg` where (`g`.`group_id` = `sg`.`parent_id`)) AS `gcnt`,(select count(`p`.`product_id`) AS `cnt` from `shop_products` `p` where (`g`.`group_id` = `p`.`group_id`)) AS `pcnt` from `shop_productgroups` `g` */; +/*!50001 CREATE */ +/*!50013 */ +/*!50001 VIEW `shop_attributes_view` AS select `shop_attributes`.`attribute_id` AS `attribute_id`,`shop_attributes`.`attributename` AS `attributename`,`shop_attributes`.`cat_id` AS `cat_id`,`shop_attributes`.`attributetype` AS `attributetype`,`shop_attributes`.`valueslist` AS `valueslist`,`shop_attributes_order`.`ordern` AS `ordern` from (`shop_attributes` join `shop_attributes_order` on(((`shop_attributes`.`attribute_id` = `shop_attributes_order`.`attr_id`) and (`shop_attributes`.`cat_id` = `shop_attributes_order`.`pg_id`)))) order by `shop_attributes_order`.`ordern` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -1369,9 +1292,9 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ -/*!50001 VIEW `shop_products_view` AS select `p`.`product_id` AS `product_id`,`p`.`group_id` AS `group_id`,`p`.`productname` AS `productname`,`p`.`manufacturer_id` AS `manufacturer_id`,`p`.`price` AS `price`,`p`.`sold` AS `sold`,`p`.`deleted` AS `deleted`,`p`.`sef` AS `sef`,`p`.`item_id` AS `item_id`,`p`.`created` AS `created`,`p`.`detail` AS `detail`,`p`.`rating` AS `rating`,`i`.`item_code` AS `item_code`,(case when (`p`.`created` > (now() - interval 1 month)) then 1 else 0 end) AS `novelty`,`p`.`comments` AS `comments`,`g`.`groupname` AS `groupname`,`m`.`manufacturername` AS `manufacturername`,0 AS `qty` from (((`shop_products` `p` join `shop_productgroups` `g` on((`p`.`group_id` = `g`.`group_id`))) left join `shop_manufacturers` `m` on((`p`.`manufacturer_id` = `m`.`manufacturer_id`))) join `items` `i` on((`p`.`item_id` = `i`.`item_id`))) */; +/*!50001 CREATE */ +/*!50013 */ +/*!50001 VIEW `shop_products_view` AS select `i`.`item_id` AS `item_id`,`i`.`itemname` AS `itemname`,`i`.`description` AS `description`,`i`.`detail` AS `detail`,`i`.`item_code` AS `item_code`,`i`.`bar_code` AS `bar_code`,`i`.`cat_id` AS `cat_id`,`i`.`msr` AS `msr`,`i`.`disabled` AS `disabled`,`i`.`minqty` AS `minqty`,`i`.`item_type` AS `item_type`,`i`.`manufacturer` AS `manufacturer`,`i`.`cat_name` AS `cat_name`,coalesce((select sum(`store_stock`.`qty`) from `store_stock` where (`store_stock`.`item_id` = `i`.`item_id`)),0) AS `qty`,coalesce((select count(0) from `shop_prod_comments` `c` where (`c`.`item_id` = `i`.`item_id`)),0) AS `comments`,coalesce((select sum(`c`.`rating`) from `shop_prod_comments` `c` where (`c`.`item_id` = `i`.`item_id`)),0) AS `ratings` from `items_view` `i` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -1382,8 +1305,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = utf8mb4 */; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!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`.`item_type` AS `item_type`,`i`.`bar_code` AS `bar_code`,`i`.`cat_name` AS `cat_name`,`i`.`disabled` AS `itemdisabled`,`stores`.`storename` AS `storename`,`st`.`qty` AS `qty`,`st`.`snumber` AS `snumber`,`st`.`sdate` AS `sdate` 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 */; @@ -1395,8 +1318,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `timesheet_view` AS select `t`.`time_id` AS `time_id`,`t`.`emp_id` AS `emp_id`,`t`.`description` AS `description`,`t`.`t_start` AS `t_start`,`t`.`t_end` AS `t_end`,`t`.`t_type` AS `t_type`,`t`.`t_break` AS `t_break`,`e`.`emp_name` AS `emp_name`,`e`.`disabled` AS `disabled`,`e`.`branch_id` AS `branch_id` from (`timesheet` `t` join `employees` `e` on((`t`.`emp_id` = `e`.`employee_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -1408,8 +1331,8 @@ CREATE TABLE `zformstat` ( /*!50001 SET character_set_client = utf8mb4 */; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE */ -/*!50013 */ +/*!50001 CREATE */ +/*!50013 */ /*!50001 VIEW `users_view` AS select `users`.`user_id` AS `user_id`,`users`.`userlogin` AS `userlogin`,`users`.`userpass` AS `userpass`,`users`.`createdon` AS `createdon`,`users`.`email` AS `email`,`users`.`acl` AS `acl`,`users`.`options` AS `options`,`users`.`disabled` AS `disabled`,`roles`.`rolename` AS `rolename`,`users`.`role_id` AS `role_id`,`roles`.`acl` AS `roleacl`,coalesce(`employees`.`employee_id`,0) AS `employee_id`,(case when isnull(`employees`.`emp_name`) then `users`.`userlogin` else `employees`.`emp_name` end) AS `username` from ((`users` left join `employees` on(((`users`.`userlogin` = `employees`.`login`) and (`employees`.`disabled` <> 1)))) left join `roles` on((`users`.`role_id` = `roles`.`role_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; diff --git a/db/temp.sql b/db/temp.sql index 6b889ad7d..3d6c13dc9 100644 --- a/db/temp.sql +++ b/db/temp.sql @@ -1,6 +1,8 @@ - /* - +/* +INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 5, '��� ������� (�������)', 'ARMFood', '', 0); + + CREATE TABLE `empacc` ( `ea_id` int(11) NOT NULL AUTO_INCREMENT, `emp_id` int(11) NOT NULL, @@ -27,5 +29,5 @@ CREATE TABLE `prodproc` ( - */ - \ No newline at end of file + + */ \ No newline at end of file diff --git a/db/update485to490.sql b/db/update485to490.sql new file mode 100644 index 000000000..5ef259504 --- /dev/null +++ b/db/update485to490.sql @@ -0,0 +1,47 @@ +ALTER TABLE `entrylist` CHANGE `extcode` `extcode` DECIMAL(11,2) NULL DEFAULT 0; + + +ALTER VIEW entrylist_view AS + select + entrylist.entry_id AS entry_id, + entrylist.document_id AS document_id, + entrylist.amount AS amount, + entrylist.quantity AS quantity, + documents.customer_id AS customer_id, + entrylist.extcode AS extcode, + entrylist.stock_id AS stock_id, + entrylist.service_id AS service_id, + store_stock.item_id AS item_id, + store_stock.partion AS partion, + documents.document_date AS document_date + from + ((entrylist left join store_stock on((entrylist.stock_id = store_stock.stock_id))) join documents on((entrylist.document_id = documents.document_id))); + +ALTER TABLE `item_cat` ADD `parent_id` INT NULL DEFAULT '0' ; + + + +ALTER TABLE `shop_attributes` CHANGE `group_id` `cat_id` INT(11) NOT NULL; +ALTER TABLE `shop_attributevalues` CHANGE `product_id` `item_id` INT(11) NOT NULL; +ALTER TABLE `shop_prod_comments` CHANGE `product_id` `item_id` INT(11) NOT NULL; + + +ALTER TABLE `shop_attributes` CHANGE `valueslist` `valueslist` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; +ALTER TABLE `shop_attributes` ADD `showincompare` TINYINT(1) NOT NULL DEFAULT '0' ; + +ALTER VIEW shop_attributes_view AS + select + shop_attributes.attribute_id AS attribute_id, + shop_attributes.attributename AS attributename, + shop_attributes.cat_id AS cat_id, + shop_attributes.attributetype AS attributetype, + shop_attributes.valueslist AS valueslist, + shop_attributes.showinlist AS showinlist, + shop_attributes.showincompare AS showincompare, + shop_attributes_order.ordern AS ordern + from + (shop_attributes join shop_attributes_order on(((shop_attributes.attribute_id = shop_attributes_order.attr_id) and (shop_attributes.cat_id = shop_attributes_order.pg_id)))) + order by + shop_attributes_order.ordern; + + diff --git a/www/app/api/docs.php b/www/app/api/docs.php index 1d427c0ed..73317fe1d 100644 --- a/www/app/api/docs.php +++ b/www/app/api/docs.php @@ -23,6 +23,13 @@ public function branchlist() { return $list; } + //список производственных участвков + public function parealist() { + $list = \App\Entity\ProdArea::findArray('pa_name', '', 'pa_name'); + + return $list; + } + //записать ордер public function createorder($args) { @@ -228,4 +235,64 @@ public function cancel($args) { } + + + // /api/docs + // {"jsonrpc": "2.0", "method": "createprodissue", "params": { "store_id":"1","parea":"1","items":[{"item_code":"cbs500-1","quantity":2.1},{"item_code":"ID0018","quantity":2}] }, "id": 1} + + //Списание ТМЦ в производсво + public function createprodissue($args) { + + + if ($args['store_id'] > 0) { + $store = \App\Entity\Store::load($args['store_id']); + if ($store == null) { + throw new \Exception('Не указан склад'); + } + } + $doc = Document::create('ProdIssue'); + $doc->document_number = $doc->nextNumber(); + $doc->document_date = time(); + $doc->headerdata['store'] = $args['store_id']; + $doc->headerdata['parea'] = $args['parea']; + $doc->state = Document::STATE_NEW; + + $doc->notes = @base64_decode($args['description']); + $details = array(); + $total = 0; + if (is_array($args['items']) && count($args['items']) > 0) { + foreach ($args['items'] as $it) { + if (strlen($it['item_code']) == 0) { + throw new \Exception(H::l("apientercode")); + } + $item = Item::getFirst("disabled<> 1 and item_code=" . Item::qstr($it['item_code'])); + + if ($item instanceof Item) { + + $item->quantity = $it['quantity']; + + $details[$item->item_id] = $item; + } else { + throw new \Exception(H::l("apiitemnotfound", $it['code'])); + } + } + } else { + throw new \Exception(H::l("apinoitems")); + } + if (count($details) == 0) { + throw new \Exception(H::l("apinoitems")); + } + $doc->packDetails('detaildata', $details); + + $doc->amount = 0; + + + $doc->save(); + + $doc->updateStatus(Document::STATE_EXECUTED); + + + return $doc->document_number; + } + } diff --git a/www/app/application.php b/www/app/application.php index 74b63310c..c0cb15bdd 100644 --- a/www/app/application.php +++ b/www/app/application.php @@ -115,6 +115,7 @@ public function Route($uri) { "aboutus" => "\\App\\Modules\\Shop\\Pages\\AboutUs", "delivery" => "\\App\\Modules\\Shop\\Pages\\Delivery", "contact" => "\\App\\Modules\\Shop\\Pages\\Contact", + "news" => "\\App\\Modules\\Shop\\Pages\\News", "scat" => "\\App\\Modules\\Shop\\Pages\\Main", "pcat" => "\\App\\Modules\\Shop\\Pages\\Catalog", "project" => "\\App\\Modules\\Issue\\Pages\\ProjectList", @@ -134,9 +135,18 @@ public function Route($uri) { } } } + return; } if (strlen($pages[$uri]) > 0) { self::$app->LoadPage($pages[$uri]); + return; + } + + + $prod = \App\Modules\Shop\Entity\Product::loadSEF($uri); + if ($prod instanceof \App\Entity\Item) { + self::$app->LoadPage($pages['sp'], $prod->item_id); + return; } } diff --git a/www/app/calendar.php b/www/app/calendar.php index 6a1935f75..f8a2abb5d 100644 --- a/www/app/calendar.php +++ b/www/app/calendar.php @@ -2,21 +2,21 @@ namespace App; -class Calendar extends \Zippy\Html\HtmlComponent implements \Zippy\Interfaces\Requestable,\Zippy\Interfaces\AjaxRender +class Calendar extends \Zippy\Html\HtmlComponent implements \Zippy\Interfaces\Requestable, \Zippy\Interfaces\AjaxRender { private $event = null; private $data = array(); private $view = 'dayGridMonth'; - - public function __construct($id ) { + + public function __construct($id) { parent::__construct($id); - $this->view = 'dayGridMonth' ; - - } - - + $this->view = 'dayGridMonth'; + + } + + public final function RenderImpl() { global $_config; $id = $this->getAttribute('id'); @@ -25,11 +25,11 @@ public final function RenderImpl() { if ($_config['common']['lang'] == 'ua') { $lang = 'ua'; } - + if (count($this->data) > 0) { $ev = ",events: ["; foreach ($this->data as $dt) { - + $ev .= " { id : '{$dt->id}', title : '{$dt->title}', start : {$dt->start} , @@ -132,10 +132,10 @@ public final function RequestHandle() { $action['enddelta'] = $action['enddelta'] / 1000; } if ($action['action'] == 'move') { - $action['years'] = $action['years'] ; - $action['month'] = $action['month'] ; - $action['days'] = $action['days'] ; - $action['ms'] = $action['ms']/1000 ; + $action['years'] = $action['years']; + $action['month'] = $action['month']; + $action['days'] = $action['days']; + $action['ms'] = $action['ms'] / 1000; } if ($this->event != null) { @@ -151,7 +151,8 @@ public function setEvent(\Zippy\Interfaces\EventReceiver $receiver, $handler) { public function setData($data) { $this->data = $data; } - public function AjaxAnswer() { + + public function AjaxAnswer() { return ''; } @@ -165,9 +166,9 @@ class CEvent public function __construct($id, $title, $start, $end, $color) { $this->id = $id; $this->title = $title; - $this->start = "new Date(".date("Y", $start).", ".( date("m", $start) -1).", ".date("d", $start).",".date("H", $start).",".date("i", $start).")" ; - $this->end = "new Date(".date("Y", $end).", ".( date("m", $end) -1).", ".date("d", $end).",".date("H", $end).",".date("i", $end).")" ; - // $this->end = date("Y-m-dTH:i", $end); + $this->start = "new Date(" . date("Y", $start) . ", " . (date("m", $start) - 1) . ", " . date("d", $start) . "," . date("H", $start) . "," . date("i", $start) . ")"; + $this->end = "new Date(" . date("Y", $end) . ", " . (date("m", $end) - 1) . ", " . date("d", $end) . "," . date("H", $end) . "," . date("i", $end) . ")"; + // $this->end = date("Y-m-dTH:i", $end); $this->color = $color; } diff --git a/www/app/entity/category.php b/www/app/entity/category.php index 80cd71807..08fc6c945 100644 --- a/www/app/entity/category.php +++ b/www/app/entity/category.php @@ -11,17 +11,15 @@ class Category extends \ZCL\DB\Entity { + public $parents = array(); + protected function init() { $this->cat_id = 0; + $this->parent_id = 0; + $this->image_id = 0; + $this->parents = array(); } - 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) ? "Категория используется в товарах" : ""; - } protected function afterLoad() { @@ -33,6 +31,8 @@ protected function afterLoad() { $this->price3 = (string)($xml->price3[0]); $this->price4 = (string)($xml->price4[0]); $this->price5 = (string)($xml->price5[0]); + $this->image_id = (int)$xml->image_id[0]; + $this->noshop = (int)$xml->noshop[0]; parent::afterLoad(); @@ -48,6 +48,8 @@ protected function beforeSave() { $this->detail .= "{$this->price3}"; $this->detail .= "{$this->price4}"; $this->detail .= "{$this->price5}"; + $this->detail .= "{$this->image_id}"; + $this->detail .= "{$this->noshop}"; $this->detail .= ""; @@ -55,4 +57,97 @@ protected function beforeSave() { return true; } + + public function hasChild() { + $conn = \ZDB\DB::getConnect(); + + $sql = " select count(*) from item_cat where parent_id = {$this->cat_id} "; + $cnt = $conn->GetOne($sql); + return $cnt > 0; + + } + + public static function findFullData($clist = null) { + if ($clist == null) { + $clist = Category::find('', 'cat_name'); + } + $plist = Category::find('', 'cat_name'); + + foreach ($clist as $c) { + + $c->parents = $c->getParents($plist); + + $names = array(); + foreach ($c->parents as $p) { + $names[] = $plist[$p]->cat_name; + } + $names = array_reverse($names); + $names[] = $c->cat_name; + $c->full_name = implode(' / ', $names); + } + + return $clist; + + } + + public function getParents(&$clist = null) { + if ($clist == null) { + $clist = Category::find('', 'cat_name'); + } + + + $p = array(); + + if ($clist[$this->parent_id] instanceof Category) { + $p[] = $this->parent_id; + $pp = $clist[$this->parent_id]->getParents($clist); + if (count($pp) > 0) { + $p = array_merge($p, $pp); + } + } + return $p; + } + + public function getChildren(&$clist = null) { + if ($clist == null) { + $clist = Category::find('', 'cat_name'); + } + + $p = array(); + + + foreach ($clist as $ch) { + if ($ch->parent_id == $this->cat_id) { + $p[] = $ch->cat_id; + $pp = $clist[$ch->cat_id]->getChildren($clist); + foreach ($pp as $_p) { + $p[] = $_p; + } + + } + + } + + + return $p; + + } + + //список с тмц + public static function getList($fullname = false) { + if ($fullname == false) { + return Category::findArray("cat_name", "cat_id in (select cat_id from items where disabled <>1 )", "cat_name"); + } + + $list = Category::find("cat_id in (select cat_id from items where disabled <>1 )", "cat_name"); + $list = self::findFullData($list); + + $ret = array(); + foreach ($list as $c) { + $ret[$c->cat_id] = $c->full_name; + } + return $ret; + } + + } diff --git a/www/app/entity/contract.php b/www/app/entity/contract.php index 476beee8a..5005bb2ec 100644 --- a/www/app/entity/contract.php +++ b/www/app/entity/contract.php @@ -112,37 +112,37 @@ public function getDocs() { public function getDolg() { $amount = 0; - + $where = " customer_id={$this->customer_id} and content like '%{$this->contract_id}%' "; - - if($this->ctype==1){ - $_docs = " and ( meta_name in('GoodsIssue','Invoice','RetCustIssue','PosCheck','ServiceAct','Order') or (meta_name='IncomeMoney' and content like '%1%' ) or (meta_name='OutcomeMoney' and content like '%2%' )) "; - - $sql .= " + + if ($this->ctype == 1) { + $_docs = " and ( meta_name in('GoodsIssue','Invoice','RetCustIssue','PosCheck','ServiceAct','Order') or (meta_name='IncomeMoney' and content like '%1%' ) or (meta_name='OutcomeMoney' and content like '%2%' )) "; + + $sql .= " select sum((case when meta_name='OutcomeMoney' then (payed - payamount ) else (payamount - payed) end) ) as sam from `documents_view` where {$where} and (payamount >0 or payed >0) {$_docs} and state not in (1,2,3,17,8) and ( (meta_name <>'POSCheck' and payamount <> payed) or(meta_name = 'POSCheck' and payamount > payed )) - "; - } else - if($this->ctype==2) { - $_docs = " and ( meta_name in('GoodsReceipt','InvoiceCust','ReturnIssue') or (meta_name='OutcomeMoney' and content like '%1%' ) or (meta_name='IncomeMoney' and content like '%2%' )) "; - - $sql .= " + "; + } else { + if ($this->ctype == 2) { + $_docs = " and ( meta_name in('GoodsReceipt','InvoiceCust','ReturnIssue') or (meta_name='OutcomeMoney' and content like '%1%' ) or (meta_name='IncomeMoney' and content like '%2%' )) "; + + $sql .= " select sum((case when meta_name='IncomeMoney' then (payed - payamount ) else (payamount - payed) end) ) as sam from `documents_view` where {$where} and (payamount >0 or payed >0) {$_docs} and state not in (1,2,3,17,8) and payamount <> payed - "; - - } - else { - return 0; + "; + + } else { + return 0; + } } - $conn = \ZDB\DB::getConnect() ; + $conn = \ZDB\DB::getConnect(); $amount = $conn->GetOne($sql); - + return $amount; } diff --git a/www/app/entity/customer.php b/www/app/entity/customer.php index 54425a686..c2792243a 100644 --- a/www/app/entity/customer.php +++ b/www/app/entity/customer.php @@ -19,9 +19,8 @@ class Customer extends \ZCL\DB\Entity const TYPE_BAYER = 1; //покупатель const TYPE_SELLER = 2; //поставщик - - - + + protected function init() { $this->customer_id = 0; $this->customer_name = ''; @@ -43,9 +42,9 @@ protected function beforeSave() { $this->detail .= "{$this->isholding}"; $this->detail .= "{$this->holding}"; $this->detail .= "{$this->viber}"; - + $this->detail .= "{$this->user_id}"; - + $this->detail .= "holding_name}]]>"; $this->detail .= "
address}]]>
"; $this->detail .= "comment}]]>"; @@ -66,15 +65,15 @@ protected function afterLoad() { $this->isholding = (int)($xml->isholding[0]); $this->user_id = (int)($xml->user_id[0]); $this->fromlead = (int)($xml->fromlead[0]); - + $this->holding = (int)($xml->holding[0]); $this->holding_name = (string)($xml->holding_name[0]); $this->address = (string)($xml->address[0]); $this->comment = (string)($xml->comment[0]); $this->viber = (string)($xml->viber[0]); - - $this->createdon = strtotime($this->createdon); - + + $this->createdon = strtotime($this->createdon); + parent::afterLoad(); } @@ -150,36 +149,44 @@ public static function getHoldList($type = 0) { return Customer::findArray("customer_name", $where, "customer_name"); } - public static function getLeadSources(){ - $options = \App\System::getOptions('common' ) ; - - if(is_array($options['leadsources'])==false)$options['leadsources'] = array(); + public static function getLeadSources() { + $options = \App\System::getOptions('common'); + + if (is_array($options['leadsources']) == false) { + $options['leadsources'] = array(); + } $list = array(); - foreach($options['leadsources'] as $item){ - if(strlen($item->name)==0) continue; - $list[$item->name] = $item->name; + foreach ($options['leadsources'] as $item) { + if (strlen($item->name) == 0) { + continue; + } + $list[$item->name] = $item->name; } - - - return $list; + + + return $list; } - - public static function getLeadStatuses(){ - $options = \App\System::getOptions('common' ) ; - - if(is_array($options['leadstatuses'])==false)$options['leadstatuses'] = array(); + + public static function getLeadStatuses() { + $options = \App\System::getOptions('common'); + + if (is_array($options['leadstatuses']) == false) { + $options['leadstatuses'] = array(); + } $list = array(); - foreach($options['leadstatuses'] as $item){ - if(strlen($item->name)==0) continue; - $list[$item->name] = $item->name; + foreach ($options['leadstatuses'] as $item) { + if (strlen($item->name) == 0) { + continue; + } + $list[$item->name] = $item->name; } - - - return $list; - + + + return $list; + } - - + + } diff --git a/www/app/entity/doc/document.php b/www/app/entity/doc/document.php index 551465b25..5f2ac1cc7 100644 --- a/www/app/entity/doc/document.php +++ b/www/app/entity/doc/document.php @@ -361,23 +361,23 @@ public function updateStatus($state) { if ($oldstate != $state) { $doc = $this->cast(); - $doc->onState( $state); - \App\Entity\Subscribe::onDocumentState($doc->document_id,$state) ; + $doc->onState($state); + \App\Entity\Subscribe::onDocumentState($doc->document_id, $state); } return true; } - + /** - * обработчик изменения статусов - * переопределяется в дочерних документах - * - * @param mixed $state новый статус - */ - protected function onState( $state) { + * обработчик изменения статусов + * переопределяется в дочерних документах + * + * @param mixed $state новый статус + */ + protected function onState($state) { + - } /** diff --git a/www/app/entity/doc/goodsissue.php b/www/app/entity/doc/goodsissue.php index fe0d57010..b758fa404 100644 --- a/www/app/entity/doc/goodsissue.php +++ b/www/app/entity/doc/goodsissue.php @@ -86,34 +86,56 @@ public function generateReport() { } public function Execute() { - + $parts = array(); $k = 1; //учитываем скидку if ($this->headerdata["paydisc"] > 0 && $this->amount > 0) { $k = ($this->amount - $this->headerdata["paydisc"]) / $this->amount; } $amount = 0; foreach ($this->unpackDetails('detaildata') as $item) { - - - //оприходуем с производства - if( $this->headerdata['fromprod'] ==1 && $item->item_type==Item::TYPE_PROD) { - $price = $item->getProdprice() ; - - if($price ==0){ - throw new \Exception(H::l('noselfprice',$item->itemname)) ; - + + + //оприходуем с производства + if ($item->autoincome == 1 && $item->item_type == Item::TYPE_PROD) { + + if ($item->autooutcome == 1) { //комплекты + $set = \App\Entity\ItemSet::find("pitem_id=" . $item->item_id); + foreach ($set as $part) { + + $itemp = \App\Entity\Item::load($part->item_id); + $itemp->quantity = $item->quantity * $part->qty; + $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $itemp); + + foreach ($listst as $st) { + $sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity); + $sc->setStock($st->stock_id); + + $sc->save(); + } + + + } + } + + + $price = $item->getProdprice(); + + if ($price == 0) { + throw new \Exception(H::l('noselfprice', $item->itemname)); + } $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $item->item_id, $price, $item->snumber, $item->sdate, true); $sc = new Entry($this->document_id, $item->quantity * $price, $item->quantity); $sc->setStock($stock->stock_id); - + $sc->save(); - - } - - + + + } + + //продажа $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $item); @@ -124,18 +146,11 @@ public function Execute() { $sc->save(); $amount += $item->price * $k * $st->quantity; } - - - + } - - - - - - + //списываем бонусы if ($this->headerdata['paydisc'] > 0 && $this->customer_id > 0) { $customer = \App\Entity\Customer::load($this->customer_id); diff --git a/www/app/entity/doc/goodsreceipt.php b/www/app/entity/doc/goodsreceipt.php index 63a091dc0..0ff46a290 100644 --- a/www/app/entity/doc/goodsreceipt.php +++ b/www/app/entity/doc/goodsreceipt.php @@ -105,7 +105,7 @@ public function Execute() { $item->amount = $item->price * $item->quantity; $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $item->item_id, $item->price, $item->snumber, $item->sdate, true); - $sc = new Entry($this->document_id, $item->amount, $item->quantity); + $sc = new Entry($this->document_id, $item->price * $item->quantity, $item->quantity); $sc->setStock($stock->stock_id); $sc->setExtCode($item->price); //Для АВС // $sc->setCustomer($this->customer_id); diff --git a/www/app/entity/doc/invoice.php b/www/app/entity/doc/invoice.php index c2a9a47d0..6d752c513 100644 --- a/www/app/entity/doc/invoice.php +++ b/www/app/entity/doc/invoice.php @@ -42,7 +42,7 @@ public function generateReport() { "_detail" => $detail, "customer_name" => $this->customer_name, "firm_name" => $firm['firm_name'], - "firm_address" => $firm['address'], + "firm_address" => $firm['address'], "logo" => _BASEURL . $firm['logo'], "islogo" => strlen($firm['logo']) > 0, "stamp" => _BASEURL . $firm['stamp'], diff --git a/www/app/entity/doc/movemoney.php b/www/app/entity/doc/movemoney.php index f3274240c..dce7b4652 100644 --- a/www/app/entity/doc/movemoney.php +++ b/www/app/entity/doc/movemoney.php @@ -15,21 +15,21 @@ class MoveMoney extends Document public function Execute() { Pay::addPayment($this->document_id, $this->document_date, 0 - $this->amount, $this->headerdata['paymentfrom'], 0, $this->notes); - Pay::addPayment($this->document_id, $this->document_date, $this->amount, $this->headerdata['paymentto'], 0, $this->notes); - + Pay::addPayment($this->document_id, $this->document_date, $this->amount, $this->headerdata['paymentto'], 0, $this->notes); + return true; } public function generateReport() { - + $header = array( 'amount' => H::fa($this->amount), 'date' => H::fd($this->document_date), "notes" => $this->notes, "from" => $this->headerdata["paymentfromname"], - "to" => $this->headerdata["paymenttoname"], + "to" => $this->headerdata["paymenttoname"], "document_number" => $this->document_number ); $report = new \App\Report('doc/movemoney.tpl'); diff --git a/www/app/entity/doc/order.php b/www/app/entity/doc/order.php index 2a1653203..255304d05 100644 --- a/www/app/entity/doc/order.php +++ b/www/app/entity/doc/order.php @@ -22,7 +22,7 @@ public function generateReport() { if (isset($detail[$item->item_id])) { $detail[$item->item_id]['quantity'] += $item->quantity; } else { - + /* $ocstoreopt = @unserialize($item->octoreoptions); //опции с опенкарта if (is_array($ocstoreopt)) { @@ -39,7 +39,7 @@ public function generateReport() { "quantity" => H::fqty($item->quantity), "price" => H::fa($item->price), "msr" => $item->msr, - "desc" => $item->desc, + "desc" => $item->desc, "amount" => H::fa($item->quantity * $item->price) ); } @@ -53,7 +53,7 @@ public function generateReport() { "email" => $this->headerdata["email"], "delivery" => $this->headerdata["delivery_name"], "ship_address" => strlen($this->headerdata["ship_address"]) > 0 ? $this->headerdata["ship_address"] : false, - "notes" => $this->notes, + "notes" => nl2br($this->notes), "document_number" => $this->document_number, "total" => H::fa($this->amount), "payed" => H::fa($this->payed), @@ -91,7 +91,7 @@ public function getRelationBased() { } public function supportedExport() { - return array(self::EX_EXCEL, self::EX_POS); + return array(self::EX_EXCEL, self::EX_PDF, self::EX_POS); } @@ -131,8 +131,8 @@ public function generatePosReport() { } - protected function onState( $state) { - + protected function onState($state) { + if ($state == self::STATE_INPROCESS) { //списываем бонусы if ($this->headerdata['paydisc'] > 0 && $this->customer_id > 0) { diff --git a/www/app/entity/doc/ordercust.php b/www/app/entity/doc/ordercust.php index 8e6480868..887a030a7 100644 --- a/www/app/entity/doc/ordercust.php +++ b/www/app/entity/doc/ordercust.php @@ -5,7 +5,7 @@ use App\Helper as H; /** - * Класс-сущность документ приходная накладая + * Класс-сущность документ заявка поставщику * */ class OrderCust extends Document @@ -25,8 +25,8 @@ public function generateReport() { "quantity" => H::fqty($item->quantity), "price" => H::fa($item->price), "msr" => $item->msr, - "desc" => $item->desc, - "amount" => H::fa($item->quantity * $item->price) + "desc" => $item->desc, + "amount" => H::fa($item->quantity * $item->price) ); } diff --git a/www/app/entity/doc/poscheck.php b/www/app/entity/doc/poscheck.php index 846f44148..6b557a718 100644 --- a/www/app/entity/doc/poscheck.php +++ b/www/app/entity/doc/poscheck.php @@ -141,6 +141,48 @@ public function Execute() { foreach ($this->unpackDetails('detaildata') as $item) { + + //оприходуем с производства + if ($item->autoincome == 1 && $item->item_type == Item::TYPE_PROD) { + + if ($item->autooutcome == 1) { //комплекты + $set = \App\Entity\ItemSet::find("pitem_id=" . $item->item_id); + foreach ($set as $part) { + + $itemp = \App\Entity\Item::load($part->item_id); + $itemp->quantity = $item->quantity * $part->qty; + $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $itemp); + + foreach ($listst as $st) { + $sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity); + $sc->setStock($st->stock_id); + + $sc->save(); + } + + + } + } + + + $price = $item->getProdprice(); + + if ($price == 0) { + throw new \Exception(H::l('noselfprice', $item->itemname)); + + } + $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $item->item_id, $price, $item->snumber, $item->sdate, true); + + $sc = new Entry($this->document_id, $item->quantity * $price, $item->quantity); + $sc->setStock($stock->stock_id); + + + $sc->save(); + + + } + + $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $item); foreach ($listst as $st) { diff --git a/www/app/entity/doc/prodreceipt.php b/www/app/entity/doc/prodreceipt.php index 4b9bb1e6e..118b158dc 100644 --- a/www/app/entity/doc/prodreceipt.php +++ b/www/app/entity/doc/prodreceipt.php @@ -55,45 +55,42 @@ public function generateReport() { public function Execute() { $types = array(); $common = \App\System::getOptions("common"); - $parts = array(); - - + + foreach ($this->unpackDetails('detaildata') as $item) { - + + if ($item->autooutcome == 1) { //списание комплектующих + $set = \App\Entity\ItemSet::find("pitem_id=" . $item->item_id); + foreach ($set as $part) { + + $itemp = \App\Entity\Item::load($part->item_id); + $itemp->quantity = $item->quantity * $part->qty; + $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $itemp); + + foreach ($listst as $st) { + $sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity); + $sc->setStock($st->stock_id); + + $sc->save(); + } + + + } + } + + $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $item->item_id, $item->price, $item->snumber, $item->sdate, true); $sc = new Entry($this->document_id, $item->quantity * $item->price, $item->quantity); $sc->setStock($stock->stock_id); - // $sc->setExtCode($item->price); //Для АВС - + $sc->save(); - - $set = \App\Entity\ItemSet::find("pitem_id=" . $item->item_id); - foreach($set as $part) { - if( isset($parts[$part->item_id])==false) $parts[$part->item_id] =0; - $parts[$part->item_id] += $part->qty; - } - - - } - // списываем в производство - if($this->headerdata['storefrom'] >0) { - foreach($parts as $id=>$qty) { - $item = \App\Entity\Item::load($id); - $item->quantity = $qty; - $listst = \App\Entity\Stock::pickup($this->headerdata['storefrom'], $item); - - foreach ($listst as $st) { - $sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity); - $sc->setStock($st->stock_id); - - $sc->save(); - } - - } + } + + return true; } diff --git a/www/app/entity/doc/returnissue.php b/www/app/entity/doc/returnissue.php index cb359c06a..1e180c034 100644 --- a/www/app/entity/doc/returnissue.php +++ b/www/app/entity/doc/returnissue.php @@ -61,7 +61,7 @@ public function Execute() { foreach ($this->unpackDetails('detaildata') as $item) { - $lp = $item->getLastPartion($this->headerdata['store'], $item->snumber); + $lp = $item->getLastPartion($this->headerdata['store'], $item->snumber, false); $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $item->item_id, $lp, $item->snumber, $item->sdate, true); diff --git a/www/app/entity/doc/task.php b/www/app/entity/doc/task.php index 9d2ce855c..0f4076f60 100644 --- a/www/app/entity/doc/task.php +++ b/www/app/entity/doc/task.php @@ -12,10 +12,10 @@ */ class Task extends Document { - + protected function init() { parent::init(); - // $this->tasktype = 0;//0 - услуги,1- производство + // $this->tasktype = 0;//0 - услуги,1- производство } @@ -34,7 +34,7 @@ public function generateReport() { } $detail[] = array("no" => $i++, "service_name" => $ser->service_name, - "desc" => $ser->desc, + "desc" => $ser->desc, "quantity" => H::fqty($ser->quantity), "cost" => H::fa($ser->cost * $ser->quantity), @@ -58,19 +58,19 @@ public function generateReport() { ); } - - $detailprod = array(); + + $detailprod = array(); foreach ($this->unpackDetails('prodlist') as $item) { - - $detailprod[] = array("no" => $i++, - "itemname" => $item->itemname, - "desc" => $item->desc, - "quantity" => H::fqty($item->quantity) ); - + + $detailprod[] = array("no" => $i++, + "itemname" => $item->itemname, + "desc" => $item->desc, + "quantity" => H::fqty($item->quantity)); + } - - + + $header = array('date' => H::fd($this->document_date), "pareaname" => strlen($this->headerdata["pareaname"]) > 0 ? $this->headerdata["pareaname"] : false, "document_date" => H::fd($this->document_date), @@ -79,7 +79,7 @@ public function generateReport() { "baseddoc" => strlen($this->headerdata["parent_number"]) > 0 ? $this->headerdata["parent_number"] : false, "cust" => strlen($this->customer_name) > 0 ? $this->customer_name : false, "_detail" => $detail, - "_detailprod" => $detailprod, + "_detailprod" => $detailprod, "_detail2" => $detail2, "iseq" => count($detail2) > 0, "_detail3" => $detail3 diff --git a/www/app/entity/doc/ttn.php b/www/app/entity/doc/ttn.php index 53bcde783..42faba395 100644 --- a/www/app/entity/doc/ttn.php +++ b/www/app/entity/doc/ttn.php @@ -3,6 +3,7 @@ namespace App\Entity\Doc; use App\Entity\Entry; +use App\Entity\Item; use App\Helper as H; /** @@ -167,6 +168,50 @@ public function Execute() { foreach ($this->unpackDetails('detaildata') as $item) { + + + //оприходуем с производства + if ($item->autoincome == 1 && $item->item_type == Item::TYPE_PROD) { + + if ($item->autooutcome == 1) { //комплекты + $set = \App\Entity\ItemSet::find("pitem_id=" . $item->item_id); + foreach ($set as $part) { + + $itemp = \App\Entity\Item::load($part->item_id); + $itemp->quantity = $item->quantity * $part->qty; + $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $itemp); + + foreach ($listst as $st) { + $sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity); + $sc->setStock($st->stock_id); + + $sc->save(); + } + + + } + } + + + $price = $item->getProdprice(); + + if ($price == 0) { + throw new \Exception(H::l('noselfprice', $item->itemname)); + + } + $stock = \App\Entity\Stock::getStock($this->headerdata['store'], $item->item_id, $price, $item->snumber, $item->sdate, true); + + $sc = new Entry($this->document_id, $item->quantity * $price, $item->quantity); + $sc->setStock($stock->stock_id); + + + $sc->save(); + + + } + + + //продажа $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $item); foreach ($listst as $st) { @@ -180,8 +225,8 @@ public function Execute() { return true; } - public function onState( $state) { - + public function onState($state) { + if ($state == Document::STATE_INSHIPMENT) { //расходы на доставку if ($this->headerdata['ship_amount'] > 0) { @@ -199,10 +244,10 @@ public function onState( $state) { $list = $order->getChildren('TTN'); if (count($list) == 1 && $common['numberttn'] <> 1) { //только эта ТТН - if ($state == Document::STATE_DELIVERED && ($order->state == Document::STATE_INSHIPMENT || $order->state == Document::STATE_READYTOSHIP || $order->state == Document::STATE_INPROCESS)) { + if ($state == Document::STATE_DELIVERED && ($order->state == Document::STATE_INSHIPMENT || $order->state == Document::STATE_READYTOSHIP || $order->state == Document::STATE_INPROCESS)) { $order->updateStatus(Document::STATE_DELIVERED); } - if ($state == Document::STATE_INSHIPMENT && ($order->state == Document::STATE_INPROCESS || $order->state == Document::STATE_READYTOSHIP) ) { + if ($state == Document::STATE_INSHIPMENT && ($order->state == Document::STATE_INPROCESS || $order->state == Document::STATE_READYTOSHIP)) { $order->updateStatus(Document::STATE_INSHIPMENT); } if ($state == Document::STATE_READYTOSHIP && $order->state == Document::STATE_INPROCESS) { diff --git a/www/app/entity/entry.php b/www/app/entity/entry.php index 9f45a1904..b2884b24d 100644 --- a/www/app/entity/entry.php +++ b/www/app/entity/entry.php @@ -70,11 +70,8 @@ public function setExtCode($code) { * @param mixed $stock товар (партия) * @param mixed $customer контрашент * @param mixed $emp сотрудник - * @param mixed $mf денежный счет - * @param mixed $asset необоротный актив - * @param mixed $code универсальное поле */ - public static function getQuantity($date = 0, $stock = 0, $customer = 0, $emp = 0, $code = 0) { + public static function getQuantity($date = 0, $stock = 0, $customer = 0, $emp = 0) { $conn = \ZDB\DB::getConnect(); $where = " 1=1"; if ($date > 0) { @@ -85,9 +82,6 @@ public static function getQuantity($date = 0, $stock = 0, $customer = 0, $emp = $where = $where . " and employee_id= " . $emp; } - if ($code > 0) { - $where = $where . " and extcode= " . $code; - } if ($stock > 0) { $where = $where . " and stock_id= " . $stock; @@ -108,11 +102,8 @@ public static function getQuantity($date = 0, $stock = 0, $customer = 0, $emp = * @param mixed $stock товар (партия) * @param mixed $customer контрашент * @param mixed $emp сотрудник - * @param mixed $mf денежный счет - * @param mixed $asset необоротный актив - * @param mixed $code универсальное поле */ - public static function getAmount($date = 0, $stock = 0, $customer = 0, $emp = 0, $code = 0) { + public static function getAmount($date = 0, $stock = 0, $customer = 0, $emp = 0) { $conn = \ZDB\DB::getConnect(); $where = " 1=1"; if ($date > 0) { @@ -123,9 +114,6 @@ public static function getAmount($date = 0, $stock = 0, $customer = 0, $emp = 0, $where = $where . " and employee_id= " . $emp; } - if ($code > 0) { - $where = $where . " and extcode= " . $code; - } if ($stock > 0) { $where = $where . " and stock_id= " . $stock; diff --git a/www/app/entity/firm.php b/www/app/entity/firm.php index 1fa439f28..8952dbece 100644 --- a/www/app/entity/firm.php +++ b/www/app/entity/firm.php @@ -47,7 +47,7 @@ protected function beforeSave() { $this->details .= "{$this->phone}"; $this->details .= "{$this->pposerver}"; $this->details .= "{$this->pposerverport}"; - $this->details .= "{$this->tin}"; + $this->details .= "{$this->tin}"; $this->details .= ""; return true; diff --git a/www/app/entity/item.php b/www/app/entity/item.php index 63aa3082a..f5ca8ce18 100644 --- a/www/app/entity/item.php +++ b/www/app/entity/item.php @@ -43,14 +43,22 @@ protected function afterLoad() { $this->val = (string)($xml->val[0]); $this->zarp = (string)($xml->zarp[0]); - $this->pricelist = (int)$xml->pricelist[0]; + $this->noprice = (int)$xml->noprice[0]; + $this->noshop = (int)$xml->noshop[0]; + $this->autooutcome = (int)$xml->autooutcome[0]; + $this->autoincome = (int)$xml->autoincome[0]; $this->useserial = (int)$xml->useserial[0]; $this->image_id = (int)$xml->image_id[0]; $this->weight = (string)$xml->weight[0]; + $this->maxsize = (string)$xml->maxsize[0]; + $this->volume = (string)$xml->volume[0]; + $this->customsize = (string)$xml->customsize[0]; $this->manufacturer = (string)$xml->manufacturer[0]; $this->shortname = (string)$xml->shortname[0]; $this->warranty = (string)$xml->warranty[0]; + $this->extdata = (string)$xml->extdata[0]; + $this->sef = (string)$xml->sef[0]; $this->cell = (string)$xml->cell[0]; // $this->octoreoptions = (string) $xml->octoreoptions[0]; @@ -88,7 +96,10 @@ protected function beforeSave() { } $this->detail = ""; //упаковываем данные в detail - $this->detail .= "{$this->pricelist}"; + $this->detail .= "{$this->noprice}"; + $this->detail .= "{$this->noshop}"; + $this->detail .= "{$this->autooutcome}"; + $this->detail .= "{$this->autoincome}"; $this->detail .= "{$this->useserial}"; $this->detail .= "{$this->cell}"; @@ -96,6 +107,7 @@ protected function beforeSave() { $this->detail .= "manufacturer}]]>"; $this->detail .= "shortname}]]>"; $this->detail .= "warranty}]]>"; + $this->detail .= "extdata}]]>"; $this->detail .= "{$this->price1}"; $this->detail .= "{$this->price2}"; @@ -108,15 +120,17 @@ protected function beforeSave() { $this->detail .= "{$this->image_id}"; $this->detail .= "{$this->weight}"; + $this->detail .= "{$this->maxsize}"; + $this->detail .= "{$this->volume}"; + $this->detail .= "{$this->customsize}"; + $this->detail .= "{$this->sef}"; //упаковываем цены по филиалам $brprice = serialize($this->brprice); - $this->detail .= ""; - $this->detail .= ""; return true; @@ -143,7 +157,7 @@ protected function afterDelete() { //$_price - цифра (заданая цена) или наименование цены из настроек //$store - склад //$partion - партия - public function getPrice($_price_, $store = 0, $partion = 0) { + public function getPrice($_price_ = 'price1', $store = 0, $partion = 0) { $price = 0; $_price = 0; $common = \App\System::getOptions("common"); @@ -254,21 +268,26 @@ public function getPrice($_price_, $store = 0, $partion = 0) { return \App\Helper::fa($price); } - public function getLastPartion($store = 0, $snumber = "") { + //последняя партия true по приходной false по расходной + public function getLastPartion($store = 0, $snumber = "", $gi = true) { $conn = \ZDB\DB::getConnect(); - $sql = " select coalesce(partion,0) from store_stock where partion >0 and item_id = {$this->item_id} "; + $q = $gi == true ? "e.quantity >0" : "e.quantity <0"; + + $sql = " select coalesce(partion,0) from store_stock st join entrylist e on st.stock_id = e.stock_id where {$q} and st.partion>0 and st.item_id = {$this->item_id} "; + if ($store > 0) { - $sql = $sql . " and store_id=" . $store; + $sql = $sql . " and st.store_id=" . $store; } if (strlen($snumber) > 0) { - $sql .= " and snumber = " . $conn->qstr($snumber); + $sql .= " and st.snumber = " . $conn->qstr($snumber); } - $sql = $sql . " order by stock_id desc limit 0,1"; + $sql = $sql . " order by e.document_id desc limit 0,1"; return $conn->GetOne($sql); } + public static function getPriceTypeList() { $common = \App\System::getOptions("common"); @@ -404,8 +423,12 @@ public static function getNextArticle() { return "ID" . sprintf("%04d", ++$id); } - - public static function getManufacturers() { + /** + * список производителей + * + * @param mixed $nametoindex добавить имя в индекс 9для комбобоксов) + */ + public static function getManufacturers($nametoindex = false) { $conn = \ZDB\DB::getConnect(); @@ -414,7 +437,12 @@ public static function getManufacturers() { $list = array(); foreach ($res as $v) { if (strlen($v['manufacturer']) > 0) { - $list[] = $v['manufacturer']; + if ($nametoindex) { + $list[$v['manufacturer']] = $v['manufacturer']; + } else { + $list[] = $v['manufacturer']; + } + } } return $list; @@ -436,10 +464,10 @@ public static function getTypes() { } /** - * себестоимость для готовой продукции - * - */ - public function getProdprice(){ + * себестоимость для готовой продукции + * + */ + public function getProdprice() { $price = 0; if ($this->zarp > 0) { $price += $this->zarp; @@ -452,11 +480,11 @@ public function getProdprice(){ $pr = $it->getLastPartion(0); $price += ($iset->qty * $pr); } - } - if($price==0) { //ищем последнюю партию + } + if ($price == 0) { //ищем последнюю партию $pr = $this->getLastPartion(0); } - - return $price; + + return $price; } } diff --git a/www/app/entity/pay.php b/www/app/entity/pay.php index cb7444497..206ff6485 100644 --- a/www/app/entity/pay.php +++ b/www/app/entity/pay.php @@ -16,6 +16,7 @@ class Pay extends \ZCL\DB\Entity const PAY_BASE_INCOME = 1; //операционные доходы const PAY_OTHER_INCOME = 2; //прочие доходы const PAY_FIN = 3; //доходы от фин. деятельности + const PAY_CANCEL_CUST = 5; //отмена платежа покупки const PAY_BASE_OUTCOME = 50; //операционные расходы @@ -29,6 +30,7 @@ class Pay extends \ZCL\DB\Entity const PAY_DIVIDEND_OUTCOME = 58; //распределение прибыли const PAY_INV = 59; //Инвестиции const PAY_BANK = 60; //Банковское обслуживание + const PAY_CANCEL = 58; //отмена платежа продажи protected function init() { $this->pl_id = 0; @@ -131,12 +133,18 @@ public static function cancelPayment($id, $comment) { return; } + $doc = \App\Entity\Doc\Document::load($pl->document_id); + $pay = new \App\Entity\Pay(); $pay->mf_id = $pl->mf_id; $pay->amount = 0 - $pl->amount; $pay->document_id = $pl->document_id; + + $pay->paytype = $pl->paytype; + + $pay->paydate = time(); $pay->notes = $comment; @@ -158,6 +166,7 @@ public static function getPayTypeList($type = 0) { $list[self::PAY_OTHER_INCOME] = \App\Helper::l('pt_inother'); $list[self::PAY_FIN] = \App\Helper::l('pt_fin'); + $list[self::PAY_CANCEL_CUST] = \App\Helper::l('pt_cancelcust'); } @@ -173,6 +182,7 @@ public static function getPayTypeList($type = 0) { $list[self::PAY_OTHER_OUTCOME] = \App\Helper::l('pt_outother'); $list[self::PAY_INV] = \App\Helper::l('pt_inv'); $list[self::PAY_BANK] = \App\Helper::l('pt_bank'); + $list[self::PAY_CANCEL] = \App\Helper::l('pt_cancel'); } diff --git a/www/app/entity/stock.php b/www/app/entity/stock.php index ced721942..3ff348128 100644 --- a/www/app/entity/stock.php +++ b/www/app/entity/stock.php @@ -133,7 +133,9 @@ public static function pickup($store_id, $item) { if (strlen($item->snumber) > 0) { $where .= " and snumber=" . Stock::qstr($item->snumber); } + $stlist = self::find($where, ' stock_id '); + $qty = $item->quantity; $last = null; foreach ($stlist as $st) { @@ -162,10 +164,12 @@ public static function pickup($store_id, $item) { } $last = self::getFirst($where, ' stock_id desc '); if ($last == null) { - $conn = \ZDB\DB::getConnect(); - $lastpartion = $conn->GetOne("select coalesce(partion,0) from store_stock where qty > 0 and item_id={$item->item_id} order by stock_id desc limit 0,1 ") ; - if($lastpartion==0) $lastpartion= $price; - + $conn = \ZDB\DB::getConnect(); + $lastpartion = $conn->GetOne("select coalesce(partion,0) from store_stock where qty > 0 and item_id={$item->item_id} order by stock_id desc limit 0,1 "); + if ($lastpartion == 0) { + $lastpartion = $price; + } + $last = new Stock(); $last->store_id = $store_id; $last->item_id = $item->item_id; diff --git a/www/app/entity/store.php b/www/app/entity/store.php index 75db3022d..4b74f9702 100644 --- a/www/app/entity/store.php +++ b/www/app/entity/store.php @@ -34,7 +34,12 @@ public static function getList() { } public static function getConstraint() { - return \App\ACL::getBranchConstraint(); + $br = \App\ACL::getBranchConstraint(); + if (strlen($br) > 0) { + $br = " (" . $br . " or coalesce(branch_id,0)=0) "; + } //склады не привязаные к филиалу + return $br; + } } diff --git a/www/app/entity/subscribe.php b/www/app/entity/subscribe.php index fba56e5d2..1a95508ba 100644 --- a/www/app/entity/subscribe.php +++ b/www/app/entity/subscribe.php @@ -3,7 +3,7 @@ namespace App\Entity; use App\Helper as H; -use App\System ; +use App\System; /** * Класс-сущность подписка на событие @@ -15,25 +15,25 @@ class Subscribe extends \ZCL\DB\Entity { //типы событий - const EVENT_DOCSTATE =1; - + const EVENT_DOCSTATE = 1; + //типы сообщений const MSG_NOTIFY = 1; - const MSG_EMAIL = 2; - const MSG_SMS = 3; - const MSG_VIBER = 4; - + const MSG_EMAIL = 2; + const MSG_SMS = 3; + const MSG_VIBER = 4; + //типы получателей - const RSV_CUSTOMER =1; - const RSV_DOCAUTHOR =2; - const RSV_USER =3; - + const RSV_CUSTOMER = 1; + const RSV_DOCAUTHOR = 2; + const RSV_USER = 3; + protected function init() { $this->sub_id = 0; } - + protected function afterLoad() { - + $xml = @simplexml_load_string($this->detail); $this->sub_typename = (string)($xml->sub_typename[0]); @@ -46,7 +46,7 @@ protected function afterLoad() { $this->user_id = (int)($xml->user_id[0]); $this->state = (int)($xml->state[0]); $this->doctype = (int)($xml->doctype[0]); - + parent::afterLoad(); } @@ -65,263 +65,269 @@ protected function beforeSave() { $this->detail .= "{$this->statename}"; $this->detail .= "{$this->username}"; $this->detail .= "{$this->msgsubject}"; - - + + $this->detail .= ""; return true; } - - - - public static function getEventList(){ + public static function getEventList() { $list = array(); - $list[self::EVENT_DOCSTATE]= H::l("sb_docstate"); - - return $list; - + $list[self::EVENT_DOCSTATE] = H::l("sb_docstate"); + + return $list; + } - public static function getMsgTypeList(){ + + public static function getMsgTypeList() { $list = array(); - $list[self::MSG_NOTIFY]= H::l("sb_msgnotify"); - $list[self::MSG_EMAIL]= H::l("sb_msgemail"); - $list[self::MSG_SMS]= H::l("sb_msgsms"); - // $list[self::MSG_VIBER]= H::l("sb_msgviber"); - - return $list; - + $list[self::MSG_NOTIFY] = H::l("sb_msgnotify"); + $list[self::MSG_EMAIL] = H::l("sb_msgemail"); + $list[self::MSG_SMS] = H::l("sb_msgsms"); + // $list[self::MSG_VIBER]= H::l("sb_msgviber"); + + return $list; + } - public static function getRecieverList(){ + + public static function getRecieverList() { $list = array(); - $list[self::RSV_CUSTOMER]= H::l("sb_rsvcust"); - $list[self::RSV_DOCAUTHOR]= H::l("sb_rsvda"); - $list[self::RSV_USER]= H::l("sb_rsvuser"); - - - return $list; - + $list[self::RSV_CUSTOMER] = H::l("sb_rsvcust"); + $list[self::RSV_DOCAUTHOR] = H::l("sb_rsvda"); + $list[self::RSV_USER] = H::l("sb_rsvuser"); + + + return $list; + } - + //изменение состояние документа - public static function onDocumentState($doc_id,$state) { - $doc = \App\Entity\Doc\Document::load($doc_id) ; - - $list = self::find('disabled <> 1 and sub_type= '. self::EVENT_DOCSTATE) ; - foreach($list as $sub) { - if($sub->doctype != $doc->meta_id) continue; - if($sub->state != $state) continue; - $phone=''; - // $viber=''; - $email=''; - $notify= 0 ; - if($sub->reciever_type == self::RSV_CUSTOMER) { - $c = \App\Entity\Customer::load($doc->customer_id) ; - if($c != null) { - $phone = $c->phone; - // $viber = $c->viber; - $email = $c->email; - - } - } - if($sub->reciever_type == self::RSV_DOCAUTHOR) { - $u = \App\Entity\User::load($doc->user_id) ; - if($u != null) { - $phone = $u->phone; - // $viber = $u->viber; - $email = $u->email; - $notify = $doc->user_id; - - } - - } - if($sub->reciever_type == self::RSV_USER) { - $u = \App\Entity\User::load($sub->user_id) ; - if($u != null) { - $phone = $u->phone; + public static function onDocumentState($doc_id, $state) { + $doc = \App\Entity\Doc\Document::load($doc_id); + + $list = self::find('disabled <> 1 and sub_type= ' . self::EVENT_DOCSTATE); + foreach ($list as $sub) { + if ($sub->doctype != $doc->meta_id) { + continue; + } + if ($sub->state != $state) { + continue; + } + $phone = ''; + // $viber=''; + $email = ''; + $notify = 0; + if ($sub->reciever_type == self::RSV_CUSTOMER) { + $c = \App\Entity\Customer::load($doc->customer_id); + if ($c != null) { + $phone = $c->phone; + // $viber = $c->viber; + $email = $c->email; + + } + } + if ($sub->reciever_type == self::RSV_DOCAUTHOR) { + $u = \App\Entity\User::load($doc->user_id); + if ($u != null) { + $phone = $u->phone; + // $viber = $u->viber; + $email = $u->email; + $notify = $doc->user_id; + + } + + } + if ($sub->reciever_type == self::RSV_USER) { + $u = \App\Entity\User::load($sub->user_id); + if ($u != null) { + $phone = $u->phone; // $viber = $u->viber; - $email = $u->email; - $notify = $doc->user_id; - - } - - } - $text = $sub->getText($doc) ; - if(strlen($phone)>0 && $sub->msg_type == self::MSG_SMS) { - self::sendSMS($phone,$text) ; - } - if(strlen($email)>0 && $sub->msg_type == self::MSG_EMAIL) { - self::sendEmail($email,$text,$sub->msgsubject) ; - } - // if(strlen($viber)>0 && $sub->msg_type == self::MSG_VIBER) { - // self::sendViber($viber,$text) ; - // } - if($notify>0 && $sub->msg_type == self::MSG_NOTIFY) { - self::sendNotify($notify,$text) ; - } - + $email = $u->email; + $notify = $doc->user_id; + + } + + } + $text = $sub->getText($doc); + if (strlen($phone) > 0 && $sub->msg_type == self::MSG_SMS) { + self::sendSMS($phone, $text); + } + if (strlen($email) > 0 && $sub->msg_type == self::MSG_EMAIL) { + self::sendEmail($email, $text, $sub->msgsubject); + } + // if(strlen($viber)>0 && $sub->msg_type == self::MSG_VIBER) { + // self::sendViber($viber,$text) ; + // } + if ($notify > 0 && $sub->msg_type == self::MSG_NOTIFY) { + self::sendNotify($notify, $text); + } + } - - } - + + } + /** - * возвращает текст с учетом разметки - * - * @param mixed $doc - */ - public function getText($doc){ + * возвращает текст с учетом разметки + * + * @param mixed $doc + */ + public function getText($doc) { //в разметке одинарные - $this->msgtext = str_replace('{','{{',$this->msgtext) ; - $this->msgtext = str_replace('}','}}',$this->msgtext) ; - - $header = array(); - - $header['document_number']=$doc->document_number ; - $header['document_date']= \App\Helper::fd($doc->document_date) ; - $header['amount']= \App\Helper::fa($doc->amount) ; - $header['forpay']= \App\Helper::fa($doc->payamount) ; - $header['customer_name']= $doc->customer_name ; - - $table=array(); - foreach($doc->unpackDetails('detaildata') as $item) { - $table[] = array('item_name'=>$item->itemname, - 'item_code'=>$item->item_code, - 'item_barcode'=>$item->bar_code, - 'msr'=>$item->msr, - 'qty'=>\App\Helper::fqty($item->quantity), - 'price'=>\App\Helper::fa($item->price), - 'summa'=>\App\Helper::fa($item->price*$item->quantity) - ) ; + $this->msgtext = str_replace('{', '{{', $this->msgtext); + $this->msgtext = str_replace('}', '}}', $this->msgtext); + + $header = array(); + + $header['document_number'] = $doc->document_number; + $header['document_date'] = \App\Helper::fd($doc->document_date); + $header['amount'] = \App\Helper::fa($doc->amount); + $header['forpay'] = \App\Helper::fa($doc->payamount); + $header['customer_name'] = $doc->customer_name; + + $table = array(); + foreach ($doc->unpackDetails('detaildata') as $item) { + $table[] = array('item_name' => $item->itemname, + 'item_code' => $item->item_code, + 'item_barcode' => $item->bar_code, + 'msr' => $item->msr, + 'qty' => \App\Helper::fqty($item->quantity), + 'price' => \App\Helper::fa($item->price), + 'summa' => \App\Helper::fa($item->price * $item->quantity) + ); } - - - $header['list'] = $table; - - try - { - $m = new \Mustache_Engine(); - $text = $m->render($this->msgtext, $header); - - - return $text; - - } catch(\Exception $e) { - return "Ошибка разметки" ; + + + $header['list'] = $table; + + try { + $m = new \Mustache_Engine(); + $text = $m->render($this->msgtext, $header); + + + return $text; + + } catch(\Exception $e) { + return "Ошибка разметки"; } - - - + + } - - - public static function sendEmail($email,$text,$subject) { + + + public static function sendEmail($email, $text, $subject) { $common = System::getOptions("common"); - - H::sendLetter($text,'',$email,$subject) ; + + H::sendLetter($text, '', $email, $subject); } - public static function sendViber($viber,$text) { - + + public static function sendViber($viber, $text) { + } - public static function sendNotify($user_id,$text) { - $n = new \App\Entity\Notify(); - $n->user_id = $user_id; - $n->message = $text; - - $n->save(); + + public static function sendNotify($user_id, $text) { + $n = new \App\Entity\Notify(); + $n->user_id = $user_id; + $n->message = $text; + + $n->save(); } - public static function sendSMS($phone,$text,$viber=false) { - try{ - $sms = System::getOptions("sms"); - - if($sms['smstype']==1) { //semy sms - - $data = array( - "phone" => $phone, - "msg" => $text, - "device" => $sms['smssemydevid'], - "token" => $sms['smssemytoken'] - ); - $url = "https://semysms.net/api/3/sms.php"; - $curl = curl_init($url); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); - $output = curl_exec($curl); - if (curl_errno($curl) > 0) { - - return 'Curl error: ' . curl_error($curl); - - } curl_close($curl); - $output = json_decode($output,true) ; - if($output['code']<>0) { - \App\Helper::logerror($output['error']) ; - return $output['error']; - } else { - return ''; - } - - } - if($sms['smstype']==2) { //turbo sms - - $json = '{ + + public static function sendSMS($phone, $text, $viber = false) { + try { + $sms = System::getOptions("sms"); + + if ($sms['smstype'] == 1) { //semy sms + + $data = array( + "phone" => $phone, + "msg" => $text, + "device" => $sms['smssemydevid'], + "token" => $sms['smssemytoken'] + ); + $url = "https://semysms.net/api/3/sms.php"; + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + $output = curl_exec($curl); + if (curl_errno($curl) > 0) { + + return 'Curl error: ' . curl_error($curl); + + } + curl_close($curl); + $output = json_decode($output, true); + if ($output['code'] <> 0) { + \App\Helper::logerror($output['error']); + return $output['error']; + } else { + return ''; + } + + } + if ($sms['smstype'] == 2) { //turbo sms + + $json = '{ "recipients":[ - "'.$phone.'" + "' . $phone . '" ], "sms":{ - "text": "'.$text.'" - } - } '; - - $url = "https://api.turbosms.ua/message/send.json"; - $curl = curl_init($url); - curl_setopt($curl, CURLOPT_USERPWD , $sms['turbosmstoken'] ); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $json); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json" )); - $output = curl_exec($curl); - if (curl_errno($curl) > 0) { - - return 'Curl error: ' . curl_error($curl); - - } curl_close($curl); - $output = json_decode($output,true) ; - if($output['response_code']<>0) { - \App\Helper::logerror($output['response_status']) ; - return $output['response_status']; - } else { - return ''; - } - - } - if($sms['smstype']==3) { //sms fly - - // $text = iconv('windows-1251', 'utf-8', htmlspecialchars('Заметьте, что когда герой фильма подписывает договор с Сатаной, он не подписывает копию договора и не получает ее.')); - $an =''; - if(strlen($sms['flysmsan'])>0) { - $an = "source=\"{$sms['flysmsan']}\""; + "text": "' . $text . '" } - - - $lifetime = 4; // срок жизни сообщения 4 часа - - $myXML = "\n"; - $myXML .= ""."\n"; - $myXML .= "SENDSMS"."\n"; - $myXML .= ' '."\n"; - $myXML .= " ".$text.""."\n"; - $myXML .= " ".$phone.""."\n"; - $myXML .= ""."\n"; - $myXML .= ""; + } '; + + $url = "https://api.turbosms.ua/message/send.json"; + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_USERPWD, $sms['turbosmstoken']); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $json); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); + $output = curl_exec($curl); + if (curl_errno($curl) > 0) { + + return 'Curl error: ' . curl_error($curl); + + } + curl_close($curl); + $output = json_decode($output, true); + if ($output['response_code'] <> 0) { + \App\Helper::logerror($output['response_status']); + return $output['response_status']; + } else { + return ''; + } + + } + if ($sms['smstype'] == 3) { //sms fly + + // $text = iconv('windows-1251', 'utf-8', htmlspecialchars('Заметьте, что когда герой фильма подписывает договор с Сатаной, он не подписывает копию договора и не получает ее.')); + $an = ''; + if (strlen($sms['flysmsan']) > 0) { + $an = "source=\"{$sms['flysmsan']}\""; + } + + + $lifetime = 4; // срок жизни сообщения 4 часа + + $myXML = "\n"; + $myXML .= "" . "\n"; + $myXML .= "SENDSMS" . "\n"; + $myXML .= ' ' . "\n"; + $myXML .= " " . $text . "" . "\n"; + $myXML .= " " . $phone . "" . "\n"; + $myXML .= "" . "\n"; + $myXML .= ""; $ch = curl_init(); - curl_setopt($ch, CURLOPT_USERPWD , $sms['flysmslogin'].':'.$sms['flysmspass']); + curl_setopt($ch, CURLOPT_USERPWD, $sms['flysmslogin'] . ':' . $sms['flysmspass']); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, 'http://sms-fly.com/api/api.php'); @@ -329,25 +335,26 @@ public static function sendSMS($phone,$text,$viber=false) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $myXML); $response = curl_exec($ch); - + if (curl_errno($ch) > 0) { - return 'Curl error: ' . curl_error($ch); - - } - curl_close($ch); - if(strpos($response,'ACCEPT') >0) return ''; - \App\Helper::logerror($response) ; - return $response; - - - - } - }catch(\Exception $e){ - \App\Helper::logerror($e->getMessage()) ; - return $e->getMessage() ; - } - + return 'Curl error: ' . curl_error($ch); + + } + curl_close($ch); + if (strpos($response, 'ACCEPT') > 0) { + return ''; + } + \App\Helper::logerror($response); + return $response; + + + } + } catch(\Exception $e) { + \App\Helper::logerror($e->getMessage()); + return $e->getMessage(); + } + } - + } \ No newline at end of file diff --git a/www/app/helper.php b/www/app/helper.php index ce35c7421..341ebe0e2 100644 --- a/www/app/helper.php +++ b/www/app/helper.php @@ -228,8 +228,10 @@ public static function loadEmail($template, $keys = array()) { public static function sendLetter($template, $emailfrom, $emailto, $subject = "") { global $_config; - if(strlen($emailfrom)==0) $emailfrom = $_config['smtp']['user'] ; - + if (strlen($emailfrom) == 0) { + $emailfrom = $_config['smtp']['user']; + } + $mail = new \PHPMailer\PHPMailer\PHPMailer(); $mail->setFrom($emailfrom); $mail->addAddress($emailto); @@ -373,7 +375,8 @@ public static function log($msg) { global $logger; $logger->debug($msg); } - /** + + /** * логгирование ошибок * * @param mixed $msg @@ -460,7 +463,7 @@ public static function fqty($qty) { if (strlen($qty) == 0) { return ''; } - $qty = str_replace(',','.',$qty) ; + $qty = str_replace(',', '.', $qty); $common = System::getOptions("common"); if ($common['qtydigits'] > 0) { @@ -480,7 +483,7 @@ public static function fa($am) { if (strlen($am) == 0) { return ''; } - $am = str_replace(',','.',$am) ; + $am = str_replace(',', '.', $am); $common = System::getOptions("common"); if ($common['amdigits'] == 1) { return number_format($am, 2, '.', ''); @@ -707,7 +710,7 @@ public static function getValName($vn) { return 'RUB'; } } - + public static function exportExcel($data, $header, $filename) { $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); @@ -797,6 +800,6 @@ public static function exportExcel($data, $header, $filename) { $writer->save('php://output'); die; } - - + + } diff --git a/www/app/modules/issue/pages/calendar.php b/www/app/modules/issue/pages/calendar.php index 8c3806092..59d8cc43b 100644 --- a/www/app/modules/issue/pages/calendar.php +++ b/www/app/modules/issue/pages/calendar.php @@ -35,7 +35,7 @@ public function __construct() { $this->add(new ClickLink('tabc', $this, 'onTab')); $this->add(new ClickLink('tabs', $this, 'onTab')); $this->listpan->add(new Panel('tasktab'))->setVisible(false); - + $this->listpan->tasktab->add(new ClickLink('addtime', $this, 'OnAdd')); $this->listpan->tasktab->add(new DataView('timelist', new EntityDataSource("\\App\\Modules\\Issue\\Entity\\TimeLine", 'user_id=' . $user->user_id, 'id desc'), $this, 'OnTimeRow')); @@ -44,7 +44,7 @@ public function __construct() { $this->listpan->tasktab->timelist->Reload(); $this->listpan->add(new Panel('caltab')); - + $this->listpan->caltab->add(new \App\Calendar('calendar'))->setEvent($this, 'OnCal'); $this->updateCal(); @@ -57,9 +57,10 @@ public function __construct() { $this->editform->add(new TextInput('enotes')); $this->editform->add(new DropDownChoice('eproject', Project::findArray('project_name', '', 'project_id desc')))->onChange($this, 'OnProject'); $this->editform->add(new DropDownChoice('eissue')); - - $this->onTab($this->tabc); + + $this->onTab($this->tabc); } + public function onTab($sender) { $this->_tvars['tabcbadge'] = $sender->id == 'tabc' ? "badge badge-dark badge-pill " : "badge badge-light badge-pill "; @@ -69,7 +70,7 @@ public function onTab($sender) { $this->listpan->tasktab->setVisible($sender->id == 'tabs'); $this->listpan->tasktab->timelist->Reload(); $this->updateCal(); - + } public function OnTimeRow($row) { @@ -202,43 +203,43 @@ public function OnCal($sender, $action) { if ($action['action'] == 'move') { $tl = TimeLine::load($action['id']); $tl->createdon = $tl->createdon + $action['delta']; - if($action['years'] <> 0) { - $tl->createdon = strtotime($action['years'] .' years',$tl->createdon) ; - + if ($action['years'] <> 0) { + $tl->createdon = strtotime($action['years'] . ' years', $tl->createdon); + } - if($action['months'] <> 0) { - $tl->createdon = strtotime($action['months'] .' months',$tl->createdon) ; - + if ($action['months'] <> 0) { + $tl->createdon = strtotime($action['months'] . ' months', $tl->createdon); + } - if($action['days'] <> 0) { - $tl->createdon = strtotime($action['days'] .' days',$tl->createdon) ; + if ($action['days'] <> 0) { + $tl->createdon = strtotime($action['days'] . ' days', $tl->createdon); } - if($action['ms'] <> 0) { - $tl->createdon = $tl->createdon + $action['ms']; + if ($action['ms'] <> 0) { + $tl->createdon = $tl->createdon + $action['ms']; } $tl->save(); - + } if ($action['action'] == 'resize') { $tl = TimeLine::load($action['id']); - - if($action['startdelta'] !=0) { - - $tl->createdon = $tl->createdon + ($action['startdelta'] / 3600); - $tl->duration = $tl->duration - ($action['startdelta'] / 3600); - - } - - if($action['enddelta'] != 0) { - - $tl->duration = $tl->duration + ($action['enddelta'] / 3600); + + if ($action['startdelta'] != 0) { + + $tl->createdon = $tl->createdon + ($action['startdelta'] / 3600); + $tl->duration = $tl->duration - ($action['startdelta'] / 3600); + + } + + if ($action['enddelta'] != 0) { + + $tl->duration = $tl->duration + ($action['enddelta'] / 3600); } $tl->save(); - + } - // $this->updateCal(); - // $this->listpan->timelist->Reload(); + // $this->updateCal(); + // $this->listpan->timelist->Reload(); } } diff --git a/www/app/modules/np/helper.php b/www/app/modules/np/helper.php index 6e66513bf..8927def05 100644 --- a/www/app/modules/np/helper.php +++ b/www/app/modules/np/helper.php @@ -53,28 +53,30 @@ public function getPointList($cityref) { //проверка экспрес накладной public function check($docs) { - $ar = array() ; - foreach($docs as $track) { - $ar[]=array('DocumentNumber' => $track) ; + $ar = array(); + foreach ($docs as $track) { + $ar[] = array('DocumentNumber' => $track); } - if(count($ar)==0) return array(); - + if (count($ar) == 0) { + return array(); + } + $params = array('Documents' => $ar); $list = array(); - + $res = $this ->model('TrackingDocument') ->method('getStatusDocuments') ->params($params) - ->execute(); - - if($res['success']==true) { - foreach($res['data'] as $row) { - $list[$row['Number']]= array('StatusCode'=>$row['StatusCode'],'Status'=>$row['Status']); + ->execute(); + + if ($res['success'] == true) { + foreach ($res['data'] as $row) { + $list[$row['Number']] = array('StatusCode' => $row['StatusCode'], 'Status' => $row['Status']); } - + } - return $list; + return $list; /* 1 Нова пошта очікує надходження від відправника diff --git a/www/app/modules/np/ttnlist.php b/www/app/modules/np/ttnlist.php index 9dd8c6bf0..e3e4d9499 100644 --- a/www/app/modules/np/ttnlist.php +++ b/www/app/modules/np/ttnlist.php @@ -18,12 +18,12 @@ use Zippy\Html\DataList\ArrayDataSource; class TTNList extends \App\Pages\Base -{ - public $_doclist = array() ; - private $_apikey = '' ; - - - public function __construct() { +{ + public $_doclist = array(); + private $_apikey = ''; + + + public function __construct() { parent::__construct(); if (strpos(System::getUser()->modules, 'np') === false && System::getUser()->rolename != 'admins') { @@ -34,33 +34,32 @@ public function __construct() { } $modules = System::getOptions("modules"); - $this->_apikey = $modules['npapikey'] ; - $this->add(new ClickLink('refresh',$this,'onRefresh')) ; - - $this->add(new DataView('doclist', new ArrayDataSource($this,'_doclist'), $this, 'doclistOnRow')); - + $this->_apikey = $modules['npapikey']; + $this->add(new ClickLink('refresh', $this, 'onRefresh')); + + $this->add(new DataView('doclist', new ArrayDataSource($this, '_doclist'), $this, 'doclistOnRow')); + $this->onRefresh($this->refresh); - - } - + + } + public function doclistOnRow($row) { $doc = $row->getDataItem(); $row->add(new Label('document_number', $doc->document_number)); $row->add(new Label('ship_number', $doc->headerdata['ship_number'])); $row->add(new Label('customer_name', $doc->customer_name)); - $row->add(new Label('amount', H::fa($doc->amount) )); - $row->add(new Label('state', $doc->headerdata['sn_state'] )); - - - $link= "https://my.novaposhta.ua/orders/printMarking100x100/orders[]/".$doc->headerdata['ship_number']."/type/pdf/apiKey/".$this->_apikey; + $row->add(new Label('amount', H::fa($doc->amount))); + $row->add(new Label('state', $doc->headerdata['sn_state'])); + + + $link = "https://my.novaposhta.ua/orders/printMarking100x100/orders[]/" . $doc->headerdata['ship_number'] . "/type/pdf/apiKey/" . $this->_apikey; $row->add(new BookmarkableLink('print'))->setLink($link); - - } - - - - //обновление статусов + + } + + + //обновление статусов public function onRefresh($sender) { $this->_doclist = array(); $api = new \App\Modules\NP\Helper(); @@ -68,27 +67,30 @@ public function onRefresh($sender) { $docs = Document::find("content like '%%' and meta_name = 'TTN' and state in(11,20) "); $tracks = array(); foreach ($docs as $ttn) { - if(strlen($ttn->headerdata['ship_number'])>0) $tracks[]=$ttn->headerdata['ship_number']; + if (strlen($ttn->headerdata['ship_number']) > 0) { + $tracks[] = $ttn->headerdata['ship_number']; + } } - + $statuses = $api->check($tracks); - + foreach ($docs as $ttn) { - - $decl = $ttn->headerdata['ship_number']; - if(strlen($decl)==0) continue; + + $decl = $ttn->headerdata['ship_number']; + if (strlen($decl) == 0) { + continue; + } $cnt = 0; - - + + $st = $statuses[$decl]['Status']; $code = $statuses[$decl]['StatusCode']; - $ttn->headerdata['sn_state']= $st; + $ttn->headerdata['sn_state'] = $st; // 9,10,11,106 - получено //4,5,6,7,8,41,101 - в пути //102,103,104,108,105,2,3 проблемы - - - + + if (in_array($code, array(9, 10, 11, 106))) { $ttn->updateStatus(Document::STATE_DELIVERED); $cnt++; @@ -105,15 +107,14 @@ public function onRefresh($sender) { } else { $this->setSuccess("npupdated", $cnt); } - - $this->_doclist[$ttn->document_id]=$ttn; + + $this->_doclist[$ttn->document_id] = $ttn; } - + $this->doclist->Reload(); } - - - + + } \ No newline at end of file diff --git a/www/app/modules/ocstore/items.php b/www/app/modules/ocstore/items.php index 8323ea80d..0af281f7e 100644 --- a/www/app/modules/ocstore/items.php +++ b/www/app/modules/ocstore/items.php @@ -38,7 +38,7 @@ public function __construct() { } $this->add(new Form('filter'))->onSubmit($this, 'filterOnSubmit'); - $this->filter->add(new DropDownChoice('searchcat', \App\Entity\Category::findArray("cat_name", "", "cat_name"), 0)); + $this->filter->add(new DropDownChoice('searchcat', \App\Entity\Category::getList(), 0)); $this->add(new Form('exportform'))->onSubmit($this, 'exportOnSubmit'); diff --git a/www/app/modules/ocstore/orders.php b/www/app/modules/ocstore/orders.php index d82b415ba..f47f494e0 100644 --- a/www/app/modules/ocstore/orders.php +++ b/www/app/modules/ocstore/orders.php @@ -151,10 +151,10 @@ public function onImport($sender) { } $tovar->quantity = $product['quantity']; $tovar->price = round($product['price']); - $desc=''; - if(array($product['_options_'] )) { - foreach($product['_options_'] as $k => $v){ - $desc= $desc . $k.':'.$v.';'; + $desc = ''; + if (array($product['_options_'])) { + foreach ($product['_options_'] as $k => $v) { + $desc = $desc . $k . ':' . $v . ';'; } } //$tovar->octoreoptions = serialize($product['_options_']); diff --git a/www/app/modules/shop/basket.php b/www/app/modules/shop/basket.php index 2de942f21..56fc89974 100644 --- a/www/app/modules/shop/basket.php +++ b/www/app/modules/shop/basket.php @@ -21,7 +21,12 @@ public static function getBasket() { } public function addProduct($product) { - $this->list[$product->product_id] = $product; + if(isset($this->list[$product->item_id] )) { + $this->list[$product->item_id]->quantity++; + } else { + $this->list[$product->item_id] = $product; + } + } public function deleteProduct($product_id) { @@ -29,10 +34,10 @@ public function deleteProduct($product_id) { $this->list_ = array_values($this->list); $this->list = array(); foreach ($this->list_ as $p) { - if ($p->product_id == $product_id) { + if ($p->item_id == $product_id) { continue; } - $this->list[$p->product_id] = $p; + $this->list[$p->item_id] = $p; } } diff --git a/www/app/modules/shop/comparelist.php b/www/app/modules/shop/comparelist.php index a88a96a0f..5bde0c4cc 100644 --- a/www/app/modules/shop/comparelist.php +++ b/www/app/modules/shop/comparelist.php @@ -4,8 +4,8 @@ use App\System; -//клаасс списка сравоения -class CompareList implements \Zippy\Interfaces\DataSource +//класс списка сравнения +class CompareList // implements \Zippy\Interfaces\DataSource { public $list = array(); @@ -23,27 +23,27 @@ public static function getCompareList() { public function addProduct($product) { if (count($this->list) > 0) { $v = array_values($this->list); - if ($v[0]->group_id != $product->group_id) { + if ($v[0]->cat_id != $product->cat_id) { return false; } } - $this->list[$product->product_id] = $product; + $this->list[$product->item_id] = $product; return true; } - public function deleteProduct($product_id) { + public function deleteProduct($item_id) { $this->list_ = array_values($this->list); $this->list = array(); foreach ($this->list_ as $p) { - if ($p->product_id == $product_id) { + if ($p->item_id == $item_id) { continue; } - $this->list[$p->product_id] = $p; + $this->list[$p->item_id] = $p; } } - public function hasProsuct($product_id) { - return isset($this->list[$product_id]); + public function hasProsuct($item_id) { + return isset($this->list[$item_id]); } public function isEmpty() { @@ -51,7 +51,7 @@ public function isEmpty() { } // реализация DataSource - + /* public function getItems($start, $count, $sortfield = null, $asc = null) { return array_values($this->list); } @@ -59,5 +59,5 @@ public function getItems($start, $count, $sortfield = null, $asc = null) { public function getItemCount() { return count($this->list); } - + */ } diff --git a/www/app/modules/shop/entity/image.php b/www/app/modules/shop/entity/image.php deleted file mode 100644 index 9dbc2b1ce..000000000 --- a/www/app/modules/shop/entity/image.php +++ /dev/null @@ -1,17 +0,0 @@ -manufacturer_id = 0; - } - - protected function beforeDelete() { - - $conn = \ZDB\DB::getConnect(); - $sql = " select count(*) from shop_products where manufacturer_id = {$this->manufacturer_id}"; - $cnt = $conn->GetOne($sql); - return ($cnt > 0) ? "Производитель используется в товарах" : ""; - } - -} diff --git a/www/app/modules/shop/entity/order.php b/www/app/modules/shop/entity/order.php deleted file mode 100644 index 3d76eb813..000000000 --- a/www/app/modules/shop/entity/order.php +++ /dev/null @@ -1,63 +0,0 @@ -order_id = 0; - $this->payment = 0; - $this->created = time(); - } - - protected function beforeSave() { - parent::beforeSave(); - //упаковываем данные в detail - $this->details = "{$this->delivery}"; - $this->details .= "{$this->payment}"; - $this->details .= ""; - - return true; - } - - protected function afterLoad() { - $this->created = strtotime($this->created); - $this->closed = strlen($this->closed) > 0 ? strtotime($this->closed) : null; - - //распаковываем данные из detail - $xml = simplexml_load_string($this->details); - $this->delivery = (int)($xml->delivery[0]); - $this->payment = (int)($xml->payment[0]); - - parent::afterLoad(); - } - - protected function afterSave($update) { - parent::afterSave($update); - if ($update == false) { - return; - } - $conn = \ZCL\DB\DB::getConnect(); - - $plist = OrderDetail::find("order_id =" . $this->order_id); - foreach ($plist as $p) { - $conn->Execute("update shop_products set sold =0 where group_id=" . $p->group_id); - $sql = "SELECT product_id ,count(quantity) as qnt FROM `shop_orderdetails_view` WHERE product_id in( select product_id from shop_products where deleted <> 1 and group_id= " . $p->group_id . ") and (orderstatus = 1 or orderstatus =2) group by product_id order by count(quantity) DESC LIMIT 1"; - $row = $conn->GetRow($sql); - if ($p->product_id == $row["product_id"]) { - $pr = Product::load($p->product_id); - $pr->sold = 1; - $pr->save(); - } - } - } - -} diff --git a/www/app/modules/shop/entity/orderdetail.php b/www/app/modules/shop/entity/orderdetail.php deleted file mode 100644 index 8be82f275..000000000 --- a/www/app/modules/shop/entity/orderdetail.php +++ /dev/null @@ -1,20 +0,0 @@ -order_id = 0; - $this->orderdetail_id = 0; - } - -} diff --git a/www/app/modules/shop/entity/product.php b/www/app/modules/shop/entity/product.php index 7c89061e4..040db179b 100644 --- a/www/app/modules/shop/entity/product.php +++ b/www/app/modules/shop/entity/product.php @@ -2,111 +2,74 @@ namespace App\Modules\Shop\Entity; -//класс-сущность товара - /** - * @keyfield=product_id - * @table=shop_products - * @view=shop_products_view + * Класс-сущность товар онлайн каталога + * + * @table=items + * @view=items_view + * @keyfield=item_id */ -class Product extends \ZCL\DB\Entity +class Product extends \App\Entity\Item { - public $attributevalues; - public $images = array(); - + + public $productdata ; + protected function init() { - $this->product_id = 0; - $this->item_id = 0; - - $this->image_id = 0; - $this->group_id = 0; - $this->price = 0; - - $this->novelty = 0; //новинка - $this->sold = 0; //кол продаж - $this->topsold = 0; //топ продаж - - $this->rating = 0; //рейтинг - $this->comments = 0; //кол отзывов - $this->attributevalues = array(); - $this->images = array(); - $this->created = time(); + $this->productdata = new ProductData() ; + + + $this->productdata->desc = ''; + $this->productdata->actionprice = ''; + $this->productdata->sold = 0; //кол продаж + + $this->productdata->rating = 0; //рейтинг + $this->productdata->comments = 0; //кол отзывов + $this->productdata->attributevalues = array(); + $this->productdata->images = array(); + + } protected function afterLoad() { - - $xml = @simplexml_load_string($this->detail); - - $this->item_id = (int)($xml->item_id[0]); - $this->image_id = (int)($xml->image_id[0]); - $images = (string)($xml->images[0]); - $this->topsold = (int)($xml->topsold[0]); - - $this->item_code = (string)($xml->item_code[0]); - $this->chprice = (string)($xml->chprice[0]); - $this->description = (string)($xml->description[0]); - $this->fulldescription = (string)($xml->fulldescription[0]); - $this->aboutus = (string)($xml->aboutus[0]); - $this->contact = (string)($xml->contact[0]); - $this->delivery = (string)($xml->delivery[0]); - - $this->rating = round($this->rating); - $this->created = strtotime($this->created); - - if (strlen($images) > 0) { - $this->images = explode(',', $images); - } - parent::afterLoad(); + + $this->productdata = @unserialize(@base64_decode($this->extdata)) ; + if($this->productdata == null){ + $this->productdata = new ProductData() ; + } + + } protected function beforeSave() { + + $this->extdata = base64_encode(serialize($this->productdata)) ; + parent::beforeSave(); - $this->detail = ""; - //упаковываем данные в detail - $this->detail .= "{$this->item_id}"; - $this->detail .= "{$this->image_id}"; - $this->detail .= "" . implode(',', $this->images) . ""; - $this->detail .= "{$this->topsold}"; - - $this->detail .= "{$this->item_code}"; - $this->detail .= "{$this->chprice}"; - $this->detail .= "description}]]>"; - $this->detail .= "fulldescription}]]>"; - $this->detail .= "aboutus}]]>"; - $this->detail .= "contact}]]>"; - $this->detail .= "delivery}]]>"; - - $this->detail .= ""; - - return true; } //перезеписываем значения атрибутов protected function afterSave($update) { $conn = \ZCL\DB\DB::getConnect(); - $conn->Execute("delete from shop_attributevalues where product_id=" . $this->product_id); - foreach ($this->attributevalues as $key => $value) { + $conn->Execute("delete from shop_attributevalues where item_id=" . $this->item_id); + foreach ($this->productdata->attributevalues as $key => $value) { //if ($value != null) { - $conn->Execute("insert into shop_attributevalues (attribute_id,product_id,attributevalue) values ({$key},{$this->product_id}," . $conn->qstr($value) . ")"); + $conn->Execute("insert into shop_attributevalues (attribute_id,item_id,attributevalue) values ({$key},{$this->item_id}," . $conn->qstr($value) . ")"); // } } + + parent::afterSave($update) ; } - protected function beforeDelete() { - - $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() { + parent::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); + $conn->Execute("delete from shop_attributevalues where item_id=" . $this->item_id); + } /** @@ -117,12 +80,12 @@ public function getAttrList() { $conn = \ZCL\DB\DB::getConnect(); //$attrlist = ProductAttribute::find("group_id=" . $this->group_id); - $attrlist = \App\Modules\Shop\Helper::getProductAttributeListByGroup($this->group_id); + $attrlist = \App\Modules\Shop\Helper::getProductAttributeListByGroup($this->cat_id); $ret = array(); $attrvalues = array(); - //выбираем значения атриутов продукта - $rows = $conn->Execute("select attribute_id,attributevalue from shop_attributevalues where product_id=" . $this->product_id); + //выбираем значения атрибутов продукта + $rows = $conn->Execute("select attribute_id,attributevalue from shop_attributevalues where item_id=" . $this->item_id); foreach ($rows as $row) { $attrvalues[$row['attribute_id']] = $row['attributevalue']; } @@ -130,7 +93,7 @@ public function getAttrList() { foreach ($attrlist as $attr) { $attr->value = @$attrvalues[$attr->attribute_id]; if (strlen($attr->value) == 0) { - $attr->nodata = true; + // $attr->nodata = 1; } $ret[] = $attr; } @@ -138,12 +101,25 @@ public function getAttrList() { return $ret; } - /** + //для сортировки + public function getPriceFinal() { + if($this->productdata->actionprice >0) return $this->productdata->actionprice; + return $this->price; + } + public function getRating() { + $r = 0; + if($this->comments >0) { + return round($this->ratings/$this->comments) ; + } + return $r; + } + + /** * Возвращает ЧПУ строку. Если не задана, возвращвет id * */ public function getSEF() { - return strlen($this->sef) > 0 ? $this->sef : $this->product_id; + return strlen($this->sef) > 0 ? $this->sef : '/sp/'. $this->item_id; } /** @@ -151,26 +127,38 @@ public function getSEF() { * */ public static function loadSEF($sef) { - return self::getFirst("product_id={$sef} or sef='{$sef}'"); + $sef = trim($sef,'/') ; + return self::getFirst(" detail like '%{$sef}%' "); } - /** - * возвращает количество на складе - * - * @param mixed $item_id - * @param mixed $store_id - */ - public function getQuantity($store_id = 0) { - - $conn = \ZDB\DB::getConnect(); - $sql = " select coalesce(sum(qty),0) as qty from store_stock where item_id = {$this->item_id} "; - if ($store_id > 0) { - $sql .= " and store_id = " . $store_id; - } - - $cnt = $conn->GetOne($sql); - return $cnt; + + public function getDescription() { + if(strlen($this->productdata->desc)>0) return $this->productdata->desc; + return $this->description; + } + public function getImages($includecover=false) { + $im = array(); + if($this->image_id >0 && $includecover) { + $im[]= $this->image_id ; + } + if(is_array($this->productdata->images)) { + foreach($this->productdata->images as $img) { + if($img != $this->image_id) $im[]= $img; + } + + } + return $im; } } + +/** +* Вспомагательный класс для упаковки данных относящихся к каталогу +*/ +class ProductData extends \App\DataItem +{ + public $attributevalues= array(); + public $images = array(); + +} \ No newline at end of file diff --git a/www/app/modules/shop/entity/productattribute.php b/www/app/modules/shop/entity/productattribute.php index 0206cb709..a73d2054c 100644 --- a/www/app/modules/shop/entity/productattribute.php +++ b/www/app/modules/shop/entity/productattribute.php @@ -12,12 +12,13 @@ class ProductAttribute extends \ZCL\DB\Entity { public $searchvalue; - public $nodata = 0; + protected function init() { $this->attribute_id = 0; - $this->showinlist = 0; + $this->value = ''; + } protected function afterDelete() { @@ -26,4 +27,18 @@ protected function afterDelete() { $conn->Execute("delete from shop_attributes_order where attr_id=" . $this->attribute_id); } + public function hasData(){ + if ($this->attributevalue == '') { + return false; + } + if ($this->attributetype == 3 ) { + if($this->attributevalue == -1) return false; + } + if ($item->attributetype == 1) { + if($attr->attributevalue == -1) return false; + + } + return true; + } + } diff --git a/www/app/modules/shop/entity/productcomment.php b/www/app/modules/shop/entity/productcomment.php index d7d5cabbe..aa3361108 100644 --- a/www/app/modules/shop/entity/productcomment.php +++ b/www/app/modules/shop/entity/productcomment.php @@ -15,8 +15,8 @@ protected function init() { $this->comment_id = 0; } - public static function findByProduct($product_id) { - return ProductComment::find(' product_id=' . $product_id, 'comment_id desc'); + public static function findByProduct($item_id) { + return ProductComment::find(' item_id=' . $item_id, 'comment_id desc'); } protected function afterLoad() { diff --git a/www/app/modules/shop/entity/productgroup.php b/www/app/modules/shop/entity/productgroup.php deleted file mode 100644 index 09a507499..000000000 --- a/www/app/modules/shop/entity/productgroup.php +++ /dev/null @@ -1,38 +0,0 @@ -group_id = 0; - $this->parent_id = 0; - $this->mpath = ''; - } - - protected function beforeDelete() { - - $conn = \ZDB\DB::getConnect(); - $sql = " select count(*) from shop_products where group_id = {$this->group_id}"; - $cnt = $conn->GetOne($sql); - return ($cnt > 0) ? \App\Helper::l('nodelusedfroup') : ""; - } - - 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) { - \App\Entity\Image::delete($image_id); - } - } - -} diff --git a/www/app/modules/shop/helper.php b/www/app/modules/shop/helper.php index c41785ba8..f1d5f5394 100644 --- a/www/app/modules/shop/helper.php +++ b/www/app/modules/shop/helper.php @@ -4,7 +4,7 @@ use App\Modules\Shop\Entity\Product; use App\Modules\Shop\Entity\ProductAttribute; -use App\Modules\Shop\Entity\ProductGroup; +use App\Entity\Category ; use ZCL\DB\DB; //класс вспомагательных функций @@ -15,41 +15,140 @@ public static function getBreadScrumbs($id) { $bs = "
  • Каталог
  • "; if ($id > 0) { - $g = ProductGroup::load($id); + $g = Category ::load($id); $gl = $g->getParents(); - - foreach ($gl as $gi) { - $bs .= "
  • {$gi->groupname}
  • "; + $gl = array_reverse($gl) ; + $all = Category::find(''); + foreach ($gl as $cat_id) { + $c = $all[$cat_id]; + $bs .= "
  • {$c->cat_name}
  • "; } - $bs .= "
  • {$g->groupname}
  • "; + $bs .= "
  • {$g->cat_name}
  • "; } return $bs; } //список производителей в данной группе товаров - public static function _getManufacturerNamesByGroup($group_id, $child = false) { + public static function getManufacturers($cat_id=0 ) { + $cat = ''; + if($cat_id>0) { + $cat = " cat_id={$cat_id} and " ; + } + $list = array(); + $conn = DB::getConnect(); + $sql = " select manufacturer from items where {$cat} disabled <> 1 order by manufacturer "; + $rs = $conn->Execute($sql); + foreach ($rs as $row) { + if(strlen($row["manufacturer"])>0) { + $list[] = $row["manufacturer"]; + } + } + + return $list; + } + + /** + * список значений атрибутов товара + * + * @param mixed $product + */ + public static function getAttributeValuesByProduct($product,$all=true) { $list = array(); $conn = DB::getConnect(); - $in = " select manufacturer_id from shop_products p where p.group_id={$group_id}"; - if ($child === true) { - $in = " select manufacturer_id from shop_products p where p.deleted <> 1 and p.group_id in( select g.group_id from shop_productgroups g where treeorder like '%" . sprintf('%08s', $group_id) . "%' )"; + $sql = "select v.attribute_id ,a.attributename,a.attributetype,a.valueslist,a.valueslist,v.attributevalue from shop_attributes a join shop_attributevalues v on a.attribute_id = v.attribute_id where v.item_id= " . $product->item_id; + + + $rs = $conn->Execute($sql); + foreach ($rs as $row) { + $prod = new ProductAttribute($row); + if($all == false && $prod->hasData()==false) continue; + + $list[$row['attribute_id']] = $prod; } + return $list; + } + + /** + * Возвращает список атрибутов для группы + * + * @param mixed $cat_id группа + */ + public static function getProductAttributeListByGroup($cat_id) { + $list = array(); + + $conn = DB::getConnect(); + + + $group = \App\Entity\Category::load($cat_id); + $grlist = $group->getParents(); + + $grlist[] = $cat_id; + $grlist[] = 0; + + $sql = "select attribute_id, cat_id,attributename,attributetype,valueslist,ordern from shop_attributes_view where cat_id in(". implode(',',$grlist) .") order by ordern"; - $sql = "select manufacturer_id,manufacturername from shop_manufacturers where manufacturer_id in({$in}) order by manufacturername "; + $attrtypes = self::getAttributeTypes(); $rs = $conn->Execute($sql); foreach ($rs as $row) { - $list[$row["manufacturer_id"]] = $row["manufacturername"]; + $row['attributetypename'] = $attrtypes[$row['attributetype']]; + $list[$row["attribute_id"]] = new ProductAttribute($row); + } + return $list; + } + + /** + * Возвращает список атрибутов группы для отбора + * + * @param mixed $cat_id группа + */ + public static function getProductSearchAttributeListByGroup($cat_id) { + $list = array(); + if ($cat_id == 0) { + return $list; } + $conn = DB::getConnect(); + $cat = \App\Entity\Category::load($cat_id); + $plist = $cat->getParents(); + $plist[]=$cat_id; + $grlist = implode(',',$plist) ; + $sql = "select attribute_id, cat_id,attributename,attributetype,valueslist from shop_attributes + where cat_id in($grlist) and attributetype in(1,2,3,4) and attribute_id in(select distinct attribute_id from shop_attributevalues) order by cat_id"; + + $attrtypes = self::getAttributeTypes(); + $rs = $conn->Execute($sql); + foreach ($rs as $row) { + $row['attributetypename'] = $attrtypes[$row['attributetype']]; + $list[$row["attribute_id"]] = new ProductAttribute($row); + } return $list; } + // список типов атрибутов товара + public static function getAttributeTypes() { + + return array(1 => \App\Helper::l("shopattrynname") , + // 2 => \App\Helper::l("shopattrnumname") , + 3 => \App\Helper::l("shopattrlistname") , + 4 => \App\Helper::l("shopattrsetname") , + 5 => \App\Helper::l("shopattrstrname") + ); + } + + //список значений для атрибута типа число + public static function getAttrValues($cat_id, $attribute_id) { + $conn = DB::getConnect(); + $sql = "select distinct attributevalue from shop_attributevalues where attribute_id = {$attribute_id} and item_id in(select item_id from items where disabled <> 1 and cat_id={$cat_id}) order by attributevalue"; + return $conn->GetCol($sql); + } + + /* //формирование условий отбора по выбранным критериям private static function _getWhere($filter) { $where = ' where deleted <> 1 '; - if ($filter->group_id > 0) { - // $where = $where . " and p.group_id in (select g.group_id from shop_productgroups g where treeorder like '%" . sprintf('%08s', $filter->group_id) . "%') "; - $where = $where . " and group_id ={$filter->group_id} "; + if ($filter->cat_id > 0) { + // $where = $where . " and p.cat_id in (select g.cat_id from shop_productgroups g where treeorder like '%" . sprintf('%08s', $filter->cat_id) . "%') "; + $where = $where . " and cat_id ={$filter->cat_id} "; } if ($filter->minprice > 0) { $where = $where . " and price >= " . $filter->minprice; @@ -70,7 +169,7 @@ private static function _getWhere($filter) { if (count($filter->attributes) > 0) { - $wherep = " and product_id in(select product_id from shop_attributevalues where "; + $wherep = " and item_id in(select item_id from shop_attributevalues where "; foreach ($filter->attributes as $attr) { if ($attr->attributetype == 1 and $attr->searchvalue == 1) { $where = $where . $wherep . " attribute_id = " . $attr->attribute_id . " and attributevalue = '1')"; @@ -95,14 +194,14 @@ private static function _getWhere($filter) { return $where; } - /* + //список отфильтрованных товаров на странице (используется для пагинатора) public static function getProductList($start, $count) { $filter = ProductSearchFilter::getFilter(); $list = array(); - if ($filter->group_id == 0) { + if ($filter->cat_id == 0) { return $list; } $conn = DB::getConnect(); @@ -120,12 +219,12 @@ public static function getProductList($start, $count) { } return $list; } - */ + //количество отфильтрованных товаров (используется для пагинатора) public static function getProductCount($filter) { - if ($filter->group_id == 0) { + if ($filter->cat_id == 0) { return 0; } @@ -133,137 +232,11 @@ public static function getProductCount($filter) { $conn = DB::getConnect(); $where = self::_getWhere($filter); - $sql = "select count(product_id) as cnt from shop_products p " . $where; + $sql = "select count(item_id) as cnt from items p " . $where; return $conn->GetOne($sql); } - /* - public static function getProduct($product_id) - { - $conn = DB::getConnect(); - $sql = "select group_id,product_id,productname,p.manufacturer_id,price,image_id,description,fulldescription,m.manufacturername from shop_products p left join shop_manufacturers m on p.manufacturer_id = m.manufacturer_id where product_id=" . $product_id; - $rs = $conn->Execute($sql); - $product = new Product($rs->FetchRow()); - //$sql = "select av.attribute_id ,attributevalue,attributetype,valueslist from shop_attributevalues av join shop_attributes at on av.attribute_id = at.attribute_id where product_id= ". $product_id; - // $product->attributes = self::getAttributesByProduct($product_id) ; - - return $product; - } */ - //список атрибутов товара - public static function _getAttributesByProduct($product) { - $conn = DB::getConnect(); - $gr = $conn->GetOne('select treeorder from shop_productgroups g where g.group_id=' . $product->group_id); - $grs = str_split($gr, 8); - $grlist = implode(',', $grs); - - $sql = "select a.attribute_id, attributename,attributetype,valueslist,(select attributevalue from shop_attributevalues v where a.attribute_id = v.attribute_id and product_id={$product->product_id}) as attributevalue from shop_attributes a where group_id in($grlist) "; - - $list = array(); - - - $rs = $conn->Execute($sql); - foreach ($rs as $row) { - $list[$row['attribute_id']] = new ProductAttribute($row); - } - - return $list; - } - - /** - * список значений атрибутов товара - * - * @param mixed $product - */ - public static function getAttributeValuesByProduct($product) { - $list = array(); - $conn = DB::getConnect(); - $sql = "select v.attribute_id ,a.attributename,a.attributetype,a.valueslist,a.valueslist,v.attributevalue from shop_attributes a join shop_attributevalues v on a.attribute_id = v.attribute_id where v.product_id= " . $product->product_id; - - - $rs = $conn->Execute($sql); - foreach ($rs as $row) { - $list[$row['attribute_id']] = new ProductAttribute($row); - } - return $list; - } - - /** - * Возвращает список атрибутов для группы - * - * @param mixed $group_id группа - */ - public static function getProductAttributeListByGroup($group_id) { - $list = array(); - if ($group_id == 0) { - return $list; - } - $conn = DB::getConnect(); - - - $gr = $conn->GetOne("select mpath from shop_productgroups where group_id={$group_id} "); - $grs = str_split($gr, 8); - $grlist = implode(',', $grs); -// - $sql = "select attribute_id,showinlist, group_id,attributename,attributetype,valueslist,ordern from shop_attributes_view where group_id in($grlist) order by ordern"; - - $attrtypes = self::getAttributeTypes(); - $rs = $conn->Execute($sql); - foreach ($rs as $row) { - $row['attributetypename'] = $attrtypes[$row['attributetype']]; - $list[$row["attribute_id"]] = new ProductAttribute($row); - } - return $list; - } - - /** - * Возвращает список атрибутов группы для отбора - * - * @param mixed $group_id группа - */ - public static function getProductSearchAttributeListByGroup($group_id) { - $list = array(); - if ($group_id == 0) { - return $list; - } - $conn = DB::getConnect(); - - $gr = $conn->GetOne("select mpath from shop_productgroups where group_id={$group_id} "); - $grs = str_split($gr, 8); // получаем все родительские группы - $grlist = implode(',', $grs); - if (strlen($grlist) == 0) { - return $list; - } - $sql = "select attribute_id,showinlist, group_id,attributename,attributetype,valueslist from shop_attributes - where showinlist = 1 and group_id in($grlist) and attributetype in(1,2,3,4) and attribute_id in(select distinct attribute_id from shop_attributevalues) order by group_id"; - - $attrtypes = self::getAttributeTypes(); - $rs = $conn->Execute($sql); - foreach ($rs as $row) { - $row['attributetypename'] = $attrtypes[$row['attributetype']]; - $list[$row["attribute_id"]] = new ProductAttribute($row); - } - return $list; - } - - // список типов атрибутов товара - public static function getAttributeTypes() { - return array(1 => 'Есть/Нет', 2 => 'Число', 3 => 'Список', 4 => 'Набор', 5 => 'Строка'); - } - - //список значений для атрибута типа число - public static function getAttrValues($group_id, $attribute_id) { - $conn = DB::getConnect(); - $sql = "select distinct attributevalue from shop_attributevalues where attribute_id = {$attribute_id} and product_id in(select product_id from shop_products where deleted <> 1 and group_id={$group_id}) order by attributevalue"; - return $conn->GetCol($sql); - } - - //возвращает наименьшую и наибольшую цену - public static function getPriceRange($group_id) { - $conn = DB::getConnect(); - $sql = "select coalesce(min(price),0) as minp,coalesce(max(price),0) as maxp from shop_products where deleted <> 1 and group_id={$group_id} "; - return $conn->GetRow($sql); - } - + } diff --git a/www/app/modules/shop/pages/base.php b/www/app/modules/shop/pages/base.php index ca927a515..44ad5a992 100644 --- a/www/app/modules/shop/pages/base.php +++ b/www/app/modules/shop/pages/base.php @@ -5,6 +5,7 @@ use App\Application as App; use App\Helper; use App\System; +use \App\Modules\Shop\Entity\Product; class Base extends \Zippy\Html\WebPage { @@ -12,6 +13,7 @@ class Base extends \Zippy\Html\WebPage public function __construct($params = null) { \Zippy\Html\WebPage::__construct(); + global $_config; $shop = System::getOptions("shop"); if (!is_array($shop)) { @@ -31,6 +33,9 @@ public function __construct($params = null) { $this->_tvars["currencyname"] = $shop["currencyname"]; $this->_tvars["notcnt"] = false; + $this->add(new \Zippy\Html\Form\Form('searchform')); + $this->searchform->add(new \Zippy\Html\Form\AutocompleteTextInput('searchitem'))->onText($this,'onSearch'); + $this->searchform->searchitem->onChange($this,'onSelect'); $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); @@ -38,9 +43,36 @@ public function __construct($params = null) { $this->add(new \Zippy\Html\Link\BookmarkableLink('logo', "/"))->setVisible(strlen($this->op['logo']) > 0); $this->logo->setValue($this->op['logo']); - + $this->_tvars["shopname"] = $this->op['shopname']; + $this->_tvars["aboutus"] =strlen($this->op['aboutus'])>0; + $this->_tvars["contact"] =strlen($this->op['contact'])>0; + $this->_tvars["delivery"] =strlen($this->op['delivery'])>0; + $this->_tvars["news"] =strlen($this->op['news'])>0; + + $this->_tvars["np"] = $_config['modules']['np'] == 1; + } + + public function onSearch(\Zippy\Html\Form\AutocompleteTextInput $sender){ + $r = array(); + + + $text = Product::qstr('%' . $sender->getText() . '%'); + $code = Product::qstr($sender->getText() ); + $list = Product::findArray('itemname', " disabled <>1 and detail not like '%1%' and cat_id in(select cat_id from item_cat where detail not like '%1%' ) and ( itemname like {$text} or item_code like {$code} or bar_code like {$code} ) "); + foreach ($list as $k => $v) { + $r[$k] = $v; + } + return $r; + + } + public function onSelect(\Zippy\Html\Form\AutocompleteTextInput $sender){ + $key = $sender->getKey(); + if($key>0) { + App::Redirect("\\App\\Modules\\Shop\\Pages\\ProductView",$key) ; + } + } //вывод ошибки, используется в дочерних страницах public function setError($msg, $p1 = "", $p2 = "") { $msg = Helper::l($msg, $p1, $p2); diff --git a/www/app/modules/shop/pages/catalog.php b/www/app/modules/shop/pages/catalog.php index ae4e1172e..9e2d36b7a 100644 --- a/www/app/modules/shop/pages/catalog.php +++ b/www/app/modules/shop/pages/catalog.php @@ -19,47 +19,48 @@ class Catalog extends Base { - public $group_id = 0; + public $cat_id = 0; + public $_isfilter = false; //отфильтрованы ли данные + public $_list = array(); - public function __construct($id) { + public function __construct($id=0) { parent::__construct(); - $this->group_id = $id; - + $this->cat_id = $id; + $options= \App\System::getOptions('shop') ; + $this->_tvars['usefilter']= $options['usefilter'] ==1; + $this->_tvars['usefeedback']= $options['usefeedback'] ==1; + + $this->add(new BookmarkableLink("filterbtn")); $this->add(new Label("breadcrumb", Helper::getBreadScrumbs($id), true)); $filter = Filter::getFilter("ProductCatalog"); - $filter->group_id = $id; + $filter->cat_id = $id; $this->add(new Form('sfilter'))->onSubmit($this, 'searchformOnSubmit'); $this->sfilter->add(new ClickLink('sclear'))->onClick($this, 'onSClear'); $this->sfilter->add(new ManufacturerList('mlist')); - 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); + foreach ( Helper::getManufacturers($this->cat_id) as $m ) { + $this->sfilter->mlist->AddCheckBox($m, false, $m); } - $this->sfilter->add(new DataView('attrlist', new ArrayDataSource(Helper::getProductSearchAttributeListByGroup($this->group_id)), $this, 'attrlistOnRow'))->Reload(); - - $pr = Helper::getPriceRange($this->group_id); - $this->sfilter->add(new TextInput('pricefrom'))->setText(floor($pr["minp"])); - $this->sfilter->add(new TextInput('priceto'))->setText(ceil($pr["maxp"])); + $this->sfilter->add(new DataView('attrlist', new ArrayDataSource(Helper::getProductSearchAttributeListByGroup($this->cat_id)), $this, 'attrlistOnRow'))->Reload(); - $this->sfilter->add(new TextInput('searchkey')); + - if ($id > 0 && $filter->group_id != $id) { + if ($id > 0 && $filter->cat_id != $id) { $filter->clean(); //переключена группа - $filter->group_id = $id; + $filter->cat_id = $id; } $this->add(new Form('sortform')); - $this->sortform->add(new DropDownChoice('sortorder'))->onChange($this, 'onSort'); + $this->sortform->add(new DropDownChoice('sortorder',5))->onChange($this, 'onSort'); - $this->add(new DataView('catlist', new CatDataSource($this), $this, 'plistOnRow')); - $this->add(new \Zippy\Html\DataList\Paginator('pag', $this->catlist)); - $this->catlist->setPageSize(15); - $this->catlist->Reload(); - + $this->add(new DataView('catlist', new ArrayDataSource($this,'_list'), $this, 'plistOnRow')); + // $this->add(new \Zippy\Html\DataList\Paginator('pag', $this->catlist)); + // $this->catlist->setPageSize(15); + $this->UpdateList(); //недавно просмотренные $ra = array(); @@ -74,26 +75,153 @@ public function __construct($id) { } } $this->add(new Panel("recentlyp"))->setVisible(count($ra) > 0); - $this->recentlyp->add(new DataView('rlist', new EntityDataSource("\\App\\Modules\\Shop\\Entity\\Product", " product_id in (" . implode(",", $ra) . ")"), $this, 'rOnRow')); + $this->recentlyp->add(new DataView('rlist', new EntityDataSource("\\App\\Modules\\Shop\\Entity\\Product", " item_id in (" . implode(",", $ra) . ")"), $this, 'rOnRow')); if (count($ra) > 0) { $this->recentlyp->rlist->Reload(); } + + $this->_tvars['fcolor'] = "class=\"btn btn-success\""; + } + private function UpdateList(){ + $options= \App\System::getOptions('shop') ; + $conn = \ZDB\DB::getConnect(); + + $this->_list=array(); + + + $fields = "items_view.*" ; + $fields .= ",coalesce(( select count(0) from shop_prod_comments `c` where `c`.`item_id` = items_view.item_id ),0) AS `comments`" ; + $fields .= ",coalesce(( select sum(`r`.`rating`) from shop_prod_comments `r` where `r`.`item_id` = items_view.item_id),0) AS `ratings`" ; + $store = ""; + if($options['defstore']>0) $store = " s.store_id={$options['defstore']} and "; + $fields .= ",coalesce(( select sum(`s`.`qty`) from store_stock `s` where {$store} `s`.`item_id` = items_view.item_id) ,0) AS `qty`" ; + $fields .= ",coalesce(( select sum(0-`e`.`quantity`) from entrylist_view `e` where `e`.`quantity` < 0 and `e`.`item_id` = items_view.item_id),0) AS `sold`" ; + + + + $where = "cat_id = {$this->cat_id} and disabled <> 1 and detail not like '%1%' " ; + + $mlist = $this->sfilter->mlist->getCheckedList(); + if (count($mlist) > 0) { + $_mlist = array() ; + foreach($mlist as $m ) { + $_mlist[] = $conn->qstr($m); + } + + + $where .= " and manufacturer in (" . implode(",", $_mlist) . ") "; + } + if($this->_isfilter == true) { + + $ar = $this->sfilter->attrlist->getDataRows(); + foreach ($ar as $r) { + $attr = $r->getComponent("attrdata"); + if (count($attr->value) > 0) { + + $ar = $attr->value; + if (count($ar) > 0) { + + $where .= " and item_id in(select item_id from shop_attributevalues where attribute_id = " . $attr->productattribute->attribute_id; + + + $where .= " and (1=2 "; + foreach ($ar as $arv) { + $where .= " or attributevalue like " . $conn->qstr("%{$arv}%"); + } + + $where .= ")"; + } + + + $where .= " )"; + } + } + } //filtered + + foreach(Product::find($where,'itemname',-1,-1,$fields) as $prod) { + $prod->price = $prod->getPrice($options['defpricetype']) ; + + $this->_list[]=$prod; + } + + $sort = $this->sortform->sortorder->getValue(); + + if ($sort == 0) { + // $order = "price asc"; + usort( $this->_list,function($a,$b){ + return $a->getPriceFinal() > $b->getPriceFinal(); + }) ; + } + if ($sort == 1) { + // $order = "price desc"; + usort( $this->_list,function($a,$b){ + return $a->getPriceFinal() < $b->getPriceFinal(); + }) ; + } + if ($sort == 2) { + // $order = "rating desc"; + usort( $this->_list,function($a,$b){ + return $a->getRating() < $b->getRating(); + }) ; + } + if ($sort == 3) { + // $order = "comments desc"; + usort( $this->_list,function($a,$b){ + return $a->comments < $b->comments; + }) ; + } + + if ($sort == 4) { + // $order = "sold desc"; + usort( $this->_list,function($a,$b){ + return $a->sold < $b->sold; + }) ; + } + if ($sort == -1) { + // $order = "productname"; + usort( $this->_list,function($a,$b){ + return $a->itemname > $b->itemname; + }) ; + } + + $this->catlist->Reload(); + + } + + //строка товара public function plistOnRow($row) { $item = $row->getDataItem(); + $options= \App\System::getOptions('shop') ; + - - $row->add(new BookmarkableLink("simage", "/sp/" . $item->product_id))->setValue('/loadshopimage.php?id=' . $item->image_id . "&t=t"); - $row->add(new BookmarkableLink("scatname", "/sp/" . $item->product_id))->setValue($item->productname); - $row->add(new Label("stopsold"))->setVisible($item->topsold == 1); - $row->add(new Label("snovelty"))->setVisible($item->novelty == 1); - $row->add(new Label("sshortdesc", $item->description)); - $row->add(new Label("sprice", $item->price)); - $row->add(new TextInput('srated'))->setText($item->rating); + $row->add(new BookmarkableLink("simage", $item->getSEF()))->setValue('/loadshopimage.php?id=' . $item->image_id . "&t=t"); + $row->add(new BookmarkableLink("scatname", $item->getSEF()))->setValue($item->itemname); + + $row->add(new Label("sprice", $item->price.' '. $options['currencyname'])); + $row->add(new Label("sactionprice", $item->productdata->actionprice.' '. $options['currencyname']))->setVisible(false); + $row->add(new Label('saction'))->setVisible(false); + + if($item->productdata->actionprice > 0) { + $row->sprice->setAttribute('style','text-decoration:line-through'); + $row->sactionprice->setVisible(true); + $row->saction->setVisible(true); + } + + $row->add(new TextInput('srated'))->setText($item->getRating()); + $row->add(new Label('scomments'))->setText(\App\Helper::l("shopfeedbaks",$item->comments) ); $row->add(new ClickLink('sbuy', $this, 'OnBuy')); + if ($item->getQuantity($options['defstore']) > 0) { + $row->sbuy->setValue(\App\Helper::l('tobay')); + } else { + $row->sbuy->setValue(\App\Helper::l('toorder')); + } + + + $op = \App\System::getOptions("shop"); if ($item->getQuantity($op['defstore']) > 0) { @@ -101,34 +229,24 @@ public function plistOnRow($row) { } else { $row->sbuy->setValue(\App\Helper::l('toorder')); } - $row->add(new Label('arrowup'))->setVisible($item->chprice == 'up'); - $row->add(new Label('arrowdown'))->setVisible($item->chprice == 'down'); } public function oncartdel($sender) { $item = $sender->getOwner()->getDataItem(); - \App\Modules\Shop\Basket::getBasket()->deleteProduct($item->product_id); + \App\Modules\Shop\Basket::getBasket()->deleteProduct($item->item_id); } public function oncompdel($sender) { $item = $sender->getOwner()->getDataItem(); - \App\Modules\Shop\CompareList::getCompareList()->deleteProduct($item->product_id); + \App\Modules\Shop\CompareList::getCompareList()->deleteProduct($item->item_id); } public function rOnRow($row) { $item = $row->getDataItem(); - $row->add(new BookmarkableLink("rimage", "/sp/" . $item->product_id))->setValue('/loadshopimage.php?id=' . $item->image_id . "&t=t"); - $row->add(new BookmarkableLink("rname", "/sp/" . $item->product_id))->setValue($item->productname); + $row->add(new BookmarkableLink("rimage", $item->getSEF()))->setValue('/loadshopimage.php?id=' . $item->image_id . "&t=t"); + $row->add(new BookmarkableLink("rname", $item->getSEF()))->setValue($item->itemname); } - public function onSClear($sender) { - $this->sfilter->clean(); - $pr = Helper::getPriceRange($this->group_id); - $this->sfilter->pricefrom->setText(floor($pr["minp"] / 100)); - $this->sfilter->priceto->setText(ceil($pr["maxp"] / 100)); - - $this->catlist->Reload(); - } public function OnBuy($sender) { @@ -142,13 +260,22 @@ public function OnBuy($sender) { } public function searchformOnSubmit($sender) { + $this->_isfilter = true; + $this->filterbtn->setAttribute('class','btn btn-danger'); + + $this->UpdateList(); + } + public function onSClear($sender) { + $this->sfilter->clean(); + $this->_isfilter = false; - $this->catlist->Reload(); + $this->filterbtn->setAttribute('class','btn btn-success'); + $this->UpdateList(); } public function onSort($sender) { - $this->catlist->Reload(); + $this->UpdateList(); } //строка атрибута @@ -161,91 +288,7 @@ public function attrlistOnRow($row) { } -class CatDataSource implements \Zippy\Interfaces\DataSource -{ - - private $page; - - public function __construct($page) { - $this->page = $page; - } - - private function getWhere() { - - // $filter = Filter::getFilter("ProductCatalog"); - - $conn = \ZDB\DB::getConnect(); - $form = $this->page->sfilter; - $where = "deleted <> 1 and group_id = " . $this->page->group_id; - $where .= " and price >= " . $form->pricefrom->getText(); - $where .= " and price <= " . $form->priceto->getText(); - $sk = $form->searchkey->getText(); - if (strlen(trim($sk)) > 0) { - $where .= " and productname like " . $conn->qstr("%{$sk}%"); - } - $mlist = $form->mlist->getCheckedList(); - if (count($mlist) > 0) { - $where .= " and manufacturer_id in (" . implode(",", $mlist) . ")"; - } - $ar = $form->attrlist->getDataRows(); - foreach ($ar as $r) { - $attr = $r->getComponent("attrdata"); - if (count($attr->value) > 0) { - - $ar = $attr->value; - if (count($ar) > 0) { - - $where .= " and product_id in(select product_id from shop_attributevalues where attribute_id = " . $attr->productattribute->attribute_id; - - - $where .= " and (1=2 "; - foreach ($ar as $arv) { - $where .= " or attributevalue like " . $conn->qstr("%{$arv}%"); - } - - $where .= ")"; - } - - - $where .= " )"; - } - } - //$logger->info($where); - return $where; - } - - public function getItemCount() { - return Product::findCnt($this->getWhere()); - } - - public function getItems($start, $count, $sortfield = null, $asc = null) { - - $order = "productname"; - $sort = $this->page->sortform->sortorder->getValue(); - if ($sort == 0) { - $order = "price asc"; - } - if ($sort == 1) { - $order = "price desc"; - } - if ($sort == 2) { - $order = "rating desc"; - } - if ($sort == 3) { - $order = "comments desc"; - } - if ($sort == 4) { - $order = "sold desc"; - } - if ($sort == 5) { - $order = "productname"; - } - - - return Product::find($this->getWhere(), $order, $count, $start); - } - -} + //компонент атрибута товара для фильтра //выводит элементы формы ввода в зависимости от типа атрибута @@ -266,9 +309,9 @@ public function getContent($attributes) { $name = $name . ", " . $this->productattribute->valueslist; } - $ret = "productattribute->attribute_id}\" data-toggle=\"collapse\" class=\"filtertiem\" >{$name} "; - $ret .= "
    productattribute->attribute_id}\" class=\"collapse\" >"; - + // $ret = "productattribute->attribute_id}\" data-toggle=\"collapse\" class=\"filtertiem\" >{$name} "; + // $ret .= "
    productattribute->attribute_id}\" class=\"collapse\" >"; + $ret = "{$name}"; //'Есть/Нет' if ($this->productattribute->attributetype == 1) { @@ -277,19 +320,19 @@ public function getContent($attributes) { if (in_array("1", $this->value)) { $checked = ' checked="on"'; } - $ret .= "
    "; + $ret .= "id}[]\" value=\"1\" {$checked} /> Есть
    "; $checked = ""; if (in_array("0", $this->value)) { $checked = ' checked="on"'; } - $ret .= ""; + $ret .= "id}[]\" value=\"0\" {$checked} /> Нет "; $ret .= "
    "; } //'Число' if ($this->productattribute->attributetype == 2) { $filter = Filter::getFilter("ProductCatalog"); - $list = Helper::getAttrValues($filter->group_id, $this->productattribute->attribute_id); + $list = Helper::getAttrValues($filter->cat_id, $this->productattribute->attribute_id); $ret .= "
    "; @@ -361,7 +404,8 @@ public function getContent($attributes) { $ret .= "
    "; } */ - return $ret . "
    "; + // return $ret . ""; + return $ret ; } //Вынимаем данные формы после сабмита diff --git a/www/app/modules/shop/pages/compare.php b/www/app/modules/shop/pages/compare.php index 8fbcb54e5..dc9db74c3 100644 --- a/www/app/modules/shop/pages/compare.php +++ b/www/app/modules/shop/pages/compare.php @@ -12,6 +12,7 @@ class Compare extends Base public function __construct() { parent::__construct(); + $this->add(new \Zippy\Html\Link\ClickLink('backtolist', $this, 'OnBack')); $this->add(new CompareGrid('comparegrid')); } @@ -21,6 +22,14 @@ protected function beforeRender() { $comparelist = Comparelist::getCompareList()->list; } + public function OnBack($sender) { + + $filter = \App\Filter::getFilter("ProductCatalog"); + + App::Redirect("\\App\\Modules\\Shop\\Pages\\Catalog", $filter->cat_id); + + } + } //класс формирующий таблицу сравнения @@ -28,18 +37,23 @@ class CompareGrid extends \Zippy\Html\CustomComponent implements \Zippy\Interfac { public function getContent($attributes) { - $result = ""; + $result = "
    "; $comparelist = Comparelist::getCompareList(); $attrlist = array(); $attrnames = array(); $attrvalues = array(); + $options = \App\System::getOptions('shop'); + + $nodata = \App\Helper::l("shopattrnodata"); + $yes = \App\Helper::l("shopattryes"); + $no = \App\Helper::l("shopattrno"); - $result .= ""; + $result .= ""; $url = $this->owner->getURLNode() . "::" . $this->id; ///цикл по товарам foreach ($comparelist->list as $product) { - $result .= (""); + $result .= (" "); $attributes = Helper::getAttributeValuesByProduct($product); //цикл по атрибутам для получения значений @@ -54,13 +68,18 @@ public function getContent($attributes) { } if ($attr->attributetype == 1) { - $value = $attr->attributevalue == 1 ? "Ecть" : "Нет"; + if ($attr->attributevalue == 0) { + $value = $no; + } + if ($attr->attributevalue == 1) { + $value = $yes; + } } - if ($attr->attributevalue == '') { - $value = "Н/Д"; + if ($attr->hasData() == false) { + $value = $nodata; } - $attrvalues[$attr->attribute_id][$product->product_id] = $value; + $attrvalues[$attr->attribute_id][$product->item_id] = $value; } } $result .= ""; @@ -71,7 +90,7 @@ public function getContent($attributes) { $result .= (""); foreach ($comparelist->list as $product) { - $result .= (""); + $result .= (""); } $result .= ""; $i++; @@ -89,7 +108,8 @@ public function RequestHandle() { $comparelist->deleteProduct($params[0]); if ($comparelist->isEmpty()) { $filter = \App\Filter::getFilter("ProductCatalog"); - App::Redirect("\\App\\Modules\\Shop\\Pages\\Catalog", $filter->group_id); + + App::Redirect("\\App\\Modules\\Shop\\Pages\\Catalog", $filter->cat_id); } } diff --git a/www/app/modules/shop/pages/grouplist.php b/www/app/modules/shop/pages/grouplist.php index ae13fd203..1fa890742 100644 --- a/www/app/modules/shop/pages/grouplist.php +++ b/www/app/modules/shop/pages/grouplist.php @@ -8,8 +8,10 @@ use App\Modules\Shop\Entity\ProductGroup; use App\Modules\Shop\Helper; use App\System; -use ZCL\BT\Tree; +use App\Entity\Category; use Zippy\Binding\PropertyBinding as Bind; +use Zippy\Html\DataList\DataView; +use Zippy\Html\DataList\ArrayDataSource; use Zippy\Html\Form\CheckBox; use Zippy\Html\Form\Form; use Zippy\Html\Form\TextArea; @@ -22,9 +24,10 @@ class GroupList extends \App\Pages\Base { - private $group = null, $rootgroup; - public $attrlist = array(); - private $mm; + private $group = null ; + public $_grouplist = array() ; + public $attrlist = array(); + private $mm; public function __construct() { parent::__construct(); @@ -35,28 +38,18 @@ public function __construct() { return; } - - $tree = $this->add(new Tree("tree")); - $tree->onSelectNode($this, "onTree"); - - $this->ReloadTree(); - - $form = $this->add(new Form('newgroupform')); - $form->add(new TextInput('newgroupname')); - $form->add(new SubmitLink('newgroup'))->onClick($this, 'OnNewGroup'); - - $form = $this->add(new Form('groupform')); - - - $form->add(new TextInput('groupname')); - $form->add(new SubmitLink('renamegroup'))->onClick($this, 'OnRenameGroup'); - $form->add(new SubmitLink('delgroup'))->onClick($this, 'OnDelGroup'); - $form->add(new SubmitLink('savegroup'))->onClick($this, 'OnSavePhoto'); - $form->add(new \Zippy\Html\Form\File('photo')); - $form->add(new \Zippy\Html\Image('group_image', '')); - + $clist = Category::find(" cat_id in(select cat_id from items where disabled <>1) and detail not like '%1%' " ) ; + + $this->_grouplist = Category::findFullData($clist) ; + + usort($this->_grouplist,function($a,$b){ return $a->full_name > $b->full_name; }) ; + + $this->add(new DataView('grouplist', new ArrayDataSource($this,'_grouplist'), $this, 'OnGroupRow')); + $this->grouplist->setSelectedClass('table-success'); + $this->grouplist->Reload(); + $attrpanel = $this->add(new Panel('attrpanel')); - $attrpanel->add(new \Zippy\Html\DataList\DataView('attritem', new \Zippy\Html\DataList\ArrayDataSource(new Bind($this, 'attrlist')), $this, 'OnAddRow')); + $attrpanel->add(new \Zippy\Html\DataList\DataView('attritem', new \Zippy\Html\DataList\ArrayDataSource(new Bind($this, 'attrlist')), $this, 'OnAttrRow')); //$this->UpdateAttrList(); @@ -69,7 +62,7 @@ public function __construct() { $form->add(new \Zippy\Html\Form\DropDownChoice('attrtype', Helper::getAttributeTypes()))->onChange($this, 'OnAttrType'); $form->add(new Label('attrtypename')); $form->add(new Label('tt'))->setAttribute("title", "Атрибут 'Есть/Нет' указывает наличие или отсутствие какойго либо параметра. Наприме FM-тюнер"); - $form->add(new CheckBox('showinlist')); + $form->add(new Panel('attrvaluespanel')); $form->attrvaluespanel->add(new TextArea('attrvalues')); @@ -79,162 +72,39 @@ public function __construct() { $form->meashurepanel->add(new TextInput('meashure')); $form->meashurepanel->setVisible(false); } - - //загрузить дерево - public function ReloadTree() { - - $this->tree->removeNodes(); - - $this->rootgroup = new ProductGroup(); - $this->rootgroup->group_id = PHP_INT_MAX; - $this->rootgroup->groupname = "//"; - - $root = new \ZCL\BT\TreeNode("//", PHP_INT_MAX); - $this->tree->addNode($root); - - $itemlist = ProductGroup::find("", "mpath,groupname"); - $nodelist = array(); - - foreach ($itemlist as $item) { - $node = new \ZCL\BT\TreeNode($item->groupname, $item->group_id); - $parentnode = @$nodelist[$item->parent_id]; - if ($item->parent_id == 0) { - $parentnode = $root; - } - - $this->tree->addNode($node, $parentnode); - - $nodelist[$item->group_id] = $node; - } + + public function OnGroupRow($row){ + $group = $row->getDataItem() ; + $row->add(new ClickLink('groupname',$this,'onGroup'))->setValue($group->full_name) ; } - - //клик по узлу - public function onTree($sender, $id) { - $nodeid = $this->tree->selectedNodeId(); - if ($nodeid == -1) { - $this->group = null; - return; - } - if ($nodeid == PHP_INT_MAX) { - $this->group = $this->rootgroup; - return; - } - $this->group = ProductGroup::load($nodeid); - $this->groupform->groupname->setText($this->group->groupname); - - $this->groupform->group_image->setUrl('/assets/images/noimage.jpg'); - if ($this->group->image_id > 0) { - $this->groupform->group_image->setUrl('/loadshopimage.php?id=' . $this->group->image_id); - } + + public function onGroup($sender ) { + $this->group = $sender->getOwner()->getDataItem(); + $this->grouplist->setSelectedRow($sender->getOwner()); + + $this->grouplist->Reload(false); $this->UpdateAttrList(); - //у верхнего уровня нет картинок - $this->groupform->group_image->setVisible($this->group->parent_id > 0); - $this->groupform->photo->setVisible($this->group->parent_id > 0); - $this->groupform->savegroup->setVisible($this->group->parent_id > 0); - } - - public function OnNewGroup($sender) { - $this->group = new ProductGroup(); - $this->group->groupname = $this->newgroupform->newgroupname->getText(); - $this->group->parent_id = $this->tree->selectedNodeId(); - if ($this->group->parent_id == $this->rootgroup->group_id) { - $this->group->parent_id = 0; - } else { - $pcnt = Product::findCnt("group_id=" . $this->group->parent_id); - if ($pcnt > 0) { - $this->setError('notallowedtotovgroup'); - - return; - } - } - $this->group->save(); - - $this->newgroupform->newgroupname->setText(''); - $this->ReloadTree(); - $this->tree->selectedNodeId($this->group->group_id); - $this->onTree($this->tree, 0); - } - - public function OnRenameGroup($sender) { - $newname = $this->groupform->groupname->getText(); - - if ($this->group->groupname == $newname) { - return; - } - - $this->group->groupname = $newname; - $this->group->save(); - $this->ReloadTree(); - } - - public function OnDelGroup($sender) { - - $del = ProductGroup::delete($this->group->group_id); - if (strlen($del) > 0 && is_string($del)) { - $this->setError($del); - return; - } - $this->group = null; - $this->ReloadTree(); - } - - public function OnSavePhoto($sender) { - - - $filedata = $this->getComponent('photo')->getFile(); - if (strlen($filedata["tmp_name"]) > 0) { - $imagedata = getimagesize($filedata["tmp_name"]); - - if (preg_match('/(gif|png|jpeg)$/', $imagedata['mime']) == 0) { - $this->setError(''); - return; - } - - if ($imagedata[0] * $imagedata[1] > 1000000) { - - $this->setError('toobigimage'); - return; - } - $r = ((double)$imagedata[0]) / $imagedata[1]; - if ($r > 1.1 || $r < 0.9) { - $this->setError(''); - $this->setError('squareimage'); - return; - } - - - $image = new \App\Modules\Shop\Entity\Image(); - $image->content = file_get_contents($filedata['tmp_name']); - - $thumb = new \App\Thumb($filedata['tmp_name']); - $thumb->resize(256, 256); - $image->thumb = $thumb->getImageAsString(); - - $image->mime = $imagedata['mime']; - $image->save(); - $this->group->image_id = $image->image_id; - $this->group->save(); - $this->groupform->group_image->setUrl('/loadshopimage.php?id=' . $this->group->image_id); - } + $this->attrpanel->attreditform->setVisible(false); } + //обновить атрибуты protected function UpdateAttrList() { $conn = \ZCL\DB\DB::getConnect(); - $this->mm = $conn->GetRow("select coalesce(max(ordern),0) as mm,coalesce(min(ordern),0) as mi from shop_attributes_order where pg_id=" . $this->group->group_id); + $this->mm = $conn->GetRow("select coalesce(max(ordern),0) as mm,coalesce(min(ordern),0) as mi from shop_attributes_order where pg_id=" . $this->group->cat_id); - $this->attrlist = Helper::getProductAttributeListByGroup($this->group->group_id); + $this->attrlist = Helper::getProductAttributeListByGroup($this->group->cat_id ); $this->attrpanel->attritem->Reload(); } - public function OnAddRow(\Zippy\Html\DataList\DataRow $datarow) { + public function OnAttrRow(\Zippy\Html\DataList\DataRow $datarow) { $item = $datarow->getDataItem(); $datarow->add(new Label("itemname", $item->attributename)); $attrlist = Helper::getAttributeTypes(); $datarow->add(new Label("itemtype", $attrlist[$item->attributetype])); $datarow->add(new Label("itemvalues", $item->valueslist)); - $datarow->add(new ClickLink("itemdel", $this, 'OnDeleteAtribute'))->setVisible($this->group->group_id == $item->group_id); - $datarow->add(new ClickLink("itemedit", $this, 'OnEditAtribute'))->setVisible($this->group->group_id == $item->group_id); + $datarow->add(new ClickLink("itemdel", $this, 'OnDeleteAtribute'))->setVisible($this->group->cat_id == $item->cat_id); + $datarow->add(new ClickLink("itemedit", $this, 'OnEditAtribute'))->setVisible($this->group->cat_id == $item->cat_id); $datarow->add(new ClickLink("orderup", $this, 'OnUp'))->setVisible($item->ordern > $this->mm["mi"]); $datarow->add(new ClickLink("orderdown", $this, 'OnDown'))->setVisible($item->ordern < $this->mm["mm"]); @@ -268,16 +138,16 @@ public function OnAttrType($sender) { $this->attrpanel->attreditform->attrvaluespanel->setVisible(true); } if ($type == 1) { - $this->attrpanel->attreditform->tt->setAttribute("title", "Атрибут 'Ксть/Нет' указывает на наличие или отстствие характеристики. Например FM-тюнер"); + $this->attrpanel->attreditform->tt->setAttribute("title", \App\Helper::l("shopattryn") ); } if ($type == 2) { - $this->attrpanel->attreditform->tt->setAttribute("title", "Атрибут 'Число' - числовой параметр (напрмер емкость акумулятора). Список для для фильтра отбора формируется на осноании диапазона значений атрибутв заданых для товароыв."); + $this->attrpanel->attreditform->tt->setAttribute("title", \App\Helper::l("shopattrnum") ); } if ($type == 3) { - $this->attrpanel->attreditform->tt->setAttribute("title", "Атрибут 'Список' предназначен для перечня из которого можно выбрать только одно значение. Например цвет. Задается списком через запятую"); + $this->attrpanel->attreditform->tt->setAttribute("title", \App\Helper::l("shopattrlist") ); } if ($type == 4) { - $this->attrpanel->attreditform->tt->setAttribute("title", "Атрибут 'Набор' предназначен для перечня из которого можно выбрать несколько значений.. Например диапазоны приема сигнала. Задается списком через запятую. "); + $this->attrpanel->attreditform->tt->setAttribute("title", \App\Helper::l("shopattrset") ); } if ($type == 5) { $this->attrpanel->attreditform->tt->setAttribute("title", "Атрибут 'Строка'- просто текстовый параметр (например тип процессора). Значени не используется в фильтре. "); @@ -311,7 +181,7 @@ public function OnEditAtribute($sender) { if ($item->attributetype == 3 || $item->attributetype == 4) { $form->attrvaluespanel->setVisible(true); } - $form->showinlist->setChecked($item->showinlist > 0); + } public function OnSaveAttribute($sender) { @@ -320,7 +190,7 @@ public function OnSaveAttribute($sender) { if ($attrid == "0") { $attr = new ProductAttribute(); - $attr->group_id = $this->group->group_id; + $attr->cat_id = $this->group->cat_id; $attr->attributetype = $form->attrtype->getValue(); } else { $attr = ProductAttribute::load($attrid); @@ -338,16 +208,15 @@ public function OnSaveAttribute($sender) { } if ($attr->attributetype == 3 || $attr->attributetype == 4) { $attr->valueslist = $form->attrvaluespanel->attrvalues->getText(); - $attr->valueslist = preg_replace('/\s+/', " ", $attr->valueslist); + $attr->valueslist = preg_replace('/\s+/', "", $attr->valueslist); } - $attr->showinlist = $form->showinlist->isChecked() ? 1 : 0; - + $attr->Save(); if ($attrid == "0") { $conn = \ZCL\DB\DB::getConnect(); $no = $conn->GetOne("select coalesce(max(ordern),0)+1 from shop_attributes_order"); - $conn->Execute("insert into shop_attributes_order (pg_id,attr_id,ordern)values({$attr->group_id},{$attr->attribute_id},{$no} )"); + $conn->Execute("insert into shop_attributes_order (pg_id,attr_id,ordern)values({$attr->cat_id},{$attr->attribute_id},{$no} )"); } $this->UpdateAttrList(); @@ -359,10 +228,10 @@ public function OnUp($sender) { $a1 = $sender->getOwner()->getDataItem(); //предыдущий - $a2 = ProductAttribute::getFirst("group_id={$this->group->group_id} and ordern < {$a1->ordern}", "ordern desc"); + $a2 = ProductAttribute::getFirst("cat_id={$this->group->cat_id} and ordern < {$a1->ordern}", "ordern desc"); $conn = \ZCL\DB\DB::getConnect(); - $conn->Execute("update shop_attributes_order set ordern={$a2->ordern} where pg_id={$this->group->group_id} and attr_id={$a1->attribute_id}"); - $conn->Execute("update shop_attributes_order set ordern={$a1->ordern} where pg_id={$this->group->group_id} and attr_id={$a2->attribute_id}"); + $conn->Execute("update shop_attributes_order set ordern={$a2->ordern} where pg_id={$this->group->cat_id} and attr_id={$a1->attribute_id}"); + $conn->Execute("update shop_attributes_order set ordern={$a1->ordern} where pg_id={$this->group->cat_id} and attr_id={$a2->attribute_id}"); $this->UpdateAttrList(); } @@ -371,10 +240,10 @@ public function OnDown($sender) { $a1 = $sender->getOwner()->getDataItem(); //следующий - $a2 = ProductAttribute::getFirst("group_id={$this->group->group_id} and ordern > {$a1->ordern}", "ordern asc"); + $a2 = ProductAttribute::getFirst("cat_id={$this->group->cat_id} and ordern > {$a1->ordern}", "ordern asc"); $conn = \ZCL\DB\DB::getConnect(); - $conn->Execute("update shop_attributes_order set ordern={$a2->ordern} where pg_id={$this->group->group_id} and attr_id={$a1->attribute_id}"); - $conn->Execute("update shop_attributes_order set ordern={$a1->ordern} where pg_id={$this->group->group_id} and attr_id={$a2->attribute_id}"); + $conn->Execute("update shop_attributes_order set ordern={$a2->ordern} where pg_id={$this->group->cat_id} and attr_id={$a1->attribute_id}"); + $conn->Execute("update shop_attributes_order set ordern={$a1->ordern} where pg_id={$this->group->cat_id} and attr_id={$a2->attribute_id}"); $this->UpdateAttrList(); } @@ -389,13 +258,12 @@ public function OnDeleteAtribute($sender) { public function beforeRender() { parent::beforeRender(); - $this->groupform->setVisible(false); + $this->attrpanel->setVisible(false); - if ($this->group instanceof ProductGroup) { - if ($this->group->groupname != "//") { - $this->groupform->setVisible(true); - $this->attrpanel->setVisible(true); - } + if ($this->group instanceof \App\Entity\Category ) { + + $this->attrpanel->setVisible(true); + } } diff --git a/www/app/modules/shop/pages/main.php b/www/app/modules/shop/pages/main.php index bebf11b5c..a96d486a3 100644 --- a/www/app/modules/shop/pages/main.php +++ b/www/app/modules/shop/pages/main.php @@ -13,49 +13,47 @@ class Main extends Base { - private $group_id = 0; + private $cat_id = 0; public function __construct($id = 0) { parent::__construct(); - $this->group_id = $id; + $this->cat_id = $id; - $toplist = ProductGroup::find("parent_id=0"); - - $this->_tvars["leftmenu"] = array(); - foreach ($toplist as $g) { - if ($g->gcnt > 0) { - $this->_tvars["leftmenu"][] = array("link" => "/scat/{$g->group_id}", "name" => $g->groupname); - } else { - $this->_tvars["leftmenu"][] = array("link" => "/pcat/{$g->group_id}", "name" => $g->groupname); - } - } + $this->add(new Label("breadcrumb", Helper::getBreadScrumbs($id), true)); $this->add(new Panel("subcatlistp")); - $this->subcatlistp->setVisible($id > 0); - $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->subcatlistp->add(new DataView("subcatlist", new EntityDataSource("\\App\\Entity\\Category", " detail not like '%1%' and parent_id=" . $id), $this, 'OnCatRow')); + + $this->subcatlistp->subcatlist->Reload(); + $this->add(new Panel("newlistp")); - $this->newlistp->add(new DataView("newlist", new EntityDataSource("\\App\\Modules\\Shop\\Entity\\Product", "", "product_id desc", 12), $this, 'OnNewRow'))->Reload(); + $cat=''; + if($id > 0) { + $c = \App\Entity\Category::load($id); + $ch = $c->getChildren() ; + $cat =" cat_id in (". implode(',',$ch) .") and " ; + } + + $this->newlistp->add(new DataView("newlist", new EntityDataSource("\\App\\Modules\\Shop\\Entity\\Product", " {$cat} disabled <> 1 and detail not like '%1%' ", "item_id desc", 6), $this, 'OnNewRow'))->Reload(); } public function OnCatRow($datarow) { $g = $datarow->getDataItem(); - $link = $g->gcnt > 0 ? "/scat/" . $g->group_id : "/pcat/" . $g->group_id; + $link = $g->hasChild() > 0 ? "/scat/" . $g->cat_id : "/pcat/" . $g->cat_id; $datarow->add(new BookmarkableLink("scatimg", $link))->setValue("/loadshopimage.php?id=" . $g->image_id); - $datarow->add(new BookmarkableLink("scatname", $link))->setValue($g->groupname); + $datarow->add(new BookmarkableLink("scatname", $link))->setValue($g->cat_name); } public function OnNewRow($row) { $item = $row->getDataItem(); - $row->add(new BookmarkableLink("nimage", "/sp/" . $item->product_id))->setValue('/loadshopimage.php?id=' . $item->image_id . "&t=t"); - $row->add(new BookmarkableLink("nname", "/sp/" . $item->product_id))->setValue($item->productname); + $row->add(new BookmarkableLink("nimage", $item->getSEF()))->setValue('/loadshopimage.php?id=' . $item->image_id . "&t=t"); + $row->add(new BookmarkableLink("nname", $item->getSEF()))->setValue($item->itemname); } } diff --git a/www/app/modules/shop/pages/manufacturers.php b/www/app/modules/shop/pages/manufacturers.php deleted file mode 100644 index 581233e8d..000000000 --- a/www/app/modules/shop/pages/manufacturers.php +++ /dev/null @@ -1,102 +0,0 @@ -modules, 'shop') === false && System::getUser()->rolename != 'admins') { - System::setErrorMsg('noaccesstopage'); - App::RedirectError(); - return; - } - - $panellist = $this->add(new \Zippy\Html\Panel('list')); - - $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')); - - - $editform = $this->add(new \Zippy\Html\Form\Form('editform')); - $editform->add(new \Zippy\Html\Form\TextInput('manufacturername')); - $editform->add(new \Zippy\Html\Form\TextInput('url')); - $editform->add(new \Zippy\Html\Form\TextInput('manufacturer_id')); - $editform->add(new \Zippy\Html\Form\SubmitButton('save'))->onClick($this, 'OnSubmit'); - $editform->add(new \Zippy\Html\Form\Button('cancel'))->onClick($this, 'cancelOnClick'); - - $editform->setVisible(false); - $this->list->manufacturerslist->Reload(); - } - - public function OnDeleteClick($sender) { - $item = $sender->getOwner()->getDataItem(); - - $del = Manufacturer::delete($item->manufacturer_id); - if (strlen($del) > 0) { - $this->setError($del); - return; - } - $this->list->manufacturerslist->Reload(); - } - - public function OnEditClick($sender) { - - $this->editform->SetVisible(true); - $this->list->SetVisible(false); - $item = $sender->getOwner()->getDataItem(); - $this->editform->manufacturername->setText($item->manufacturername); - $this->editform->url->setText($item->url); - $this->editform->manufacturer_id->setText($item->manufacturer_id); - } - - public function OnSubmit($sender) { - $name = $this->editform->manufacturername->getText(); - $url = $this->editform->url->getText(); - $id = $this->editform->manufacturer_id->getText(); - - if ($id > 0) { - $manufacturer = Manufacturer::load($id); - } else { - $manufacturer = new Manufacturer(); - } - $manufacturer->manufacturername = $this->editform->manufacturername->getText();; - $manufacturer->url = $this->editform->url->getText(); - $manufacturer->save(); - $this->list->manufacturerslist->Reload(); - $this->editform->SetVisible(false); - $this->list->SetVisible(true); - } - - public function OnAddClick($sender) { - $this->editform->SetVisible(true); - $this->list->SetVisible(false); - $this->editform->manufacturername->setText(''); - $this->editform->url->setText(''); - $this->editform->manufacturer_id->setText(0); - } - - public function OnAddRow(DataRow $datarow) { - $item = $datarow->getDataItem(); - $datarow->add(new \Zippy\Html\Label("manufacturername", $item->manufacturername)); - $datarow->add(new \Zippy\Html\Link\BookmarkableLink("url", $item->url))->setValue($item->url); - $datarow->add(new \Zippy\Html\Link\ClickLink("edit", $this, "OnEditClick")); - $datarow->add(new \Zippy\Html\Link\ClickLink("delete", $this, "OnDeleteClick")); - } - - public function cancelOnClick($sender) { - $this->list->setVisible(true); - $this->editform->setVisible(false); - } - -} diff --git a/www/app/modules/shop/pages/news.php b/www/app/modules/shop/pages/news.php new file mode 100644 index 000000000..c2c27608b --- /dev/null +++ b/www/app/modules/shop/pages/news.php @@ -0,0 +1,16 @@ +_tvars['news'] = base64_decode($shop['news']); + } + +} diff --git a/www/app/modules/shop/pages/options.php b/www/app/modules/shop/pages/options.php index 824bed738..2d5493f50 100644 --- a/www/app/modules/shop/pages/options.php +++ b/www/app/modules/shop/pages/options.php @@ -27,31 +27,42 @@ public function __construct() { $this->add(new Form('shop'))->onSubmit($this, 'saveShopOnClick'); - $this->shop->add(new DropDownChoice('shopdefstore', \App\Entity\Store::getList())); + $this->shop->add(new DropDownChoice('shopdefcust', \App\Entity\Customer::getList())); $this->shop->add(new DropDownChoice('shopdefpricetype', \App\Entity\Item::getPriceTypeList())); $this->shop->add(new TextInput('email')); + $this->shop->add(new TextInput('shopname')); $this->shop->add(new TextInput('currencyname')); $this->shop->add(new File('logo')); $this->shop->add(new CheckBox('uselogin')); + $this->shop->add(new CheckBox('usefilter')); + $this->shop->add(new CheckBox('usefeedback')); + $this->shop->add(new CheckBox('createnewcust')); $this->add(new Form('texts'))->onSubmit($this, 'saveTextsOnClick'); $this->texts->add(new TextArea('aboutus')); $this->texts->add(new TextArea('contact')); $this->texts->add(new TextArea('delivery')); + $this->texts->add(new TextArea('news')); $shop = System::getOptions("shop"); if (!is_array($shop)) { $shop = array(); } - $this->shop->shopdefstore->setValue($shop['defstore']); + $this->shop->shopdefcust->setValue($shop['defcust']); $this->shop->shopdefpricetype->setValue($shop['defpricetype']); $this->shop->currencyname->setText($shop['currencyname']); $this->shop->uselogin->setChecked($shop['uselogin']); + $this->shop->usefilter->setChecked($shop['usefilter']); + $this->shop->createnewcust->setChecked($shop['createnewcust']); + $this->shop->usefeedback->setChecked($shop['usefeedback']); + $this->shop->shopname->setText($shop['shopname']); + $this->shop->email->setText($shop['email']); + $this->shop->currencyname->setText($shop['currencyname']); - $this->add(new ClickLink('updateprices'))->onClick($this, 'updatePriceOnClick'); + $this->add(new ClickLink('updatesitemap'))->onClick($this, 'updateSiteMapOnClick'); if (strlen($shop['aboutus']) > 10) { @@ -63,6 +74,9 @@ public function __construct() { if (strlen($shop['delivery']) > 10) { $this->texts->delivery->setText(base64_decode($shop['delivery'])); } + if (strlen($shop['news']) > 10) { + $this->texts->news->setText(base64_decode($shop['news'])); + } } public function saveShopOnClick($sender) { @@ -71,11 +85,15 @@ public function saveShopOnClick($sender) { //todo контрагент магазина, кому нотификацию $shop['defcust'] = $this->shop->shopdefcust->getValue(); - $shop['defstore'] = $this->shop->shopdefstore->getValue(); + $shop['defpricetype'] = $this->shop->shopdefpricetype->getValue(); $shop['email'] = $this->shop->email->getText(); + $shop['shopname'] = $this->shop->shopname->getText(); $shop['currencyname'] = $this->shop->currencyname->getText(); $shop['uselogin'] = $this->shop->uselogin->isChecked() ? 1 : 0; + $shop['usefilter'] = $this->shop->usefilter->isChecked() ? 1 : 0; + $shop['createnewcust'] = $this->shop->createnewcust->isChecked() ? 1 : 0; + $shop['usefeedback'] = $this->shop->usefeedback->isChecked() ? 1 : 0; $file = $sender->logo->getFile(); @@ -101,36 +119,23 @@ public function saveShopOnClick($sender) { System::setOptions("shop", $shop); $this->setSuccess('saved'); } - - public function updatePriceOnClick($sender) { - $shop = System::getOptions("shop"); - - $prods = Product::find(" deleted = 0 "); - foreach ($prods as $p) { - $item = Item::load($p->item_id); - $price = $item->getPrice($shop['defpricetype']); - $p->chprice = ""; - if ($price > $p->price) { - $p->chprice = "up"; - } - if ($price < $p->price) { - $p->chprice = "down"; - } - $p->price = $price; - $p->save(); - } - $this->setSuccess('refreshed'); - } + public function updateSiteMapOnClick($sender) { + + $sm = _ROOT . 'sitemap.xml'; @unlink($sm); $xml = ""; $prods = Product::find(" deleted = 0 "); foreach ($prods as $p) { - - $xml = $xml . " " . _BASEURL . "sp/{$p->product_id}"; + if(strlen($p->sef)>0) { + $xml = $xml . " " . _BASEURL . "{$p->sef}"; + } else { + $xml = $xml . " " . _BASEURL . "sp/{$p->item_id}"; + } + } $xml .= ""; file_put_contents($sm, $xml); @@ -143,6 +148,7 @@ public function saveTextsOnClick($sender) { $shop['aboutus'] = base64_encode($this->texts->aboutus->getText()); $shop['contact'] = base64_encode($this->texts->contact->getText()); $shop['delivery'] = base64_encode($this->texts->delivery->getText()); + $shop['news'] = base64_encode($this->texts->news->getText()); System::setOptions("shop", $shop); $this->setSuccess('refreshed'); diff --git a/www/app/modules/shop/pages/order.php b/www/app/modules/shop/pages/order.php index 3ee93496b..a67ba0ac3 100644 --- a/www/app/modules/shop/pages/order.php +++ b/www/app/modules/shop/pages/order.php @@ -30,11 +30,12 @@ public function __construct() { $form->add(new Label('summa', new \Zippy\Binding\PropertyBinding($this, 'sum'))); $this->OnUpdate($this); $form = $this->add(new Form('orderform')); - $form->add(new DropDownChoice('delivery', array(1 => 'Самовывоз', 2 => 'Курьер', 3 => 'Почта')))->onChange($this, 'OnDelivery'); + $form->add(new DropDownChoice('delivery', Document::getDeliveryTypes($this->_tvars['np'] == 1) ))->onChange($this, 'OnDelivery'); $form->add(new TextInput('email')); $form->add(new TextInput('phone')); - $form->add(new TextInput('address'))->setVisible(false); - $form->add(new TextArea('contact')); + $form->add(new TextInput('name')); + $form->add(new TextArea('address'))->setVisible(false); + $form->add(new TextArea('notes')); $form->onSubmit($this, 'OnSave'); } @@ -61,7 +62,7 @@ public function OnUpdate($sender) { break; } - $this->sum = $this->sum + $product->price * $product->quantity; + $this->sum = $this->sum + $product->getPriceFinal() * $product->quantity; } Basket::getBasket()->list = $this->basketlist; @@ -69,12 +70,12 @@ public function OnUpdate($sender) { } public function OnDelete($sender) { - $product_id = $sender->owner->getDataItem()->product_id; - Basket::getBasket()->deleteProduct($product_id); + $item_id = $sender->owner->getDataItem()->item_id; + Basket::getBasket()->deleteProduct($item_id); $this->basketlist = Basket::getBasket()->list; if (Basket::getBasket()->isEmpty()) { - App::Redirect("\\App\\Modules\\Shop\\Pages\\Catalog", 0); + App::Redirect("\\App\\Modules\\Shop\\Pages\\Main", 0); } else { $this->OnUpdate($this); } @@ -85,9 +86,11 @@ public function OnSave($sender) { if (count($this->basketlist) == 0) { return; } - + $shop = System::getOptions("shop"); + $email = trim($this->orderform->email->getText()); $phone = trim($this->orderform->phone->getText()); + $name = trim($this->orderform->name->getText()); $delivery = $this->orderform->delivery->getValue(); $address = $this->orderform->address->getValue(); @@ -101,12 +104,21 @@ public function OnSave($sender) { $this->setError("enteraddress"); return; } + if (($delivery == 2 || $delivery == 3) && strlen($phone) == 0) { + + $this->setError("enterteldeliv"); + return; + } if (strlen($phone) == 0 && strlen($email) == 0) { $this->setError("entertelemail"); return; } - + if (strlen($phone) > 0 && strlen($phone) != \App\Helper::PhoneL()) { + $this->setError("tel10", \App\Helper::PhoneL()); + return; + } + try { $op = System::getOptions("shop"); @@ -121,16 +133,16 @@ public function OnSave($sender) { $order = Document::create('Order', $f); $order->document_number = $order->nextNumber(); if (strlen($order->document_number) == 0) { - $order->document_number = 'З0001'; + $order->document_number = 'З-0001'; } $amount = 0; $itlist = array(); foreach ($this->basketlist as $product) { $item = \App\Entity\Item::load($product->item_id); - $item->price = $product->price; + $item->price = $product->getPriceFinal(); $item->quantity = $product->quantity; - $item->product_id = $product->product_id; - $amount += ($product->price * $product->quantity); + $item->item_id = $product->item_id; + $amount += ($product->getPriceFinal() * $product->quantity); $itlist[$item->item_id] = $item; } @@ -139,48 +151,75 @@ public function OnSave($sender) { 'delivery_name' => $this->orderform->delivery->getValueName(), 'email' => $email, 'phone' => $phone, - 'address' => $address, + 'ship_address' => $address, 'total' => $amount ); $order->packDetails('detaildata', $itlist); - $cust = \App\Entity\Customer::load($op["defcust"]); + $cust = \App\Entity\Customer::getByEmail($email); if ($cust instanceof \App\Entity\Customer) { $order->customer_id = $cust->customer_id; } - $order->headerdata['store'] = $store_id; + $cust = \App\Entity\Customer::getByPhone($phone); + if ($cust instanceof \App\Entity\Customer) { + $order->customer_id = $cust->customer_id; + } + + if($order->customer_id==0) { + $cust = \App\Entity\Customer::load($op["defcust"]); + if ($cust instanceof \App\Entity\Customer) { + $order->customer_id = $cust->customer_id; + } + + if($shop['createnewcust'] == 1 ) { + + $c = new \App\Entity\Customer() ; + $c->customer_name = $name; + $c->email = $email; + $c->phone = $phone; + $c->save(); + $order->customer_id = $c->customer_id; + + } + + + + } + $order->headerdata['pricetype'] = $op["defpricetype"]; - $order->notes = trim($this->orderform->contact->getText()); + $order->notes = trim($this->orderform->notes->getText()); $order->amount = $amount; $order->save(); $order->updateStatus(Document::STATE_NEW); - - //todo покупатель по умолчанию - //todo отослаnь нотификацию - //todo отослаnь письмо + $this->setSuccess("shopneworder",$order->document_number); + + if(strlen($phone)>0) { + \App\Entity\Subscribe::sendSMS($phone, \App\Helper::l("shopyoursorder",$order->document_number) ) ; + } + } catch(\Exception $ee) { $this->setError($ee->getMessage()); } - $this->orderform->contact->setText(''); + $this->orderform->notes->setText(''); $this->basketlist = array(); Basket::getBasket()->list = array(); $this->orderform->setVisible(false); $this->listform->setVisible(false); - $this->setSuccess("order_sent"); + App::RedirectURI("/shop"); } public function OnAddRow(\Zippy\Html\DataList\DataRow $datarow) { $item = $datarow->getDataItem(); $datarow->setDataItem($item); - $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 \Zippy\Html\Link\RedirectLink('pname', '\App\Modules\Shop\Pages\ProductView', $item->item_id))->setValue($item->productname); + $datarow->add(new Label('price', $item->getPriceFinal())); $datarow->add(new TextInput('quantity', new \Zippy\Binding\PropertyBinding($item, 'quantity'))); $datarow->add(new \Zippy\Html\Link\ClickLink('delete', $this, 'OnDelete')); $datarow->add(new Image('photo', "/loadshopimage.php?id={$item->image_id}&t=t")); diff --git a/www/app/modules/shop/pages/productlist.php b/www/app/modules/shop/pages/productlist.php index 73971c36a..8249a85fc 100644 --- a/www/app/modules/shop/pages/productlist.php +++ b/www/app/modules/shop/pages/productlist.php @@ -5,11 +5,11 @@ use App\Application as App; use App\Entity\Item; use App\Modules\Shop\Entity\Product; -use App\Modules\Shop\Entity\ProductGroup; -use App\Modules\Shop\Entity\Manufacturer; + +use \App\Entity\Category; use App\System; -use ZCL\BT\Tree; + use Zippy\Binding\PropertyBinding as PB; use Zippy\Html\DataList\ArrayDataSource; use Zippy\Html\DataList\DataView; @@ -26,10 +26,12 @@ class ProductList extends \App\Pages\Base { - private $rootgroup, $product; + private $_item; private $store = ""; private $op; - public $group = null, $attrlist = array(), $imglist = array(); + public $attrlist = array(), $imglist = array(); + public $group = null ; + public $_grouplist = array() ; public function __construct() { parent::__construct(); @@ -46,46 +48,52 @@ public function __construct() { } - $tree = $this->add(new Tree("tree")); - $tree->onSelectNode($this, "onTree"); + $clist = Category::find(" cat_id in(select cat_id from items where disabled <>1) and detail not like '%1%' " ) ; + + $this->_grouplist = Category::findFullData($clist) ; + + usort($this->_grouplist,function($a,$b){ return $a->full_name > $b->full_name; }) ; + + $fc = new Category(); + $fc->cat_id=0; + $fc->cat_name= \App\Helper::l("allcategory"); + $fc->full_name= \App\Helper::l("allcategory"); + + $first=array($fc) ; + + + $this->_grouplist = array_merge($first,$this->_grouplist); + $this->add(new DataView('grouplist', new ArrayDataSource($this,'_grouplist'), $this, 'OnGroupRow')); + $this->grouplist->setSelectedClass('table-success'); + $this->grouplist->Reload(); - $this->ReloadTree(); $this->add(new Panel('listpanel')); $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', Manufacturer::findArray('manufacturername', '', 'manufacturername'))); + + $this->listpanel->searchform->add(new DropDownChoice('smanuf', \App\Modules\Shop\Helper::getManufacturers())); $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'); + + $this->listpanel->add(new ClickLink('addnew'))->onClick($this, 'addnewOnClick'); $this->listpanel->add(new DataView('plist', new ProductDataSource($this), $this, 'plistOnRow')); $this->listpanel->add(new \Zippy\Html\DataList\Paginator('pag', $this->listpanel->plist)); $this->listpanel->plist->setPageSize(15); - + $this->listpanel->setVisible(false); $this->add(new Panel('editpanel'))->setVisible(false); $editform = $this->editpanel->add(new Form('editform')); - $editform->add(new AutocompleteTextInput('eitem'))->onText($this, 'OnAutoItem'); - $editform->eitem->onChange($this, 'onChangeItem'); - $editform->add(new TextInput('ename')); - $editform->add(new TextInput('ecode')); - $editform->add(new TextInput('eprice', 0)); - - - $editform->add(new TextArea('edescshort')); + $editform->add(new TextInput('esef')); + $editform->add(new TextInput('actionprice')); + $editform->add(new TextArea('edescdet')); - - $editform->add(new DropDownChoice('emanuf', Manufacturer::findArray('manufacturername', '', 'manufacturername'))); - $editform->add(new DropDownChoice('egroup', ProductGroup::findArray('groupname', 'group_id not in (select parent_id from shop_productgroups)', 'groupname'))); - - + $editform->add(new DataView('attrlist', new ArrayDataSource(new PB($this, 'attrlist')), $this, 'attrlistOnRow')); - $editform->add(new CheckBox('edisabled')); + $editform->add(new ClickLink('bcancel'))->onClick($this, 'bcancelOnClick'); - $editform->add(new ClickLink('bdelete'))->onClick($this, 'bdeleteOnClick'); + $editform->onSubmit($this, 'onSubmitForm'); @@ -100,135 +108,48 @@ public function __construct() { $this->editimagepanel->add(new DataView('imagelist', new ArrayDataSource(new PB($this, 'imglist')), $this, 'imglistOnRow')); } - //загрузить дерево - public function ReloadTree() { - - $this->tree->removeNodes(); - - $this->rootgroup = new ProductGroup(); - $this->rootgroup->group_id = PHP_INT_MAX; - $this->rootgroup->groupname = "//"; - - $root = new \ZCL\BT\TreeNode("//", PHP_INT_MAX); - $this->tree->addNode($root); - - $itemlist = ProductGroup::find("", "mpath,groupname"); - $nodelist = array(); - - foreach ($itemlist as $item) { - $node = new \ZCL\BT\TreeNode($item->groupname, $item->group_id); - $parentnode = @$nodelist[$item->parent_id]; - if ($item->parent_id == 0) { - $parentnode = $root; - } - - $this->tree->addNode($node, $parentnode); + - $nodelist[$item->group_id] = $node; - } + public function OnGroupRow($row){ + $group = $row->getDataItem() ; + $row->add(new ClickLink('groupname',$this,'onGroup'))->setValue($group->full_name) ; } - - //клик по узлу - public function onTree($sender, $id) { - $this->listpanel->addnew->setVisible(false); - $this->editpanel->setVisible(false); - - $nodeid = $this->tree->selectedNodeId(); - if ($nodeid == -1) { - $this->group = null; - return; - } - if ($nodeid == -2) { - $this->group = $this->rootgroup; - return; - } - $this->group = ProductGroup::load($nodeid); - if ($this->group instanceof ProductGroup) { - $ch = $this->group->getChildren(); - //добавляем только для конечных групп - $this->listpanel->addnew->setVisible(count($ch) == 0); // Добавляем товар если нет дочерних груп у текущей] - } + + public function onGroup($sender ) { + $this->group = $sender->getOwner()->getDataItem(); + $this->grouplist->setSelectedRow($sender->getOwner()); + + $this->grouplist->Reload(false); + $this->editpanel->setVisible(false); + $this->listpanel->setVisible(true); $this->listpanel->plist->Reload(); - $this->attrlist = array(); - - $this->listpanel->setVisible(true); - } - + } + + public function searchformOnSubmit($sender) { $this->listpanel->plist->Reload(); } - public function sortingOnChange($sender) { - $this->listpanel->plist->Reload(); - } public function onSClear($sender) { $this->listpanel->searchform->clean(); $this->listpanel->plist->Reload(); } -//новый - public function addnewOnClick($sender) { - - $this->product = new Product(); - $this->product->createdon = time(); - $this->product->group_id = $this->group->group_id; - $this->editpanel->setVisible(true); - $this->editpanel->editform->eitem->setKey(0); - $this->editpanel->editform->eitem->setText(''); - $this->editpanel->editform->eitem->setAttribute('readonly', null); - $this->listpanel->setVisible(false); - $this->attrlist = $this->product->getAttrList(); - $this->editpanel->editform->attrlist->Reload(); - $this->editpanel->editform->clean(); - $this->editpanel->editform->bdelete->setVisible(false); - $this->editpanel->editform->egroup->setValue($this->group->group_id); - } - - //выбран товар - public function onChangeItem($sender) { - - $item = Item::load($sender->getKey()); - $this->product->productname = $item->itemname; - $this->product->item_code = $item->item_code; - - $this->editpanel->editform->ename->setText($this->product->productname); - $this->editpanel->editform->ecode->setText($this->product->item_code); - $this->editpanel->editform->eprice->setText($item->getPrice($this->op['defpricetype'], $this->op['defstore'])); - - //подтягиваем бренд если совпадает имя - if (strlen($item->manufacturer) > 0) { - $m = Manufacturer::getFirst('manufacturername =' . Manufacturer::qstr($item->manufacturer)); - if ($m instanceof Manufacturer) { - $this->editpanel->editform->emanuf->setValue($m->manufacturer_id); - } - } - - - } - - public function OnAutoItem($sender) { - - $text = Item::qstr('%' . trim($sender->getText()) . '%'); - $code = Item::qstr(trim($sender->getText())); - $list = Item::findArray("itemname", " disabled <> 1 and (itemname like {$text} or item_code = {$code} or bar_code = {$code} ) "); - - return $list; - } + //строка товара public function plistOnRow($row) { $item = $row->getDataItem(); - $row->add(new ClickLink("lname", $this, "lnameOnClick"))->setValue($item->productname); + $row->add(new ClickLink("lname", $this, "lnameOnClick"))->setValue($item->itemname); $row->add(new ClickLink("imedit", $this, "imeditOnClick")); - // $row->add(new Label("lmanuf", $item->manufacturername)); - $row->add(new Label("ldescshort", $item->description)); + $row->add(new Label("lcode", $item->item_code)); - $row->add(new Label("lprice", $item->price)); - //$qty=\App\Entity\Item::getQuantity($item->item_id) ; - $row->add(new Label("lcnt", $item->getQuantity($this->op['defstore']))); + $row->add(new Label("lprice", \App\Helper::fa($item->getPriceFinal()))); + + $row->add(new Label("lcnt", \App\Helper::fqty($item->getQuantity()))); $row->add(new \Zippy\Html\Image("lphoto"))->setUrl('/loadshopimage.php?id=' . $item->image_id . '&t=t'); } @@ -239,63 +160,43 @@ public function lnameOnClick($sender) { $this->editpanel->setVisible(true); $this->listpanel->setVisible(false); - $this->product = $sender->getOwner()->getDataItem(); - $this->editpanel->editform->eitem->setAttribute('readonly', 'readonly'); - - $this->editpanel->editform->ename->setText($this->product->productname); - - $item = Item::load($this->product->item_id); - $this->editpanel->editform->eitem->setText($item->itemname); - $this->editpanel->editform->eitem->setKey($this->product->item_id); - - $this->editpanel->editform->ecode->setText($this->product->item_code); - $this->editpanel->editform->edescshort->setText($this->product->description); - $this->editpanel->editform->edescdet->setText($this->product->fulldescription); - - $this->editpanel->editform->eprice->setText($this->product->price); - $this->editpanel->editform->emanuf->setValue($this->product->manufacturer_id); - - $this->editpanel->editform->bdelete->setVisible(true); - - $this->editpanel->editform->edisabled->setChecked($this->product->deleted > 0); - - $this->attrlist = $this->product->getAttrList(); + $this->_item = $sender->getOwner()->getDataItem(); + + $this->editpanel->editform->esef->setText($this->_item->sef); + $this->editpanel->editform->actionprice->setText($this->_item->productdata->actionprice); + + + + $this->editpanel->editform->edescdet->setText($this->_item->getDescription()); + + + + $this->attrlist = $this->_item->getAttrList(); $this->editpanel->editform->attrlist->Reload(); - $this->editpanel->editform->egroup->setValue($this->group->group_id); + } public function onSubmitForm($sender) { - $this->product->manufacturer_id = $sender->emanuf->getValue(); - - $this->product->productname = $sender->ename->getText(); - $this->product->item_id = $sender->eitem->getKey(); - $this->product->item_code = $sender->ecode->getText(); - $this->product->group_id = $sender->egroup->getValue(); - $this->product->description = $sender->edescshort->getText(); - $this->product->fulldescription = $sender->edescdet->getText(); - $this->product->price = $sender->eprice->getText(); - $this->product->chprice = "up"; - - $this->product->deleted = $sender->edisabled->isChecked(); - if (strlen($this->product->productname) == 0) { - $this->setError('entername'); - return; - } - - - $this->product->attributevalues = array(); + + $this->_item->sef = $sender->esef->getText(); + + $this->_item->productdata->desc = $sender->edescdet->getText(); + $this->_item->productdata->actionprice = $sender->actionprice->getText(); + + $this->_item->productdata->attributevalues = array(); $rows = $sender->attrlist->getChildComponents(); foreach ($rows as $r) { $a = $r->getDataItem(); - $this->product->attributevalues[$a->attribute_id] = "" . $a->attributevalue; + + $this->_item->productdata->attributevalues[$a->attribute_id] = "" . $a->attributevalue; if ($a->nodata == 1) { - $this->product->attributevalues[$a->attribute_id] = ''; + $this->_item->productdata->attributevalues[$a->attribute_id] = ''; } } - $this->product->save(); + $this->_item->save(); $this->listpanel->plist->Reload(); $this->editpanel->setVisible(false); $this->listpanel->setVisible(true); @@ -314,20 +215,10 @@ public function bcancelOnClick($sender) { $this->listpanel->setVisible(true); } - public function bdeleteOnClick($sender) { - - $del = Product::delete($this->product->product_id); - if (strlen($del) > 0) { - $this->setError($del); - return; - } - $this->listpanel->plist->Reload(); - $this->editpanel->setVisible(false); - $this->listpanel->setVisible(true); - } + public function imeditOnClick($sender) { - $this->product = $sender->getOwner()->getDataItem(); + $this->_item = $sender->getOwner()->getDataItem(); $this->listpanel->setVisible(false); $this->editimagepanel->setVisible(true); $this->updateImages(); @@ -354,23 +245,30 @@ public function onImageSubmit($sender) { $this->setError('toobigimage'); return; } - $r = ((double)$imagedata[0]) / $imagedata[1]; - if ($r > 1.1 || $r < 0.9) { - $this->setError('squareimage'); - return; - } - - $image = new \App\Modules\Shop\Entity\Image(); + + + $image = new \App\Entity\Image(); $image->content = file_get_contents($file['tmp_name']); $image->mime = $imagedata['mime']; - $thumb = new \App\Thumb($file['tmp_name']); + if($imagedata[0] != $imagedata[1] ) { + $thumb = new \App\Thumb($file['tmp_name']); + if($imagedata[0] > $imagedata[1] ) { + $thumb->cropFromCenter($imagedata[1], $imagedata[1]); + } + if($imagedata[0] < $imagedata[1] ) { + $thumb->cropFromCenter($imagedata[0], $imagedata[0]); + } + $image->content = $thumb->getImageAsString(); + + } + $thumb->resize(256, 256); $image->thumb = $thumb->getImageAsString(); $image->save(); - $this->product->images[] = $image->image_id; - $this->product->save(); + $this->_item->productdata->images[] = $image->image_id; + $this->_item->save(); $sender->clean(); $this->updateImages(); @@ -380,29 +278,22 @@ public function onImageSubmit($sender) { public function imglistOnRow($row) { $image = $row->getDataItem(); $row->add(new \Zippy\html\Image("imgitem"))->setUrl('/loadshopimage.php?id=' . $image->image_id . "&t=t"); - $row->add(new ClickLink("icover", $this, "icoverOnClick"))->setVisible($image->image_id != $this->product->image_id); $row->add(new ClickLink("idel", $this, "idelOnClick")); } - - public function icoverOnClick($sender) { - $image = $sender->getOwner()->getDataItem(); - $this->product->image_id = $image->image_id; - $this->product->save(); - $this->listpanel->plist->Reload(); - $this->updateImages(); - } - + public function idelOnClick($sender) { $image = $sender->getOwner()->getDataItem(); - $this->product->images = array_diff($this->product->images, array($image->image_id)); - $this->product->save(); + $this->_item->productdata->images = array_diff($this->_item->productdata->images, array($image->image_id)); + + $this->_item->save(); + \App\Entity\Image::delete($image->image_id) ; $this->updateImages(); } public function updateImages() { $this->imglist = array(); - foreach ($this->product->images as $id) { + foreach ($this->_item->getImages() as $id) { $this->imglist[] = \App\Entity\Image::load($id); } $this->editimagepanel->imagelist->Reload(); @@ -423,27 +314,25 @@ private function getWhere() { $conn = \ZDB\DB::getConnect(); - $where = "1=1 "; - if ($this->page->group instanceof ProductGroup) { - $gr = sprintf('%08s', $this->page->group->group_id); + $where = "disabled<>1 "; + + if ($this->page->group instanceof Category) { + - $where .= " and group_id in (select group_id from shop_productgroups where mpath like '%{$gr}%' ) "; + $where .= " and cat_id = " . $this->page->group->cat_id; } - + $st = $this->page->listpanel->searchform->skeyword->getText(); $sm = $this->page->listpanel->searchform->smanuf->getValue(); - if ($sm > 0) { - $where .= " and manufacturer_id = " . $sm; + + if (strlen($sm) > 1 && $sm != -1) { + $where .= " and manufacturer = " . $conn->qstr($sm); } if (strlen($st) > 0) { - $where .= " and (productname like " . $conn->qstr("%{$st}%") . " or item_code = " . $conn->qstr($st) . ") "; - } - if ($this->page->listpanel->searchform->sstatus->isChecked()) { - $where .= " and deleted = 1 "; - } else { - $where .= " and deleted = 0 "; + $where .= " and item_code = " . $conn->qstr($st) ; } - + + return $where; } @@ -454,21 +343,9 @@ public function getItemCount() { public function getItems($start, $count, $sortfield = null, $asc = null) { - $order = "productname "; - $o = $this->page->listpanel->sortform->sorting->getValue(); - if ($o == 1) { - $order = "price asc"; - } - if ($o == 2) { - $order = "price desc"; - } - if ($o == 3) { - $order = "qty asc"; - } - if ($o == 4) { - $order = "qty desc"; - } - + $order = "itemname "; + + return Product::find($this->getWhere(), $order, $count, $start); } @@ -492,25 +369,36 @@ public function __construct($id, $productattribute) { public function getContent($attributes) { $ret = " "; - + + $ret .= ""; return $ret; } //Вынимаем данные формы после сабмита public function getRequestData() { - if ($this->productattribute->attributetype == 1) { - $this->productattribute->attributevalue = isset($_POST[$this->id]) ? 1 : 0; - }; if ($this->productattribute->attributetype == 2 || $this->productattribute->attributetype == 5) { $this->productattribute->attributevalue = $_POST[$this->id]; } - if ($this->productattribute->attributetype == 3) { + if ($this->productattribute->attributetype == 1 ) { + + $this->productattribute->attributevalue = $_POST[$this->id] ; + } + if ( $this->productattribute->attributetype == 3) { $list = explode(',', $this->productattribute->valueslist); $this->productattribute->attributevalue = $list[$_POST[$this->id]]; @@ -585,11 +469,8 @@ public function getRequestData() { } $this->productattribute->attributevalue = implode(',', $values); }; - $this->productattribute->nodata = 0; - if (isset($_POST['dis' . $this->id])) { - $this->productattribute->nodata = 1; - $this->productattribute->attributevalue = ''; - } + + } public function clean() { diff --git a/www/app/modules/shop/pages/productview.php b/www/app/modules/shop/pages/productview.php index 8b6990e65..a45dffe66 100644 --- a/www/app/modules/shop/pages/productview.php +++ b/www/app/modules/shop/pages/productview.php @@ -21,41 +21,48 @@ class ProductView extends Base { public $msg, $attrlist, $clist; - protected $product_id, $gotocomment; + protected $item_id ; - public function __construct($product_id = 0) { + public function __construct($item_id = 0) { parent::__construct(); - $this->product_id = $product_id; - $product = Product::load($product_id); + $this->item_id = $item_id; + $product = Product::load($item_id); if ($product == null) { App::Redirect404(); } - $this->add(new Label("breadcrumb", Helper::getBreadScrumbs($product->group_id), true)); - - $this->_title = $product->productname; - $this->_description = $product->description; - // $this->_keywords = $product->description; - $this->add(new \Zippy\Html\Link\BookmarkableLink('product_image'))->setValue("/loadshopimage.php?id={$product->image_id}&t=t"); + + $options= \App\System::getOptions('shop') ; + $this->_tvars['usefeedback']= $options['usefeedback'] ==1; + + $this->add(new Label("breadcrumb", Helper::getBreadScrumbs($product->cat_id), true)); + $this->add(new ClickLink('backtolist', $this, 'OnBack')); + + $this->_title = $product->itemname; + // $this->_description = $product->getDescription(); + + $this->add(new \Zippy\Html\Link\BookmarkableLink('product_image'))->setValue("/loadshopimage.php?id={$product->image_id}"); $this->product_image->setAttribute('href', "/loadshopimage.php?id={$product->image_id}"); - $this->add(new Label('productname', $product->productname)); + $this->add(new Label('productname', $product->itemname)); + $this->add(new Label('productcode', $product->item_code)); $this->add(new Label('onstore')); - $this->add(new \Zippy\Html\Label('manufacturername', $product->manufacturername))->SetVisible($product->manufacturer_id > 0); - - $this->add(new Label("topsold"))->setVisible($product->topsold == 1); - $this->add(new Label("novelty"))->setVisible($product->novelty == 1); - - $this->add(new Label('price', $product->price)); - - $this->add(new Label('description', $product->description)); - $this->add(new Label('fulldescription', $product->fulldescription)); - $this->add(new Label('arrowup'))->setVisible($product->chprice == 'up'); - $this->add(new Label('arrowdown'))->setVisible($product->chprice == 'down'); - $this->add(new TextInput('rated'))->setText($product->rating); - $this->add(new Label('comments', "Отзывов({$product->comments})")); + $this->add(new Label('action'))->setVisible(false); + $this->add(new \Zippy\Html\Label('manufacturername', $product->manufacturer))->SetVisible(strlen($product->manufacturer) > 0); + + $this->add(new Label('price', $product->getPrice($options['defpricetype']) .' '. $options['currencyname'] )); + $this->add(new Label('actionprice',$product->productdata->actionprice .' '. $options['currencyname'] ))->setVisible(false); + if($product->productdata->actionprice > 0) { + $this->price->setAttribute('style','text-decoration:line-through'); + $this->actionprice->setVisible(true); + $this->action->setVisible(true) ; + } + + $this->add(new Label('description', $product->getDescription(),true)); + $this->add(new TextInput('rated'))->setText($product->getRating()); + $this->add(new Label('comments', \App\Helper::l("shopfeedbaks",$product->comments) )); - $list = Helper::getAttributeValuesByProduct($product); + $list = Helper::getAttributeValuesByProduct($product,false); $this->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')); @@ -66,18 +73,23 @@ public function __construct($product_id = 0) { $form->add(new TextInput('nick')); $form->add(new TextInput('rating')); $form->add(new TextArea('comment')); - $this->clist = ProductComment::findByProduct($product->product_id); + $form->add(new TextInput('capchacode')); + $form->add(new \ZCL\Captcha\Captcha('capcha')); + + + + $this->clist = ProductComment::findByProduct($product->item_id); $this->add(new \Zippy\Html\DataList\DataView('commentlist', new \Zippy\Html\DataList\ArrayDataSource(new PropertyBinding($this, 'clist')), $this, 'OnAddCommentRow')); - $this->commentlist->setPageSize(5); + $this->commentlist->setPageSize(10); $this->add(new \Zippy\Html\DataList\Pager("pag", $this->commentlist)); $this->commentlist->Reload(); - if ($product->deleted == 1) { + if ($product->disabled == 1 || $product->noshop==1) { $this->onstore = \App\Helper::l('cancelsell'); $this->buy->setVisible(false); } else { - $op = \App\System::getOptions("shop"); - if ($product->getQuantity($op['defstore']) > 0) { + + if ($product->getQuantity($options['defstore']) > 0) { $this->onstore->setText(\App\Helper::l('isonstore')); $this->buy->setValue(\App\Helper::l('tobay')); } else { @@ -88,7 +100,7 @@ public function __construct($product_id = 0) { $imglist = array(); - foreach ($product->images as $id) { + foreach ($product->getImages(true) as $id) { $imglist[] = \App\Entity\Image::load($id); } $this->add(new DataView('imagelist', new ArrayDataSource($imglist), $this, 'imglistOnRow'))->Reload(); @@ -98,41 +110,54 @@ public function __construct($product_id = 0) { if (!is_array($recently)) { $recently = array(); } - $recently[$product->product_id] = $product->product_id; + $recently[$product->item_id] = $product->item_id; \App\Session::getSession()->recently = $recently; + } + public function OnBack($sender){ + $product = Product::load($this->item_id); + + App::Redirect("\\App\\Modules\\Shop\\Pages\\Catalog", $product->cat_id); + + } + public function OnAddAttributeRow(\Zippy\Html\DataList\DataRow $datarow) { $item = $datarow->getDataItem(); $datarow->add(new Label("attrname", $item->attributename)); $meashure = ""; + $nodata = \App\Helper::l("shopattrnodata") ; + $yes = \App\Helper::l("shopattryes") ; + $no = \App\Helper::l("shopattrno") ; $value = $item->attributevalue; if ($item->attributetype == 2) { $meashure = $item->valueslist; } + if ($item->attributetype == 1) { - $value = $item->attributevalue == 1 ? "Есть" : "Нет"; + if($item->attributevalue == '0') $value = $no; + if($item->attributevalue == '1') $value = $yes; } $value = $value . $meashure; - if ($item->attributevalue == '') { - $value = "Н/Д"; + if ($item->hasData()==false) { + $value = $nodata; } $datarow->add(new Label("attrvalue", $value)); } //добавление в корзину public function OnBuy($sender) { - $product = Product::load($this->product_id); + $product = Product::load($this->item_id); $product->quantity = 1; \App\Modules\Shop\Basket::getBasket()->addProduct($product); $this->setSuccess("addedtocart"); - //$this->resetURL(); - App::RedirectURI('/pcat/' . $product->group_id); + $this->resetURL(); + // App::RedirectURI('/pcat/' . $product->cat_id); } //добавить к форме сравнения public function OnAddCompare($sender) { - $product = Product::load($this->product_id); + $product = Product::load($this->item_id); $comparelist = \App\Modules\Shop\CompareList::getCompareList(); if (false == $comparelist->addProduct($product)) { @@ -145,9 +170,17 @@ public function OnAddCompare($sender) { //добавать комментарий public function OnComment($sender) { + $entercode = $this->formcomment->capchacode->getText(); + $capchacode = $this->formcomment->capcha->getCode(); + if (strlen($entercode) == 0 || $entercode != $capchacode) { + $this->setError("invalidcapcha"); + + + return; + } $comment = new \App\Modules\Shop\Entity\ProductComment(); - $comment->product_id = $this->product_id; + $comment->item_id = $this->item_id; $comment->author = $this->formcomment->nick->getText(); $comment->comment = $this->formcomment->comment->getText(); $comment->rating = $this->formcomment->rating->getText(); @@ -156,22 +189,17 @@ public function OnComment($sender) { $this->formcomment->nick->setText(''); $this->formcomment->comment->setText(''); $this->formcomment->rating->setText('0'); - $this->clist = ProductComment::findByProduct($this->product_id); + $this->clist = ProductComment::findByProduct($this->item_id); $this->commentlist->Reload(); - - - $this->gotocomment = true; + $this->updateComments(); } protected function beforeRender() { parent::beforeRender(); - if ($this->gotocomment == true) { - App::addJavaScript("openComments();", true); - $this->gotocomment = false; - } - if (\App\Modules\Shop\CompareList::getCompareList()->hasProsuct($this->product_id)) { + + if (\App\Modules\Shop\CompareList::getCompareList()->hasProsuct($this->item_id)) { $this->compare->setVisible(true); $this->addtocompare->setVisible(false); } else { @@ -189,7 +217,7 @@ public function OnAddCommentRow(\Zippy\Html\DataList\DataRow $datarow) { $datarow->add(new Label("comment", $item->comment)); $datarow->add(new Label("created", \App\Helper::fdt($item->created))); $datarow->add(new TextInput("rate"))->setText($item->rating); - $datarow->add(new ClickLink('deletecomment', $this, 'OnDeleteComment'))->SetVisible(System::getUser()->userlogin == 'admin' && $item->moderated != 1); + $datarow->add(new ClickLink('deletecomment', $this, 'OnDeleteComment'))->setVisible(System::getUser()->userlogin == 'admin' && $item->moderated != 1); } //удалить коментарий @@ -197,10 +225,10 @@ public function OnDeleteComment($sender) { $comment = $sender->owner->getDataItem(); $comment->moderated = 1; $comment->rating = 0; - $comment->Save(); + $comment->save(); // App::$app->getResponse()->addJavaScript("window.location='#{$comment->comment_id}'", true); //\Application::getApplication()->Redirect('\\ZippyCMS\\Modules\\Articles\\Pages\\ArticleList'); - $this->clist = ProductComment::findByProduct($this->product_id); + $this->clist = ProductComment::findByProduct($this->item_id); $this->commentlist->Reload(); $this->updateComments(); } @@ -208,11 +236,11 @@ public function OnDeleteComment($sender) { private function updateComments() { $conn = \ZDB\DB::getConnect(); - $product = Product::load($this->product_id); + $product = Product::load($this->item_id); - $product->rating = $conn->GetOne("select sum(rating)/count(*) from `shop_prod_comments`where product_id ={$this->product_id} and moderated <> 1 and rating >0"); + $product->rating = $conn->GetOne("select sum(rating)/count(*) from `shop_prod_comments`where item_id ={$this->item_id} and moderated <> 1 and rating >0"); $product->rating = round($product->rating); - $product->comments = $conn->GetOne("select count(*) from `shop_prod_comments`where product_id ={$this->product_id} and moderated <> 1"); + $product->comments = $conn->GetOne("select count(*) from `shop_prod_comments`where item_id ={$this->item_id} and moderated <> 1"); $product->save(); $this->rated->setText($product->rating); $this->comments->setText("Отзывов({$product->comments})"); diff --git a/www/app/modules/wc/orders.php b/www/app/modules/wc/orders.php index 5e246b7e5..41f8f1f58 100644 --- a/www/app/modules/wc/orders.php +++ b/www/app/modules/wc/orders.php @@ -97,7 +97,7 @@ public function filterOnSubmit($sender) { } $tovar->quantity = $product->quantity; $tovar->price = round($product->price); - + $itlist[] = $tovar; } $neworder->packDetails('detaildata', $itlist); diff --git a/www/app/pages/base.php b/www/app/pages/base.php index 708b2891d..224ec2d34 100644 --- a/www/app/pages/base.php +++ b/www/app/pages/base.php @@ -26,19 +26,27 @@ public function __construct($params = null) { App::Redirect("\\App\\Pages\\Userlogin"); return; } - - $options = System::getOptions('common'); - - - //опции + + $options = System::getOptions('common'); + + + //опции $this->_tvars["usesnumber"] = $options['usesnumber'] == 1; $this->_tvars["usescanner"] = $options['usescanner'] == 1; $this->_tvars["useimages"] = $options['useimages'] == 1; $this->_tvars["usebranch"] = $options['usebranch'] == 1; $this->_tvars["useval"] = $options['useval'] == 1; - + $this->_tvars["usecattree"] = $options['usecattree'] == 1; + $this->_tvars["usemobileprinter"] = $options['usemobileprinter'] == 1; + if (System::getSession()->defbranch > 0) { + $this->branch_id = System::getSession()->defbranch; + System::setBranch($this->branch_id); + + } + + $blist = array(); - if($this->_tvars["usebranch"]==true) { + if ($this->_tvars["usebranch"] == true) { $this->branch_id = System::getBranch(); $blist = \App\Entity\Branch::getList(System::getUser()->user_id); if (count($blist) == 1) { @@ -65,8 +73,6 @@ public function __construct($params = null) { $this->_tvars["isadmin"] = $user->userlogin == 'admin'; $this->_tvars["isadmins"] = $user->rolename == 'admins'; - - if ($this->_tvars["usebranch"] == false) { $this->branch_id = 0; @@ -114,10 +120,10 @@ public function __construct($params = null) { $this->_tvars["hidesidebar"] = $user->hidesidebar == 1 ? 'hold-transition sidebar-collapse' : 'hold-transition sidebar-mini sidebar-collapse'; //для скрытия блока разметки в шаблоне страниц $this->_tvars["hideblock"] = false; - - - $this->generateTosats(); - + + + $this->generateTosats(); + } public function LogoutClick($sender) { @@ -136,6 +142,9 @@ public function onnbFirm($sender) { $branch_id = $sender->getValue(); System::setBranch($branch_id); + + setcookie("branch_id", $branch_id, time() + 60 * 60 * 24 * 30); + $page = get_class($this); App::Redirect($page); } @@ -219,23 +228,25 @@ public function addJavaScript($js, $docready = false) { public function goDocView() { $this->goAnkor('dankor'); } - + private function generateTosats() { - + $this->_tvars["toasts"] = array(); - if(\App\Session::getSession()->toasts == true) return;//уже показан - - $user = System::getUser() ; - if($user->defstore ==0) { - $this->_tvars["toasts"][] = array('title'=>"title:\"".Helper::l("nodefstore")."\"") ; + if (\App\Session::getSession()->toasts == true) { + return; + }//уже показан + + $user = System::getUser(); + if ($user->defstore == 0) { + $this->_tvars["toasts"][] = array('title' => "title:\"" . Helper::l("nodefstore") . "\""); } - if($user->deffirm ==0) { - $this->_tvars["toasts"][] = array('title'=>"title:\"".Helper::l("nodeffirm")."\"") ; + if ($user->deffirm == 0) { + $this->_tvars["toasts"][] = array('title' => "title:\"" . Helper::l("nodeffirm") . "\""); } - if($user->defmf ==0) { - $this->_tvars["toasts"][] = array('title'=>"title:\"".Helper::l("nodefmf")."\"") ; + if ($user->defmf == 0) { + $this->_tvars["toasts"][] = array('title' => "title:\"" . Helper::l("nodefmf") . "\""); } - - \App\Session::getSession()->toasts = true; + + \App\Session::getSession()->toasts = true; } } diff --git a/www/app/pages/branchlist.php b/www/app/pages/branchlist.php index 28e2cdcab..71e4eb356 100644 --- a/www/app/pages/branchlist.php +++ b/www/app/pages/branchlist.php @@ -26,7 +26,7 @@ class BranchList extends \App\Pages\Base public function __construct() { parent::__construct(); if (System::getUser()->userlogin != 'admin') { - System::setErrorMsg(H::l('onlyadminpage')); + System::setErrorMsg(H::l('onlyadminpage')); \App\Application::RedirectError(); return false; diff --git a/www/app/pages/doc/goodsissue.php b/www/app/pages/doc/goodsissue.php index 1bc616668..24b1d5a3e 100644 --- a/www/app/pages/doc/goodsissue.php +++ b/www/app/pages/doc/goodsissue.php @@ -70,7 +70,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new SubmitLink('addcode'))->onClick($this, 'addcodeOnClick'); - $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())) ; + $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())); $this->docform->add(new SubmitLink('addcust'))->onClick($this, 'addcustOnClick'); @@ -87,7 +87,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new TextInput('order')); $this->docform->add(new TextInput('notes')); - $this->docform->add(new CheckBox('fromprod')); + $cp = \App\Session::getSession()->clipboard; $this->docform->add(new ClickLink('paste', $this, 'onPaste'))->setVisible(is_array($cp) && count($cp) > 0); @@ -135,7 +135,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->total->setText($this->_doc->amount); $this->docform->document_date->setDate($this->_doc->document_date); - $this->docform->fromprod->setChecked($this->_doc->headerdata['fromprod']); + $this->docform->payment->setValue($this->_doc->headerdata['payment']); $this->docform->payamount->setText($this->_doc->payamount); @@ -185,7 +185,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->customer->setText($basedoc->customer_name); $this->docform->pricetype->setValue($basedoc->headerdata['pricetype']); - // $this->docform->store->setValue($basedoc->headerdata['store']); + // $this->docform->store->setValue($basedoc->headerdata['store']); $this->_orderid = $basedocid; $this->docform->order->setText($basedoc->document_number); $this->docform->paydisc->setText($basedoc->headerdata['paydisc']); @@ -309,7 +309,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->_tvars['manlist'][] = array('mitem' => $man); } - $this->checkProd(); + } public function detailOnRow($row) { @@ -350,8 +350,8 @@ public function deleteOnClick($sender) { $this->docform->detail->Reload(); $this->calcTotal(); $this->calcPay(); - $this->checkProd(); - } + + } public function addrowOnClick($sender) { $this->editdetail->setVisible(true); @@ -548,7 +548,7 @@ public function saverowOnClick($sender) { $this->editdetail->editserial->setText(""); $this->calcTotal(); $this->calcPay(); - $this->checkProd(); + } public function cancelrowOnClick($sender) { @@ -616,7 +616,7 @@ public function savedocOnClick($sender) { $this->_doc->headerdata['store_name'] = $this->docform->store->getValueName(); $this->_doc->headerdata['pricetype'] = $this->docform->pricetype->getValue(); $this->_doc->headerdata['pricetypename'] = $this->docform->pricetype->getValueName(); - $this->_doc->headerdata['fromprod'] = $this->docform->fromprod->isChecked() ?1:0; + $this->_doc->headerdata['order_id'] = $this->_orderid; $this->_doc->packDetails('detaildata', $this->_itemlist); @@ -847,7 +847,6 @@ public function backtolistOnClick($sender) { App::RedirectBack(); } - public function OnChangeItem($sender) { $id = $sender->getKey(); @@ -1013,19 +1012,6 @@ public function onPaste($sender) { $this->calcPay(); } - public function checkProd(){ - $this->docform->fromprod->setVisible(false); - foreach ($this->_itemlist as $item) { - if($item->item_type == Item::TYPE_PROD) { - $this->docform->fromprod->setVisible(true); - - return; - } - - } - - - } } diff --git a/www/app/pages/doc/goodsreceipt.php b/www/app/pages/doc/goodsreceipt.php index f4a47655c..0e9996554 100644 --- a/www/app/pages/doc/goodsreceipt.php +++ b/www/app/pages/doc/goodsreceipt.php @@ -112,7 +112,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editnewitem->add(new TextInput('editnewitemsnumber')); $this->editnewitem->add(new Date('editnewitemsdate')); $this->editnewitem->add(new TextInput('editnewmanufacturer')); - $this->editnewitem->add(new DropDownChoice('editnewcat', \App\Entity\Category::findArray("cat_name", "", "cat_name"), 0)); + $this->editnewitem->add(new DropDownChoice('editnewcat', \App\Entity\Category::getList(), 0)); $this->editnewitem->add(new Button('cancelnewitem'))->onClick($this, 'cancelnewitemOnClick'); $this->editnewitem->add(new SubmitButton('savenewitem'))->onClick($this, 'savenewitemOnClick'); diff --git a/www/app/pages/doc/inventory.php b/www/app/pages/doc/inventory.php index 1273dae38..dd5aabc6f 100644 --- a/www/app/pages/doc/inventory.php +++ b/www/app/pages/doc/inventory.php @@ -39,7 +39,7 @@ public function __construct($docid = 0) { $this->docform->add(new Date('document_date', time())); $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore()))->onChange($this, 'OnChangeStore'); - $this->docform->add(new DropDownChoice('category', Category::findArray("cat_name", "", "cat_name"), 0))->onChange($this, 'OnChangeCat'); + $this->docform->add(new DropDownChoice('category', Category::getList(), 0))->onChange($this, 'OnChangeCat'); $this->docform->add(new TextInput('notes')); $this->docform->add(new CheckBox('autoincome')); $this->docform->add(new CheckBox('autooutcome')); diff --git a/www/app/pages/doc/invoicecust.php b/www/app/pages/doc/invoicecust.php index 52553b3ce..3c41d6946 100644 --- a/www/app/pages/doc/invoicecust.php +++ b/www/app/pages/doc/invoicecust.php @@ -92,7 +92,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editnewitem->add(new TextInput('editnewitemname')); $this->editnewitem->add(new TextInput('editnewitemcode')); $this->editnewitem->add(new Button('cancelnewitem'))->onClick($this, 'cancelnewitemOnClick'); - $this->editnewitem->add(new DropDownChoice('editnewcat', \App\Entity\Category::findArray("cat_name", "", "cat_name"), 0)); + $this->editnewitem->add(new DropDownChoice('editnewcat', \App\Entity\Category::getList(), 0)); $this->editnewitem->add(new SubmitButton('savenewitem'))->onClick($this, 'savenewitemOnClick'); if ($docid > 0) { //загружаем содержимое документа настраницу diff --git a/www/app/pages/doc/movemoney.php b/www/app/pages/doc/movemoney.php index 33024a688..491429e3c 100644 --- a/www/app/pages/doc/movemoney.php +++ b/www/app/pages/doc/movemoney.php @@ -33,7 +33,7 @@ public function __construct($docid = 0) { $this->docform->add(new TextInput('document_number')); $this->docform->add(new Date('document_date', time())); - + $this->docform->add(new DropDownChoice('paymentfrom', MoneyFund::getList(), H::getDefMF())); $this->docform->add(new DropDownChoice('paymentto', MoneyFund::getList(), H::getDefMF())); $this->docform->add(new TextInput('notes')); @@ -47,7 +47,7 @@ public function __construct($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->paymentfrom->setValue($this->_doc->headerdata['paymentfrom']); $this->docform->paymentto->setValue($this->_doc->headerdata['paymentto']); $this->docform->notes->setText($this->_doc->notes); @@ -61,7 +61,7 @@ public function __construct($docid = 0) { if (false == \App\ACL::checkShowDoc($this->_doc)) { return; } - + } public function savedocOnClick($sender) { @@ -74,7 +74,7 @@ public function savedocOnClick($sender) { $this->_doc->headerdata['paymenttoname'] = $this->docform->paymentto->getValueName(); $this->_doc->headerdata['paymentfrom'] = $this->docform->paymentfrom->getValue(); $this->_doc->headerdata['paymentfromname'] = $this->docform->paymentfrom->getValueName(); - + $this->_doc->amount = H::fa($this->docform->amount->getText()); $this->_doc->document_number = trim($this->docform->document_number->getText()); $this->_doc->document_date = strtotime($this->docform->document_date->getText()); @@ -137,12 +137,12 @@ private function checkForm() { if (($this->_doc->amount > 0) == false) { $this->setError("noentersum"); } - - if($this->_doc->headerdata['paymentto'] == 0 || $this->_doc->headerdata['paymentfrom']==0) { - $this->setError("noselpayment"); + + if ($this->_doc->headerdata['paymentto'] == 0 || $this->_doc->headerdata['paymentfrom'] == 0) { + $this->setError("noselpayment"); } - if($this->_doc->headerdata['paymentto'] == $this->_doc->headerdata['paymentfrom']) { - $this->setError("paymentseq"); + if ($this->_doc->headerdata['paymentto'] == $this->_doc->headerdata['paymentfrom']) { + $this->setError("paymentseq"); } return !$this->isError(); @@ -152,8 +152,5 @@ public function backtolistOnClick($sender) { App::RedirectBack(); } - - - } diff --git a/www/app/pages/doc/order.php b/www/app/pages/doc/order.php index d1bfb4471..2aa2f413d 100644 --- a/www/app/pages/doc/order.php +++ b/www/app/pages/doc/order.php @@ -181,8 +181,8 @@ public function deleteOnClick($sender) { } $this->_tovarlist = array_diff_key($this->_tovarlist, array($item->rowid => $this->_tovarlist[$item->rowid])); - - $this->docform->detail->Reload(); + + $this->docform->detail->Reload(); $this->calcTotal(); $this->calcPay(); } @@ -247,8 +247,8 @@ public function saverowOnClick($sender) { $this->_tovarlist[$item->rowid] = $item; $this->_rowid = 0; - - + + $this->editdetail->setVisible(false); $this->docform->setVisible(true); $this->docform->detail->Reload(); diff --git a/www/app/pages/doc/ordercust.php b/www/app/pages/doc/ordercust.php index 9c225b999..0db41136d 100644 --- a/www/app/pages/doc/ordercust.php +++ b/www/app/pages/doc/ordercust.php @@ -60,7 +60,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editdetail->add(new TextInput('editquantity'))->setText("1"); $this->editdetail->add(new TextInput('editcustcode')); $this->editdetail->add(new TextInput('editprice')); - $this->editdetail->add(new TextInput('editdesc')); + $this->editdetail->add(new TextInput('editdesc')); $this->editdetail->add(new Button('cancelrow'))->onClick($this, 'cancelrowOnClick'); $this->editdetail->add(new SubmitButton('saverow'))->onClick($this, 'saverowOnClick'); @@ -70,7 +70,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->editnewitem->add(new TextInput('editnewitemname')); $this->editnewitem->add(new TextInput('editnewitemcode')); $this->editnewitem->add(new Button('cancelnewitem'))->onClick($this, 'cancelnewitemOnClick'); - $this->editnewitem->add(new DropDownChoice('editnewcat', \App\Entity\Category::findArray("cat_name", "", "cat_name"), 0)); + $this->editnewitem->add(new DropDownChoice('editnewcat', \App\Entity\Category::getList(), 0)); $this->editnewitem->add(new SubmitButton('savenewitem'))->onClick($this, 'savenewitemOnClick'); @@ -95,17 +95,17 @@ public function __construct($docid = 0, $basedocid = 0) { if ($basedoc instanceof Document) { $this->_basedocid = $basedocid; if ($basedoc->meta_name == 'Order') { - + $order = $basedoc->cast(); - + $this->docform->total->setText($order->amount); - + $this->_itemlist = $basedoc->unpackDetails('detaildata'); $this->calcTotal(); - + } - } + } } } $this->calcTotal(); @@ -172,7 +172,7 @@ public function deleteOnClick($sender) { } $this->_itemlist = array_diff_key($this->_itemlist, array($item->rowid => $this->_itemlist[$item->rowid])); - $this->docform->detail->Reload(); + $this->docform->detail->Reload(); } public function addrowOnClick($sender) { @@ -206,7 +206,7 @@ public function saverowOnClick($sender) { $item->desc = $this->editdetail->editdesc->getText(); - if ($this->_rowid > 0) { + if ($this->_rowid > 0) { $item->rowid = $this->_rowid; } else { $next = count($this->_itemlist) > 0 ? max(array_keys($this->_itemlist)) : 0; diff --git a/www/app/pages/doc/outcomemoney.php b/www/app/pages/doc/outcomemoney.php index 4bfb888f4..6c2d7b4e0 100644 --- a/www/app/pages/doc/outcomemoney.php +++ b/www/app/pages/doc/outcomemoney.php @@ -34,7 +34,7 @@ public function __construct($docid = 0) { $this->docform->add(new Date('document_date', time())); $this->docform->add(new DropDownChoice('detail', array(), 1))->onChange($this, 'OnDetail'); - $this->docform->add(new DropDownChoice('mtype', Pay::getPayTypeList(2), 0)); + $this->docform->add(new DropDownChoice('mtype', Pay::getPayTypeList(2), Pay::PAY_BASE_OUTCOME)); $this->docform->add(new DropDownChoice('contract', array(), 0)); $this->docform->add(new DropDownChoice('emp', Employee::findArray('emp_name', 'disabled<>1', 'emp_name'), 0)); diff --git a/www/app/pages/doc/poscheck.php b/www/app/pages/doc/poscheck.php index 9d8530d49..264ec1a6d 100644 --- a/www/app/pages/doc/poscheck.php +++ b/www/app/pages/doc/poscheck.php @@ -126,21 +126,21 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->document_number->setText($this->_doc->document_number); $this->docform->pricetype->setValue($this->_doc->headerdata['pricetype']); - $this->docform->total->setText($this->_doc->amount); + $this->docform->total->setText(H::fa($this->_doc->amount)); $this->docform->document_date->setDate($this->_doc->document_date); - $this->docform->payment->setValue($this->_doc->headerdata['payment']); + $this->docform->payment->setValue(H::fa($this->_doc->headerdata['payment'])); $this->docform->exchange->setText($this->_doc->exchange); - $this->docform->payamount->setText($this->_doc->payamount); - $this->docform->editpayamount->setText($this->_doc->payamount); - $this->docform->paydisc->setText($this->_doc->headerdata['paydisc']); + $this->docform->payamount->setText(H::fa($this->_doc->payamount)); + $this->docform->editpayamount->setText(H::fa($this->_doc->payamount)); + $this->docform->paydisc->setText(H::fa($this->_doc->headerdata['paydisc'])); $this->docform->editpaydisc->setText($this->_doc->headerdata['paydisc']); - $this->docform->payed->setText($this->_doc->payed); - $this->docform->editpayed->setText($this->_doc->payed); - $this->docform->exchange->setText($this->_doc->headerdata['exchange']); + $this->docform->payed->setText(H::fa($this->_doc->payed)); + $this->docform->editpayed->setText(H::fa($this->_doc->payed)); + $this->docform->exchange->setText(H::fa($this->_doc->headerdata['exchange'])); $this->OnPayment($this->docform->payment); @@ -259,7 +259,7 @@ public function detailOnRow($row) { $row->add(new Label('amount', H::fa($item->quantity * $item->price))); $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); - // $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); + $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); } public function serOnRow($row) { @@ -272,7 +272,7 @@ public function serOnRow($row) { $row->add(new Label('seramount', H::fa($item->quantity * $item->price))); $row->add(new ClickLink('serdelete'))->onClick($this, 'serdeleteOnClick'); - // $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); + $row->add(new ClickLink('seredit'))->onClick($this, 'sereditOnClick'); } public function deleteOnClick($sender) { @@ -281,9 +281,9 @@ public function deleteOnClick($sender) { } $tovar = $sender->owner->getDataItem(); - // unset($this->_itemlist[$tovar->tovar_id]); - $this->_itemlist = array_diff_key($this->_itemlist, array($tovar->item_id => $this->_itemlist[$tovar->item_id])); + + $this->_itemlist = array_diff_key($this->_itemlist, array($tovar->rowid => $this->_itemlist[$tovar->rowid])); $this->docform->detail->Reload(); $this->calcTotal(); $this->calcPay(); @@ -295,9 +295,8 @@ public function serdeleteOnClick($sender) { } $ser = $sender->owner->getDataItem(); - // unset($this->_itemlist[$tovar->tovar_id]); - $this->_serlist = array_diff_key($this->_serlist, array($ser->service_id => $this->_serlist[$ser->service_id])); + $this->_serlist = array_diff_key($this->_serlist, array($ser->rowid => $this->_serlist[$ser->rowid])); $this->docform->detailser->Reload(); $this->calcTotal(); $this->calcPay(); @@ -318,6 +317,7 @@ public function addserOnClick($sender) { $this->editserdetail->editserprice->setText("0"); $this->docform->setVisible(false); + $this->_rowid = 0; } public function editOnClick($sender) { @@ -334,8 +334,35 @@ public function editOnClick($sender) { $this->editdetail->editprice->setText($item->price); $this->editdetail->editquantity->setText($item->quantity); $this->editdetail->editserial->setText($item->serial); + if ($item->rowid > 0) { + ; + } //для совместимости + else { + $item->rowid = $item->item_id; + } - $this->_rowid = $item->item_id; + $this->_rowid = $item->rowid; + } + + public function sereditOnClick($sender) { + $ser = $sender->getOwner()->getDataItem(); + $this->editserdetail->setVisible(true); + $this->docform->setVisible(false); + + $this->editserdetail->editser->setKey($ser->service_id); + $this->editserdetail->editser->setText($ser->service_name); + + $this->editserdetail->editserprice->setText($ser->price); + $this->editserdetail->editserquantity->setText($ser->quantity); + + if ($ser->rowid > 0) { + ; + } //для совместимости + else { + $ser->rowid = $ser->service_id; + } + + $this->_rowid = $ser->rowid; } public function saverowOnClick($sender) { @@ -371,8 +398,16 @@ public function saverowOnClick($sender) { } } - unset($this->_itemlist[$this->_rowid]); - $this->_itemlist[$item->item_id] = $item; + if ($this->_rowid > 0) { + $item->rowid = $this->_rowid; + } else { + $next = count($this->_itemlist) > 0 ? max(array_keys($this->_itemlist)) : 0; + $item->rowid = $next + 1; + } + $this->_itemlist[$item->rowid] = $item; + + $this->_rowid = 0; + $this->editdetail->setVisible(false); $this->docform->setVisible(true); $this->docform->detail->Reload(); @@ -403,7 +438,16 @@ public function saveserOnClick($sender) { $ser->price = $this->editserdetail->editserprice->getText(); - $this->_serlist[$ser->service_id] = $ser; + if ($this->_rowid > 0) { + $ser->rowid = $this->_rowid; + } else { + $next = count($this->_serlist) > 0 ? max(array_keys($this->_serlist)) : 0; + $ser->rowid = $next + 1; + } + $this->_serlist[$ser->rowid] = $ser; + + $this->_rowid = 0; + $this->editserdetail->setVisible(false); $this->docform->setVisible(true); $this->docform->detailser->Reload(); @@ -483,7 +527,7 @@ public function savedocOnClick($sender) { $pos = \App\Entity\Pos::load($this->_doc->headerdata['pos']); - if ($pos->usefisc == 1 && $sender->id == 'execdoc') { + if ($this->_tvars["ppo"] == true && $pos->usefisc == 1 && $sender->id == 'execdoc') { $ret = \App\Modules\PPO\PPOHelper::check($this->_doc); diff --git a/www/app/pages/doc/prodreceipt.php b/www/app/pages/doc/prodreceipt.php index e6c1d3a32..c73f9d392 100644 --- a/www/app/pages/doc/prodreceipt.php +++ b/www/app/pages/doc/prodreceipt.php @@ -41,7 +41,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new Date('document_date'))->setDate(time()); $this->docform->add(new DropDownChoice('parea', \App\Entity\Prodarea::findArray("pa_name", ""), 0)); $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())); - $this->docform->add(new DropDownChoice('storefrom', Store::getList(), H::getDefStore())); + $this->docform->add(new TextInput('notes')); @@ -73,7 +73,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->parea->setValue($this->_doc->headerdata['parea']); $this->docform->store->setValue($this->_doc->headerdata['store']); - $this->docform->storefrom->setValue($this->_doc->headerdata['storefrom']); + $this->_itemlist = $this->_doc->unpackDetails('detaildata'); @@ -86,7 +86,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->_basedocid = $basedocid; if ($basedoc->meta_name == 'ProdReceipt') { $this->docform->store->setValue($basedoc->headerdata['store']); - $this->docform->storefrom->setValue($basedoc->headerdata['storefrom']); + $this->docform->parea->setValue($basedoc->headerdata['parea']); $this->_itemlist = $basedoc->unpackDetails('detaildata'); @@ -105,13 +105,13 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->notes->setText('Наряд ' . $basedoc->document_number); $this->docform->parea->setValue($basedoc->headerdata['parea']); - - foreach($basedoc->unpackDetails('prodlist') as $item){ - $item->price = $item->getProdprice(); - $this->_itemlist[$item->item_id]= $item; + + foreach ($basedoc->unpackDetails('prodlist') as $item) { + $item->price = $item->getProdprice(); + $this->_itemlist[$item->item_id] = $item; } - - + + } } @@ -267,7 +267,6 @@ public function savedocOnClick($sender) { $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['storefrom'] = $this->docform->storefrom->getValue(); $this->_doc->packDetails('detaildata', $this->_itemlist); @@ -368,7 +367,7 @@ public function OnChangeItem($sender) { $id = $sender->getValue(); $item = \App\Entity\Item::load($id); - + $price = $item->getProdprice(); $this->editdetail->editprice->setText($price > 0 ? H::fa($price) : ''); diff --git a/www/app/pages/doc/serviceact.php b/www/app/pages/doc/serviceact.php index a46bff19e..fa693f2e0 100644 --- a/www/app/pages/doc/serviceact.php +++ b/www/app/pages/doc/serviceact.php @@ -174,17 +174,17 @@ public function editOnClick($sender) { $this->editdetail->editservice->setValue($service->service_id); - + if ($service->rowid > 0) { ; } //для совместимости else { - $service->_rowid = $service->service_id; + $service->_rowid = $service->service_id; } $this->_rowid = $service->rowid; - - + + } public function deleteOnClick($sender) { @@ -194,7 +194,7 @@ public function deleteOnClick($sender) { $item = $sender->owner->getDataItem(); - + if ($item->rowid > 0) { ; } //для совместимости @@ -203,8 +203,8 @@ public function deleteOnClick($sender) { } $this->_servicelist = array_diff_key($this->_servicelist, array($item->rowid => $this->_servicelist[$item->rowid])); - - + + $this->docform->detail->Reload(); $this->calcTotal(); $this->calcPay(); @@ -233,9 +233,7 @@ public function saverowOnClick($sender) { $service->desc = $this->editdetail->editdesc->getText(); - - - if ($this->_rowid > 0) { + if ($this->_rowid > 0) { $service->rowid = $this->_rowid; } else { $next = count($this->_servicelist) > 0 ? max(array_keys($this->_servicelist)) : 0; @@ -244,9 +242,8 @@ public function saverowOnClick($sender) { $this->_servicelist[$service->rowid] = $service; $this->_rowid = 0; - - - + + $this->editdetail->setVisible(false); $this->docform->setVisible(true); $this->docform->detail->Reload(); diff --git a/www/app/pages/doc/task.php b/www/app/pages/doc/task.php index 0fa752142..723746023 100644 --- a/www/app/pages/doc/task.php +++ b/www/app/pages/doc/task.php @@ -29,13 +29,13 @@ class Task extends \App\Pages\Base { private $_doc; - public $_prodlist = array(); + public $_prodlist = array(); public $_servicelist = array(); public $_eqlist = array(); public $_emplist = array(); private $_basedocid = 0; - private $_rowidser = 0; - private $_rowidprod = 0; + private $_rowidser = 0; + private $_rowidprod = 0; public function __construct($docid = 0, $basedocid = 0, $date = null) { parent::__construct(); @@ -176,7 +176,7 @@ public function addserviceOnClick($sender) { $this->editdetail->editservice->setValue(0); - $this->_rowidser =0; + $this->_rowidser = 0; $this->editdetail->editqty->setText('1'); $this->editdetail->editdesc->setText(''); @@ -186,7 +186,7 @@ public function editOnClick($sender) { $service = $sender->getOwner()->getDataItem(); $this->editdetail->setVisible(true); $this->docform->setVisible(false); - if ($service->_rowidser > 0) { + if ($service->_rowidser > 0) { ; } //для совместимости else { @@ -194,7 +194,7 @@ public function editOnClick($sender) { } $this->_rowidser = $service->_rowidser; - + $this->editdetail->editqty->setText($service->quantity); $this->editdetail->editdesc->setText($service->desc); @@ -207,7 +207,7 @@ public function deleteOnClick($sender) { return; } $service = $sender->owner->getDataItem(); - if ($service->_rowidser > 0) { + if ($service->_rowidser > 0) { ; } //для совместимости else { @@ -216,7 +216,7 @@ public function deleteOnClick($sender) { $this->_servicelist = array_diff_key($this->_servicelist, array($service->_rowidser => $this->_servicelist[$service->_rowidser])); - } + } public function saverowOnClick($sender) { $id = $this->editdetail->editservice->getValue(); @@ -233,8 +233,8 @@ public function saverowOnClick($sender) { if (strlen($service->price) == 0) { $service->price = 0; } - - + + if ($this->_rowidser > 0) { $service->_rowidser = $this->_rowidser; } else { @@ -244,9 +244,8 @@ public function saverowOnClick($sender) { $this->_servicelist[$service->_rowidser] = $service; $this->_rowidser = 0; - - - + + $this->editdetail->setVisible(false); $this->docform->setVisible(true); @@ -266,14 +265,15 @@ public function addprodOnClick($sender) { $this->editdetailprod->editprod->setValue(0); - $this->_rowidprod =0; + $this->_rowidprod = 0; $this->editdetailprod->editqtyprod->setText('1'); $this->editdetailprod->editdescprod->setText(''); } - public function detailprodOnRow($row) { - $item= $row->getDataItem(); + + public function detailprodOnRow($row) { + $item = $row->getDataItem(); $row->add(new Label('prod', $item->itemname)); @@ -285,8 +285,8 @@ public function detailprodOnRow($row) { $row->add(new ClickLink('editprod'))->onClick($this, 'editprodOnClick'); $row->add(new ClickLink('deleteprod'))->onClick($this, 'deleteprodOnClick'); } - - public function cancelprodrowOnClick($sender) { + + public function cancelprodrowOnClick($sender) { $this->editdetail->setVisible(false); $this->editdetailprod->setVisible(false); @@ -295,12 +295,13 @@ public function cancelprodrowOnClick($sender) { $this->docform->setVisible(true); } - public function editprodOnClick($sender) { + + public function editprodOnClick($sender) { $item = $sender->getOwner()->getDataItem(); $this->editdetailprod->setVisible(true); $this->docform->setVisible(false); - if ($item->_rowidprod > 0) { + if ($item->_rowidprod > 0) { ; } //для совместимости else { @@ -320,7 +321,7 @@ public function deleteprodOnClick($sender) { return; } $item = $sender->owner->getDataItem(); - if ($item->_rowidprod > 0) { + if ($item->_rowidprod > 0) { ; } //для совместимости else { @@ -329,7 +330,7 @@ public function deleteprodOnClick($sender) { $this->_prodlist = array_diff_key($this->_prodlist, array($item->_rowidprod => $this->_prodlist[$item->_rowidprod])); - $this->docform->detailprod->Reload(); + $this->docform->detailprod->Reload(); } public function saverowprodOnClick($sender) { @@ -343,8 +344,8 @@ public function saverowprodOnClick($sender) { $item->quantity = $this->editdetailprod->editqtyprod->getText(); $item->desc = $this->editdetailprod->editdescprod->getText(); - - + + if ($this->_rowidprod > 0) { $item->_rowidprod = $this->_rowidprod; } else { @@ -354,7 +355,7 @@ public function saverowprodOnClick($sender) { $this->_prodlist[$item->_rowidprod] = $item; $this->_rowidprod = 0; - + $this->editdetailprod->setVisible(false); $this->docform->setVisible(true); @@ -366,8 +367,8 @@ public function saverowprodOnClick($sender) { $this->editdetailprod->editqtyprod->setText("1"); } - - + + //employee public function addempOnClick($sender) { $this->editdetail3->setVisible(true); diff --git a/www/app/pages/doc/ttn.php b/www/app/pages/doc/ttn.php index 6f2996ecd..7139548e6 100644 --- a/www/app/pages/doc/ttn.php +++ b/www/app/pages/doc/ttn.php @@ -59,7 +59,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->docform->add(new SubmitLink('addcode'))->onClick($this, 'addcodeOnClick'); - $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())) ; + $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())); $this->docform->add(new SubmitLink('addcust'))->onClick($this, 'addcustOnClick'); @@ -220,7 +220,7 @@ public function __construct($docid = 0, $basedocid = 0) { } $this->_itemlist = array(); - foreach ($itemlist as $i=>$it) { + foreach ($itemlist as $i => $it) { $it->price = $it->price * $k; $this->_itemlist[$i] = $it; } @@ -636,7 +636,7 @@ public function savedocOnClick($sender) { $this->_doc->updateStatus(Document::STATE_NEW); } - + // проверка на минус в количестве $allowminus = System::getOption("common", "allowminus"); if ($allowminus != 1) { @@ -649,7 +649,7 @@ public function savedocOnClick($sender) { } } } - + $this->_doc->updateStatus(Document::STATE_EXECUTED); $this->_doc->updateStatus(Document::STATE_READYTOSHIP); @@ -672,16 +672,18 @@ public function savedocOnClick($sender) { $this->_doc->updateStatus(Document::STATE_NEW); } - $this->_doc->updateStatus(Document::STATE_EXECUTED); - if ($sender->id == 'senddoc')$this->_doc->updateStatus(Document::STATE_INSHIPMENT); - if ($sender->id == 'sendnp') { - $this->_doc->updateStatus(Document::STATE_READYTOSHIP); - - } + $this->_doc->updateStatus(Document::STATE_EXECUTED); + if ($sender->id == 'senddoc') { + $this->_doc->updateStatus(Document::STATE_INSHIPMENT); + } + if ($sender->id == 'sendnp') { + $this->_doc->updateStatus(Document::STATE_READYTOSHIP); + + } // $this->_doc->headerdata['sent_date'] = time(); - // $this->_doc->save(); - - + // $this->_doc->save(); + + } else { $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW); } @@ -689,11 +691,11 @@ public function savedocOnClick($sender) { $conn->CommitTrans(); - if ($sender->id == 'sendnp') { - - App::Redirect('\App\Pages\Register\GIList',$this->_doc->document_id) ; - return; - } + if ($sender->id == 'sendnp') { + + App::Redirect('\App\Pages\Register\GIList', $this->_doc->document_id); + return; + } App::Redirect("\\App\\Pages\\Register\\GIList"); } catch(\Throwable $ee) { @@ -776,7 +778,6 @@ public function backtolistOnClick($sender) { App::RedirectBack(); } - public function OnChangeItem($sender) { $id = $sender->getKey(); @@ -885,7 +886,7 @@ public function cancelcustOnClick($sender) { } public function OnDelivery($sender) { - + if ($sender->getValue() != Document::DEL_SELF) { $this->docform->senddoc->setVisible(true); @@ -900,7 +901,7 @@ public function OnDelivery($sender) { } else { $this->docform->senddoc->setVisible(false); - + $this->docform->ship_address->setVisible(false); $this->docform->ship_number->setVisible(false); $this->docform->ship_amount->setVisible(false); diff --git a/www/app/pages/doc/warranty.php b/www/app/pages/doc/warranty.php index 4f28f3d28..23ef143b5 100644 --- a/www/app/pages/doc/warranty.php +++ b/www/app/pages/doc/warranty.php @@ -135,9 +135,9 @@ public function editOnClick($sender) { $item = $sender->owner->getDataItem(); $this->editdetail->edittovar->setKey($item->item_id); $this->editdetail->edittovar->setText($item->itemname); - + $this->editdetail->editprice->setText($item->price); - + $this->editdetail->editquantity->setText($item->quantity); $this->editdetail->editwarranty->setText($item->warranty); $this->editdetail->editsn->setText($item->sn); @@ -167,7 +167,7 @@ public function saverowOnClick($sender) { $item->price = $this->editdetail->editprice->getText(); $item->sn = $this->editdetail->editsn->getText(); $item->warranty = $this->editdetail->editwarranty->getText(); - + $this->_tovarlist[$item->item_id] = $item; $this->editdetail->setVisible(false); $this->docform->setVisible(true); @@ -210,7 +210,7 @@ public function savedocOnClick($sender) { $firm = H::getFirmData($this->_doc->firm_id, $this->branch_id); $this->_doc->headerdata["firm_name"] = $firm['firm_name']; - + $this->_doc->packDetails('detaildata', $this->_tovarlist); $this->_doc->document_number = $this->docform->document_number->getText(); @@ -230,7 +230,7 @@ public function savedocOnClick($sender) { } else { $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW); } - + $conn->CommitTrans(); App::RedirectBack(); } catch(\Throwable $ee) { diff --git a/www/app/pages/error.php b/www/app/pages/error.php index 4e9b4bf37..67cb8eafb 100644 --- a/www/app/pages/error.php +++ b/www/app/pages/error.php @@ -5,7 +5,7 @@ class Error extends \App\Pages\Base { public function __construct($error = '') { - parent::__construct() ; + parent::__construct(); $this->add(new \Zippy\Html\Panel('errpan'))->setVisible(strlen($error) > 0); $this->errpan->add(new \Zippy\Html\Label('errmsg', $error)); diff --git a/www/app/pages/main.php b/www/app/pages/main.php index eeab3c570..14d0bfe05 100644 --- a/www/app/pages/main.php +++ b/www/app/pages/main.php @@ -24,7 +24,7 @@ public function __construct() { parent::__construct(); $user = System::getUser(); - + $this->_tvars['wminqty'] = strpos(System::getUser()->widgets, 'wminqty') !== false; $this->_tvars['wsdate'] = strpos(System::getUser()->widgets, 'wsdate') !== false; $this->_tvars['wrdoc'] = strpos(System::getUser()->widgets, 'wrdoc') !== false; @@ -32,7 +32,7 @@ public function __construct() { $this->_tvars['wgraph'] = strpos(System::getUser()->widgets, 'wgraph') !== false; if ($user->rolename == 'admins') { $this->_tvars['wminqty'] = true; - + $this->_tvars['wsdate'] = true; $this->_tvars['wrdoc'] = true; $this->_tvars['winfo'] = true; @@ -41,7 +41,8 @@ public function __construct() { if ($this->_tvars["usesnumber"] == false) { $this->_tvars['wsdate'] = false; } - + $br = ''; + $cstr = ''; $brids = \App\ACL::getBranchIDsConstraint(); if (strlen($brids) > 0) { $br = " and d.branch_id in ({$brids}) "; @@ -64,10 +65,10 @@ public function __construct() { } if (count($data) == 0) { - $this->_tvars['wsdate'] = false; + $this->_tvars['wsdate'] = false; } - $this->add(new ClickLink('sdcsv',$this,'onSDcsv')) ; + $this->add(new ClickLink('sdcsv', $this, 'onSDcsv')); $sdlist = $this->add(new DataView('sdlist', new ArrayDataSource($data), $this, 'sdlistOnRow')); $sdlist->setPageSize(10); $this->add(new Paginator("sdpag", $sdlist)); @@ -88,9 +89,9 @@ public function __construct() { $data[] = new DataItem($row); } if (count($data) == 0) { - $this->_tvars['wminqty'] = false; + $this->_tvars['wminqty'] = false; } - $this->add(new ClickLink('mqcsv',$this,'onMQcsv')) ; + $this->add(new ClickLink('mqcsv', $this, 'onMQcsv')); $mqlist = $this->add(new DataView('mqlist', new ArrayDataSource($data), $this, 'mqlistOnRow')); $mqlist->setPageSize(10); $this->add(new Paginator("mqpag", $mqlist)); @@ -99,7 +100,7 @@ public function __construct() { } - //недавние документы + //недавние документы if ($this->_tvars['wrdoc'] == true) { $data = array(); @@ -112,9 +113,9 @@ public function __construct() { $data[] = new \App\DataItem($row); } if (count($data) == 0) { - $this->_tvars['wrdoc'] = false; + $this->_tvars['wrdoc'] = false; } - $this->add(new ClickLink('rdcsv',$this,'onRDcsv')) ; + $this->add(new ClickLink('rdcsv', $this, 'onRDcsv')); $doclist = $this->add(new DataView('rdoclist', new ArrayDataSource($data), $this, 'rdoclistOnRow')); $doclist->setPageSize(10); @@ -254,12 +255,30 @@ public function __construct() { $this->_tvars['biorders'] = $conn->GetOne($sql); - + $sql = " select coalesce(sum(partion*qty),0) as cnt from store_stock_view where qty >0 {$cstr} "; $this->_tvars['biitemscnt'] = H::fa($conn->GetOne($sql)); + $sql = "select coalesce( sum(case when meta_name='OutcomeMoney' then (payed - payamount ) else (payamount - payed) end) ,0) as sam + from `documents_view` d + where (payamount >0 or payed >0) {$br} and + ( meta_name in('GoodsIssue','Invoice' ,'PosCheck','ServiceAct','Order') or (meta_name='IncomeMoney' and content like '%1%' ) or (meta_name='OutcomeMoney' and content like '%2%' )) + and state not in (1,2,3,17,8) and customer_id >0 and ( (meta_name <>'POSCheck' and payamount <> payed) or(meta_name = 'POSCheck' and payamount > payed )) + "; + + $this->_tvars['bidebet'] = H::fa($conn->GetOne($sql)); + + $sql = " select coalesce( sum(case when meta_name='IncomeMoney' then (payed - payamount ) else (payamount - payed) end),0) as sam + from `documents_view` d + where customer_id > 0 {$br} + and ( meta_name in('GoodsReceipt','InvoiceCust' ) or (meta_name='OutcomeMoney' and content like '%1%' ) or (meta_name='IncomeMoney' and content like '%2%' )) + and state > 3 and (payamount >0 or payed >0) and payamount <> payed + "; + + $this->_tvars['bicredit'] = H::fa($conn->GetOne($sql)); + } @@ -286,7 +305,7 @@ public function mqlistOnRow($row) { $row->add(new Label('wmq_qty', H::fqty($item->qty))); $row->add(new Label('wmq_minqty', H::fqty($item->minqty))); } - + public function rdoclistOnRow($row) { $item = $row->getDataItem(); @@ -296,30 +315,31 @@ public function rdoclistOnRow($row) { $row->add(new \Zippy\Html\Link\RedirectLink("wrd_number", "\\App\\Pages\\Register\\DocList", $item->document_id))->setValue($item->document_number); } - - public function onRDcsv($sender){ - $data = array(); - $conn = $conn = \ZDB\DB::getConnect(); - $user = System::getUser(); - - $sql = "select distinct d.document_id,d.meta_desc,d.document_number,d.document_date,d.amount from docstatelog_view l join documents_view d on l.document_id= d.document_id where 1=1 {$br} and l.user_id={$user->user_id} and l.createdon > " . $conn->DBDate(strtotime("-1 month", time())) . " limit 0,100"; - - $rc = $conn->Execute($sql); - + + public function onRDcsv($sender) { + $data = array(); + $conn = $conn = \ZDB\DB::getConnect(); + $user = System::getUser(); + + $sql = "select distinct d.document_id,d.meta_desc,d.document_number,d.document_date,d.amount from docstatelog_view l join documents_view d on l.document_id= d.document_id where 1=1 {$br} and l.user_id={$user->user_id} and l.createdon > " . $conn->DBDate(strtotime("-1 month", time())) . " limit 0,100"; + + $rc = $conn->Execute($sql); + $header = array(); $data = array(); - $i=0; + $i = 0; foreach ($rc as $row) { $i++; - $data['A' . $i] = \App\Helper::fd(strtotime($row['document_date'])); + $data['A' . $i] = \App\Helper::fd(strtotime($row['document_date'])); $data['B' . $i] = $row['meta_desc']; - $data['C' . $i] = array('value' => H::fa($row['amount']),'format'=>'number'); + $data['C' . $i] = array('value' => H::fa($row['amount']), 'format' => 'number'); } - H::exportExcel($data, $header, 'recentlydoc.xlsx'); + H::exportExcel($data, $header, 'recentlydoc.xlsx'); } - public function onSDcsv($sender){ + + public function onSDcsv($sender) { $brids = \App\ACL::getBranchIDsConstraint(); if (strlen($brids) > 0) { $br = " and d.branch_id in ({$brids}) "; @@ -330,25 +350,26 @@ public function onSDcsv($sender){ } $conn = $conn = \ZDB\DB::getConnect(); - $stock = Stock::find(" {$cstr} qty > 0 and sdate is not null and sdate < ADDDATE( now(), INTERVAL 7 day) "); - $header = array(); + $stock = Stock::find(" {$cstr} qty > 0 and sdate is not null and sdate < ADDDATE( now(), INTERVAL 7 day) "); + $header = array(); $data = array(); - $i=0; + $i = 0; foreach ($stock as $st) { $i++; $data['A' . $i] = $st->storename; $data['B' . $i] = $st->itemname; $data['C' . $i] = $st->snumber; $data['D' . $i] = H::fd($st->sdate); - $data['E' . $i] = array('value' =>H::fqty($st->qty),'format'=>'number'); - + $data['E' . $i] = array('value' => H::fqty($st->qty), 'format' => 'number'); + } - H::exportExcel($data, $header, 'termitem.xlsx'); - + H::exportExcel($data, $header, 'termitem.xlsx'); + } - public function onMQcsv($sender){ - $brids = \App\ACL::getBranchIDsConstraint(); + + public function onMQcsv($sender) { + $brids = \App\ACL::getBranchIDsConstraint(); if (strlen($brids) > 0) { $br = " and d.branch_id in ({$brids}) "; } @@ -356,38 +377,37 @@ public function onMQcsv($sender){ if (strlen($cstr) > 0) { $cstr = " and store_id in ({$cstr}) "; } - $conn = $conn = \ZDB\DB::getConnect(); - - $sql = "select t.qty, i.`minqty`,i.`itemname`,i.`item_code`,s.`storename` from (select item_id,store_id,coalesce(sum( `qty`),0) as qty from store_stock where 1=1 + $conn = $conn = \ZDB\DB::getConnect(); + + $sql = "select t.qty, i.`minqty`,i.`itemname`,i.`item_code`,s.`storename` from (select item_id,store_id,coalesce(sum( `qty`),0) as qty from store_stock where 1=1 {$cstr} group by item_id,store_id ) t join items i on t.item_id = i.item_id join stores s on t.store_id = s.store_id where i.disabled <> 1 and t.qty < i.`minqty` and i.`minqty`>0 "; - $rc = $conn->Execute($sql); - $header = array(); + $rc = $conn->Execute($sql); + $header = array(); $data = array(); - $i=0; + $i = 0; foreach ($rc as $row) { - $i++; - $data['A' . $i] = $row['storename']; + $i++; + $data['A' . $i] = $row['storename']; $data['B' . $i] = $row['itemname']; $data['C' . $i] = $row['item_code']; $data['D' . $i] = H::fd($row['sdate']); - $data['E' . $i] = array('value' =>H::fqty($row['qty']),'format'=>'number'); - $data['F' . $i] = array('value' =>H::fqty($row['minqty']),'format'=>'number'); - + $data['E' . $i] = array('value' => H::fqty($row['qty']), 'format' => 'number'); + $data['F' . $i] = array('value' => H::fqty($row['minqty']), 'format' => 'number'); + } - H::exportExcel($data, $header, 'minqty.xlsx'); - + H::exportExcel($data, $header, 'minqty.xlsx'); + } - + /* public function test($args,$post) { return "test"; } */ - - - + + } diff --git a/www/app/pages/options.php b/www/app/pages/options.php index 89d0937f4..b3b39f1aa 100644 --- a/www/app/pages/options.php +++ b/www/app/pages/options.php @@ -51,6 +51,8 @@ public function __construct() { $this->common->add(new CheckBox('useimages')); $this->common->add(new CheckBox('usescanner')); $this->common->add(new CheckBox('usebranch')); + $this->common->add(new CheckBox('usecattree')); + $this->common->add(new CheckBox('usemobileprinter')); $this->common->add(new CheckBox('allowminus')); $this->common->add(new CheckBox('noallowfiz')); $this->common->add(new CheckBox('capcha')); @@ -92,6 +94,8 @@ public function __construct() { $this->common->usesnumber->setChecked($common['usesnumber']); + $this->common->usemobileprinter->setChecked($common['usemobileprinter']); + $this->common->usecattree->setChecked($common['usecattree']); $this->common->usescanner->setChecked($common['usescanner']); $this->common->useimages->setChecked($common['useimages']); $this->common->usebranch->setChecked($common['usebranch']); @@ -163,7 +167,7 @@ public function __construct() { $this->api->atype->setValue($api['atype']); $this->onApiType($this->api->atype); - + //SMS $this->add(new Form('sms')); @@ -180,16 +184,16 @@ public function __construct() { $this->sms->add(new TextInput('flysmslogin')); $this->sms->add(new TextInput('flysmspass')); $this->sms->add(new TextInput('flysmsan')); - $this->sms->add(new DropDownChoice('smstype', array('1' => "SemySMS", /*'2' => "TurboSMS", */'3'=>'SMS-Fly'), 0))->onChange($this, 'onSMSType'); + $this->sms->add(new DropDownChoice('smstype', array('1' => "SemySMS", /*'2' => "TurboSMS", */ '3' => 'SMS-Fly'), 0))->onChange($this, 'onSMSType'); $sms = System::getOptions("sms"); - + $this->sms->smssemytoken->setText($sms['smssemytoken']); $this->sms->smssemydevid->setValue($sms['smssemydevid']); $this->sms->flysmslogin->setText($sms['flysmslogin']); $this->sms->flysmspass->setValue($sms['flysmspass']); $this->sms->flysmsan->setValue($sms['flysmsan']); $this->sms->turbosmstoken->setValue($sms['turbosmstoken']); - + $this->sms->smstype->setValue($sms['smstype']); $this->onSMSType($this->sms->smstype); @@ -225,6 +229,8 @@ public function saveCommonOnClick($sender) { $common['usescanner'] = $this->common->usescanner->isChecked() ? 1 : 0; $common['useimages'] = $this->common->useimages->isChecked() ? 1 : 0; + $common['usemobileprinter'] = $this->common->usemobileprinter->isChecked() ? 1 : 0; + $common['usecattree'] = $this->common->usecattree->isChecked() ? 1 : 0; $common['usebranch'] = $this->common->usebranch->isChecked() ? 1 : 0; $common['noallowfiz'] = $this->common->noallowfiz->isChecked() ? 1 : 0; $common['allowminus'] = $this->common->allowminus->isChecked() ? 1 : 0; @@ -285,7 +291,7 @@ public function onApiType($sender) { } - + public function saveApiOnClick($sender) { $api = array(); $api['exp'] = $this->api->aexp->getText(); @@ -297,8 +303,8 @@ public function saveApiOnClick($sender) { } - - public function onSMSType($sender) { + + public function onSMSType($sender) { $type = $this->sms->smstype->getValue(); $this->sms->smssemytoken->setVisible($type == 1); $this->sms->smssemydevid->setVisible($type == 1); @@ -306,14 +312,14 @@ public function onSMSType($sender) { $this->sms->flysmslogin->setVisible($type == 3); $this->sms->flysmspass->setVisible($type == 3); $this->sms->flysmsan->setVisible($type == 3); - - + + $this->sms->semysmssite->setVisible($type == 1); $this->sms->turbosmssite->setVisible($type == 2); $this->sms->smsflysite->setVisible($type == 3); // $this->goAnkor('atype'); - + } public function saveSMSOnClick($sender) { @@ -328,19 +334,19 @@ public function saveSMSOnClick($sender) { System::setOptions("sms", $sms); $this->setSuccess('saved'); - + } - + public function testSMSOnClick($sender) { - - $res = \App\Entity\Subscribe::sendSMS($this->sms->smstestphone->getText(),$this->sms->smstesttext->getText()) ; - if(strlen($res)==0) { - $this->setSuccess('success'); - } else { - $this->setError($res) ; - } - - + + $res = \App\Entity\Subscribe::sendSMS($this->sms->smstestphone->getText(), $this->sms->smstesttext->getText()); + if (strlen($res) == 0) { + $this->setSuccess('success'); + } else { + $this->setError($res); + } + + } } diff --git a/www/app/pages/reference/categorylist.php b/www/app/pages/reference/categorylist.php index 9046a3d2c..56ff176fc 100644 --- a/www/app/pages/reference/categorylist.php +++ b/www/app/pages/reference/categorylist.php @@ -5,10 +5,13 @@ use App\Entity\Category; use App\System; use Zippy\Html\DataList\DataView; +use Zippy\Html\DataList\ArrayDataSource; use Zippy\Html\Form\Button; use Zippy\Html\Form\Form; use Zippy\Html\Form\SubmitButton; use Zippy\Html\Form\TextInput; +use Zippy\Html\Form\CheckBox; +use Zippy\Html\Form\DropDownChoice; use Zippy\Html\Label; use Zippy\Html\Link\ClickLink; use Zippy\Html\Panel; @@ -20,6 +23,8 @@ class CategoryList extends \App\Pages\Base { private $_category; + public $_catlist = array(); + public function __construct() { parent::__construct(); @@ -28,11 +33,11 @@ public function __construct() { } $this->add(new Panel('categorytable'))->setVisible(true); - $this->categorytable->add(new DataView('categorylist', new \ZCL\DB\EntityDataSource('\App\Entity\Category', '', 'cat_name'), $this, 'categorylistOnRow'))->Reload(); + $this->categorytable->add(new DataView('categorylist', new ArrayDataSource($this, '_catlist'), $this, 'categorylistOnRow')); $this->categorytable->add(new ClickLink('addnew'))->onClick($this, 'addOnClick'); $this->add(new Form('categorydetail'))->setVisible(false); $this->categorydetail->add(new TextInput('editcat_name')); - + $this->categorydetail->add(new DropDownChoice('editparent', 0)); $this->categorydetail->add(new TextInput('editprice1')); $this->categorydetail->add(new TextInput('editprice2')); @@ -70,18 +75,61 @@ public function __construct() { } else { $this->categorydetail->editprice5->setVisible(false); } - + $this->categorydetail->add(new \Zippy\Html\Image('editimage', '/loadimage.php?id=0')); + $this->categorydetail->add(new \Zippy\Html\Form\File('editaddfile')); + $this->categorydetail->add(new CheckBox('editdelimage')); + $this->categorydetail->add(new CheckBox('editnoshop')); $this->categorydetail->add(new SubmitButton('save'))->onClick($this, 'saveOnClick'); $this->categorydetail->add(new Button('cancel'))->onClick($this, 'cancelOnClick'); + + $this->Reload(); + } + + public function Reload() { + $this->_catlist = Category::find('', 'cat_name', -1, -1, "item_cat.*, coalesce(( select count(0) from `items` `i` where (`i`.`cat_id` = `item_cat`.`cat_id`)),0) AS `qty`"); + foreach (Category::findFullData() as $c) { + $this->_catlist[$c->cat_id]->full_name = $c->full_name; + $this->_catlist[$c->cat_id]->parents = $c->parents; + } + + + $this->categorytable->categorylist->Reload(); } - public function categorylistOnRow($row) { + public function updateParentList($id = 0) { + $plist = array(); + foreach ($this->_catlist as $c) { + if ($c->cat_id == $id) { + continue; + } + if ($c->qty > 0) { + continue; + } + if (in_array($id, $c->parents)) { + continue; + } + $plist[$c->cat_id] = $c->full_name; + } + + $this->categorydetail->editparent->setOptionList($plist); + } + + public function categorylistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('cat_name', $item->cat_name)); + $row->add(new Label('p_name', $this->_catlist[$item->parent_id]->full_name)); + $row->add(new Label('qty', $item->qty))->setVisible($item->qty > 0); $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); + + $row->add(new \Zippy\Html\Link\BookmarkableLink('imagelistitem'))->setValue("/loadimage.php?id={$item->image_id}"); + $row->imagelistitem->setAttribute('href', "/loadimage.php?id={$item->image_id}"); + $row->imagelistitem->setAttribute('data-gallery', $item->image_id); + if ($item->image_id == 0) { + $row->imagelistitem->setVisible(false); + } } public function deleteOnClick($sender) { @@ -89,37 +137,61 @@ public function deleteOnClick($sender) { return; } - $cat_id = $sender->owner->getDataItem()->cat_id; - - $del = Category::delete($cat_id); - if (strlen($del) > 0) { - $this->setError($del); + if ($this->_catlist[$cat_id]->qty > 0) { + $this->setError('nodelcat'); + return; + } + if ($this->_catlist[$cat_id]->hasChild()) { + $this->setError('nodelcatchild'); return; } - $this->categorytable->categorylist->Reload(); + + Category::delete($cat_id); + + + $this->Reload(); } public function editOnClick($sender) { $this->_category = $sender->owner->getDataItem(); + $this->updateParentList($this->_category->cat_id); + $this->categorytable->setVisible(false); $this->categorydetail->setVisible(true); $this->categorydetail->editcat_name->setText($this->_category->cat_name); + $this->categorydetail->editparent->setValue($this->_category->parent_id); + $this->categorydetail->editnoshop->setChecked($this->_category->noshop); $this->categorydetail->editprice1->setText($this->_category->price1); $this->categorydetail->editprice2->setText($this->_category->price2); $this->categorydetail->editprice3->setText($this->_category->price3); $this->categorydetail->editprice4->setText($this->_category->price4); $this->categorydetail->editprice5->setText($this->_category->price5); + + if ($this->_category->image_id > 0) { + $this->categorydetail->editdelimage->setChecked(false); + $this->categorydetail->editdelimage->setVisible(true); + $this->categorydetail->editimage->setVisible(true); + $this->categorydetail->editimage->setUrl('/loadimage.php?id=' . $this->_category->image_id); + } else { + $this->categorydetail->editdelimage->setVisible(false); + $this->categorydetail->editimage->setVisible(false); + } + + } public function addOnClick($sender) { + $this->updateParentList($this->_category->cat_id); $this->categorytable->setVisible(false); $this->categorydetail->setVisible(true); // Очищаем форму $this->categorydetail->clean(); - + $this->categorydetail->editimage->setVisible(false); + $this->categorydetail->editdelimage->setVisible(false); + $this->updateParentList(); $this->_category = new Category(); } @@ -128,7 +200,9 @@ public function saveOnClick($sender) { return; } + $this->_category->parent_id = $this->categorydetail->editparent->getValue(); $this->_category->cat_name = $this->categorydetail->editcat_name->getText(); + $this->_category->noshop = $this->categorydetail->editnoshop->isChecked() ? 1 : 0; if ($this->_category->cat_name == '') { $this->setError("entername"); return; @@ -140,10 +214,58 @@ public function saveOnClick($sender) { $this->_category->price4 = $this->categorydetail->editprice4->getText(); $this->_category->price5 = $this->categorydetail->editprice5->getText(); - $this->_category->Save(); + //delete image + if ($this->categorydetail->editdelimage->isChecked()) { + if ($this->_category->image_id > 0) { + Category::delete($this->_category->image_id); + } + $this->_category->image_id = 0; + } + + $this->_category->save(); + + $file = $this->categorydetail->editaddfile->getFile(); + if (strlen($file["tmp_name"]) > 0) { + $imagedata = getimagesize($file["tmp_name"]); + + if (preg_match('/(gif|png|jpeg)$/', $imagedata['mime']) == 0) { + $this->setError('invalidformatimage'); + return; + } + + if ($imagedata[0] * $imagedata[1] > 1000000) { + + $this->setError('toobigimage'); + return; + } + + $image = new \App\Entity\Image(); + $image->content = file_get_contents($file['tmp_name']); + $image->mime = $imagedata['mime']; + + if ($imagedata[0] != $imagedata[1]) { + $thumb = new \App\Thumb($file['tmp_name']); + if ($imagedata[0] > $imagedata[1]) { + $thumb->cropFromCenter($imagedata[1], $imagedata[1]); + } + if ($imagedata[0] < $imagedata[1]) { + $thumb->cropFromCenter($imagedata[0], $imagedata[0]); + } + $thumb->resize(256, 256); + $image->content = $thumb->getImageAsString(); + + + } + + + $image->save(); + $this->_category->image_id = $image->image_id; + $this->_category->save(); + } + $this->categorydetail->setVisible(false); $this->categorytable->setVisible(true); - $this->categorytable->categorylist->Reload(); + $this->Reload(); } public function cancelOnClick($sender) { diff --git a/www/app/pages/reference/contractlist.php b/www/app/pages/reference/contractlist.php index 36e59a00a..efbedfe09 100644 --- a/www/app/pages/reference/contractlist.php +++ b/www/app/pages/reference/contractlist.php @@ -45,8 +45,8 @@ public function __construct($id = 0) { $this->contracttable->add(new ClickLink('addnew'))->onClick($this, 'addOnClick'); $this->contracttable->contractlist->setPageSize(H::getPG()); $this->contracttable->add(new \Zippy\Html\DataList\Paginator('pag', $this->contracttable->contractlist)); - $this->contracttable->contractlist->Reload() ; - + $this->contracttable->contractlist->Reload(); + $this->add(new Form('contractdetail'))->setVisible(false); $this->contractdetail->add(new Date('editcreatedon', time())); $this->contractdetail->add(new Date('editenddate', strtotime("+1 month", time()))); @@ -56,7 +56,7 @@ public function __construct($id = 0) { $this->contractdetail->add(new AutocompleteTextInput('editcust'))->onText($this, 'OnAutoCustomer'); $this->contractdetail->add(new DropDownChoice('editcomp', Firm::findArray('firm_name', 'disabled<>1', 'firm_name'), 0)); $this->contractdetail->add(new DropDownChoice('editemp', Employee::findArray('emp_name', 'disabled<>1', 'emp_name'), 0)); - $this->contractdetail->add(new DropDownChoice('editctype',array() , 0)); + $this->contractdetail->add(new DropDownChoice('editctype', array(), 0)); $this->contractdetail->add(new \Zippy\Html\Form\File('scan')); @@ -67,15 +67,14 @@ public function __construct($id = 0) { $this->add(new Panel('docpan'))->setVisible(false); $this->docpan->add(new Label("cname")); - - + $this->docpan->add(new ClickLink('back'))->onClick($this, 'cancelOnClick'); $this->docpan->add(new DataView('dtable', new ArrayDataSource(array()), $this, 'doclistOnRow')); $this->docpan->dtable->setPageSize(H::getPG()); $this->docpan->add(new \Zippy\Html\DataList\Paginator('dpag', $this->docpan->dtable)); - + if ($id > 0) { $c = Contract::load($id); $this->filter->searchkey->setText($c->contract_number); @@ -84,7 +83,7 @@ public function __construct($id = 0) { } - public function contractlistOnRow($row) { + public function contractlistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('contract_number', $item->contract_number)); @@ -93,8 +92,8 @@ public function contractlistOnRow($row) { $row->add(new Label('customer', $item->customer_name)); $row->add(new Label('firm', $item->firm_name)); - $dolg = $item->getDolg() ; - $row->add(new Label('dolg', $dolg <>0 ? H::fa($dolg) :"" )); + $dolg = $item->getDolg(); + $row->add(new Label('dolg', $dolg <> 0 ? H::fa($dolg) : "")); $row->add(new Label('emp', $item->emp_name)); $row->add(new Label('hasnotes'))->setVisible(strlen($item->desc) > 0); $row->hasnotes->setAttribute('title', $item->desc); @@ -214,7 +213,7 @@ public function cancelOnClick($sender) { public function OnFilter($sender) { $this->contracttable->contractlist->Reload(); $this->docpan->setVisible(false); - + } public function OnAutoCustomer($sender) { @@ -229,23 +228,22 @@ public function showOnClick($sender) { $dlist = $this->_contract->getDocs(); - + $this->docpan->dtable->getDataSource()->setArray($dlist); $this->docpan->dtable->Reload(); - + } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $row->add(new Label("dnum", $doc->document_number)); $row->add(new Label("dtype", $doc->meta_desc)); $row->add(new Label("ddate", H::fd($doc->document_date))); $row->add(new Label("dsumma", H::fa($doc->amount))); - + } - } diff --git a/www/app/pages/reference/customerlist.php b/www/app/pages/reference/customerlist.php index 37295abfc..3668a5887 100644 --- a/www/app/pages/reference/customerlist.php +++ b/www/app/pages/reference/customerlist.php @@ -20,6 +20,7 @@ use Zippy\Html\Link\SubmitLink; use Zippy\Html\Panel; use Zippy\Html\Link\SortLink; +use \Zippy\Html\DataList\DataRow; /** * Страница контрагентов @@ -27,11 +28,11 @@ class CustomerList extends \App\Pages\Base { - private $_customer = null; - public $_fileslist = array(); - public $_msglist = array(); - public $_eventlist = array(); - public $_contrtlist = array(); + private $_customer = null; + public $_fileslist = array(); + public $_msglist = array(); + public $_eventlist = array(); + public $_contrtlist = array(); public $_leadsourceslist = array(); public function __construct($id = 0) { @@ -40,19 +41,19 @@ public function __construct($id = 0) { return; } - + $this->add(new Form('leadf')); $this->leadf->add(new CheckBox('chleads'))->onChange($this, 'OnLeadMode'); - - + + $this->add(new Form('filter'))->onSubmit($this, 'OnSearch'); $this->filter->add(new TextInput('searchkey')); $this->filter->add(new DropDownChoice('searchtype', array(Customer::TYPE_BAYER => Helper::l("bayers"), Customer::TYPE_SELLER => Helper::l("sellers"), 5 => Helper::l("holdings")), 0)); $this->filter->add(new DropDownChoice('searchholding', Customer::getHoldList(), 0)); - + $this->filter->add(new DropDownChoice('searchleadsource', Customer::getLeadSources(), "0")); $this->filter->add(new DropDownChoice('searchleadstatus', Customer::getLeadStatuses(), "0")); - + $this->add(new Panel('customertable'))->setVisible(true); $this->customertable->add(new DataView('customerlist', new CustomerDataSource($this), $this, 'customerlistOnRow')); @@ -68,7 +69,7 @@ public function __construct($id = 0) { $this->customertable->add(new ClickLink('showstat'))->onClick($this, 'showStat'); $this->add(new Panel('statpan'))->setVisible(false); $this->statpan->add(new ClickLink('closestat'))->onClick($this, 'closeStat'); - + $this->add(new Form('customerdetail'))->setVisible(false); $this->customerdetail->add(new TextInput('editaddress')); $this->customerdetail->add(new TextInput('editcity')); @@ -80,30 +81,30 @@ public function __construct($id = 0) { $this->customerdetail->add(new CheckBox('editisholding')); $this->customerdetail->add(new DropDownChoice('editholding', Customer::getHoldList(), 0)); $this->customerdetail->add(new DropDownChoice('edittype', array(1 => Helper::l("bayer"), 2 => Helper::l("seller")), 0)); - - $this->customerdetail->add(new CheckBox('editdisabled' )); - + + $this->customerdetail->add(new CheckBox('editdisabled')); + $this->customerdetail->add(new TextInput('discount')); $this->customerdetail->add(new TextInput('bonus')); $this->customerdetail->add(new TextArea('editcomment')); - $this->customerdetail->add(new DropDownChoice('editleadsource',Customer::getLeadSources(),"0")); - $this->customerdetail->add(new DropDownChoice('editleadstatus',Customer::getLeadStatuses(),"0")); + $this->customerdetail->add(new DropDownChoice('editleadsource', Customer::getLeadSources(), "0")); + $this->customerdetail->add(new DropDownChoice('editleadstatus', Customer::getLeadStatuses(), "0")); $this->customerdetail->add(new SubmitButton('save'))->onClick($this, 'saveOnClick'); $this->customerdetail->add(new Button('cancel'))->onClick($this, 'cancelOnClick'); $this->add(new Panel('contentview'))->setVisible(false); $this->contentview->add(new ClickLink('back'))->onClick($this, 'cancelOnClick'); - $this->contentview->add(new Label('concname')) ; - $this->contentview->add(new Label('concreated')) ; - $this->contentview->add(new Label('conlastdoc')) ; - $this->contentview->add(new Label('conphone')) ; - $this->contentview->add(new Label('conemail')) ; - $this->contentview->add(new ClickLink('convert',$this,'onConvert')) ; - $this->contentview->add(new Form('conlstform' )) ; - $this->contentview->conlstform->add(new DropDownChoice('conleadstatus',Customer::getLeadStatuses() ))->onChange($this,'OnSelStatus') ; - - + $this->contentview->add(new Label('concname')); + $this->contentview->add(new Label('concreated')); + $this->contentview->add(new Label('conlastdoc')); + $this->contentview->add(new Label('conphone')); + $this->contentview->add(new Label('conemail')); + $this->contentview->add(new ClickLink('convert', $this, 'onConvert')); + $this->contentview->add(new Form('conlstform')); + $this->contentview->conlstform->add(new DropDownChoice('conleadstatus', Customer::getLeadStatuses()))->onChange($this, 'OnSelStatus'); + + $this->contentview->add(new Form('addfileform'))->onSubmit($this, 'OnFileSubmit'); $this->contentview->addfileform->add(new \Zippy\Html\Form\File('addfile')); $this->contentview->addfileform->add(new TextInput('adddescfile')); @@ -123,50 +124,50 @@ public function __construct($id = 0) { $this->contentview->dw_eventlist->setPageSize(10); $this->contentview->add(new \Zippy\Html\DataList\Paginator('eventpag', $this->contentview->dw_eventlist)); - - $this->customertable->add(new ClickLink('leadsourcesedit',$this,'onLeadSourcesList')); - $this->customertable->add(new ClickLink('leadstatusesedit',$this,'onLeadStatusesList')); - - $this->add(new Form('leadsourcesform'))->setVisible(false) ; + + $this->customertable->add(new ClickLink('leadsourcesedit', $this, 'onLeadSourcesList')); + $this->customertable->add(new ClickLink('leadstatusesedit', $this, 'onLeadStatusesList')); + + $this->add(new Form('leadsourcesform'))->setVisible(false); $this->leadsourcesform->add(new SubmitButton('leadsourcesave'))->onClick($this, 'OnSaveLeadSource'); $this->leadsourcesform->add(new SubmitLink('addnewsource'))->onClick($this, 'OnAddLeadSource'); $this->leadsourcesform->add(new ClickLink('leadsourcecancel'))->onClick($this, 'OnCancelLeadSource'); - + $this->leadsourcesform->add(new DataView('leadsourceslist', new ArrayDataSource(new Bind($this, '_leadsourceslist')), $this, 'leadsourceListOnRow')); - - - $this->add(new Form('leadstatusesform'))->setVisible(false) ; + + + $this->add(new Form('leadstatusesform'))->setVisible(false); $this->leadstatusesform->add(new SubmitButton('leadstatussave'))->onClick($this, 'OnSaveLeadStatus'); $this->leadstatusesform->add(new SubmitLink('addnewstatus'))->onClick($this, 'OnAddLeadStatus'); $this->leadstatusesform->add(new ClickLink('leadstatuscancel'))->onClick($this, 'OnCancelLeadStatus'); - + $this->leadstatusesform->add(new DataView('leadstatuseslist', new ArrayDataSource(new Bind($this, '_leadstatuseslist')), $this, 'leadstatusListOnRow')); - - + + $this->contentview->add(new DataView('dw_contr', new ArrayDataSource(new Bind($this, '_contrlist')), $this, 'contrListOnRow')); - - + + if ($id > 0) { $this->_customer = Customer::load($id); if ($this->_customer instanceof Customer) { $this->show(); } } - - $this->_tvars['leadmode']= false; + + $this->_tvars['leadmode'] = false; } public function OnLeadMode($sender) { - + $this->_tvars['leadmode'] = $sender->isChecked(); $this->filter->clean(); $this->customertable->customerlist->Reload(); - - - + + } - public function OnSearch($sender) { - + + public function OnSearch($sender) { + $this->customertable->customerlist->Reload(); $this->contentview->setVisible(false); } @@ -178,29 +179,28 @@ public function customerlistOnRow($row) { $row->add(new Label('customerphone', $item->phone)); $row->add(new Label('customeremail', $item->email)); $row->add(new Label('leadstatus', $item->leadstatus)); - $row->add(new Label('docs', $item->docs))->setVisible($item->docs>0); - + $row->add(new Label('docs', $item->docs))->setVisible($item->docs > 0); + $row->add(new Label('customercomment'))->setVisible(strlen($item->comment) > 0 && $item->comment == strip_tags($item->comment)); $row->customercomment->setAttribute('title', $item->comment); - + $row->add(new Label('hasmsg'))->setVisible($item->mcnt > 0); $row->add(new Label('hasfiles'))->setVisible($item->fcnt > 0); $row->add(new Label('isplanned'))->setVisible($item->ecnt > 0); - + $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); $row->add(new ClickLink('contentlist'))->onClick($this, 'editContentOnClick'); $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); - + $row->setAttribute('style', $item->status == 1 ? 'color: #aaa' : null); - + } - - public function onSort($sender) { + + public function onSort($sender) { $sortfield = $sender->fileld; $sortdir = $sender->dir; $this->customertable->sortdoc->Reset(); - $this->customertable->customerlist->setSorting($sortfield, $sortdir); @@ -236,7 +236,7 @@ public function show() { $this->customerdetail->editleadsource->setValue($this->_customer->leadsource); $this->customerdetail->editleadstatus->setValue($this->_customer->leadstatus); $this->customerdetail->editholding->setValue($this->_customer->holding); - $this->customerdetail->editdisabled->setChecked($this->_customer->status==1); + $this->customerdetail->editdisabled->setChecked($this->_customer->status == 1); $this->customerdetail->editjurid->setChecked($this->_customer->jurid); $this->customerdetail->editisholding->setChecked($this->_customer->isholding); @@ -263,9 +263,9 @@ public function addOnClick($sender) { $this->customerdetail->setVisible(true); // Очищаем форму $this->customerdetail->clean(); - + $this->contentview->setVisible(false); - + $this->_customer = new Customer(); } @@ -290,25 +290,25 @@ public function saveOnClick($sender) { $this->_customer->type = $this->customerdetail->edittype->getValue(); $this->_customer->holding = $this->customerdetail->editholding->getValue(); $this->_customer->holding_name = $this->customerdetail->editholding->getValueName(); - - if($this->_tvars['leadmode']==true) { - $this->_customer->leadsource = $this->customerdetail->editleadsource->getValue(); - $this->_customer->leadstatus = $this->customerdetail->editleadstatus->getValue(); - $this->_customer->status = 2; - if( $this->_customer->leadsource=="0") { - $this->setError("enterleadsource"); - return; - } - if( $this->_customer->leadstatus=="0") { - $this->setError("enterleadstatus"); - return; - } - - - } else { - $this->_customer->status = $this->customerdetail->editdisabled->isChecked() ?1:0; + + if ($this->_tvars['leadmode'] == true) { + $this->_customer->leadsource = $this->customerdetail->editleadsource->getValue(); + $this->_customer->leadstatus = $this->customerdetail->editleadstatus->getValue(); + $this->_customer->status = 2; + if ($this->_customer->leadsource == "0") { + $this->setError("enterleadsource"); + return; + } + if ($this->_customer->leadstatus == "0") { + $this->setError("enterleadstatus"); + return; + } + + + } else { + $this->_customer->status = $this->customerdetail->editdisabled->isChecked() ? 1 : 0; } - + $this->_customer->isholding = $this->customerdetail->editisholding->isChecked() ? 1 : 0; if ($this->_customer->isholding == 1 && $this->_customer->holding > 0) { @@ -338,9 +338,9 @@ public function saveOnClick($sender) { } } - if($this->_customer->customer_id==0){ //новый - $this->_customer->createdon = time(); - $this->_customer->user_id = System::getUser()->user_id; + if ($this->_customer->customer_id == 0) { //новый + $this->_customer->createdon = time(); + $this->_customer->user_id = System::getUser()->user_id; } $this->_customer->save(); $this->customerdetail->setVisible(false); @@ -361,33 +361,33 @@ public function editContentOnClick($sender) { $this->contentview->setVisible(true); $this->customertable->setVisible(false); $this->contentview->concname->setText($this->_customer->customer_name); - $created =''; - $lastdoc =''; - if($this->_customer->created >0) { + $created = ''; + $lastdoc = ''; + if ($this->_customer->created > 0) { $user = \App\Entity\User::load($this->_customer->user_id); - $created = Helper::l('custcreated',Helper::fd($this->_customer->createdon),$user->username) ; + $created = Helper::l('custcreated', Helper::fd($this->_customer->createdon), $user->username); } - $doc = \App\Entity\Doc\Document::getFirst("customer_id=".$this->_customer->customer_id, 'document_id desc'); - if($doc instanceof \App\Entity\Doc\Document) { - $lastdoc = Helper::l('custlastdoc',$doc->document_number,Helper::fd($doc->document_date),$this->_customer->docs) ; - + $doc = \App\Entity\Doc\Document::getFirst("customer_id=" . $this->_customer->customer_id, 'document_id desc'); + if ($doc instanceof \App\Entity\Doc\Document) { + $lastdoc = Helper::l('custlastdoc', $doc->document_number, Helper::fd($doc->document_date), $this->_customer->docs); + } - + $this->contentview->concreated->setText($created); $this->contentview->conlastdoc->setText($lastdoc); $this->contentview->conphone->setText($this->_customer->phone); $this->contentview->conemail->setText($this->_customer->email); - $this->contentview->conphone->setVisible(strlen($this->_customer->phone)>0); - $this->contentview->conemail->setVisible(strlen($this->_customer->email)>0); + $this->contentview->conphone->setVisible(strlen($this->_customer->phone) > 0); + $this->contentview->conemail->setVisible(strlen($this->_customer->email) > 0); $this->contentview->conlstform->conleadstatus->setValue($this->_customer->leadstatus); - + $this->updateFiles(); $this->updateMessages(); $this->updateEvents(); $this->updateContrs(); $this->customertable->customerlist->setSelectedRow($sender->getOwner()); $this->customertable->customerlist->Reload(); - // $this->goAnkor('contentviewlink'); + // $this->goAnkor('contentviewlink'); } //контент @@ -413,7 +413,7 @@ private function updateFiles() { } //вывод строки прикрепленного файла - public function filelistOnRow($row) { + public function filelistOnRow(DataRow $row) { $item = $row->getDataItem(); $file = $row->add(new \Zippy\Html\Link\BookmarkableLink("filename", _BASEURL . 'loadfile.php?id=' . $item->file_id)); @@ -461,7 +461,7 @@ private function updateMessages() { } //вывод строки коментария - public function msgListOnRow($row) { + public function msgListOnRow(DataRow $row) { $item = $row->getDataItem(); $row->add(new Label("msgdata", nl2br($item->message))); @@ -521,7 +521,7 @@ private function updateContrs() { } //вывод строки коментария - public function eventListOnRow($row) { + public function eventListOnRow(DataRow $row) { $event = $row->getDataItem(); @@ -543,7 +543,7 @@ public function deleteEventOnClick($sender) { } - public function contrListOnRow($row) { + public function contrListOnRow(DataRow $row) { $contr = $row->getDataItem(); @@ -560,143 +560,152 @@ public function contractOnClick($sender) { \App\Application::Redirect("\\App\\Pages\\Reference\\ContractList", $contr->contract_id); } - public function OnSelStatus($sender){ - $this->_customer->leadstatus = $sender->getValue(); - $this->_customer->save(); - $this->customertable->customerlist->Reload(); - + public function OnSelStatus($sender) { + $this->_customer->leadstatus = $sender->getValue(); + $this->_customer->save(); + $this->customertable->customerlist->Reload(); + } - public function onConvert($sender){ + + public function onConvert($sender) { $this->leadf->chleads->setChecked(false); $this->_tvars['leadmode'] = false; - + $this->filter->clean(); $this->customertable->customerlist->Reload(); - $this->_customer->status = 0; - $this->_customer->fromlead = 1; - - $this->show() ; - + $this->_customer->status = 0; + $this->_customer->fromlead = 1; + + $this->show(); + } - + //редактирование источников - public function onLeadSourcesList($sender){ - $options = System::getOptions('common' ) ; - $this->_leadsourceslist = $options['leadsources']; - if(is_array($this->_leadsourceslist)==false)$this->_leadsourceslist = array(); - - $this->customertable->setVisible(false); - $this->leadsourcesform->setVisible(true); - $this->leadsourcesform->leadsourceslist->Reload(); - } - public function OnSaveLeadSource($sender){ - - $this->customertable->setVisible(true); - $this->leadsourcesform->setVisible(false); - - $options = System::getOptions('common' ) ; - $options['leadsources'] = $this->_leadsourceslist; - System::setOptions('common',$options ) ; - - $this->filter->searchleadsource->setOptionList(Customer::getLeadSources()); - $this->customerdetail->editleadsource->setOptionList(Customer::getLeadSources()); - - } - public function OnAddLeadSource($sender){ - $ls = new \App\DataItem() ; - $ls->name=''; - $ls->id=time(); - $this->_leadsourceslist[$ls->id]= $ls; - $this->leadsourcesform->leadsourceslist->Reload(); - - - } - - public function OnCancelLeadSource($sender){ - $this->customertable->setVisible(true); - $this->leadsourcesform->setVisible(false); - - } - - - public function leadsourceListOnRow($row){ - $item = $row->getDataItem(); - $row->add(new TextInput('leadsourcename',new Bind($item,'name'))) ; - $row->add(new ClickLink('delsource',$this,'onDelLeadSource')); - } - + public function onLeadSourcesList($sender) { + $options = System::getOptions('common'); + $this->_leadsourceslist = $options['leadsources']; + if (is_array($this->_leadsourceslist) == false) { + $this->_leadsourceslist = array(); + } + + $this->customertable->setVisible(false); + $this->leadsourcesform->setVisible(true); + $this->leadsourcesform->leadsourceslist->Reload(); + } + + public function OnSaveLeadSource($sender) { + + $this->customertable->setVisible(true); + $this->leadsourcesform->setVisible(false); + + $options = System::getOptions('common'); + $options['leadsources'] = $this->_leadsourceslist; + System::setOptions('common', $options); + + $this->filter->searchleadsource->setOptionList(Customer::getLeadSources()); + $this->customerdetail->editleadsource->setOptionList(Customer::getLeadSources()); + + } + + public function OnAddLeadSource($sender) { + $ls = new \App\DataItem(); + $ls->name = ''; + $ls->id = time(); + $this->_leadsourceslist[$ls->id] = $ls; + $this->leadsourcesform->leadsourceslist->Reload(); + + + } + + public function OnCancelLeadSource($sender) { + $this->customertable->setVisible(true); + $this->leadsourcesform->setVisible(false); + + } + + + public function leadsourceListOnRow(DataRow $row) { + $item = $row->getDataItem(); + $row->add(new TextInput('leadsourcename', new Bind($item, 'name'))); + $row->add(new ClickLink('delsource', $this, 'onDelLeadSource')); + } + public function onDelLeadSource($sender) { - $item = $sender->getOwner()->getDataItem() ; - + $item = $sender->getOwner()->getDataItem(); + $this->_leadsourceslist = array_diff_key($this->_leadsourceslist, array($item->id => $this->_leadsourceslist[$item->id])); - - $this->leadsourcesform->leadsourceslist->Reload(); - + + $this->leadsourcesform->leadsourceslist->Reload(); + } - + //редактирование состояний - public function onLeadStatusesList($sender){ - $options = System::getOptions('common' ) ; - $this->_leadstatuseslist = $options['leadstatuses']; - if(is_array($this->_leadstatuseslist)==false)$this->_leadstatuseslist = array(); - - $this->customertable->setVisible(false); - $this->leadstatusesform->setVisible(true); - $this->leadstatusesform->leadstatuseslist->Reload(); - } - public function OnSaveLeadStatus($sender){ - - $this->customertable->setVisible(true); - $this->leadstatusesform->setVisible(false); - - $options = System::getOptions('common' ) ; - $options['leadstatuses'] = $this->_leadstatuseslist; - System::setOptions('common',$options ) ; - - - $this->filter->searchleadstatus->setOptionList(Customer::getLeadStatuses()); - $this->customerdetail->editleadstatus->setOptionList(Customer::getLeadStatuses()); - - } - public function OnAddLeadStatus($sender){ - $ls = new \App\DataItem() ; - $ls->name=''; - $ls->id=time(); - $this->_leadstatuseslist[$ls->id]= $ls; - $this->leadstatusesform->leadstatuseslist->Reload(); - - - } - - public function OnCancelLeadStatus($sender){ - $this->customertable->setVisible(true); - $this->leadstatusesform->setVisible(false); - - } - - - public function leadstatusListOnRow($row){ - $item = $row->getDataItem(); - $row->add(new TextInput('leadstatusname',new Bind($item,'name'))) ; - $row->add(new ClickLink('delstatus',$this,'onDelLeadStatus')); - } - + public function onLeadStatusesList($sender) { + $options = System::getOptions('common'); + $this->_leadstatuseslist = $options['leadstatuses']; + if (is_array($this->_leadstatuseslist) == false) { + $this->_leadstatuseslist = array(); + } + + $this->customertable->setVisible(false); + $this->leadstatusesform->setVisible(true); + $this->leadstatusesform->leadstatuseslist->Reload(); + } + + public function OnSaveLeadStatus($sender) { + + $this->customertable->setVisible(true); + $this->leadstatusesform->setVisible(false); + + $options = System::getOptions('common'); + $options['leadstatuses'] = $this->_leadstatuseslist; + System::setOptions('common', $options); + + + $this->filter->searchleadstatus->setOptionList(Customer::getLeadStatuses()); + $this->customerdetail->editleadstatus->setOptionList(Customer::getLeadStatuses()); + + } + + public function OnAddLeadStatus($sender) { + $ls = new \App\DataItem(); + $ls->name = ''; + $ls->id = time(); + $this->_leadstatuseslist[$ls->id] = $ls; + $this->leadstatusesform->leadstatuseslist->Reload(); + + + } + + public function OnCancelLeadStatus($sender) { + $this->customertable->setVisible(true); + $this->leadstatusesform->setVisible(false); + + } + + + public function leadstatusListOnRow(DataRow $row) { + $item = $row->getDataItem(); + $row->add(new TextInput('leadstatusname', new Bind($item, 'name'))); + $row->add(new ClickLink('delstatus', $this, 'onDelLeadStatus')); + } + public function onDelLeadStatus($sender) { - $item = $sender->getOwner()->getDataItem() ; - + $item = $sender->getOwner()->getDataItem(); + $this->_leadstatuseslist = array_diff_key($this->_leadstatuseslist, array($item->id => $this->_leadstatuseslist[$item->id])); - - $this->leadstatusesform->leadstatuseslist->Reload(); - - } - - - public function showStat($sender){ - $this->customertable->setVisible(false); - $this->statpan->setVisible(true); - - $conn = $conn = \ZDB\DB::getConnect(); - $sql = " + + $this->leadstatusesform->leadstatuseslist->Reload(); + + } + + + public function showStat($sender) { + $this->customertable->setVisible(false); + $this->statpan->setVisible(true); + + $conn = $conn = \ZDB\DB::getConnect(); + $sql = " SELECT leadstatus,coalesce(count(*),0) as cnt FROM customers WHERE status =2 @@ -708,20 +717,20 @@ public function showStat($sender){ $rs = $conn->Execute($sql); $title = array(); $data = array(); - $color = array(); - + $color = array(); + foreach ($rs as $row) { - $data[] = $row['cnt']; + $data[] = $row['cnt']; $title[] = $row['leadstatus']; $color[] = '#' . \App\Util::genColor(); } $this->_tvars['gr1title'] = json_encode($title, JSON_UNESCAPED_UNICODE); $this->_tvars['gr1data'] = json_encode($data); $this->_tvars['gr1color'] = json_encode($color); - - - $sql = " + + + $sql = " SELECT leadsource,coalesce(count(*),0) as cnt FROM customers WHERE status =2 @@ -733,19 +742,19 @@ public function showStat($sender){ $rs = $conn->Execute($sql); $title = array(); $data = array(); - $color = array(); - + $color = array(); + foreach ($rs as $row) { - $data[] = $row['cnt']; + $data[] = $row['cnt']; $title[] = $row['leadsource']; $color[] = '#' . \App\Util::genColor(); } $this->_tvars['gr2title'] = json_encode($title, JSON_UNESCAPED_UNICODE); $this->_tvars['gr2data'] = json_encode($data); $this->_tvars['gr2color'] = json_encode($color); - - $sql = " + + $sql = " SELECT leadsource,coalesce(count(*),0) as cnt FROM customers WHERE status =0 and detail like '%1%' @@ -757,27 +766,25 @@ public function showStat($sender){ $rs = $conn->Execute($sql); $title = array(); $data = array(); - $color = array(); - + $color = array(); + foreach ($rs as $row) { - $data[] = $row['cnt']; + $data[] = $row['cnt']; $title[] = $row['leadsource']; $color[] = '#' . \App\Util::genColor(); } $this->_tvars['gr3title'] = json_encode($title, JSON_UNESCAPED_UNICODE); $this->_tvars['gr3data'] = json_encode($data); $this->_tvars['gr3color'] = json_encode($color); - - - - - } - - public function closeStat($sender){ - $this->customertable->setVisible(true); - $this->statpan->setVisible(false); - } + + + } + + public function closeStat($sender) { + $this->customertable->setVisible(true); + $this->statpan->setVisible(false); + } } class CustomerDataSource implements \Zippy\Interfaces\DataSource @@ -789,18 +796,18 @@ public function __construct($page) { } private function getWhere() { - - $conn = \ZDB\DB::getConnect(); - - + + $conn = \ZDB\DB::getConnect(); + + $type = $this->page->filter->searchtype->getValue(); $holding = $this->page->filter->searchholding->getValue(); $search = trim($this->page->filter->searchkey->getText()); - - $isleads = $this->page->leadf->chleads->isChecked() ; - if($isleads==false) { - $where = "status < 2 " ; + + $isleads = $this->page->leadf->chleads->isChecked(); + if ($isleads == false) { + $where = "status < 2 "; if (strlen($search) > 0) { $search = Customer::qstr('%' . $search . '%'); @@ -821,25 +828,25 @@ private function getWhere() { } else { $searchleadsource = $this->page->filter->searchleadsource->getValue(); $searchleadstatus = $this->page->filter->searchleadstatus->getValue(); - - - $where = "status = 2 " ; + + + $where = "status = 2 "; if (strlen($search) > 0) { $search = Customer::qstr('%' . $search . '%'); $where .= " and (customer_name like {$search} or phone like {$search} or email like {$search} )"; } if (strlen($searchleadsource) > 1) { - $searchleadsource = Customer::qstr( $searchleadsource ); + $searchleadsource = Customer::qstr($searchleadsource); $where .= " and (leadsource = {$searchleadsource} )"; } if (strlen($searchleadstatus) > 1) { - $searchleadstatus = Customer::qstr( $searchleadstatus ); + $searchleadstatus = Customer::qstr($searchleadstatus); $where .= " and (leadstatus = {$searchleadstatus} )"; } - + } - + return $where; } @@ -848,10 +855,10 @@ public function getItemCount() { } public function getItems($start, $count, $sortfield = null, $asc = null) { - - return Customer::find($this->getWhere(), $sortfield . " " . $asc, $count, $start,"*, coalesce( (select count(*) from documents where documents.customer_id= customers_view.customer_id and documents.state>3 ),0) as docs"); - - + + return Customer::find($this->getWhere(), $sortfield . " " . $asc, $count, $start, "*, coalesce( (select count(*) from documents where documents.customer_id= customers_view.customer_id and documents.state>3 ),0) as docs"); + + } public function getItem($id) { diff --git a/www/app/pages/reference/employeelist.php b/www/app/pages/reference/employeelist.php index 7708a5223..bf8a49baa 100644 --- a/www/app/pages/reference/employeelist.php +++ b/www/app/pages/reference/employeelist.php @@ -58,7 +58,7 @@ public function onType($sender){ } */ - public function employeelistOnRow($row) { + public function employeelistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('emp_name', $item->emp_name)); @@ -107,7 +107,7 @@ public function addOnClick($sender) { $this->employeedetail->clean(); $this->employeedetail->editlogin->setOptionList(Employee::getFreeLogins()); $this->employeedetail->editlogin->setValue('0'); - + $b = \App\System::getBranch(); $this->employeedetail->editbranch->setValue($b > 0 ? $b : 0); diff --git a/www/app/pages/reference/eqlist.php b/www/app/pages/reference/eqlist.php index 26976de85..3806709a1 100644 --- a/www/app/pages/reference/eqlist.php +++ b/www/app/pages/reference/eqlist.php @@ -70,7 +70,7 @@ public function __construct() { $this->usetable->add(new DataView('uselist', new ArrayDataSource($this, '_uselist'), $this, 'uselistOnRow')); } - public function eqlistOnRow($row) { + public function eqlistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('eq_name', $item->eq_name)); $row->add(new Label('code', $item->code)); @@ -119,7 +119,7 @@ public function useOnClick($sender) { $this->usetable->uselist->Reload(); } - public function uselistOnRow($row) { + public function uselistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('usetask', $item->usetask)); $row->add(new Label('useplace', $item->useplace)); diff --git a/www/app/pages/reference/itemlist.php b/www/app/pages/reference/itemlist.php index ba20446cf..66d8e019d 100644 --- a/www/app/pages/reference/itemlist.php +++ b/www/app/pages/reference/itemlist.php @@ -39,7 +39,7 @@ public function __construct($add = false) { $this->filter->add(new TextInput('searchkey')); $catlist = array(); $catlist[-1] = H::l("withoutcat"); - foreach (Category::findArray("cat_name", "", "cat_name") as $k => $v) { + foreach (Category::getList() as $k => $v) { $catlist[$k] = $v; } $this->filter->add(new DropDownChoice('searchcat', $catlist, 0)); @@ -95,17 +95,24 @@ public function __construct($add = false) { $this->itemdetail->add(new TextInput('editminqty')); $this->itemdetail->add(new TextInput('editzarp')); $this->itemdetail->add(new TextInput('editweight')); + $this->itemdetail->add(new TextInput('editmaxsize')); + $this->itemdetail->add(new TextInput('editvolume')); + $this->itemdetail->add(new TextInput('editcustomsize')); $this->itemdetail->add(new TextInput('editwarranty')); $this->itemdetail->add(new TextInput('editcell')); $this->itemdetail->add(new TextInput('editmsr')); - $this->itemdetail->add(new DropDownChoice('editcat', Category::findArray("cat_name", "", "cat_name"), 0)); + + $this->itemdetail->add(new DropDownChoice('editcat', Category::findArray("cat_name", "cat_id not in (select coalesce(parent_id,0) from item_cat )", "cat_name"), 0)); $this->itemdetail->add(new TextInput('editcode')); $this->itemdetail->add(new TextArea('editdescription')); $this->itemdetail->add(new CheckBox('editdisabled')); $this->itemdetail->add(new CheckBox('edituseserial')); - $this->itemdetail->add(new CheckBox('editpricelist', true)); - $this->itemdetail->add(new \Zippy\Html\Image('editimage', '/LoadImage.php?id=0')); + $this->itemdetail->add(new CheckBox('editnoprice')); + $this->itemdetail->add(new CheckBox('editnoshop')); + $this->itemdetail->add(new CheckBox('editautooutcome')); + $this->itemdetail->add(new CheckBox('editautoincome')); + $this->itemdetail->add(new \Zippy\Html\Image('editimage', '/loadimage.php?id=0')); $this->itemdetail->add(new \Zippy\Html\Form\File('editaddfile')); $this->itemdetail->add(new CheckBox('editdelimage')); $this->itemdetail->add(new DropDownChoice('edittype', Item::getTypes())); @@ -131,7 +138,7 @@ public function __construct($add = false) { } - public function itemlistOnRow($row) { + public function itemlistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->setAttribute('style', $item->disabled == 1 ? 'color: #aaa' : null); @@ -163,7 +170,6 @@ public function itemlistOnRow($row) { $row->add(new Label('cell', $item->cell)); - $row->add(new Label('inprice'))->setVisible($item->pricelist); $row->add(new Label('inseria'))->setVisible($item->useserial); $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); @@ -175,6 +181,7 @@ public function itemlistOnRow($row) { $row->add(new \Zippy\Html\Link\BookmarkableLink('imagelistitem'))->setValue("/loadimage.php?id={$item->image_id}"); $row->imagelistitem->setAttribute('href', "/loadimage.php?id={$item->image_id}"); + $row->imagelistitem->setAttribute('data-gallery', $item->image_id); if ($item->image_id == 0) { $row->imagelistitem->setVisible(false); } @@ -225,7 +232,9 @@ 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->editweight->setText($this->_item->weight); + $this->itemdetail->editmaxsize->setText($this->_item->maxsize); + $this->itemdetail->editvolume->setText($this->_item->volume); + $this->itemdetail->editcustomsize->setText($this->_item->customsize); $this->itemdetail->editwarranty->setText($this->_item->warranty); $this->itemdetail->edittype->setValue($this->_item->item_type); @@ -234,12 +243,14 @@ public function editOnClick($sender) { $this->itemdetail->editzarp->setText(\App\Helper::fqty($this->_item->zarp)); $this->itemdetail->editdisabled->setChecked($this->_item->disabled); $this->itemdetail->edituseserial->setChecked($this->_item->useserial); - $this->itemdetail->editpricelist->setChecked($this->_item->pricelist); + $this->itemdetail->editnoshop->setChecked($this->_item->noshop); + $this->itemdetail->editautooutcome->setChecked($this->_item->autooutcome); + $this->itemdetail->editautoincome->setChecked($this->_item->autoincome); if ($this->_item->image_id > 0) { $this->itemdetail->editdelimage->setChecked(false); $this->itemdetail->editdelimage->setVisible(true); $this->itemdetail->editimage->setVisible(true); - $this->itemdetail->editimage->setUrl('/LoadImage.php?id=' . $this->_item->image_id); + $this->itemdetail->editimage->setUrl('/loadimage.php?id=' . $this->_item->image_id); } else { $this->itemdetail->editdelimage->setVisible(false); $this->itemdetail->editimage->setVisible(false); @@ -259,7 +270,10 @@ public function addOnClick($sender) { $this->itemdetail->editmsr->setText('шт'); $this->itemdetail->editimage->setVisible(false); $this->itemdetail->editdelimage->setVisible(false); - $this->itemdetail->editpricelist->setChecked(true); + $this->itemdetail->editnoprice->setChecked(false); + $this->itemdetail->editnoshop->setChecked(false); + $this->itemdetail->editautooutcome->setChecked(false); + $this->itemdetail->editautoincome->setChecked(false); $this->_item = new Item(); if (System::getOption("common", "autoarticle") == 1) { @@ -301,6 +315,9 @@ public function OnSubmit($sender) { $this->_item->bar_code = trim($this->itemdetail->editbarcode->getText()); $this->_item->msr = $this->itemdetail->editmsr->getText(); $this->_item->weight = $this->itemdetail->editweight->getText(); + $this->_item->maxsize = $this->itemdetail->editmaxsize->getText(); + $this->_item->volume = $this->itemdetail->editvolume->getText(); + $this->_item->customsize = $this->itemdetail->editcustomsize->getText(); $this->_item->warranty = $this->itemdetail->editwarranty->getText(); $this->_item->item_type = $this->itemdetail->edittype->getValue(); @@ -311,7 +328,11 @@ public function OnSubmit($sender) { $this->_item->disabled = $this->itemdetail->editdisabled->isChecked() ? 1 : 0; $this->_item->useserial = $this->itemdetail->edituseserial->isChecked() ? 1 : 0; - $this->_item->pricelist = $this->itemdetail->editpricelist->isChecked() ? 1 : 0; + $this->_item->noprice = $this->itemdetail->editnoprice->isChecked() ? 1 : 0; + $this->_item->noshop = $this->itemdetail->editnoshop->isChecked() ? 1 : 0; + $this->_item->autooutcome = $this->itemdetail->editautooutcome->isChecked() ? 1 : 0; + $this->_item->autoincome = $this->itemdetail->editautoincome->isChecked() ? 1 : 0; + //проверка уникальности артикула if (strlen($this->_item->item_code) > 0) { @@ -383,6 +404,24 @@ public function OnSubmit($sender) { $image->content = file_get_contents($file['tmp_name']); $image->mime = $imagedata['mime']; + if ($imagedata[0] != $imagedata[1]) { + $thumb = new \App\Thumb($file['tmp_name']); + if ($imagedata[0] > $imagedata[1]) { + $thumb->cropFromCenter($imagedata[1], $imagedata[1]); + } + if ($imagedata[0] < $imagedata[1]) { + $thumb->cropFromCenter($imagedata[0], $imagedata[0]); + } + + + $image->content = $thumb->getImageAsString(); + $thumb->resize(256, 256); + $image->thumb = $thumb->getImageAsString(); + + + } + + $image->save(); $this->_item->image_id = $image->image_id; $this->_item->Save(); @@ -415,7 +454,7 @@ public function setOnClick($sender) { $this->setpanel->setlist->Reload(); } - public function itemsetlistOnRow($row) { + public function itemsetlistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('sname', $item->itemname)); $row->add(new Label('scode', $item->item_code)); @@ -506,10 +545,7 @@ public function printOnClick($sender) { if (strlen($barcode) == 0) { $barcode = $item->item_code; } - if (($barcode > 0) == false) { - $this->updateAjax(array(), " alert('Не цифровой код')"); - return; - } + $generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); $img = ''; $header['img'] = $img; diff --git a/www/app/pages/reference/mflist.php b/www/app/pages/reference/mflist.php index b4130cf84..0c5df13b2 100644 --- a/www/app/pages/reference/mflist.php +++ b/www/app/pages/reference/mflist.php @@ -50,7 +50,7 @@ public function __construct() { $this->mfdetail->add(new Button('cancel'))->onClick($this, 'cancelOnClick'); } - public function mflistOnRow($row) { + public function mflistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('mf_name', $item->mf_name)); diff --git a/www/app/pages/reference/servicelist.php b/www/app/pages/reference/servicelist.php index 3679e787c..444dc2d77 100644 --- a/www/app/pages/reference/servicelist.php +++ b/www/app/pages/reference/servicelist.php @@ -46,7 +46,7 @@ public function __construct() { $this->servicedetail->add(new Button('cancel'))->onClick($this, 'cancelOnClick'); } - public function servicelistOnRow($row) { + public function servicelistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('service_name', $item->service_name)); diff --git a/www/app/pages/reference/storelist.php b/www/app/pages/reference/storelist.php index cf2d123e7..fb08d08a5 100644 --- a/www/app/pages/reference/storelist.php +++ b/www/app/pages/reference/storelist.php @@ -40,7 +40,7 @@ public function __construct() { $this->storetable->storelist->Reload(); } - public function storelistOnRow($row) { + public function storelistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $row->add(new Label('storename', $item->storename)); diff --git a/www/app/pages/register/doclist.php b/www/app/pages/register/doclist.php index 4a1ee281e..1e206548a 100644 --- a/www/app/pages/register/doclist.php +++ b/www/app/pages/register/doclist.php @@ -145,7 +145,7 @@ public function filterOnSubmit($sender) { } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $doc = $doc->cast(); $row->add(new Label('name', $doc->meta_desc)); @@ -446,7 +446,9 @@ private function getWhere() { if (strlen($sn) > 1) { // игнорируем другие поля $sn = $conn->qstr('%' . $sn . '%'); - $where = " document_number like {$sn} "; + + + $where = " document_number like {$sn} or content like {$sn} or notes like {$sn} "; } diff --git a/www/app/pages/register/gilist.php b/www/app/pages/register/gilist.php index 6aabda897..319512d5e 100644 --- a/www/app/pages/register/gilist.php +++ b/www/app/pages/register/gilist.php @@ -34,7 +34,7 @@ class GIList extends \App\Pages\Base * @param mixed $docid Документ должен быть показан в просмотре * @return DocList */ - public function __construct($doc=0) { + public function __construct($doc = 0) { parent::__construct(); if (false == \App\ACL::checkShowReg('GIList')) { return; @@ -54,7 +54,7 @@ public function __construct($doc=0) { $this->listpan->add(new Paginator('pag', $doclist)); $doclist->setPageSize(H::getPG()); $this->listpan->add(new ClickLink('csv', $this, 'oncsv')); - + $this->add(new Panel("statuspan"))->setVisible(false); @@ -105,12 +105,12 @@ public function __construct($doc=0) { $npform->add(new Label('npttncust')); $npform->add(new Label('npttaddress')); $npform->add(new Label('npttnnotes')); + $npform->add(new Label('printform')); - $npform->add(new DataView('npitemlist', new ArrayDataSource(array()), $this, 'nplistOnRow')); - if($doc>0) { - $this->_doc = Document::load($doc); - $this->npshowOnSubmit( $this->statuspan->statusform->bnp);; + if ($doc > 0) { + $this->_doc = Document::load($doc); + $this->npshowOnSubmit($this->statuspan->statusform->bnp);; } } @@ -122,7 +122,7 @@ public function filterOnSubmit($sender) { } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $row->add(new Label('number', $doc->document_number)); @@ -166,7 +166,7 @@ public function statusOnSubmit($sender) { $this->_doc->save(); - + $this->setSuccess('sent'); } @@ -191,14 +191,14 @@ public function statusOnSubmit($sender) { // $this->_doc->updateStatus(Document::STATE_CLOSED); } - + if ($sender->id == "bdecl") { $dec = $this->statuspan->statusform->ship_number->getText(); if (strlen($dec) > 0) { $this->_doc->headerdata['ship_number'] = $dec; } - $this->_doc->save(); - $this->setSuccess("saved"); + $this->_doc->save(); + $this->setSuccess("saved"); $this->statuspan->setVisible(false); } if ($sender->id == "bttn") { @@ -236,7 +236,7 @@ public function updateStatusButtons() { $this->statuspan->statusform->closeorder->setVisible(false); if ($this->_doc->headerdata['order_id'] > 0) { $order = Document::load($this->_doc->headerdata['order_id']); - if ($order->payamount == $order->payed || $order->headerdata['payment']==0) { + if ($order->payamount == $order->payed || $order->headerdata['payment'] == 0) { $this->statuspan->statusform->closeorder->setVisible(true); } } @@ -393,7 +393,12 @@ public function npshowOnSubmit($sender) { $this->nppan->npform->nppm->setOptionList($stlist); $this->nppan->npform->nppm->setValue('Cash'); - $this->nppan->npform->nppmback->setOptionList($stlist); + $bmlist = array(); + $bmlist['0'] = 'Без доставки'; + $bmlist['Cash'] = 'Наличные'; + $bmlist['NonCash'] = 'Безнал'; + $bmlist['Control'] = 'Контроль доставки'; + $this->nppan->npform->nppmback->setOptionList($bmlist); $this->nppan->npform->nppmback->setValue('Cash'); //кто оплачивает $stlist = array(); @@ -418,28 +423,26 @@ public function npshowOnSubmit($sender) { $this->nppan->npform->selpoint->setValue($modules['nppointref']); } $this->nppan->npform->seltel->setText($modules['nptel']); - $this->nppan->npform->npdesc->setText($this->_doc->notes) ; + $this->nppan->npform->npdesc->setText($this->_doc->notes); $list = $this->_doc->unpackDetails('detaildata'); $w = 0; $p = 0; foreach ($list as $it) { if ($it->weight > 0) { - $w += ($it->weight*$it->quantity); + $w += ($it->weight * $it->quantity); } $p = $p + ($it->quantity * $it->price); } - $this->nppan->npform->npitemlist->getDataSource()->setArray($list); - $this->nppan->npform->npitemlist->Reload(); $this->nppan->npform->npw->setText($w); - $this->nppan->npform->npback->setText(intval($p)); - $this->nppan->npform->npcost->setText(intval($p)); + $this->nppan->npform->npback->setText(round($p)); + $this->nppan->npform->npcost->setText(round($p)); $order = Document::load($this->_doc->parent_id); if ($order instanceof Document) { if ($order->payamount > 0) { - $this->nppan->npform->npback->setText(intval($order->payamount)); - $this->nppan->npform->npcost->setText(intval($order->payamount)); + $this->nppan->npform->npback->setText(round($order->payamount)); + $this->nppan->npform->npcost->setText(round($order->payamount)); } @@ -465,18 +468,12 @@ public function npshowOnSubmit($sender) { $this->nppan->npform->npttncust->setText($cust); $this->nppan->npform->npttaddress->setText($this->_doc->headerdata["ship_address"]); $this->nppan->npform->npttnnotes->setText($this->_doc->notes); - } - public function nplistOnRow($row) { - $item = $row->getDataItem(); - $row->add(new Label("npitemname", $item->itemname)); - $row->add(new Label("npitemcode", $item->item_code)); - $row->add(new Label("npitemw", $item->weight)); - $row->add(new Label("npitemqty", H::fqty($item->quantity))); - $row->add(new Label("npitemprice", H::fa($item->price))); + $this->nppan->npform->printform->setText($this->_doc->cast()->generateReport(), true); } + public function onSelArea($sender) { $api = new \App\Modules\NP\Helper(); @@ -537,18 +534,37 @@ public function npOnSubmit($sender) { $params['CargoType'] = 'Cargo'; $params['Weight'] = $this->nppan->npform->npw->getText(); - if($params['SeatsAmount'] >1) { - $params['Weight'] = number_format($params['Weight'] / $params['SeatsAmount'] , 1, '.', ''); + if ($params['SeatsAmount'] > 1) { + $params['Weight'] = number_format($params['Weight'] / $params['SeatsAmount'], 1, '.', ''); } - + $moneyback = $this->nppan->npform->npback->getText(); + if ($moneyback > 0) { //если введена обратная сумма - $params['BackwardDeliveryData'] = array(array( - 'PayerType' => 'Recipient', - 'CargoType' => 'Money', - 'PaymentMethod' => $this->nppan->npform->nppmback->getValue(), - 'RedeliveryString' => $moneyback) - ); + $back = $this->nppan->npform->nppmback->getValue(); + + if ($back == 'Control') { + $params['AfterpaymentOnGoodsCost'] = $moneyback; + } else { + if ($back == 'Cash') { + $params['BackwardDeliveryData'] = array(array( + 'PayerType' => 'Recipient', + 'CargoType' => 'Money', + 'RedeliveryString' => $moneyback + ) + ); + } else { + if ($back == 'NonCash') { + $params['BackwardDeliveryData'] = array(array( + 'PayerType' => 'Recipient', + 'CargoType' => 'Money', + 'PaymentMethod' => 'NonCash', + 'RedeliveryString' => $moneyback + ) + ); + } + } + } } @@ -615,8 +631,8 @@ public function npOnSubmit($sender) { $recipient['ContactRecipient'] = $result['data'][0]['ContactPerson']['data'][0]['Ref']; $recipient['CityRecipient'] = $this->nppan->npform->baycity->getValue(); $recipient['RecipientsPhone'] = $this->nppan->npform->baytel->getValue(); - // $recipient['Region'] = $this->nppan->npform->bayarea->getValue(); - // $recipient['Warehouse'] = $this->nppan->npform->baypoint->getValue(); + // $recipient['Region'] = $this->nppan->npform->bayarea->getValue(); + // $recipient['Warehouse'] = $this->nppan->npform->baypoint->getValue(); $recipient['RecipientType'] = $result['data'][0]['CounterpartyType']; $recipient['RecipientAddress'] = $this->nppan->npform->baypoint->getValue(); @@ -649,7 +665,7 @@ public function npOnSubmit($sender) { } - + } /** diff --git a/www/app/pages/register/grlist.php b/www/app/pages/register/grlist.php index 0cbc10a98..82a2c4fe3 100644 --- a/www/app/pages/register/grlist.php +++ b/www/app/pages/register/grlist.php @@ -74,7 +74,7 @@ public function filterOnSubmit($sender) { $this->doclist->Reload(); } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $row->add(new Label('number', $doc->document_number)); diff --git a/www/app/pages/register/itemlist.php b/www/app/pages/register/itemlist.php index 06f47f33d..46f333cab 100644 --- a/www/app/pages/register/itemlist.php +++ b/www/app/pages/register/itemlist.php @@ -28,7 +28,7 @@ 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->filter->add(new DropDownChoice('searchcat', Category::getList(), 0)); $this->filter->add(new DropDownChoice('searchstore', Store::getList(), 0)); @@ -54,7 +54,7 @@ public function __construct() { $this->OnFilter(null); } - public function itemlistOnRow($row) { + public function itemlistOnRow(\Zippy\Html\DataList\DataRow $row) { $item = $row->getDataItem(); $store = $this->filter->searchstore->getValue(); diff --git a/www/app/pages/register/ordercustlist.php b/www/app/pages/register/ordercustlist.php index f482fab5f..1fbd2fffb 100644 --- a/www/app/pages/register/ordercustlist.php +++ b/www/app/pages/register/ordercustlist.php @@ -77,7 +77,7 @@ public function filterOnSubmit($sender) { $this->doclist->Reload(); } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $row->add(new Label('number', $doc->document_number)); diff --git a/www/app/pages/register/orderlist.php b/www/app/pages/register/orderlist.php index d56effddf..56ce386ae 100644 --- a/www/app/pages/register/orderlist.php +++ b/www/app/pages/register/orderlist.php @@ -42,7 +42,7 @@ public function __construct() { $this->filter->add(new TextInput('searchnumber')); $this->filter->add(new TextInput('searchtext')); - $this->filter->add(new DropDownChoice('status', array(0 => 'Открытые', 1 => 'Новые', 2 => 'Неоплаченые', 3 => 'Все'), 0)); + $this->filter->add(new DropDownChoice('status', array(0 => 'Открытые', 1 => 'Новые', 3 => 'Все'), 0)); $doclist = $this->add(new DataView('doclist', new OrderDataSource($this), $this, 'doclistOnRow')); $doclist->setSelectedClass('table-success'); @@ -57,7 +57,7 @@ public function __construct() { $this->statuspan->statusform->add(new SubmitButton('bclose'))->onClick($this, 'statusOnSubmit'); $this->statuspan->statusform->add(new SubmitButton('binp'))->onClick($this, 'statusOnSubmit'); $this->statuspan->statusform->add(new SubmitButton('brd'))->onClick($this, 'statusOnSubmit'); - + $this->statuspan->statusform->add(new SubmitButton('binv'))->onClick($this, 'statusOnSubmit'); $this->statuspan->statusform->add(new SubmitButton('bgi'))->onClick($this, 'statusOnSubmit'); $this->statuspan->statusform->add(new SubmitButton('bco'))->onClick($this, 'statusOnSubmit'); @@ -90,7 +90,7 @@ public function filterOnSubmit($sender) { $this->doclist->Reload(); } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $row->add(new Label('number', $doc->document_number)); @@ -99,13 +99,33 @@ public function doclistOnRow($row) { $row->add(new Label('onotes', $doc->notes)); $row->add(new Label('customer', $doc->customer_name)); $row->add(new Label('amount', H::fa($doc->amount))); + $stname = Document::getStateName($doc->state); + + $row->add(new Label('state', $stname)); + if ($doc->state == Document::STATE_NEW) { + $row->state->setText('' . $stname . '', true); + } + if ($doc->state == Document::STATE_READYTOSHIP + || $doc->state == Document::STATE_INSHIPMENT + || $doc->state == Document::STATE_DELIVERED + ) { + $row->state->setText('' . $stname . '', true); + } + if ($doc->state == Document::STATE_INPROCESS) { + $row->state->setText('' . $stname . '', true); + } - $row->add(new Label('state', Document::getStateName($doc->state))); + if ($doc->state == Document::STATE_CLOSED || $doc->state == Document::STATE_EXECUTED) { + $row->state->setText('' . $stname . '', true); + } + if ($doc->state == Document::STATE_FAIL) { + $row->state->setText('' . $stname . '', true); + } $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); $row->add(new ClickLink('pay', $this, 'payOnClick'))->setVisible($doc->payamount > 0 && $doc->payamount > $doc->payed); - + $row->pay->setVisible(false);//убрана оплата в расчеты с контрагентами if ($doc->state < Document::STATE_EXECUTED) { $row->edit->setVisible(true); } else { @@ -133,7 +153,7 @@ public function statusOnSubmit($sender) { if ($sender->id == "binp") { $this->_doc->updateStatus(Document::STATE_INPROCESS); } - if ($sender->id == "brd") { + if ($sender->id == "brd") { $this->_doc->updateStatus(Document::STATE_READYTOSHIP); } if ($sender->id == "bref") { @@ -165,7 +185,7 @@ public function statusOnSubmit($sender) { return; } - if ($sender->id == "bgi") { + if ($sender->id == "bgi") { if ($invoice) { $this->setWarn('goodsissue_exists'); } @@ -173,7 +193,7 @@ public function statusOnSubmit($sender) { return; } if ($sender->id == "bco") { - + App::Redirect("\\App\\Pages\\Doc\\OrderCust", 0, $this->_doc->document_id); return; } @@ -196,7 +216,7 @@ public function updateStatusButtons() { $common = System::getOptions("common"); $this->statuspan->statusform->bclose->setVisible(true); - + $state = $this->_doc->state; //доставлен @@ -207,7 +227,6 @@ public function updateStatusButtons() { $ref = $this->_doc->checkStates(array(Document::STATE_REFUSED)); $this->statuspan->statusform->brd->setVisible(false); - //новый @@ -222,7 +241,7 @@ public function updateStatusButtons() { $this->statuspan->statusform->bco->setVisible(false); $this->statuspan->statusform->binp->setVisible(true); $this->statuspan->statusform->brd->setVisible(false); - + } else { @@ -242,43 +261,43 @@ public function updateStatusButtons() { $this->statuspan->statusform->binv->setVisible(false); $this->statuspan->statusform->bgi->setVisible(false); $this->statuspan->statusform->brd->setVisible(false); - + } - if ($state == Document::STATE_INPROCESS) { + if ($state == Document::STATE_INPROCESS) { $this->statuspan->statusform->brd->setVisible(true); - - + + $this->statuspan->statusform->bttn->setVisible(true); $this->statuspan->statusform->binv->setVisible(true); $this->statuspan->statusform->bgi->setVisible(true); - - } - if ($state == Document::STATE_INSHIPMENT) { - + + } + if ($state == Document::STATE_INSHIPMENT) { + $this->statuspan->statusform->bttn->setVisible(false); $this->statuspan->statusform->binv->setVisible(false); $this->statuspan->statusform->bgi->setVisible(false); $this->statuspan->statusform->btask->setVisible(false); - - } + + } if ($state == Document::STATE_READYTOSHIP) { - + $this->statuspan->statusform->bttn->setVisible(true); $this->statuspan->statusform->binv->setVisible(false); $this->statuspan->statusform->bgi->setVisible(true); $this->statuspan->statusform->btask->setVisible(false); - - } - if ($state == Document::STATE_DELIVERED) { - + + } + if ($state == Document::STATE_DELIVERED) { + $this->statuspan->statusform->bttn->setVisible(false); $this->statuspan->statusform->binv->setVisible(false); $this->statuspan->statusform->bgi->setVisible(false); $this->statuspan->statusform->btask->setVisible(false); $this->statuspan->statusform->bref->setVisible(false); - - } + + } //закрыт if ($state == Document::STATE_CLOSED) { @@ -291,11 +310,11 @@ public function updateStatusButtons() { $this->statuspan->statusform->bttn->setVisible(false); $this->statuspan->statusform->setVisible(false); $this->statuspan->statusform->brd->setVisible(false); - - } + + } if ($this->_doc->payamount > 0 && $this->_doc->payamount > $this->_doc->payed) { - $this->statuspan->statusform->bclose->setVisible(false); + // $this->statuspan->statusform->bclose->setVisible(false); } @@ -318,12 +337,13 @@ public function updateStatusButtons() { $this->statuspan->statusform->bgi->setVisible(false); } - + $list = $this->_doc->getChildren('Invoice'); - if(count($list) > 0) $this->statuspan->statusform->binv->setVisible(false); + if (count($list) > 0) { + $this->statuspan->statusform->binv->setVisible(false); + } - } @@ -501,7 +521,7 @@ private function getWhere() { $status = $this->page->filter->status->getValue(); if ($status == 0) { - $where .= " and state <> 9 "; + $where .= " and state not in (9,17) "; } if ($status == 1) { $where .= " and state =1 "; diff --git a/www/app/pages/register/paybaylist.php b/www/app/pages/register/paybaylist.php index 5677e0ddf..c265864ec 100644 --- a/www/app/pages/register/paybaylist.php +++ b/www/app/pages/register/paybaylist.php @@ -29,7 +29,7 @@ class PayBayList extends \App\Pages\Base public $_pays = array(); public $_totamount = 0; - private $_docs = " and ( meta_name in('GoodsIssue','Invoice','RetCustIssue','PosCheck','ServiceAct','Order') or (meta_name='IncomeMoney' and content like '%1%' ) or (meta_name='OutcomeMoney' and content like '%2%' )) "; + private $_docs = " and ( meta_name in('GoodsIssue','Invoice' ,'PosCheck','ServiceAct','Order') or (meta_name='IncomeMoney' and content like '%1%' ) or (meta_name='OutcomeMoney' and content like '%2%' )) "; private $_state = "1,2,3,17,8"; @@ -100,7 +100,7 @@ public function updateCust() { select customer_id, (case when meta_name='OutcomeMoney' then (payed - payamount ) else (payamount - payed) end) as sam from `documents_view` where {$br} (payamount >0 or payed >0) {$this->_docs} and state not in ({$this->_state}) and ( (meta_name <>'POSCheck' and payamount <> payed) or(meta_name = 'POSCheck' and payamount > payed )) - ) t join customers c on t.customer_id = c.customer_id {$hold} + ) t join customers c on t.customer_id = c.customer_id and c.status=0 {$hold} group by c.customer_name,c.phone, c.customer_id having sam <> 0 order by c.customer_name "; @@ -115,7 +115,7 @@ public function updateCust() { } - public function custlistOnRow($row) { + public function custlistOnRow(\Zippy\Html\DataList\DataRow $row) { $cust = $row->getDataItem(); $row->add(new RedirectLink('customer_name', "\\App\\Pages\\Reference\\CustomerList", array($cust->customer_id)))->setValue($cust->customer_name); $row->add(new Label('phone', $cust->phone)); @@ -149,8 +149,19 @@ public function updateDocs() { $br = " {$c} and "; } + $this->_doclist = array(); - $this->_doclist = \App\Entity\Doc\Document::find(" {$br} customer_id= {$this->_cust->customer_id} and (payamount >0 or payed >0) and ( (meta_name <>'POSCheck' and payamount <> payed) or(meta_name = 'POSCheck' and payamount > payed )) and state not in ({$this->_state}) {$this->_docs} ", "document_date"); + $list = \App\Entity\Doc\Document::find(" {$br} customer_id= {$this->_cust->customer_id} and (payamount >0 or payed >0) and ( (meta_name <>'POSCheck' and payamount <> payed) or(meta_name = 'POSCheck' and payamount > payed )) and state not in ({$this->_state}) {$this->_docs} ", "document_date desc, document_id desc"); + $sum = 0; + + foreach ($list as $d) { + $this->_doclist[] = $d; + $sum += ($d->payamount - $d->payed); + if ($this->_cust->sam == $sum) { + break; + } + } + $this->_doclist = array_reverse($this->_doclist); $this->plist->doclist->Reload(); } @@ -173,6 +184,7 @@ public function doclistOnRow($row) { $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); $row->add(new ClickLink('pay'))->onClick($this, 'payOnClick'); + $row->pay->setVisible($doc->payamount > 0); } //просмотр @@ -213,6 +225,10 @@ public function payOnClick($sender) { $this->plist->doclist->Reload(false); $this->goAnkor('dankor'); + $amount = $this->_doc->payamount - $this->_doc->payed; + if ($amount > $this->_cust->sam) { + $amount = $this->_cust->sam; + } $this->paypan->payform->pamount->setText(H::fa($this->_doc->payamount - $this->_doc->payed)); $this->paypan->payform->pcomment->setText("");; @@ -292,8 +308,9 @@ public function payOnSubmit($sender) { $this->setSuccess('payment_added'); - $this->updateDocs(); + //$this->updateDocs(); $this->paypan->setVisible(false); + $this->onBack(null); } public function oncsv($sender) { diff --git a/www/app/pages/register/paylist.php b/www/app/pages/register/paylist.php index b1f1539f0..ac9d33d5a 100644 --- a/www/app/pages/register/paylist.php +++ b/www/app/pages/register/paylist.php @@ -16,6 +16,7 @@ use Zippy\Html\Form\TextInput; use Zippy\Html\Label; use Zippy\Html\Link\ClickLink; +use Zippy\Html\Link\BookmarkableLink; /** * журнал платежей @@ -74,7 +75,7 @@ public function OnAutoCustomer($sender) { return Customer::getList($sender->getText()); } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $row->add(new Label('number', $doc->document_number)); @@ -92,8 +93,11 @@ public function doclistOnRow($row) { $row->add(new ClickLink('show', $this, 'showOnClick')); $user = \App\System::getUser(); - // $row->add(new ClickLink('del'))->setVisible($user->rolename == 'admins'); - // $row->del->setAttribute('onclick', "delpay({$doc->pl_id})"); + $row->add(new BookmarkableLink('del'))->setVisible($user->rolename == 'admins'); + $row->del->setAttribute('onclick', "delpay({$doc->pl_id})"); + + $row->add(new ClickLink('print'))->onClick($this, 'printOnClick', true); + } //просмотр @@ -116,9 +120,11 @@ public function delOnClick($sender) { $id = $sender->pl_id->getText(); $pl = Pay::load($id); + + $doc = Document::load($pl->document_id); - // Pay::cancelPayment($id, $sender->notes->getText()); - Pay::delete($id); + Pay::cancelPayment($id, $sender->notes->getText()); + $conn = \ZDB\DB::getConnect(); $sql = "select coalesce(abs(sum(amount)),0) from paylist where document_id=" . $pl->document_id; @@ -163,7 +169,7 @@ public function oncsv($sender) { $i = 1; foreach ($list as $doc) { $i++; - $data['A' . $i] = H::fd(strtotime($doc->paydate)); + $data['A' . $i] = H::fd($doc->paydate); $data['B' . $i] = $doc->mf_name; $data['C' . $i] = ($doc->amount > 0 ? H::fa($doc->amount) : ""); $data['D' . $i] = ($doc->amount < 0 ? H::fa(0 - $doc->amount) : ""); @@ -177,6 +183,28 @@ public function oncsv($sender) { H::exportExcel($data, $header, 'paylist.xlsx'); } + public function printOnClick($sender) { + $pay = $sender->getOwner()->getDataItem(); + $doc = \App\Entity\Doc\Document::load($pay->document_id); + + $header = array(); + $header['document_number'] = $doc->document_number; + $header['firm_name'] = $doc->firm_name; + $header['customer_name'] = $doc->customer_name; + $list = Pay::find("document_id=" . $pay->document_id, "pl_id"); + $all = 0; + $header['plist'] = array(); + foreach ($list as $p) { + $header['plist'][] = array('ppay' => H::fa(abs($p->amount)), 'pdate' => H::fd($p->paydate)); + $all += abs($p->amount); + } + $header['pall'] = H::fa($all); + + $report = new \App\Report('pays_bill.tpl'); + + $html = $report->generate($header); + $this->updateAjax(array(), " $('#paysprint').html('{$html}') ; $('#pform').modal()"); + } } @@ -197,7 +225,7 @@ private function getWhere() { $conn = \ZDB\DB::getConnect(); - $where = " 1=1 "; + $where = " d.customer_id in(select customer_id from customers where status=0)"; $author = $this->page->filter->fuser->getValue(); $type = $this->page->filter->ftype->getValue(); diff --git a/www/app/pages/register/paysellist.php b/www/app/pages/register/paysellist.php index b6ec66afa..ba35b9304 100644 --- a/www/app/pages/register/paysellist.php +++ b/www/app/pages/register/paysellist.php @@ -27,7 +27,7 @@ class PaySelList extends \App\Pages\Base public $_doclist = array(); public $_pays = array(); public $_totamount = 0; - private $_docs = " and ( meta_name in('GoodsReceipt','InvoiceCust','ReturnIssue') or (meta_name='OutcomeMoney' and content like '%1%' ) or (meta_name='IncomeMoney' and content like '%2%' )) "; + private $_docs = " and ( meta_name in('GoodsReceipt','InvoiceCust' ) or (meta_name='OutcomeMoney' and content like '%1%' ) or (meta_name='IncomeMoney' and content like '%2%' )) "; private $_state = "1,2,3,17,8"; @@ -98,7 +98,7 @@ public function updateCust() { select customer_id, (case when meta_name='IncomeMoney' then (payed - payamount ) else (payamount - payed) end) as sam from `documents_view` where {$br} customer_id > 0 {$this->_docs} and state > 3 and (payamount >0 or payed >0) and payamount <> payed - ) t join customers c on t.customer_id = c.customer_id {$hold} + ) t join customers c on t.customer_id = c.customer_id and c.status=0 {$hold} group by c.customer_name,c.phone, c.customer_id having sam <> 0 order by c.customer_name "; @@ -112,7 +112,7 @@ public function updateCust() { } - public function custlistOnRow($row) { + public function custlistOnRow(\Zippy\Html\DataList\DataRow $row) { $cust = $row->getDataItem(); $row->add(new RedirectLink('customer_name', "\\App\\Pages\\Reference\\CustomerList", array($cust->customer_id)))->setValue($cust->customer_name); $row->add(new Label('phone', $cust->phone)); @@ -144,9 +144,19 @@ public function updateDocs() { if (strlen($c) > 0) { $br = " {$c} and "; } + $this->_doclist = array(); + $list = \App\Entity\Doc\Document::find(" {$br} customer_id= {$this->_cust->customer_id} and (payamount > 0 or payed >0) and payamount <> payed and state > 3 {$this->_docs} ", " document_date desc, document_id desc"); + $sum = 0; - $this->_doclist = \App\Entity\Doc\Document::find(" {$br} customer_id= {$this->_cust->customer_id} and (payamount > 0 or payed >0) and payamount <> payed and state > 3 {$this->_docs} ", "document_date"); + foreach ($list as $d) { + $this->_doclist[] = $d; + $sum += ($d->payamount - $d->payed); + if ($this->_cust->sam == $sum) { + break; + } + } + $this->_doclist = array_reverse($this->_doclist); $this->plist->doclist->Reload(); } @@ -170,6 +180,7 @@ public function doclistOnRow($row) { $row->add(new ClickLink('show'))->onClick($this, 'showOnClick'); $row->add(new ClickLink('pay'))->onClick($this, 'payOnClick'); + $row->pay->setVisible($doc->payamount > 0); } //просмотр @@ -210,8 +221,11 @@ public function payOnClick($sender) { $this->plist->doclist->Reload(false); $this->goAnkor('dankor'); - - $this->paypan->payform->pamount->setText(H::fa($this->_doc->payamount - $this->_doc->payed)); + $amount = $this->_doc->payamount - $this->_doc->payed; + if ($amount > $this->_cust->sam) { + $amount = $this->_cust->sam; + } + $this->paypan->payform->pamount->setText(H::fa($amount)); $this->paypan->payform->pcomment->setText("");; $this->paypan->pname->setText($this->_doc->document_number);; @@ -289,8 +303,9 @@ public function payOnSubmit($sender) { $this->setSuccess('payment_added'); - $this->updateDocs(); + //$this->updateDocs(); $this->paypan->setVisible(false); + $this->onBack(null); } public function oncsv($sender) { diff --git a/www/app/pages/register/serlist.php b/www/app/pages/register/serlist.php index 3c237e364..805c311bb 100644 --- a/www/app/pages/register/serlist.php +++ b/www/app/pages/register/serlist.php @@ -73,10 +73,10 @@ public function filterOnSubmit($sender) { $this->statuspan->setVisible(false); - $this->doclist->Reload( ); + $this->doclist->Reload(); } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); $row->add(new Label('number', $doc->document_number)); diff --git a/www/app/pages/register/stocklist.php b/www/app/pages/register/stocklist.php index 1e9cf1e19..52db41bfa 100644 --- a/www/app/pages/register/stocklist.php +++ b/www/app/pages/register/stocklist.php @@ -46,7 +46,7 @@ public function __construct() { $this->add(new Paginator('pag', $doclist)); $doclist->setPageSize(H::getPG()); - + $this->add(new \App\Widgets\DocView('docview'))->setVisible(false); } @@ -61,7 +61,7 @@ public function filterOnSubmit($sender) { $this->doclist->Reload(); } - public function doclistOnRow($row) { + public function doclistOnRow(\Zippy\Html\DataList\DataRow $row) { $doc = $row->getDataItem(); @@ -100,7 +100,7 @@ public function showOnClick($sender) { $this->docview->setVisible(true); $this->docview->setDoc($this->_doc); } - + } /** diff --git a/www/app/pages/register/tasklist.php b/www/app/pages/register/tasklist.php index 327125b9a..136cc3829 100644 --- a/www/app/pages/register/tasklist.php +++ b/www/app/pages/register/tasklist.php @@ -74,7 +74,7 @@ public function __construct() { $this->tasktab->statuspan->add(new \App\Widgets\DocView('docview')); - $this->caltab->add(new \App\Calendar('calendar' ))->setEvent($this, 'OnCal'); + $this->caltab->add(new \App\Calendar('calendar'))->setEvent($this, 'OnCal'); $this->updateTasks(); $this->updateCal(); @@ -92,11 +92,11 @@ public function onTab($sender) { $this->tasktab->setVisible($sender->id == 'tabs'); $this->updateTasks(); $this->updateCal(); - + } - public function tasklistOnRow($row) { + public function tasklistOnRow(\Zippy\Html\DataList\DataRow $row) { $task = $row->getDataItem(); $row->add(new Label('tasknumber', $task->document_number)); @@ -104,20 +104,20 @@ public function tasklistOnRow($row) { $row->add(new Label('taskdocument_date', H::fdt($task->headerdata['start']))); $row->add(new Label('taskhours', $task->headerdata['taskhours'])); - - $row->add(new Label('taskstatus', Document::getStateName($task->state))); + $stname = Document::getStateName($task->state); + $row->add(new Label('taskstatus', $stname)); if ($task->state == Document::STATE_EXECUTED) { - $row->taskstatus->setText('Выполнен', true); + $row->taskstatus->setText('' . $stname . '', true); } if ($task->state == Document::STATE_INPROCESS) { - $row->taskstatus->setText('Выполняется', true); + $row->taskstatus->setText('' . $stname . '', true); } if ($task->state == Document::STATE_SHIFTED) { - $row->taskstatus->setText('Отложена', true); + $row->taskstatus->setText('' . $stname . '', true); } if ($task->state == Document::STATE_CLOSED) { - $row->taskstatus->setText('Закончено', true); + $row->taskstatus->setText('' . $stname . '', true); } $emps = array(); @@ -288,10 +288,10 @@ public function updateCal() { } if (strlen($item->headerdata['taskhours']) == 0) { $item->headerdata['taskhours'] = 0; - } - $d = ($item->headerdata['taskhours'] ); - $end_date = $item->headerdata['start'] + round(3600 * $d) ; - + } + $d = ($item->headerdata['taskhours']); + $end_date = $item->headerdata['start'] + round(3600 * $d); + $tasks[] = new \App\CEvent($item->document_id, $item->document_number, $item->headerdata['start'], $end_date, $col); } @@ -311,7 +311,7 @@ public function OnCal($sender, $action) { if ($action['action'] == 'click') { $task = Document::load($action['id']); - + $class = "\\App\\Pages\\Doc\\Task"; @@ -326,50 +326,49 @@ public function OnCal($sender, $action) { return; } if ($task->state == Document::STATE_CLOSED) { - return; - } + return; + } if ($action['action'] == 'move') { $task = Task::load($action['id']); - - if($action['years'] <> 0) { - $task->headerdata['start'] = strtotime($action['years'] .' years',$task->headerdata['start']) ; - + + if ($action['years'] <> 0) { + $task->headerdata['start'] = strtotime($action['years'] . ' years', $task->headerdata['start']); + } - if($action['months'] <> 0) { - $task->headerdata['start'] = strtotime($action['months'] .' months',$task->headerdata['start']) ; - + if ($action['months'] <> 0) { + $task->headerdata['start'] = strtotime($action['months'] . ' months', $task->headerdata['start']); + } - if($action['days'] <> 0) { - $task->headerdata['start'] = strtotime($action['days'] .' days',$task->headerdata['start']) ; + if ($action['days'] <> 0) { + $task->headerdata['start'] = strtotime($action['days'] . ' days', $task->headerdata['start']); } - if($action['ms'] <> 0) { - $task->headerdata['start'] = $task->headerdata['start'] + $action['ms']; + if ($action['ms'] <> 0) { + $task->headerdata['start'] = $task->headerdata['start'] + $action['ms']; } - + $task->document_date = $task->headerdata['start']; - - - + + } if ($action['action'] == 'resize') { $task = Document::load($action['id']); - if($action['startdelta'] !=0) { - $task->document_date = $task->document_date + ($action['startdelta'] ); - $task->headerdata['start'] = $task->headerdata['start'] + ($action['enddelta']/3600 ) ; - $task->headerdata['taskhours'] = $task->headerdata['taskhours'] + (0-$action['enddelta']/3600 ); - + if ($action['startdelta'] != 0) { + $task->document_date = $task->document_date + ($action['startdelta']); + $task->headerdata['start'] = $task->headerdata['start'] + ($action['enddelta'] / 3600); + $task->headerdata['taskhours'] = $task->headerdata['taskhours'] + (0 - $action['enddelta'] / 3600); + } - if($action['enddelta'] != 0) { - $task->headerdata['taskhours'] = $task->headerdata['taskhours'] + $action['enddelta']/3600 ; - + if ($action['enddelta'] != 0) { + $task->headerdata['taskhours'] = $task->headerdata['taskhours'] + $action['enddelta'] / 3600; + } - - + + } - $task->save(); - - // $this->updateCal(); - // $this->updateTasks(); + $task->save(); + + // $this->updateCal(); + // $this->updateTasks(); } public function OnFilter($sender) { diff --git a/www/app/pages/report/abc.php b/www/app/pages/report/abc.php index b6e75d9c3..4f88cd0af 100644 --- a/www/app/pages/report/abc.php +++ b/www/app/pages/report/abc.php @@ -222,7 +222,7 @@ private function find4() { $list = array(); $conn = \ZDB\DB::getConnect(); $sql = "SELECT * FROM ( - SELECT services.service_name as name, SUM( ABS( entrylist_view.amount*entrylist_view.quantity ) ) AS value + SELECT services.service_name as name, SUM( ABS( entrylist_view.amount ) ) AS value FROM `entrylist_view` join services on entrylist_view.service_id = services.service_id join documents_view on entrylist_view.document_id = documents_view.document_id diff --git a/www/app/pages/report/outcome.php b/www/app/pages/report/outcome.php index ca853c3e7..9127c07dc 100644 --- a/www/app/pages/report/outcome.php +++ b/www/app/pages/report/outcome.php @@ -32,7 +32,7 @@ public function __construct() { $this->filter->add(new Date('from', time() - (7 * 24 * 3600))); $this->filter->add(new Date('to', time())); $this->filter->add(new DropDownChoice('emp', \App\Entity\User::findArray('username', "user_id in (select user_id from documents_view where meta_name in('GoodsIssue','ServiceAct','Task','Order','POSCheck','TTN') {$br} )", 'username'), 0)); - $this->filter->add(new DropDownChoice('cat', \App\Entity\Category::findArray('cat_name', "", 'cat_name'), 0))->setVisible(false); + $this->filter->add(new DropDownChoice('cat', \App\Entity\Category::getList(), 0))->setVisible(false); $hlist = \App\Entity\Customer::getHoldList(); // $this->filter->add(new DropDownChoice('holding', $hlist, 0))->setVisible(false); @@ -45,9 +45,12 @@ public function __construct() { $types[4] = H::l('repbyservices'); $types[7] = H::l('repbybyersservices'); $types[5] = H::l('repbycat'); + if (count($hlist) > 0) { $types[8] = H::l('repbyhold'); } + $types[9] = H::l('repbybyfirm'); + $types[10] = H::l('repbybystore'); $this->filter->add(new DropDownChoice('type', $types, 1))->onChange($this, "OnType"); @@ -135,7 +138,6 @@ private function generateReport() { $br = " and d.branch_id in ({$brids}) "; } - $detail = array(); @@ -163,7 +165,7 @@ private function generateReport() { $sql = ''; if ($type == 1 || $type == 6 || strlen($cat) > 0) { //по товарам $sql = " - select i.`itemname`,i.`item_code`,sum(0-e.`quantity`) as qty, sum(0-e.`amount`) as summa, sum(e.extcode*(0-e.`quantity`)) as navar + select i.`itemname`,i.`item_code`,sum(0-e.`quantity`) as qty, sum(0-e.quantity*e.partion) as summa, sum(e.extcode*(0-e.`quantity`)) as navar from `entrylist_view` e join `items_view` i on e.`item_id` = i.`item_id` @@ -180,7 +182,7 @@ private function generateReport() { if ($type == 2) { //по покупателям $empty = H::l("emptycust"); $sql = " - select coalesce(c.`customer_name`,'{$empty}') as itemname,c.`customer_id`, sum(0-e.`amount`) as summa, sum(e.extcode*(0-e.`quantity`)) as navar + select coalesce(c.`customer_name`,'{$empty}') as itemname,c.`customer_id`, sum(0-e.quantity*e.partion) as summa, sum(e.extcode*(0-e.`quantity`)) as navar from `entrylist_view` e left join `customers` c on c.`customer_id` = e.`customer_id` @@ -195,7 +197,7 @@ private function generateReport() { } if ($type == 3) { //по датам $sql = " - select e.`document_date` as dt , sum(0-e.`amount`) as summa ,0 as navar + select e.`document_date` as dt , sum(0-e.quantity*e.partion) as summa ,0 as navar from `entrylist_view` e join `items` i on e.`item_id` = i.`item_id` @@ -226,7 +228,7 @@ private function generateReport() { if ($type == 5 && strlen($cat) == 0) { //по категориях $sql = " - select i.`cat_name` as itemname,sum(0-e.`quantity`) as qty, sum(0-e.`amount`) as summa, sum(e.extcode*(0-e.`quantity`)) as navar + select i.`cat_name` as itemname,sum(0-e.`quantity`) as qty, sum(0- e.quantity*e.partion) as summa, sum(e.extcode*(0-e.`quantity`)) as navar from `entrylist_view` e join `items_view` i on e.`item_id` = i.`item_id` @@ -281,6 +283,43 @@ private function generateReport() { } + if ($type == 9) { //по компаниям + $sql = " + select d.`firm_name` as itemname,sum(0-e.`quantity`) as qty, sum(0-e.`amount`) as summa, sum(e.extcode*(0-e.`quantity`)) as navar + from `entrylist_view` e + + + join `documents_view` d on d.`document_id` = e.`document_id` + where d.`firm_id` >0 and e.`quantity` <>0 + and d.`meta_name` in ('GoodsIssue', 'POSCheck','ReturnIssue','TTN') + {$br} {$u} + AND DATE(e.document_date) >= " . $conn->DBDate($from) . " + AND DATE(e.document_date) <= " . $conn->DBDate($to) . " + group by d.`firm_name` + order by d.`firm_name` + "; + } + if ($type == 10) { //по складах + $sql = " + select sr.`storename` as itemname,sum(0-e.`quantity`) as qty, sum(0-e.quantity*e.partion) as summa, sum(e.extcode*(0-e.`quantity`)) as navar + from `entrylist_view` e + + + join `store_stock` st on e.`stock_id` = st.`stock_id` + join `stores` sr on sr.`store_id` = st.`store_id` + + join `documents_view` d on d.`document_id` = e.`document_id` + where d.`firm_id` >0 and e.`quantity` <>0 + and d.`meta_name` in ('GoodsIssue', 'POSCheck','ReturnIssue','TTN') + {$br} {$u} + AND DATE(e.document_date) >= " . $conn->DBDate($from) . " + AND DATE(e.document_date) <= " . $conn->DBDate($to) . " + group by sr.`storename` + order by sr.`storename` + "; + } + + $totsum = 0; $totnavar = 0; @@ -322,42 +361,38 @@ private function generateReport() { $header['isdisc'] = $disc > 0; $header['totall'] = H::fa($totsum - $disc); + $header['_type1'] = false; + $header['_type2'] = false; + $header['_type3'] = false; + $header['_type4'] = false; + $header['_type5'] = false; + $header['_type6'] = false; + $header['_type7'] = false; if ($type == 1 || $type == 6 || strlen($cat) > 0) { $header['_type1'] = true; - $header['_type2'] = false; - $header['_type3'] = false; - $header['_type4'] = false; - $header['_type5'] = false; + } if ($type == 2 || $type == 8) { - $header['_type1'] = false; + $header['_type2'] = true; - $header['_type3'] = false; - $header['_type4'] = false; - $header['_type5'] = false; + } if ($type == 3) { - $header['_type1'] = false; - $header['_type2'] = false; $header['_type3'] = true; - $header['_type4'] = false; - $header['_type5'] = false; } if ($type == 4 || $type == 7) { - $header['_type1'] = false; - $header['_type2'] = false; - $header['_type3'] = false; $header['_type4'] = true; - $header['_type5'] = false; } if ($type == 5 && strlen($cat) == 0) { - $header['_type1'] = false; - $header['_type2'] = false; - $header['_type3'] = false; - $header['_type4'] = false; $header['_type5'] = true; } + if ($type == 9) { + $header['_type6'] = true; + } + if ($type == 10) { + $header['_type7'] = true; + } $report = new \App\Report('report/outcome.tpl'); diff --git a/www/app/pages/roles.php b/www/app/pages/roles.php index 7ff0b7138..4bf3bd6f6 100644 --- a/www/app/pages/roles.php +++ b/www/app/pages/roles.php @@ -51,7 +51,7 @@ public function __construct() { //виджеты - + $this->editpan->editform->add(new CheckBox('editwminqty')); $this->editpan->editform->add(new CheckBox('editwsdate')); $this->editpan->editform->add(new CheckBox('editwrdoc')); @@ -149,8 +149,6 @@ public function OnAcl($sender) { $this->editpan->editform->metaaccess->metarow->Reload(); - - if (strpos($this->role->widgets, 'wminqty') !== false) { $this->editpan->editform->editwminqty->setChecked(true); } @@ -274,7 +272,6 @@ public function saveaclOnClick($sender) { $widgets = ""; - if ($this->editpan->editform->editwminqty->isChecked()) { $widgets = $widgets . ',wminqty'; } diff --git a/www/app/pages/service/armfood.php b/www/app/pages/service/armfood.php new file mode 100644 index 000000000..a7a7430df --- /dev/null +++ b/www/app/pages/service/armfood.php @@ -0,0 +1,39 @@ +add(new Label('amount', H::fa($item->quantity * $item->price))); $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); + $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); } public function serOnRow($row) { @@ -254,7 +256,7 @@ public function serOnRow($row) { $row->add(new Label('seramount', H::fa($item->quantity * $item->price))); $row->add(new ClickLink('serdelete'))->onClick($this, 'serdeleteOnClick'); - // $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); + $row->add(new ClickLink('seredit'))->onClick($this, 'sereditOnClick'); } public function addcodeOnClick($sender) { @@ -321,26 +323,50 @@ public function addcodeOnClick($sender) { $this->calcTotal(); } - public function deleteOnClick($sender) { + public function editOnClick($sender) { + $tovar = $sender->owner->getDataItem(); + $this->editdetail->setVisible(true); + $this->editdetail->edittovar->setKey($tovar->item_id); + $this->editdetail->edittovar->setText($tovar->itemname); + $this->editdetail->editquantity->setText($tovar->quantity); + $this->editdetail->editprice->setText($tovar->price); + $this->editdetail->editserial->setText($tovar->snumber); + $this->editdetail->qtystock->setText(""); + $this->form2->setVisible(false); + $this->_rowid = $tovar->rowid; + } + + public function deleteOnClick($sender) { $tovar = $sender->owner->getDataItem(); - // unset($this->_itemlist[$tovar->tovar_id]); - $this->_itemlist = array_diff_key($this->_itemlist, array($tovar->item_id => $this->_itemlist[$tovar->item_id])); + $this->_itemlist = array_diff_key($this->_itemlist, array($tovar->rowid => $this->_itemlist[$tovar->rowid])); $this->form2->detail->Reload(); $this->calcTotal(); } + public function sereditOnClick($sender) { + $ser = $sender->owner->getDataItem(); + $this->editserdetail->setVisible(true); + $this->editserdetail->editser->setKey($ser->service_id); + $this->editserdetail->editser->setText($ser->service_name); + $this->editserdetail->editserquantity->setText($ser->quantity); + $this->editserdetail->editserprice->setText($ser->price); + + $this->form2->setVisible(false); + $this->_rowid = $ser->rowid; + + } + public function serdeleteOnClick($sender) { if (false == \App\ACL::checkEditDoc($this->_doc)) { return; } $ser = $sender->owner->getDataItem(); - // unset($this->_itemlist[$tovar->tovar_id]); - $this->_serlist = array_diff_key($this->_serlist, array($ser->service_id => $this->_serlist[$ser->service_id])); + $this->_serlist = array_diff_key($this->_serlist, array($ser->rowid => $this->_serlist[$ser->rowid])); $this->form2->detailser->Reload(); $this->calcTotal(); } @@ -351,6 +377,7 @@ public function addrowOnClick($sender) { $this->editdetail->editprice->setText("0"); $this->editdetail->qtystock->setText(""); $this->form2->setVisible(false); + $this->_rowid = 0; } public function addserOnClick($sender) { @@ -359,6 +386,7 @@ public function addserOnClick($sender) { $this->editserdetail->editserprice->setText("0"); $this->form2->setVisible(false); + $this->_rowid = 0; } public function saverowOnClick($sender) { @@ -394,8 +422,17 @@ public function saverowOnClick($sender) { } } + if ($this->_rowid > 0) { + $item->rowid = $this->_rowid; + } else { + $next = count($this->_itemlist) > 0 ? max(array_keys($this->_itemlist)) : 0; + $item->rowid = $next + 1; + } + $this->_itemlist[$item->rowid] = $item; + + $this->_rowid = 0; + - $this->_itemlist[$item->item_id] = $item; $this->editdetail->setVisible(false); $this->form2->setVisible(true); @@ -424,9 +461,19 @@ public function saveserOnClick($sender) { $ser->quantity = $this->editserdetail->editserquantity->getText(); - $ser->price =H::fa( $this->editserdetail->editserprice->getText()); + $ser->price = H::fa($this->editserdetail->editserprice->getText()); + + if ($this->_rowid > 0) { + $ser->rowid = $this->_rowid; + } else { + $next = count($this->_serlist) > 0 ? max(array_keys($this->_serlist)) : 0; + $ser->rowid = $next + 1; + } + $this->_serlist[$ser->rowid] = $ser; + + $this->_rowid = 0; + - $this->_serlist[$ser->service_id] = $ser; $this->editserdetail->setVisible(false); $this->form2->setVisible(true); $this->form2->detailser->Reload(); diff --git a/www/app/pages/subscribes.php b/www/app/pages/subscribes.php index 6668eb5ca..cd551cef5 100644 --- a/www/app/pages/subscribes.php +++ b/www/app/pages/subscribes.php @@ -1,5 +1,5 @@ rolename != 'admins') { System::setErrorMsg(H::l('onlyadminsaccess')); \App\Application::RedirectError(); return false; } $this->add(new Panel('plist')); - $this->plist->add(new ClickLink('addnew',$this,'onAdd')); - - $this->plist->add(new DataView('subslist', new ArrayDataSource($this,'_subslist'), $this, 'sublistOnRow')); - + $this->plist->add(new ClickLink('addnew', $this, 'onAdd')); + + $this->plist->add(new DataView('subslist', new ArrayDataSource($this, '_subslist'), $this, 'sublistOnRow')); + $this->add(new Form('editform'))->setVisible(false); $this->editform->add(new CheckBox('editdisabled')); $this->editform->add(new TextArea('editmsgtext')); $this->editform->add(new TextInput('editmsgsubject')); - $this->editform->add(new DropDownChoice('editeventtype', Subscribe::getEventList(),Subscribe::EVENT_DOCSTATE))->onChange($this,'update'); - $this->editform->add(new DropDownChoice('editdoctype', H::getDocTypes(),0)); - $this->editform->add(new DropDownChoice('editstate', \App\Entity\Doc\Document::getStateList(),0)); - $this->editform->add(new DropDownChoice('editrecievertype', Subscribe::getRecieverList(),Subscribe::RSV_CUSTOMER))->onChange($this,'update'); - $this->editform->add(new DropDownChoice('editmsgtype', Subscribe::getMsgTypeList(),0))->onChange($this,'update');; - $this->editform->add(new DropDownChoice('edituser', \App\Entity\User::findArray('username','','username'),0)); - - + $this->editform->add(new DropDownChoice('editeventtype', Subscribe::getEventList(), Subscribe::EVENT_DOCSTATE))->onChange($this, 'update'); + $this->editform->add(new DropDownChoice('editdoctype', H::getDocTypes(), 0)); + $this->editform->add(new DropDownChoice('editstate', \App\Entity\Doc\Document::getStateList(), 0)); + $this->editform->add(new DropDownChoice('editrecievertype', Subscribe::getRecieverList(), Subscribe::RSV_CUSTOMER))->onChange($this, 'update'); + $this->editform->add(new DropDownChoice('editmsgtype', Subscribe::getMsgTypeList(), 0))->onChange($this, 'update');; + $this->editform->add(new DropDownChoice('edituser', \App\Entity\User::findArray('username', '', 'username'), 0)); + + $this->editform->add(new SubmitButton('save'))->onClick($this, 'OnSave'); $this->editform->add(new ClickLink('cancel'))->onClick($this, 'OnCancel'); $this->editform->add(new ClickLink('delete'))->onClick($this, 'OnDelete'); - $this->Reload() ; + $this->Reload(); } - public function update($sender){ - $et = $this->editform->editeventtype->getValue(); - - $this->editform->editdoctype->setVisible($et==Subscribe::EVENT_DOCSTATE) ; - $this->editform->editstate->setVisible($et==Subscribe::EVENT_DOCSTATE) ; - $rt = $this->editform->editrecievertype->getValue(); - $this->editform->edituser->setVisible($rt==Subscribe::RSV_USER) ; - $mt = $this->editform->editmsgtype->getValue(); - $this->editform->editmsgsubject->setVisible($mt==Subscribe::MSG_EMAIL) ; - + + public function update($sender) { + $et = $this->editform->editeventtype->getValue(); + + $this->editform->editdoctype->setVisible($et == Subscribe::EVENT_DOCSTATE); + $this->editform->editstate->setVisible($et == Subscribe::EVENT_DOCSTATE); + $rt = $this->editform->editrecievertype->getValue(); + $this->editform->edituser->setVisible($rt == Subscribe::RSV_USER); + $mt = $this->editform->editmsgtype->getValue(); + $this->editform->editmsgsubject->setVisible($mt == Subscribe::MSG_EMAIL); + } - + public function sublistOnRow($row) { - $sub = $row->getDataItem(); - - $row->add(new Label('sub_typename',$sub->sub_typename)); - $row->add(new Label('msg_typename',$sub->msg_typename)); - $row->add(new Label('reciever_typename',$sub->reciever_typename)); - $desc=array(); - if($sub->doctype>0) $desc[]= $sub->doctypename ; - if($sub->state>0) $desc[]= $sub->statename ; - if($sub->user_id>0) $desc[]= $sub->username ; - $row->add(new Label('desc',implode(', ',$desc))); - - - $row->add(new ClickLink('edit',$this,'OnEdit')); + $sub = $row->getDataItem(); + + $row->add(new Label('sub_typename', $sub->sub_typename)); + $row->add(new Label('msg_typename', $sub->msg_typename)); + $row->add(new Label('reciever_typename', $sub->reciever_typename)); + $desc = array(); + if ($sub->doctype > 0) { + $desc[] = $sub->doctypename; + } + if ($sub->state > 0) { + $desc[] = $sub->statename; + } + if ($sub->user_id > 0) { + $desc[] = $sub->username; + } + $row->add(new Label('desc', implode(', ', $desc))); + + + $row->add(new ClickLink('edit', $this, 'OnEdit')); $row->setAttribute('style', $sub->disabled == 1 ? 'color: #aaa' : null); - + } - + public function onAdd($sender) { $this->plist->setVisible(false); $this->editform->setVisible(true); $this->editform->clean(); $this->_sub = new Subscribe(); - $this->editform->editeventtype->setValue(Subscribe::EVENT_DOCSTATE) ; - $this->editform->editrecievertype->setValue(Subscribe::EVENT_DOCSTATE) ; - $this->update($this->editform->editeventtype) ; + $this->editform->editeventtype->setValue(Subscribe::EVENT_DOCSTATE); + $this->editform->editrecievertype->setValue(Subscribe::EVENT_DOCSTATE); + $this->update($this->editform->editeventtype); } - public function OnEdit($sender) { - $this->_sub = $sender->getOwner()->getDataItem(); + + public function OnEdit($sender) { + $this->_sub = $sender->getOwner()->getDataItem(); $this->editform->editeventtype->setValue($this->_sub->sub_type); $this->editform->editrecievertype->setValue($this->_sub->reciever_type); @@ -107,77 +115,79 @@ public function OnEdit($sender) { $this->editform->edituser->setValue($this->_sub->user_id); $this->editform->editdoctype->setValue($this->_sub->doctype); $this->editform->editstate->setValue($this->_sub->state); - - $this->editform->editmsgtext->setText($this->_sub->msgtext) ; - $this->editform->editmsgsubject->setText($this->_sub->msgsubject) ; - $this->editform->editdisabled->setCheCked($this->_sub->disabled) ; - - $this->update($this->editform->editeventtype) ; + + $this->editform->editmsgtext->setText($this->_sub->msgtext); + $this->editform->editmsgsubject->setText($this->_sub->msgsubject); + $this->editform->editdisabled->setCheCked($this->_sub->disabled); + + $this->update($this->editform->editeventtype); $this->plist->setVisible(false); $this->editform->setVisible(true); - + } + public function OnSave($sender) { - - - $this->_sub->sub_type = $this->editform->editeventtype->getValue(); - $this->_sub->sub_typename = $this->editform->editeventtype->getValueName(); - $this->_sub->reciever_type = $this->editform->editrecievertype->getValue(); - $this->_sub->reciever_typename = $this->editform->editrecievertype->getValueName(); - $this->_sub->msg_type = $this->editform->editmsgtype->getValue(); - $this->_sub->msg_typename = $this->editform->editmsgtype->getValueName(); - $this->_sub->user_id = $this->editform->edituser->getValue(); - $this->_sub->username = $this->editform->edituser->getValueName(); - $this->_sub->doctype = $this->editform->editdoctype->getValue(); - $this->_sub->doctypename = $this->editform->editdoctype->getValueName(); - $this->_sub->state = $this->editform->editstate->getValue(); - $this->_sub->statename = $this->editform->editstate->getValueName(); - - $this->_sub->msgtext = trim($this->editform->editmsgtext->getText()) ; - $this->_sub->msgsubject = trim($this->editform->editmsgsubject->getText()) ; - $this->_sub->disabled = $this->editform->editdisabled->isCheCked() ? 1:0; - - if( $this->_sub->msg_type==0) { - $this->setError('sb_errmtype') ; + + + $this->_sub->sub_type = $this->editform->editeventtype->getValue(); + $this->_sub->sub_typename = $this->editform->editeventtype->getValueName(); + $this->_sub->reciever_type = $this->editform->editrecievertype->getValue(); + $this->_sub->reciever_typename = $this->editform->editrecievertype->getValueName(); + $this->_sub->msg_type = $this->editform->editmsgtype->getValue(); + $this->_sub->msg_typename = $this->editform->editmsgtype->getValueName(); + $this->_sub->user_id = $this->editform->edituser->getValue(); + $this->_sub->username = $this->editform->edituser->getValueName(); + $this->_sub->doctype = $this->editform->editdoctype->getValue(); + $this->_sub->doctypename = $this->editform->editdoctype->getValueName(); + $this->_sub->state = $this->editform->editstate->getValue(); + $this->_sub->statename = $this->editform->editstate->getValueName(); + + $this->_sub->msgtext = trim($this->editform->editmsgtext->getText()); + $this->_sub->msgsubject = trim($this->editform->editmsgsubject->getText()); + $this->_sub->disabled = $this->editform->editdisabled->isCheCked() ? 1 : 0; + + if ($this->_sub->msg_type == 0) { + $this->setError('sb_errmtype'); return; } - if( $this->_sub->reciever_type==Subscribe::RSV_USER && $this->_sub->user_id==0) { - $this->setError('sb_erruser') ; + if ($this->_sub->reciever_type == Subscribe::RSV_USER && $this->_sub->user_id == 0) { + $this->setError('sb_erruser'); return; } - - if(strlen($this->_sub->msgtext)==0) { - $this->setError('sb_errtext') ; + + if (strlen($this->_sub->msgtext) == 0) { + $this->setError('sb_errtext'); return; - + } $this->_sub->save(); - $this->Reload() ; + $this->Reload(); $this->plist->setVisible(true); $this->editform->setVisible(false); - + } - + public function OnCancel($sender) { $this->plist->setVisible(true); $this->editform->setVisible(false); - + // $this->Reload() ; } - public function OnDelete($sender) { + + public function OnDelete($sender) { $this->plist->setVisible(true); $this->editform->setVisible(false); - - Subscribe::delete($this->_sub->sub_id) ; - $this->Reload() ; + + Subscribe::delete($this->_sub->sub_id); + $this->Reload(); } - - + + public function Reload() { - - $this->_subslist = Subscribe::find('') ; - - $this->plist->subslist->Reload() ; + + $this->_subslist = Subscribe::find(''); + + $this->plist->subslist->Reload(); } - + } diff --git a/www/app/pages/timesheet.php b/www/app/pages/timesheet.php index 6df6ffc8c..9603947ba 100644 --- a/www/app/pages/timesheet.php +++ b/www/app/pages/timesheet.php @@ -76,7 +76,7 @@ public function __construct() { $tagen->add(new DataView('llist', new ArrayDataSource($this, '_list'), $this, 'listOnRow')); $tstat->add(new DataView('lstat', new ArrayDataSource($this, '_stat'), $this, 'statOnRow')); - $tcal->add(new \App\Calendar('calendar' ))->setEvent($this, 'OnCal'); + $tcal->add(new \App\Calendar('calendar'))->setEvent($this, 'OnCal'); $this->add(new Form('editform'))->onSubmit($this, 'timeOnSubmit'); @@ -220,7 +220,7 @@ private function updateCal() { foreach ($this->_list as $item) { $col = "#bbb"; - + if ($item->t_type == TimeItem::TIME_WORK) { $col = "#007bff"; } diff --git a/www/app/pages/userlogin.php b/www/app/pages/userlogin.php index e24e8a312..18026a376 100644 --- a/www/app/pages/userlogin.php +++ b/www/app/pages/userlogin.php @@ -31,7 +31,7 @@ public function __construct() { $this->setError(''); - $curver = 'v4.8.5'; + $curver = 'v4.9.0'; $this->_tvars['curversion'] = $curver; //проверка новой версии @@ -86,7 +86,7 @@ public function onsubmit($sender) { $user = Helper::login($login, $password); if ($user instanceof User) { - \App\Session::getSession()->clean() ; + \App\Session::getSession()->clean(); $user->lastlogin = time(); $user->save(); System::setUser($user); @@ -97,7 +97,10 @@ public function onsubmit($sender) { setcookie("remember", $user->user_id . '_' . md5($user->user_id . $_config['common']['salt']), time() + 60 * 60 * 24 * 30); } - + if ($_COOKIE['branch_id'] > 0) { + System::getSession()->defbranch = $_COOKIE['branch_id']; + } + if ($_config['modules']['shop'] == 1) { App::Redirect('\App\Pages\Main'); } else { diff --git a/www/app/pages/users.php b/www/app/pages/users.php index 78f9ac5fd..7a27fd277 100644 --- a/www/app/pages/users.php +++ b/www/app/pages/users.php @@ -72,7 +72,7 @@ public function onAdd($sender) { $this->editpan->setVisible(true); // Очищаем форму $this->editpan->editform->clean(); - + $this->editpan->editform->brow->Reload(); $this->user = new User(); } @@ -103,15 +103,15 @@ public function onEdit($sender) { public function saveOnClick($sender) { - $emp = \App\Entity\Employee::getByLogin($this->user->userlogin) ; - + $emp = \App\Entity\Employee::getByLogin($this->user->userlogin); + $this->user->email = $this->editpan->editform->editemail->getText(); - $this->user->userlogin = $this->editpan->editform->editlogin->getText(); - if ($emp != null && $this->user->userlogin != $emp->login){ - $emp->login = $this->user->userlogin; + $this->user->userlogin = $this->editpan->editform->editlogin->getText(); + if ($emp != null && $this->user->userlogin != $emp->login) { + $emp->login = $this->user->userlogin; $emp->save(); } - + $user = User::getByLogin($this->user->userlogin); if ($user instanceof User) { if ($user->user_id != $this->user->user_id) { diff --git a/www/app/session.php b/www/app/session.php index 8e96d2e5c..21ac2145a 100644 --- a/www/app/session.php +++ b/www/app/session.php @@ -36,9 +36,9 @@ public static function getSession() { return $_SESSION['App_session']; } - public function clean(){ - $this->values = array(); - $this->filter = array(); - + public function clean() { + $this->values = array(); + $this->filter = array(); + } } diff --git a/www/app/widgets/docview.php b/www/app/widgets/docview.php index 5c500dd83..cbde1e239 100644 --- a/www/app/widgets/docview.php +++ b/www/app/widgets/docview.php @@ -36,11 +36,13 @@ public function __construct($id) { parent::__construct($id); $this->add(new BookmarkableLink('print', "")); + $this->add(new RedirectLink('printmob', "")); $this->add(new RedirectLink('html', ""))->setVisible(false); $this->add(new RedirectLink('word', "")); $this->add(new RedirectLink('excel', "")); $this->add(new RedirectLink('pdf', "")); $this->add(new BookmarkableLink('pos', "")); + $this->add(new RedirectLink('posmob', "")); $this->add(new ClickLink('email', $this, "onMail")); $this->add(new Label('preview')); @@ -110,10 +112,15 @@ public function setDoc(\App\Entity\Doc\Document $doc) { $this->email->setVisible(in_array(Document::EX_MAIL, $exportlist)); $reportpage = "App/Pages/ShowDoc"; - - - // $this->print->pagename = $reportpage; - // $this->print->params = array('print', $doc->document_id); + + $this->printmob->pagename = $reportpage; + $this->printmob->params = array('print', $doc->document_id); + + $this->posmob->pagename = $reportpage; + $this->posmob->params = array('pos', $doc->document_id); + + + $this->html->pagename = $reportpage; $this->html->params = array('html', $doc->document_id); $this->word->pagename = $reportpage; @@ -122,8 +129,6 @@ public function setDoc(\App\Entity\Doc\Document $doc) { $this->excel->params = array('xls', $doc->document_id); $this->pdf->pagename = $reportpage; $this->pdf->params = array('pdf', $doc->document_id); - // $this->pos->pagename = $reportpage; - // $this->pos->params = array('pos', $doc->document_id); $this->updateMessages(); @@ -144,7 +149,7 @@ public function setDoc(\App\Entity\Doc\Document $doc) { $this->dw_paylist->Reload(); //проводки - $sql = " select e.entry_id, s.stock_id, s.itemname,s.item_code,e.quantity,e.amount from entrylist e join store_stock_view s on e.stock_id = s.stock_id where coalesce(e.quantity,0) <> 0 and document_id=" . $this->_doc->document_id . " order by s.itemname"; + $sql = " select e.entry_id, s.stock_id, s.itemname,s.item_code,e.quantity,e.amount from entrylist e join store_stock_view s on e.stock_id = s.stock_id where coalesce(e.quantity,0) <> 0 and document_id=" . $this->_doc->document_id . " order by e.entry_id"; $this->_itemlist = \App\Entity\Entry::findBySql($sql); $this->dw_itemlist->Reload(); diff --git a/www/app/widgets/itemsel.php b/www/app/widgets/itemsel.php index 0ff091ac2..4ec73f78e 100644 --- a/www/app/widgets/itemsel.php +++ b/www/app/widgets/itemsel.php @@ -40,7 +40,7 @@ public function __construct($id, $page, $event) { $this->add(new Form('wisfilter'))->onSubmit($this, 'ReloadData'); $this->wisfilter->add(new TextInput('wissearchkey')); - $this->wisfilter->add(new DropDownChoice('wissearchcat', Category::findArray("cat_name", "", "cat_name"), 0)); + $this->wisfilter->add(new DropDownChoice('wissearchcat', Category::getList(), 0)); $this->wisfilter->add(new TextInput('wissearchmanufacturer')); diff --git a/www/assets/css/shop.css b/www/assets/css/shop.css index 4db8da8a7..ee96c1e29 100644 --- a/www/assets/css/shop.css +++ b/www/assets/css/shop.css @@ -7,33 +7,59 @@ } .container-fluid { height: 65px; - background-color: #333; - color: #fff; - border-radius: 0 0 30px 30px; + + } -.container-fluid-img { - font-size: 20pt; - background-color: #333; - color: #fff; - font-style: italic; +.container-fluid-img img { + height: 65px; + + } -.subcatlist { - margin-bottom: 10px; +.logo-text:hover { + text-decoration: none !important; } +a.container-fluid-img { + font-size: 24px; + +} +.wrapper { + min-height: 100vh; +} +.content { + flex: 1 0 auto; +} +.ribbon-wrap { + position: absolute; + top: 0; + left: 0; + z-index: 1; + display: flex; + flex-direction: column; + align-items: flex-start; +} +.ribbon { + display: inline-block; + margin-top: 15px; + padding: 2px 15px; + color: #000; +} + + .header { + border-bottom: 1px solid #ced4da; + background-color: #eee; + } .footer { text-align: center; background-color: #333; color: #fff; + flex: 0 0 auto; bottom: 0; - width: 100%; - border-radius: 30px 30px 0 0; - height: 100px; } .footer a { @@ -41,70 +67,25 @@ text-decoration: none; } -.breadcrumb { - margin-top: 1%; - margin-bottom: 2%; - background-color: #343a40; - border: 1mm solid #00000; - border-radius: 40px 10px; - font-style: italic; -} - -.breadcrumb a { - font-size:16px; - color: #fff; - font-weight:bold; -} - -.breadcrumb a:hover { - font-size:16px; - color:#ff6600; - font-weight:bold; -} - -.breadcrumb-item.active { - color: rgba(255, 255, 255, 0.8); -} - -.breadcrumb-item.active a { - font-size:16px; - color: rgba(255, 255, 255, 0.8); - font-weight:bold; - + +.card-custom-title { + flex: 1 1 auto; } - -.breadcrumb-item.active a:hover { - font-size:16px; - color:#28a745; - font-weight:bold; +.card-custom-body { + flex-direction: column; + height: 100%; } - -a { - color:#28a745; - font-weight:bold; - text-decoration:none; -} - -a:hover { - color:#ff6600; - font-weight:bold; - text-decoration:none; +.card-custom-card { + height: 100%; } - -.btn-outline-info { - margin-left: 2px; +.searchform-search { + cursor: pointer; + border-radius: 0 4px 4px 0; } - - -.sfilter { - padding: 10px; - border: 2px solid #343a40; - border-radius: 10px 10px 10px 10px; -} .newlist { - margin-bottom: 10px; + } @@ -114,11 +95,11 @@ a:hover { } .fa-star { - color: #ffd600; + color: orange; } .card-body { - padding: 0; + padding: 0; } a:not([href]) { @@ -150,14 +131,7 @@ a:not([href]):hover { color: #17a2b8; } -b { - font-size:16px; color:#17a2b8; font-weight:bold -} - -span { - color:#17a2b8; - font-weight:bold -} + .rating-symbol-foreground { color: red; @@ -175,7 +149,7 @@ span { .price-arrow{ font-size:14px; - + } .list-group-item-action { @@ -195,4 +169,15 @@ span { padding:04px; } - \ No newline at end of file +.compareimage { + height:256px ; +} +.comparetable { + +} +.comparetable td { + padding:8px; +} +.comparetable th { + padding:8px; +} \ No newline at end of file diff --git a/www/assets/images/noimage.jpg b/www/assets/images/noimage.jpg index a8163d8d2..0ffc9f294 100644 Binary files a/www/assets/images/noimage.jpg and b/www/assets/images/noimage.jpg differ diff --git a/www/assets/js/mustache.js b/www/assets/js/mustache.js new file mode 100644 index 000000000..8cad81638 --- /dev/null +++ b/www/assets/js/mustache.js @@ -0,0 +1,764 @@ +/*! + * mustache.js - Logic-less {{mustache}} templates with JavaScript + * http://github.com/janl/mustache.js + */ + +var objectToString = Object.prototype.toString; +var isArray = Array.isArray || function isArrayPolyfill (object) { + return objectToString.call(object) === '[object Array]'; +}; + +function isFunction (object) { + return typeof object === 'function'; +} + +/** + * More correct typeof string handling array + * which normally returns typeof 'object' + */ +function typeStr (obj) { + return isArray(obj) ? 'array' : typeof obj; +} + +function escapeRegExp (string) { + return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&'); +} + +/** + * Null safe way of checking whether or not an object, + * including its prototype, has a given property + */ +function hasProperty (obj, propName) { + return obj != null && typeof obj === 'object' && (propName in obj); +} + +/** + * Safe way of detecting whether or not the given thing is a primitive and + * whether it has the given property + */ +function primitiveHasOwnProperty (primitive, propName) { + return ( + primitive != null + && typeof primitive !== 'object' + && primitive.hasOwnProperty + && primitive.hasOwnProperty(propName) + ); +} + +// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577 +// See https://github.com/janl/mustache.js/issues/189 +var regExpTest = RegExp.prototype.test; +function testRegExp (re, string) { + return regExpTest.call(re, string); +} + +var nonSpaceRe = /\S/; +function isWhitespace (string) { + return !testRegExp(nonSpaceRe, string); +} + +var entityMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '/': '/', + '`': '`', + '=': '=' +}; + +function escapeHtml (string) { + return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { + return entityMap[s]; + }); +} + +var whiteRe = /\s*/; +var spaceRe = /\s+/; +var equalsRe = /\s*=/; +var curlyRe = /\s*\}/; +var tagRe = /#|\^|\/|>|\{|&|=|!/; + +/** + * Breaks up the given `template` string into a tree of tokens. If the `tags` + * argument is given here it must be an array with two string values: the + * opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of + * course, the default is to use mustaches (i.e. mustache.tags). + * + * A token is an array with at least 4 elements. The first element is the + * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag + * did not contain a symbol (i.e. {{myValue}}) this element is "name". For + * all text that appears outside a symbol this element is "text". + * + * The second element of a token is its "value". For mustache tags this is + * whatever else was inside the tag besides the opening symbol. For text tokens + * this is the text itself. + * + * The third and fourth elements of the token are the start and end indices, + * respectively, of the token in the original template. + * + * Tokens that are the root node of a subtree contain two more elements: 1) an + * array of tokens in the subtree and 2) the index in the original template at + * which the closing tag for that section begins. + * + * Tokens for partials also contain two more elements: 1) a string value of + * indendation prior to that tag and 2) the index of that tag on that line - + * eg a value of 2 indicates the partial is the third tag on this line. + */ +function parseTemplate (template, tags) { + if (!template) + return []; + var lineHasNonSpace = false; + var sections = []; // Stack to hold section tokens + var tokens = []; // Buffer to hold the tokens + var spaces = []; // Indices of whitespace tokens on the current line + var hasTag = false; // Is there a {{tag}} on the current line? + var nonSpace = false; // Is there a non-space char on the current line? + var indentation = ''; // Tracks indentation for tags that use it + var tagIndex = 0; // Stores a count of number of tags encountered on a line + + // Strips all whitespace tokens array for the current line + // if there was a {{#tag}} on it and otherwise only space. + function stripSpace () { + if (hasTag && !nonSpace) { + while (spaces.length) + delete tokens[spaces.pop()]; + } else { + spaces = []; + } + + hasTag = false; + nonSpace = false; + } + + var openingTagRe, closingTagRe, closingCurlyRe; + function compileTags (tagsToCompile) { + if (typeof tagsToCompile === 'string') + tagsToCompile = tagsToCompile.split(spaceRe, 2); + + if (!isArray(tagsToCompile) || tagsToCompile.length !== 2) + throw new Error('Invalid tags: ' + tagsToCompile); + + openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*'); + closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1])); + closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1])); + } + + compileTags(tags || mustache.tags); + + var scanner = new Scanner(template); + + var start, type, value, chr, token, openSection; + while (!scanner.eos()) { + start = scanner.pos; + + // Match any text between tags. + value = scanner.scanUntil(openingTagRe); + + if (value) { + for (var i = 0, valueLength = value.length; i < valueLength; ++i) { + chr = value.charAt(i); + + if (isWhitespace(chr)) { + spaces.push(tokens.length); + indentation += chr; + } else { + nonSpace = true; + lineHasNonSpace = true; + indentation += ' '; + } + + tokens.push([ 'text', chr, start, start + 1 ]); + start += 1; + + // Check for whitespace on the current line. + if (chr === '\n') { + stripSpace(); + indentation = ''; + tagIndex = 0; + lineHasNonSpace = false; + } + } + } + + // Match the opening tag. + if (!scanner.scan(openingTagRe)) + break; + + hasTag = true; + + // Get the tag type. + type = scanner.scan(tagRe) || 'name'; + scanner.scan(whiteRe); + + // Get the tag value. + if (type === '=') { + value = scanner.scanUntil(equalsRe); + scanner.scan(equalsRe); + scanner.scanUntil(closingTagRe); + } else if (type === '{') { + value = scanner.scanUntil(closingCurlyRe); + scanner.scan(curlyRe); + scanner.scanUntil(closingTagRe); + type = '&'; + } else { + value = scanner.scanUntil(closingTagRe); + } + + // Match the closing tag. + if (!scanner.scan(closingTagRe)) + throw new Error('Unclosed tag at ' + scanner.pos); + + if (type == '>') { + token = [ type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace ]; + } else { + token = [ type, value, start, scanner.pos ]; + } + tagIndex++; + tokens.push(token); + + if (type === '#' || type === '^') { + sections.push(token); + } else if (type === '/') { + // Check section nesting. + openSection = sections.pop(); + + if (!openSection) + throw new Error('Unopened section "' + value + '" at ' + start); + + if (openSection[1] !== value) + throw new Error('Unclosed section "' + openSection[1] + '" at ' + start); + } else if (type === 'name' || type === '{' || type === '&') { + nonSpace = true; + } else if (type === '=') { + // Set the tags for the next time around. + compileTags(value); + } + } + + stripSpace(); + + // Make sure there are no open sections when we're done. + openSection = sections.pop(); + + if (openSection) + throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos); + + return nestTokens(squashTokens(tokens)); +} + +/** + * Combines the values of consecutive text tokens in the given `tokens` array + * to a single token. + */ +function squashTokens (tokens) { + var squashedTokens = []; + + var token, lastToken; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + token = tokens[i]; + + if (token) { + if (token[0] === 'text' && lastToken && lastToken[0] === 'text') { + lastToken[1] += token[1]; + lastToken[3] = token[3]; + } else { + squashedTokens.push(token); + lastToken = token; + } + } + } + + return squashedTokens; +} + +/** + * Forms the given array of `tokens` into a nested tree structure where + * tokens that represent a section have two additional items: 1) an array of + * all tokens that appear in that section and 2) the index in the original + * template that represents the end of that section. + */ +function nestTokens (tokens) { + var nestedTokens = []; + var collector = nestedTokens; + var sections = []; + + var token, section; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + token = tokens[i]; + + switch (token[0]) { + case '#': + case '^': + collector.push(token); + sections.push(token); + collector = token[4] = []; + break; + case '/': + section = sections.pop(); + section[5] = token[2]; + collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens; + break; + default: + collector.push(token); + } + } + + return nestedTokens; +} + +/** + * A simple string scanner that is used by the template parser to find + * tokens in template strings. + */ +function Scanner (string) { + this.string = string; + this.tail = string; + this.pos = 0; +} + +/** + * Returns `true` if the tail is empty (end of string). + */ +Scanner.prototype.eos = function eos () { + return this.tail === ''; +}; + +/** + * Tries to match the given regular expression at the current position. + * Returns the matched text if it can match, the empty string otherwise. + */ +Scanner.prototype.scan = function scan (re) { + var match = this.tail.match(re); + + if (!match || match.index !== 0) + return ''; + + var string = match[0]; + + this.tail = this.tail.substring(string.length); + this.pos += string.length; + + return string; +}; + +/** + * Skips all text until the given regular expression can be matched. Returns + * the skipped string, which is the entire tail if no match can be made. + */ +Scanner.prototype.scanUntil = function scanUntil (re) { + var index = this.tail.search(re), match; + + switch (index) { + case -1: + match = this.tail; + this.tail = ''; + break; + case 0: + match = ''; + break; + default: + match = this.tail.substring(0, index); + this.tail = this.tail.substring(index); + } + + this.pos += match.length; + + return match; +}; + +/** + * Represents a rendering context by wrapping a view object and + * maintaining a reference to the parent context. + */ +function Context (view, parentContext) { + this.view = view; + this.cache = { '.': this.view }; + this.parent = parentContext; +} + +/** + * Creates a new context using the given view with this context + * as the parent. + */ +Context.prototype.push = function push (view) { + return new Context(view, this); +}; + +/** + * Returns the value of the given name in this context, traversing + * up the context hierarchy if the value is absent in this context's view. + */ +Context.prototype.lookup = function lookup (name) { + var cache = this.cache; + + var value; + if (cache.hasOwnProperty(name)) { + value = cache[name]; + } else { + var context = this, intermediateValue, names, index, lookupHit = false; + + while (context) { + if (name.indexOf('.') > 0) { + intermediateValue = context.view; + names = name.split('.'); + index = 0; + + /** + * Using the dot notion path in `name`, we descend through the + * nested objects. + * + * To be certain that the lookup has been successful, we have to + * check if the last object in the path actually has the property + * we are looking for. We store the result in `lookupHit`. + * + * This is specially necessary for when the value has been set to + * `undefined` and we want to avoid looking up parent contexts. + * + * In the case where dot notation is used, we consider the lookup + * to be successful even if the last "object" in the path is + * not actually an object but a primitive (e.g., a string, or an + * integer), because it is sometimes useful to access a property + * of an autoboxed primitive, such as the length of a string. + **/ + while (intermediateValue != null && index < names.length) { + if (index === names.length - 1) + lookupHit = ( + hasProperty(intermediateValue, names[index]) + || primitiveHasOwnProperty(intermediateValue, names[index]) + ); + + intermediateValue = intermediateValue[names[index++]]; + } + } else { + intermediateValue = context.view[name]; + + /** + * Only checking against `hasProperty`, which always returns `false` if + * `context.view` is not an object. Deliberately omitting the check + * against `primitiveHasOwnProperty` if dot notation is not used. + * + * Consider this example: + * ``` + * Mustache.render("The length of a football field is {{#length}}{{length}}{{/length}}.", {length: "100 yards"}) + * ``` + * + * If we were to check also against `primitiveHasOwnProperty`, as we do + * in the dot notation case, then render call would return: + * + * "The length of a football field is 9." + * + * rather than the expected: + * + * "The length of a football field is 100 yards." + **/ + lookupHit = hasProperty(context.view, name); + } + + if (lookupHit) { + value = intermediateValue; + break; + } + + context = context.parent; + } + + cache[name] = value; + } + + if (isFunction(value)) + value = value.call(this.view); + + return value; +}; + +/** + * A Writer knows how to take a stream of tokens and render them to a + * string, given a context. It also maintains a cache of templates to + * avoid the need to parse the same template twice. + */ +function Writer () { + this.templateCache = { + _cache: {}, + set: function set (key, value) { + this._cache[key] = value; + }, + get: function get (key) { + return this._cache[key]; + }, + clear: function clear () { + this._cache = {}; + } + }; +} + +/** + * Clears all cached templates in this writer. + */ +Writer.prototype.clearCache = function clearCache () { + if (typeof this.templateCache !== 'undefined') { + this.templateCache.clear(); + } +}; + +/** + * Parses and caches the given `template` according to the given `tags` or + * `mustache.tags` if `tags` is omitted, and returns the array of tokens + * that is generated from the parse. + */ +Writer.prototype.parse = function parse (template, tags) { + var cache = this.templateCache; + var cacheKey = template + ':' + (tags || mustache.tags).join(':'); + var isCacheEnabled = typeof cache !== 'undefined'; + var tokens = isCacheEnabled ? cache.get(cacheKey) : undefined; + + if (tokens == undefined) { + tokens = parseTemplate(template, tags); + isCacheEnabled && cache.set(cacheKey, tokens); + } + return tokens; +}; + +/** + * High-level method that is used to render the given `template` with + * the given `view`. + * + * The optional `partials` argument may be an object that contains the + * names and templates of partials that are used in the template. It may + * also be a function that is used to load partial templates on the fly + * that takes a single argument: the name of the partial. + * + * If the optional `config` argument is given here, then it should be an + * object with a `tags` attribute or an `escape` attribute or both. + * If an array is passed, then it will be interpreted the same way as + * a `tags` attribute on a `config` object. + * + * The `tags` attribute of a `config` object must be an array with two + * string values: the opening and closing tags used in the template (e.g. + * [ "<%", "%>" ]). The default is to mustache.tags. + * + * The `escape` attribute of a `config` object must be a function which + * accepts a string as input and outputs a safely escaped string. + * If an `escape` function is not provided, then an HTML-safe string + * escaping function is used as the default. + */ +Writer.prototype.render = function render (template, view, partials, config) { + var tags = this.getConfigTags(config); + var tokens = this.parse(template, tags); + var context = (view instanceof Context) ? view : new Context(view, undefined); + return this.renderTokens(tokens, context, partials, template, config); +}; + +/** + * Low-level method that renders the given array of `tokens` using + * the given `context` and `partials`. + * + * Note: The `originalTemplate` is only ever used to extract the portion + * of the original template that was contained in a higher-order section. + * If the template doesn't use higher-order sections, this argument may + * be omitted. + */ +Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) { + var buffer = ''; + + var token, symbol, value; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + value = undefined; + token = tokens[i]; + symbol = token[0]; + + if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate, config); + else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate, config); + else if (symbol === '>') value = this.renderPartial(token, context, partials, config); + else if (symbol === '&') value = this.unescapedValue(token, context); + else if (symbol === 'name') value = this.escapedValue(token, context, config); + else if (symbol === 'text') value = this.rawValue(token); + + if (value !== undefined) + buffer += value; + } + + return buffer; +}; + +Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) { + var self = this; + var buffer = ''; + var value = context.lookup(token[1]); + + // This function is used to render an arbitrary template + // in the current context by higher-order sections. + function subRender (template) { + return self.render(template, context, partials, config); + } + + if (!value) return; + + if (isArray(value)) { + for (var j = 0, valueLength = value.length; j < valueLength; ++j) { + buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config); + } + } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') { + buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config); + } else if (isFunction(value)) { + if (typeof originalTemplate !== 'string') + throw new Error('Cannot use higher-order sections without the original template'); + + // Extract the portion of the original template that the section contains. + value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender); + + if (value != null) + buffer += value; + } else { + buffer += this.renderTokens(token[4], context, partials, originalTemplate, config); + } + return buffer; +}; + +Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate, config) { + var value = context.lookup(token[1]); + + // Use JavaScript's definition of falsy. Include empty arrays. + // See https://github.com/janl/mustache.js/issues/186 + if (!value || (isArray(value) && value.length === 0)) + return this.renderTokens(token[4], context, partials, originalTemplate, config); +}; + +Writer.prototype.indentPartial = function indentPartial (partial, indentation, lineHasNonSpace) { + var filteredIndentation = indentation.replace(/[^ \t]/g, ''); + var partialByNl = partial.split('\n'); + for (var i = 0; i < partialByNl.length; i++) { + if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) { + partialByNl[i] = filteredIndentation + partialByNl[i]; + } + } + return partialByNl.join('\n'); +}; + +Writer.prototype.renderPartial = function renderPartial (token, context, partials, config) { + if (!partials) return; + var tags = this.getConfigTags(config); + + var value = isFunction(partials) ? partials(token[1]) : partials[token[1]]; + if (value != null) { + var lineHasNonSpace = token[6]; + var tagIndex = token[5]; + var indentation = token[4]; + var indentedValue = value; + if (tagIndex == 0 && indentation) { + indentedValue = this.indentPartial(value, indentation, lineHasNonSpace); + } + var tokens = this.parse(indentedValue, tags); + return this.renderTokens(tokens, context, partials, indentedValue, config); + } +}; + +Writer.prototype.unescapedValue = function unescapedValue (token, context) { + var value = context.lookup(token[1]); + if (value != null) + return value; +}; + +Writer.prototype.escapedValue = function escapedValue (token, context, config) { + var escape = this.getConfigEscape(config) || mustache.escape; + var value = context.lookup(token[1]); + if (value != null) + return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value); +}; + +Writer.prototype.rawValue = function rawValue (token) { + return token[1]; +}; + +Writer.prototype.getConfigTags = function getConfigTags (config) { + if (isArray(config)) { + return config; + } + else if (config && typeof config === 'object') { + return config.tags; + } + else { + return undefined; + } +}; + +Writer.prototype.getConfigEscape = function getConfigEscape (config) { + if (config && typeof config === 'object' && !isArray(config)) { + return config.escape; + } + else { + return undefined; + } +}; + +var mustache = { + name: 'mustache.js', + version: '4.1.0', + tags: [ '{{', '}}' ], + clearCache: undefined, + escape: undefined, + parse: undefined, + render: undefined, + Scanner: undefined, + Context: undefined, + Writer: undefined, + /** + * Allows a user to override the default caching strategy, by providing an + * object with set, get and clear methods. This can also be used to disable + * the cache by setting it to the literal `undefined`. + */ + set templateCache (cache) { + defaultWriter.templateCache = cache; + }, + /** + * Gets the default or overridden caching object from the default writer. + */ + get templateCache () { + return defaultWriter.templateCache; + } +}; + +// All high-level mustache.* functions use this writer. +var defaultWriter = new Writer(); + +/** + * Clears all cached templates in the default writer. + */ +mustache.clearCache = function clearCache () { + return defaultWriter.clearCache(); +}; + +/** + * Parses and caches the given template in the default writer and returns the + * array of tokens it contains. Doing this ahead of time avoids the need to + * parse templates on the fly as they are rendered. + */ +mustache.parse = function parse (template, tags) { + return defaultWriter.parse(template, tags); +}; + +/** + * Renders the `template` with the given `view`, `partials`, and `config` + * using the default writer. + */ +mustache.render = function render (template, view, partials, config) { + if (typeof template !== 'string') { + throw new TypeError('Invalid template! Template should be a "string" ' + + 'but "' + typeStr(template) + '" was given as the first ' + + 'argument for mustache#render(template, view, partials)'); + } + + return defaultWriter.render(template, view, partials, config); +}; + +// Export the escaping function so that the user may override it. +// See https://github.com/janl/mustache.js/issues/244 +mustache.escape = escapeHtml; + +// Export these mainly for testing, but also for advanced usage. +mustache.Scanner = Scanner; +mustache.Context = Context; +mustache.Writer = Writer; + +export default mustache; diff --git a/www/init.php b/www/init.php index eaf42d8bf..12334660d 100644 --- a/www/init.php +++ b/www/init.php @@ -1,6 +1,6 @@ 0) { - $image = \App\Modules\Shop\Entity\Image::load($_REQUEST['id']); - if ($image instanceof \App\Modules\Shop\Entity\Image) { + $image = \App\Entity\Image::load($_REQUEST['id']); + if ($image instanceof \App\Entity\Image) { header("Content-Type: " . $image->mime); if ($_REQUEST['t'] == "t" && strlen($image->thumb) > 0) { diff --git a/www/templates/lang.json b/www/templates/lang.json index a992366b7..6fab7f798 100644 --- a/www/templates/lang.json +++ b/www/templates/lang.json @@ -33,6 +33,8 @@ "pt_outrent": "Расходы на аренду и комуналку", "pt_outcap": "Распределение прибыли ", "pt_outother": "Прочие расходы", + "pt_cancelcust": "Отмена платежа закупки", + "pt_cancel": "Отмена платежа продажи", "pt_bank": "Услуги банка", "pr_new": "Новый", "pr_inp": "В работе", @@ -166,6 +168,7 @@ "enterdelivery": "Выберите тип доставки", "enteraddress": "Введите адрес", "entertelemail": "Введите телефон или email", + "enterteldeliv": "Для данного типа доставки нужно ввести телефон", "selbranch": "Выберите филиал", "selmf": "Выберите кассу", "thesamebranch": "Склад, касса и терминал должны быть с одного филиала", @@ -241,6 +244,8 @@ "repbyservices": "Услуги, работы", "repbybyersservices": "Услуги по покупателям", "repbyhold": "По холдингам", + "repbybyfirm": "По компаниям", + "repbybystore": "По складам", "mall": "Все", "mopen": "Открытые", "msgtask": "Комментарий к задаче", @@ -303,6 +308,7 @@ "modshopprlist": "Товары в онлайн каталоге", "delitemwarn": "Товар уже используется. Переведен в неактивный", "withoutcat": "Без категории", + "allcategory": "Все категории", "ppoexecuted": "Выполнено", "emptycust": "Физ. лицо", "nothold": "Холдинг не может быть дочерней компанией", @@ -398,5 +404,23 @@ "enterleadstatus": "Не введено состояние лида", "nodefstore": "Укажите в профиле склад по умолчанию", "nodefmf": "Укажите в профиле кассу по умолчанию", - "nodeffirm": "Укажите в профиле компанию по умолчанию" -} \ No newline at end of file + "nodeffirm": "Укажите в профиле компанию по умолчанию", + "nodelcat": "Нельзя удилить категорию с ТМЦ", + "nodelcatchild": "У категории есть дочерние категории" , + "shopattryn": "Атрибут 'Есть/Нет' указывает на наличие или отсутствие характеристики. Например FM-тюнер" , + "shopattrnum": "Атрибут 'Число' - числовой параметр (напрмер емкость акумулятора). Список для для фильтра отбора формируется на основании диапазона значений атрибута, заданых для товаров." , + "shopattrlist": "Атрибут 'Список' предназначен для перечня из которого можно выбрать только одно значение. Например цвет. Задается списком через запятую" , + "shopattrset": "Атрибут 'Набор' предназначен для перечня из которого можно выбрать несколько значений.. Например диапазоны приема сигнала. Задается списком через запятую. " , + "shopattrynname" :"Есть/Нет", + "shopattrnumname" :"Число", + "shopattrlistname" :"Список", + "shopattrsetname" :"Набор", + "shopattrstrname" :"Строка", + "shopattrnodata" :"Нет данных", + "shopattryes" :"Есть", + "shopattrno" :"Нет", + "shopfeedbaks" :"Отзывов(%s)", + "shopneworder" :"Создан заказ %s" , + "shopyoursorder" :"Ваш заказ %s" + + } \ No newline at end of file diff --git a/www/templates/modules/issue/pages/issuelist.html b/www/templates/modules/issue/pages/issuelist.html index 9105dd63b..cd8dc113e 100644 --- a/www/templates/modules/issue/pages/issuelist.html +++ b/www/templates/modules/issue/pages/issuelist.html @@ -257,7 +257,10 @@
    Коментарии
    callbacks: { onEnter: function (e) { - e.preventDefault(); + if (e.keyCode === key.code.ENTER) { + e.shiftKey = true; + context.triggerEvent('enter', e); + } }, onPaste: function (e) { diff --git a/www/templates/modules/issue/pages/projectlist.html b/www/templates/modules/issue/pages/projectlist.html index 485f96aa7..40b8b278c 100644 --- a/www/templates/modules/issue/pages/projectlist.html +++ b/www/templates/modules/issue/pages/projectlist.html @@ -185,7 +185,10 @@
    Коментарии
    callbacks: { onEnter: function (e) { - e.preventDefault(); + if (e.keyCode === key.code.ENTER) { + e.shiftKey = true; + context.triggerEvent('enter', e); + } }, onPaste: function (e) { diff --git a/www/templates/modules/note/pages/main.html b/www/templates/modules/note/pages/main.html index f100d8de4..b6272abd4 100644 --- a/www/templates/modules/note/pages/main.html +++ b/www/templates/modules/note/pages/main.html @@ -304,7 +304,10 @@ callbacks: { onEnter: function (e) { - e.preventDefault(); + if (e.keyCode === key.code.ENTER) { + e.shiftKey = true; + context.triggerEvent('enter', e); + } }, onPaste: function (e) { diff --git a/www/templates/modules/shop/pages/base.html b/www/templates/modules/shop/pages/base.html index ffcf10fc7..6d7663eb1 100644 --- a/www/templates/modules/shop/pages/base.html +++ b/www/templates/modules/shop/pages/base.html @@ -20,7 +20,7 @@ - + @@ -32,52 +32,63 @@ - -
    -
    -
    - Zippy Магазин + + + + +
    +
    +
    +
    -
    - +
    + - diff --git a/www/templates/modules/shop/pages/productview.html b/www/templates/modules/shop/pages/productview.html index 919f50308..5b1342780 100644 --- a/www/templates/modules/shop/pages/productview.html +++ b/www/templates/modules/shop/pages/productview.html @@ -7,21 +7,27 @@
    +

    -
    -
    +
    + {{#islistimage}}
    - + +
    {{/islistimage}} @@ -29,52 +35,58 @@
    -
    +
    - Новинка - Топ продаж - -

    + +
    +
    Код:
    -

    -
    -
    - -

      {{currencyname}}

    -
    -
    - -
    -
    - Добавить к сравнениюСравнить -
      +

    +

    + +
    +
    + +
    + {{#usefeedback}} + +   + {{/usefeedback}} +
    - -
    -
    +
    + -
    -
    -

    Характеристики

    +
    +
    +
    Характеристики
    image_id}&t=t\">
    product_id}\">" . $product->productname . " product_id}\">
    image_id}&t=t\">

    item_id}\">" . $product->itemname . "
    " . $product->getPriceFinal() . ' ' . $options['currencyname'] . "         item_id}\">
    " . $attrnames[$attribute_id] . "" . $attrvalues[$attribute_id][$product->product_id] . "" . $attrvalues[$attribute_id][$product->item_id] . "
    {$this->productattribute->attributename}"; - + $nodata = \App\Helper::l("shopattrnodata") ; //'Есть/Нет' if ($this->productattribute->attributetype == 1) { - - if ($this->productattribute->value == 1) { - $checked = ' checked="on"'; - } - $ret .= " id}\" {$checked} /> "; + $yes = \App\Helper::l("shopattryes") ; + $no = \App\Helper::l("shopattrno") ; + + + $s1=($this->productattribute->value == -1 || strlen($this->productattribute->value)==0) ? 'selected="on"' :''; + $s2=$this->productattribute->value == '0' ? 'selected="on"' :''; + $s3=$this->productattribute->value == 1 ? 'selected="on"' :''; + + + $ret .= " '; + } //'Число' if ($this->productattribute->attributetype == 2) { - $ret .= " id}\" type=\"text\" value=\"{$this->productattribute->value}\" class=\"form-control\" /> "; + $ret .= " pattern='[0-9\.]+' id}\" type=\"text\" value=\"{$this->productattribute->value}\" class=\"form-control\" /> "; $ret .= ""; } //'Список' if ($this->productattribute->attributetype == 3) { $sel = ''; - $ret .= " id}\" class=\"form-control\" >"; $list = explode(',', $this->productattribute->valueslist); foreach ($list as $key => $value) { $value = trim($value); @@ -546,28 +434,24 @@ public function getContent($attributes) { //'Строка' if ($this->productattribute->attributetype == 5) { - $ret .= " "; - } - if ($this->productattribute->nodata == 1) { - $checked = ' checked="on"'; + $ret .= "id}\" type=\"text\" class=\"form-control\" value=\"{$this->productattribute->value}\" "; } - $ret .= " id}\"> Н/Д - -
    - +
    -
    -

    Отзывы

    +
    + + {{#usefeedback}} +
    +
    Отзывы
    @@ -83,14 +95,14 @@

    Отзывы

    zippy="rate" value="0" data-filled="fas fa-star" data-empty="far fa-star "/>
    : -

    +

    - {{#islogined}} + - {{/islogined}} +
    @@ -98,19 +110,30 @@

    Отзывы

    -
    - - +
    +
    + Имя +
    +
    -
    + +
    - +
    -
    - - +
    +
    + Отзыв +
    + +
    + +
    + +
    + +
    @@ -121,7 +144,7 @@

    Отзывы

    - + {{/usefeedback}}
    diff --git a/www/templates/pages/base.html b/www/templates/pages/base.html index e1ef456e1..22aead6e1 100644 --- a/www/templates/pages/base.html +++ b/www/templates/pages/base.html @@ -399,7 +399,7 @@ {{/note}} - {{#shop}} + {{#shop}}
  • -

      Товары

    +

      Значения атрибутов

  • -
  • - - -

      Бренды

    -
    -
  • -
  • -
    _______________
    -
  • +
  • @@ -723,6 +715,16 @@
    _______________
  • {{/isadmins}} + +
    diff --git a/www/templates/pages/doc/goodsissue.html b/www/templates/pages/doc/goodsissue.html index 86b2614e4..ef57801ba 100644 --- a/www/templates/pages/doc/goodsissue.html +++ b/www/templates/pages/doc/goodsissue.html @@ -186,10 +186,7 @@

    Расходная накладная

      -   Оприходовать с производства. - - +
    diff --git a/www/templates/pages/doc/poscheck.html b/www/templates/pages/doc/poscheck.html index 6d614dbd8..e11d474d3 100644 --- a/www/templates/pages/doc/poscheck.html +++ b/www/templates/pages/doc/poscheck.html @@ -93,7 +93,8 @@

    Кассовый чек

    Цена Сумма - + + @@ -109,6 +110,7 @@

    Кассовый чек

    + @@ -126,7 +128,8 @@

    Кассовый чек

    - + + diff --git a/www/templates/pages/doc/prodreceipt.html b/www/templates/pages/doc/prodreceipt.html index d773f1224..4c1d8f0f2 100644 --- a/www/templates/pages/doc/prodreceipt.html +++ b/www/templates/pages/doc/prodreceipt.html @@ -19,16 +19,7 @@

    Оприходование с производства

    -
    - - - -
    +
    diff --git a/www/templates/pages/main.html b/www/templates/pages/main.html index b4da6c07a..34a12c456 100644 --- a/www/templates/pages/main.html +++ b/www/templates/pages/main.html @@ -8,7 +8,7 @@ {{#winfo}}
    -
    +
    @@ -24,22 +24,56 @@
    -
    +
    - Товаров на складе + ТМЦ на складе На сумму {{biitemscnt}}
    - +
    - + +
    +
    +
    + + +
    + К оплате + + На сумму {{bicredit}} + + + +
    + +
    +
    +
    +
    + + +
    + Ожидается оплата + + На сумму {{bidebet}} + + + +
    + +
    + +
    + +
    {{/winfo}} diff --git a/www/templates/pages/options.html b/www/templates/pages/options.html index ae4083b89..9a746af55 100644 --- a/www/templates/pages/options.html +++ b/www/templates/pages/options.html @@ -9,6 +9,7 @@

    Общие настройки

    + После изменения настроек следует перелогинится
    @@ -163,6 +164,18 @@

    Общие настройки

    +
    + + + +
    +
    + + + +

    diff --git a/www/templates/pages/reference/categorylist.html b/www/templates/pages/reference/categorylist.html index 59bb76e90..88f8d5b46 100644 --- a/www/templates/pages/reference/categorylist.html +++ b/www/templates/pages/reference/categorylist.html @@ -1,10 +1,19 @@ + + +
    + {{#usecattree}} +
    + {{/usecattree}} + {{^usecattree}}
    + {{/usecattree}} +

    Категории товаров Категории товаров Добавить - + {{#useimages}} + + {{/useimages}} + + {{#usecattree}} + + {{/usecattree}} + - + {{#useimages}} + + + {{/useimages}} + + {{#usecattree}} + + {{/usecattree}} + + +
    НазваниеНазвание Родительская Кол. ТМЦ
    + - +    
    @@ -37,11 +64,20 @@

    Категории товаров
    - +
    + {{#usecattree}} +
    + + +
    + {{/usecattree}} +
    @@ -53,14 +89,45 @@

    Категории товаров Типы цен задаются в настройках.

    - +
    + + + Изображение должно быть квадратным иначе будет обрезано +
    +
    +
    +
    + + + Удалить избражение +
    +
    +
    + + +
    + + +
       - +
    + \ No newline at end of file diff --git a/www/templates/pages/reference/itemlist.html b/www/templates/pages/reference/itemlist.html index 1cf9a941d..0669e2f1a 100644 --- a/www/templates/pages/reference/itemlist.html +++ b/www/templates/pages/reference/itemlist.html @@ -9,7 +9,7 @@
    -

    Справочник товаров +

    Справочник номенклатуры Отп. цена Ячейка - + {{#usesnumber}} {{/usesnumber}} @@ -64,7 +64,7 @@

    Справочник товаров {{#useimages}} - @@ -80,7 +80,7 @@

    Справочник товаров - + {{#usesnumber}} {{/usesnumber}} @@ -91,7 +91,7 @@

    Справочник товаров -    +      @@ -102,170 +102,230 @@

    Справочник товаров

    -
    +
    -

    Редактирование товара

    -
    - -
    - +

    Редактирование

    +
    +
    + +
    + +
    + +
    -
    -
    - -
    - - - Для использования например в ценниках +
    + +
    + + + Для использования например в ценниках +
    -
    -
    - -
    - +
    + +
    + +
    -
    -
    - -
    - - - - - - Типы цен задаются в настройках. Для наценок указать '%' после - цифры +
    + +
    + + + + + + Типы цен задаются в настройках. Для наценок указать '%' после + цифры +
    -
    -
    - -
    - - Код товара должен быть уникальным. - Если используется код производителя, следует добавить бренд к коду например - k123_имябренда +
    + +
    + + Код товара должен быть уникальным. + Если используется код производителя, следует добавить бренд к коду например + k123_имябренда +
    -
    -
    - -
    - -
    -
    -
    - -
    - +
    + +
    + +
    -
    -
    - -
    - - Используется если есть производство +
    + +
    + + Используется если есть производство +
    -
    -
    - -
    - - Если задано то при уменьшении количества на складе меньше - заданного товар появится в соответствующем виджете на главной странице +
    + +
    + + Если задано то при уменьшении количества на складе меньше + заданного товар появится в соответствующем виджете на главной странице +
    -
    -
    - -
    - +
    + +
    + +
    -
    -
    - -
    - +
    + +
    + + + {{#manlist}} + +
    -
    -
    - -
    - - - {{#manlist}} - +
    + +
    + + Используется для готовой продукции и полуфабрикатов при сдельной + оплате +
    -
    -
    - -
    - - Используется для готовой продукции и полуфабрикатов при сдельной - оплате +
    + +
    + + +
    -
    -
    - -
    - + {{#usesnumber}} +
    + +
    -
    - {{#usesnumber}} -
    - - -
    + {{/usesnumber}} - {{/usesnumber}} -
    - - -
    -
    - - -
    - {{#useimages}} -
    - - -
    -
    - -
    - - + +
    + + +
    +
    + + +
    +
    + + + + +
    +
    + + + + + +
    + + +
    + + +
    + + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Например для меню в общепите (300 гр, 250 мл...) +
    -
    - {{/useimages}} -
    - -
    - + + {{#useimages}} +
    + + +
    +
    + +
    + + +
    + Изображение должно быть квадратным иначе будет обрезано +
    -
    -
    -    - + {{/useimages}} +
    + +
    + +
    +
    + + +
    +
    + +
    +    + +
    +
    diff --git a/www/templates/pages/register/doclist.html b/www/templates/pages/register/doclist.html index e60924d28..c7f1b5a0f 100644 --- a/www/templates/pages/register/doclist.html +++ b/www/templates/pages/register/doclist.html @@ -13,8 +13,8 @@

    Журнал документов
    diff --git a/www/templates/pages/register/itemlist.html b/www/templates/pages/register/itemlist.html index 07191f2e3..aa0a717aa 100644 --- a/www/templates/pages/register/itemlist.html +++ b/www/templates/pages/register/itemlist.html @@ -152,6 +152,7 @@

    $(this).ekkoLightbox({'alwaysShowClose': true}); }); + $('#searchkey').focus(); }); diff --git a/www/templates/pages/register/paylist.html b/www/templates/pages/register/paylist.html index b394be110..e8e31ec07 100644 --- a/www/templates/pages/register/paylist.html +++ b/www/templates/pages/register/paylist.html @@ -38,7 +38,7 @@

    Журнал платежей


    Экспорт в Excel -
    Отмена и изменение платежа производится путем отмены и перепроведения соответствующего документа +
    Отмена оплаты выполняется провелением оплаты со знаком минус @@ -75,7 +75,9 @@

    Журнал платежей

    @@ -122,6 +124,26 @@

    Журнал платежей

    +
    - +    + +   
    + + + + + + +
    Печать
    +
    +

    +
    +
    + @@ -32,48 +32,63 @@ - -
    -
    -
    - Zippy Магазин + + + + +
    +
    +
    +
    + +
    -
    - +
    + +

    -
    -
    +
    + {{#islistimage}}
    - + +
    {{/islistimage}} @@ -29,52 +35,58 @@
    -
    +
    - Новинка - Топ продажів - -

    + +
    +
    Код:
    -

    -
    -
    - -

      {{currencyname}}

    -
    -
    - -
    -
    - Додати до порівнянняПорівняти -
      +

    +

    + +
    +
    + +
    + {{#usefeedback}} + +   + {{/usefeedback}} +
    - -
    -
    +
    + -
    -
    -

    Характеристики

    +
    +
    +
    Характеристики
    - +
    -
    -

    Відгуки

    +
    + + {{#usefeedback}} +
    +
    Вiдгуки
    @@ -83,14 +95,14 @@

    Відгуки

    zippy="rate" value="0" data-filled="fas fa-star" data-empty="far fa-star "/>
    : -

    +

    - {{#islogined}} + - {{/islogined}} + class="fa fa-trash-alt"> +
    @@ -98,19 +110,30 @@

    Відгуки

    -
    - - +
    +
    + Им'я +
    +
    -
    - - + +
    + +
    -
    - - +
    +
    + Вiдгук +
    + +
    + +
    + +
    + +
    @@ -121,7 +144,7 @@

    Відгуки

    - + {{/usefeedback}}
    diff --git a/www/templates_ua/modules/shop/pages/userlogin.html b/www/templates_ua/modules/shop/pages/userlogin.html index 6f9ed480b..fa3105ab0 100644 --- a/www/templates_ua/modules/shop/pages/userlogin.html +++ b/www/templates_ua/modules/shop/pages/userlogin.html @@ -20,7 +20,7 @@ - + @@ -51,7 +51,7 @@
    - +
    @@ -72,13 +72,13 @@
    - +
    diff --git a/www/templates_ua/pages/base.html b/www/templates_ua/pages/base.html index 5d6abbe71..6ca286226 100644 --- a/www/templates_ua/pages/base.html +++ b/www/templates_ua/pages/base.html @@ -407,24 +407,16 @@
  • -

      Товари

    -
    -
  • -
  • - - -

      Бренди

    +

      Значення атрибутiв

  • -
  • -
    _______________
    -
  • +
  • @@ -698,6 +690,16 @@
    _______________
  • {{/isadmins}} + +
    diff --git a/www/templates_ua/pages/doc/goodsissue.html b/www/templates_ua/pages/doc/goodsissue.html index d3ec442f2..eab87c58b 100644 --- a/www/templates_ua/pages/doc/goodsissue.html +++ b/www/templates_ua/pages/doc/goodsissue.html @@ -185,10 +185,7 @@

    Видаткова накладна

      -   Оприбуткувати з виробництва - - +
    diff --git a/www/templates_ua/pages/doc/poscheck.html b/www/templates_ua/pages/doc/poscheck.html index 2692db6a6..79941ef56 100644 --- a/www/templates_ua/pages/doc/poscheck.html +++ b/www/templates_ua/pages/doc/poscheck.html @@ -93,7 +93,8 @@

    Касовий чек

    Ціна Сума - + + @@ -109,6 +110,7 @@

    Касовий чек

    + @@ -126,7 +128,8 @@

    Касовий чек

    - + + diff --git a/www/templates_ua/pages/doc/prodreceipt.html b/www/templates_ua/pages/doc/prodreceipt.html index ac432f80c..e1fb4f6e1 100644 --- a/www/templates_ua/pages/doc/prodreceipt.html +++ b/www/templates_ua/pages/doc/prodreceipt.html @@ -19,16 +19,7 @@

    Оприбуткування з виробництва

    -
    - - - -
    +
    diff --git a/www/templates_ua/pages/main.html b/www/templates_ua/pages/main.html index 7d461a45f..3210566e3 100644 --- a/www/templates_ua/pages/main.html +++ b/www/templates_ua/pages/main.html @@ -8,7 +8,7 @@ {{#winfo}}
    -
    +
    @@ -24,7 +24,7 @@
    -
    +
    @@ -40,6 +40,40 @@
    + +
    +
    + + +
    + До сплати + + На суму {{bicredit}} + + + +
    + +
    + +
    +
    +
    + + +
    + Очiкуєтся оплата + + На суму {{bidebet}} + + + +
    + +
    + +
    +
    {{/winfo}} diff --git a/www/templates_ua/pages/options.html b/www/templates_ua/pages/options.html index 55e8c6efe..f5db952db 100644 --- a/www/templates_ua/pages/options.html +++ b/www/templates_ua/pages/options.html @@ -9,7 +9,8 @@

    Налаштування

    Загальнi налаштування

    - + Після зміни налаштувань слід перелогінитись +
    @@ -165,6 +166,18 @@

    Загальнi налаштування

    +
    + + + +
    +
    + + + +

    diff --git a/www/templates_ua/pages/reference/categorylist.html b/www/templates_ua/pages/reference/categorylist.html index 356a3915b..98fe9f7fa 100644 --- a/www/templates_ua/pages/reference/categorylist.html +++ b/www/templates_ua/pages/reference/categorylist.html @@ -1,10 +1,18 @@ + + +
    + {{#usecattree}} +
    + {{/usecattree}} + {{^usecattree}}
    + {{/usecattree}}

    Категорії товарів Категорії товарів Додати - + {{#useimages}} + + {{/useimages}} + + {{#usecattree}} + + {{/usecattree}} + - + {{#useimages}} + + {{/useimages}} + + {{#usecattree}} + + {{/usecattree}} + - +
    НазваНазва БатькiвськаКiл. ТМЦ
    + + + +    
    @@ -37,12 +63,20 @@

    Категорії товарів
    - +
    -
    + {{#usecattree}} +
    + + +
    + {{/usecattree}} +
    @@ -53,14 +87,43 @@

    Категорії товарів Типи цін задаються в налаштуваннях.

    - +
    + + + Зображення повинно бути квадратним інакше буде обрізано обрезано +
    +
    +
    +
    + + + Видалити зображення +
    +
    +
    + + +
    +
       - +
    + \ No newline at end of file diff --git a/www/templates_ua/pages/reference/itemlist.html b/www/templates_ua/pages/reference/itemlist.html index 648938672..3630a8bbf 100644 --- a/www/templates_ua/pages/reference/itemlist.html +++ b/www/templates_ua/pages/reference/itemlist.html @@ -9,7 +9,7 @@
    -

    Довідник товарів +

    Довідник номенклатури {{#useimages}} - @@ -102,10 +102,12 @@

    Довідник товарів

    -
    +
    -

    Редагування товару

    -
    +

    Редагування

    +
    +
    +
    @@ -158,13 +160,7 @@

    Редагування товару

    -
    - -
    - -
    -
    -
    +
    -
    - -
    - -
    -
    -
    +
    @@ -232,15 +222,75 @@

    Редагування товару

    {{/usesnumber}} -
    - - -
    +
    + + +
    +
    + + +
    +
    + + + + +
    +
    + + + + + +
    +
    - {{#useimages}} + + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + + Наприклад для меню в кафе (300 гр, 250 мл...) +
    +
    + + {{#useimages}}
    @@ -252,6 +302,7 @@

    Редагування товару

    + Зображення повинно бути квадратним інакше буде обрізано
    @@ -262,13 +313,18 @@

    Редагування товару

    +
    +
    +
      
    - +
    +
    +
    diff --git a/www/templates_ua/pages/register/doclist.html b/www/templates_ua/pages/register/doclist.html index 4e996aed7..52221105a 100644 --- a/www/templates_ua/pages/register/doclist.html +++ b/www/templates_ua/pages/register/doclist.html @@ -13,8 +13,8 @@

    Журнал документів
    diff --git a/www/templates_ua/pages/register/itemlist.html b/www/templates_ua/pages/register/itemlist.html index 681f66048..38213c76d 100644 --- a/www/templates_ua/pages/register/itemlist.html +++ b/www/templates_ua/pages/register/itemlist.html @@ -134,8 +134,7 @@

    Скоригувати партii наприклад коли утворився мiнус можна - документами - Оприбуткування та Списання ТМЦ. . + документами Оприбуткування та Списання ТМЦ. .
    @@ -153,6 +152,8 @@

    $(this).ekkoLightbox({'alwaysShowClose': true}); }); + $('#searchkey').focus(); + }); diff --git a/www/templates_ua/pages/register/paylist.html b/www/templates_ua/pages/register/paylist.html index a007608df..2355d285c 100644 --- a/www/templates_ua/pages/register/paylist.html +++ b/www/templates_ua/pages/register/paylist.html @@ -38,7 +38,7 @@

    Журнал платежів


    Експорт в Excel -
    Скасування і зміна платежу проводиться шляхом скасування і перепроведення відповідного документу +
    Скасування оплати виконуется проведенням оплати зi знаком мiнус @@ -76,7 +76,9 @@

    Журнал платежів

    @@ -123,6 +125,26 @@

    Журнал платежів

    +
    - +    + +   
    + + + + + + +
    Друк
    +

    +
    +
    +
    +