From bcf59aa3972a39b1bb8e5fc3a152ebb451acf93a Mon Sep 17 00:00:00 2001 From: "HOME\\leonm" Date: Mon, 15 Mar 2021 16:22:14 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B8=D0=B7=D0=B2=D0=BE?= =?UTF-8?q?=D0=B4=D1=81=D1=82=D0=B2=D0=BE=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B5=20=20?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=B8=D1=85=D0=BE=D0=B4=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=20=D0=B8=20=D1=81=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/app/pages/doc/ordercust.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/app/pages/doc/ordercust.php b/www/app/pages/doc/ordercust.php index 050dd1c19..9c225b999 100644 --- a/www/app/pages/doc/ordercust.php +++ b/www/app/pages/doc/ordercust.php @@ -128,10 +128,10 @@ public function detailOnRow($row) { $row->add(new Label('desc', $item->desc)); $row->add(new Label('amount', H::fa($item->quantity * $item->price))); - $row->add(new ClickLink('edit'))->onClick($this, 'editOnClick'); + $row->add(new SubmitLink('edit'))->onClick($this, 'editOnClick'); $row->edit->setVisible($item->old != true); - $row->add(new ClickLink('delete'))->onClick($this, 'deleteOnClick'); + $row->add(new SubmitLink('delete'))->onClick($this, 'deleteOnClick'); } public function editOnClick($sender) { From a7ae2095186514d25ab24b15d268f11c0957cf39 Mon Sep 17 00:00:00 2001 From: "HOME\\leonm" Date: Mon, 15 Mar 2021 16:22:37 +0200 Subject: [PATCH 2/5] fix --- www/app/entity/doc/goodsissue.php | 33 ++++++++++++++- www/app/entity/doc/prodreceipt.php | 45 ++++++++++++++++----- www/app/entity/item.php | 4 +- www/app/entity/stock.php | 2 +- www/app/pages/doc/goodsissue.php | 22 +++++++++- www/app/pages/doc/prodreceipt.php | 4 ++ www/app/pages/reference/itemlist.php | 2 +- www/app/pages/register/orderlist.php | 2 +- www/app/pages/report/prod.php | 8 ++-- www/templates/pages/doc/goodsissue.html | 4 ++ www/templates/pages/doc/prodreceipt.html | 17 ++++++-- www/templates_ua/pages/doc/goodsissue.html | 5 ++- www/templates_ua/pages/doc/prodreceipt.html | 13 +++++- 13 files changed, 133 insertions(+), 28 deletions(-) diff --git a/www/app/entity/doc/goodsissue.php b/www/app/entity/doc/goodsissue.php index 36988627f..9182764e8 100644 --- a/www/app/entity/doc/goodsissue.php +++ b/www/app/entity/doc/goodsissue.php @@ -3,6 +3,7 @@ namespace App\Entity\Doc; use App\Entity\Entry; +use App\Entity\Item; use App\Helper as H; /** @@ -85,7 +86,6 @@ public function generateReport() { } public function Execute() { - //$conn = \ZDB\DB::getConnect(); $k = 1; //учитываем скидку if ($this->headerdata["paydisc"] > 0 && $this->amount > 0) { @@ -93,6 +93,27 @@ public function Execute() { } $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('test')) ; + + } + $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) { @@ -102,8 +123,18 @@ 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/prodreceipt.php b/www/app/entity/doc/prodreceipt.php index ad89a9b7b..4b9bb1e6e 100644 --- a/www/app/entity/doc/prodreceipt.php +++ b/www/app/entity/doc/prodreceipt.php @@ -55,20 +55,45 @@ public function generateReport() { public function Execute() { $types = array(); $common = \App\System::getOptions("common"); - - //аналитика + $parts = array(); + + foreach ($this->unpackDetails('detaildata') as $item) { - $listst = \App\Entity\Stock::pickup($this->headerdata['store'], $item); - - foreach ($listst as $st) { - $sc = new Entry($this->document_id, $st->quantity * $item->price, $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/item.php b/www/app/entity/item.php index 4174f756a..63aa3082a 100644 --- a/www/app/entity/item.php +++ b/www/app/entity/item.php @@ -453,7 +453,9 @@ public function getProdprice(){ $price += ($iset->qty * $pr); } } - + if($price==0) { //ищем последнюю партию + $pr = $this->getLastPartion(0); + } return $price; } diff --git a/www/app/entity/stock.php b/www/app/entity/stock.php index dfa9e3707..ced721942 100644 --- a/www/app/entity/stock.php +++ b/www/app/entity/stock.php @@ -163,7 +163,7 @@ 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_id} order by stock_id desc limit 0,1 ") ; + $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(); diff --git a/www/app/pages/doc/goodsissue.php b/www/app/pages/doc/goodsissue.php index 851be81de..f557d344e 100644 --- a/www/app/pages/doc/goodsissue.php +++ b/www/app/pages/doc/goodsissue.php @@ -18,6 +18,7 @@ use Zippy\Html\Form\DropDownChoice; use Zippy\Html\Form\Form; use Zippy\Html\Form\SubmitButton; +use Zippy\Html\Form\CheckBox; use Zippy\Html\Form\TextInput; use Zippy\Html\Label; use Zippy\Html\Link\ClickLink; @@ -86,6 +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); @@ -306,7 +308,7 @@ public function __construct($docid = 0, $basedocid = 0) { $this->_tvars['manlist'][] = array('mitem' => $man); } - + $this->checkProd(); } public function detailOnRow($row) { @@ -347,7 +349,8 @@ public function deleteOnClick($sender) { $this->docform->detail->Reload(); $this->calcTotal(); $this->calcPay(); - } + $this->checkProd(); + } public function addrowOnClick($sender) { $this->editdetail->setVisible(true); @@ -544,6 +547,7 @@ public function saverowOnClick($sender) { $this->editdetail->editserial->setText(""); $this->calcTotal(); $this->calcPay(); + $this->checkProd(); } public function cancelrowOnClick($sender) { @@ -611,6 +615,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); @@ -1007,6 +1012,19 @@ 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/prodreceipt.php b/www/app/pages/doc/prodreceipt.php index f2de4ba40..e6c1d3a32 100644 --- a/www/app/pages/doc/prodreceipt.php +++ b/www/app/pages/doc/prodreceipt.php @@ -41,6 +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')); @@ -72,6 +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'); @@ -84,6 +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'); @@ -264,6 +267,7 @@ 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); diff --git a/www/app/pages/reference/itemlist.php b/www/app/pages/reference/itemlist.php index 33307f645..ba20446cf 100644 --- a/www/app/pages/reference/itemlist.php +++ b/www/app/pages/reference/itemlist.php @@ -431,7 +431,7 @@ public function OnAutoSet($sender) { } $in .= ")"; - return Item::findArray('itemname', "coalesce(item_type,0) <> 1 and coalesce(item_type,0) <>3 and item_id not in {$in} and (itemname like {$text} or item_code like {$text}) and disabled <> 1", 'itemname'); + return Item::findArray('itemname', "coalesce(item_type,0) in (2,5) and item_id not in {$in} and (itemname like {$text} or item_code like {$text}) and disabled <> 1", 'itemname'); } public function OnAddSet($sender) { diff --git a/www/app/pages/register/orderlist.php b/www/app/pages/register/orderlist.php index bbf6911a7..d56effddf 100644 --- a/www/app/pages/register/orderlist.php +++ b/www/app/pages/register/orderlist.php @@ -266,7 +266,7 @@ public function updateStatusButtons() { $this->statuspan->statusform->bttn->setVisible(true); $this->statuspan->statusform->binv->setVisible(false); - $this->statuspan->statusform->bgi->setVisible(false); + $this->statuspan->statusform->bgi->setVisible(true); $this->statuspan->statusform->btask->setVisible(false); } diff --git a/www/app/pages/report/prod.php b/www/app/pages/report/prod.php index b5e06e3a8..3b6f1ddb8 100644 --- a/www/app/pages/report/prod.php +++ b/www/app/pages/report/prod.php @@ -81,8 +81,8 @@ private function generateReport() { join `items` i on e.`item_id` = i.`item_id` join `documents_view` d on d.`document_id` = e.`document_id` - where e.`item_id` >0 and e.`quantity` <>0 - and d.`meta_name` in ('ProdIssue') + where e.`item_id` >0 and e.`quantity` < 0 + and d.`meta_name` in ('ProdIssue','ProdReceipt') {$wparea} AND DATE(e.document_date) >= " . $conn->DBDate($from) . " AND DATE(e.document_date) <= " . $conn->DBDate($to) . " @@ -108,8 +108,8 @@ private function generateReport() { join `items` i on e.`item_id` = i.`item_id` join `documents_view` d on d.`document_id` = e.`document_id` - where e.`item_id` >0 and e.`quantity` <>0 - and d.`meta_name` in ('ProdReceipt') + where e.`item_id` >0 and e.`quantity` >0 + and d.`meta_name` in ('GoodsIssue','ProdIssue','ProdReceipt') AND DATE(e.document_date) >= " . $conn->DBDate($from) . " AND DATE(e.document_date) <= " . $conn->DBDate($to) . " diff --git a/www/templates/pages/doc/goodsissue.html b/www/templates/pages/doc/goodsissue.html index 388abc8a1..86b2614e4 100644 --- a/www/templates/pages/doc/goodsissue.html +++ b/www/templates/pages/doc/goodsissue.html @@ -186,6 +186,10 @@

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

  +   Оприходовать с производства. + + diff --git a/www/templates/pages/doc/prodreceipt.html b/www/templates/pages/doc/prodreceipt.html index e811a4d71..d773f1224 100644 --- a/www/templates/pages/doc/prodreceipt.html +++ b/www/templates/pages/doc/prodreceipt.html @@ -14,12 +14,21 @@

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

- +
- +
+ + + +
@@ -39,13 +48,13 @@

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

- +
- Добавить позицию + Добавить позицию diff --git a/www/templates_ua/pages/doc/goodsissue.html b/www/templates_ua/pages/doc/goodsissue.html index e3b4b4285..d3ec442f2 100644 --- a/www/templates_ua/pages/doc/goodsissue.html +++ b/www/templates_ua/pages/doc/goodsissue.html @@ -185,7 +185,10 @@

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

  - +   Оприбуткувати з виробництва + + diff --git a/www/templates_ua/pages/doc/prodreceipt.html b/www/templates_ua/pages/doc/prodreceipt.html index caab7f899..ac432f80c 100644 --- a/www/templates_ua/pages/doc/prodreceipt.html +++ b/www/templates_ua/pages/doc/prodreceipt.html @@ -19,7 +19,16 @@

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

- +
+ + + +
@@ -45,7 +54,7 @@

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

From 54f17dc874560d45b64bee3ceba6dbcbb15e0d69 Mon Sep 17 00:00:00 2001 From: "HOME\\leonm" Date: Mon, 15 Mar 2021 17:10:05 +0200 Subject: [PATCH 3/5] fix --- www/app/entity/doc/goodsissue.php | 3 ++- www/app/pages/doc/goodsissue.php | 4 +++- www/templates/lang.json | 1 + www/templates_ua/lang.json | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/www/app/entity/doc/goodsissue.php b/www/app/entity/doc/goodsissue.php index 9182764e8..fe0d57010 100644 --- a/www/app/entity/doc/goodsissue.php +++ b/www/app/entity/doc/goodsissue.php @@ -98,8 +98,9 @@ public function Execute() { //оприходуем с производства if( $this->headerdata['fromprod'] ==1 && $item->item_type==Item::TYPE_PROD) { $price = $item->getProdprice() ; + if($price ==0){ - throw new \Exception(H::l('test')) ; + 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); diff --git a/www/app/pages/doc/goodsissue.php b/www/app/pages/doc/goodsissue.php index f557d344e..1bc616668 100644 --- a/www/app/pages/doc/goodsissue.php +++ b/www/app/pages/doc/goodsissue.php @@ -135,6 +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); @@ -1016,7 +1017,8 @@ 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); + $this->docform->fromprod->setVisible(true); + return; } diff --git a/www/templates/lang.json b/www/templates/lang.json index b7bc3bdb9..dbd7038b8 100644 --- a/www/templates/lang.json +++ b/www/templates/lang.json @@ -393,6 +393,7 @@ "paymentseq": "Счета одинаковые" , "custcreated": "Добавлен %s пользователем %s", "custlastdoc": "Последний документ %s от %s. Всего %s" , + "noselfprice": "Не расчитана себестоимость готовой продукции %s", "enterleadsource": "Не введен источник лида", "enterleadstatus": "Не введено состояние лида" } \ No newline at end of file diff --git a/www/templates_ua/lang.json b/www/templates_ua/lang.json index c61fc09d7..6c1ca7271 100644 --- a/www/templates_ua/lang.json +++ b/www/templates_ua/lang.json @@ -382,6 +382,7 @@ "paymentseq": "Рахунки однаковi" , "custcreated": "Доданий %s користувачем %s", "custlastdoc": "Останнiй документ %s вiд %s. Всього %s", + "noselfprice": "Не розрахована собівартість готової продукції %s", "enterleadsource": "Не введено джероло лiда", "enterleadstatus": "Не введений стан лiда" From 844f758d25016af457c0c2abfcc9d1b8907be747 Mon Sep 17 00:00:00 2001 From: "HOME\\leonm" Date: Tue, 16 Mar 2021 09:27:28 +0200 Subject: [PATCH 4/5] fix --- www/app/pages/base.php | 12 +++++++++++- www/assets/css/app.css | 5 ++++- www/templates/pages/base.html | 21 ++++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/www/app/pages/base.php b/www/app/pages/base.php index 318160684..79356d90e 100644 --- a/www/app/pages/base.php +++ b/www/app/pages/base.php @@ -114,6 +114,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(); + } public function LogoutClick($sender) { @@ -215,5 +219,11 @@ public function addJavaScript($js, $docready = false) { public function goDocView() { $this->goAnkor('dankor'); } - + + private function generateTosats() { + + $this->_tvars["toasts"] = array(); + // $this->_tvars["toasts"][] = array('title'=>"title:\"Задайте склад по умолчанию в профиле\"") ; + + } } diff --git a/www/assets/css/app.css b/www/assets/css/app.css index ce153fd61..549cb85bd 100644 --- a/www/assets/css/app.css +++ b/www/assets/css/app.css @@ -111,4 +111,7 @@ body { table { font-family: "Arial" } - \ No newline at end of file +.toast-header { + + background-color: #fff; +} \ No newline at end of file diff --git a/www/templates/pages/base.html b/www/templates/pages/base.html index 0c2c6579f..9c2dadcc8 100644 --- a/www/templates/pages/base.html +++ b/www/templates/pages/base.html @@ -731,6 +731,9 @@
_______________
+ + +
@@ -757,6 +760,9 @@
_______________
+ + +
@@ -766,10 +772,23 @@
_______________
+ +