diff --git a/modules/visa/batch/batch_tools.php b/modules/visa/batch/batch_tools.php index 379a1994280211fcdaf7398dc872f5795ff39689..a940a2d0407dc0e6a7d185eebc58b7735afc4fa8 100755 --- a/modules/visa/batch/batch_tools.php +++ b/modules/visa/batch/batch_tools.php @@ -176,7 +176,23 @@ function Bt_createAttachment($aArgs = []) "status" => 'TRA' ]; - // TODO curl storeResource + $opts = [ + CURLOPT_URL => $GLOBALS['applicationUrl'] . 'rest/res', + CURLOPT_HTTPHEADER => [ + 'accept:application/json', + 'content-type:application/json' + ], + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => 'Authorization: Basic ' . base64_encode($GLOBALS['userWS']. ':' .$GLOBALS['passwordWS']), + CURLOPT_POSTFIELDS => json_encode($allDatas), + CURLOPT_POST => true + ]; + + $curl = curl_init(); + curl_setopt_array($curl, $opts); + $rawResponse = curl_exec($curl); + + return json_decode($rawResponse, true); } function Bt_refusedSignedMail($aArgs = []) diff --git a/modules/visa/batch/config/config.xml.default b/modules/visa/batch/config/config.xml.default index d3da49a0cb2f0924ff27641c5d625ead743fc8ce..4c16cdaa720daee5e06bf2b3954c71fa719b8e6d 100755 --- a/modules/visa/batch/config/config.xml.default +++ b/modules/visa/batch/config/config.xml.default @@ -5,6 +5,9 @@ <CustomId>cs_maarch_v2</CustomId> <validatedStatus>VAL</validatedStatus> <refusedStatus>COU</refusedStatus> + <applicationUrl>http://localhost/maarch_v2/</applicationUrl> + <userWS>superadmin</userWS> + <passwordWS>superadmin</passwordWS> </CONFIG> <LOG4PHP> <enabled>true</enabled> diff --git a/modules/visa/batch/process_mailsFromSignatoryBook.php b/modules/visa/batch/process_mailsFromSignatoryBook.php index df81ab126809c257cd80e83ac6e3d2e494ef8ad7..f0355cc14f4fb18697c9ff37c2bc584c34157f7c 100755 --- a/modules/visa/batch/process_mailsFromSignatoryBook.php +++ b/modules/visa/batch/process_mailsFromSignatoryBook.php @@ -121,6 +121,9 @@ $config = $xmlconfig->CONFIG; $GLOBALS['MaarchDirectory'] = $_SESSION['config']['corepath'] = (string)$config->MaarchDirectory; $_SESSION['config']['app_id'] = 'maarch_entreprise'; $GLOBALS['CustomId'] = $_SESSION['custom_override_id'] = (string)$config->CustomId; +$GLOBALS['applicationUrl'] = (string)$config->applicationUrl; +$GLOBALS['userWS'] = (string)$config->userWS; +$GLOBALS['passwordWS'] = (string)$config->passwordWS; $GLOBALS['batchDirectory'] = $GLOBALS['MaarchDirectory'] . 'modules' . DIRECTORY_SEPARATOR . 'visa' . DIRECTORY_SEPARATOR . 'batch'; $validatedStatus = (string)$config->validatedStatus; $refusedStatus = (string)$config->refusedStatus; @@ -163,7 +166,7 @@ try { } } } else { - $GLOBALS['logger']->write($path . ' dfoes not exist', 'ERROR', 102); + $GLOBALS['logger']->write($path . ' does not exist', 'ERROR', 102); echo "\nConfiguration file ".$path." does not exist ! \nThe batch cannot be launched !\n\n"; exit(102); }