xaionaro

updated

@@ -243,41 +243,47 @@ switch ($file) { @@ -243,41 +243,47 @@ switch ($file) {
243 } 243 }
244 } 244 }
245 245
246 - $unitName = '_________________'; 246 + $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];
247 - $unitHead = '_________________'; 247 +
248 - if (!empty($a['ChiefName'])) { 248 + $unitCode = $curUnit['Code'];
249 - //$unitHeadFullname = $curUnit['ChiefName']; 249 + while (substr($unitCode, strlen($unitCode)-2, 2) != '00') {
250 - $unitName = mb_strtoupper(chop($a['Podr_BriefName'])).' ['.$a['Code'].']'; 250 + $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];
251 - $unitHeadFullname = preg_replace('/[ ][ ]+/', ' ', chop(str_replace(array('и.о. ', 'и.о.'), array('', ''), preg_replace('/[0-9].*+/', '', chop($a['ChiefName']))))); 251 + $unitCode = $curUnit['Code'];
  252 + if (empty($unitCode)) {
  253 + error_log('empty unitCode');
  254 + break;
  255 + }
  256 + }
  257 +
  258 + $unitName = mb_strtoupper(chop($curUnit['BriefName'])).' ['.$curUnit['Code'].']';
  259 + $unitHeadFullname = $curUnit['ChiefName'];
  260 + $unitHeadNameWords = split(' ', preg_replace('/[А-Я][.]/', '', $unitHeadFullname));
  261 + $unitHeadLastname = $unitHeadNameWords[0];
  262 + if (mb_strtoupper($a['SurName']) == mb_strtoupper($unitHeadLastname)) {
  263 +
  264 + $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];
  265 + $unitName = mb_strtoupper(chop($parentUnit['BriefName'])).' ['.$parentUnit['Code'].']';
  266 + $unitHeadFullname = $parentUnit['ChiefName'];
252 $unitHeadNameWords = split(' ', preg_replace('/[А-Я][.]/', '', $unitHeadFullname)); 267 $unitHeadNameWords = split(' ', preg_replace('/[А-Я][.]/', '', $unitHeadFullname));
253 $unitHeadLastname = $unitHeadNameWords[0]; 268 $unitHeadLastname = $unitHeadNameWords[0];
254 - if (mb_strtoupper($a['SurName']) == mb_strtoupper($unitHeadLastname)) { 269 + }
255 - $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];  
256 -  
257 - $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];  
258 - $unitName = mb_strtoupper(chop($parentUnit['BriefName'])).' ['.$parentUnit['Code'].']';  
259 - $unitHeadFullname = $parentUnit['ChiefName'];  
260 - $unitHeadNameWords = split(' ', preg_replace('/[А-Я][.]/', '', $unitHeadFullname));  
261 - $unitHeadLastname = $unitHeadNameWords[0];  
262 - }  
263 270
264 - if (count($unitHeadNameWords) != 3) { 271 + if (count($unitHeadNameWords) != 3) {
265 - $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); 272 + $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);
266 - $fullnames = array(); 273 + $fullnames = array();
267 - foreach ($employeesByLastname as $employee) { 274 + foreach ($employeesByLastname as $employee) {
268 - $fullnames[$employee['SurName'].' '.$employee['FirstName'].' '.$employee['MiddleName']] = true; 275 + $fullnames[$employee['SurName'].' '.$employee['FirstName'].' '.$employee['MiddleName']] = true;
269 - }  
270 - if (count($fullnames) == 1) {  
271 - $unitHeadFullname = $fullnames[0];  
272 - $unitHeadNameWords = split(' ', $unitHeadFullname);  
273 - }  
274 } 276 }
275 - 277 + if (count($fullnames) == 1) {
276 - if (count($unitHeadNameWords) == 3) { 278 + $unitHeadFullname = $fullnames[0];
277 - $unitHead = $unitHeadNameWords[0].' '.mb_substr($unitHeadNameWords[1], 0, 1).'.'.mb_substr($unitHeadNameWords[2], 0, 1).'.'; 279 + $unitHeadNameWords = split(' ', $unitHeadFullname);
278 } 280 }
279 } 281 }
280 282
  283 + if (count($unitHeadNameWords) == 3) {
  284 + $unitHead = $unitHeadNameWords[0].' '.mb_substr($unitHeadNameWords[1], 0, 1).'.'.mb_substr($unitHeadNameWords[2], 0, 1).'.';
  285 + }
  286 +
