From b9b99bfdab8562551a5d9ef7b78624b989f23056 Mon Sep 17 00:00:00 2001 From: Dmitry Yu Okunev Date: Tue, 13 Dec 2016 13:59:23 +0300 Subject: [PATCH] bugfixes --- genpdf/genpdf.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/genpdf/genpdf.php b/genpdf/genpdf.php index f53dc8b..f2c6d15 100644 --- a/genpdf/genpdf.php +++ b/genpdf/genpdf.php @@ -20,7 +20,7 @@ foreach(split("\n", file_get_contents("/tmp/gethashes")) as $request_hash_alread //die('Такой запрос уже был сгенерирован сегодня'); } } -file_put_contents("/tmp/gethashes", $GEThash."\n", FILE_APPEND|LOCK_EX); +file_put_contents("/tmp/gethashes", $request_hash."\n", FILE_APPEND|LOCK_EX); /* @@ -137,6 +137,8 @@ function considerAppointment($key, &$appointment) { $signer_subdivs = '['.$appointment->subdivision->s_code.'] '.mb_strtoupper($appointment->subdivision->shortname); $signer_subdivs_full = $appointment->subdivision->name; + //error_log(serialize($appointment)); + $_GET[$key.'-appointment-id'] = $appointment->w_id; $_GET[$key.'-fullname'] = $appointment->employee->fullname; $fullname_words = explode(' ', $_GET[$key.'-fullname']); @@ -152,6 +154,28 @@ function considerAppointment($key, &$appointment) { } +function appointment_voip2cps($appointment_voip) { + //if (!empty($_COOKIE['debug'])) { print_r($appointment_voip);die(); } + + $subscriber = $appointment_voip['Subscriber']; + $unit = $appointment_voip['Unit']; + + @$employee->fullname = $subscriber['Lastname'].' '.$subscriber['Firstname'].' '.$subscriber['Patronymic']; + + @$subdivision->s_code = $unit['CodeStr']; + @$subdivision->shortname = $unit['Shortname']; + @$subdivision->name = $unit['Fullname']; + + + @$appointment->w_id = $appointment_voip['StfCardId']; + @$appointment->employee = $employee; + @$appointment->subdivision = $subdivision; + + //if (!empty($_COOKIE['debug'])) { print_r($appointment);die(); } + + return $appointment; +} + $_GET = array_merge ($_GET, $_POST); header( "Content-Type: text/plain" ); //print_r ($_GET); die(); @@ -164,7 +188,7 @@ if (isset($_GET['signer2user']) && empty($_GET['user-appointment-id'])) { $me = NULL; $inflect = new Inflect(); -$redmine_admin = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); +$redmine_admin = new Redmine\Client('http://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); //$redmine_admin = new Redmine\Client('https://tasks.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); if (isset($_GET['signer-serialized'])) { @@ -202,7 +226,7 @@ if (isset($_GET['signer-serialized'])) { @$user->employee = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getemployeeinfo&username=".urlencode($username_drupal) )); @$user->oauth = $user_oauth; @$user->login = $login; - print_r($user); + //print_r($user); $_GET['signer-appointment-id'] = empty($_GET['force-appointment-id']) ? $user->employee->WORKPOSITIONS[0]->w_id : $_GET['force-appointment-id']; } } @@ -242,7 +266,7 @@ if (isset($_GET['signer-serialized'])) { $api_key = $user_redmine['user']['api_key']; // file_put_contents("/tmp/user", print_r($user_redmine)); die(); - $redmine = new Redmine\Client('https://redmine.ut.mephi.ru', $api_key); + $redmine = new Redmine\Client('http://redmine.ut.mephi.ru', $api_key); $me = $redmine->api('user')->getCurrentUser()['user']; } else { @@ -260,6 +284,8 @@ if (isset($_GET['subdiv-code'])) { // print_r($_GET);die(); } +//if (!empty($_COOKIE['debug'])) { print_r($_GET);die(); } + foreach (array('contact', 'user', 'recipient') as $key) { if (empty($_GET[$key.'-appointment-id'])) continue; @@ -270,7 +296,15 @@ foreach (array('contact', 'user', 'recipient') as $key) { $w_id = $_GET[$key.'-appointment-id']; - $appointment = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getworkpositioninfo&w_id=".urlencode($w_id) )); + if ($w_id > 0) { + error_log($w_id.": https://cps.mephi.ru/?cmd=getworkpositioninfo&w_id=".urlencode($w_id) ); + $appointment = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getworkpositioninfo&w_id=".urlencode($w_id) )); + } else { + error_log($w_id.": https://voip.mephi.ru/appointments/".urlencode($w_id).".json?renderFilter=appointment_selected" ); + $appointment_voip = json_decode(file_get_contents("https://voip.mephi.ru/appointments/".urlencode($w_id).".json?renderFilter=appointment_selected" ), 1)['appointment_selected']; + + $appointment = appointment_voip2cps($appointment_voip); + } considerAppointment($key, $appointment); } @@ -347,7 +381,7 @@ function error($str) { function latexSpecialChars( $string ) { $string = str_replace("\\textbackslash", "\\", $string ); - $string = str_replace("\\", "\\textbackslash", $string ); + $string = str_replace("\\", "\\textbackslash ", $string ); $map = array( "#"=>"\\#", @@ -377,7 +411,7 @@ function latexSpecialChars1( $string ) "~"=>"\\~{}", "_"=>"\\_", "^"=>"\\^{}", - "\\"=>"\\textbackslash", + "\\"=>"\\textbackslash ", "{"=>"\\{", "}"=>"\\}", ); @@ -1259,7 +1293,7 @@ foreach ($files as $file) { default: $issue_props = array( - 'assigned_to_id' => USERID_EVVLASOV, + 'assigned_to_id' => USERID_DYOKUNEV, 'project_id' => $project_id, 'subject' => $memo_subject, 'description' => $text, @@ -1366,6 +1400,11 @@ foreach ($files as $file) { exec('make'); $pdf_content = file_get_contents('memo.pdf'); + if ( empty($pdf_content) ) + { + error('Can not create pdf'); + } + $pdf_upload = json_decode( $redmine_admin->api('attachment')->upload($pdf_content) ); error_log('upload:'.serialize($pdf_upload)); -- libgit2 0.24.0