Skip to content

Commit

Permalink
Merge pull request #301 from leon-mbs/dev
Browse files Browse the repository at this point in the history
6.1.0
  • Loading branch information
leon-mbs authored Apr 17, 2022
2 parents 6d4ba3e + ff49f38 commit 35c8032
Show file tree
Hide file tree
Showing 49 changed files with 1,048 additions and 1,333 deletions.
76 changes: 69 additions & 7 deletions db/db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,41 @@ SET character_set_client = utf8;
1 AS `customer_name`,
1 AS `firm_name`*/;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `custitems`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `custitems` (
`custitem_id` int(11) NOT NULL AUTO_INCREMENT,
`item_id` int(11) NOT NULL,
`customer_id` int(11) NOT NULL,
`quantity` decimal(10,3) DEFAULT NULL,
`price` decimal(10,2) NOT NULL DEFAULT '0.00',
`cust_code` varchar(255) NOT NULL,
`comment` varchar(255) DEFAULT NULL,
`updatedon` date NOT NULL,
PRIMARY KEY (`custitem_id`),
KEY `item_id` (`item_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `custitems_view`;
/*!50001 DROP VIEW IF EXISTS `custitems_view`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `custitems_view` AS SELECT
1 AS `custitem_id`,
1 AS `item_id`,
1 AS `customer_id`,
1 AS `quantity`,
1 AS `price`,
1 AS `updatedon`,
1 AS `cust_code`,
1 AS `comment`,
1 AS `itemname`,
1 AS `cat_id`,
1 AS `item_code`,
1 AS `detail`,
1 AS `customer_name`*/;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `customers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
Expand Down Expand Up @@ -100,7 +135,7 @@ CREATE TABLE `docstatelog` (
`hostname` varchar(64) NOT NULL,
PRIMARY KEY (`log_id`),
KEY `document_id` (`document_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2663 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=2679 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `docstatelog_view`;
/*!50001 DROP VIEW IF EXISTS `docstatelog_view`*/;
Expand Down Expand Up @@ -145,7 +180,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=778 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=787 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `documents_view`;
/*!50001 DROP VIEW IF EXISTS `documents_view`*/;
Expand Down Expand Up @@ -406,7 +441,7 @@ CREATE TABLE `images` (
`mime` varchar(16) DEFAULT NULL,
`thumb` longblob,
PRIMARY KEY (`image_id`)
) ENGINE=MyISAM AUTO_INCREMENT=99 DEFAULT CHARSET=utf8;
) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `iostate`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
Expand All @@ -418,7 +453,7 @@ CREATE TABLE `iostate` (
`amount` decimal(10,2) NOT NULL,
PRIMARY KEY (`id`),
KEY `document_id` (`document_id`)
) ENGINE=InnoDB AUTO_INCREMENT=134 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `iostate_view`;
/*!50001 DROP VIEW IF EXISTS `iostate_view`*/;
Expand Down Expand Up @@ -658,7 +693,7 @@ CREATE TABLE `metadata` (
`menugroup` varchar(255) DEFAULT NULL,
`disabled` tinyint(4) NOT NULL,
PRIMARY KEY (`meta_id`)
) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=113 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mfund`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
Expand Down Expand Up @@ -817,7 +852,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=625 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=627 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `paylist_view`;
/*!50001 DROP VIEW IF EXISTS `paylist_view`*/;
Expand Down Expand Up @@ -1209,7 +1244,21 @@ CREATE TABLE `subscribes` (
`detail` longtext,
`disabled` int(1) DEFAULT '0',
PRIMARY KEY (`sub_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `supitems`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `supitems` (
`supitem_id` int(11) NOT NULL AUTO_INCREMENT,
`item_id` int(11) NOT NULL,
`sup_id` int(11) NOT NULL,
`quantity` decimal(10,3) NOT NULL,
`price` decimal(10,2) NOT NULL,
`sup_code` varchar(255) DEFAULT NULL,
`comment` varchar(255) DEFAULT NULL,
PRIMARY KEY (`supitem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `timesheet`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
Expand Down Expand Up @@ -1311,6 +1360,19 @@ CREATE TABLE `zformstat` (
/*!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 `custitems_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 = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE */
/*!50013 */
/*!50001 VIEW `custitems_view` AS select `s`.`custitem_id` AS `custitem_id`,`s`.`item_id` AS `item_id`,`s`.`customer_id` AS `customer_id`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`updatedon` AS `updatedon`,`s`.`cust_code` AS `cust_code`,`s`.`comment` AS `comment`,`i`.`itemname` AS `itemname`,`i`.`cat_id` AS `cat_id`,`i`.`item_code` AS `item_code`,`i`.`detail` AS `detail`,`c`.`customer_name` AS `customer_name` from ((`custitems` `s` join `items` `i` on((`s`.`item_id` = `i`.`item_id`))) join `customers` `c` on((`s`.`customer_id` = `c`.`customer_id`))) where ((`i`.`disabled` <> 1) and (`c`.`status` <> 1)) */;
/*!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 `customers_view`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
Expand Down
2 changes: 2 additions & 0 deletions db/initdata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `
INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 2, 'Повернення постачальникам', 'Returnbayed', 'Закупки', 0);
INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 1, 'Надані послуги', 'IncomeService', 'Послуги', 0);
INSERT INTO `metadata` (`meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 2, 'Стан складiв', 'StoreItems', 'Склад', 0);
INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 3, 'Товари у постачальникIв', 'CustItems', '', 0);




Expand Down
53 changes: 0 additions & 53 deletions db/update/archive/temp.sql
Original file line number Diff line number Diff line change
@@ -1,53 +0,0 @@
INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 5, 'Ïîñòà÷àëüíèêè', 'SupplierList', 'Äðîïøèï³íã', 0);
INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 5, 'Òîâàðè', 'SupItems', 'Äðîïøèï³íã', 0);

CREATE TABLE suppliers (
sup_id int(11) NOT NULL AUTO_INCREMENT,
sup_name varchar(255) NOT NULL,
disabled tinyint(1) NOT NULL DEFAULT 0,
detail text NOT NULL,

PRIMARY KEY (sup_id)
)
ENGINE = InnoDB,
CHARACTER SET utf8 ;


CREATE TABLE supitems (
supitem_id int(11) NOT NULL AUTO_INCREMENT,
item_id int(11) NOT NULL,
sup_id int(11) NOT NULL,
quantity decimal(10, 3) NOT NULL DEFAULT 0,
price decimal(10, 2) NOT NULL DEFAULT 0,
sup_code varchar(255) DEFAULT NULL,
comment varchar(255) DEFAULT NULL,
PRIMARY KEY (supitem_id)
)
ENGINE = InnoDB,
COLLATE utf8_general_ci;



DROP VIEW supitems_view ;

CREATE
VIEW supitems_view
AS
SELECT
`s`.`supitem_id` AS `supitem_id`,
`s`.`item_id` AS `item_id`,
`s`.`sup_id` AS `sup_id`,
`s`.`quantity` AS `quantity`,
`s`.`price` AS `price`,
`s`.`sup_code` AS `sup_code`,
`s`.`comment` AS `comment`,
`i`.`itemname` AS `itemname`,
`i`.`item_code` AS `item_code`,
`i`.`detail` AS `detail`,
`sp`.`sup_name` AS `sup_name`
FROM ((`supitems` `s`
JOIN `items` `i`
ON ((`s`.`item_id` = `i`.`item_id`)))
JOIN `suppliers` `sp`
ON ((`s`.`sup_id` = `sp`.`sup_id`)))
WHERE (`i`.`disabled` <> 1 AND sp.disabled <>1);
47 changes: 47 additions & 0 deletions db/update/update600to610.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 3, 'Товари у постачальникIв', 'CustItems', '', 0);



CREATE TABLE custitems (
custitem_id int(11) NOT NULL AUTO_INCREMENT,
item_id int(11) NOT NULL,
customer_id int(11) NOT NULL,
quantity decimal(10, 3) DEFAULT NULL,
price decimal(10, 2) NOT NULL DEFAULT 0.00,
cust_code varchar(255) NOT NULL,
comment varchar(255) DEFAULT NULL,
updatedon date NOT NULL,
PRIMARY KEY (custitem_id)
)
ENGINE = InnoDB ;

ALTER TABLE custitems
ADD INDEX item_id (item_id);



CREATE
VIEW custitems_view
AS
SELECT
`s`.`custitem_id` AS `custitem_id`,
`s`.`item_id` AS `item_id`,
`s`.`customer_id` AS `customer_id`,
`s`.`quantity` AS `quantity`,
`s`.`price` AS `price`,
`s`.`cust_code` AS `cust_code`,
`s`.`comment` AS `comment`,
`s`.`updatedon` AS `updatedon`,
`i`.`itemname` AS `itemname`,
`i`.`cat_id` AS `cat_id`,
`i`.`item_code` AS `item_code`,
`i`.`detail` AS `detail`,
`c`.`customer_name` AS `customer_name`
FROM ((`custitems` `s`
JOIN `items` `i`
ON ((`s`.`item_id` = `i`.`item_id`)))
JOIN `customers` `c`
ON ((`s`.`customer_id` = `c`.`customer_id`)))
WHERE ((`i`.`disabled` <> 1)
AND (`c`.`status` <> 1));

14 changes: 9 additions & 5 deletions www/app/entity/supitem.php → www/app/entity/custitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,27 @@
/**
* Класс-сущность товар поставщика
*
* @table=supitems
* @view=supitems_view
* @keyfield=supitem_id
* @table=custitems
* @view=custitems_view
* @keyfield=custitem_id
*/
class SupItem extends \ZCL\DB\Entity
class CustItem extends \ZCL\DB\Entity
{



protected function init() {
$this->supitem_id = 0;
$this->custitem_id = 0;

}



protected function afterLoad() {

$this->updatedon = strtotime($this->updatedon);


//распаковываем данные из item detail
$xml = simplexml_load_string($this->detail);
$this->itemprice = (string)($xml->price1[0]);
Expand Down
38 changes: 21 additions & 17 deletions www/app/entity/doc/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,23 +371,7 @@ public function updateStatus($state) {
$this->insertLog($state);


if($this->state == self::STATE_NEW) $this->priority = 100;
if($this->state == self::STATE_CLOSED) $this->priority = 1;
if($this->state == self::STATE_EXECUTED) $this->priority = 10;
if($this->state == self::STATE_FINISHED) $this->priority = 20;
if($this->state == self::STATE_DELIVERED) $this->priority = 30;
if($this->state == self::STATE_INPROCESS) $this->priority = 50;
if($this->state == self::STATE_SHIFTED) $this->priority = 40;
if($this->state == self::STATE_INSHIPMENT) $this->priority = 50;
if($this->state == self::STATE_WA) $this->priority = 90;
if($this->state == self::STATE_APPROVED) $this->priority = 80;
if($this->state == self::STATE_CANCELED) $this->priority = 70;
if($this->state == self::STATE_EDITED) $this->priority = 80;
if($this->state == self::STATE_REFUSED) $this->priority = 3;
if($this->state == self::STATE_DELETED) $this->priority = 2;
if($this->state == self::STATE_FAIL) $this->priority = 3;
if($this->state == self::STATE_READYTOSHIP) $this->priority = 50;

$this->priority = $this->getPriorytyByState($this->state) ;


$this->save();
Expand All @@ -411,6 +395,26 @@ public function updateStatus($state) {
protected function onState($state) {

}
public function getPriorytyByState($state) {
if($state == self::STATE_NEW) return 100;
if($state == self::STATE_CLOSED) return 1;
if($state == self::STATE_EXECUTED) return 10;
if($state == self::STATE_FINISHED) return 20;
if($state == self::STATE_DELIVERED) return 30;
if($state == self::STATE_INPROCESS) return 50;
if($state == self::STATE_SHIFTED) return 40;
if($state == self::STATE_INSHIPMENT) return 50;
if($state == self::STATE_WA) return 90;
if($state == self::STATE_APPROVED) return 80;
if($state == self::STATE_CANCELED) return 70;
if($state == self::STATE_EDITED) return 80;
if($state == self::STATE_REFUSED) return 3;
if($state == self::STATE_DELETED) return 2;
if($state == self::STATE_FAIL) return 3;
if($state == self::STATE_READYTOSHIP) return 50;

return 0;
}

/**
* Возвращает название статуса документа
Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/goodsissue.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function Execute() {


if ($this->headerdata['payment'] > 0 && $this->payed > 0) {
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, $this->payed, $this->headerdata['payment'], \App\Entity\IOState::TYPE_BASE_INCOME);
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, $this->payed, $this->headerdata['payment']);
if ($payed > 0) {
$this->payed = $payed;
}
Expand Down
8 changes: 5 additions & 3 deletions www/app/entity/doc/goodsreceipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function Execute() {


if($this->headerdata['zatr'] > 0 && $this->headerdata['zatrself'] ==1 ) {
$total = $total + $this->headerdata["zatr"];
$total = $total + $this->headerdata["zatr"]; // распределяем накладные затраты на себестоимость
}


Expand Down Expand Up @@ -148,7 +148,7 @@ public function Execute() {
if ($this->headerdata['payment'] > 0 && $payed > 0) {


$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, 0 - $payed, $this->headerdata['payment'], \App\Entity\IOState::TYPE_BASE_OUTCOME);
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, 0 - $payed, $this->headerdata['payment']);
if ($payed > 0) {
$this->payed = $payed;
}
Expand All @@ -158,7 +158,9 @@ public function Execute() {

}
if($this->headerdata['zatr'] > 0 && $this->headerdata['zatrself'] !=1 ) {
\App\Entity\Pay::addPayment($this->document_id, $this->document_date, 0 - $this->headerdata['zatr'], $this->headerdata['payment'], \App\Entity\IOState::TYPE_NAKL);
\App\Entity\Pay::addPayment($this->document_id, $this->document_date, 0 - $this->headerdata['zatr'], $this->headerdata['payment']);
}
if($this->headerdata['zatr'] > 0 ) {
\App\Entity\IOState::addIOState($this->document_id, 0 - $this->headerdata['zatr'], \App\Entity\IOState::TYPE_NAKL);
}

Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/incomeitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function Execute() {
}

if ($this->headerdata['emp'] > 0 && $this->headerdata['exmf'] > 0 && $this->headerdata['examount'] > 0) {
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, $this->headerdata['examount'], $this->headerdata['exmf'], \App\Entity\IOState::TYPE_BASE_INCOME, $this->notes);
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, $this->headerdata['examount'], $this->headerdata['exmf'], $this->notes);
if ($payed > 0) {
$this->payed = $payed;
}
Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/incomemoney.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class IncomeMoney extends Document

public function Execute() {

$payed = Pay::addPayment($this->document_id, $this->document_date, $this->amount, $this->headerdata['payment'], $this->headerdata['type'], $this->notes);
$payed = Pay::addPayment($this->document_id, $this->document_date, $this->amount, $this->headerdata['payment'], $this->notes);
if ($payed > 0) {
$this->payed = $payed;
}
Expand Down
Loading

0 comments on commit 35c8032

Please sign in to comment.