281 $numberToWords = new NumberToWords(); 287 $numberToWords = new NumberToWords();
282 $numberTransformer = $numberToWords->getNumberTransformer('ru'); 288 $numberTransformer = $numberToWords->getNumberTransformer('ru');
283 289
@@ -288,9 +294,11 @@ switch ($file) { @@ -288,9 +294,11 @@ switch ($file) {
288 //$account = $themes[$a['Code']]['theme']; 294 //$account = $themes[$a['Code']]['theme'];
289 } 295 }
290 296
  297 + $prorector_appointment = json_decode(file_get_contents('https://voip.mephi.ru/appointments/'.$_GET['prorector-appointment-id'].'.json'), 1)['appointment_selected'];
  298 +
291 return array( 299 return array(
292 'of-prorector' => '_________________', 300 'of-prorector' => '_________________',
293 - 'prorector' => '_________________', 301 + 'prorector' => $prorector_appointment['Subscriber']['Lastname'].' '.mb_substr($prorector_appointment['Subscriber']['Firstname'], 0, 1).'.'.mb_substr($prorector_appointment['Subscriber']['Patronymic'], 0, 1).'.',
294 'attorney-date' => '«___» __________ 20___г', 302 'attorney-date' => '«___» __________ 20___г',
295 'attorney-code' => '_____________', 303 'attorney-code' => '_____________',
296 304
@@ -306,8 +314,8 @@ switch ($file) { @@ -306,8 +314,8 @@ switch ($file) {
306 'SalaryText' => $numberTransformer->toWords($salary).' рублей ноль копеек', 314 'SalaryText' => $numberTransformer->toWords($salary).' рублей ноль копеек',
307 'MultiplyingFactor' => '______', 315 'MultiplyingFactor' => '______',
308 'MultiplyingFactorReason' => '_________________________________', 316 'MultiplyingFactorReason' => '_________________________________',
309 - 'endDateWas' => formatDate($a['EndDate']), 317 + 'endDateWas' => @formatDate(@$a['EndDate']),
310 - 'endDateBecame' => $_GET['newEndDate'], 318 + 'endDateBecame' => @$_GET['newEndDate'],
311 'account' => $account, 319 'account' => $account,
312 'account-manager' => $account_manager, 320 'account-manager' => $account_manager,
313 'change-date' => '«___» __________ 20___г', 321 'change-date' => '«___» __________ 20___г',
@@ -143,7 +143,7 @@ @@ -143,7 +143,7 @@
143 143
144 \vspace{-.5cm} 144 \vspace{-.5cm}
145 145
146 - \par \fontsize{14pt}{14pt}\selectfont{НИЯУ МИФИ в лице #1, действующего на основании доверенности от #2, № #3, именуемый в дальнейшем «Работодатель», с одной стороны и #4, именуемый в дальнейшем «Работник», с другой стороны, пришли к соглашению о внесении в трудовой договор от #5 № #6 следующих дополнений и изменений с #7:} 146 + \par \fontsize{13pt}{13pt}\selectfont{НИЯУ МИФИ в лице #1, действующего на основании доверенности от #2, № #3, именуемый в дальнейшем «Работодатель», с одной стороны и #4, именуемый в дальнейшем «Работник», с другой стороны, пришли к соглашению о внесении в трудовой договор от #5 № #6 следующих дополнений и изменений с #7:}
147 } 147 }
148 148
149 % memorandum footer (signatures) 149 % memorandum footer (signatures)