diff --git a/apps/maarch_entreprise/Views/signature-book.component.html b/apps/maarch_entreprise/Views/signature-book.component.html index 50bf8dbd5bc2f049f986cd0d50ff6c1d8e62c83a..59845a90c3f61ca715f7d2fe22a042fa52dbcc50 100755 --- a/apps/maarch_entreprise/Views/signature-book.component.html +++ b/apps/maarch_entreprise/Views/signature-book.component.html @@ -168,7 +168,7 @@ <i *ngIf="!showTopRightPanel" class="fa fa-list-alt fa-2x" aria-hidden="true"></i> <i *ngIf="showTopRightPanel" class="fa fa-chevron-up" aria-hidden="true"></i> </div> - <iframe *ngIf="signatureBook.attachments[rightSelectedThumbnail].format == 'pdf' || signatureBook.attachments[rightSelectedThumbnail].isConverted" id="rightPanelShowDocumentIframe" [src]="rightViewerLink | safeUrl" [ngStyle]="{'height': showTopRightPanel ? '84%' : '99%'}"></iframe> + <iframe id="rightPanelShowDocumentIframe" [src]="rightViewerLink | safeUrl" [ngStyle]="{'height': showTopRightPanel ? '84%' : '99%'}"></iframe> <div *ngIf="signatureBook.attachments[rightSelectedThumbnail].format != 'pdf' && signatureBook.attachments[rightSelectedThumbnail].status != 'TMP' && !signatureBook.attachments[rightSelectedThumbnail].isConverted" [ngStyle]="{'height': showTopRightPanel ? '79%' : '96%'}" class="visaNoPdfWarning"> <div style="padding-top: 25%;">Aucun aperçu disponible<br/><sub>La version PDF du fichier "{{signatureBook.attachments[rightSelectedThumbnail].title}}.{{signatureBook.attachments[rightSelectedThumbnail].format}}" n'est pas disponible.</sub></div> <div class="visaPjView"> @@ -185,7 +185,7 @@ </a> </div> </div> - <div *ngIf="signatureBook.signatures[0] && signatureBook.canSign && signatureBook.attachments[rightSelectedThumbnail].status != 'TMP' && signatureBook.attachments[rightSelectedThumbnail].sign && (signatureBook.attachments[rightSelectedThumbnail].format == 'pdf' || signatureBook.attachments[rightSelectedThumbnail].isConverted)" + <div *ngIf="signatureBook.signatures[0] && signatureBook.canSign && signatureBook.attachments[rightSelectedThumbnail].status != 'TMP' && signatureBook.attachments[rightSelectedThumbnail].sign" (mouseenter)="showSignaturesPanel = true" (mouseleave)="showSignaturesPanel = false" class="pjSign" [ngClass]="[signatureBook.attachments[rightSelectedThumbnail].status == 'SIGN' ? 'signed' : '']" [ngStyle]="{'box-shadow': signatureBook.listinstance.requested_signature ? 'inset 0px 0px 5px 0px red' : 'inset 0px 0px 5px 0px #656565;'}"> <span *ngIf="signatureBook.attachments[rightSelectedThumbnail].status != 'SIGN' && signatureBook.signatures[0]" style="cursor: pointer"> <span *ngIf="!loadingSign"> @@ -211,10 +211,10 @@ <div *ngIf="signatureBook.attachments" id="rightPanelContent" class="panelRightContent"> <div title="[{{attachment.attachment_type}}] {{attachment.title}}" style="position: relative;" class="item" *ngFor="let attachment of signatureBook.attachments; let i = index" (click)="changeRightViewer(i)" [ngClass]="{'panelSelectedThumbnail': i == rightSelectedThumbnail && !showAttachmentPanel}"> <span class="fa-stack fa-lg"> - <i class="fa fa-file fa-stack-2x"></i><i style="font-weight:bold;letter-spacing: -1px;">{{attachment.icon}}</i> + <i class="far fa-file fa-stack-2x"></i><i style="font-weight:bold;letter-spacing: -1px;">{{attachment.icon}}</i> </span> <i *ngIf="attachment.sign && attachment.status == 'SIGN'" title="Le document a été signé" style="position: absolute;top: 12px;right: 6px;" class="fa fa-circle"></i> - <i *ngIf="attachment.sign && attachment.status != 'SIGN' && attachment.status != 'TMP'" title="Le document n'a pas encore été signé" style="position: absolute;top: 12px;right: 6px;" class="fa fa-circle"></i> + <i *ngIf="attachment.sign && attachment.status != 'SIGN' && attachment.status != 'TMP'" title="Le document n'a pas encore été signé" style="position: absolute;top: 12px;right: 6px;" class="far fa-circle"></i> <i *ngIf="attachment.sign && attachment.status == 'TMP'" style="color:green;-ms-transform: rotate(-35deg);-webkit-transform: rotate(-35deg);transform: rotate(-35deg);position: absolute;top: 39px;right: 1px;" >{{lang.draft}}</i> <br/><i style="position: absolute;margin-left: -9px;" >.{{attachment.format}}</i> </div> diff --git a/apps/maarch_entreprise/js/angular/app/signature-book.component.ts b/apps/maarch_entreprise/js/angular/app/signature-book.component.ts index 3406266088709fc8f9e2fa94234f8ab895648c6c..f4af11f0ec1ddc84720d99b1080c617acfeed15b 100755 --- a/apps/maarch_entreprise/js/angular/app/signature-book.component.ts +++ b/apps/maarch_entreprise/js/angular/app/signature-book.component.ts @@ -92,11 +92,7 @@ export class SignatureBookComponent implements OnInit { } prepareSignatureBook() { - $j('#inner_content').remove(); - $j('#header').remove(); - $j('#viewBasketsTitle').remove(); - $j('#homePageWelcomeTitle').remove(); - $j('#footer').remove(); + $j('main-header').remove(); $j('#container').width("99%"); } @@ -460,7 +456,7 @@ export class SignatureBookComponent implements OnInit { this.http.put(this.coreUrl + 'rest/signatureBook/' + resId + '/unsign', {'table' : collId}) .subscribe(() => { - this.rightViewerLink = "index.php?display=true&module=attachments&page=view_attachment&res_id_master=" + this.resId + "&id=" + attachment.viewerNoSignId + "&isVersion=" + isVersion; + this.rightViewerLink = "../../rest/res/" + this.resId + "/attachment/" + resId; this.signatureBook.attachments[this.rightSelectedThumbnail].viewerLink = this.rightViewerLink; this.signatureBook.attachments[this.rightSelectedThumbnail].status = 'A_TRA'; this.signatureBook.attachments[this.rightSelectedThumbnail].idToDl = resId; diff --git a/modules/attachments/attachments_content.php b/modules/attachments/attachments_content.php index d489dacad067aabc7569da1194ea8c13544d1898..d99eba1a36c5a691519007b4bc812e5feb47788d 100755 --- a/modules/attachments/attachments_content.php +++ b/modules/attachments/attachments_content.php @@ -1025,8 +1025,16 @@ if (isset($_POST['add']) && $_POST['add']) { //UPDATE QUERY if ((int) $_REQUEST['relation'] == 1) { $stmt = $db->query('UPDATE res_attachments SET '.$set_update.' WHERE res_id = :res_id', $arrayPDO); + \Convert\models\AdrModel::deleteAttachAdr([ + 'resId' => $_REQUEST['res_id'], + 'isVersion' => false + ]); } else { $stmt = $db->query('UPDATE res_version_attachments SET '.$set_update.' WHERE res_id = :res_id', $arrayPDO); + \Convert\models\AdrModel::deleteAttachAdr([ + 'resId' => $_REQUEST['res_id'], + 'isVersion' => false + ]); } } //copie de la version PDF de la pièce si mode de conversion sur le client diff --git a/modules/visa/class/class_modules_tools_Abstract.php b/modules/visa/class/class_modules_tools_Abstract.php index 0479b4af2fcd665f9beec7db6ee0384f0ad12c5f..fff22add3ebdf496bf6ac6a3632e3f7edf9f82a9 100755 --- a/modules/visa/class/class_modules_tools_Abstract.php +++ b/modules/visa/class/class_modules_tools_Abstract.php @@ -253,7 +253,7 @@ abstract class visa_Abstract extends Database return false; } - $resFirstFiles = []; + /*$resFirstFiles = []; while ($res = $stmt->fetchObject()) { if (($res->format == 'doc' || $res->format == 'docx' || $res->format == 'odt') && !in_array($res->attachment_type, ['simple_attachment', 'simple_attachment_rp'])) { @@ -278,7 +278,7 @@ abstract class visa_Abstract extends Database $this->errorMessageVisa .= '<br/> '; $this->errorMessageVisa .= $_SESSION['attachment_types'][$tmpObj->attachment_type].' : '; $this->errorMessageVisa .= $tmpObj->title; - } + }*/ return true; } diff --git a/modules/visa/sign_file.php b/modules/visa/sign_file.php index 4271729c8198f7419eaef08e9978d5e4d0a68516..31564b081c15dbb7caa2218dc5765ffbe4ea0998 100755 --- a/modules/visa/sign_file.php +++ b/modules/visa/sign_file.php @@ -57,22 +57,20 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) { $objectId = $_REQUEST['id']; $tableName = 'res_view_attachments'; if (isset($_REQUEST['isOutgoing'])) { - if (isset($_REQUEST['isVersion'])) { - $stmt = $db->query("select res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " - . $tableName - . " where attachment_type = ? and res_id_version = ?", ['outgoing_mail', $objectId]); - - } else { - $stmt = $db->query("select res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " - . $tableName - . " where attachment_type = ? and res_id = ?", ['outgoing_mail', $objectId]); - } - } else { + if (isset($_REQUEST['isVersion'])) { + $stmt = $db->query("select res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " + . $tableName + . " where attachment_type = ? and res_id_version = ?", ['outgoing_mail', $objectId]); + } else { + $stmt = $db->query("select res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " + . $tableName + . " where attachment_type = ? and res_id = ?", ['outgoing_mail', $objectId]); + } + } else { if (isset($_REQUEST['isVersion'])) { $stmt = $db->query("select res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " . $tableName . " where attachment_type NOT IN ('converted_pdf','print_folder') and res_id_version = ?", array($objectId)); - } else { $stmt = $db->query("select res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " . $tableName @@ -83,7 +81,6 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) { if ($stmt->rowCount() < 1) { echo '{"status":1, "error" : "'._FILE.' '._UNKNOWN.'"}'; exit; - //$_SESSION['error'] = _FILE . ' ' . _UNKNOWN; } else { $line = $stmt->fetchObject(); $_SESSION['visa']['last_resId_signed']['res_id'] = $line->res_id_master; @@ -95,12 +92,37 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) { $_SESSION['visa']['last_resId_signed']['dest_user'] = $line->dest_user; if (isset($_REQUEST['isOutgoing']) || $line->attachment_type == 'response_project') { - //Update outgoing date - $date = date("Y-m-d"); - $db->query("update res_letterbox SET departure_date = ? where res_id = ?", array($date,$line->res_id_master)); - } + //Update outgoing date + $date = date("Y-m-d"); + $db->query("update res_letterbox SET departure_date = ? where res_id = ?", array($date,$line->res_id_master)); + } - include 'modules/visa/retrieve_attachment_from_cm.php'; + if (isset($_REQUEST['isVersion'])) { + $isVersion = true; + $attachResId = $line->res_id_version; + } else { + $isVersion = false; + $attachResId = $line->res_id; + } + $convertedAttachment = \Attachment\models\AttachmentModel::getConvertedPdfById(['select' => ['docserver_id', 'path', 'filename'], 'resId' => $attachResId, 'isVersion' => $isVersion]); + + if (empty($convertedAttachment)) { + echo "{\"status\":1, \"error\" : \""._ATTACH_PDF_NOT_FOUND . ": {$attachResId}, version : {$isVersion}\"}"; + exit; + } + + $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $convertedAttachment["docserver_id"], 'select' => ['path_template']]); + + $fileOnDs = $docserver["path_template"] . $convertedAttachment["path"] . $convertedAttachment["filename"]; + $fileOnDs = str_replace('#', DIRECTORY_SEPARATOR, $fileOnDs); + $fileExtension = pathinfo($fileOnDs, PATHINFO_EXTENSION); + $fileNameOnTmp = 'tmp_file_' . $_SESSION['user']['UserId'] + . '_' . rand() . '.' . $fileExtension; + $filePathOnTmp = $_SESSION['config']['tmppath'] . $fileNameOnTmp; + if (!copy($fileOnDs, $filePathOnTmp)) { + echo "{\"status\":1, \"error\" : \""._FAILED_TO_COPY_ON_TMP . ": {$fileOnDs} {$filePathOnTmp}\"}"; + exit; + } //ADD CURRENT DATE IN SIGN IMG FILE $tmpPathToWantedSignature = $pathToWantedSignature; @@ -170,6 +192,12 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) { include 'modules/visa/save_attach_res_from_cm.php'; $db->query('UPDATE listinstance set signatory = TRUE WHERE listinstance_id = (SELECT listinstance_id FROM listinstance WHERE res_id = ? AND item_id = ? AND difflist_type = ? AND process_date is null ORDER BY listinstance_id LIMIT 1)', [$objectResIdMaster, $_SESSION['user']['UserId'], 'VISA_CIRCUIT']); + + if (isset($_REQUEST['isVersion'])) { + $db->query("UPDATE res_version_attachments set status = 'SIGN' WHERE res_id = ?", [$attachResId]); + } else { + $db->query("UPDATE res_attachments set status = 'SIGN' WHERE res_id = ?", [$attachResId]); + } echo "{\"status\": 0, \"new_id\": $id}"; exit; diff --git a/src/app/convert/models/AdrModel.php b/src/app/convert/models/AdrModel.php index 1c2b9d06f5e0ef0d1091c449af2b2a0a03feebaa..acae5c40c517b6c66344e66e858ad4c5b730e1b9 100644 --- a/src/app/convert/models/AdrModel.php +++ b/src/app/convert/models/AdrModel.php @@ -121,5 +121,24 @@ class AdrModel return true; } + public static function deleteAttachAdr(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['resId']); + ValidatorModel::intVal($aArgs, ['resId']); + ValidatorModel::boolType($aArgs, ['isVersion']); + + if ($aArgs['isVersion']) { + $table = "adr_attachments_version"; + } else { + $table = "adr_attachments"; + } + DatabaseModel::delete([ + 'table' => $table, + 'where' => ['res_id = ?'], + 'data' => [$aArgs['resId']] + ]); + + return true; + } } diff --git a/src/app/signatureBook/controllers/SignatureBookController.php b/src/app/signatureBook/controllers/SignatureBookController.php index f565581e7ef605d5d924816fcaa3f0e9cbe8bbd9..6d6ddfe5d87c3dd98270e0e028ed04767c87d4ca 100644 --- a/src/app/signatureBook/controllers/SignatureBookController.php +++ b/src/app/signatureBook/controllers/SignatureBookController.php @@ -169,7 +169,8 @@ class SignatureBookController 'alt_id' => $incomingMail['alt_identifier'], 'title' => $incomingMail['subject'], 'category_id' => $incomingMail['category_id'], - 'viewerLink' => "index.php?display=true&dir=indexing_searching&page=view_resource_controler&visu&id={$resId}&collid=letterbox_coll", + //'viewerLink' => "index.php?display=true&dir=indexing_searching&page=view_resource_controler&visu&id={$resId}&collid=letterbox_coll", + 'viewerLink' => "../../rest/res/{$resId}/content", 'thumbnailLink' => "rest/res/{$resId}/thumbnail" ] ]; @@ -320,7 +321,12 @@ class SignatureBookController if(!in_array(strtoupper($value['format']), ['PDF', 'JPG', 'JPEG', 'PNG', 'GIF']) ){ $isVersion = 'false'; } - $attachments[$key]['viewerLink'] = "index.php?display=true&module=attachments&page=view_attachment&res_id_master={$aArgs['resId']}&id={$viewerId}&isVersion={$isVersion}"; + + if ($value['status'] == 'SIGN') { + $attachments[$key]['viewerLink'] = "../../rest/res/{$aArgs['resId']}/attachment/{$viewerId}"; + } else { + $attachments[$key]['viewerLink'] = "../../rest/res/{$aArgs['resId']}/attachment/{$realId}"; + } } $obsAttachments = AttachmentModel::getOnView([