Skip to content

Commit

Permalink
Merge pull request #729 from leon-mbs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
leon-mbs authored Mar 25, 2024
2 parents f8185d1 + 201f73a commit 88fa0e7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
24 changes: 18 additions & 6 deletions www/app/entity/doc/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 1 addition & 4 deletions www/app/entity/subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ public static function onDocumentState($doc_id, $state) {
continue;
}

$cnt = $doc->checkStates(array($state));
if ($cnt > 1) {
// continue;
}


$ret = '';
$phone = '';
Expand Down
13 changes: 10 additions & 3 deletions www/app/pages/register/doclist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Expand Down Expand Up @@ -604,6 +606,7 @@ public function statusOnSubmit($sender) {
$n->message .= "<br> " . $text;
$n->save();


$this->statusform->refcomment->setText('');
}

Expand Down Expand Up @@ -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);

}

Expand Down

0 comments on commit 88fa0e7

Please sign in to comment.