diff --git a/genpdf/decide-note.php b/genpdf/decide-note.php new file mode 100644 index 0000000..48e40d7 --- /dev/null +++ b/genpdf/decide-note.php @@ -0,0 +1,101 @@ +api('issue')->show($_GET['issueId'])['issue']; + +$assignedTo = $redmine_admin->api('user' )->show($issue['assigned_to']['id']); + +$api_key = $assignedTo['user']['api_key']; +$redmine = new Redmine\Client('https://redmine.ut.mephi.ru', $api_key); + +switch ($_GET['action']) { + case 'agree': + header('Content-Type: text/plain'); + + $recipientId = NULL; + foreach ( $issue['custom_fields'] as $cf) { + if ($cf['id'] == 95) { + $recipientId = $cf['value']; + break; + } + } + + if (is_null($recipientId)) { + die('Cannot find recipient custom field in issue: '.$_GET['issueId']); + } + $recipient = $redmine_admin->api('user')->show($recipientId)['user']; + + if (empty($recipient['mail'])) { + die('Cannot find login of user with ID: '.$recipientId); + } + + //print @json_encode($redmine->api('issue')->update($issue['id'], array('status_id' => STATUSID_NEW, 'project_id' => redmine_proj_identifier2id(strtolower(explode('@', $recipient['mail'])[0])), 'assigned_to_id' => $recipient['id']))); + $result = $redmine->api('issue')->update($issue['id'], array('status_id' => STATUSID_NEW, 'project_id' => redmine_proj_identifier2id(strtolower(explode('@', $recipient['mail'])[0])), 'assigned_to_id' => $recipient['id'])); + if ($result == true) { + header('Location: https://tasks.mephi.ru/issues/'.$_GET['issueId']); + } + break; + case 'decline': + header('Content-Type: text/plain'); + + //print @json_encode($redmine->api('issue')->update($_GET['issueId'], array('status_id' => STATUSID_DECLINED))); + $result = $redmine->api('issue')->update($_GET['issueId'], array('status_id' => STATUSID_DECLINED)); + if ($result == true) { + header('Location: https://tasks.mephi.ru/issues/'.$_GET['issueId']); + } + break; + default: + die('Unknown action: '.$_GET['action']); +} + + +?> diff --git a/genpdf/genpdf.php b/genpdf/genpdf.php index 505de69..dfd1fcc 100644 --- a/genpdf/genpdf.php +++ b/genpdf/genpdf.php @@ -143,6 +143,10 @@ header( "Content-Type: text/plain" ); //print_r ($_GET); die(); //print_r($_GET); +if (isset($_GET['signer2user'])) { + $_GET['user-appointment-id'] = $_GET['signer-appointment-id']; +} + $me = NULL; $inflect = new Inflect(); @@ -786,7 +790,13 @@ foreach ($files as $file) { break; case 'request/custom': //print_r($_GET);die(); - $project_id = redmine_proj_identifier2id ($_GET['recipient-login']); + if ($_GET['user-appointment-id'] != $_GET['signer-appointment-id']) { + $project_id = 15971; + $_GET['recipient-redmine-id'] = redmine_login2id($_GET['recipient-login']); + $custom_fields_keys = array (95 => 'recipient-redmine-id'); + } else { + $project_id = redmine_proj_identifier2id ($_GET['recipient-login']); + } $memo_subject = 'Служебная записка'; $me['id'] = $user_redmine['user']['id']; $replacement_is_already_done = true; @@ -1051,7 +1061,8 @@ foreach ($files as $file) { case 'request/custom': $header = '\mmheader{'.my_mb_ucfirst($_GET['to-recipient-appointment-w-fullsubdiv-cap']).'}{'.my_mb_ucfirst($_GET['to-recipient-name']).'}'; $body = latexSpecialChars1(str_replace("\n", "\n\n", $body)); - $footer = '\mmfooter{'.my_mb_ucfirst($_GET['signer-appointment']).'}{'.$_GET['signer-name'].'}{'.$_GET['current-date'].'}{}'; + $footer = '\mmfooter{'.my_mb_ucfirst($_GET['user-appointment']).'}{'.$_GET['user-name'].'}{'.$_GET['current-date'].'}{}'; + // $footer = '\mmfooter{'.my_mb_ucfirst($_GET['signer-appointment']).'}{'.$_GET['current-date'].'}{'.$_GET['signer-name'].'}{}'; @@ -1155,14 +1166,19 @@ foreach ($files as $file) { - case 'request/custom': //AASD + case 'request/custom': + if ($_GET['user-appointment-id'] != $_GET['signer-appointment-id']) { + $assigned_to_id = redmine_login2id($_GET['user-login']); + } else { + $assigned_to_id = redmine_login2id($_GET['recepient-login']); + } + $issue_props = array( - 'assigned_to_id' => redmine_login2id($_GET['recepient-login']), + 'assigned_to_id' => $assigned_to_id, 'project_id' => $project_id, 'subject' => 'Служебная записка '.$_GET['to-recipient-name'].' от '.$_GET['of-signer-name'].', '.date(" Y.m.d, H:i:s"), 'description' => "
".$text."
", - ); break; @@ -1210,7 +1226,8 @@ foreach ($files as $file) { if (!empty($_GET['category_id'])) $issue_props['category_id'] = $_GET['category_id']; - + //print_r($issue_props);die(); + error_log(base64_encode(serialize($issue_props))); $key = serialize($issue_props); @@ -1241,7 +1258,21 @@ foreach ($files as $file) { } } - file_put_contents('urlqr.tex', '\mmredmineurlqr{'.$issue_id.'}'); + $qr = '\mmredmineurlqr{'.$issue_id.'}'; + switch($file) { + case 'request/custom': + if ($_GET['user-appointment-id'] != $_GET['signer-appointment-id']) { + $qr .= ' +\vspace{-2.8cm} +\begin{flushleft} + Подготовил(а):\\\\ + '.$_GET['signer-name'].' +\end{flushleft}'; + } + break; + } + + file_put_contents('urlqr.tex', $qr); if (isset($user_redmine['user']['id'])) $redmine_admin->api('issue')->addWatcher($issue_id, $user_redmine['user']['id']); diff --git a/genpdf/lib/3dparty/Inflect b/genpdf/lib/3dparty/Inflect index a60c8e4..754ec13 160000 --- a/genpdf/lib/3dparty/Inflect +++ b/genpdf/lib/3dparty/Inflect @@ -1 +1 @@ -Subproject commit a60c8e42622081bce1e8a04c0d18eef53791418b +Subproject commit 754ec13a3789333e9c0a2f858116d0aec7edd238