diff --git a/apps/maarch_entreprise/actions/close_mail.php b/apps/maarch_entreprise/actions/close_mail.php index 7ba64faa509ade201748c4de76120628d6837c47..e06d9851e79ce6ab84245355a92feb556b16dbae 100755 --- a/apps/maarch_entreprise/actions/close_mail.php +++ b/apps/maarch_entreprise/actions/close_mail.php @@ -128,7 +128,7 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col foreach ($arr_id as $res_id) { $result .= $res_id.'#'; - \Resource\models\ResModel::updateExt(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?'], 'data' => [$res_id]]); + \Resource\models\ResModel::update(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?'], 'data' => [$res_id]]); # save note if ($formValues['note_content_to_users'] != '') { diff --git a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php index caa85487d1d461f02943dcbcab1a4fcc61111577..189e6e7bd046e41adcdc1b445c35fe9f9f7b0635 100755 --- a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php +++ b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php @@ -354,7 +354,7 @@ function hasAttachmentError() 'data' => [$resId, ['converted_pdf', 'print_folder', 'signed_response']] ]); if ($attachments[0]['nb'] == 0) { - $noAttachmentsResource = \Resource\models\ResModel::getExtById(['resId' => $resId, 'select' => ['alt_identifier']]); + $noAttachmentsResource = \Resource\models\ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier']]); $noAttachment[] = $noAttachmentsResource['alt_identifier']; } } diff --git a/modules/attachments/xml/config.xml b/modules/attachments/xml/config.xml index 342909b790d76000bfc494082028ca5b87443e03..3b0fbbec183dfed94d40187e822210f3ecdd1a8a 100755 --- a/modules/attachments/xml/config.xml +++ b/modules/attachments/xml/config.xml @@ -25,14 +25,4 @@ <attachdel>true</attachdel> <attachview>true</attachview> </HISTORY> - <RECONCILIATION> - <CONFIG> - <name>reconciliation</name> - <comment>_RECONCILIATION_COMMENT</comment> - <multiple_res_id>true</multiple_res_id> <!-- Setting allowing, or not, the reconciliation of an attachment to multiple documents --> - <attach_to_empty>true</attach_to_empty> <!-- Setting allowing, or not, the reconciliation of an attachment to a document without response project --> - <delete_response_project>true</delete_response_project> <!-- Setting allowing, or not, the automatic deletion of the response project, thanks to his chrono number --> - <close_incoming>true</close_incoming> <!-- Setting allowing, or not, the possibility to close the incoming document, with a radio button--> - </CONFIG> - </RECONCILIATION> </root> diff --git a/modules/sendmail/Controllers/ReceiveMessageExchangeController.php b/modules/sendmail/Controllers/ReceiveMessageExchangeController.php index 61ab5d14b5636ac33a7305279dff41baca72f57e..cf62c1ddcd9d2f6b2e743c4f93e6dd4dca59ac6f 100755 --- a/modules/sendmail/Controllers/ReceiveMessageExchangeController.php +++ b/modules/sendmail/Controllers/ReceiveMessageExchangeController.php @@ -338,6 +338,7 @@ class ReceiveMessageExchangeController array_push($dataValue, ['column' => 'admission_date', 'value' => 'CURRENT_TIMESTAMP', 'type' => 'date']); $formatedData = StoreController::prepareExtStorage(['resId' => $aArgs['resId'], 'data' => $dataValue]); + //mlb_coll_ext $return = ResModel::createExt($formatedData); return $return; diff --git a/modules/sendmail/Controllers/SendMessageExchangeController.php b/modules/sendmail/Controllers/SendMessageExchangeController.php index a2509ea55b9bb6f985d4cb40f43765b4626238bc..1b4ec36f879497e0129f5f710d9a02d2321f37c6 100755 --- a/modules/sendmail/Controllers/SendMessageExchangeController.php +++ b/modules/sendmail/Controllers/SendMessageExchangeController.php @@ -26,7 +26,7 @@ class SendMessageExchangeController if (!empty($errors)) { return ['errors' => $errors]; } - $mlbCollExt = Resource\models\ResModel::getExtById(['resId' => $aArgs['identifier']]); + $mlbCollExt = Resource\models\ResModel::getById(['resId' => $aArgs['identifier']]); if (empty($mlbCollExt)) { return ['errors' => "wrong identifier"]; } diff --git a/modules/visa/class/IParapheurController.php b/modules/visa/class/IParapheurController.php index 7acb32cac096a096be1ff32f4f5e17375f805f92..e7dca2007340e47744546f63353e6fdc690f42d6 100755 --- a/modules/visa/class/IParapheurController.php +++ b/modules/visa/class/IParapheurController.php @@ -110,7 +110,7 @@ class IParapheurController $dossierId = $attachments[$i]['res_id'] . '_' . rand(0001, 9999); $dossierTitre = _PROJECT_NUMBER . $attachments[$i]['res_id']; - $mainResource = \Resource\models\ResModel::getExtById(['resId' => $aArgs['resIdMaster'], 'select' => ['process_limit_date']]); + $mainResource = \Resource\models\ResModel::getById(['resId' => $aArgs['resIdMaster'], 'select' => ['process_limit_date']]); if (empty($mainResource['process_limit_date'])) { $processLimitDate = $mainResource['process_limit_date'] = date('Y-m-d', strtotime(date("Y-m-d"). ' + 14 days')); } else { diff --git a/modules/visa/class/IxbusController.php b/modules/visa/class/IxbusController.php index dd0fd48eb9b90d81ffb05ba299adc36489337628..f8f9bb849666ec99c01d60d8074d8ec9115208dc 100755 --- a/modules/visa/class/IxbusController.php +++ b/modules/visa/class/IxbusController.php @@ -300,7 +300,7 @@ class IxbusController $encodedZipFile = IxbusController::createZip(['filepath' => $filePath, 'filename' => $adrInfo['filename'], 'res_id_master' => $aArgs['resIdMaster']]); - $mainResource = \Resource\models\ResModel::getExtById(['resId' => $aArgs['resIdMaster'], 'select' => ['process_limit_date']]); + $mainResource = \Resource\models\ResModel::getById(['resId' => $aArgs['resIdMaster'], 'select' => ['process_limit_date']]); if (empty($mainResource['process_limit_date'])) { $processLimitDate = date('Y-m-d', strtotime(date("Y-m-d"). ' + 14 days')); } else { diff --git a/rest/index.php b/rest/index.php index 439847966119ff1a789a80ac078986373566105f..a45874f1184ac6ba330b0a0fbc7760b5a40e89f9 100755 --- a/rest/index.php +++ b/rest/index.php @@ -302,8 +302,6 @@ $app->put('/reports/groups/{groupId}', \Report\controllers\ReportController::cla //Resources $app->post('/resources', \Resource\controllers\ResController::class . ':create'); -$app->post('/res', \Resource\controllers\ResController::class . ':createRes'); -$app->post('/resExt', \Resource\controllers\ResController::class . ':createExt'); $app->get('/res/{resId}/content', \Resource\controllers\ResController::class . ':getFileContent'); $app->get('/resources/{resId}/originalContent', \Resource\controllers\ResController::class . ':getOriginalFileContent'); $app->get('/res/{resId}/thumbnail', \Resource\controllers\ResController::class . ':getThumbnailContent'); diff --git a/src/app/action/controllers/AcknowledgementReceiptTrait.php b/src/app/action/controllers/AcknowledgementReceiptTrait.php index 7a69b8deb21b277f0ce3128d6ace60ebc4860967..883879f30404647a26d19fa321f75e44ea5d87b9 100644 --- a/src/app/action/controllers/AcknowledgementReceiptTrait.php +++ b/src/app/action/controllers/AcknowledgementReceiptTrait.php @@ -35,13 +35,13 @@ trait AcknowledgementReceiptTrait ValidatorModel::notEmpty($aArgs, ['resId']); ValidatorModel::intVal($aArgs, ['resId']); - $ext = ResModel::getExtById(['select' => ['category_id', 'address_id', 'is_multicontacts'], 'resId' => $aArgs['resId']]); - if (empty($ext) || $ext['category_id'] != 'incoming') { + $resource = ResModel::getById(['select' => ['type_id', 'destination', 'subject', 'category_id', 'address_id', 'is_multicontacts'], 'resId' => $aArgs['resId']]); + if (empty($resource) || $resource['category_id'] != 'incoming') { return []; } $contactsToProcess = []; - if ($ext['is_multicontacts'] == 'Y') { + if ($resource['is_multicontacts'] == 'Y') { $multiContacts = DatabaseModel::select([ 'select' => ['address_id'], 'table' => ['contacts_res'], @@ -52,7 +52,7 @@ trait AcknowledgementReceiptTrait $contactsToProcess[] = $multiContact['address_id']; } } else { - $contactsToProcess[] = $ext['address_id']; + $contactsToProcess[] = $resource['address_id']; } foreach ($contactsToProcess as $contactToProcess) { @@ -61,7 +61,6 @@ trait AcknowledgementReceiptTrait } } - $resource = ResModel::getById(['select' => ['type_id', 'destination', 'subject'], 'resId' => $aArgs['resId']]); $doctype = DoctypeModel::getById(['id' => $resource['type_id'], 'select' => ['process_mode']]); if ($doctype['process_mode'] == 'SVA') { diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index a7d802226ea0ee114f878bec74a77e5a6cfc0065..f20741db412e688a081c53ebc06257b36b48f4f8 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -101,7 +101,7 @@ class ActionMethodController ValidatorModel::intVal($aArgs, ['resId']); ValidatorModel::stringType($aArgs, ['note']); - ResModel::updateExt(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?', 'closing_date is null'], 'data' => [$aArgs['resId']]]); + ResModel::update(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?', 'closing_date is null'], 'data' => [$aArgs['resId']]]); if (CurlModel::isEnabled(['curlCallId' => 'closeResource'])) { $bodyData = []; @@ -161,7 +161,7 @@ class ActionMethodController ValidatorModel::notEmpty($aArgs, ['resId']); ValidatorModel::intVal($aArgs, ['resId']); - ResModel::updateExt(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?', 'closing_date is null'], 'data' => [$aArgs['resId']]]); + ResModel::update(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?', 'closing_date is null'], 'data' => [$aArgs['resId']]]); return true; } diff --git a/src/app/action/controllers/ExternalSignatoryBookTrait.php b/src/app/action/controllers/ExternalSignatoryBookTrait.php index d808bb1f2f828babe8da6db8f2d0dcae5309e598..ad7f76dfeea2436447855cbb55a3f0a6444d03cd 100644 --- a/src/app/action/controllers/ExternalSignatoryBookTrait.php +++ b/src/app/action/controllers/ExternalSignatoryBookTrait.php @@ -53,7 +53,7 @@ trait ExternalSignatoryBookTrait 'data' => [$args['resId'], ['converted_pdf', 'print_folder', 'signed_response']] ]); if ($attachments[0]['nb'] == 0 && $args['data']['objectSent'] == 'attachment') { - $noAttachmentsResource = ResModel::getExtById(['resId' => $args['resId'], 'select' => ['alt_identifier']]); + $noAttachmentsResource = ResModel::getById(['resId' => $args['resId'], 'select' => ['alt_identifier']]); return ['errors' => ['No attachment for this mail : ' . $noAttachmentsResource['alt_identifier']]]; } @@ -80,7 +80,7 @@ trait ExternalSignatoryBookTrait 'data' => [$args['resId'], ['converted_pdf', 'print_folder', 'signed_response']] ]); if ($attachments[0]['nb'] == 0) { - $noAttachmentsResource = ResModel::getExtById(['resId' => $args['resId'], 'select' => ['alt_identifier']]); + $noAttachmentsResource = ResModel::getById(['resId' => $args['resId'], 'select' => ['alt_identifier']]); return ['errors' => ['No attachment for this mail : ' . $noAttachmentsResource['alt_identifier']]]; } diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index 2be8e5c632e037fd3d8fec9d6503f79f8452f0e9..9ee918165ca5a9bea9dcf93d0f0d8aefff8a402c 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -206,33 +206,31 @@ class PreProcessActionController $data['resources'] = $resourcesForProcess; foreach ($data['resources'] as $resId) { - $ext = ResModel::getExtById(['select' => ['res_id', 'category_id', 'address_id', 'is_multicontacts', 'alt_identifier'], 'resId' => $resId]); + $resource = ResModel::getById(['select' => ['res_id', 'category_id', 'address_id', 'is_multicontacts', 'alt_identifier', 'type_id', 'destination'], 'resId' => $resId]); - if (empty($ext)) { + if (empty($resource)) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _DOCUMENT_NOT_FOUND ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => '', 'info' => _DOCUMENT_NOT_FOUND ]; continue; } if (!ResController::hasRightByResId(['resId' => [$resId], 'userId' => $GLOBALS['id']])) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _DOCUMENT_OUT_PERIMETER ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _DOCUMENT_OUT_PERIMETER ]; continue; } - if ($ext['category_id'] != 'incoming') { + if ($resource['category_id'] != 'incoming') { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _NOT_INCOMING_CATEGORY ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _NOT_INCOMING_CATEGORY ]; continue; } - //Verify template - $resource = ResModel::getById(['select' => ['type_id', 'destination'], 'resId' => $resId]); $doctype = DoctypeModel::getById(['id' => $resource['type_id'], 'select' => ['process_mode']]); if (empty($resource['destination'])) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _NO_ENTITY]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _NO_ENTITY]; continue; } @@ -254,7 +252,7 @@ class PreProcessActionController if (empty($template[0])) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _NO_TEMPLATE . ' \'' . $templateAttachmentType . '\' ' . _FOR_ENTITY . ' ' .$entity['entity_label'] ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _NO_TEMPLATE . ' \'' . $templateAttachmentType . '\' ' . _FOR_ENTITY . ' ' .$entity['entity_label'] ]; continue; } @@ -282,18 +280,18 @@ class PreProcessActionController if ($sended > 0) { $alreadySend['number'] += $sended; - $alreadySend['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier']]; + $alreadySend['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier']]; } if ($generated > 0) { $alreadyGenerated['number'] += $generated; - $alreadyGenerated['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier']]; + $alreadyGenerated['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier']]; } } //Verify associated contact $contactsToProcess = []; - if ($ext['is_multicontacts'] == 'Y') { + if ($resource['is_multicontacts'] == 'Y') { $multiContacts = DatabaseModel::select([ 'select' => ['address_id'], 'table' => ['contacts_res'], @@ -304,11 +302,11 @@ class PreProcessActionController $contactsToProcess[] = $multiContact['address_id']; } } else { - $contactsToProcess[] = $ext['address_id']; + $contactsToProcess[] = $resource['address_id']; } if (empty($contactsToProcess)) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _NO_CONTACT ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _NO_CONTACT ]; continue; } @@ -318,7 +316,7 @@ class PreProcessActionController foreach ($contactsToProcess as $contactToProcess) { if (empty($contactToProcess)) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _NO_CONTACT ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _NO_CONTACT ]; continue 2; } @@ -326,14 +324,14 @@ class PreProcessActionController if (empty($contact['email']) && (empty($contact['address_street']) || empty($contact['address_town']) || empty($contact['address_postal_code']))) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _USER_MISSING_INFORMATIONS ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _USER_MISSING_INFORMATIONS ]; continue 2; } if (!empty($contact['email'])) { if (empty($template[0]['template_content'])) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _NO_EMAIL_TEMPLATE . ' \'' . $templateAttachmentType . '\' ' . _FOR_ENTITY . ' ' . $entity['entity_label'] ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _NO_EMAIL_TEMPLATE . ' \'' . $templateAttachmentType . '\' ' . _FOR_ENTITY . ' ' . $entity['entity_label'] ]; continue 2; } else { $email += 1; @@ -341,7 +339,7 @@ class PreProcessActionController } elseif (!empty($contact['address_street']) && !empty($contact['address_town']) && !empty($contact['address_postal_code'])) { if (!file_exists($pathToDocument) || !is_file($pathToDocument)) { $noSendAR['number'] += 1; - $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $ext['alt_identifier'], 'info' => _NO_PAPER_TEMPLATE . ' \'' . $templateAttachmentType . '\' ' . _FOR_ENTITY . ' ' . $entity['entity_label'] ]; + $noSendAR['list'][] = ['resId' => $resId, 'alt_identifier' => $resource['alt_identifier'], 'info' => _NO_PAPER_TEMPLATE . ' \'' . $templateAttachmentType . '\' ' . _FOR_ENTITY . ' ' . $entity['entity_label'] ]; continue 2; } else { $paper += 1; @@ -439,7 +437,7 @@ class PreProcessActionController } foreach ($data['resources'] as $resId) { - $noAttachmentsResource = ResModel::getExtById(['resId' => $resId, 'select' => ['alt_identifier']]); + $noAttachmentsResource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier']]); if (empty($noAttachmentsResource['alt_identifier'])) { $noAttachmentsResource['alt_identifier'] = _UNDEFINED; } @@ -497,7 +495,7 @@ class PreProcessActionController } foreach ($data['resources'] as $resId) { - $noAttachmentsResource = ResModel::getExtById(['resId' => $resId, 'select' => ['alt_identifier']]); + $noAttachmentsResource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier']]); if (empty($noAttachmentsResource['alt_identifier'])) { $noAttachmentsResource['alt_identifier'] = _UNDEFINED; } @@ -618,7 +616,7 @@ class PreProcessActionController } foreach ($data['resources'] as $resId) { - $noAttachmentsResource = ResModel::getExtById(['resId' => $resId, 'select' => ['alt_identifier']]); + $noAttachmentsResource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier']]); if (empty($noAttachmentsResource['alt_identifier'])) { $noAttachmentsResource['alt_identifier'] = _UNDEFINED; } @@ -748,33 +746,33 @@ class PreProcessActionController 'isVersion' => $isVersion ]); if (empty($convertedDocument['docserver_id'])) { - $resInfo = ResModel::getExtById(['select' => ['alt_identifier'], 'resId' => $valueResId]); + $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noAttachmentConversion', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; } if (empty($attachment['dest_address_id'])) { - $resInfo = ResModel::getExtById(['select' => ['alt_identifier'], 'resId' => $valueResId]); + $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noAttachmentContact', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; } $contact = ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$attachment['dest_address_id']]]); if (empty($contact[0])) { - $resInfo = ResModel::getExtById(['select' => ['alt_identifier'], 'resId' => $valueResId]); + $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noAttachmentContact', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; } if (!empty($contact[0]['address_country']) && strtoupper(trim($contact[0]['address_country'])) != 'FRANCE') { - $resInfo = ResModel::getExtById(['select' => ['alt_identifier'], 'resId' => $valueResId]); + $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noFranceContact', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; } $afnorAddress = ContactController::getContactAfnor($contact[0]); if ((empty($afnorAddress[1]) && empty($afnorAddress[2])) || empty($afnorAddress[6]) || !preg_match("/^\d{5}\s/", $afnorAddress[6])) { - $resInfo = ResModel::getExtById(['select' => ['alt_identifier'], 'resId' => $valueResId]); + $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'incompleteAddressForPostal', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; @@ -786,7 +784,7 @@ class PreProcessActionController } if (!$resIdFound) { - $resInfo = ResModel::getExtById(['select' => ['alt_identifier'], 'resId' => $valueResId]); + $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noAttachmentToSend']; } } diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index 7fabe2478f9b217633cb82cb90537cbc3e59104d..d843c16149cd80111eef7c9e55120ac41ecb083d 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -96,7 +96,7 @@ class AttachmentController $body['data'][] = ['column' => 'type_id', 'value' => '0']; $body['data'][] = ['column' => 'relation', 'value' => '1']; $body['fileFormat'] = $body['format']; - $resId = StoreController::storeResourceRes($body); + $resId = StoreController::storeAttachment($body); if (empty($resId) || !empty($resId['errors'])) { return $response->withStatus(500)->withJson(['errors' => '[AttachmentController create] ' . $resId['errors']]); @@ -669,7 +669,7 @@ class AttachmentController "status" => 'A_TRA' ]; - StoreController::storeResourceRes($allDatas); + StoreController::storeAttachment($allDatas); } AttachmentModel::update([ diff --git a/src/app/attachment/controllers/ReconciliationController.php b/src/app/attachment/controllers/ReconciliationController.php deleted file mode 100755 index 90d871c3bdf64220e0f83a871e949cda5ccb2eed..0000000000000000000000000000000000000000 --- a/src/app/attachment/controllers/ReconciliationController.php +++ /dev/null @@ -1,194 +0,0 @@ -<?php - -namespace Attachment\controllers; - -use Slim\Http\Request; -use Slim\Http\Response; -use Attachment\models\AttachmentModel; -use Resource\models\ResModel; -use Resource\controllers\ResController; -use Respect\Validation\Validator; -use History\controllers\HistoryController; -use Resource\controllers\StoreController; -use SrcCore\models\CoreConfigModel; - -class ReconciliationController -{ - public function create(Request $request, Response $response) - { - $data = $request->getParams(); - $check = Validator::notEmpty()->validate($data['encodedFile']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['chrono']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - $resId = ReconciliationController::getWs($data); - - if (empty($resId) || !empty($resId['errors'])) { - return $response->withStatus(500)->withJson(['errors' => '[ReconciliationController create] ' . $resId['errors']]); - } - - HistoryController::add([ - 'tableName' => 'res_attachments', - 'recordId' => $resId, - 'eventType' => 'ADD', - 'info' => _DOC_ADDED, - 'moduleId' => 'reconciliation', - 'eventId' => 'attachmentadd', - ]); - - return $response->withJson(['resId' => $resId]); - } - - public static function getWs($aArgs) - { - $identifier = $aArgs['chrono']; - $encodedContent = $aArgs['encodedFile']; - - $info = AttachmentModel::getOnView([ - 'select' => ['res_id', 'title', 'res_id_master', 'dest_contact_id', 'dest_address_id'], - 'where' => ['identifier = ?', "status IN ('A_TRA', 'NEW','TMP')"], - 'data' => [$identifier], - 'orderBy' => ['res_id DESC'] - ])[0]; - - if (!Validator::intVal()->validate($info['res_id_master']) || !ResController::hasRightByResId(['resId' => [$info['res_id_master']], 'userId' => $GLOBALS['id']])) { - return ['errors' => 'Document out of perimeter']; - } - - if (!$info) { - return ['errors' => 'No attachment']; - } - - $title = $info['title']; - $fileFormat = 'pdf'; - $attachment_type = 'outgoing_mail_signed'; - $collId = 'letterbox_coll'; - $res_id_master = $info['res_id_master']; - - $data = []; - - array_push( - $data, - array( - 'column' => 'title', - 'value' => $title, - 'type' => 'string', - ) - ); - array_push( - $data, - array( - 'column' => 'identifier', - 'value' => $identifier, - 'type' => 'string', - ) - ); - array_push( - $data, - array( - 'column' => 'attachment_type', - 'value' => $attachment_type, - 'type' => 'string', - ) - ); - array_push( - $data, - array( - 'column' => 'dest_contact_id', - 'value' => $info['dest_contact_id'], - 'type' => 'integer', - ) - ); - array_push( - $data, - array( - 'column' => 'dest_address_id', - 'value' => $info['dest_address_id'], - 'type' => 'integer', - ) - ); - array_push( - $data, - array( - 'column' => 'coll_id', - 'value' => $collId, - 'type' => 'integer', - ) - ); - - array_push( - $data, - array( - 'column' => 'res_id_master', - 'value' => $res_id_master, - 'type' => 'integer', - ) - ); - - $aArgs = [ - 'collId' => $collId, - 'table' => 'res_attachments', - 'encodedFile' => $encodedContent, - 'fileFormat' => $fileFormat, - 'data' => $data, - 'status' => 'TRA' - ]; - - $resId = StoreController::storeResourceRes($aArgs); - - // Suppression du projet de reponse - $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/attachments/xml/config.xml']); - if ($loadedXml) { - $reconciliationConfig = $loadedXml->RECONCILIATION->CONFIG; - $delete_response_project = $reconciliationConfig->delete_response_project; - $close_incoming = $reconciliationConfig->close_incoming; - - if ($delete_response_project == 'true') { - AttachmentModel::update([ - 'set' => ['status' => 'DEL'], - 'where' => ['res_id = ?'], - 'data' => [$info['res_id']], - ]); - } - - // Cloture du courrier entrant - if ($close_incoming == 'true') { - ResModel::update([ - 'set' => ['status' => 'END'], - 'where' => ['res_id = ?'], - 'data' => [$res_id_master], - ]); - } - } - - return $resId; - } - - public function checkAttachment(Request $request, Response $response) - { - $data = $request->getQueryParams(); - $check = Validator::stringType()->notEmpty()->validate($data['chrono']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - $attachment = AttachmentModel::getOnView([ - 'select' => ['res_id_master'], - 'where' => ['identifier = ?', "status IN ('A_TRA', 'NEW','TMP')"], - 'data' => [$data['chrono']], - 'orderBy' => ['res_id DESC'] - ])[0]; - - if (!Validator::intVal()->validate($attachment['res_id_master']) || !ResController::hasRightByResId(['resId' => [$attachment['res_id_master']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); - } - - if ($attachment == false) { - return $response->withStatus(500)->withJson(['errors' => '[ReconciliationController checkAttachment] ' . _NO_ATTACHMENT_CHRONO]); - } else { - return $response->withJson(array('result' => 'OK')); - } - } -} diff --git a/src/app/entity/models/ListInstanceModelAbstract.php b/src/app/entity/models/ListInstanceModelAbstract.php index 4fa57eae476a5dcfc2bd405eed3f91ec9d35c6d2..8d8f4f1880c912e596958dfc8fd88f9768f8025f 100755 --- a/src/app/entity/models/ListInstanceModelAbstract.php +++ b/src/app/entity/models/ListInstanceModelAbstract.php @@ -183,8 +183,8 @@ abstract class ListInstanceModelAbstract $aListInstances = DatabaseModel::select([ 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['listinstance, res_letterbox, mlb_coll_ext'], - 'where' => ['listinstance.res_id = res_letterbox.res_id', 'mlb_coll_ext.res_id = res_letterbox.res_id', 'confidentiality = ?', 'destination = ?', 'item_id = ?', 'closing_date is null'], + 'table' => ['listinstance, res_letterbox'], + 'where' => ['listinstance.res_id = res_letterbox.res_id', 'confidentiality = ?', 'destination = ?', 'item_id = ?', 'closing_date is null'], 'data' => ['Y', $aArgs['entityId'], $aArgs['userId']] ]); @@ -199,9 +199,9 @@ abstract class ListInstanceModelAbstract $listInstances = DatabaseModel::select([ 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['listinstance', 'res_letterbox', 'mlb_coll_ext'], - 'left_join' => ['listinstance.res_id = res_letterbox.res_id', 'res_letterbox.res_id = mlb_coll_ext.res_id'], - 'where' => ['listinstance.item_id = ?', 'listinstance.difflist_type = ?', 'listinstance.item_type = ?', 'listinstance.item_mode = ?', 'mlb_coll_ext.closing_date is null', 'res_letterbox.status != ?'], + 'table' => ['listinstance', 'res_letterbox'], + 'left_join' => ['listinstance.res_id = res_letterbox.res_id'], + 'where' => ['listinstance.item_id = ?', 'listinstance.difflist_type = ?', 'listinstance.item_type = ?', 'listinstance.item_mode = ?', 'res_letterbox.closing_date is null', 'res_letterbox.status != ?'], 'data' => [$aArgs['login'], 'entity_id', 'user_id', $aArgs['itemMode'], 'DEL'] ]); diff --git a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php index 8a9498ea0901c7cc52986a5acfe7a30ca8e3e14d..1fad4534795979363684a66a10a694a5a0ace14b 100755 --- a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php +++ b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php @@ -132,7 +132,7 @@ class MaarchParapheurController 'orderBy' => ['listinstance_id'] ]); } elseif ($unit['unit'] == 'senderRecipientInformations') { - $data['mlbCollExt'] = ResModel::getExt([ + $data['senderRecipient'] = ResModel::get([ 'select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts', 'res_id'], 'where' => ['res_id in (?)'], 'data' => [$tmpIds] diff --git a/src/app/folder/controllers/FolderController.php b/src/app/folder/controllers/FolderController.php index 4adf31db0c27f5834a70a945465429a8fcd77001..96996a8bd23639a8053bb774aa61ba7388769ad4 100755 --- a/src/app/folder/controllers/FolderController.php +++ b/src/app/folder/controllers/FolderController.php @@ -419,11 +419,11 @@ class FolderController ]); $select = [ - 'res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.barcode', 'mlb_coll_ext.alt_identifier', + 'res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.barcode', 'res_letterbox.alt_identifier', 'status.label_status AS "status.label_status"', 'status.img_filename AS "status.img_filename"', 'priorities.color AS "priorities.color"' ]; - $tableFunction = ['status', 'mlb_coll_ext', 'priorities']; - $leftJoinFunction = ['res_letterbox.status = status.id', 'res_letterbox.res_id = mlb_coll_ext.res_id', 'res_letterbox.priority = priorities.id']; + $tableFunction = ['status', 'priorities']; + $leftJoinFunction = ['res_letterbox.status = status.id', 'res_letterbox.priority = priorities.id']; $order = 'CASE res_letterbox.res_id '; foreach ($resIds as $key => $resId) { diff --git a/src/app/home/controllers/HomeController.php b/src/app/home/controllers/HomeController.php index eb352db4172d2c80aaa11de75e1f3f5320bbf5f8..8ef01f7feb1d98393cdea2e7bcba902779b7fee8 100755 --- a/src/app/home/controllers/HomeController.php +++ b/src/app/home/controllers/HomeController.php @@ -113,11 +113,11 @@ class HomeController { $lastResources = ResModel::getLastResources([ 'select' => [ - 'mlb.alt_identifier', - 'mlb.closing_date', + 'r.alt_identifier', + 'r.closing_date', 'r.creation_date', 'priorities.color as priority_color', - 'mlb.process_limit_date', + 'r.process_limit_date', 'r.res_id', 'r.confidentiality', 'status.img_filename as status_icon', diff --git a/src/app/resource/controllers/ExportController.php b/src/app/resource/controllers/ExportController.php index 3e60d0df0daf06bc4aaa62378b581325a1eae14e..507083d18027cfa706e74a40196831ad32043091 100644 --- a/src/app/resource/controllers/ExportController.php +++ b/src/app/resource/controllers/ExportController.php @@ -613,16 +613,16 @@ class ExportController } foreach ($args['chunkedResIds'] as $resIds) { - $exts = ResModel::getExt([ + $resources = ResModel::get([ 'select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts', 'res_id'], 'where' => ['res_id in (?)'], 'data' => [$resIds] ]); - if (!empty($exts)) { + if (!empty($resources)) { $resId = ''; $senders = []; - foreach ($exts as $key => $ext) { + foreach ($resources as $key => $ext) { if ($key != 0 && $resId != $ext['res_id']) { $aSenders[$resId] = $senders; $senders = []; @@ -698,16 +698,16 @@ class ExportController } foreach ($args['chunkedResIds'] as $resIds) { - $exts = ResModel::getExt([ + $resources = ResModel::get([ 'select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts', 'res_id'], 'where' => ['res_id in (?)'], 'data' => [$resIds] ]); - if (!empty($exts)) { + if (!empty($resources)) { $resId = ''; $recipients = []; - foreach ($exts as $key => $ext) { + foreach ($resources as $key => $ext) { if ($key != 0 && $resId != $ext['res_id']) { $aRecipients[$resId] = $recipients; $recipients = []; diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 81da74b3316c0a9be835876e3575a14428291e8f..91361f82630e6b8aab1cef8edeb44949cd7f2789 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -102,93 +102,6 @@ class ResController return $response->withJson(['resId' => $resId]); } - public function createRes(Request $request, Response $response) - { - if (!ServiceModel::hasService(['id' => 'index_mlb', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'menu'])) { - return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); - } - - $data = $request->getParams(); - - $check = Validator::notEmpty()->validate($data['encodedFile']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['fileFormat']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['status']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['collId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['table']); - $check = $check && Validator::arrayType()->notEmpty()->validate($data['data']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - $mandatoryColumns = []; - if ($data['table'] == 'res_letterbox') { - $mandatoryColumns[] = 'type_id'; - } - - foreach ($data['data'] as $value) { - foreach ($mandatoryColumns as $columnKey => $column) { - if ($column == $value['column'] && !empty($value['value'])) { - unset($mandatoryColumns[$columnKey]); - } - } - } - if (!empty($mandatoryColumns)) { - return $response->withStatus(400)->withJson(['errors' => 'Data array needs column(s) [' . implode(', ', $mandatoryColumns) . ']']); - } - - $resId = StoreController::storeResourceRes($data); - - if (empty($resId) || !empty($resId['errors'])) { - return $response->withStatus(500)->withJson(['errors' => '[ResController create] ' . $resId['errors']]); - } - - HistoryController::add([ - 'tableName' => 'res_letterbox', - 'recordId' => $resId, - 'eventType' => 'ADD', - 'info' => _DOC_ADDED, - 'moduleId' => 'res', - 'eventId' => 'resadd', - ]); - - return $response->withJson(['resId' => $resId]); - } - - public function createExt(Request $request, Response $response) - { - if (!ServiceModel::hasService(['id' => 'index_mlb', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'menu'])) { - return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); - } - - $data = $request->getParams(); - - $check = Validator::intVal()->notEmpty()->validate($data['resId']); - $check = $check && Validator::arrayType()->notEmpty()->validate($data['data']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - $document = ResModel::getById(['resId' => $data['resId'], 'select' => ['1']]); - if (empty($document)) { - return $response->withStatus(404)->withJson(['errors' => 'Document does not exist']); - } - $documentExt = ResModel::getExtById(['resId' => $data['resId'], 'select' => ['1']]); - if (!empty($documentExt)) { - return $response->withStatus(400)->withJson(['errors' => 'Document already exists in mlb_coll_ext']); - } - - $formatedData = StoreController::prepareExtStorage(['resId' => $data['resId'], 'data' => $data['data']]); - - $check = Validator::stringType()->notEmpty()->validate($formatedData['category_id']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - ResModel::createExt($formatedData); - - return $response->withJson(['status' => true]); - } - public function updateStatus(Request $request, Response $response) { $data = $request->getParams(); @@ -213,7 +126,7 @@ class ResController $identifiers = !empty($data['chrono']) ? $data['chrono'] : $data['resId']; foreach ($identifiers as $id) { if (!empty($data['chrono'])) { - $document = ResModel::getResIdByAltIdentifier(['altIdentifier' => $id]); + $document = ResModel::getByAltIdentifier(['altIdentifier' => $id, 'select' => ['res_id']]); } else { $document = ResModel::getById(['resId' => $id, 'select' => ['res_id']]); } @@ -245,13 +158,12 @@ class ResController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } - $document = ResModel::getById(['select' => ['docserver_id', 'path', 'filename', 'fingerprint'], 'resId' => $aArgs['resId']]); - $extDocument = ResModel::getExtById(['select' => ['category_id', 'alt_identifier'], 'resId' => $aArgs['resId']]); - if (empty($document) || empty($extDocument)) { + $document = ResModel::getById(['select' => ['docserver_id', 'path', 'filename', 'fingerprint', 'category_id', 'alt_identifier'], 'resId' => $aArgs['resId']]); + if (empty($document)) { return $response->withStatus(400)->withJson(['errors' => 'Document does not exist']); } - if ($extDocument['category_id'] == 'outgoing') { + if ($document['category_id'] == 'outgoing') { $attachment = AttachmentModel::getOnView([ 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename'], 'where' => ['res_id_master = ?', 'attachment_type = ?', 'status not in (?)'], @@ -321,7 +233,7 @@ class ResController } elseif ($value == 'hour_now') { $tmp = date('H:i'); } elseif ($value == 'alt_identifier') { - $tmp = $extDocument['alt_identifier']; + $tmp = $document['alt_identifier']; } else { $backFromView = ResModel::getOnView(['select' => $value, 'where' => ['res_id = ?'], 'data' => [$aArgs['resId']]]); if (!empty($backFromView[0][$value])) { @@ -409,13 +321,12 @@ class ResController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } - $document = ResModel::getById(['select' => ['docserver_id', 'path', 'filename'], 'resId' => $aArgs['resId']]); - $extDocument = ResModel::getExtById(['select' => ['category_id', 'alt_identifier'], 'resId' => $aArgs['resId']]); - if (empty($document) || empty($extDocument)) { + $document = ResModel::getById(['select' => ['docserver_id', 'path', 'filename', 'category_id'], 'resId' => $aArgs['resId']]); + if (empty($document)) { return $response->withStatus(400)->withJson(['errors' => 'Document does not exist']); } - if ($extDocument['category_id'] == 'outgoing') { + if ($document['category_id'] == 'outgoing') { $attachment = AttachmentModel::getOnView([ 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename', 'fingerprint'], 'where' => ['res_id_master = ?', 'attachment_type = ?', 'status not in (?)'], @@ -491,8 +402,8 @@ class ResController 'type' => 'TNL' ]); if (empty($tnlAdr)) { - $extDocument = ResModel::getExtById(['select' => ['category_id'], 'resId' => $aArgs['resId']]); - if ($extDocument['category_id'] == 'outgoing') { + $document = ResModel::getById(['select' => ['category_id'], 'resId' => $aArgs['resId']]); + if ($document['category_id'] == 'outgoing') { $attachment = AttachmentModel::getOnView([ 'select' => ['res_id', 'res_id_version'], 'where' => ['res_id_master = ?', 'attachment_type = ?', 'status not in (?)'], @@ -593,11 +504,10 @@ class ResController ValidatorModel::intVal($aArgs, ['resId']); ValidatorModel::boolType($aArgs, ['original']); - $document = ResModel::getById(['select' => ['docserver_id', 'path', 'filename', 'subject'], 'resId' => $aArgs['resId']]); - $extDocument = ResModel::getExtById(['select' => ['category_id'], 'resId' => $aArgs['resId']]); + $document = ResModel::getById(['select' => ['docserver_id', 'path', 'filename', 'subject', 'category_id'], 'resId' => $aArgs['resId']]); if (empty($aArgs['original'])) { - if ($extDocument['category_id'] == 'outgoing') { + if ($document['category_id'] == 'outgoing') { $attachment = AttachmentModel::getOnView([ 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename'], 'where' => ['res_id_master = ?', 'attachment_type = ?', 'status not in (?)'], diff --git a/src/app/resource/controllers/ResourceListController.php b/src/app/resource/controllers/ResourceListController.php index 1a7aae99d3bf05f0b6ece21101f411a8c422ea3e..c1798f29547b1fd800fdfe400db3448620b6797e 100644 --- a/src/app/resource/controllers/ResourceListController.php +++ b/src/app/resource/controllers/ResourceListController.php @@ -102,25 +102,25 @@ class ResourceListController $listDisplay = json_decode($groupBasket[0]['list_display']); $select = [ - 'res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.barcode', 'mlb_coll_ext.alt_identifier', + 'res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.barcode', 'res_letterbox.alt_identifier', 'status.label_status AS "status.label_status"', 'status.img_filename AS "status.img_filename"', 'priorities.color AS "priorities.color"', - 'mlb_coll_ext.closing_date', 'res_letterbox.locker_user_id', 'res_letterbox.locker_time', 'res_letterbox.confidentiality' + 'res_letterbox.closing_date', 'res_letterbox.locker_user_id', 'res_letterbox.locker_time', 'res_letterbox.confidentiality' ]; - $tableFunction = ['status', 'mlb_coll_ext', 'priorities']; - $leftJoinFunction = ['res_letterbox.status = status.id', 'res_letterbox.res_id = mlb_coll_ext.res_id', 'res_letterbox.priority = priorities.id']; + $tableFunction = ['status', 'priorities']; + $leftJoinFunction = ['res_letterbox.status = status.id', 'res_letterbox.priority = priorities.id']; foreach ($listDisplay as $value) { $value = (array)$value; if ($value['value'] == 'getPriority') { $select[] = 'priorities.label AS "priorities.label"'; } elseif ($value['value'] == 'getCategory') { - $select[] = 'mlb_coll_ext.category_id'; + $select[] = 'res_letterbox.category_id'; } elseif ($value['value'] == 'getDoctype') { $select[] = 'doctypes.description AS "doctypes.description"'; $tableFunction[] = 'doctypes'; $leftJoinFunction[] = 'res_letterbox.type_id = doctypes.type_id'; } elseif ($value['value'] == 'getCreationAndProcessLimitDates') { $select[] = 'res_letterbox.creation_date'; - $select[] = 'mlb_coll_ext.process_limit_date'; + $select[] = 'res_letterbox.process_limit_date'; } elseif ($value['value'] == 'getModificationDate') { $select[] = 'res_letterbox.modification_date'; } elseif ($value['value'] == 'getOpinionLimitDate') { @@ -669,18 +669,18 @@ class ResourceListController ValidatorModel::notEmpty($args, ['resId']); ValidatorModel::intVal($args, ['resId']); - $ext = ResModel::getExtById(['select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts'], 'resId' => $args['resId']]); + $resource = ResModel::getById(['select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts'], 'resId' => $args['resId']]); $senders = []; - if (!empty($ext)) { - if ($ext['category_id'] == 'outgoing') { + if (!empty($resource)) { + if ($resource['category_id'] == 'outgoing') { $resourcesContacts = ResourceContactModel::getFormattedByResId(['resId' => $args['resId']]); foreach ($resourcesContacts as $resourcesContact) { $senders[] = $resourcesContact['restrictedFormat']; } } else { $rawContacts = []; - if ($ext['is_multicontacts'] == 'Y') { + if ($resource['is_multicontacts'] == 'Y') { $multiContacts = DatabaseModel::select([ 'select' => ['contact_id', 'address_id'], 'table' => ['contacts_res'], @@ -695,8 +695,8 @@ class ResourceListController } } else { $rawContacts[] = [ - 'login' => $ext['exp_user_id'], - 'address_id' => $ext['address_id'], + 'login' => $resource['exp_user_id'], + 'address_id' => $resource['address_id'], ]; } foreach ($rawContacts as $rawContact) { @@ -725,13 +725,13 @@ class ResourceListController ValidatorModel::notEmpty($args, ['resId']); ValidatorModel::intVal($args, ['resId']); - $ext = ResModel::getExtById(['select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts'], 'resId' => $args['resId']]); + $resource = ResModel::getById(['select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts'], 'resId' => $args['resId']]); $recipients = []; - if (!empty($ext)) { - if ($ext['category_id'] == 'outgoing') { + if (!empty($resource)) { + if ($resource['category_id'] == 'outgoing') { $rawContacts = []; - if ($ext['is_multicontacts'] == 'Y') { + if ($resource['is_multicontacts'] == 'Y') { $multiContacts = DatabaseModel::select([ 'select' => ['contact_id', 'address_id'], 'table' => ['contacts_res'], @@ -746,8 +746,8 @@ class ResourceListController } } else { $rawContacts[] = [ - 'login' => $ext['dest_user_id'], - 'address_id' => $ext['address_id'], + 'login' => $resource['dest_user_id'], + 'address_id' => $resource['address_id'], ]; } foreach ($rawContacts as $rawContact) { diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php index 6cd276ca7cb4e4ea7fe4a76b1d89b77660876fa4..34bc70048b4eb22542f06a94077aa9fe0be0519d 100755 --- a/src/app/resource/controllers/StoreController.php +++ b/src/app/resource/controllers/StoreController.php @@ -36,10 +36,6 @@ class StoreController ValidatorModel::notEmpty($aArgs, ['encodedFile', 'format', 'status', 'type_id', 'category_id']); ValidatorModel::stringType($aArgs, ['format', 'status']); - $mlbColumns = [ - 'category_id', 'exp_contact_id', 'exp_user_id', 'dest_contact_id', 'dest_user_id', - 'nature_id', 'alt_identifier', 'admission_date', 'process_limit_date', 'closing_date', 'address_id' - ]; try { foreach ($aArgs as $column => $value) { if (empty($value)) { @@ -72,39 +68,25 @@ class StoreController $data = array_merge($aArgs, $data); $data = StoreController::prepareStorage($data); - $dataMlb = []; - foreach ($data as $key => $value) { - if (in_array($key, $mlbColumns)) { - $dataMlb[$key] = $value; - unset($data[$key]); - } - } ResModel::create($data); - $dataMlb['res_id'] = $resId; - ResModel::createExt($dataMlb); - return $resId; } catch (\Exception $e) { return ['errors' => '[storeResource] ' . $e->getMessage()]; } } - public static function storeResourceRes(array $aArgs) + public static function storeAttachment(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['encodedFile', 'data', 'collId', 'table', 'fileFormat', 'status']); ValidatorModel::stringType($aArgs, ['collId', 'table', 'fileFormat', 'status']); ValidatorModel::arrayType($aArgs, ['data']); - if (!in_array($aArgs['table'], ['res_letterbox', 'res_attachments', 'res_version_attachments'])) { - return ['errors' => '[storeResource] Table not valid']; - } - try { $fileContent = base64_decode(str_replace(['-', '_'], ['+', '/'], $aArgs['encodedFile'])); $storeResult = DocserverController::storeResourceOnDocServer([ - 'collId' => $aArgs['collId'], + 'collId' => empty($aArgs['version']) ? 'attachments_coll' : 'attachments_version_coll', 'docserverTypeId' => 'DOC', 'encodedResource' => base64_encode($fileContent), 'format' => $aArgs['fileFormat'] @@ -113,7 +95,7 @@ class StoreController return ['errors' => '[storeResource] ' . $storeResult['errors']]; } - $data = StoreController::prepareStorageRes([ + $data = StoreController::prepareAttachmentStorage([ 'data' => $aArgs['data'], 'docserverId' => $storeResult['docserver_id'], 'status' => $aArgs['status'], @@ -124,16 +106,13 @@ class StoreController 'fingerPrint' => $storeResult['fingerPrint'] ]); - $resId = false; - if ($aArgs['table'] == 'res_letterbox') { - $resId = ResModel::create($data); - } elseif ($aArgs['table'] == 'res_attachments') { - $resId = AttachmentModel::create($data); - } elseif ($aArgs['table'] == 'res_version_attachments') { - $resId = AttachmentModel::createVersion($data); + if (empty($aArgs['version'])) { + $id = AttachmentModel::create($data); + } else { + $id = AttachmentModel::createVersion($data); } - return $resId; + return $id; } catch (\Exception $e) { return ['errors' => '[storeResource] ' . $e->getMessage()]; } @@ -227,120 +206,17 @@ class StoreController return $aArgs; } - public static function prepareStorageRes(array $aArgs) + public static function prepareAttachmentStorage(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['data', 'docserverId', 'fileName', 'fileFormat', 'fileSize', 'path', 'fingerPrint']); ValidatorModel::stringType($aArgs, ['docserverId', 'status', 'fileName', 'fileFormat', 'path', 'fingerPrint']); ValidatorModel::arrayType($aArgs, ['data']); ValidatorModel::intVal($aArgs, ['fileSize']); - $statusFound = false; - $typistFound = false; - $toAddressFound = false; - $userPrimaryEntity = false; - foreach ($aArgs['data'] as $key => $value) { $aArgs['data'][$key]['column'] = strtolower($value['column']); } - foreach ($aArgs['data'] as $key => $value) { - if (strtolower($value['type']) == 'integer' || strtolower($value['type']) == 'float') { - if (empty($value['value'])) { - $aArgs['data'][$key]['value'] = '0'; - } - } elseif (strtolower($value['type']) == 'string') { - $aArgs['data'][$key]['value'] = str_replace(';', '', $value['value']); - $aArgs['data'][$key]['value'] = str_replace('--', '', $value['value']); - } - - if ($value['column'] == 'status') { - $statusFound = true; - } elseif ($value['column'] == 'typist') { - $typistFound = true; - } elseif ($value['column'] == 'custom_t10') { - $theString = str_replace('>', '', $value['value']); - $mail = explode("<", $theString); - $user = UserModel::getByEmail(['mail' => $mail[count($mail) -1], 'select' => ['user_id']]); - if (!empty($user[0]['user_id'])) { - $toAddressFound = true; - $destUser = $user[0]['user_id']; - $entity = EntityModel::getByLogin(['login' => $destUser, 'select' => ['entity_id']]); - if (!empty($entity[0]['entity_id'])) { - $userEntity = $entity[0]['entity_id']; - $userPrimaryEntity = true; - } - } else { - $entity = EntityModel::getByEmail(['email' => $mail[count($mail) -1], 'select' => ['entity_id']]); - if (!empty($entity[0]['entity_id'])) { - $userPrimaryEntity = true; - } - } - } - } - - $destUser = empty($destUser) ? '' : $destUser; - $userEntity = empty($userEntity) ? '' : $userEntity; - - if (!$typistFound && !$toAddressFound) { - $aArgs['data'][] = [ - 'column' => 'typist', - 'value' => 'auto', - 'type' => 'string' - ]; - } - if (!$statusFound) { - $aArgs['data'][] = [ - 'column' => 'status', - 'value' => $aArgs['status'], - 'type' => 'string' - ]; - } - if ($toAddressFound) { - $aArgs['data'][] = [ - 'column' => 'dest_user', - 'value' => $destUser, - 'type' => 'string' - ]; - if (!$typistFound) { - $aArgs['data'][] = [ - 'column' => 'typist', - 'value' => $destUser, - 'type' => 'string' - ]; - } - } - if ($userPrimaryEntity) { - $destinationFound = false; - $initiatorFound = false; - foreach ($aArgs['data'] as $key => $value) { - if ($value['column'] == 'destination') { - if (empty($value['value'])) { - $aArgs['data'][$key]['value'] = $userEntity; - } - $destinationFound = true; - } elseif ($value['column'] == 'initiator') { - if (empty($value['value'])) { - $aArgs['data'][$key]['value'] = $userEntity; - } - $initiatorFound = true; - } - } - if (!$destinationFound) { - $aArgs['data'][] = [ - 'column' => 'destination', - 'value' => $userEntity, - 'type' => 'string' - ]; - } - if (!$initiatorFound) { - $aArgs['data'][] = [ - 'column' => 'initiator', - 'value' => $userEntity, - 'type' => 'string' - ]; - } - } - $aArgs['data'][] = [ 'column' => 'docserver_id', 'value' => $aArgs['docserverId'], @@ -385,79 +261,6 @@ class StoreController return $formatedData; } - public static function prepareExtStorage(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['data', 'resId']); - ValidatorModel::arrayType($aArgs, ['data']); - ValidatorModel::intVal($aArgs, ['resId']); - - $processLimitDateFound = false; - $admissionDate = null; - - foreach ($aArgs['data'] as $key => $value) { - $aArgs['data'][$key]['column'] = strtolower($value['column']); - } - - foreach ($aArgs['data'] as $value) { - if ($value['column'] == 'process_limit_date') { - $processLimitDateFound = true; - } - if ($value['column'] == 'category_id') { - $categoryId = $value['value']; - } - if ($value['column'] == 'admission_date') { - $admissionDate = $value['value']; - } - } - - if (!$processLimitDateFound) { - $processLimitDate = ResModel::getStoredProcessLimitDate(['resId' => $aArgs['resId'], 'admissionDate' => $admissionDate]); - - $aArgs['data'][] = [ - 'column' => 'process_limit_date', - 'value' => $processLimitDate, - 'type' => 'date' - ]; - } - - foreach ($aArgs['data'] as $key => $value) { - if (strtolower($value['type']) == 'integer' || strtolower($value['type']) == 'float') { - if ($value['value'] == '') { - $aArgs['data'][$key]['value'] = '0'; - } - $aArgs['data'][$key]['value'] = str_replace(',', '.', $value['value']); - } - if ($value['column'] == 'alt_identifier' && empty($value['value']) && !empty($categoryId)) { - $document = ResModel::getById(['resId' => $aArgs['resId'], 'select' => ['destination, type_id']]); - $aArgs['data'][$key]['value'] = ChronoModel::getChrono(['id' => $categoryId, 'entityId' => $document['destination'], 'typeId' => $document['type_id']]); - } elseif ($value['column'] == 'exp_contact_id' && !empty($value['value']) && !is_numeric($value['value'])) { - $mail = explode('<', str_replace('>', '', $value['value'])); - $contact = ContactModel::getByEmail(['email' => $mail[count($mail) - 1], 'select' => ['contacts_v2.contact_id']]); - if (!empty($contact['contact_id'])) { - $aArgs['data'][$key]['value'] = $contact['contact_id']; - } else { - $aArgs['data'][$key]['value'] = 0; - } - } elseif ($value['column'] == 'address_id' && !empty($value['value']) && !is_numeric($value['value'])) { - $mail = explode('<', str_replace('>', '', $value['value'])); - $contact = ContactModel::getByEmail(['email' => $mail[count($mail) - 1], 'select' => ['contact_addresses.id']]); - if (!empty($contact['id'])) { - $aArgs['data'][$key]['value'] = $contact['ca_id']; - } else { - $aArgs['data'][$key]['value'] = 0; - } - } - } - - $formatedData = []; - foreach ($aArgs['data'] as $value) { - $formatedData[$value['column']] = $value['value']; - } - $formatedData['res_id'] = $aArgs['resId']; - - return $formatedData; - } - public function checkFileUpload(Request $request, Response $response) { $body = $request->getParsedBody(); diff --git a/src/app/resource/controllers/SummarySheetController.php b/src/app/resource/controllers/SummarySheetController.php index 1c70920fd61ae7b51dc7457e6475b33910db0a45..f600509f7f1c47379a1f6e0339e89941fe0fc515 100755 --- a/src/app/resource/controllers/SummarySheetController.php +++ b/src/app/resource/controllers/SummarySheetController.php @@ -148,7 +148,7 @@ class SummarySheetController 'orderBy' => ['listinstance_id'] ]); } elseif ($unit['unit'] == 'senderRecipientInformations') { - $data['mlbCollExt'] = ResModel::getExt([ + $data['senderRecipient'] = ResModel::get([ 'select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts', 'res_id'], 'where' => ['res_id in (?)'], 'data' => [$tmpIds] @@ -283,7 +283,7 @@ class SummarySheetController } elseif ($unit['unit'] == 'senderRecipientInformations') { $senders = []; $recipients = []; - foreach ($args['data']['mlbCollExt'] as $mlbKey => $mlbValue) { + foreach ($args['data']['senderRecipient'] as $mlbKey => $mlbValue) { if ($mlbValue['res_id'] == $resource['res_id']) { $resourcesContacts = ResourceContactModel::getFormattedByResId(['resId' => $resource['res_id']]); @@ -361,7 +361,7 @@ class SummarySheetController $senders = $oldContacts; $recipients = $resourcesContacts; } - unset($args['data']['mlbCollExt'][$mlbKey]); + unset($args['data']['senderRecipient'][$mlbKey]); break; } } diff --git a/src/app/resource/models/ResModelAbstract.php b/src/app/resource/models/ResModelAbstract.php index b1ae8d678d90371ae1d1460d66b749ee45712c3b..fe9f43ba08aa640f036a3508e6591bc7692900d7 100755 --- a/src/app/resource/models/ResModelAbstract.php +++ b/src/app/resource/models/ResModelAbstract.php @@ -60,21 +60,6 @@ abstract class ResModelAbstract return $aResources; } - public static function getExt(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['select']); - ValidatorModel::arrayType($aArgs, ['select', 'where', 'data']); - - $aResources = DatabaseModel::select([ - 'select' => $aArgs['select'], - 'table' => ['mlb_coll_ext'], - 'where' => $aArgs['where'], - 'data' => $aArgs['data'] - ]); - - return $aResources; - } - public static function getById(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['resId']); @@ -95,29 +80,10 @@ abstract class ResModelAbstract return $aResources[0]; } - public static function getExtById(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['resId']); - ValidatorModel::intVal($aArgs, ['resId']); - - $aResources = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['mlb_coll_ext'], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - - if (empty($aResources[0])) { - return []; - } - - return $aResources[0]; - } - public static function create(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['format', 'typist', 'creation_date', 'docserver_id', 'path', 'filename', 'fingerprint', 'filesize', 'status']); - ValidatorModel::stringType($aArgs, ['format', 'typist', 'creation_date', 'docserver_id', 'path', 'filename', 'fingerprint', 'status']); + ValidatorModel::notEmpty($aArgs, ['format', 'typist', 'creation_date', 'docserver_id', 'path', 'filename', 'fingerprint', 'filesize', 'status', 'category_id']); + ValidatorModel::stringType($aArgs, ['format', 'typist', 'creation_date', 'docserver_id', 'path', 'filename', 'fingerprint', 'status', 'category_id']); ValidatorModel::intVal($aArgs, ['filesize', 'res_id']); if (empty($aArgs['res_id'])) { @@ -132,20 +98,6 @@ abstract class ResModelAbstract return $aArgs['res_id']; } - public static function createExt(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['res_id', 'category_id']); - ValidatorModel::stringType($aArgs, ['category_id']); - ValidatorModel::intVal($aArgs, ['res_id']); - - DatabaseModel::insert([ - 'table' => 'mlb_coll_ext', - 'columnsValues' => $aArgs - ]); - - return true; - } - public static function update(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['set', 'where', 'data']); @@ -161,21 +113,6 @@ abstract class ResModelAbstract return true; } - public static function updateExt(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['set', 'where', 'data']); - ValidatorModel::arrayType($aArgs, ['set', 'where', 'data']); - - DatabaseModel::update([ - 'table' => 'mlb_coll_ext', - 'set' => $aArgs['set'], - 'where' => $aArgs['where'], - 'data' => $aArgs['data'] - ]); - - return true; - } - public static function delete(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['resId']); @@ -202,7 +139,7 @@ abstract class ResModelAbstract $resources = DatabaseModel::select([ 'select' => $aArgs['select'], - 'table' => ['history, res_letterbox r, mlb_coll_ext mlb, status, priorities'], + 'table' => ['history, res_letterbox r, status, priorities'], 'where' => [ 'history.user_id = ?', 'history.table_name IN (?)', 'history.record_id IS NOT NULL', 'history.record_id != ?', @@ -210,11 +147,10 @@ abstract class ResModelAbstract 'CAST(history.record_id AS INT) = r.res_id', 'r.res_id = r.res_id', 'r.status != ?', 'r.status = status.id', - 'r.priority = priorities.id', - 'r.res_id = mlb.res_id', + 'r.priority = priorities.id' ], 'data' => [$aArgs['userId'], ['res_letterbox', 'res_view_letterbox'], 'none', 'linkup', 'attach%', 'DEL'], - 'groupBy' => ['r.subject', 'r.creation_date', 'r.res_id', 'mlb.alt_identifier', 'mlb.closing_date', 'mlb.process_limit_date', 'status.id', 'status.label_status', 'status.img_filename', 'priorities.color', 'priorities.label'], + 'groupBy' => ['r.subject', 'r.creation_date', 'r.res_id', 'r.alt_identifier', 'r.closing_date', 'r.process_limit_date', 'status.id', 'status.label_status', 'status.img_filename', 'priorities.color', 'priorities.label'], 'order_by' => ['MAX(history.event_date) DESC'], 'limit' => $aArgs['limit'] ]); @@ -242,23 +178,23 @@ abstract class ResModelAbstract return $aReturn; } - public static function getResIdByAltIdentifier(array $aArgs) + public static function getByAltIdentifier(array $args) { - ValidatorModel::notEmpty($aArgs, ['altIdentifier']); - ValidatorModel::stringType($aArgs, ['altIdentifier']); + ValidatorModel::notEmpty($args, ['altIdentifier']); + ValidatorModel::stringType($args, ['altIdentifier']); - $aResources = DatabaseModel::select([ - 'select' => ['res_id'], - 'table' => ['mlb_coll_ext'], + $resource = DatabaseModel::select([ + 'select' => empty($args['select']) ? ['*'] : $args['select'], + 'table' => ['res_letterbox'], 'where' => ['alt_identifier = ?'], - 'data' => [$aArgs['altIdentifier']] + 'data' => [$args['altIdentifier']] ]); - if (empty($aResources[0])) { + if (empty($resource[0])) { return []; } - return $aResources[0]; + return $resource[0]; } public static function getStoredProcessLimitDate(array $aArgs) @@ -294,30 +230,23 @@ abstract class ResModelAbstract public static function getCategories() { - static $categories; - - if (!empty($categories)) { - return $categories; - } - $categories = [ - [ - 'id' => 'incoming', - 'label' => defined('_INCOMING') ? _INCOMING : '_INCOMING', - 'defaultCategory' => true - ], [ - 'id' => 'outgoing', - 'label' => defined('_OUTGOING') ? _OUTGOING : '_OUTGOING', - 'defaultCategory' => false - ], [ - 'id' => 'internal', - 'label' => defined('_INTERNAL') ? _INTERNAL : '_INTERNAL', - 'defaultCategory' => false - ], [ - 'id' => 'ged_doc', - 'label' => defined('_GED_DOC') ? _GED_DOC : '_GED_DOC', - 'defaultCategory' => false - ] + [ + 'id' => 'incoming', + 'label' => _INCOMING + ], + [ + 'id' => 'outgoing', + 'label' => _OUTGOING + ], + [ + 'id' => 'internal', + 'label' => _INTERNAL + ], + [ + 'id' => 'ged_doc', + 'label' => _GED_DOC + ] ]; return $categories; diff --git a/src/app/resource/models/ResourceListModel.php b/src/app/resource/models/ResourceListModel.php index df7562ae2f76ebb18b93f4ff240c23e45d406123..a6248e877fc463973d3013d31bb87914ed014b78 100644 --- a/src/app/resource/models/ResourceListModel.php +++ b/src/app/resource/models/ResourceListModel.php @@ -36,11 +36,11 @@ class ResourceListModel 'res_letterbox.subject', 'res_letterbox.creation_date', 'res_letterbox.barcode', - 'mlb_coll_ext.alt_identifier', - 'mlb_coll_ext.category_id', - 'mlb_coll_ext.closing_date', - 'mlb_coll_ext.process_limit_date', - 'mlb_coll_ext.is_multicontacts', + 'res_letterbox.alt_identifier', + 'res_letterbox.category_id', + 'res_letterbox.closing_date', + 'res_letterbox.process_limit_date', + 'res_letterbox.is_multicontacts', 'entities.entity_label as entity_destination', 'doctypes.description as doctype_label', 'contacts_v2.firstname as contact_firstname', @@ -56,13 +56,12 @@ class ResourceListModel 'us.lastname as user_dest_lastname', 'us.firstname as user_dest_firstname', ], - 'table' => ['res_letterbox', 'mlb_coll_ext', 'entities', 'doctypes', 'contacts_v2', 'users', 'priorities', 'status', 'users us'], + 'table' => ['res_letterbox', 'entities', 'doctypes', 'contacts_v2', 'users', 'priorities', 'status', 'users us'], 'left_join' => [ - 'res_letterbox.res_id = mlb_coll_ext.res_id', 'res_letterbox.destination = entities.entity_id', 'res_letterbox.type_id = doctypes.type_id', - 'mlb_coll_ext.exp_contact_id = contacts_v2.contact_id OR mlb_coll_ext.dest_contact_id = contacts_v2.contact_id', - 'mlb_coll_ext.exp_user_id = users.user_id OR mlb_coll_ext.dest_user_id = users.user_id', + 'res_letterbox.exp_contact_id = contacts_v2.contact_id OR res_letterbox.dest_contact_id = contacts_v2.contact_id', + 'res_letterbox.exp_user_id = users.user_id OR res_letterbox.dest_user_id = users.user_id', 'res_letterbox.priority = priorities.id', 'res_letterbox.status = status.id', 'res_letterbox.dest_user = us.user_id' diff --git a/src/app/signatureBook/controllers/SignatureBookController.php b/src/app/signatureBook/controllers/SignatureBookController.php index 8c7ae3ed7cd9f4d854184421a42462419d0b58ae..2179e245f655cca3c3f248064c70b32f185d63e2 100755 --- a/src/app/signatureBook/controllers/SignatureBookController.php +++ b/src/app/signatureBook/controllers/SignatureBookController.php @@ -164,18 +164,12 @@ class SignatureBookController $incomingMail = ResModel::getById([ 'resId' => $resId, - 'select' => ['res_id', 'subject'] + 'select' => ['res_id', 'subject', 'alt_identifier', 'category_id'] ]); if (empty($incomingMail)) { return ['error' => 'No Document Found']; } - $incomingExtMail = ResModel::getExtById([ - 'resId' => $resId, - 'select' => ['alt_identifier', 'category_id'] - ]); - $incomingMail['alt_identifier'] = $incomingExtMail['alt_identifier']; - $incomingMail['category_id'] = $incomingExtMail['category_id']; $incomingMailAttachments = AttachmentModel::getOnView([ 'select' => ['res_id', 'res_id_version', 'title', 'format', 'attachment_type', 'path', 'filename'], diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index bb48b1bf8b63ad6e98d53673b0fd0861a561fb01..68a2a95a8914651f4062a90d38ba48593f693ba8 100755 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -299,7 +299,7 @@ define('_SIMPLE_CONFIRM', 'Simple confirmation'); define('_SIMPLE_CONFIRM_DESC', "Simply open a modal of confirmation of the action to be performed."); define('_VIEW_DOC', 'See the mail'); define('_CLOSE_MAIL', 'Close a mail'); -define('_CLOSE_MAIL_DESC', 'Allows you to update the closing date of a mail (\'closing_date\' of the mlb_coll_ext table). ESSENTIAL in order to complete your document workflow.'); +define('_CLOSE_MAIL_DESC', 'Allows you to update the closing date of a mail. ESSENTIAL in order to complete your document workflow.'); define('_SET_PERSISTENT_MODE_ON', 'Activate the persistence'); define('_SET_PERSISTENT_MODE_ON_DESC', 'Keeps a mail in a basket regardless of its state. Insert data in the \'basket_persistent_mode\' table.'); define('_SET_PERSISTENT_MODE_OFF', 'Deactivate the persistence'); @@ -311,9 +311,9 @@ define('_SEND_DATA_WS', 'Send data via Web Service'); define('_SEND_TO_EXTERNAL_SB', 'Send data to external signature book'); define('_SEND_TO_EXTERNAL_NOTEBOOK', 'Send data to external note book'); define('_CLOSE_MAIL_AND_INDEX', 'Close a mail and launch the indexation'); -define('_CLOSE_MAIL_AND_INDEX_DESC', 'Allows you to update the closing date of a mail (\'closing_date\' of the mlb_coll_ext table) AND opens the indexing page to save a new mail.'); +define('_CLOSE_MAIL_AND_INDEX_DESC', 'Allows you to update the closing date of a mail AND opens the indexing page to save a new mail.'); define('_CLOSE_MAIL_WITH_ATTACHMENT', 'Closing with attachment'); -define('_CLOSE_MAIL_WITH_ATTACHMENT_DESC', 'Allows you to update the closing date of a mail (\'closing_date\' of the table mlb_coll_ext) with MANDATORY presence of attachment (s) / note (s).'); +define('_CLOSE_MAIL_WITH_ATTACHMENT_DESC', 'Allows you to update the closing date of a mail with MANDATORY presence of attachment (s) / note (s).'); define('_SEND_SIGNED_DOCS', 'Pass signed responses'); define('_SEND_SIGNED_DOCS_DESC', 'Check if response project are signed.'); define('_SEND_TO_VISA', 'send for visa'); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index c5f505cd97fee69211a42a0637aaa2c60b3decc6..f5bb00f2333841de329d39421ec39f61474f98ed 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -299,7 +299,7 @@ define('_SIMPLE_CONFIRM', 'Confirmation simple'); define('_SIMPLE_CONFIRM_DESC', "Ouvre simplement une modal de confirmation de l'action à effectuer."); define('_VIEW_DOC', 'Voir le courrier'); define('_CLOSE_MAIL', 'Clôturer un courrier'); -define('_CLOSE_MAIL_DESC', 'Permet de mettre à jour la date de clôture d\'un courrier (\'closing_date\' de la table mlb_coll_ext). ESSENTIEL afin de terminer votre workflow de courrier.'); +define('_CLOSE_MAIL_DESC', 'Permet de mettre à jour la date de clôture d\'un courrier. ESSENTIEL afin de terminer votre workflow de courrier.'); define('_SET_PERSISTENT_MODE_ON', 'Activer la persistance'); define('_SET_PERSISTENT_MODE_ON_DESC', 'Permet de conserver un courrier dans une bannette quelque soit son état. Insère la donnée dans la table \'basket_persistent_mode\'.'); define('_SET_PERSISTENT_MODE_OFF', 'Désactiver la persistance'); @@ -311,9 +311,9 @@ define('_SEND_DATA_WS', 'Envoyer des données via Web Service'); define('_SEND_TO_EXTERNAL_SB', 'Envoyer des données vers un parapheur externe'); define('_SEND_TO_EXTERNAL_NOTEBOOK', 'Envoyer des courriers à annoter vers Maarch Parapheur'); define('_CLOSE_MAIL_AND_INDEX', 'Clôturer un courrier et lancer l\'indexation'); -define('_CLOSE_MAIL_AND_INDEX_DESC', 'Permet de mettre à jour la date de clôture d\'un courrier (\'closing_date\' de la table mlb_coll_ext) ET ouvre la page d\'indexation afin d\'enregistrer un nouveau courrier.'); +define('_CLOSE_MAIL_AND_INDEX_DESC', 'Permet de mettre à jour la date de clôture d\'un courrier ET ouvre la page d\'indexation afin d\'enregistrer un nouveau courrier.'); define('_CLOSE_MAIL_WITH_ATTACHMENT', 'Clôturer un courrier avec pièce jointe'); -define('_CLOSE_MAIL_WITH_ATTACHMENT_DESC', 'Permet de mettre à jour la date de clôture d\'un courrier (\'closing_date\' de la table mlb_coll_ext) avec présence OBLIGATOIRE de pièce(s) jointe(s) / annotation(s).'); +define('_CLOSE_MAIL_WITH_ATTACHMENT_DESC', 'Permet de mettre à jour la date de clôture d\'un courrier avec présence OBLIGATOIRE de pièce(s) jointe(s) / annotation(s).'); define('_SEND_SIGNED_DOCS', 'Transmettre réponses signées'); define('_SEND_SIGNED_DOCS_DESC', 'Vérifie si les projets de réponse ont été signés.'); define('_SEND_TO_VISA', 'Envoyer pour visa'); diff --git a/src/core/lang/lang-nl.php b/src/core/lang/lang-nl.php index 6e8e2683759bedf2e98deaf931221d1501157aca..5670bc3cd313baa5f88057e19df4c7900aeb2118 100755 --- a/src/core/lang/lang-nl.php +++ b/src/core/lang/lang-nl.php @@ -298,7 +298,7 @@ define('_SIMPLE_CONFIRM', 'Eenvoudige bevestiging'); define('_SIMPLE_CONFIRM_DESC', 'Opent eenvoudigweg een bevestigingsmodaliteit van de uit te voeren actie.'); define('_VIEW_DOC', 'Het brief bekijken'); define('_CLOSE_MAIL', 'Een brief afsluiten'); -define('_CLOSE_MAIL_DESC', 'Om de afsluitingsdatum van een brief bij te werken (closing_date van tabel mlb_coll_ext). ESSENTIEEL om uw documentworkflow af te sluiten.'); +define('_CLOSE_MAIL_DESC', 'Om de afsluitingsdatum van een brief bij te werken. ESSENTIEEL om uw documentworkflow af te sluiten.'); define('_SET_PERSISTENT_MODE_ON', 'De persistentie activeren'); define('_SET_PERSISTENT_MODE_ON_DESC', 'Om een biref in een bakje te bewaren ongeacht zijn status. Voegt het gegeven in de tabel \basket_persistent_mode\.'); define('_SET_PERSISTENT_MODE_OFF', 'De persistentie uitschakelen'); @@ -309,9 +309,9 @@ define('_SEND_FILE_WS', 'Het document via Web Service verzenden'); define('_SEND_DATA_WS', 'Gegevens via Web Service verzenden'); define('_SEND_TO_EXTERNAL_SB', 'Gegevens naar een extern vloeiboek verzenden'); define('_CLOSE_MAIL_AND_INDEX', 'Een brief afsluiten en de indexering starten'); -define('_CLOSE_MAIL_AND_INDEX_DESC', 'Om de afsluitingsdatum van een brief bij te werken (\ closing_date van tabel mlb_coll_ext) EN de indexeringspagina te openen om een nieuw brief te bewaren.'); +define('_CLOSE_MAIL_AND_INDEX_DESC', 'Om de afsluitingsdatum van een brief bij te werken EN de indexeringspagina te openen om een nieuw brief te bewaren.'); define('_CLOSE_MAIL_WITH_ATTACHMENT', 'Een brief met een bijlage afsluiten'); -define('_CLOSE_MAIL_WITH_ATTACHMENT_DESC', 'Om de afsluitingsdatum van een brief bij te werken (closing_date van tabel mlb_coll_ext) met VERPLICHTE aanwezigheid van bijlage(n) / opmerking(en).'); +define('_CLOSE_MAIL_WITH_ATTACHMENT_DESC', 'Om de afsluitingsdatum van een brief bij te werken met VERPLICHTE aanwezigheid van bijlage(n) / opmerking(en).'); define('_SEND_SIGNED_DOCS', 'Ondertekende antwoorden doorsturen'); define('_SEND_SIGNED_DOCS_DESC', 'Controleert of de antwoordprojecten ondertekend werden.'); define('_SEND_TO_VISA', 'Versturen voor goedkeuring'); diff --git a/test/unitTests/app/doctype/DoctypeControllerTest.php b/test/unitTests/app/doctype/DoctypeControllerTest.php index b114ed448ae5ffae92bdb1d7c9529faa91c0e31d..c578214e40a50b0454906b7a7cf92d8ac94bb822 100755 --- a/test/unitTests/app/doctype/DoctypeControllerTest.php +++ b/test/unitTests/app/doctype/DoctypeControllerTest.php @@ -548,35 +548,18 @@ class DoctypeControllerTest extends TestCase $fileContent = file_get_contents('test/unitTests/samples/test.txt'); $encodedFile = base64_encode($fileContent); - $data = [ - [ - 'column' => 'subject', - 'value' => 'subject value test U', - 'type' => 'string', - ], - [ - 'column' => 'type_id', - 'value' => $doctypeId, - 'type' => 'integer', - ], - [ - 'column' => 'typist', - 'value' => 'LLane', - 'type' => 'string', - ] - ]; - $aArgs = [ - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', 'status' => 'NEW', 'encodedFile' => $encodedFile, - 'fileFormat' => 'txt', - 'data' => $data + 'format' => 'txt', + 'type_id' => $doctypeId, + 'category_id' => 'incoming', + 'subject' => 'subject value test U', + 'typist' => 'LLane' ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $resController->createRes($fullRequest, new \Slim\Http\Response()); + $response = $resController->create($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); diff --git a/test/unitTests/app/resource/ResControllerTest.php b/test/unitTests/app/resource/ResControllerTest.php index 4cf2f390ea95f2a7af80432b54c937eadf62ce3f..e7f7db4e3d9b59702d775c284020e1ae1d0d92e9 100755 --- a/test/unitTests/app/resource/ResControllerTest.php +++ b/test/unitTests/app/resource/ResControllerTest.php @@ -24,46 +24,21 @@ class ResControllerTest extends TestCase $fileContent = file_get_contents('test/unitTests/samples/test.txt'); $encodedFile = base64_encode($fileContent); - $data = [ - [ - 'column' => 'subject', - 'value' => 'Breaking News : Superman is alive - PHP unit', - 'type' => 'string', - ], - [ - 'column' => 'type_id', - 'value' => 102, - 'type' => 'integer', - ], - [ - 'column' => 'typist', - 'value' => 'LLane', - 'type' => 'string', - ], - [ - 'column' => 'dest_user', - 'value' => 'bbain', - 'type' => 'string', - ], - [ - 'column' => 'priority', - 'value' => 'poiuytre1357nbvc', - 'type' => 'string', - ] - ]; - $aArgs = [ - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', 'status' => 'NEW', 'encodedFile' => $encodedFile, - 'fileFormat' => 'txt', - 'data' => $data + 'format' => 'txt', + 'type_id' => 102, + 'category_id' => 'incoming', + 'subject' => 'Breaking News : Superman is alive - PHP unit', + 'typist' => 'LLane', + 'dest_user' => 'bbain', + 'priority' => 'poiuytre1357nbvc', ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $resController->createRes($fullRequest, new \Slim\Http\Response()); + $response = $resController->create($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); self::$id = $responseBody->resId; $this->assertInternalType('int', self::$id); @@ -83,71 +58,6 @@ class ResControllerTest extends TestCase $this->assertSame(null, $res['destination']); } - public function testCreateExt() - { - $resController = new \Resource\controllers\ResController(); - - $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']); - $request = \Slim\Http\Request::createFromEnvironment($environment); - - $data = [ - [ - 'column' => 'category_id', - 'value' => 'incoming', - 'type' => 'string', - ] - ]; - - $aArgs = [ - 'resId' => self::$id, - 'data' => $data - ]; - - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $resController->createExt($fullRequest, new \Slim\Http\Response()); - $responseBody = json_decode((string)$response->getBody()); - - $this->assertSame(true, $responseBody->status); - - $ext = \Resource\models\ResModel::getExtById(['resId' => self::$id, 'select' => ['category_id']]); - - $this->assertSame('incoming', $ext['category_id']); - - $data = [ - [ - 'column' => 'category_id', - 'value' => 'incoming', - 'type' => 'string', - ] - ]; - - $aArgs = [ - 'resId' => self::$id, - 'data' => $data - ]; - - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $resController->createExt($fullRequest, new \Slim\Http\Response()); - $responseBody = json_decode((string)$response->getBody()); - - $this->assertSame('Document already exists in mlb_coll_ext', $responseBody->errors); - - - $aArgs = [ - 'resId' => self::$id, - 'data' => null - ]; - - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $resController->createExt($fullRequest, new \Slim\Http\Response()); - $responseBody = json_decode((string)$response->getBody()); - - $this->assertSame('Bad Request', $responseBody->errors); - } - public function testGetFileContent() { $resController = new \Resource\controllers\ResController(); @@ -436,82 +346,27 @@ class ResControllerTest extends TestCase $fileContent = file_get_contents('test/unitTests/samples/test.txt'); $encodedFile = base64_encode($fileContent); - $data = [ - [ - 'column' => 'subject', - 'value' => $key . ' Breaking News : 12345 Superman is alive - PHP unit', - 'type' => 'string', - ], - [ - 'column' => 'type_id', - 'value' => $value[0], - 'type' => 'integer', - ], - [ - 'column' => 'typist', - 'value' => 'LLane', - 'type' => 'string', - ], - [ - 'column' => 'dest_user', - 'value' => 'bbain', - 'type' => 'string', - ], - [ - 'column' => 'priority', - 'value' => $value[1], - 'type' => 'string', - ], - [ - 'column' => 'destination', - 'value' => 'PJS', - 'type' => 'string', - ] - ]; - $aArgs = [ - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', 'status' => $value[2], 'encodedFile' => $encodedFile, - 'fileFormat' => 'txt', - 'data' => $data + 'format' => 'txt', + 'type_id' => $value[0], + 'category_id' => 'incoming', + 'subject' => $key . ' Breaking News : 12345 Superman is alive - PHP unit', + 'typist' => 'LLane', + 'dest_user' => 'bbain', + 'priority' => $value[1], + 'destination' => 'PJS' ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $resController->createRes($fullRequest, new \Slim\Http\Response()); + $response = $resController->create($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); $newId = $responseBody->resId; $this->assertInternalType('int', $newId); if ($key < 2) { $GLOBALS['resources'][] = $newId; } - - $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']); - $request = \Slim\Http\Request::createFromEnvironment($environment); - - $data = [ - [ - 'column' => 'category_id', - 'value' => 'incoming', - 'type' => 'string', - ] - ]; - - $aArgs = [ - 'resId' => $newId, - 'data' => $data - ]; - - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $resController->createExt($fullRequest, new \Slim\Http\Response()); - $responseBody = json_decode((string)$response->getBody()); - - $this->assertSame(true, $responseBody->status); - - $ext = \Resource\models\ResModel::getExtById(['resId' => $newId, 'select' => ['category_id']]); - - $this->assertSame('incoming', $ext['category_id']); } } }