From 90fe72b67c86792afb00e7930d4720178eb9bda7 Mon Sep 17 00:00:00 2001 From: Dmitry Yu Okunev Date: Tue, 7 Apr 2015 09:04:58 +0300 Subject: [PATCH] Fixed vacation --- genpdf/genpdf.php | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------- mephimemo/mephimemo.cls | 4 ++-- mephimemo/template/request/temporary-acting.tex | 2 +- mephimemo/template/request/vacation.tex | 2 +- 4 files changed, 73 insertions(+), 39 deletions(-) diff --git a/genpdf/genpdf.php b/genpdf/genpdf.php index e5bc7ed..a8cbea5 100644 --- a/genpdf/genpdf.php +++ b/genpdf/genpdf.php @@ -87,16 +87,17 @@ Array */ $dont_inflect_patterns = array( - '/^нач./', - '/^зам./', - '/^заф./', - '/^нач./', - '/^./', - '/^спец./', + '/^нач\./', + '/^зам\./', + '/^заф\./', + '/^нач\./', + '/^\./', + '/^спец\./', ); $inflect_cut_patterns = array( '/^(.*)[иы]й[ ]/', + '/^\[\d+\] /', ); $inflect_ignore_ending_patterns = array( @@ -153,7 +154,9 @@ function error($str) { //DE base64 subdivs if (isset($_GET['signer-subdivs'])){ $_GET['signer-subdivs'] = base64_decode($_GET['signer-subdivs']); - +} +if (isset($_GET['signer-subdivs-full'])){ + $_GET['signer-subdivs-full'] = base64_decode($_GET['signer-subdivs-full']); } $inflect = new Inflect(); @@ -210,6 +213,12 @@ foreach (array('signer', 'contact', 'user') as $key) { if (empty($_GET[$key_prefix.'-'.$key.'-fullname'])) $_GET[$key_prefix.'-'.$key.'-fullname'] = $inflect->getInflectName($_GET[$key.'-fullname'], $case); + if (empty($_GET[$key_prefix.'-'.$key.'-subdivs-full'])) { + $words = split(' ', $_GET['signer-subdivs-full']); + $words[0] = $inflect->getInflectNoun($words[0], $case); + $_GET[$key_prefix.'-'.$key.'-subdivs-full'] = join(' ', $words); + } + if (empty($_GET[$key_prefix.'-'.$key.'-appointment'])) { foreach ($dont_inflect_patterns as &$dont_inflect_pattern) { if (preg_match($dont_inflect_pattern, $_GET[$key.'-appointment'])) { @@ -217,36 +226,45 @@ foreach (array('signer', 'contact', 'user') as $key) { continue 2; } } + } // working with appointments - $appointments = split(', ', $_GET[$key.'-appointment']); - foreach ($appointments as &$appointment) { - $matches = NULL; - $ignored_ending = ''; - - $appointment = preg_replace($inflect_cut_patterns, '', $appointment); - - foreach($inflect_ignore_ending_patterns as $inflect_ignore_ending_pattern) { - if (preg_match('/'.$inflect_ignore_ending_pattern.'$/u', $appointment, $matches, PREG_OFFSET_CAPTURE)) { - foreach ($matches as &$match) { - $ignored_ending .= $match[0]; - $appointment = mb_substr($appointment, 0, -mb_strlen($match[0])); - } + $appointments = split(', ', $_GET[$key.'-appointment']); + foreach ($appointments as &$appointment) { + $matches = NULL; + $ignored_ending = ''; + + $appointment = preg_replace($inflect_cut_patterns, '', $appointment); + error_log('Appointment: '.$appointment); + + foreach($inflect_ignore_ending_patterns as $inflect_ignore_ending_pattern) { + if (preg_match('/'.$inflect_ignore_ending_pattern.'$/u', $appointment, $matches, PREG_OFFSET_CAPTURE)) { + foreach ($matches as &$match) { + $ignored_ending .= $match[0]; + $appointment = mb_substr($appointment, 0, -mb_strlen($match[0])); } } - - $appointment = $inflect->getInflectNoun($appointment, $case); - - $appointment .= $ignored_ending; - $_GET[$key_prefix.'-'.$key.'-appointment'] = $appointment; } - $_GET[$key_prefix.'-'.$key.'-appointment'] = join(', ', $appointments); - + $appointment = $inflect->getInflectNoun($appointment, $case); + + $appointment .= $ignored_ending; + $_GET[$key_prefix.'-'.$key.'-appointment'] = $appointment; } + + $_GET[$key_prefix.'-'.$key.'-appointment'] = join(', ', $appointments); } } +$signer_appointment_wosubdiv_words = split(' ', $_GET['signer-appointment-wosubdiv']); +$signer_subdivs_full_words = split(' ', $_GET['of-signer-subdivs-full']); +error_log('DDD: '.serialize($signer_appointment_wosubdiv_words)); +error_log('WWW: '.serialize($signer_subdivs_full_words)); +if ($signer_appointment_wosubdiv_words[count($signer_appointment_wosubdiv_words)-1] === $signer_subdivs_full_words[0]) + unset($signer_appointment_wosubdiv_words[count($signer_appointment_wosubdiv_words)-1]); + +$_GET['signer-appointment-wosubdiv-dedup'] = join(' ', $signer_appointment_wosubdiv_words); + foreach (array('work-date-end' => 'Срок окончания работ') as $key => $descr) { $_GET[$key.'-descr'] = $descr.': '. ( @@ -344,6 +362,8 @@ $custom_fields_keys = array(); $files = split(',', $_GET['file']); +$replacement_is_already_done = false; + $pdfs = array(); foreach ($files as $file) { $file_eff = $file; @@ -361,8 +381,8 @@ foreach ($files as $file) { $_GET['target-id'] = $_GET['ipaddr']; break; case 'container-name': - $_GET['target-type'] = 'контейнер'; - $_GET['target-id'] = $_GET['container-name']; + $_GET['target-type'] = 'контейнером'; + $_GET['target-id'] = '«'.$_GET['container-name'].'»'; break; case 'issue-id': $_GET['target-type'] = 'ранее предоставленным хостингом по заявке'; @@ -371,7 +391,7 @@ foreach ($files as $file) { } break; case 'request/vpn': - $project_id = 1; + $project_id = 84; $memo_subject = 'Запрос на учётную запись к vpn.mephi.ru'; break; case 'request/vpn-private-net': @@ -502,10 +522,6 @@ foreach ($files as $file) { foreach($custom_fields_keys as $id => $key) $custom_fields[] = array('id' => $id, 'value' => empty($_GET[$key]) ? '0' : $_GET[$key]); - foreach ($_GET as $key => &$value) { - $value = str_replace(array('\\', '_', '#'), array('{\textbackslash}', '\_', '\\#'), $value); - } - $tempdir = tempdir(); if ($tempdir === FALSE) @@ -516,6 +532,15 @@ foreach ($files as $file) { chdir($tempdir.'/mephimemo'); file_put_contents("request.get", print_r($_GET, true)); + if (!$replacement_is_already_done) { + foreach ($_GET as $key => &$value) + $value = str_replace(array('\\', '_', '#'), array('{\textbackslash}', '\_', '\\#'), $value); + + $replacement_is_already_done = true; + } + + file_put_contents("request.get.fixed", print_r($_GET, true)); + #ob_start(); #print_r($_GET); #$_GET_print_r = ob_get_clean(); @@ -576,10 +601,19 @@ foreach ($files as $file) { 'description' => $text, ); break; + case 'request/nix-hosting': + $issue_props = + array( + 'assigned_to_id' => USERID_AMGLADTSIN, + 'project_id' => $project_id, + 'subject' => $memo_subject, + 'description' => $text, + ); + break; default: $issue_props = array( - 'assigned_to_id' => USERID_DYOKUNEV, + 'assigned_to_id' => USERID_EVVLASOV, 'project_id' => $project_id, 'subject' => $memo_subject, 'description' => $text, diff --git a/mephimemo/mephimemo.cls b/mephimemo/mephimemo.cls index 334a8c2..15baed9 100644 --- a/mephimemo/mephimemo.cls +++ b/mephimemo/mephimemo.cls @@ -168,10 +168,10 @@ \newcommand{\mmredmineurlqr}[1]{ \begin{flushright} \parbox{3.2cm}{ - \psbarcode{{https://redmine.ut.mephi.ru/issues/#1}}{eclevel=L width=1.2 height=1.2}{qrcode} + \psbarcode{{https://tasks.mephi.ru/issues/#1}}{eclevel=L width=1.2 height=1.2}{qrcode} } \\ - \tiny https://redmine.ut.mephi.ru/issues/#1 + \tiny https://tasks.mephi.ru/issues/#1 \end{flushright} } diff --git a/mephimemo/template/request/temporary-acting.tex b/mephimemo/template/request/temporary-acting.tex index f32fd0b..9324422 100644 --- a/mephimemo/template/request/temporary-acting.tex +++ b/mephimemo/template/request/temporary-acting.tex @@ -1 +1 @@ -Прошу вас разрешить возложить обязанности [{signer-appointment}] на время моего [{of-vacation}] с [{days-from}] по [{days-to}] на [{of-user-appointment}] [{of-user-fullname}] с компенсацией разницы в окладах. +Прошу вас разрешить возложить обязанности [{of-signer-appointment}] на время моего [{of-vacation}] с [{days-from}] по [{days-to}] на [{of-user-appointment}] [{of-user-fullname}] с компенсацией разницы в окладах. diff --git a/mephimemo/template/request/vacation.tex b/mephimemo/template/request/vacation.tex index 2cc0927..162a461 100644 --- a/mephimemo/template/request/vacation.tex +++ b/mephimemo/template/request/vacation.tex @@ -1,7 +1,7 @@ Прошу предоставить мне [{vacation-type}] на [{days-count}] [{days-descr}] с [{days-from}] по [{days-to}]. \begin{flushright} -[{signer-appointment}]\\ +[{signer-appointment-wosubdiv-dedup}] [{of-signer-subdivs-full}]\\ \vspace{0.7cm} \_\_\_\_\_\_\_\_\_\_\_\_\_ [{signer-fullname}] \end{flushright} -- libgit2 0.24.0