Showing
1 changed file
with
47 additions
and
8 deletions
@@ -20,7 +20,7 @@ foreach(split("\n", file_get_contents("/tmp/gethashes")) as $request_hash_alread | @@ -20,7 +20,7 @@ foreach(split("\n", file_get_contents("/tmp/gethashes")) as $request_hash_alread | ||
20 | //die('Такой запрос уже был сгенерирован сегодня'); | 20 | //die('Такой запрос уже был сгенерирован сегодня'); |
21 | } | 21 | } |
22 | } | 22 | } |
23 | -file_put_contents("/tmp/gethashes", $GEThash."\n", FILE_APPEND|LOCK_EX); | 23 | +file_put_contents("/tmp/gethashes", $request_hash."\n", FILE_APPEND|LOCK_EX); |
24 | 24 | ||
25 | /* | 25 | /* |
26 | 26 | ||
@@ -137,6 +137,8 @@ function considerAppointment($key, &$appointment) { | @@ -137,6 +137,8 @@ function considerAppointment($key, &$appointment) { | ||
137 | $signer_subdivs = '['.$appointment->subdivision->s_code.'] '.mb_strtoupper($appointment->subdivision->shortname); | 137 | $signer_subdivs = '['.$appointment->subdivision->s_code.'] '.mb_strtoupper($appointment->subdivision->shortname); |
138 | $signer_subdivs_full = $appointment->subdivision->name; | 138 | $signer_subdivs_full = $appointment->subdivision->name; |
139 | 139 | ||
140 | + //error_log(serialize($appointment)); | ||
141 | + | ||
140 | $_GET[$key.'-appointment-id'] = $appointment->w_id; | 142 | $_GET[$key.'-appointment-id'] = $appointment->w_id; |
141 | $_GET[$key.'-fullname'] = $appointment->employee->fullname; | 143 | $_GET[$key.'-fullname'] = $appointment->employee->fullname; |
142 | $fullname_words = explode(' ', $_GET[$key.'-fullname']); | 144 | $fullname_words = explode(' ', $_GET[$key.'-fullname']); |
@@ -152,6 +154,28 @@ function considerAppointment($key, &$appointment) { | @@ -152,6 +154,28 @@ function considerAppointment($key, &$appointment) { | ||
152 | } | 154 | } |
153 | 155 | ||
154 | 156 | ||
157 | +function appointment_voip2cps($appointment_voip) { | ||
158 | + //if (!empty($_COOKIE['debug'])) { print_r($appointment_voip);die(); } | ||
159 | + | ||
160 | + $subscriber = $appointment_voip['Subscriber']; | ||
161 | + $unit = $appointment_voip['Unit']; | ||
162 | + | ||
163 | + @$employee->fullname = $subscriber['Lastname'].' '.$subscriber['Firstname'].' '.$subscriber['Patronymic']; | ||
164 | + | ||
165 | + @$subdivision->s_code = $unit['CodeStr']; | ||
166 | + @$subdivision->shortname = $unit['Shortname']; | ||
167 | + @$subdivision->name = $unit['Fullname']; | ||
168 | + | ||
169 | + | ||
170 | + @$appointment->w_id = $appointment_voip['StfCardId']; | ||
171 | + @$appointment->employee = $employee; | ||
172 | + @$appointment->subdivision = $subdivision; | ||
173 | + | ||
174 | + //if (!empty($_COOKIE['debug'])) { print_r($appointment);die(); } | ||
175 | + | ||
176 | + return $appointment; | ||
177 | +} | ||
178 | + | ||
155 | $_GET = array_merge ($_GET, $_POST); | 179 | $_GET = array_merge ($_GET, $_POST); |
156 | header( "Content-Type: text/plain" ); | 180 | header( "Content-Type: text/plain" ); |
157 | //print_r ($_GET); die(); | 181 | //print_r ($_GET); die(); |
@@ -164,7 +188,7 @@ if (isset($_GET['signer2user']) && empty($_GET['user-appointment-id'])) { | @@ -164,7 +188,7 @@ if (isset($_GET['signer2user']) && empty($_GET['user-appointment-id'])) { | ||
164 | $me = NULL; | 188 | $me = NULL; |
165 | 189 | ||
166 | $inflect = new Inflect(); | 190 | $inflect = new Inflect(); |
167 | -$redmine_admin = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); | 191 | +$redmine_admin = new Redmine\Client('http://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); |
168 | //$redmine_admin = new Redmine\Client('https://tasks.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); | 192 | //$redmine_admin = new Redmine\Client('https://tasks.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); |
169 | 193 | ||
170 | if (isset($_GET['signer-serialized'])) { | 194 | if (isset($_GET['signer-serialized'])) { |
@@ -202,7 +226,7 @@ if (isset($_GET['signer-serialized'])) { | @@ -202,7 +226,7 @@ if (isset($_GET['signer-serialized'])) { | ||
202 | @$user->employee = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getemployeeinfo&username=".urlencode($username_drupal) )); | 226 | @$user->employee = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getemployeeinfo&username=".urlencode($username_drupal) )); |
203 | @$user->oauth = $user_oauth; | 227 | @$user->oauth = $user_oauth; |
204 | @$user->login = $login; | 228 | @$user->login = $login; |
205 | - print_r($user); | 229 | + //print_r($user); |
206 | $_GET['signer-appointment-id'] = empty($_GET['force-appointment-id']) ? $user->employee->WORKPOSITIONS[0]->w_id : $_GET['force-appointment-id']; | 230 | $_GET['signer-appointment-id'] = empty($_GET['force-appointment-id']) ? $user->employee->WORKPOSITIONS[0]->w_id : $_GET['force-appointment-id']; |
207 | } | 231 | } |
208 | } | 232 | } |
@@ -242,7 +266,7 @@ if (isset($_GET['signer-serialized'])) { | @@ -242,7 +266,7 @@ if (isset($_GET['signer-serialized'])) { | ||
242 | $api_key = $user_redmine['user']['api_key']; | 266 | $api_key = $user_redmine['user']['api_key']; |
243 | 267 | ||
244 | // file_put_contents("/tmp/user", print_r($user_redmine)); die(); | 268 | // file_put_contents("/tmp/user", print_r($user_redmine)); die(); |
245 | - $redmine = new Redmine\Client('https://redmine.ut.mephi.ru', $api_key); | 269 | + $redmine = new Redmine\Client('http://redmine.ut.mephi.ru', $api_key); |
246 | 270 | ||
247 | $me = $redmine->api('user')->getCurrentUser()['user']; | 271 | $me = $redmine->api('user')->getCurrentUser()['user']; |
248 | } else { | 272 | } else { |
@@ -260,6 +284,8 @@ if (isset($_GET['subdiv-code'])) { | @@ -260,6 +284,8 @@ if (isset($_GET['subdiv-code'])) { | ||
260 | // print_r($_GET);die(); | 284 | // print_r($_GET);die(); |
261 | } | 285 | } |
262 | 286 | ||
287 | +//if (!empty($_COOKIE['debug'])) { print_r($_GET);die(); } | ||
288 | + | ||
263 | foreach (array('contact', 'user', 'recipient') as $key) { | 289 | foreach (array('contact', 'user', 'recipient') as $key) { |
264 | if (empty($_GET[$key.'-appointment-id'])) | 290 | if (empty($_GET[$key.'-appointment-id'])) |
265 | continue; | 291 | continue; |
@@ -270,7 +296,15 @@ foreach (array('contact', 'user', 'recipient') as $key) { | @@ -270,7 +296,15 @@ foreach (array('contact', 'user', 'recipient') as $key) { | ||
270 | 296 | ||
271 | $w_id = $_GET[$key.'-appointment-id']; | 297 | $w_id = $_GET[$key.'-appointment-id']; |
272 | 298 | ||
273 | - $appointment = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getworkpositioninfo&w_id=".urlencode($w_id) )); | 299 | + if ($w_id > 0) { |
300 | + error_log($w_id.": https://cps.mephi.ru/?cmd=getworkpositioninfo&w_id=".urlencode($w_id) ); | ||
301 | + $appointment = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getworkpositioninfo&w_id=".urlencode($w_id) )); | ||
302 | + } else { | ||
303 | + error_log($w_id.": https://voip.mephi.ru/appointments/".urlencode($w_id).".json?renderFilter=appointment_selected" ); | ||
304 | + $appointment_voip = json_decode(file_get_contents("https://voip.mephi.ru/appointments/".urlencode($w_id).".json?renderFilter=appointment_selected" ), 1)['appointment_selected']; | ||
305 | + | ||
306 | + $appointment = appointment_voip2cps($appointment_voip); | ||
307 | + } | ||
274 | 308 | ||
275 | considerAppointment($key, $appointment); | 309 | considerAppointment($key, $appointment); |
276 | } | 310 | } |
@@ -347,7 +381,7 @@ function error($str) { | @@ -347,7 +381,7 @@ function error($str) { | ||
347 | 381 | ||
348 | function latexSpecialChars( $string ) { | 382 | function latexSpecialChars( $string ) { |
349 | $string = str_replace("\\textbackslash", "\\", $string ); | 383 | $string = str_replace("\\textbackslash", "\\", $string ); |
350 | - $string = str_replace("\\", "\\textbackslash", $string ); | 384 | + $string = str_replace("\\", "\\textbackslash ", $string ); |
351 | 385 | ||
352 | $map = array( | 386 | $map = array( |
353 | "#"=>"\\#", | 387 | "#"=>"\\#", |
@@ -377,7 +411,7 @@ function latexSpecialChars1( $string ) | @@ -377,7 +411,7 @@ function latexSpecialChars1( $string ) | ||
377 | "~"=>"\\~{}", | 411 | "~"=>"\\~{}", |
378 | "_"=>"\\_", | 412 | "_"=>"\\_", |
379 | "^"=>"\\^{}", | 413 | "^"=>"\\^{}", |
380 | - "\\"=>"\\textbackslash", | 414 | + "\\"=>"\\textbackslash ", |
381 | "{"=>"\\{", | 415 | "{"=>"\\{", |
382 | "}"=>"\\}", | 416 | "}"=>"\\}", |
383 | ); | 417 | ); |
@@ -1259,7 +1293,7 @@ foreach ($files as $file) { | @@ -1259,7 +1293,7 @@ foreach ($files as $file) { | ||
1259 | default: | 1293 | default: |
1260 | $issue_props = | 1294 | $issue_props = |
1261 | array( | 1295 | array( |
1262 | - 'assigned_to_id' => USERID_EVVLASOV, | 1296 | + 'assigned_to_id' => USERID_DYOKUNEV, |
1263 | 'project_id' => $project_id, | 1297 | 'project_id' => $project_id, |
1264 | 'subject' => $memo_subject, | 1298 | 'subject' => $memo_subject, |
1265 | 'description' => $text, | 1299 | 'description' => $text, |
@@ -1366,6 +1400,11 @@ foreach ($files as $file) { | @@ -1366,6 +1400,11 @@ foreach ($files as $file) { | ||
1366 | exec('make'); | 1400 | exec('make'); |
1367 | $pdf_content = file_get_contents('memo.pdf'); | 1401 | $pdf_content = file_get_contents('memo.pdf'); |
1368 | 1402 | ||
1403 | + if ( empty($pdf_content) ) | ||
1404 | + { | ||
1405 | + error('Can not create pdf'); | ||
1406 | + } | ||
1407 | + | ||
1369 | $pdf_upload = json_decode( $redmine_admin->api('attachment')->upload($pdf_content) ); | 1408 | $pdf_upload = json_decode( $redmine_admin->api('attachment')->upload($pdf_content) ); |
1370 | error_log('upload:'.serialize($pdf_upload)); | 1409 | error_log('upload:'.serialize($pdf_upload)); |
1371 | 1410 |
-
Please register or login to post a comment