From aa2c7bd3ae7f647f9969d86fc1bd35de58701f8e Mon Sep 17 00:00:00 2001 From: "leon.mbs@gmail.com" Date: Sun, 24 Mar 2024 13:05:11 +0200 Subject: [PATCH] fix --- www/app/entity/doc/document.php | 24 ++++++++++++++++++------ www/app/entity/subscribe.php | 5 +---- www/app/pages/register/doclist.php | 13 ++++++++++--- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/www/app/entity/doc/document.php b/www/app/entity/doc/document.php index 0ef99d50f..d235ccf11 100644 --- a/www/app/entity/doc/document.php +++ b/www/app/entity/doc/document.php @@ -756,19 +756,31 @@ protected function afterDelete() { * запись состояния в лог документа * @param mixed $state */ - public function insertLog($state) { + public function insertLog($state,$user_id=0) { $conn = \ZDB\DB::getConnect(); $host = $_SERVER["REMOTE_ADDR"]; if($host==null) { $host = ""; } $host = $conn->qstr($host); - $user = \App\System::getUser(); - if($user == null) { - $user = \App\Entity\User::getByLogin('admin') ; - } + if($user_id==0){ + $user = \App\System::getUser(); + if($user == null) { + $user = \App\Entity\User::getByLogin('admin') ; + } + $user_id= $user->user_id; + } else { - $sql = "insert into docstatelog (document_id,user_id,createdon,docstate,hostname) values({$this->document_id},{$user->user_id},now(),{$state},{$host})"; + $n = new \App\Entity\Notify(); + $n->user_id = $user_id; + $n->sender_id = \App\Entity\Notify::SYSTEM; + $n->dateshow = time(); + $n->message = "Ви призначені виконавцем документу {$this->document_number} " ; + + $n->save(); + } + + $sql = "insert into docstatelog (document_id,user_id,createdon,docstate,hostname) values({$this->document_id},{$user_id},now(),{$state},{$host})"; $conn->Execute($sql); } diff --git a/www/app/entity/subscribe.php b/www/app/entity/subscribe.php index 2b1070dbb..71d1d11cf 100644 --- a/www/app/entity/subscribe.php +++ b/www/app/entity/subscribe.php @@ -133,10 +133,7 @@ public static function onDocumentState($doc_id, $state) { continue; } - $cnt = $doc->checkStates(array($state)); - if ($cnt > 1) { - // continue; - } + $ret = ''; $phone = ''; diff --git a/www/app/pages/register/doclist.php b/www/app/pages/register/doclist.php index abd02b538..177446ede 100644 --- a/www/app/pages/register/doclist.php +++ b/www/app/pages/register/doclist.php @@ -372,9 +372,11 @@ public function show($doc) { } } $this->statusform->musers->setOptionList($u); - $user = System::getUser(); - if(in_array($user->user_id, array_keys($u))) { - $this->statusform->musers->setValue($user->user_id); +// $user = System::getUser(); + if(in_array($this->_doc->user_id, array_keys($u))) { + $this->statusform->musers->setValue($this->_doc->user_id); + } else { + $this->statusform->musers->setValue(0); } } @@ -604,6 +606,7 @@ public function statusOnSubmit($sender) { $n->message .= "
" . $text; $n->save(); + $this->statusform->refcomment->setText(''); } @@ -643,10 +646,14 @@ public function statusOnSubmit($sender) { if($user_id==0) { return; } + if($user_id==$this->_doc->user_id) { + return; + } $this->_doc->user_id = $user_id; $this->_doc->save(); + $this->_doc->insertLog($this->_doc->state,$this->_doc->user_id); }