From c94c4dc7d69841e0f0bb8b2477b87d7eef16ec5c Mon Sep 17 00:00:00 2001 From: Dmitry Yu Okunev Date: Thu, 5 Jun 2014 16:49:00 +0400 Subject: [PATCH] Updated --- .gitignore | 2 ++ genpdf/config.php | 6 ++++++ genpdf/genpdf.php | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mephimemo/mephimemo.cls | 10 ++++++---- mephimemo/template/request/hpc.tex | 5 +++++ mephimemo/template/request/nix-hosting.tex | 1 + mephimemo/template/request/vpn-private-net.tex | 3 +++ mephimemo/template/request/vpn.tex | 5 +++++ mephimemo/template/request/win-hosting.tex | 1 + 9 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 genpdf/config.php create mode 100644 genpdf/genpdf.php create mode 100644 mephimemo/template/request/hpc.tex create mode 100644 mephimemo/template/request/nix-hosting.tex create mode 100644 mephimemo/template/request/vpn-private-net.tex create mode 100644 mephimemo/template/request/vpn.tex create mode 100644 mephimemo/template/request/win-hosting.tex diff --git a/.gitignore b/.gitignore index 5e421c7..3fcd5ff 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ mephimemo/body.tex mephimemo/footer.tex mephimemo/responsible.tex mephimemo/urlqr.tex +mephimemo/memo.aux +mephimemo/memo.fdb_latexmk diff --git a/genpdf/config.php b/genpdf/config.php new file mode 100644 index 0000000..3a73ed5 --- /dev/null +++ b/genpdf/config.php @@ -0,0 +1,6 @@ + diff --git a/genpdf/genpdf.php b/genpdf/genpdf.php new file mode 100644 index 0000000..dd6e55a --- /dev/null +++ b/genpdf/genpdf.php @@ -0,0 +1,141 @@ + $value) + $_GET_withbraces['[{'.$key.'}]'] = $value; + + switch ($_GET['file']) { + case 'request/vpn': + if (isset($_GET['vlan'])) + $_GET_withbraces['[{additional-access}]'] = 'Также прошу предоставить доступ к VLAN '. $_GET['vlan']. ' через данную учётную запись.'; + if (!isset($_GET_withbraces['[{is-additional-login}]'])); + $_GET_withbraces['[{is-additional-login}]'] = ''; + break; + } + + $body = str_replace(array_keys($_GET_withbraces), array_values($_GET_withbraces), $body); + + return $body; +} + +switch ($_GET['file']) { + case 'request/vpn': + $project_id = 1; + $memo_subject = 'Запрос на учётную запись к vpn.mephi.ru'; + break; + case 'request/vpn-private-net': + $project_id = 1; + $memo_subject = 'Запрос на доступ к VLAN через vpn.mephi.ru'; + break; + case 'request/nix-hosting': + $project_id = 1; + $memo_subject = 'Заявка на предоставление nix-хостинга'; + break; + case 'request/win-hosting': + $project_id = 1; + $memo_subject = 'Заявка на предоставление win-хостинга'; + break; + case 'request/hpc': + $project_id = NULL; //38; + $memo_subject = 'Запрос на учётную запись к vpn.mephi.ru'; + break; + default: + die('unknown memo-type'); +} + +$tempdir = tempdir(); + +if ($tempdir === FALSE) + die('Cannot create temporary directory'); + + +exec('cp -a /var/www/ut.mephi.ru/ut-tex/mephimemo "'.$tempdir.'/"'); +chdir($tempdir.'/mephimemo'); + +ob_start(); +print_r($_GET); +$_GET_print_r = ob_get_clean(); + +$redmine = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); + +if (!is_null($project_id)) { + $issue = $redmine->api('issue')->create( + array( + 'project_id' => $project_id, + 'subject' => $memo_subject, + 'description' => $_GET_print_r, + ) + ); + + $issue_id = $issue->id; +} else { + $issue_id = $_GET['issue-id']; +} + +if (!isset($_GET['date-end'])) + $_GET['date-end'] = (date('Y')+1).'-12-31'; + +foreach (array('fullname', 'phonenumber', 'email') as $key) + if (!isset($_GET['contact-'.$key])) + $_GET['contact-'.$key] = $_GET['user-'.$key]; + +foreach ($_GET as $key => &$value) + $value = str_replace('_', '\_', $value); + +$body_template = file_get_contents('template/'.$_GET['file'].'.tex'); +$body = body_parse($body_template); + +file_put_contents('header.tex', '\mmheader{Начальнику управления информатизации}{Н. Н. Романову}'); +file_put_contents('body.tex', $body); +file_put_contents('footer.tex', '\mmfooter{'.$_GET['signer-appointment'].'}{'.$_GET{'signer-fullname'}.'}'); +file_put_contents('responsible.tex', '\mmresponsible{'.$_GET['contact-fullname'].'}{'.$_GET{'contact-phonenumber'}.'}{'.$_GET['contact-email'].'}'); +file_put_contents('urlqr.tex', '\mmredmineurlqr{'.$issue_id.'}'); + +exec('make'); +$pdf_content = file_get_contents('memo.pdf'); + +$pdf_upload = json_decode( $redmine->api('attachment')->upload($pdf_content) ); + +$redmine->api('issue')->attach( + $issue_id, + array( + 'token' => $pdf_upload->upload->token, + 'filename' => 'memorandum.pdf', + 'description' => 'Memorandum', + 'content_type'=> 'application/pdf' + ) +); + +header('Content-type: application/pdf'); +print $pdf_content; + +?> diff --git a/mephimemo/mephimemo.cls b/mephimemo/mephimemo.cls index 24958c6..234f8e1 100644 --- a/mephimemo/mephimemo.cls +++ b/mephimemo/mephimemo.cls @@ -65,9 +65,9 @@ \small{ Ответственное лицо:\\ \vspace{0.2cm} - {#1}\\ - IP телефон: {#2}\\ - Эл. почта: {#3} + ФИО: {#1}\\ + телефон: {#2}\\ + эл. почта: {#3} } \end{flushleft} } @@ -78,8 +78,10 @@ \newcommand{\mmredmineurlqr}[1]{ \begin{flushright} \parbox{2.1cm}{ - \psbarcode{{http://redmine.ut.mephi.ru/issues/#1}}{}{qrcode} + \psbarcode{{https://redmine.ut.mephi.ru/issues/#1}}{}{qrcode} } + \\ + \tiny https://redmine.ut.mephi.ru/issues/#1 \end{flushright} } diff --git a/mephimemo/template/request/hpc.tex b/mephimemo/template/request/hpc.tex new file mode 100644 index 0000000..ab3c5b7 --- /dev/null +++ b/mephimemo/template/request/hpc.tex @@ -0,0 +1,5 @@ +Прошу предоставить [{user-appointment}] [{user-fullname}] доступ к ресурсам высокопроизводительного вычислительного центра НИЯУ МИФИ для [{reason-for}]. + +Предпочитаемое имя пользователя: [{preffered-login}]. + +Срок окончания работ: [{date-end}] diff --git a/mephimemo/template/request/nix-hosting.tex b/mephimemo/template/request/nix-hosting.tex new file mode 100644 index 0000000..e885f77 --- /dev/null +++ b/mephimemo/template/request/nix-hosting.tex @@ -0,0 +1 @@ +Прошу предоставить хостинг на базе «[{os}]» для размещения ресурса «[{domainnames}]» diff --git a/mephimemo/template/request/vpn-private-net.tex b/mephimemo/template/request/vpn-private-net.tex new file mode 100644 index 0000000..66eccc6 --- /dev/null +++ b/mephimemo/template/request/vpn-private-net.tex @@ -0,0 +1,3 @@ +Прошу предоставить [{user-appointment}] [{user-fullname}] доступ к VLAN [{vlan}] посредством сервиса VPN НИЯУ МИФИ по адресу «vpn.mephi.ru» для [{reason-for}]. + +Имя пользователя: [{preffered-login}]. diff --git a/mephimemo/template/request/vpn.tex b/mephimemo/template/request/vpn.tex new file mode 100644 index 0000000..8b20ecd --- /dev/null +++ b/mephimemo/template/request/vpn.tex @@ -0,0 +1,5 @@ +Прошу предоставить [{user-appointment}] [{user-fullname}] [{is-additional-login}] учётную запись к сервису VPN НИЯУ МИФИ по адресу «vpn.mephi.ru» для [{reason-for}]. + +Предпочитаемое имя пользователя: [{preffered-login}]. + +[{additional-access}] diff --git a/mephimemo/template/request/win-hosting.tex b/mephimemo/template/request/win-hosting.tex new file mode 100644 index 0000000..e885f77 --- /dev/null +++ b/mephimemo/template/request/win-hosting.tex @@ -0,0 +1 @@ +Прошу предоставить хостинг на базе «[{os}]» для размещения ресурса «[{domainnames}]» -- libgit2 0.24.0