From 7c3ae1ac9948b5a241d88ea64db398452be8ff7a Mon Sep 17 00:00:00 2001 From: xaionaro Date: Wed, 25 Oct 2017 10:08:32 +0300 Subject: [PATCH] updated --- genpdf/genpdf2.php | 70 +++++++++++++++++++++++++++++++++++++++------------------------------- mephimemo/mephimemo.cls | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/genpdf/genpdf2.php b/genpdf/genpdf2.php index 3592f16..54e37a4 100644 --- a/genpdf/genpdf2.php +++ b/genpdf/genpdf2.php @@ -243,41 +243,47 @@ switch ($file) { } } - $unitName = '_________________'; - $unitHead = '_________________'; - if (!empty($a['ChiefName'])) { - //$unitHeadFullname = $curUnit['ChiefName']; - $unitName = mb_strtoupper(chop($a['Podr_BriefName'])).' ['.$a['Code'].']'; - $unitHeadFullname = preg_replace('/[ ][ ]+/', ' ', chop(str_replace(array('и.о. ', 'и.о.'), array('', ''), preg_replace('/[0-9].*+/', '', chop($a['ChiefName']))))); + $curUnit = json_decode(file_get_contents('https://sd.mephi.ru/api/1/units.json?from_local_db=true&active_only=true&api_key='.SDAPI_KEY.'&filter_id='.preg_replace('/[^0-9]+/', '', $a['OrgDiv'])), 1)[0]; + + $unitCode = $curUnit['Code']; + while (substr($unitCode, strlen($unitCode)-2, 2) != '00') { + $curUnit = json_decode(file_get_contents('https://sd.mephi.ru/api/1/units.json?from_local_db=true&active_only=true&api_key='.SDAPI_KEY.'&filter_id='.preg_replace('/[^0-9]+/', '', $curUnit['ParentId'])), 1)[0]; + $unitCode = $curUnit['Code']; + if (empty($unitCode)) { + error_log('empty unitCode'); + break; + } + } + + $unitName = mb_strtoupper(chop($curUnit['BriefName'])).' ['.$curUnit['Code'].']'; + $unitHeadFullname = $curUnit['ChiefName']; + $unitHeadNameWords = split(' ', preg_replace('/[А-Я][.]/', '', $unitHeadFullname)); + $unitHeadLastname = $unitHeadNameWords[0]; + if (mb_strtoupper($a['SurName']) == mb_strtoupper($unitHeadLastname)) { + + $parentUnit = json_decode(file_get_contents('https://sd.mephi.ru/api/1/units.json?from_local_db=true&active_only=true&api_key='.SDAPI_KEY.'&filter_id='.preg_replace('/[^0-9]+/', '', $curUnit['ParentId'])), 1)[0]; + $unitName = mb_strtoupper(chop($parentUnit['BriefName'])).' ['.$parentUnit['Code'].']'; + $unitHeadFullname = $parentUnit['ChiefName']; $unitHeadNameWords = split(' ', preg_replace('/[А-Я][.]/', '', $unitHeadFullname)); $unitHeadLastname = $unitHeadNameWords[0]; - if (mb_strtoupper($a['SurName']) == mb_strtoupper($unitHeadLastname)) { - $curUnit = json_decode(file_get_contents('https://sd.mephi.ru/api/1/units.json?from_local_db=true&active_only=true&api_key='.SDAPI_KEY.'&filter_id='.preg_replace('/[^0-9]+/', '', $a['OrgDiv'])), 1)[0]; - - $parentUnit = json_decode(file_get_contents('https://sd.mephi.ru/api/1/units.json?from_local_db=true&active_only=true&api_key='.SDAPI_KEY.'&filter_id='.preg_replace('/[^0-9]+/', '', $curUnit['ParentId'])), 1)[0]; - $unitName = mb_strtoupper(chop($parentUnit['BriefName'])).' ['.$parentUnit['Code'].']'; - $unitHeadFullname = $parentUnit['ChiefName']; - $unitHeadNameWords = split(' ', preg_replace('/[А-Я][.]/', '', $unitHeadFullname)); - $unitHeadLastname = $unitHeadNameWords[0]; - } + } - if (count($unitHeadNameWords) != 3) { - $employeesByLastname = json_decode(file_get_contents('https://sd.mephi.ru/api/1/formulars.json?from_local_db=true&active_only=true&api_key='.SDAPI_KEY.'&filter_SurName='.preg_replace('/[^а-яА-Я]+/', '', $unitHeadLastname)), 1); - $fullnames = array(); - foreach ($employeesByLastname as $employee) { - $fullnames[$employee['SurName'].' '.$employee['FirstName'].' '.$employee['MiddleName']] = true; - } - if (count($fullnames) == 1) { - $unitHeadFullname = $fullnames[0]; - $unitHeadNameWords = split(' ', $unitHeadFullname); - } + if (count($unitHeadNameWords) != 3) { + $employeesByLastname = json_decode(file_get_contents('https://sd.mephi.ru/api/1/formulars.json?from_local_db=true&active_only=true&api_key='.SDAPI_KEY.'&filter_SurName='.preg_replace('/[^а-яА-Я]+/', '', $unitHeadLastname)), 1); + $fullnames = array(); + foreach ($employeesByLastname as $employee) { + $fullnames[$employee['SurName'].' '.$employee['FirstName'].' '.$employee['MiddleName']] = true; } - - if (count($unitHeadNameWords) == 3) { - $unitHead = $unitHeadNameWords[0].' '.mb_substr($unitHeadNameWords[1], 0, 1).'.'.mb_substr($unitHeadNameWords[2], 0, 1).'.'; + if (count($fullnames) == 1) { + $unitHeadFullname = $fullnames[0]; + $unitHeadNameWords = split(' ', $unitHeadFullname); } } + if (count($unitHeadNameWords) == 3) { + $unitHead = $unitHeadNameWords[0].' '.mb_substr($unitHeadNameWords[1], 0, 1).'.'.mb_substr($unitHeadNameWords[2], 0, 1).'.'; + } + $numberToWords = new NumberToWords(); $numberTransformer = $numberToWords->getNumberTransformer('ru'); @@ -288,9 +294,11 @@ switch ($file) { //$account = $themes[$a['Code']]['theme']; } + $prorector_appointment = json_decode(file_get_contents('https://voip.mephi.ru/appointments/'.$_GET['prorector-appointment-id'].'.json'), 1)['appointment_selected']; + return array( 'of-prorector' => '_________________', - 'prorector' => '_________________', + 'prorector' => $prorector_appointment['Subscriber']['Lastname'].' '.mb_substr($prorector_appointment['Subscriber']['Firstname'], 0, 1).'.'.mb_substr($prorector_appointment['Subscriber']['Patronymic'], 0, 1).'.', 'attorney-date' => '«___» __________ 20___г', 'attorney-code' => '_____________', @@ -306,8 +314,8 @@ switch ($file) { 'SalaryText' => $numberTransformer->toWords($salary).' рублей ноль копеек', 'MultiplyingFactor' => '______', 'MultiplyingFactorReason' => '_________________________________', - 'endDateWas' => formatDate($a['EndDate']), - 'endDateBecame' => $_GET['newEndDate'], + 'endDateWas' => @formatDate(@$a['EndDate']), + 'endDateBecame' => @$_GET['newEndDate'], 'account' => $account, 'account-manager' => $account_manager, 'change-date' => '«___» __________ 20___г', diff --git a/mephimemo/mephimemo.cls b/mephimemo/mephimemo.cls index 666fbd1..6c1d0b2 100644 --- a/mephimemo/mephimemo.cls +++ b/mephimemo/mephimemo.cls @@ -143,7 +143,7 @@ \vspace{-.5cm} - \par \fontsize{14pt}{14pt}\selectfont{НИЯУ МИФИ в лице #1, действующего на основании доверенности от #2, № #3, именуемый в дальнейшем «Работодатель», с одной стороны и #4, именуемый в дальнейшем «Работник», с другой стороны, пришли к соглашению о внесении в трудовой договор от #5 № #6 следующих дополнений и изменений с #7:} + \par \fontsize{13pt}{13pt}\selectfont{НИЯУ МИФИ в лице #1, действующего на основании доверенности от #2, № #3, именуемый в дальнейшем «Работодатель», с одной стороны и #4, именуемый в дальнейшем «Работник», с другой стороны, пришли к соглашению о внесении в трудовой договор от #5 № #6 следующих дополнений и изменений с #7:} } % memorandum footer (signatures) -- libgit2 0.24.0