From db73a2093e49555a2f9a0a7d22f20be032849021 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Wed, 8 Aug 2018 15:07:04 +0200 Subject: [PATCH] FEAT #7504 mailing begins --- modules/attachments/attachments_content.php | 16 ++++++++-------- modules/attachments/js/functions.js | 19 ++++++++++++++----- .../content_management/applet_controller.php | 5 +++-- modules/content_management/js/functions.js | 3 +++ .../retrieve_template_from_cm.php | 4 ++-- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/modules/attachments/attachments_content.php b/modules/attachments/attachments_content.php index 3594038c90a..ba4097f0f46 100755 --- a/modules/attachments/attachments_content.php +++ b/modules/attachments/attachments_content.php @@ -1179,12 +1179,14 @@ $objectTable = $sec->retrieve_table_from_coll($_SESSION['collection_id_choice']) $content .= '<h2> '.$title; //multicontact + if (!empty($infoAttach->multi_contact)) { $content .= ' pour le contact : <select style="background-color: #FFF;border: 1px solid #999;color: #666;text-align: left;" id="selectContactIdRes" onchange="loadSelectedContact()">'; foreach ($infoAttach->multi_contact as $key => $value) { $content .= '<option value="'.$value['contact_id'].'#'.$value['address_id'].'#'.$value['format_contact'].'">'.$value['format_contact'].'</option>'; } + $content .= '<option value="mailing">Publipostage</option>'; $content .= '</select>'; $content .= '<script>$j("#selectContactIdRes", window.top.document).change();</script>'; } @@ -1260,12 +1262,10 @@ $content .= '<div class="transmissionDiv" id="addAttach1">'; $content .= '<option value="">'._CHOOSE_MODEL.'</option>'; $content .= '</select>'; - if ($mode == 'add') { - $content .= ' <input type="button" value="'; - $content .= _EDIT_MODEL; - $content .= '" name="templateOffice_edit[]" id="templateOffice_edit" style="display:none;margin-top: 0" class="button" ' - .'onclick="showAppletLauncher(this, \''.$_SESSION['doc_id'].'\',\''.$objectTable.'\',\'attachmentVersion\',\'attachment\');$(\'add\').value=\'Edition en cours ...\';editingDoc(this,\''.$_SESSION['user']['UserId'].'\');$(\'add\').disabled=\'disabled\';$(\'add\').style.opacity=\'0.5\';this.hide();$j(\'#\'+this.id).parent().find(\'[name=templateOffice\\\\[\\\\]]\').css(\'width\',\'206px\');"/>'; - } + $content .= ' <input type="button" value="'; + $content .= _EDIT_MODEL; + $content .= '" name="templateOffice_edit[]" id="templateOffice_edit" style="display:none;margin-top: 0" class="button" ' + .'onclick="showAppletLauncher(this, \''.$_SESSION['doc_id'].'\',\''.$objectTable.'\',\'attachmentVersion\',\'attachment\');$(\'add\').value=\'Edition en cours ...\';editingDoc(this,\''.$_SESSION['user']['UserId'].'\');$(\'add\').disabled=\'disabled\';$(\'add\').style.opacity=\'0.5\';this.hide();$j(\'#\'+this.id).parent().find(\'[name=templateOffice\\\\[\\\\]]\').css(\'width\',\'206px\');"/>'; $content .= '<iframe style="display:none; width:210px" name="choose_file" id="choose_file" frameborder="0" scrolling="no" height="25" src="'.$_SESSION['config']['businessappurl'] .'index.php?display=true&module=attachments&page=choose_attachment"></iframe>'; @@ -1325,7 +1325,7 @@ $content .= '<div class="transmissionDiv" id="addAttach1">'; $content .= "<input type='hidden' name='dataCreationDate' id='dataCreationDate' value='{$dataForDate}' />"; //CONTACT - $content .= '<div style="margin-bottom:10px;">'; + $content .= '<div id="contactDiv" style="margin-bottom:10px;">'; $content .= '<label>'._DEST_USER_PJ; if ($core->test_admin('my_contacts', 'apps', false)) { $content .= ' <a href="#" id="create_multi_contact" title="'._CREATE_CONTACT @@ -1350,7 +1350,7 @@ $content .= '<div class="transmissionDiv" id="addAttach1">'; if ($mode == 'add' && $_GET['cat'] != 'outgoing') { $content .= '<p>'; - $content .= '<div style="float: left">'; + $content .= '<div id="newAttachDiv" style="float: left">'; //ADD ATTACH OTHER ATTACHEMENT $content .= '<input type="button" class="button readonly" id="newAttachButton" value="'._NEW_ATTACH_ADDED.'" title="'._NEW_ATTACH_ADDED.'" onclick="addNewAttach();" disabled="disabled"></input>'; diff --git a/modules/attachments/js/functions.js b/modules/attachments/js/functions.js index 5313cdfebf8..4ea10ad58ee 100755 --- a/modules/attachments/js/functions.js +++ b/modules/attachments/js/functions.js @@ -248,11 +248,20 @@ function setFinalVersion(path) { function loadSelectedContact() { var ContactAndAddress = $('selectContactIdRes').value; - var value = ContactAndAddress.split("#"); - $('contactidAttach').value=value[0]; - $('addressidAttach').value=value[1]; - $('contact_attach').value=value[2]; - $('contact_attach').focus(); + + if (ContactAndAddress == 'mailing') { + $j("#contactDiv").hide(); + $j("#newAttachDiv").hide(); + $j('#contactidAttach').val('mailing'); + } else { + $j("#contactDiv").show(); + $j("#newAttachDiv").show(); + var value = ContactAndAddress.split("#"); + $j('#contactidAttach').val(value[0]); + $j('#addressidAttach').val(value[1]); + $j('#contact_attach').val(value[2]); + $j('#contact_attach').focus(); + } } function createModalinAttachmentList(txt, id_mod, height, width, mode_frm){ diff --git a/modules/content_management/applet_controller.php b/modules/content_management/applet_controller.php index fec70dbb902..3032d8c1f9b 100755 --- a/modules/content_management/applet_controller.php +++ b/modules/content_management/applet_controller.php @@ -149,6 +149,7 @@ if (!empty($_REQUEST['action']) && $objectType <> 'attachmentFromTemplate' && $objectType <> 'attachment' && $objectType <> 'attachmentVersion' + && $objectType <> 'attachmentMailing' && $objectType <> 'outgoingMail' && $objectType <> 'attachmentUpVersion' && $objectType <> 'newAttachment' @@ -282,7 +283,7 @@ if (!empty($_REQUEST['action']) fclose($inF); //Récupération de la version pdf du document - if ($_SESSION['modules_loaded']['attachments']['convertPdf'] == "true" && ($objectType == 'attachmentFromTemplate' || $objectType == 'attachment' || $objectType == 'attachmentUpVersion' || $objectType == 'attachmentVersion' || $objectType == 'outgoingMail' || $objectType == 'resourceEdit' || $objectType == 'transmission' || $objectType == 'newAttachment') && isset($_REQUEST['pdfContent'])) { + if ($_SESSION['modules_loaded']['attachments']['convertPdf'] == "true" && ($objectType == 'attachmentFromTemplate' || $objectType == 'attachment' || $objectType == 'attachmentUpVersion' || $objectType == 'attachmentVersion' || $objectType == 'attachmentMailing' || $objectType == 'outgoingMail' || $objectType == 'resourceEdit' || $objectType == 'transmission' || $objectType == 'newAttachment') && isset($_REQUEST['pdfContent'])) { $pdfEncodedContent = str_replace( ' ', '+', @@ -325,7 +326,7 @@ if (!empty($_REQUEST['action']) } elseif ($objectType == 'templateStyle' || $objectType == 'template') { include 'modules/content_management/save_template_from_cm.php'; //ADD - EDIT NEW ATTACHMENT (FOR TEMPORARY SAVE) - } elseif ($objectType == 'attachmentVersion' || $objectType == 'attachmentUpVersion' || $objectType == 'outgoingMail' || $objectType == 'newAttachment') { + } elseif ($objectType == 'attachmentVersion' || $objectType == 'attachmentMailing' || $objectType == 'attachmentUpVersion' || $objectType == 'outgoingMail' || $objectType == 'newAttachment') { include 'modules/content_management/save_attachment_from_cm.php'; } diff --git a/modules/content_management/js/functions.js b/modules/content_management/js/functions.js index f274b495efc..09d8e4dbdc1 100755 --- a/modules/content_management/js/functions.js +++ b/modules/content_management/js/functions.js @@ -181,6 +181,9 @@ function showAppletLauncher(target, resId, objectTable, objectType, mode) { back_date = ''; } var backDateStatus = $j('#'+target.id).parent().parent().find('[name=backDateStatus\\[\\]]').val(); + if (objectType == 'attachmentVersion' && $('selectContactIdRes').value == 'mailing') { + objectType = 'attachmentMailing'; + } var path = 'index.php?display=true&module=content_management&page=applet_modal_launcher&uniqueId='+attachNum+'&objectType='+objectType+'&objectId='+templateOffice+'&attachType='+attachment_types+'&objectTable=' + objectTable + '&contactId='+contactidAttach+'&addressId='+addressidAttach+'&chronoAttachment='+chrono+'&titleAttachment='+title+'&backDateStatus='+backDateStatus+'&back_date='+back_date+'&resMaster=' + resId } diff --git a/modules/content_management/retrieve_template_from_cm.php b/modules/content_management/retrieve_template_from_cm.php index 62c9061ea7c..81cdf5d6bf4 100755 --- a/modules/content_management/retrieve_template_from_cm.php +++ b/modules/content_management/retrieve_template_from_cm.php @@ -17,7 +17,7 @@ if ($objectType == 'templateStyle') { ); createXML('ERROR', $result); } -} elseif ($objectType == 'template' || $objectType == 'attachmentFromTemplate' || $objectType == 'attachmentVersion' || $objectType == 'outgoingMail' || $objectType == 'transmission') { +} elseif ($objectType == 'template' || $objectType == 'attachmentFromTemplate' || $objectType == 'attachmentVersion' || $objectType == 'attachmentMailing' || $objectType == 'outgoingMail' || $objectType == 'transmission') { if ($_SESSION['m_admin']['templates']['current_style'] <> '') { // edition in progress $fileExtension = $func->extractFileExt( @@ -48,7 +48,7 @@ if ($objectType == 'templateStyle') { $filePathOnTmp = $templateCtrl->merge($objectId, $params, 'file'); $templateObj = $templateCtrl->get($objectId); $_SESSION['cm']['templateStyle'] = $templateObj->template_style; - } elseif ($objectType == 'template') { + } elseif ($objectType == 'template' || $objectType == 'attachmentMailing') { $filePathOnTmp = $templateCtrl->copyTemplateOnTmp($objectId); if ($filePathOnTmp == '') { $result = array('ERROR' => _FAILED_TO_COPY_ON_TMP -- GitLab