redmine

Added CustomForm [node165]

@@ -147,6 +147,7 @@ $me = NULL; @@ -147,6 +147,7 @@ $me = NULL;
147 147
148 $inflect = new Inflect(); 148 $inflect = new Inflect();
149 $redmine_admin = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD); 149 $redmine_admin = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD);
  150 +//$redmine_admin = new Redmine\Client('https://tasks.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD);
150 151
151 if (isset($_GET['signer-serialized'])) { 152 if (isset($_GET['signer-serialized'])) {
152 $user_serialized = base64_decode($_GET['signer-serialized']); 153 $user_serialized = base64_decode($_GET['signer-serialized']);
@@ -183,7 +184,8 @@ if (isset($_GET['signer-serialized'])) { @@ -183,7 +184,8 @@ if (isset($_GET['signer-serialized'])) {
183 @$user->employee = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getemployeeinfo&username=".urlencode($username_drupal) )); 184 @$user->employee = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getemployeeinfo&username=".urlencode($username_drupal) ));
184 @$user->oauth = $user_oauth; 185 @$user->oauth = $user_oauth;
185 @$user->login = $login; 186 @$user->login = $login;
186 - $_GET['signer-appointment-id'] = $user->employee->WORKPOSITIONS[0]->w_id; 187 + print_r($user);
  188 + $_GET['signer-appointment-id'] = empty($_GET['force-appointment-id']) ? $user->employee->WORKPOSITIONS[0]->w_id : $_GET['force-appointment_id'];
187 } 189 }
188 } 190 }
189 191
@@ -722,6 +724,10 @@ foreach ($files as $file) { @@ -722,6 +724,10 @@ foreach ($files as $file) {
722 } 724 }
723 725
724 break; 726 break;
  727 + case 'request/customform':
  728 + $project_id = 15905;
  729 + $memo_subject = 'Заявка на доступ к ИТ-услуге «Конструктор веб-форм» НИЯУ МИФИ';
  730 + break;
725 case 'request/itsupport': 731 case 'request/itsupport':
726 $project_id = 121; 732 $project_id = 121;
727 $memo_subject = 'Заявка в службу технической поддержки'; 733 $memo_subject = 'Заявка в службу технической поддержки';
@@ -855,6 +861,7 @@ foreach ($files as $file) { @@ -855,6 +861,7 @@ foreach ($files as $file) {
855 case 'request/voip3': 861 case 'request/voip3':
856 case 'request/cps': 862 case 'request/cps':
857 case 'request/php': 863 case 'request/php':
  864 + case 'request/customform':
858 if (empty($_GET['subdiv-code'])) { 865 if (empty($_GET['subdiv-code'])) {
859 if (!empty($_SERVER['HTTP_REFERER'])) { 866 if (!empty($_SERVER['HTTP_REFERER'])) {
860 header('Location: '.$_SERVER['HTTP_REFERER'].'?errmsg='.urlencode('Не указан код подразделения')); 867 header('Location: '.$_SERVER['HTTP_REFERER'].'?errmsg='.urlencode('Не указан код подразделения'));
@@ -989,7 +996,7 @@ foreach ($files as $file) { @@ -989,7 +996,7 @@ foreach ($files as $file) {
989 996
990 default: 997 default:
991 $header = '\mmheader{Начальнику управления информатизации}{Н. Н. Романову}'; 998 $header = '\mmheader{Начальнику управления информатизации}{Н. Н. Романову}';
992 - $footer = '\mmfooter{'.my_mb_ucfirst($_GET['signer-appointment']).'}{'.$_GET{'signer-name'}.'}{}{}'; 999 + $footer = '\mmfooter{'.my_mb_ucfirst($_GET['signer-appointment']).'}{'.$_GET{'signer-name'}.'}{'.$_GET['current-date'].'}{}';
993 } 1000 }
994 file_put_contents('header.tex', $header); 1001 file_put_contents('header.tex', $header);
995 file_put_contents('body.tex', $body); 1002 file_put_contents('body.tex', $body);
@@ -1009,6 +1016,15 @@ foreach ($files as $file) { @@ -1009,6 +1016,15 @@ foreach ($files as $file) {
1009 unlink('memo.pdf'); 1016 unlink('memo.pdf');
1010 1017
1011 switch($file) { 1018 switch($file) {
  1019 + case 'request/customform':
  1020 + $issue_props =
  1021 + array(
  1022 + 'assigned_to_id' => USERID_KVMARTINOV,
  1023 + 'project_id' => $project_id,
  1024 + 'subject' => $memo_subject,
  1025 + 'description' => $text,
  1026 + );
  1027 + break;
1012 case 'request/php': 1028 case 'request/php':
1013 $issue_props = 1029 $issue_props =
1014 array( 1030 array(
@@ -1148,6 +1164,7 @@ foreach ($files as $file) { @@ -1148,6 +1164,7 @@ foreach ($files as $file) {
1148 case 'request/php': 1164 case 'request/php':
1149 case 'request/itsupport': 1165 case 'request/itsupport':
1150 case 'request/custom': 1166 case 'request/custom':
  1167 + case 'request/customform':
1151 break; 1168 break;
1152 default: 1169 default:
1153 file_put_contents('responsible.tex', '\mmresponsible{'.$_GET['contact-name'].'}{'.$_GET{'contact-phonenumber'}.'}{'.$_GET['contact-email'].'}'); 1170 file_put_contents('responsible.tex', '\mmresponsible{'.$_GET['contact-name'].'}{'.$_GET{'contact-phonenumber'}.'}{'.$_GET['contact-email'].'}');
@@ -1157,8 +1174,9 @@ foreach ($files as $file) { @@ -1157,8 +1174,9 @@ foreach ($files as $file) {
1157 $pdf_content = file_get_contents('memo.pdf'); 1174 $pdf_content = file_get_contents('memo.pdf');
1158 1175
1159 $pdf_upload = json_decode( $redmine_admin->api('attachment')->upload($pdf_content) ); 1176 $pdf_upload = json_decode( $redmine_admin->api('attachment')->upload($pdf_content) );
  1177 + error_log('upload:'.serialize($pdf_upload));
1160 1178
1161 - $redmine_admin->api('issue')->attach( 1179 + error_log('attach:'.serialize($redmine_admin->api('issue')->attach(
1162 $issue_id, 1180 $issue_id,
1163 array( 1181 array(
1164 'token' => $pdf_upload->upload->token, 1182 'token' => $pdf_upload->upload->token,
@@ -1166,7 +1184,7 @@ foreach ($files as $file) { @@ -1166,7 +1184,7 @@ foreach ($files as $file) {
1166 'description' => 'Служебная записка', 1184 'description' => 'Служебная записка',
1167 'content_type'=> 'application/pdf' 1185 'content_type'=> 'application/pdf'
1168 ) 1186 )
1169 - ); 1187 + )));
1170 1188
1171 if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) { 1189 if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) {
1172 system('convert -density 400 memo.pdf memo.png'); 1190 system('convert -density 400 memo.pdf memo.png');