diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21ec1cbdb..075a82eea 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,13 @@ CHANGELOG
Для обновления версии обновить папки app, templates, templates_ua, assets, выполнить update482to483.sql
+### v4.8.4 (2021-03-01)
+* Интеграция с Новой Почтой (Украина)
+* Настройка подписки на события и уведомлений
+* Интеграция с сервисами рассылок смс.
+
+Для обновления версии обновить папки app, templates, templates_ua, выполнить update483to484.sql
+
### v4.8.2 (2021-01-10)
* Исправление ошибок
diff --git a/db/initdata.sql b/db/initdata.sql
index 7a9228c4c..192a76122 100644
--- a/db/initdata.sql
+++ b/db/initdata.sql
@@ -58,8 +58,8 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(47, 3, 'Журнал платежей', 'PayList', 'Касса и платежи', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(48, 2, 'Движение по денежным счетам', 'PayActivity', 'Платежи', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(64, 1, 'Списание ТМЦ', 'OutcomeItem', 'Склад', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(50, 1, 'Приходный ордер', 'IncomeMoney', 'Платежи', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(51, 1, 'Расходный ордер', 'OutcomeMoney', 'Платежи', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(50, 1, 'Приходный ордер', 'IncomeMoney', 'Касса и платежи', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(51, 1, 'Расходный ордер', 'OutcomeMoney', 'Касса и платежи', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(53, 2, 'Финансовые результаты', 'PayBalance', '', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(57, 1, 'Инвентаризация', 'Inventory', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(58, 1, 'Счет входящий', 'InvoiceCust', 'Закупки', 0);
@@ -72,9 +72,9 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(75, 5, 'Экспорт', 'Export', '', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(67, 5, 'АРМ кассира', 'ARMPos', '', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(71, 3, 'Товары на складе', 'ItemList', 'Склад', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(76, 1, 'Выплата зарплаты', 'OutSalary', 'Платежи', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(76, 1, 'Выплата зарплаты', 'OutSalary', 'Касса и платежи', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(77, 2, 'Отчет по зарплате', 'SalaryRep', 'Зарплата', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(78, 2, 'Движение по контрагентам', 'CustActivity', 'Платежи', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(78, 2, 'Движение по контрагентам', 'CustActivity', 'Касса и платежи', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(81, 4, 'Договора', 'ContractList', '', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(82, 1, 'Перемещение товара', 'MoveItem', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(83, 2, 'Рабочее время', 'Timestat', 'Зарплата', 0);
@@ -82,4 +82,7 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(85, 2, 'Неликвидные товары', 'NoLiq', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(86, 3, 'Расчеты с поставщиками', 'PaySelList', 'Касса и платежи', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(87, 3, 'Расчеты с покупателями', 'PayBayList', 'Касса и платежи', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(88, 1, 'Перемещение денег', 'MoveMoney', 'Касса и платежи', 0);
+
+
\ No newline at end of file
diff --git a/db/initdata_ua.sql b/db/initdata_ua.sql
index 79cad86bd..2c680f0f0 100644
--- a/db/initdata_ua.sql
+++ b/db/initdata_ua.sql
@@ -55,10 +55,10 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(44, 1, 'Перекомплектація ТМЦ', 'TransItem', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(46, 4, 'Каси, рахунки', 'MFList', '', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(47, 3, 'Журнал платежів', 'PayList', 'Каса та платежі', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(48, 2, 'Рух по грошовим рахунках', 'PayActivity', 'Платежі', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(50, 1, 'Прибутковий ордер', 'IncomeMoney', 'Платежі', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(51, 1, 'Видатковий ордер', 'OutcomeMoney', 'Платежі', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(53, 2, 'Платіжний баланс', 'PayBalance', 'Платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(48, 2, 'Рух по грошовим рахунках', 'PayActivity', 'Каса та платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(50, 1, 'Прибутковий ордер', 'IncomeMoney', 'Каса та платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(51, 1, 'Видатковий ордер', 'OutcomeMoney', 'Каса та платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(53, 2, 'Платіжний баланс', 'PayBalance', 'Каса та платежі', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(57, 1, 'Інвентаризація', 'Inventory', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(58, 1, 'Рахунок, вхідний', 'InvoiceCust', 'Закупки', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(59, 1, 'Рахунок-фактура', 'Invoice', 'Продажі', 0);
@@ -72,9 +72,9 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(69, 3, 'Роботи, послуги', 'SerList', '', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(71, 3, 'Товари на складі', 'ItemList', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(75, 5, 'Експорт', 'Export', '', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(76, 1, 'Виплата зарплати', 'OutSalary', 'Платежі', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(77, 2, 'Звіт по зарплаті', 'SalaryRep', 'Платежі', 0);
-INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(78, 2, 'Рух по контрагентах', 'CustActivity', 'Платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(76, 1, 'Виплата зарплати', 'OutSalary', 'Каса та платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(77, 2, 'Звіт по зарплаті', 'SalaryRep', 'Каса та платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(78, 2, 'Рух по контрагентах', 'CustActivity', 'Каса та платежі', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(79, 4, 'Контракти', 'ContractList', '', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(80, 1, 'Перемiщення ТМЦ', 'MoveItem', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(81, 2, 'Робочий час', 'Timestat', '', 0);
@@ -82,3 +82,4 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(85, 2, 'Нелiквiднi товари', 'NoLiq', 'Склад', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(86, 3, 'Розрахунки с поставщиками', 'PaySelList', 'Каса та платежі', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(87, 3, 'Розрахунки с покупателями', 'PayBayList', 'Каса та платежі', 0);
+INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(88, 1, 'Перемiщення грошей', 'MoveMoney', 'Каса та платежі', 0);
diff --git a/db/temp.sql b/db/temp.sql
new file mode 100644
index 000000000..76efe0a91
--- /dev/null
+++ b/db/temp.sql
@@ -0,0 +1,30 @@
+ /*
+
+
+CREATE TABLE `empacc` (
+ `ea_id` int(11) NOT NULL AUTO_INCREMENT,
+ `emp_id` int(11) NOT NULL,
+ `document_id` int(11) DEFAULT NULL,
+ `optype` int(11) DEFAULT NULL,
+ //`createdon` date NOT NULL,
+ `notes` varchar(255) DEFAULT NULL,
+ `amount` decimal(10,2) NOT NULL,
+
+ PRIMARY KEY (`ea_id`),
+ KEY `emp_id` (`emp_id`)
+) engine=InnoDB DEFAULT CHARSET=utf8;
+
+
+
+CREATE TABLE `prodproc` (
+ `pp_id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(255) DEFAULT NULL,
+ `detail` LONGTEXT DEFAULT NULL,
+ PRIMARY KEY (`pp_id`)
+
+) engine=InnoDB DEFAULT CHARSET=utf8;
+
+
+
+
+ */
\ No newline at end of file
diff --git a/db/update483to484.sql b/db/update483to484.sql
index 7354dd5a4..7c3ec7691 100644
--- a/db/update483to484.sql
+++ b/db/update483to484.sql
@@ -1,4 +1,3 @@
-
CREATE TABLE `subscribes` (
`sub_id` int(11) NOT NULL AUTO_INCREMENT,
`sub_type` int(11) DEFAULT NULL,
@@ -6,38 +5,12 @@
`reciever_type` int(11) DEFAULT NULL,
`msg_type` int(11) DEFAULT NULL,
- `detail` LONGTEXT DEFAULT NULL,
+ `detail` TEXT DEFAULT NULL,
+ `msgtext` TEXT DEFAULT NULL,
`disabled` int(1) DEFAULT 0,
PRIMARY KEY (`sub_id`)
) engine=InnoDB DEFAULT CHARSET=utf8;
- /*
-
-CREATE TABLE `empacc` (
- `ea_id` int(11) NOT NULL AUTO_INCREMENT,
- `emp_id` int(11) NOT NULL,
- `document_id` int(11) DEFAULT NULL,
- `optype` int(11) DEFAULT NULL,
- //`createdon` date NOT NULL,
- `notes` varchar(255) DEFAULT NULL,
- `amount` decimal(10,2) NOT NULL,
-
- PRIMARY KEY (`ea_id`),
- KEY `emp_id` (`emp_id`)
-) engine=InnoDB DEFAULT CHARSET=utf8;
-
-
-
-CREATE TABLE `prodproc` (
- `pp_id` int(11) NOT NULL AUTO_INCREMENT,
- `name` varchar(255) DEFAULT NULL,
- `detail` LONGTEXT DEFAULT NULL,
- PRIMARY KEY (`pp_id`)
-
-) engine=InnoDB DEFAULT CHARSET=utf8;
-
-
-
-
- */
\ No newline at end of file
+INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 1, 'Перемещение денег', 'MoveMoney', 'Платежи', 0);
+
\ No newline at end of file
diff --git a/www/app/calendar.php b/www/app/calendar.php
index 2e6e147c8..95577eaf2 100644
--- a/www/app/calendar.php
+++ b/www/app/calendar.php
@@ -7,7 +7,14 @@ class Calendar extends \Zippy\Html\HtmlComponent implements \Zippy\Interfaces\Re
private $event = null;
private $data = array();
+ private $view = 'month';
+ public function __construct($id,$view='month') {
+ parent::__construct($id);
+ $this->view = $view;
+ }
+
+
public final function RenderImpl() {
global $_config;
$id = $this->getAttribute('id');
@@ -36,7 +43,7 @@ public final function RenderImpl() {
center: 'title',
right: ' prev,next'
},
- defaultView: 'month',
+ defaultView: '{$this->view}',
eventTextColor:'white',
minTime: '08:00:00',
maxTime: '20:00:00',
diff --git a/www/app/entity/contract.php b/www/app/entity/contract.php
index 08b068fdd..476beee8a 100644
--- a/www/app/entity/contract.php
+++ b/www/app/entity/contract.php
@@ -115,13 +115,14 @@ public function getDolg() {
$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 .= "
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 payamount <> payed
+ 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
diff --git a/www/app/entity/customer.php b/www/app/entity/customer.php
index 64c65a98a..044eff639 100644
--- a/www/app/entity/customer.php
+++ b/www/app/entity/customer.php
@@ -14,7 +14,7 @@ class Customer extends \ZCL\DB\Entity
const STATUS_ACTUAL = 0; //актуальный
const STATUS_DISABLED = 1; //не используется
- const STATUS_WAIT = 2; //потенциальный
+ // const STATUS_WAIT = 2; //потенциальный
const TYPE_BAYER = 1; //покупатель
@@ -37,6 +37,9 @@ protected function beforeSave() {
$this->detail .= "{$this->shopcust_id}";
$this->detail .= "{$this->isholding}";
$this->detail .= "{$this->holding}";
+ $this->detail .= "{$this->viber}";
+ $this->detail .= "{$this->created}";
+ $this->detail .= "{$this->user_id}";
$this->detail .= "holding_name}]]>";
$this->detail .= "
address}]]>";
@@ -56,10 +59,13 @@ protected function afterLoad() {
$this->jurid = (int)($xml->jurid[0]);
$this->shopcust_id = (int)($xml->shopcust_id[0]);
$this->isholding = (int)($xml->isholding[0]);
+ $this->user_id = (int)($xml->user_id[0]);
+ $this->created = (int)($xml->created[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]);
parent::afterLoad();
}
diff --git a/www/app/entity/doc/document.php b/www/app/entity/doc/document.php
index 16bfe274f..551465b25 100644
--- a/www/app/entity/doc/document.php
+++ b/www/app/entity/doc/document.php
@@ -248,7 +248,7 @@ protected function Cancel() {
$conn->Execute("delete from entrylist where document_id =" . $this->document_id);
//удаляем освободившиеся стоки
- $conn->Execute("delete from store_stock where stock_id not in (select coalesce(stock_id,0) from entrylist) ");
+ $conn->Execute("delete from store_stock where stock_id not in (select stock_id from entrylist) ");
//отменяем оплаты
$conn->Execute("delete from paylist where document_id = " . $this->document_id);
@@ -361,15 +361,21 @@ public function updateStatus($state) {
if ($oldstate != $state) {
$doc = $this->cast();
- $doc->onState($oldstate, $state);
- \App\Entity\Subscribe::onDocumentState($doc->meta_name,$state) ;
+ $doc->onState( $state);
+ \App\Entity\Subscribe::onDocumentState($doc->document_id,$state) ;
}
return true;
}
- //обработчик изменения статусов
- protected function onState($oldstate, $state) {
+
+ /**
+ * обработчик изменения статусов
+ * переопределяется в дочерних документах
+ *
+ * @param mixed $state новый статус
+ */
+ protected function onState( $state) {
}
diff --git a/www/app/entity/doc/movemoney.php b/www/app/entity/doc/movemoney.php
new file mode 100644
index 000000000..f3274240c
--- /dev/null
+++ b/www/app/entity/doc/movemoney.php
@@ -0,0 +1,46 @@
+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);
+
+
+ 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"],
+ "document_number" => $this->document_number
+ );
+ $report = new \App\Report('doc/movemoney.tpl');
+
+ $html = $report->generate($header);
+
+ return $html;
+ }
+
+ protected function getNumberTemplate() {
+ return 'ПМ-000000';
+ }
+
+}
diff --git a/www/app/entity/doc/order.php b/www/app/entity/doc/order.php
index 29aec1f50..2a1653203 100644
--- a/www/app/entity/doc/order.php
+++ b/www/app/entity/doc/order.php
@@ -22,7 +22,8 @@ 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)) {
$t = "Опции: | |
";
@@ -31,13 +32,14 @@ public function generateReport() {
}
$t .= "
";
$item->itemname = $item->itemname . $t;
- }
+ } */
$detail[] = array("no" => $i++,
"tovar_name" => $item->itemname,
"tovar_code" => $item->item_code,
"quantity" => H::fqty($item->quantity),
"price" => H::fa($item->price),
"msr" => $item->msr,
+ "desc" => $item->desc,
"amount" => H::fa($item->quantity * $item->price)
);
}
@@ -71,7 +73,7 @@ public function generateReport() {
protected function getNumberTemplate() {
- return 'ЗК-000000';
+ return 'З-000000';
}
public function getRelationBased() {
@@ -82,6 +84,7 @@ public function getRelationBased() {
$list['POSCheck'] = self::getDesc('POSCheck');
$list['Task'] = self::getDesc('Task');
$list['TTN'] = self::getDesc('TTN');
+ $list['OrderCust'] = self::getDesc('OrderCust');
return $list;
@@ -128,7 +131,7 @@ public function generatePosReport() {
}
- protected function onState($oldstate, $state) {
+ protected function onState( $state) {
if ($state == self::STATE_INPROCESS) {
//списываем бонусы
diff --git a/www/app/entity/doc/ordercust.php b/www/app/entity/doc/ordercust.php
index 5d9795ab8..8e6480868 100644
--- a/www/app/entity/doc/ordercust.php
+++ b/www/app/entity/doc/ordercust.php
@@ -25,7 +25,8 @@ public function generateReport() {
"quantity" => H::fqty($item->quantity),
"price" => H::fa($item->price),
"msr" => $item->msr,
- "amount" => H::fa($item->quantity * $item->price)
+ "desc" => $item->desc,
+ "amount" => H::fa($item->quantity * $item->price)
);
}
@@ -46,7 +47,7 @@ public function generateReport() {
protected function getNumberTemplate() {
- return 'ЗКП-000000';
+ return 'ЗП-000000';
}
public function getRelationBased() {
diff --git a/www/app/entity/doc/task.php b/www/app/entity/doc/task.php
index 806d83d21..17dcfe32c 100644
--- a/www/app/entity/doc/task.php
+++ b/www/app/entity/doc/task.php
@@ -33,6 +33,7 @@ public function generateReport() {
}
$detail[] = array("no" => $i++,
"service_name" => $ser->service_name,
+ "desc" => $ser->desc,
"quantity" => H::fqty($ser->quantity),
"cost" => H::fa($ser->cost * $ser->quantity),
diff --git a/www/app/entity/doc/ttn.php b/www/app/entity/doc/ttn.php
index 3dde2e971..53bcde783 100644
--- a/www/app/entity/doc/ttn.php
+++ b/www/app/entity/doc/ttn.php
@@ -180,7 +180,7 @@ public function Execute() {
return true;
}
- public function onState($oldstate, $state) {
+ public function onState( $state) {
if ($state == Document::STATE_INSHIPMENT) {
//расходы на доставку
@@ -199,10 +199,10 @@ public function onState($oldstate, $state) {
$list = $order->getChildren('TTN');
if (count($list) == 1 && $common['numberttn'] <> 1) { //только эта ТТН
- if ($state == Document::STATE_DELIVERED && $order->state == Document::STATE_INSHIPMENT) {
+ 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) {
+ 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/item.php b/www/app/entity/item.php
index 5dd18153f..680d0a3aa 100644
--- a/www/app/entity/item.php
+++ b/www/app/entity/item.php
@@ -374,7 +374,7 @@ public static function findArrayAC($partname, $store = 0, $cat = 0) {
if (strlen($partname) > 0) {
$like = self::qstr('%' . $partname . '%');
$partname = self::qstr($partname);
- $criteria .= " and (itemname like {$like} or item_code = {$partname} or bar_code = {$partname} )";
+ $criteria .= " and (itemname like {$like} or item_code like {$like} or bar_code like {$like} )";
}
$itemlist = self::find($criteria);
diff --git a/www/app/entity/pay.php b/www/app/entity/pay.php
index d756583df..cb7444497 100644
--- a/www/app/entity/pay.php
+++ b/www/app/entity/pay.php
@@ -154,25 +154,25 @@ public static function cancelPayment($id, $comment) {
public static function getPayTypeList($type = 0) {
$list = array();
if ($type != 2) {
- $list[PAY::PAY_BASE_INCOME] = \App\Helper::l('pt_inprod');
+ $list[self::PAY_BASE_INCOME] = \App\Helper::l('pt_inprod');
- $list[PAY::PAY_OTHER_INCOME] = \App\Helper::l('pt_inother');
- $list[PAY::PAY_FIN] = \App\Helper::l('pt_fin');
+ $list[self::PAY_OTHER_INCOME] = \App\Helper::l('pt_inother');
+ $list[self::PAY_FIN] = \App\Helper::l('pt_fin');
}
if ($type != 1) {
- $list[PAY::PAY_BASE_OUTCOME] = \App\Helper::l('pt_outprod');
- $list[PAY::PAY_COMMON_OUTCOME] = \App\Helper::l('pt_outcommon');
- $list[PAY::PAY_ADMIN_OUTCOME] = \App\Helper::l('pt_outadm');
- $list[PAY::PAY_SALE_OUTCOME] = \App\Helper::l('pt_outsell');
- $list[PAY::PAY_SALARY_OUTCOME] = \App\Helper::l('pt_outsalary');
- $list[PAY::PAY_TAX_OUTCOME] = \App\Helper::l('pt_outtax');
- $list[PAY::PAY_BILL_OUTCOME] = \App\Helper::l('pt_outrent');
- $list[PAY::PAY_DIVIDEND_OUTCOME] = \App\Helper::l('pt_outcap');
- $list[PAY::PAY_OTHER_OUTCOME] = \App\Helper::l('pt_outother');
- $list[PAY::PAY_INV] = \App\Helper::l('pt_inv');
- $list[PAY::PAY_BANK] = \App\Helper::l('pt_bank');
+ $list[self::PAY_BASE_OUTCOME] = \App\Helper::l('pt_outprod');
+ $list[self::PAY_COMMON_OUTCOME] = \App\Helper::l('pt_outcommon');
+ $list[self::PAY_ADMIN_OUTCOME] = \App\Helper::l('pt_outadm');
+ $list[self::PAY_SALE_OUTCOME] = \App\Helper::l('pt_outsell');
+ $list[self::PAY_SALARY_OUTCOME] = \App\Helper::l('pt_outsalary');
+ $list[self::PAY_TAX_OUTCOME] = \App\Helper::l('pt_outtax');
+ $list[self::PAY_BILL_OUTCOME] = \App\Helper::l('pt_outrent');
+ $list[self::PAY_DIVIDEND_OUTCOME] = \App\Helper::l('pt_outcap');
+ $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');
}
diff --git a/www/app/entity/stock.php b/www/app/entity/stock.php
index e3eccec5f..dfa9e3707 100644
--- a/www/app/entity/stock.php
+++ b/www/app/entity/stock.php
@@ -162,10 +162,14 @@ 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 ") ;
+ if($lastpartion==0) $lastpartion= $price;
+
$last = new Stock();
$last->store_id = $store_id;
$last->item_id = $item->item_id;
- $last->partion = 0;
+ $last->partion = $lastpartion;
$last->snumber = $item->snumber;
$last->sdate = $item->sdate;
diff --git a/www/app/entity/subscribe.php b/www/app/entity/subscribe.php
index ed79d6778..5b97025a0 100644
--- a/www/app/entity/subscribe.php
+++ b/www/app/entity/subscribe.php
@@ -2,6 +2,9 @@
namespace App\Entity;
+use App\Helper as H;
+use App\System ;
+
/**
* Класс-сущность подписка на событие
*
@@ -10,24 +13,40 @@
*/
class Subscribe extends \ZCL\DB\Entity
{
- const TYPE_DOCSTATE =1;
+ //типы событий
+ const EVENT_DOCSTATE =1;
+
+ //типы сообщений
+ const MSG_NOTIFY = 1;
+ const MSG_EMAIL = 2;
+ const MSG_SMS = 3;
+ const MSG_VIBER = 4;
+
+ //типы получателей
+ const RSV_CUSTOMER =1;
+ const RSV_DOCAUTHOR =2;
+ const RSV_USER =3;
+
protected function init() {
- $this->cat_id = 0;
+ $this->sub_id = 0;
}
-
-
-
+
protected function afterLoad() {
-
-
+
$xml = @simplexml_load_string($this->detail);
- $this->docmetaname = (string)($xml->docmetaname[0]);
- $this->docstate = (int)($xml->docstate[0]);
-
-
-
+ $this->sub_typename = (string)($xml->sub_typename[0]);
+ $this->reciever_typename = (string)($xml->reciever_typename[0]);
+ $this->msg_typename = (string)($xml->msg_typename[0]);
+ $this->statename = (string)($xml->statename[0]);
+ $this->doctypename = (string)($xml->doctypename[0]);
+ $this->msgsubject = (string)($xml->msgsubject[0]);
+ $this->username = (string)($xml->username[0]);
+ $this->user_id = (int)($xml->user_id[0]);
+ $this->state = (int)($xml->state[0]);
+ $this->doctype = (int)($xml->doctype[0]);
+
parent::afterLoad();
}
@@ -36,21 +55,282 @@ protected function beforeSave() {
$this->detail = "";
- $this->detail .= "{$this->docmetaname}";
- $this->detail .= "{$this->docstate}";
-
-
-
+ $this->detail .= "{$this->docmetaname}";
+ $this->detail .= "{$this->reciever_typename}";
+ $this->detail .= "{$this->msg_typename}";
+ $this->detail .= "{$this->user_id}";
+ $this->detail .= "{$this->state}";
+ $this->detail .= "{$this->doctype}";
+ $this->detail .= "{$this->doctypename}";
+ $this->detail .= "{$this->statename}";
+ $this->detail .= "{$this->username}";
+ $this->detail .= "{$this->msgsubject}";
+
+
$this->detail .= "";
return true;
}
- public static function onDocumentState($metaname,$state) {
-
- // $list = self::find('disabled <> 1 and sub_type= '. self::TYPE_DOCSTATE) ;
-
+
+
+
+
+ public static function getEventList(){
+ $list = array();
+ $list[self::EVENT_DOCSTATE]= H::l("sb_docstate");
+
+ return $list;
+
+ }
+ 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;
+
+ }
+ 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;
+
+ }
+
+ //изменение состояние документа
+ 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) ;
+ }
+
+ }
+
+ }
+
+ /**
+ * возвращает текст с учетом разметки
+ *
+ * @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)
+ ) ;
+ }
+
+
+ $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) {
+ $common = System::getOptions("common");
+
+ H::sendLetter($text,'',$email,$subject) ;
+ }
+ 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 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);
+ 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.'"
+ ],
+ "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);
+ 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('Заметьте, что когда герой фильма подписывает договор с Сатаной, он не подписывает копию договора и не получает ее.'));
+
+ $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_SSL_VERIFYPEER, FALSE);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_URL, 'http://sms-fly.com/api/api.noai.php');
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml", "Accept: text/xml"));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $myXML);
+ $response = curl_exec($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/entity/user.php b/www/app/entity/user.php
index 8f6e7ed95..a6c2fe6d1 100644
--- a/www/app/entity/user.php
+++ b/www/app/entity/user.php
@@ -88,6 +88,8 @@ protected function afterLoad() {
$this->defstore = (int)$options['defstore'];
$this->defmf = (int)$options['defmf'];
$this->pagesize = (int)$options['pagesize'];
+ $this->phone = (string)$options['phone'];
+ $this->viber = (string)$options['viber'];
$this->hidesidebar = (int)$options['hidesidebar'];
@@ -107,6 +109,8 @@ protected function beforeSave() {
$acl['aclbranch'] = $this->aclbranch;
$acl['onlymy'] = $this->onlymy;
+ $acl['phone'] = $this->phone;
+ $acl['viber'] = $this->viber;
$this->acl = serialize($acl);
diff --git a/www/app/helper.php b/www/app/helper.php
index f5ac947ef..9727ca2da 100644
--- a/www/app/helper.php
+++ b/www/app/helper.php
@@ -227,7 +227,9 @@ 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'] ;
+
$mail = new \PHPMailer\PHPMailer\PHPMailer();
$mail->setFrom($emailfrom);
$mail->addAddress($emailto);
@@ -371,6 +373,15 @@ public static function log($msg) {
global $logger;
$logger->debug($msg);
}
+ /**
+ * логгирование ошибок
+ *
+ * @param mixed $msg
+ */
+ public static function logerror($msg) {
+ global $logger;
+ $logger->error($msg);
+ }
/**
* Возвращает компанию по умолчанию
@@ -695,8 +706,7 @@ public static function getValName($vn) {
return 'RUB';
}
}
-
-
+
public static function exportExcel($data, $header, $filename) {
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
@@ -786,5 +796,6 @@ public static function exportExcel($data, $header, $filename) {
$writer->save('php://output');
die;
}
-
+
+
}
diff --git a/www/app/modules/np/helper.php b/www/app/modules/np/helper.php
index 0a3aa9ecc..6e66513bf 100644
--- a/www/app/modules/np/helper.php
+++ b/www/app/modules/np/helper.php
@@ -52,8 +52,30 @@ public function getPointList($cityref) {
}
//проверка экспрес накладной
- public function check($dec) {
- return $this->model('TrackingDocument"')->getStatusDocuments($dec);
+ public function check($docs) {
+ $ar = array() ;
+ foreach($docs as $track) {
+ $ar[]=array('DocumentNumber' => $track) ;
+ }
+ 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']);
+ }
+
+ }
+ return $list;
+
/*
1 Нова пошта очікує надходження від відправника
2 Видалено
diff --git a/www/app/modules/np/ttnlist.php b/www/app/modules/np/ttnlist.php
new file mode 100644
index 000000000..16aa6543d
--- /dev/null
+++ b/www/app/modules/np/ttnlist.php
@@ -0,0 +1,128 @@
+modules, 'np') === false && System::getUser()->rolename != 'admins') {
+ System::setErrorMsg(H::l('noaccesstopage'));
+
+ App::RedirectError();
+ return;
+ }
+
+ $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->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::l($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();
+ $errors = array();
+ $docs = Document::find("content like '%%' and meta_name = 'TTN' and state in(11,20) ");
+ $tracks = array();
+ foreach ($docs as $ttn) {
+ $tracks[]=$ttn->headerdata['ship_number'];
+ }
+
+ $statuses = $api->check($tracks);
+
+ foreach ($docs as $ttn) {
+
+ $decl = $ttn->headerdata['ship_number'];
+
+ $cnt = 0;
+
+
+ $st = $statuses[$decl]['Status'];
+ $code = $statuses[$decl]['StatusCode'];
+ $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++;
+ }
+ if (in_array($code, array(4, 5, 6, 7, 8, 41, 101))) {
+ $ttn->updateStatus(Document::STATE_INSHIPMENT);
+ $cnt++;
+ }
+ if (in_array($code, array(102, 103, 104, 108, 105, 2, 3))) {
+ $errors[] = $ttn->headerdata['ship_number'] . " - " . $st;
+ }
+ if (count($errors) > 0) {
+ $this->setError(Implode('
', $errors));
+ } else {
+ $this->setSuccess("npupdated", $cnt);
+ }
+
+ $this->_doclist[$ttn->document_id]=$ttn;
+ }
+
+ $this->doclist->Reload();
+ }
+
+ public function printOnClick($sender) {
+ $ttn = $sender->getOwner()->getDataItem();
+ $decl = $ttn->headerdata['ship_number'];
+
+ $api = new \App\Modules\NP\Helper();
+
+
+ $html="";
+ $this->updateAjax(array(), " $('#tag').html('{$html}') ; $('#pform').modal()");
+ }
+
+}
+
+
\ No newline at end of file
diff --git a/www/app/modules/ocstore/orders.php b/www/app/modules/ocstore/orders.php
index f2ce358d3..8fc252f1d 100644
--- a/www/app/modules/ocstore/orders.php
+++ b/www/app/modules/ocstore/orders.php
@@ -151,7 +151,14 @@ public function onImport($sender) {
}
$tovar->quantity = $product['quantity'];
$tovar->price = round($product['price']);
- $tovar->octoreoptions = serialize($product['_options_']);
+ $desc='';
+ if(array($product['_options_'] )) {
+ foreach($product['_options_'] as $k => $v){
+ $desc= $desc . $k.':'.$v.';';
+ }
+ }
+ //$tovar->octoreoptions = serialize($product['_options_']);
+ $tovar->desc = $desc;
$tlist[] = $tovar;
}
diff --git a/www/app/modules/wc/orders.php b/www/app/modules/wc/orders.php
index 44e4cf9ed..5e246b7e5 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);
- //$tovar->octoreoptions = serialize($product['_options_']);
+
$itlist[] = $tovar;
}
$neworder->packDetails('detaildata', $itlist);
diff --git a/www/app/pages/base.php b/www/app/pages/base.php
index 0c2d152ec..318160684 100644
--- a/www/app/pages/base.php
+++ b/www/app/pages/base.php
@@ -26,14 +26,26 @@ public function __construct($params = null) {
App::Redirect("\\App\\Pages\\Userlogin");
return;
}
-
-
- $this->branch_id = System::getBranch();
- $blist = \App\Entity\Branch::getList(System::getUser()->user_id);
- if (count($blist) == 1) {
- $k = array_keys($blist);//если одна
- $this->branch_id = array_pop($k);
- System::setBranch($this->branch_id);
+
+ $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;
+
+ $blist = array();
+ if($this->_tvars["usebranch"]==true) {
+ $this->branch_id = System::getBranch();
+ $blist = \App\Entity\Branch::getList(System::getUser()->user_id);
+ if (count($blist) == 1) {
+ $k = array_keys($blist);//если одна
+ $this->branch_id = array_pop($k);
+ System::setBranch($this->branch_id);
+ }
}
//форма филиалов
$this->add(new \Zippy\Html\Form\Form('nbform'));
@@ -53,15 +65,8 @@ public function __construct($params = null) {
$this->_tvars["isadmin"] = $user->userlogin == 'admin';
$this->_tvars["isadmins"] = $user->rolename == 'admins';
- $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;
-
+
+
if ($this->_tvars["usebranch"] == false) {
$this->branch_id = 0;
diff --git a/www/app/pages/doc/goodsissue.php b/www/app/pages/doc/goodsissue.php
index 5c2c59ef1..32205416d 100644
--- a/www/app/pages/doc/goodsissue.php
+++ b/www/app/pages/doc/goodsissue.php
@@ -69,7 +69,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()))->onChange($this, 'OnChangeStore');
+ $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())) ;
$this->docform->add(new SubmitLink('addcust'))->onClick($this, 'addcustOnClick');
@@ -182,7 +182,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']);
@@ -841,11 +841,7 @@ public function backtolistOnClick($sender) {
App::RedirectBack();
}
- public function OnChangeStore($sender) {
- //очистка списка товаров
- $this->_itemlist = array();
- $this->docform->detail->Reload();
- }
+
public function OnChangeItem($sender) {
$id = $sender->getKey();
diff --git a/www/app/pages/doc/movemoney.php b/www/app/pages/doc/movemoney.php
new file mode 100644
index 000000000..33024a688
--- /dev/null
+++ b/www/app/pages/doc/movemoney.php
@@ -0,0 +1,159 @@
+add(new Form('docform'));
+ $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'));
+ $this->docform->add(new TextInput('amount'));
+ $this->docform->add(new SubmitButton('savedoc'))->onClick($this, 'savedocOnClick');
+ $this->docform->add(new SubmitButton('execdoc'))->onClick($this, 'savedocOnClick');
+ $this->docform->add(new Button('backtolist'))->onClick($this, 'backtolistOnClick');
+
+
+ if ($docid > 0) { //загружаем содержимое документа на страницу
+ $this->_doc = Document::load($docid)->cast();
+ $this->docform->document_number->setText($this->_doc->document_number);
+ $this->docform->document_date->setDate($this->_doc->document_date);
+
+ $this->docform->paymentfrom->setValue($this->_doc->headerdata['paymentfrom']);
+ $this->docform->paymentto->setValue($this->_doc->headerdata['paymentto']);
+ $this->docform->notes->setText($this->_doc->notes);
+ $this->docform->amount->setText($this->_doc->amount);
+ } else {
+ $this->_doc = Document::create('MoveMoney');
+ $this->docform->document_number->setText($this->_doc->nextNumber());
+ }
+
+
+ if (false == \App\ACL::checkShowDoc($this->_doc)) {
+ return;
+ }
+
+ }
+
+ public function savedocOnClick($sender) {
+ if (false == \App\ACL::checkEditDoc($this->_doc)) {
+ return;
+ }
+ $this->_doc->notes = $this->docform->notes->getText();
+
+ $this->_doc->headerdata['paymentto'] = $this->docform->paymentto->getValue();
+ $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());
+ $this->_doc->payment = 0;
+ $this->_doc->payed = 0;
+ if ($this->checkForm() == false) {
+ return;
+ }
+
+ $isEdited = $this->_doc->document_id > 0;
+
+ $conn = \ZDB\DB::getConnect();
+ $conn->BeginTrans();
+ try {
+
+ $this->_doc->save();
+
+
+ if ($sender->id == 'execdoc') {
+ if (!$isEdited) {
+ $this->_doc->updateStatus(Document::STATE_NEW);
+ }
+ $this->_doc->updateStatus(Document::STATE_EXECUTED);
+ } else {
+ $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
+ }
+ $conn->CommitTrans();
+ App::RedirectBack();
+ } catch(\Throwable $ee) {
+ global $logger;
+ $conn->RollbackTrans();
+ if ($isEdited == false) {
+ $this->_doc->document_id = 0;
+ }
+ $this->setError($ee->getMessage());
+ $logger->error($ee->getMessage() . " Документ " . $this->_doc->meta_desc);
+
+ return;
+ }
+ }
+
+ /**
+ * Валидация формы
+ *
+ */
+ private function checkForm() {
+
+ if (strlen($this->_doc->document_number) == 0) {
+ $this->setError("enterdocnumber");
+ }
+ if (false == $this->_doc->checkUniqueNumber()) {
+ $next = $this->_doc->nextNumber();
+ $this->docform->document_number->setText($next);
+ $this->_doc->document_number = $next;
+ if (strlen($next) == 0) {
+ $this->setError('docnumbercancreated');
+ }
+ }
+
+ 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'] == $this->_doc->headerdata['paymentfrom']) {
+ $this->setError("paymentseq");
+ }
+
+ return !$this->isError();
+ }
+
+ public function backtolistOnClick($sender) {
+ App::RedirectBack();
+ }
+
+
+
+
+
+}
diff --git a/www/app/pages/doc/order.php b/www/app/pages/doc/order.php
index d09db310b..b0505f6a5 100644
--- a/www/app/pages/doc/order.php
+++ b/www/app/pages/doc/order.php
@@ -83,6 +83,7 @@ public function __construct($docid = 0, $basedocid = 0) {
$this->add(new Form('editdetail'))->setVisible(false);
$this->editdetail->add(new TextInput('editquantity'))->setText("1");
$this->editdetail->add(new TextInput('editprice'));
+ $this->editdetail->add(new TextInput('editdesc'));
$this->editdetail->add(new AutocompleteTextInput('edittovar'))->onText($this, 'OnAutoItem');
$this->editdetail->edittovar->onChange($this, 'OnChangeItem', true);
@@ -157,6 +158,7 @@ public function detailOnRow($row) {
$row->add(new Label('code', $item->item_code));
$row->add(new Label('msr', $item->msr));
+ $row->add(new Label('desc', $item->desc));
$row->add(new Label('quantity', H::fqty($item->quantity)));
$row->add(new Label('price', H::fa($item->price)));
@@ -171,8 +173,7 @@ public function deleteOnClick($sender) {
return;
}
$tovar = $sender->owner->getDataItem();
- // unset($this->_tovarlist[$tovar->tovar_id]);
-
+
$this->_tovarlist = array_diff_key($this->_tovarlist, array($tovar->item_id => $this->_tovarlist[$tovar->item_id]));
$this->docform->detail->Reload();
$this->calcTotal();
@@ -183,6 +184,7 @@ public function addrowOnClick($sender) {
$this->editdetail->setVisible(true);
$this->editdetail->editquantity->setText("1");
$this->editdetail->editprice->setText("0");
+ $this->editdetail->editdesc->setText("");
$this->docform->setVisible(false);
$this->_rowid = 0;
}
@@ -194,6 +196,7 @@ public function editOnClick($sender) {
$this->editdetail->editquantity->setText($item->quantity);
$this->editdetail->editprice->setText($item->price);
+ $this->editdetail->editdesc->setText($item->desc);
$this->editdetail->edittovar->setKey($item->item_id);
@@ -217,6 +220,7 @@ public function saverowOnClick($sender) {
$item->price = $this->editdetail->editprice->getText();
+ $item->desc = $this->editdetail->editdesc->getText();
unset($this->_tovarlist[$this->_rowid]);
diff --git a/www/app/pages/doc/ordercust.php b/www/app/pages/doc/ordercust.php
index 860f0a463..0f7409d27 100644
--- a/www/app/pages/doc/ordercust.php
+++ b/www/app/pages/doc/ordercust.php
@@ -60,6 +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 Button('cancelrow'))->onClick($this, 'cancelrowOnClick');
$this->editdetail->add(new SubmitButton('saverow'))->onClick($this, 'saverowOnClick');
@@ -93,7 +94,18 @@ public function __construct($docid = 0, $basedocid = 0) {
$basedoc = Document::load($basedocid);
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();
@@ -113,6 +125,7 @@ public function detailOnRow($row) {
$row->add(new Label('quantity', H::fqty($item->quantity)));
$row->add(new Label('price', H::fa($item->price)));
$row->add(new Label('msr', $item->msr));
+ $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');
@@ -129,6 +142,7 @@ public function editOnClick($sender) {
$this->editdetail->editcustcode->setText($item->custcode);
$this->editdetail->editquantity->setText($item->quantity);
$this->editdetail->editprice->setText($item->price);
+ $this->editdetail->editdesc->setText($item->desc);
$this->editdetail->edititem->setKey($item->item_id);
@@ -152,6 +166,7 @@ public function deleteOnClick($sender) {
public function addrowOnClick($sender) {
$this->editdetail->setVisible(true);
$this->docform->setVisible(false);
+ $this->editdetail->editdesc->setText("");
$this->_rowid = 0;
$this->editdetail->editprice->setText("0");
}
@@ -176,6 +191,7 @@ public function saverowOnClick($sender) {
if ($item->price == 0) {
$this->setWarn("no_price");
}
+ $item->desc = $this->editdetail->editdesc->getText();
$tarr = array();
diff --git a/www/app/pages/doc/task.php b/www/app/pages/doc/task.php
index 14cec1d03..e5f19d3d4 100644
--- a/www/app/pages/doc/task.php
+++ b/www/app/pages/doc/task.php
@@ -8,6 +8,7 @@
use App\Entity\Equipment;
use App\Entity\Prodarea;
use App\Entity\Service;
+use App\Entity\Item;
use Zippy\Html\DataList\DataView;
use Zippy\Html\Form\Button;
use Zippy\Html\Form\DropDownChoice;
@@ -28,6 +29,7 @@ class Task extends \App\Pages\Base
{
private $_doc;
+ public $_prodlist = array();
public $_servicelist = array();
public $_eqlist = array();
public $_emplist = array();
@@ -36,10 +38,9 @@ class Task extends \App\Pages\Base
public function __construct($docid = 0, $basedocid = 0, $date = null) {
parent::__construct();
-
$this->add(new Form('docform'));
$this->docform->add(new TextInput('document_number'));
- $this->docform->add(new \ZCL\BT\DatePicker('document_date'))->setDate(time());
+ $this->docform->add(new \ZCL\BT\DateTimePicker('document_date'))->setDate(time());
$this->docform->add(new TextArea('notes'));
$this->docform->add(new TextInput('taskhours', "0"));
@@ -49,6 +50,7 @@ public function __construct($docid = 0, $basedocid = 0, $date = null) {
$this->docform->add(new DropDownChoice('parea', Prodarea::findArray("pa_name", ""), 0));
$this->docform->add(new SubmitLink('addservice'))->onClick($this, 'addserviceOnClick');
+ $this->docform->add(new SubmitLink('addprod'))->onClick($this, 'addprodOnClick');
$this->docform->add(new SubmitLink('addeq'))->onClick($this, 'addeqOnClick');
$this->docform->add(new SubmitLink('addemp'))->onClick($this, 'addempOnClick');
@@ -61,8 +63,17 @@ public function __construct($docid = 0, $basedocid = 0, $date = null) {
$this->editdetail->add(new DropDownChoice('editservice', Service::findArray("service_name", "disabled<>1", "service_name")));
$this->editdetail->add(new TextInput('editqty'));
+ $this->editdetail->add(new TextInput('editdesc'));
$this->editdetail->add(new Button('cancelrow'))->onClick($this, 'cancelrowOnClick');
$this->editdetail->add(new SubmitButton('saverow'))->onClick($this, 'saverowOnClick');
+ //prod
+ $this->add(new Form('editdetailprod'))->setVisible(false);
+ $this->editdetailprod->add(new DropDownChoice('editprod', Item::findArray("itemname", "item_type in(4,5) and disabled<>1", "itemname")));
+
+ $this->editdetailprod->add(new TextInput('editqtyprod'));
+ $this->editdetailprod->add(new TextInput('editdescprod'));
+ $this->editdetailprod->add(new Button('cancelrowprod'))->onClick($this, 'cancelrowOnClick');
+ $this->editdetailprod->add(new SubmitButton('saverowprod'))->onClick($this, 'saverowOnClick');
//employer
$this->add(new Form('editdetail3'))->setVisible(false);
@@ -94,6 +105,7 @@ public function __construct($docid = 0, $basedocid = 0, $date = null) {
$this->_servicelist = $this->_doc->unpackDetails('detaildata');
$this->_eqlist = $this->_doc->unpackDetails('eqlist');
$this->_emplist = $this->_doc->unpackDetails('emplist');
+ $this->_prodlist = $this->_doc->unpackDetails('prodlist');
} else {
$this->_doc = Document::create('Task');
$this->docform->document_date->setDate(time());
@@ -115,7 +127,7 @@ public function __construct($docid = 0, $basedocid = 0, $date = null) {
}
if ($basedoc->meta_name == 'Order') {
$this->docform->notes->setText(H::l('basedon') . $basedoc->document_number);
- $this->_servicelist = $basedoc->unpackDetails('detaildata');
+ //$this->_prodlist = $basedoc->unpackDetails('detaildata');
}
}
}
@@ -124,6 +136,7 @@ public function __construct($docid = 0, $basedocid = 0, $date = null) {
$this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_servicelist')), $this, 'detailOnRow'))->Reload();
$this->docform->add(new DataView('detail3', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_emplist')), $this, 'detail3OnRow'))->Reload();
$this->docform->add(new DataView('detail4', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_eqlist')), $this, 'detail4OnRow'))->Reload();
+ $this->docform->add(new DataView('detailprod', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_prodlist')), $this, 'detailprodOnRow'))->Reload();
if (false == \App\ACL::checkShowDoc($this->_doc)) {
@@ -133,6 +146,7 @@ public function __construct($docid = 0, $basedocid = 0, $date = null) {
public function cancelrowOnClick($sender) {
$this->editdetail->setVisible(false);
+ $this->editdetailprod->setVisible(false);
$this->editdetail3->setVisible(false);
$this->editdetail4->setVisible(false);
@@ -147,6 +161,7 @@ public function detailOnRow($row) {
$row->add(new Label('quantity', $service->quantity));
+ $row->add(new Label('desc', $service->desc));
$row->add(new ClickLink('edit'))->onClick($this, 'editOnClick');
@@ -162,6 +177,7 @@ public function addserviceOnClick($sender) {
$this->editdetail->editqty->setText('1');
+ $this->editdetail->editdesc->setText('');
}
public function editOnClick($sender) {
@@ -171,6 +187,7 @@ public function editOnClick($sender) {
$this->editdetail->editqty->setText($service->quantity);
+ $this->editdetail->editdesc->setText($service->desc);
$this->editdetail->editservice->setValue($service->service_id);
}
@@ -195,6 +212,7 @@ public function saverowOnClick($sender) {
$service->quantity = $this->editdetail->editqty->getText();
+ $service->desc = $this->editdetail->editdesc->getText();
$service->price = $service->cost;
if (strlen($service->price) == 0) {
$service->price = 0;
@@ -212,6 +230,90 @@ public function saverowOnClick($sender) {
$this->editdetail->editqty->setText("1");
}
+ //prod
+ public function addprodOnClick($sender) {
+ $this->editdetailprod->setVisible(true);
+ $this->docform->setVisible(false);
+
+
+ $this->editdetailprod->editprod->setValue(0);
+
+
+ $this->editdetailprod->editqtyprod->setText('1');
+ $this->editdetailprod->editdescprod->setText('');
+ }
+ public function detailprodOnRow($row) {
+ $item= $row->getDataItem();
+
+ $row->add(new Label('prod', $item->itemname));
+
+
+ $row->add(new Label('quantityprod', $item->quantity));
+ $row->add(new Label('descprod', $item->desc));
+
+
+ $row->add(new ClickLink('editprod'))->onClick($this, 'editprodOnClick');
+ $row->add(new ClickLink('deleteprod'))->onClick($this, 'deleteprodOnClick');
+ }
+
+ public function cancelprodrowOnClick($sender) {
+ $this->editdetail->setVisible(false);
+ $this->editdetailprod->setVisible(false);
+
+ $this->editdetail3->setVisible(false);
+ $this->editdetail4->setVisible(false);
+
+ $this->docform->setVisible(true);
+ }
+ public function editprodOnClick($sender) {
+ $item = $sender->getOwner()->getDataItem();
+ $this->editdetailprod->setVisible(true);
+ $this->docform->setVisible(false);
+
+
+ $this->editdetail->editqtyprod->setText($item->quantity);
+ $this->editdetail->editdescprod->setText($item->desc);
+
+ $this->editdetail->editprod->setValue($item->item_id);
+ }
+
+ public function deleteprodOnClick($sender) {
+ if (false == \App\ACL::checkEditDoc($this->_doc)) {
+ return;
+ }
+ $item = $sender->owner->getDataItem();
+
+ $this->_prodlist = array_diff_key($this->_itemlist, array($item->item_id => $this->_itemlist[$item->item_id]));
+ $this->docform->detailprod->Reload();
+ }
+
+ public function saverowprodOnClick($sender) {
+ $id = $this->editdetailprod->editprod->getValue();
+ if ($id == 0) {
+ $this->setError("noselprod");
+ return;
+ }
+ $item = Item::load($id);
+
+
+ $item->quantity = $this->editdetailprod->editqtyprod->getText();
+ $item->desc = $this->editdetailprod->editdescprod->getText();
+
+
+ $this->_prodlist[$item->item_id] = $item;
+ $this->editdetailprod->setVisible(false);
+ $this->docform->setVisible(true);
+
+
+ $this->docform->detailprod->Reload();
+
+ //очищаем форму
+ $this->editdetailprod->editprod->setValue(0);
+
+ $this->editdetailprod->editqtyprod->setText("1");
+ }
+
+
//employee
public function addempOnClick($sender) {
$this->editdetail3->setVisible(true);
@@ -309,6 +411,7 @@ public function savedocOnClick($sender) {
$this->_doc->packDetails('detaildata', $this->_servicelist);
$this->_doc->packDetails('eqlist', $this->_eqlist);
$this->_doc->packDetails('emplist', $this->_emplist);
+ $this->_doc->packDetails('prodlist', $this->_prodlist);
$isEdited = $this->_doc->document_id > 0;
diff --git a/www/app/pages/doc/ttn.php b/www/app/pages/doc/ttn.php
index 93350a907..e31c7f3f8 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()))->onChange($this, 'OnChangeStore');
+ $this->docform->add(new DropDownChoice('store', Store::getList(), H::getDefStore())) ;
$this->docform->add(new SubmitLink('addcust'))->onClick($this, 'addcustOnClick');
@@ -90,6 +90,7 @@ public function __construct($docid = 0, $basedocid = 0) {
$this->docform->add(new SubmitButton('savedoc'))->onClick($this, 'savedocOnClick');
$this->docform->add(new SubmitButton('execdoc'))->onClick($this, 'savedocOnClick');
$this->docform->add(new SubmitButton('senddoc'))->onClick($this, 'savedocOnClick');
+ $this->docform->add(new SubmitButton('sendnp'))->onClick($this, 'savedocOnClick');
$this->docform->add(new Button('backtolist'))->onClick($this, 'backtolistOnClick');
@@ -664,17 +665,23 @@ public function savedocOnClick($sender) {
}
} */
} else {
- if ($sender->id == 'senddoc') {
+ if ($sender->id == 'senddoc' || $sender->id == 'sendnp') {
if (!$isEdited) {
$this->_doc->updateStatus(Document::STATE_NEW);
}
- $this->_doc->updateStatus(Document::STATE_EXECUTED);
- $this->_doc->updateStatus(Document::STATE_INSHIPMENT);
+ $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);
}
@@ -682,7 +689,11 @@ public function savedocOnClick($sender) {
$conn->CommitTrans();
-
+ if ($sender->id == 'sendnp') {
+
+ App::Redirect('\App\Pages\Register\GIList',$this->_doc->document_id) ;
+ return;
+ }
App::Redirect("\\App\\Pages\\Register\\GIList");
} catch(\Throwable $ee) {
@@ -765,11 +776,7 @@ public function backtolistOnClick($sender) {
App::RedirectBack();
}
- public function OnChangeStore($sender) {
- //очистка списка товаров
- $this->_itemlist = array();
- $this->docform->detail->Reload();
- }
+
public function OnChangeItem($sender) {
$id = $sender->getKey();
@@ -878,9 +885,11 @@ public function cancelcustOnClick($sender) {
}
public function OnDelivery($sender) {
+
if ($sender->getValue() != Document::DEL_SELF) {
$this->docform->senddoc->setVisible(true);
+ $this->docform->sendnp->setVisible(true);
$this->docform->ship_address->setVisible(true);
$this->docform->ship_number->setVisible($sender->getValue() == 3);
@@ -891,7 +900,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);
@@ -900,7 +909,7 @@ public function OnDelivery($sender) {
$this->docform->emp->setVisible(false);
$this->docform->ship_number->setText('');
}
-
+ $this->docform->sendnp->setVisible($sender->getValue() == Document::DEL_NP);
}
public function onOpenItemSel($sender) {
diff --git a/www/app/pages/doc/warranty.php b/www/app/pages/doc/warranty.php
index 3c0085689..4f28f3d28 100644
--- a/www/app/pages/doc/warranty.php
+++ b/www/app/pages/doc/warranty.php
@@ -135,11 +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);
@@ -169,8 +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);
@@ -213,8 +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();
@@ -234,8 +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/main.php b/www/app/pages/main.php
index b07499ab7..309278cdc 100644
--- a/www/app/pages/main.php
+++ b/www/app/pages/main.php
@@ -8,6 +8,7 @@
use Zippy\Html\DataList\DataView;
use Zippy\Html\DataList\Paginator;
use Zippy\Html\Label;
+use Zippy\Html\Link\ClickLink;
use App\Entity\Stock;
use App\Entity\Item;
use App\DataItem;
@@ -24,6 +25,8 @@ public function __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;
@@ -66,7 +69,7 @@ public function __construct() {
$this->_tvars['wsdate'] = false;
}
-
+ $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));
@@ -89,7 +92,8 @@ public function __construct() {
if (count($data) == 0) {
$this->_tvars['wminqty'] = false;
}
- $mqlist = $this->add(new DataView('mqlist', new ArrayDataSource($data), $this, 'mqlistOnRow'));
+ $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));
$mqlist->Reload();
@@ -112,6 +116,7 @@ public function __construct() {
if (count($data) == 0) {
$this->_tvars['wrdoc'] = false;
}
+ $this->add(new ClickLink('rdcsv',$this,'onRDcsv')) ;
$doclist = $this->add(new DataView('rdoclist', new ArrayDataSource($data), $this, 'doclistOnRow'));
$doclist->setPageSize(10);
@@ -302,9 +307,41 @@ public function doclistOnRow($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){
+ $list = $this->tasktab->tasklist->getDataSource()->getItems(-1, -1, 'document_id');
+
+
+ $header = array();
+ $data = array();
+
+ $i = 0;
+ foreach ($list as $task) {
+ $i++;
+ $data['A' . $i] = $task->document_number;
+ $data['B' . $i] = $task->notes;
+ $data['C' . $i] = H::fdt($task->document_date);
+ $data['D' . $i] = $task->headerdata['taskhours'];
+ $data['E' . $i] = Document::getStateName($task->state);
+ $data['F' . $i] = $task->notes;
+
+ }
+
+ H::exportExcel($data, $header, 'taskslist.xlsx');
+ }
+ public function onSDcsv($sender){
+
+ }
+ public function onMQcsv($sender){
+
+ }
+
/*
public function test($args,$post) {
return "test";
} */
+
+
+
}
diff --git a/www/app/pages/options.php b/www/app/pages/options.php
index 47ea83d05..3eb6c737f 100644
--- a/www/app/pages/options.php
+++ b/www/app/pages/options.php
@@ -11,6 +11,7 @@
use Zippy\Html\Form\Form;
use Zippy\Html\Form\File;
use Zippy\Html\Form\TextInput;
+use Zippy\Html\Form\SubmitButton;
use Zippy\Html\Label;
use Zippy\Html\Link\ClickLink;
use Zippy\Html\Panel;
@@ -104,6 +105,7 @@ public function __construct() {
$this->common->ts_start->setText($common['ts_start'] == null ? '09:00' : $common['ts_start']);
$this->common->ts_end->setText($common['ts_end'] == null ? '18:00' : $common['ts_end']);
+ //валюты
$this->add(new Form('valform'))->onSubmit($this, 'saveValOnClick');
$this->valform->add(new TextInput('valuan'));
$this->valform->add(new TextInput('valusd'));
@@ -121,6 +123,7 @@ public function __construct() {
$this->valform->valrub->setText($val['valrub']);
$this->valform->valprice->setChecked($val['valprice']);
+ //печать
$this->add(new Form('printer'))->onSubmit($this, 'savePrinterOnClick');
$this->printer->add(new TextInput('pwidth'));
$this->printer->add(new DropDownChoice('pricetype', \App\Entity\Item::getPriceTypeList()));
@@ -145,6 +148,7 @@ public function __construct() {
$this->printer->pbarcode->setChecked($printer['pbarcode']);
$this->printer->pprice->setChecked($printer['pprice']);
+ //API
$this->add(new Form('api'))->onSubmit($this, 'saveApiOnClick');
$this->api->add(new TextInput('akey'));
@@ -159,6 +163,34 @@ public function __construct() {
$this->api->atype->setValue($api['atype']);
$this->onApiType($this->api->atype);
+
+ //SMS
+ $this->add(new Form('sms'));
+
+ $this->sms->add(new SubmitButton('smssubmit'))->onClick($this, 'saveSMSOnClick');
+ $this->sms->add(new SubmitButton('smstest'))->onClick($this, 'testSMSOnClick');
+ $this->sms->add(new Label('semysmssite'));
+ $this->sms->add(new Label('turbosmssite'));
+ $this->sms->add(new Label('smsflysite'));
+ $this->sms->add(new TextInput('turbosmstoken'));
+ $this->sms->add(new TextInput('smssemytoken'));
+ $this->sms->add(new TextInput('smssemydevid'));
+ $this->sms->add(new TextInput('smstestphone'));
+ $this->sms->add(new TextInput('smstesttext'));
+ $this->sms->add(new TextInput('flysmslogin'));
+ $this->sms->add(new TextInput('flysmspass'));
+ $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->turbosmstoken->setValue($sms['turbosmstoken']);
+
+ $this->sms->smstype->setValue($sms['smstype']);
+
+ $this->onSMSType($this->sms->smstype);
}
@@ -251,6 +283,7 @@ public function onApiType($sender) {
}
+
public function saveApiOnClick($sender) {
$api = array();
$api['exp'] = $this->api->aexp->getText();
@@ -262,6 +295,48 @@ public function saveApiOnClick($sender) {
}
+
+ public function onSMSType($sender) {
+ $type = $this->sms->smstype->getValue();
+ $this->sms->smssemytoken->setVisible($type == 1);
+ $this->sms->smssemydevid->setVisible($type == 1);
+ $this->sms->turbosmstoken->setVisible($type == 2);
+ $this->sms->flysmslogin->setVisible($type == 3);
+ $this->sms->flysmspass->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) {
+ $sms = array();
+ $sms['turbosmstoken'] = $this->sms->turbosmstoken->getText();
+ $sms['smssemytoken'] = $this->sms->smssemytoken->getText();
+ $sms['smssemydevid'] = $this->sms->smssemydevid->getText();
+ $sms['flysmslogin'] = $this->sms->flysmslogin->getText();
+ $sms['flysmspass'] = $this->sms->flysmspass->getText();
+ $sms['smstype'] = $this->sms->smstype->getValue();
+
+ 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) ;
+ }
+
+
+ }
}
diff --git a/www/app/pages/reference/contractlist.php b/www/app/pages/reference/contractlist.php
index f585f949c..36e59a00a 100644
--- a/www/app/pages/reference/contractlist.php
+++ b/www/app/pages/reference/contractlist.php
@@ -41,11 +41,12 @@ public function __construct($id = 0) {
$this->filter->add(new DropDownChoice('searchcomp', Firm::findArray('firm_name', 'disabled<>1', 'firm_name'), 0));
$this->add(new Panel('contracttable'))->setVisible(true);
- $this->contracttable->add(new DataView('contractlist', new ContractDataSource($this), $this, 'contractlistOnRow'))->Reload();
+ $this->contracttable->add(new DataView('contractlist', new ContractDataSource($this), $this, 'contractlistOnRow'));
$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->add(new Form('contractdetail'))->setVisible(false);
$this->contractdetail->add(new Date('editcreatedon', time()));
$this->contractdetail->add(new Date('editenddate', strtotime("+1 month", time())));
@@ -66,21 +67,15 @@ public function __construct($id = 0) {
$this->add(new Panel('docpan'))->setVisible(false);
$this->docpan->add(new Label("cname"));
- $this->docpan->add(new Label("totsumma"));
- $this->docpan->add(new Label("totdolg"));
+
+
$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));
- $this->docpan->add(new Form('payform'))->onSubmit($this, 'payOnSubmit');
- $this->docpan->payform->add(new DropDownChoice('payment', \App\Entity\MoneyFund::getList(), H::getDefMF()));
- $this->docpan->payform->add(new TextInput('pamount'));
- $this->docpan->payform->add(new TextInput('pcomment'));
- $this->docpan->payform->add(new Date('pdate', time()));
- $this->docpan->payform->setVisible(false);
-
+
if ($id > 0) {
$c = Contract::load($id);
$this->filter->searchkey->setText($c->contract_number);
@@ -218,6 +213,8 @@ public function cancelOnClick($sender) {
public function OnFilter($sender) {
$this->contracttable->contractlist->Reload();
+ $this->docpan->setVisible(false);
+
}
public function OnAutoCustomer($sender) {
@@ -232,19 +229,11 @@ public function showOnClick($sender) {
$dlist = $this->_contract->getDocs();
- $totsumma = 0;
-
- foreach ($dlist as $d) {
- $totsumma += $d->amount;
-
- }
- $this->docpan->totsumma->setText(H::fa($totsumma));
$this->docpan->dtable->getDataSource()->setArray($dlist);
$this->docpan->dtable->Reload();
- $this->docpan->payform->setVisible($totdolg > 0);
- $this->docpan->payform->pamount->setText(H::fa($totdolg));
+
}
public function doclistOnRow($row) {
@@ -256,48 +245,7 @@ public function doclistOnRow($row) {
}
- public function payOnSubmit($sender) {
-
- $amount = $sender->pamount->getText();
- $pdate = $sender->pdate->getDate();
- $comment = $sender->pcomment->getText();
- if (strlen($comment) == 0) {
- $comment = H::l('bycontract', $this->_contract->contract_number);
- }
-
- foreach ($this->_contract->getDocs() as $doc) {
-
-
- if ($doc->payamount > 0 && $doc->payamount > $doc->payed) {
- $p = $doc->payamount - $doc->payed;
- if ($amount > $p) {
-
- $amount -= $p;
- } else {
-
- $p = $amount;
- $amount = 0;
- }
- if (in_array($doc->meta_name, array('GoodsReceipt', 'InvoiceCust'))) {
- Pay::addPayment($doc->document_id, $pdate, 0 - $p, $sender->payment->getValue(), Pay::PAY_BASE_OUTCOME, $comment);
- } else {
- Pay::addPayment($doc->document_id, $pdate, $p, $sender->payment->getValue(), Pay::PAY_BASE_INCOME, $comment);
-
- }
-
- if ($amount == 0) {
- break;
- }
- }
-
- }
-
- $this->contracttable->contractlist->Reload(false);
- $this->contracttable->setVisible(true);
-
- $this->docpan->setVisible(false);
- }
-
+
}
diff --git a/www/app/pages/reference/customerlist.php b/www/app/pages/reference/customerlist.php
index ac64e616a..e0090e487 100644
--- a/www/app/pages/reference/customerlist.php
+++ b/www/app/pages/reference/customerlist.php
@@ -40,7 +40,6 @@ public function __construct($id = 0) {
$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('searchstatus', array(Customer::STATUS_ACTUAL => Helper::l("isactul"), Customer::STATUS_DISABLED => Helper::l("notused"), Customer::STATUS_WAIT => Helper::l("potential")), Customer::STATUS_ACTUAL));
$this->filter->add(new DropDownChoice('searchholding', Customer::getHoldList(), 0));
@@ -57,12 +56,13 @@ public function __construct($id = 0) {
$this->customerdetail->add(new TextInput('editcity'));
$this->customerdetail->add(new TextInput('editcustomername'));
$this->customerdetail->add(new TextInput('editphone'));
+ $this->customerdetail->add(new TextInput('editviber'));
$this->customerdetail->add(new TextInput('editemail'));
$this->customerdetail->add(new CheckBox('editjurid'));
$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 DropDownChoice('editstatus', array(Customer::STATUS_ACTUAL => 'Актуальный', Customer::STATUS_DISABLED => 'Не используется', Customer::STATUS_WAIT => 'Потенциальный'), Customer::STATUS_ACTUAL));
+ $this->customerdetail->add(new DropDownChoice('editstatus', array(0 => Helper::l("isactual"), 1 => Helper::l("notused")), 0));
$this->customerdetail->add(new TextInput('discount'));
$this->customerdetail->add(new TextInput('bonus'));
$this->customerdetail->add(new TextArea('editcomment'));
@@ -103,11 +103,11 @@ public function __construct($id = 0) {
}
public function OnSearch($sender) {
- $status = $this->filter->searchstatus->getValue();
+
$type = $this->filter->searchtype->getValue();
$holding = $this->filter->searchholding->getValue();
$search = trim($this->filter->searchkey->getText());
- $where = "status=" . $status;
+ $where = "1=1" ;
if (strlen($search) > 0) {
$search = Customer::qstr('%' . $search . '%');
@@ -139,7 +139,11 @@ public function customerlistOnRow($row) {
$row->add(new Label('customername', $item->customer_name));
$row->add(new Label('customerphone', $item->phone));
$row->add(new Label('customeremail', $item->email));
- $row->add(new Label('customercomment', $item->comment));
+
+
+ $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);
@@ -147,6 +151,9 @@ public function customerlistOnRow($row) {
$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 editOnClick($sender) {
@@ -163,6 +170,7 @@ public function show() {
$this->customerdetail->editcustomername->setText($this->_customer->customer_name);
$this->customerdetail->editphone->setText($this->_customer->phone);
+ $this->customerdetail->editviber->setText($this->_customer->viber);
$this->customerdetail->editemail->setText($this->_customer->email);
$this->customerdetail->editaddress->setText($this->_customer->address);
$this->customerdetail->editcity->setText($this->_customer->city);
@@ -214,6 +222,7 @@ public function saveOnClick($sender) {
return;
}
$this->_customer->phone = $this->customerdetail->editphone->getText();
+ $this->_customer->viber = $this->customerdetail->editviber->getText();
$this->_customer->email = $this->customerdetail->editemail->getText();
$this->_customer->address = $this->customerdetail->editaddress->getText();
$this->_customer->city = $this->customerdetail->editcity->getText();
@@ -253,7 +262,10 @@ public function saveOnClick($sender) {
}
}
-
+ if($this->_customer->customer_id==0){ //новый
+ $this->_customer->created = time();
+ $this->_customer->user_id = System::getUser()->user_id;
+ }
$this->_customer->save();
$this->customerdetail->setVisible(false);
$this->customertable->setVisible(true);
diff --git a/www/app/pages/register/gilist.php b/www/app/pages/register/gilist.php
index fe04ca403..43e60eea0 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() {
+ public function __construct($doc=0) {
parent::__construct();
if (false == \App\ACL::checkShowReg('GIList')) {
return;
@@ -54,7 +54,7 @@ public function __construct() {
$this->listpan->add(new Paginator('pag', $doclist));
$doclist->setPageSize(H::getPG());
$this->listpan->add(new ClickLink('csv', $this, 'oncsv'));
- $this->listpan->add(new ClickLink('statusNP', $this, 'onNP'));
+
$this->add(new Panel("statuspan"))->setVisible(false);
@@ -66,6 +66,7 @@ public function __construct() {
$this->statuspan->statusform->add(new SubmitButton('bgar'))->onClick($this, 'statusOnSubmit');
$this->statuspan->statusform->add(new SubmitButton('bret'))->onClick($this, 'statusOnSubmit');
$this->statuspan->statusform->add(new SubmitButton('bnp'))->onClick($this, 'npshowOnSubmit');
+ $this->statuspan->statusform->add(new SubmitButton('bdecl'))->onClick($this, 'statusOnSubmit');
$this->statuspan->statusform->add(new TextInput('ship_number'));
$this->statuspan->statusform->add(new CheckBox('closeorder'));
@@ -106,13 +107,17 @@ public function __construct() {
$npform->add(new DataView('npitemlist', new ArrayDataSource(array()), $this, 'nplistOnRow'));
+ if($doc>0) {
+ $this->_doc = Document::load($doc);
+ $this->npshowOnSubmit( $this->statuspan->statusform->bnp);;
+ }
}
public function filterOnSubmit($sender) {
$this->statuspan->setVisible(false);
- $this->listpan->doclist->Reload(false);
+ $this->listpan->doclist->Reload();
}
@@ -147,10 +152,7 @@ public function statusOnSubmit($sender) {
$state = $this->_doc->state;
if ($sender->id == "bsend") {
- $dec = $this->statuspan->statusform->ship_number->getText();
- if (strlen($dec) > 0) {
- $this->_doc->headerdata['ship_number'] = $dec;
- }
+
$this->_doc->headerdata['sentdate'] = H::fd(time());
$this->_doc->headerdata['document_date'] = time();
$this->_doc->save();
@@ -163,7 +165,7 @@ public function statusOnSubmit($sender) {
$this->_doc->save();
- $this->statuspan->statusform->ship_number->setText($this->_doc->headerdata['ship_number']);
+
$this->setSuccess('sent');
}
@@ -188,7 +190,16 @@ 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->statuspan->setVisible(false);
+ }
if ($sender->id == "bttn") {
App::Redirect("\\App\\Pages\\Doc\\TTN", 0, $this->_doc->document_id);
@@ -218,6 +229,7 @@ public function updateStatusButtons() {
$this->statuspan->statusform->bgar->setVisible(true);
$this->statuspan->statusform->bnp->setVisible(false);
$this->statuspan->statusform->ship_number->setVisible(false);
+ $this->statuspan->statusform->bdecl->setVisible(false);
$this->statuspan->statusform->closeorder->setVisible(false);
@@ -244,28 +256,26 @@ public function updateStatusButtons() {
//отправлен
if ($state == Document::STATE_INSHIPMENT) {
$this->statuspan->statusform->bsend->setVisible(false);
- $this->statuspan->statusform->ship_number->setVisible(false);
}
// Доставлен
if ($state == Document::STATE_DELIVERED) {
$this->statuspan->statusform->bdevivered->setVisible(false);
$this->statuspan->statusform->bsend->setVisible(false);
- $this->statuspan->statusform->ship_number->setVisible(false);
}
//прячем лишнее
if ($this->_doc->meta_name == 'TTN') {
if ($this->_doc->headerdata['delivery'] < 3) { //не служба доставки
$this->statuspan->statusform->ship_number->setVisible(false);
+ $this->statuspan->statusform->bdecl->setVisible(false);
}
$this->statuspan->statusform->bttn->setVisible(false);
}
- if ($this->_doc->meta_name == 'TTN' && $this->_doc->state = Document::STATE_READYTOSHIP) {
+ if ($this->_doc->meta_name == 'TTN' && $this->_doc->state == Document::STATE_READYTOSHIP) {
$this->statuspan->statusform->bnp->setVisible(true);
- $this->statuspan->statusform->ship_number->setVisible(true);
}
@@ -273,12 +283,10 @@ public function updateStatusButtons() {
$this->statuspan->statusform->bdevivered->setVisible(false);
$this->statuspan->statusform->ship_number->setVisible(false);
- $this->statuspan->statusform->bsend->setVisible(false);
}
if ($this->_doc->meta_name == 'POSCheck') {
$this->statuspan->statusform->bdevivered->setVisible(false);
$this->statuspan->statusform->ship_number->setVisible(false);
- $this->statuspan->statusform->bsend->setVisible(false);
}
if ($this->_doc->meta_name == 'Invoice') {
@@ -286,7 +294,6 @@ public function updateStatusButtons() {
$this->statuspan->statusform->bdevivered->setVisible(false);
$this->statuspan->statusform->bret->setVisible(false);
$this->statuspan->statusform->bgar->setVisible(false);
- $this->statuspan->statusform->ship_number->setVisible(false);
}
if ($this->_doc->meta_name == 'ReturnIssue') {
@@ -295,10 +302,13 @@ public function updateStatusButtons() {
$this->statuspan->statusform->bttn->setVisible(false);
$this->statuspan->statusform->bret->setVisible(false);
$this->statuspan->statusform->bgar->setVisible(false);
- $this->statuspan->statusform->ship_number->setVisible(false);
}
+ if ($this->_doc->meta_name == 'TTN' && $this->_doc->state != Document::STATE_DELIVERED) {
+ $this->statuspan->statusform->ship_number->setVisible(true);
+ $this->statuspan->statusform->bdecl->setVisible(true);
+ }
}
//просмотр
@@ -405,7 +415,7 @@ 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) ;
$list = $this->_doc->unpackDetails('detaildata');
$w = 0;
$p = 0;
@@ -526,10 +536,11 @@ public function npOnSubmit($sender) {
$params['Weight'] = $this->nppan->npform->npw->getText();
$moneyback = $this->nppan->npform->npback->getText();
if ($moneyback > 0) { //если введена обратная сумма
- $params['BackwardDeliveryData'] = array(
+ $params['BackwardDeliveryData'] = array(array(
'PayerType' => 'Recipient',
'CargoType' => 'Money',
- 'RedeliveryString' => $moneyback);
+ 'RedeliveryString' => $moneyback)
+ );
}
@@ -572,6 +583,7 @@ public function npOnSubmit($sender) {
// $sender['Warehouse']= $this->nppan->npform->selpoint->getValue();
$sender['SenderType'] = $result['data'][0]['CounterpartyType'];
$sender['ContactSender'] = $resultc['data'][0]['Ref'];
+ $sender['SenderAddress'] = $this->nppan->npform->selpoint->getValue();
$recipient['FirstName'] = $this->nppan->npform->bayfirstname->getText();
@@ -595,10 +607,10 @@ 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'] = $recipient['Warehouse'];
+ $recipient['RecipientAddress'] = $this->nppan->npform->baypoint->getValue();
$paramsInternetDocument = array_merge($sender, $recipient, $params);
@@ -629,47 +641,7 @@ public function npOnSubmit($sender) {
}
- //обновление статусов
- public function onNP($sender) {
-
- $api = new \App\Modules\NP\Helper();
- $errors = array();
- $docs = Document::find("meta_name='TTN' and state in(11,20) ");
- foreach ($docs as $ttn) {
- if (strlen($ttn->headerdata['ship_numberref']) == 0) {
- continue;
- }
-
- $cnt = 0;
- $decstate = $api->documentsTracking($ttn->headerdata['ship_number']);
- $st = $decstate['data'][0]['Status'];
- $code = $decstate['data'][0]['StatusCode'];
-
- // 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++;
- }
- if (in_array($code, array(4, 5, 6, 7, 8, 41, 101))) {
- $ttn->updateStatus(Document::STATE_INSHIPMENT);
- $cnt++;
- }
- if (in_array($code, array(102, 103, 104, 108, 105, 2, 3))) {
- $errors[] = $ttn->headerdata['ship_number'] . " - " . $st;
- }
- if (count($errors) > 0) {
- $this->setError(Implode('
', $errors));
- } else {
- $this->setSuccess("npupdated", $cnt);
- }
-
- }
-
- $this->listpan->doclist->Reload();
- }
-
+
}
/**
diff --git a/www/app/pages/register/grlist.php b/www/app/pages/register/grlist.php
index 8b4198e5d..0cbc10a98 100644
--- a/www/app/pages/register/grlist.php
+++ b/www/app/pages/register/grlist.php
@@ -71,7 +71,7 @@ public function filterOnSubmit($sender) {
$this->statuspan->setVisible(false);
- $this->doclist->Reload(false);
+ $this->doclist->Reload();
}
public function doclistOnRow($row) {
diff --git a/www/app/pages/register/itemlist.php b/www/app/pages/register/itemlist.php
index 21c4502c5..06f47f33d 100644
--- a/www/app/pages/register/itemlist.php
+++ b/www/app/pages/register/itemlist.php
@@ -270,7 +270,7 @@ public function oncsv($sender) {
}
- H::exportExcel($data, $header, 'stocklist.xlsx');
+ H::exportExcel($data, $header, 'itemlist.xlsx');
}
diff --git a/www/app/pages/register/orderlist.php b/www/app/pages/register/orderlist.php
index 174a069b4..723c9b954 100644
--- a/www/app/pages/register/orderlist.php
+++ b/www/app/pages/register/orderlist.php
@@ -56,7 +56,11 @@ 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('bsent'))->onClick($this, 'statusOnSubmit');
+ $this->statuspan->statusform->add(new SubmitButton('bdel'))->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');
$this->statuspan->statusform->add(new SubmitButton('bref'))->onClick($this, 'statusOnSubmit');
$this->statuspan->statusform->add(new SubmitButton('bttn'))->onClick($this, 'statusOnSubmit');
$this->statuspan->statusform->add(new SubmitButton('btask'))->onClick($this, 'statusOnSubmit');
@@ -118,8 +122,10 @@ public function statusOnSubmit($sender) {
//проверяем что есть ТТН
- $list = $this->_doc->getChildren('GoodsIssue');
+ $list = $this->_doc->getChildren('TTN');
$ttn = count($list) > 0;
+ $list = $this->_doc->getChildren('GoodsIssue');
+ $gi = count($list) > 0;
$list = $this->_doc->getChildren('Invoice');
$invoice = count($list) > 0;
@@ -127,6 +133,12 @@ public function statusOnSubmit($sender) {
if ($sender->id == "binp") {
$this->_doc->updateStatus(Document::STATE_INPROCESS);
}
+ if ($sender->id == "bsent") {
+ $this->_doc->updateStatus(Document::STATE_INSHIPMENT);
+ }
+ if ($sender->id == "bdel") {
+ $this->_doc->updateStatus(Document::STATE_DELIVERED);
+ }
if ($sender->id == "bref") {
$this->_doc->updateStatus(Document::STATE_REFUSED);
@@ -156,6 +168,19 @@ public function statusOnSubmit($sender) {
return;
}
+ if ($sender->id == "bgi") {
+ if ($invoice) {
+ $this->setWarn('goodsissue_exists');
+ }
+ App::Redirect("\\App\\Pages\\Doc\\GoodsIssue", 0, $this->_doc->document_id);
+ return;
+ }
+ if ($sender->id == "bco") {
+
+ App::Redirect("\\App\\Pages\\Doc\\OrderCust", 0, $this->_doc->document_id);
+ return;
+ }
+
if ($sender->id == "bclose") {
@@ -174,7 +199,7 @@ public function updateStatusButtons() {
$common = System::getOptions("common");
$this->statuspan->statusform->bclose->setVisible(true);
-
+
$state = $this->_doc->state;
//доставлен
@@ -184,14 +209,9 @@ public function updateStatusButtons() {
//аннулирован
$ref = $this->_doc->checkStates(array(Document::STATE_REFUSED));
+ $this->statuspan->statusform->bsent->setVisible(false);
+ $this->statuspan->statusform->bdel->setVisible(false);
- //проверяем что есть ТТН
-
- $list = $this->_doc->getChildren('Invoice');
- $invoice = count($list) > 0;
-
- $this->statuspan->statusform->bttn->setVisible(!$closed);
- $this->statuspan->statusform->binv->setVisible(!$closed);
//новый
if ($state < Document::STATE_EXECUTED) {
@@ -201,13 +221,18 @@ public function updateStatusButtons() {
$this->statuspan->statusform->bref->setVisible(false);
$this->statuspan->statusform->bttn->setVisible(false);
$this->statuspan->statusform->binv->setVisible(false);
+ $this->statuspan->statusform->bgi->setVisible(false);
+ $this->statuspan->statusform->bco->setVisible(false);
$this->statuspan->statusform->binp->setVisible(true);
+ $this->statuspan->statusform->bsent->setVisible(false);
+ $this->statuspan->statusform->bdel->setVisible(false);
} else {
$this->statuspan->statusform->bclose->setVisible(true);
$this->statuspan->statusform->bref->setVisible(true);
$this->statuspan->statusform->binp->setVisible(false);
+ $this->statuspan->statusform->bco->setVisible(true);
$this->statuspan->statusform->btask->setVisible(true);
}
@@ -218,20 +243,51 @@ public function updateStatusButtons() {
$this->statuspan->statusform->bref->setVisible(false);
$this->statuspan->statusform->bttn->setVisible(false);
$this->statuspan->statusform->binv->setVisible(false);
+ $this->statuspan->statusform->bgi->setVisible(false);
+ $this->statuspan->statusform->bsent->setVisible(false);
+ $this->statuspan->statusform->bdel->setVisible(false);
}
-
+ if ($state == Document::STATE_INPROCESS) {
+ $this->statuspan->statusform->bsent->setVisible(true);
+ $this->statuspan->statusform->bdel->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) {
+ $this->statuspan->statusform->bdel->setVisible(true);
+ $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_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) {
$this->statuspan->statusform->bclose->setVisible(false);
$this->statuspan->statusform->btask->setVisible(false);
$this->statuspan->statusform->binv->setVisible(false);
+ $this->statuspan->statusform->bgi->setVisible(false);
$this->statuspan->statusform->binp->setVisible(false);
$this->statuspan->statusform->bref->setVisible(false);
$this->statuspan->statusform->bttn->setVisible(false);
$this->statuspan->statusform->setVisible(false);
- }
+ $this->statuspan->statusform->bsent->setVisible(false);
+ $this->statuspan->statusform->bdel->setVisible(false);
+ }
if ($this->_doc->payamount > 0 && $this->_doc->payamount > $this->_doc->payed) {
$this->statuspan->statusform->bclose->setVisible(false);
@@ -254,10 +310,15 @@ public function updateStatusButtons() {
$list = $order->getChildren('GoodsIssue');
if (count($list) > 0 && $common['numberttn'] <> 1) {
- $this->statuspan->statusform->bttn->setVisible(false);
+ $this->statuspan->statusform->bgi->setVisible(false);
}
+
+
+ $list = $this->_doc->getChildren('Invoice');
+ if(count($list) > 0) $this->statuspan->statusform->binv->setVisible(false);
+
}
@@ -451,7 +512,7 @@ private function getWhere() {
$sn = trim($this->page->filter->searchnumber->getText());
if (strlen($sn) > 1) { // игнорируем другие поля
$sn = $conn->qstr('%' . $sn . '%');
- $where = " meta_name = 'Order' document_number like {$sn} ";
+ $where = " meta_name = 'Order' and document_number like {$sn} ";
}
return $where;
diff --git a/www/app/pages/register/paybaylist.php b/www/app/pages/register/paybaylist.php
index 9c29498b3..5677e0ddf 100644
--- a/www/app/pages/register/paybaylist.php
+++ b/www/app/pages/register/paybaylist.php
@@ -99,7 +99,7 @@ public function updateCust() {
$sql = "select c.customer_name,c.phone, c.customer_id,coalesce(sum(sam),0) as sam from (
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 payamount <> payed
+ 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}
group by c.customer_name,c.phone, c.customer_id
having sam <> 0
@@ -150,7 +150,7 @@ public function updateDocs() {
}
- $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 not in ({$this->_state}) {$this->_docs} ", "document_date");
+ $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");
$this->plist->doclist->Reload();
}
diff --git a/www/app/pages/register/serlist.php b/www/app/pages/register/serlist.php
index 71c855df0..3c237e364 100644
--- a/www/app/pages/register/serlist.php
+++ b/www/app/pages/register/serlist.php
@@ -73,7 +73,7 @@ public function filterOnSubmit($sender) {
$this->statuspan->setVisible(false);
- $this->doclist->Reload(false);
+ $this->doclist->Reload( );
}
public function doclistOnRow($row) {
diff --git a/www/app/pages/register/stocklist.php b/www/app/pages/register/stocklist.php
index aa6d18c80..1e9cf1e19 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);
}
@@ -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 e142b45c0..bd5d6604b 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','agendaWeek'))->setEvent($this, 'OnCal');
$this->updateTasks();
$this->updateCal();
diff --git a/www/app/pages/report/abc.php b/www/app/pages/report/abc.php
index e64556cd8..b6e75d9c3 100644
--- a/www/app/pages/report/abc.php
+++ b/www/app/pages/report/abc.php
@@ -177,7 +177,7 @@ private function find2() {
WHERE entrylist_view.amount >0 and meta_name in('GoodsReceipt')
AND entrylist_view.document_date >= " . $conn->DBDate($this->filter->from->getDate()) . "
AND entrylist_view.document_date <= " . $conn->DBDate($this->filter->to->getDate()) . "
- AND customers.details not like '%1%'
+ AND customers.detail not like '%1%'
{$this->br}
GROUP BY name
)t
@@ -203,7 +203,7 @@ private function find3() {
WHERE entrylist_view.amount <0 and meta_name in('GoodsIssue','POSCheck','Order')
AND entrylist_view.document_date >= " . $conn->DBDate($this->filter->from->getDate()) . "
AND entrylist_view.document_date <= " . $conn->DBDate($this->filter->to->getDate()) . "
- AND customers.details not like '%1%'
+ AND customers.detail not like '%1%'
{$this->br}
GROUP BY name
)t
diff --git a/www/app/pages/report/price.php b/www/app/pages/report/price.php
index abd7780fe..285a853ae 100644
--- a/www/app/pages/report/price.php
+++ b/www/app/pages/report/price.php
@@ -17,7 +17,7 @@ class Price extends \App\Pages\Base
public function __construct() {
parent::__construct();
- if (false == \App\ACL::checkShowReport('ItemActivity')) {
+ if (false == \App\ACL::checkShowReport('Price')) {
return;
}
diff --git a/www/app/pages/service/import.php b/www/app/pages/service/import.php
index 5dd9ab79d..f5fd678a6 100644
--- a/www/app/pages/service/import.php
+++ b/www/app/pages/service/import.php
@@ -272,7 +272,7 @@ public function onImport($sender) {
$amount = 0;
$itlist = array();
foreach ($newitems as $item) {
- $itlist[] = $item;
+ $itlist[$item->item_id] = $item;
$amount = $amount + ($item->quantity * $item->price);
}
$doc->packDetails('detaildata', $itlist);
@@ -543,7 +543,7 @@ public function onNImport($sender) {
$amount = 0;
$itlist = array();
foreach ($items as $item) {
- $itlist[] = $item;
+ $itlist[$item->item_id] = $item;
$amount = $amount + ($item->quantity * $item->price);
}
$doc->packDetails('detaildata', $itlist);
diff --git a/www/app/pages/subscribes.php b/www/app/pages/subscribes.php
index df6ffbc22..6668eb5ca 100644
--- a/www/app/pages/subscribes.php
+++ b/www/app/pages/subscribes.php
@@ -2,24 +2,30 @@
namespace App\Pages;
-use App\Entity\Firm;
+use App\Entity\Subscribe;
use App\Helper as H;
use Zippy\Html\DataList\DataView;
+use Zippy\Html\DataList\ArrayDataSource;
use Zippy\Html\Form\Button;
-use Zippy\Html\Form\CheckBox;
+
use Zippy\Html\Form\Form;
use Zippy\Html\Form\SubmitButton;
use Zippy\Html\Form\TextInput;
+use Zippy\Html\Form\TextArea;
+use Zippy\Html\Form\CheckBox;
+use Zippy\Html\Form\DropDownChoice;
use Zippy\Html\Label;
use Zippy\Html\Link\ClickLink;
use Zippy\Html\Panel;
+
use App\System;
class Subscribes extends \App\Pages\Base
{
private $_sub;
+ public $_subslist=array();
public function __construct() {
parent::__construct();
@@ -29,6 +35,149 @@ public function __construct() {
\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->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 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() ;
+ }
+ 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'));
+ $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) ;
+ }
+ 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);
+ $this->editform->editmsgtype->setValue($this->_sub->msg_type);
+ $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->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') ;
+ return;
+ }
+ 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') ;
+ return;
+
+ }
+ $this->_sub->save();
+ $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) {
+ $this->plist->setVisible(true);
+ $this->editform->setVisible(false);
+
+ Subscribe::delete($this->_sub->sub_id) ;
+ $this->Reload() ;
+ }
+
+
+ public function Reload() {
+
+ $this->_subslist = Subscribe::find('') ;
+
+ $this->plist->subslist->Reload() ;
+ }
+
}
diff --git a/www/app/pages/userlogin.php b/www/app/pages/userlogin.php
index e7bf67700..eac16d11b 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.3';
+ $curver = 'v4.8.4';
$this->_tvars['curversion'] = $curver;
//проверка новой версии
@@ -147,7 +147,7 @@ private function counter() {
$this->setError('invalidloginalert');
$this->loginform->setVisible(false);
if (strlen($admin->email) > 0) {
- Helper::sendLetter($msg, $admin->email, $admin->email, "Zippy Store alert");
+ Helper::sendLetter($msg, '', $admin->email, "Zippy Store alert");
}
}
diff --git a/www/app/pages/userprofile.php b/www/app/pages/userprofile.php
index 5685b775e..018eb1bd2 100644
--- a/www/app/pages/userprofile.php
+++ b/www/app/pages/userprofile.php
@@ -32,6 +32,8 @@ public function __construct() {
$form->onSubmit($this, 'onsubmit');
$form->add(new Label('userlogin', $this->user->userlogin));
$form->add(new TextInput('email', $this->user->email));
+ $form->add(new TextInput('phone', $this->user->phone));
+ $form->add(new TextInput('viber', $this->user->viber));
$form->add(new CheckBox('hidesidebar', $this->user->hidesidebar));
@@ -99,6 +101,8 @@ public function __construct() {
public function onsubmit($sender) {
$this->user->email = $sender->email->getText();
+ $this->user->phone = $sender->phone->getText();
+ $this->user->viber = $sender->viber->getText();
$this->user->hidesidebar = $sender->hidesidebar->isChecked() ? 1 : 0;
$this->user->deffirm = $sender->deffirm->getValue();
diff --git a/www/app/pages/users.php b/www/app/pages/users.php
index 68655d8b9..78f9ac5fd 100644
--- a/www/app/pages/users.php
+++ b/www/app/pages/users.php
@@ -103,10 +103,15 @@ public function onEdit($sender) {
public function saveOnClick($sender) {
-
+ $emp = \App\Entity\Employee::getByLogin($this->user->userlogin) ;
+
$this->user->email = $this->editpan->editform->editemail->getText();
- $this->user->userlogin = $this->editpan->editform->editlogin->getText();
-
+ $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/config/config.ini b/www/config/config.ini
index 880a3ef98..5136be6fe 100644
--- a/www/config/config.ini
+++ b/www/config/config.ini
@@ -25,9 +25,9 @@ tls=true
ocstore=0 ; интеграция с опенкарт
shop=0 ; встроеный модуль онлайн каталога
note=1 ; модуль органайзера(базы знаний)
-issue=0 ; модуль Проекты и задачи
+issue=1 ; модуль Проекты и задачи
woocomerce=0 ; интеграция с вукомерсе
tecdoc=0 ; поиск по базе автозапчастей
ppo=0 ; фискализация
-np=0 ; интеграция с новой почтой
+np=1
\ No newline at end of file
diff --git a/www/index.php b/www/index.php
index 97584a9d4..a1dacde03 100644
--- a/www/index.php
+++ b/www/index.php
@@ -65,4 +65,4 @@
}
}
-// 3f217d4c7b7458d3d00207b177d8776c
\ No newline at end of file
+
\ No newline at end of file
diff --git a/www/templates/lang.json b/www/templates/lang.json
index 4b8da63ff..eacc343c0 100644
--- a/www/templates/lang.json
+++ b/www/templates/lang.json
@@ -128,6 +128,7 @@
"noseloutcome": "Не выбран тип расхода",
"noselservice": "Не выбрана услуга",
"noseljob": "Не выбрана работа",
+ "noselprod": "Не выбрана продукция",
"noenterpos": "Не введены позиции",
"noselexecutor": "Не выбран исполнитель",
"noseleq": "Не выбрано оборудование",
@@ -310,7 +311,7 @@
"bayer": "Покупатель",
"seller": "Поставщик",
"holdings": "Холдинги",
- "isactul": "Актуальный",
+ "isactual": "Актуальный",
"notused": "Не используется",
"potential": "Потенциальный",
"bankproc": "Банковский процент за транзакцию",
@@ -374,5 +375,20 @@
"contract": "Договор",
"noselcontract": "Не выбран договор",
"bycontract": "Оплата по договору %s",
- "noselctype": "Не вибран тип договора"
+ "noselctype": "Не вибран тип договора" ,
+ "sb_docstate": "Изменения статуса документа",
+ "sb_msgnotify": "Системное уведомление",
+ "sb_msgemail": "E-mail",
+ "sb_msgsms": "SMS",
+ "sb_msgviber": "Viber",
+ "sb_rsvcust": "Контрагент документа",
+ "sb_rsvda": "Автор документа",
+ "sb_rsvuser": "Пользователь системы",
+ "sb_errtext": "Не введен текст сообщения",
+ "sb_errmtype": "Не указан тип сообщения",
+ "sb_erruser": "Не указан пользователь",
+ "sb_rsvuser": "Пользователь системы",
+ "sb_subject": "Уведомление с %s",
+ "noselpayment": "Не выбрано счет",
+ "paymentseq": "Счета одинаковые"
}
\ No newline at end of file
diff --git a/www/templates/modules/np/ttnlist.html b/www/templates/modules/np/ttnlist.html
new file mode 100644
index 000000000..09269230b
--- /dev/null
+++ b/www/templates/modules/np/ttnlist.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
Состояние доставок
+
Обновить
+
+
+ ТТН |
+ Сумма |
+ Покупатель |
+ Экспрес-накладная |
+ Состояние |
+ |
+
+
+
+ |
+ | |
+ |
+ |
+ |
+
+
+
+
+
+
+
diff --git a/www/templates/pages/base.html b/www/templates/pages/base.html
index d72ef41c9..0c2c6579f 100644
--- a/www/templates/pages/base.html
+++ b/www/templates/pages/base.html
@@ -604,8 +604,18 @@ _______________
-
+
+
+
+
+
+ -
+
+
+
Список доставок
+
+
-
diff --git a/www/templates/pages/doc/movemoney.html b/www/templates/pages/doc/movemoney.html
new file mode 100644
index 000000000..5cf14f26c
--- /dev/null
+++ b/www/templates/pages/doc/movemoney.html
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/www/templates/pages/doc/order.html b/www/templates/pages/doc/order.html
index fcac164da..80f938d7b 100644
--- a/www/templates/pages/doc/order.html
+++ b/www/templates/pages/doc/order.html
@@ -92,12 +92,13 @@
Заказ
Название |
Код |
Ед. |
-
+ |
Кол. |
Цена |
Сумма |
+
|
@@ -105,23 +106,24 @@ Заказ
|
|
-
+ |
|
|
|
+
|
- Всего: |
+ Всего: |
|
|
- Скидка: |
+ Скидка: |
|
@@ -131,7 +133,7 @@ Заказ
- К оплате: |
+ К оплате: |
|
@@ -140,7 +142,7 @@ Заказ
- Внесена оплата: |
+ Внесена оплата: |
|
@@ -261,6 +263,11 @@ Ввод товара
style="width: 70px;">
+
+
+
+
+
diff --git a/www/templates/pages/doc/ordercust.html b/www/templates/pages/doc/ordercust.html
index df734ebec..fb59cf51e 100644
--- a/www/templates/pages/doc/ordercust.html
+++ b/www/templates/pages/doc/ordercust.html
@@ -48,7 +48,8 @@
Заявка поставщику
Артикул |
Код поставщика |
Ед. |
- Кол. |
+ |
+ Кол. |
Цена |
Сумма |
@@ -61,6 +62,7 @@ Заявка поставщику
|
|
|
+ |
|
|
@@ -70,7 +72,7 @@ Заявка поставщику
- Всего: |
+ Всего: |
|
|
@@ -131,6 +133,11 @@ Ввод товара
+
+
+
+
+
diff --git a/www/templates/pages/main.html b/www/templates/pages/main.html
index e2782cf30..0c988b351 100644
--- a/www/templates/pages/main.html
+++ b/www/templates/pages/main.html
@@ -85,6 +85,7 @@
Просроченные товары
Товары для которых истек или истекает срок годности
+
Экспорт в Excel
@@ -115,7 +116,8 @@ Просроченные товары
Минимальное количество
Товары для которых задано минимальное количество на складе и актуальное количество меньше заданного
-
+
Экспорт в Excel
+
Склад |
Товар |
@@ -146,7 +148,8 @@ Минимальное количество
Мои недавние документы
Документы с недавно измененным статусом
-
+
Экспорт в Excel
+
Номер |
Тип |
diff --git a/www/templates/pages/options.html b/www/templates/pages/options.html
index 39831fd01..089f0e9f5 100644
--- a/www/templates/pages/options.html
+++ b/www/templates/pages/options.html
@@ -319,6 +319,72 @@ Настройка API
+
+
+
+
Настройка сервиса SMS уведомлений
+
+
+
diff --git a/www/templates/pages/reference/contractlist.html b/www/templates/pages/reference/contractlist.html
index 428e1702f..465efd517 100644
--- a/www/templates/pages/reference/contractlist.html
+++ b/www/templates/pages/reference/contractlist.html
@@ -174,39 +174,11 @@
|
|
-
- |
- |
-
- Всего: |
- |
-
-
+
-
-
-
- Оплата будет распределена по документам начиная с более ранних
-
-
+
diff --git a/www/templates/pages/reference/customerlist.html b/www/templates/pages/reference/customerlist.html
index 4debe46fe..e9a53e22c 100644
--- a/www/templates/pages/reference/customerlist.html
+++ b/www/templates/pages/reference/customerlist.html
@@ -16,10 +16,7 @@ Справочник контрагентов
-
-
+