From 1baa1a5a6638ef1e3219adbf8785dcb7fb7097d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 16 Jul 2024 17:59:33 +0200 Subject: [PATCH 01/11] #1003 [Documents] fix: documents list sort order & field --- lib/documents.lib.php | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 2ac4b817..6c915114 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -46,9 +46,11 @@ * @param string $removeaction (optional) The action to remove a file * @param int $active (optional) To show gen button disabled * @param string $tooltiptext (optional) Tooltip text when gen button disabled + * @param string $sortfield (optional) Allows to sort the list of files by a field + * @param string $sortorder (optional) Allows to sort the list of files with a specific order * @return string Output string with HTML array of documents (might be empty string) */ -function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, string $urlsource, $genallowed, int $delallowed = 0, string $modelselected = '', int $allowgenifempty = 1, int $forcenomultilang = 0, int $notused = 0, int $noform = 0, string $param = '', string $title = '', string $buttonlabel = '', string $codelang = '', string $morepicto = '', $object = null, int $hideifempty = 0, string $removeaction = 'remove_file', int $active = 1, string $tooltiptext = ''): string +function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, string $urlsource, $genallowed, int $delallowed = 0, string $modelselected = '', int $allowgenifempty = 1, int $forcenomultilang = 0, int $notused = 0, int $noform = 0, string $param = '', string $title = '', string $buttonlabel = '', string $codelang = '', string $morepicto = '', $object = null, int $hideifempty = 0, string $removeaction = 'remove_file', int $active = 1, string $tooltiptext = '', string $sortfield = '', string $sortorder = ''): string { global $conf, $db, $form, $hookmanager, $langs; @@ -63,6 +65,23 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $param .= ($param ? '&' : '') . 'entity=' . (!empty($object->entity) ? $object->entity : $conf->entity); } + if (empty($sortfield)) { + if (GETPOST('sortfield')) { + $sortfield = GETPOST('sortfield'); + } else { + $sortfield = 'name'; + } + } + + + if (empty($sortorder)) { + if (GETPOST('sortorder')) { + $sortorder = GETPOST('sortorder'); + } else { + $sortorder = 'desc'; + } + } + $hookmanager->initHooks(['formfile']); // Get list of files @@ -239,7 +258,20 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str if ($conf->global->$manualPdfGenerationConf > 0) { $out .= ''; } + $out .= ''; + $out .= ''; + $out .= '' . $langs->trans('Name'); + $out .= ''; + $out .= '' . $langs->trans('Size'); + $out .= ''; + $out .= '' . $langs->trans('Date'); + $out .= ''; + $out .= '' . $langs->trans('PDF'); + $out .= ''; + $out .= '' . $langs->trans('Action'); + $out .= ''; + $out .= ''; // Execute hooks $parameters = ['colspan' => ($colspan + $colspanmore), 'socid' => ($GLOBALS['socid'] ?? ''), 'id' => ($GLOBALS['id'] ?? ''), 'modulepart' => $modulepart]; @@ -258,7 +290,6 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str if (is_object($object) && $object->id > 0) { require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $link = new Link($db); - $sortfield = $sortorder = null; $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } @@ -271,6 +302,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= '
'; $out .= '' . "\n"; } + $fileList = dol_sort_array($fileList, $sortfield, $sortorder); // Loop on each file found if (is_array($fileList)) { From 6e6d570d91948c484148b862bb578d7b31464c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 23 Jul 2024 11:31:44 +0200 Subject: [PATCH 02/11] #1003 [Documents] fix: documents sortable list --- lib/documents.lib.php | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 6c915114..22b67b46 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -258,19 +258,14 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str if ($conf->global->$manualPdfGenerationConf > 0) { $out .= ''; } - $out .= ''; $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= get_document_title_field($sortfield, $sortorder, 'Name'); + $out .= get_document_title_field($sortfield, $sortorder, 'Size', true, 'right'); + $out .= get_document_title_field($sortfield, $sortorder, 'Date', true, 'right'); + $out .= get_document_title_field($sortfield, $sortorder, 'PDF', false, 'right'); + $out .= get_document_title_field($sortfield, $sortorder, 'Action', false, 'right'); +// $out .= ''; $out .= ''; // Execute hooks @@ -444,6 +439,24 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str return $out; } +function get_document_title_field(string $sortfield, string $sortorder, string $name, bool $sortable = true, string $morehtml = ''): string { + global $langs; + + $out = ''; + return $out; +} + /** * Exclude index.php files from list of models for document generation * From 124ea38da433c7cb93e2525dde31107b7a1d9e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 23 Jul 2024 15:39:01 +0200 Subject: [PATCH 03/11] #1003 [Documents] fix: add pagination & filters on documents list --- js/modules/document.js | 99 ++++++++++++++++++++++++++++++++++++++++++ js/saturne.min.js | 2 +- lib/documents.lib.php | 35 +++++++++++++-- 3 files changed, 132 insertions(+), 4 deletions(-) diff --git a/js/modules/document.js b/js/modules/document.js index 51f305fd..43679bbc 100644 --- a/js/modules/document.js +++ b/js/modules/document.js @@ -55,6 +55,11 @@ window.saturne.document.event = function() { $(document).on('click', '#builddoc_generatebutton', window.saturne.document.displayLoader); $(document).on('click', '.pdf-generation', window.saturne.document.displayLoader); $(document).on('click', '.download-template', window.saturne.document.autoDownloadTemplate); + $(document).on( 'keydown', '#change_pagination', window.saturne.document.changePagination ); + $(document).on( 'keydown', '.saturne-search', window.saturne.document.saturneSearch ); + $(document).on( 'click', '.saturne-search-button', window.saturne.document.saturneSearch ); + $(document).on( 'click', '.saturne-cancel-button', window.saturne.document.saturneCancelSearch ); + }; /** @@ -103,3 +108,97 @@ window.saturne.document.autoDownloadTemplate = function() { error: function () {} }); }; + +/** + * Manage documents list pagination + * + * @memberof Saturne_Framework_Document + * + * @since 1.6.0 + * @version 1.6.0 + * + * @return {void} + */ +window.saturne.document.changePagination = function (event) { + if (event.keyCode === 13) { + event.preventDefault(); + + var input = event.target; + var pageNumber = $('#page_number').val(); + var pageValue = parseInt(input.value) <= parseInt(pageNumber) ? input.value : pageNumber; + var currentUrl = new URL(window.location.href); + + if (currentUrl.searchParams.has('page')) { + currentUrl.searchParams.set('page', pageValue); + } else { + currentUrl.searchParams.append('page', pageValue); + } + + window.location.replace(currentUrl.toString()); + } +} + +/** + * Manage search on documents list + * + * @memberof Saturne_Framework_Document + * + * @since 1.6.0 + * @version 1.6.0 + * + * @return {void} + */ +window.saturne.document.saturneSearch = function (event) { + if (event.keyCode === 13 || $(this).hasClass('saturne-search-button')) { + event.preventDefault(); + + var currentUrl = new URL(window.location.href); + + let name = $('#search_name').val(); + let date = $('#search_date').val(); + + if (name === '' && date === '') { + return; + } + if (name.length > 0) { + if (currentUrl.searchParams.has('search_name')) { + currentUrl.searchParams.set('search_name', name); + } else { + currentUrl.searchParams.append('search_name', name); + } + } + if (date.length > 0) { + if (currentUrl.searchParams.has('search_date')) { + currentUrl.searchParams.set('search_date', date); + } else { + currentUrl.searchParams.append('search_date', date); + } + } + window.location.replace(currentUrl.toString()); + + } +} + +/** + * Cancel search on documents list + * + * @memberof Saturne_Framework_Document + * + * @since 1.6.0 + * @version 1.6.0 + * + * @return {void} + */ +window.saturne.document.saturneCancelSearch = function (event) { + event.preventDefault(); + + var currentUrl = new URL(window.location.href); + + if (currentUrl.searchParams.has('search_name')) { + currentUrl.searchParams.delete('search_name'); + } + if (currentUrl.searchParams.has('search_date')) { + currentUrl.searchParams.delete('search_date'); + } + window.location.replace(currentUrl.toString()); +} diff --git a/js/saturne.min.js b/js/saturne.min.js index fd81cbea..a587006d 100644 --- a/js/saturne.min.js +++ b/js/saturne.min.js @@ -1 +1 @@ -window.saturne||(window.saturne={},window.saturne.scriptsLoaded=!1),window.saturne.scriptsLoaded||(window.saturne.init=function(){window.saturne.load_list_script()},window.saturne.load_list_script=function(){if(!window.saturne.scriptsLoaded){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].init&&window.saturne[e].init(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].init&&window.saturne[e][t].init();window.saturne.scriptsLoaded=!0}},window.saturne.refresh=function(){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].refresh&&window.saturne[e].refresh(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].refresh&&window.saturne[e][t].refresh()},$(document).ready(window.saturne.init)),window.saturne.button={},window.saturne.button.init=function(){window.saturne.button.event()},window.saturne.button.event=function(){$(document).on("click",".wpeo-button:submit, .wpeo-button.auto-download",window.saturne.button.addLoader)},window.saturne.button.addLoader=function(){$(this).hasClass("no-load")||(window.saturne.loader.display($(this)),$(this).toggleClass("button-blue button-disable"))},window.saturne.dashboard={},window.saturne.dashboard.init=function(){window.saturne.dashboard.event()},window.saturne.dashboard.event=function(){$(document).on("change",".add-dashboard-widget",window.saturne.dashboard.addDashBoardInfo),$(document).on("click",".close-dashboard-widget",window.saturne.dashboard.closeDashBoardInfo),$(document).on("click",".select-dataset-dashboard-info",window.saturne.dashboard.selectDatasetDashboardInfo)},window.saturne.dashboard.addDashBoardInfo=function(){var e=document.getElementById("dashBoardForm"),e=new FormData(e).get("boxcombo"),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+n+"action=adddashboardinfo&token="+t,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(){window.location.reload()},error:function(){}})},window.saturne.dashboard.closeDashBoardInfo=function(){let t=$(this);var e=t.attr("data-widgetname"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+o+"action=closedashboardinfo&token="+n,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(e){t.closest(".box-flex-item").fadeOut(400),$(".add-widget-box").attr("style",""),$(".add-widget-box").html($(e).find(".add-widget-box").children())},error:function(){}})},window.saturne.dashboard.selectDatasetDashboardInfo=function(){var e=$("#search_userid").val(),t=$("#search_year").val(),n=$("#search_month").val(),o=window.saturne.toolbox.getToken(),a=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".fichecenter")),$.ajax({url:document.URL+a+"token="+o+"&search_userid="+e+"&search_year="+t+"&search_month="+n,type:"POST",processData:!1,contentType:!1,success:function(e){$(".fichecenter").replaceWith($(e).find(".fichecenter"))},error:function(){}})},window.saturne.document={},window.saturne.document.init=function(){window.saturne.document.event()},window.saturne.document.event=function(){$(document).on("click","#builddoc_generatebutton",window.saturne.document.displayLoader),$(document).on("click",".pdf-generation",window.saturne.document.displayLoader),$(document).on("click",".download-template",window.saturne.document.autoDownloadTemplate)},window.saturne.document.displayLoader=function(){window.saturne.loader.display($(this).closest(".div-table-responsive-no-min"))},window.saturne.document.autoDownloadTemplate=function(){let t=window.saturne.toolbox.getToken();var e=document.URL.replace(/#.*$/,"");let n=window.saturne.toolbox.getQuerySeparator(e),o=$(this).closest(".file-generation");var a=o.find(".template-type").attr("value");let i=o.find(".template-name").attr("value");$.ajax({url:e+n+"action=download_template&filename="+i+"&type="+a+"&token="+t,type:"POST",success:function(){var e=o.find(".template-path").attr("value");window.saturne.signature.download(e+i,i),$.ajax({url:document.URL+n+"action=remove_file&filename="+i+"&token="+t,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.dropdown={},window.saturne.dropdown.init=function(){window.saturne.dropdown.event()},window.saturne.dropdown.event=function(){$(document).on("keyup",window.saturne.dropdown.keyup),$(document).on("keypress",window.saturne.dropdown.keypress),$(document).on("click",".wpeo-dropdown:not(.dropdown-active) .dropdown-toggle:not(.disabled)",window.saturne.dropdown.open),$(document).on("click",".wpeo-dropdown.dropdown-active .saturne-dropdown-content",function(e){e.stopPropagation()}),$(document).on("click",".wpeo-dropdown.dropdown-active:not(.dropdown-force-display) .saturne-dropdown-content .dropdown-item",window.saturne.dropdown.close),$(document).on("click",".wpeo-dropdown.dropdown-active",function(e){window.saturne.dropdown.close(e),e.stopPropagation()}),$(document).on("click","body",window.saturne.dropdown.close)},window.saturne.dropdown.keyup=function(e){27===e.keyCode&&window.saturne.dropdown.close()},window.saturne.dropdown.keypress=function(e){var t=localStorage.currentString||"",n=localStorage.keypressNumber?+localStorage.keypressNumber:0;t+=e.keyCode,++n,localStorage.setItem("currentString",t),localStorage.setItem("keypressNumber",n),9body{"+e+n+e+t+n+t)},window.saturne.dropdown.open=function(e){var n=$(this),o=n.find("[data-fa-i2svg]"),t={},a=void 0;window.saturne.dropdown.close(e,$(this)),n.attr("data-action")?(window.saturne.loader.display(n),n.get_data(function(e){for(a in t)e[a]||(e[a]=t[a]);window.saturne.request.send(n,e,function(e,t){n.closest(".wpeo-dropdown").find(".saturne-dropdown-content").html(t.data.view),n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)})})):(n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)),e.stopPropagation()},window.saturne.dropdown.close=function(e){var n=$(this);$(".wpeo-dropdown.dropdown-active:not(.no-close)").each(function(){var e=$(this),t={close:!0};n.trigger("dropdown-before-close",[e,n,t]),t.close&&(e.removeClass("dropdown-active"),t=$(this).find(".dropdown-toggle").find("[data-fa-i2svg]"))&&window.saturne.dropdown.toggleAngleClass(t)})},window.saturne.dropdown.toggleAngleClass=function(e){e.hasClass("fa-caret-down")||e.hasClass("fa-caret-up")?e.toggleClass("fa-caret-down").toggleClass("fa-caret-up"):e.hasClass("fa-caret-circle-down")||e.hasClass("fa-caret-circle-up")?e.toggleClass("fa-caret-circle-down").toggleClass("fa-caret-circle-up"):e.hasClass("fa-angle-down")||e.hasClass("fa-angle-up")?e.toggleClass("fa-angle-down").toggleClass("fa-angle-up"):(e.hasClass("fa-chevron-circle-down")||e.hasClass("fa-chevron-circle-up"))&&e.toggleClass("fa-chevron-circle-down").toggleClass("fa-chevron-circle-up")},window.saturne.keyEvent={},window.saturne.keyEvent.init=function(){window.saturne.keyEvent.event()},window.saturne.keyEvent.event=function(){$(document).on("keydown",window.saturne.keyEvent.keyActions),$(document).on("keyup",".url-container",window.saturne.keyEvent.checkUrlFormat)},window.saturne.keyEvent.keyActions=function(e){0<$(this).find(".modal-active").length?("Escape"===e.key&&$(this).find(".modal-active .modal-close .fas.fa-times").first().click(),"Enter"!==e.key||$("input, textarea").is(":focus")||$(this).find(".modal-active .modal-footer .wpeo-button").not(".button-disable").first().click()):$(e.target).is("input, textarea")||("Enter"===e.key&&$(this).find(".button_search").click(),e.shiftKey&&"Enter"===e.key&&$(this).find(".button_removefilter").click())},window.saturne.keyEvent.checkUrlFormat=function(){$(this).val().match(/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi)?$(this).attr("style","border: solid; border-color: green"):0<$("input:focus").val().length&&$(this).attr("style","border: solid; border-color: red")},window.saturne.loader={},window.saturne.loader.init=function(){window.saturne.loader.event()},window.saturne.loader.event=function(){},window.saturne.loader.display=function(e){var t;e.hasClass("button-progress")?e.addClass("button-load"):(e.addClass("wpeo-loader"),t=$(''),e[0].loaderElement=t,e.append(e[0].loaderElement))},window.saturne.loader.remove=function(e){0"),i===a&&($(".wpeo-loader").removeClass("wpeo-loader"),$("#progressBarContainer").fadeOut(800),$("#progressBarContainer").find(".loader-spin").remove(),window.saturne.loader.display(o.find(".ecm-photo-list-content")),setTimeout(()=>{o.html($(e).find("#media_gallery").children()).promise().done(()=>{1==a&&($("#media_gallery").find(".save-photo").removeClass("button-disable"),$("#media_gallery").find(".delete-photo").removeClass("button-disable"),$("#media_gallery").find(".clickable-photo0").addClass("clicked-photo")),($(e).find(".error-medias").length?($(".messageErrorSendPhoto").find(".notice-subtitle").html(m),$(".messageErrorSendPhoto")):$(".messageSuccessSendPhoto")).removeClass("hidden"),o.attr("data-from-id",r),o.attr("data-from-type",s),o.attr("data-from-subtype",l),o.attr("data-from-subdir",c),o.find(".wpeo-button").attr("value",r)})},800))}})})},window.saturne.mediaGallery.previewPhoto=function(e){var t=setInterval(function(){$(".ui-dialog").length&&(clearInterval(t),$(document).find(".ui-dialog").addClass("preview-photo"))},100)},window.saturne.mediaGallery.unlinkFile=function(e){e.preventDefault();let t=window.saturne.toolbox.getToken();var e=$(this).closest(".modal-active"),n=0<$(this).closest(".modal-active").length;let o=null,a=(o=(n?e:$(this).closest(".linked-medias")).find(".modal-options")).attr("data-from-subtype"),i=o.attr("data-from-type"),d=o.attr("data-from-subdir"),r=o.attr("data-from-id"),s=o.attr("data-photo-class");n=$(this).closest(".media-container");let l=n.find(".file-path").val(),c=n.find(".file-name").val(),u=$(this).closest(".linked-medias").find(".media-gallery-favorite.favorite").closest(".media-container").find(".file-name").val(),w=(window.saturne.loader.display(n),window.saturne.toolbox.getQuerySeparator(document.URL));$(".card__confirmation").css("display","flex"),$(document).on("click",".confirmation-close",function(){$(".wpeo-loader").removeClass("wpeo-loader"),$(".card__confirmation").css("display","none")}),$(document).on("click",".confirmation-delete",function(){$.ajax({url:document.URL+w+"subaction=unlinkFile&token="+t,type:"POST",data:JSON.stringify({filepath:l,filename:c,objectSubtype:a,objectType:i,objectSubdir:d,objectId:r}),processData:!1,success:function(e){$(".card__confirmation").css("display","none"),$("#media_gallery .modal-container").replaceWith($(e).find("#media_gallery .modal-container")),u==c&&(void 0!==s&&0"))[1].match(/>/)&&(n[1]=n[1].replace(/>/,"")),$(this).attr("title",n[1]),$(this).html(n[0])}),t.css("width","30px"),t.find(".blockvmenusearch").hide(),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$(this).find("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),localStorage.setItem("maximized","false")):0<$(this).find("span.vmenu").find(".fa-chevron-circle-right").length&&(e.each(function(){$(this).html($(this).html().replace(">","")+" "+$(this).attr("title"))}),t.css("width","188px"),t.find(".blockvmenusearch").show(),$("div.menu_titre").attr("style","width: 188px !important; cursor : pointer"),$("span.vmenu").attr("title"," Réduire le menu"),$("span.vmenu").html(' Réduire le menu'),localStorage.setItem("maximized","true"),$(this).find("span.vmenu").find(".fa-chevron-circle-right").removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-left"))},window.saturne.menu.setMenu=function(){var e,t,n;0<$(".blockvmenu.blockvmenulast .saturne-toggle-menu").length&&($(".blockvmenu.blockvmenulast .saturne-toggle-menu").closest(".menu_titre").attr("style","cursor:pointer ! important"),"false"==localStorage.maximized&&$("#id-left").attr("style","display:none !important"),"false"==localStorage.maximized&&(e="",t=$("#id-left").find("a.vmenu, span.vmenudisabled, span.vmenu, a.vsmenu"),n=$(document).find("div.vmenu"),t.each(function(){e=$(this).html().split(""),$(this).attr("title",e[1]),$(this).html(e[0]),console.log(e)}),$("#id-left").attr("style","display:block !important"),$("div.menu_titre").attr("style","width: 50px !important"),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),n.css("width","30px"),n.find(".blockvmenusearch").hide()),localStorage.setItem("currentString",""),localStorage.setItem("keypressNumber",0))},window.saturne.modal={},window.saturne.modal.init=function(){window.saturne.modal.event()},window.saturne.modal.event=function(){$(document).on("click",".modal-close, .modal-active:not(.modal-container)",window.saturne.modal.closeModal),$(document).on("click",".modal-open",window.saturne.modal.openModal),$(document).on("click",".modal-refresh",window.saturne.modal.refreshModal)},window.saturne.modal.openModal=function(e){var t=$(this).find(".modal-options"),n=t.attr("data-modal-to-open"),o=t.attr("data-from-id"),a=t.attr("data-from-type"),i=t.attr("data-from-subtype"),d=t.attr("data-from-subdir"),r=t.attr("data-from-module"),t=t.attr("data-photo-class");let s="";s=document.URL.match(/#/)?document.URL.split(/#/)[0]:document.URL,history.pushState({path:document.URL},"",s),$("#"+n).attr("data-from-id",o),$("#"+n).attr("data-from-type",a),$("#"+n).attr("data-from-subtype",i),$("#"+n).attr("data-from-subdir",d),$("#"+n).attr("data-photo-class",t),r&&"function"==typeof window.saturne.modal.addMoreOpenModalData&&window.saturne.modal.addMoreOpenModalData(n,$(this)),$("#"+n).find(".wpeo-button").attr("value",o),$("#"+n).addClass("modal-active"),$(".notice").addClass("hidden")},window.saturne.modal.closeModal=function(e){$("input:focus").length<1&&$("textarea:focus").length<1&&($(e.target).hasClass("modal-active")||$(e.target).hasClass("modal-close")||$(e.target).parent().hasClass("modal-close"))&&($(this).closest(".modal-active").removeClass("modal-active"),$(".clicked-photo").attr("style",""),$(".clicked-photo").removeClass("clicked-photo"),$(".notice").addClass("hidden"))},window.saturne.modal.refreshModal=function(e){window.location.reload()},window.saturne.notice={},window.saturne.notice.init=function(){window.saturne.notice.event()},window.saturne.notice.event=function(){$(document).on("click",".notice-close",window.saturne.notice.closeNotice)},window.saturne.notice.closeNotice=function(){$(this).closest(".wpeo-notice").fadeOut(function(){$(this).closest(".wpeo-notice").addClass("hidden")}),$(this).hasClass("notice-close-forever")&&window.saturne.utils.reloadPage("close_notice",".fiche")},window.saturne.object={},window.saturne.object.init=function(){window.saturne.object.event()},window.saturne.object.event=function(){$(document).on("click",".toggle-object-infos",window.saturne.object.toggleObjectInfos)},window.saturne.object.toggleObjectInfos=function(){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.object-infos").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.object-infos").removeClass("hidden"))},window.saturne.signature={},window.saturne.signature.canvas={},window.saturne.signature.init=function(){window.saturne.signature.event()},window.saturne.signature.event=function(){$(document).on("click",".signature-erase",window.saturne.signature.clearCanvas),$(document).on("click",".signature-validate:not(.button-disable)",window.saturne.signature.createSignature),$(document).on("click",".auto-download",window.saturne.signature.autoDownloadSpecimen),$(document).on("click",".copy-signatureurl",window.saturne.signature.copySignatureUrlClipboard),$(document).on("click",".set-attendance",window.saturne.signature.setAttendance),document.querySelector('script[src*="signature-pad.min.js"]')&&window.saturne.signature.drawSignatureOnCanvas(),$(document).on("touchstart mousedown",".canvas-signature",function(){window.saturne.toolbox.removeAddButtonClass("signature-validate","button-grey button-disable","button-blue")})},window.saturne.signature.drawSignatureOnCanvas=function(){var e;window.saturne.signature.canvas=document.querySelector(".canvas-signature"),window.saturne.signature.canvas&&(e=Math.max(window.devicePixelRatio||1,1),window.saturne.signature.canvas.signaturePad=new SignaturePad(window.saturne.signature.canvas,{penColor:"rgb(0, 0, 0)"}),window.saturne.signature.canvas.width=window.saturne.signature.canvas.offsetWidth*e,window.saturne.signature.canvas.height=window.saturne.signature.canvas.offsetHeight*e,window.saturne.signature.canvas.getContext("2d").scale(e,e))},window.saturne.signature.clearCanvas=function(){window.saturne.signature.canvas.signaturePad.clear(),window.saturne.toolbox.removeAddButtonClass("signature-validate","button-blue","button-grey button-disable")},window.saturne.signature.createSignature=function(){var e,t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.signature.canvas.signaturePad.isEmpty()||(e=window.saturne.signature.canvas.toDataURL()),window.saturne.loader.display($(this)),$.ajax({url:document.URL+n+"action=add_signature&token="+t,type:"POST",processData:!1,contentType:"application/octet-stream",data:JSON.stringify({signature:e}),success:function(e){!0===$(".public-card__container").data("public-interface")?($(".card__confirmation").removeAttr("style"),$(".signature-confirmation-close").attr("onclick","window.close()"),$(".public-card__container").replaceWith($(e).find(".public-card__container"))):window.location.reload()},error:function(){}})},window.saturne.signature.download=function(e,t){var n=document.createElement("a");n.href=e,n.setAttribute("download",t),n.click()},window.saturne.signature.autoDownloadSpecimen=function(){let o=$(this).closest(".file-generation"),a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action=builddoc&token="+a,type:"POST",success:function(e){var t=o.find(".specimen-name").attr("data-specimen-name"),n=o.find(".specimen-path").attr("data-specimen-path");window.saturne.signature.download(n+t,t),$(".file-generation").replaceWith($(e).find(".file-generation")),$.ajax({url:document.URL+i+"action=remove_file&token="+a,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.signature.copySignatureUrlClipboard=function(){var e=$(this).attr("data-signature-url");navigator.clipboard.writeText(e).then(()=>{$(this).attr("class","fas fa-check copy-signatureurl"),$(this).css("color","#59ed9c"),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").attr("style",""),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").fadeOut(2500,()=>{$(this).attr("class","fas fa-clipboard copy-signatureurl"),$(this).css("color","#666")})})},window.saturne.signature.setAttendance=function(){var e=$(this).closest(".attendance-container").find('input[name="signatoryID"]').val(),t=$(this).attr("value"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL),a=String(document.location.href).replace(/#formmail/,"");$.ajax({url:a+o+"action=set_attendance&token="+n,type:"POST",processData:!1,contentType:"",data:JSON.stringify({signatoryID:e,attendance:t}),success:function(e){$(".signatures-container").html($(e).find(".signatures-container"))},error:function(){}})},window.saturne.toolbox={},window.saturne.toolbox.init=function(){},window.saturne.toolbox.getQuerySeparator=function(e){return e.match(/\?/)?"&":"?"},window.saturne.toolbox.getToken=function(){return $('input[name="token"]').val()},window.saturne.toolbox.toggleButtonClass=function(e,t){$("."+e).toggleClass(t)},window.saturne.toolbox.removeAddButtonClass=function(e,t,n){$("."+e).removeClass(t).addClass(n)},window.saturne.tooltip||(window.saturne.tooltip={},window.saturne.tooltip.init=function(){window.saturne.tooltip.event()},window.saturne.tooltip.tabChanged=function(){$(".wpeo-tooltip").remove()},window.saturne.tooltip.event=function(){$(document).on("mouseenter touchstart",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onEnter),$(document).on("mouseleave touchend",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onOut)},window.saturne.tooltip.onEnter=function(e){window.saturne.tooltip.display($(this))},window.saturne.tooltip.onOut=function(e){window.saturne.tooltip.remove($(this))},window.saturne.tooltip.display=function(e){var t=$(e).data("direction")?$(e).data("direction"):"top",n=$(''+$(e).attr("aria-label")+""),o=($(e).position(),$(e).offset()),a=($(e)[0].tooltipElement=n,$("body").append($(e)[0].tooltipElement),$(e).data("color")&&n.addClass("tooltip-"+$(e).data("color")),0),i=0;switch($(e).data("direction")){case"left":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left-n.outerWidth()-10+3+"px";break;case"right":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left+$(e).outerWidth()+8+"px";break;case"bottom":a=o.top+$(e).height()+10+10+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px";break;default:a=o.top-n.outerHeight()-4+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px"}n.css({top:a,left:i,opacity:1}),$(e).on("remove",function(){$($(e)[0].tooltipElement).remove()})},window.saturne.tooltip.remove=function(e){$(e)[0]&&$(e)[0].tooltipElement&&$($(e)[0].tooltipElement).remove()}),window.saturne.utils={},window.saturne.utils.init=function(){window.saturne.utils.event()},window.saturne.utils.event=function(){$(document).on("mouseenter",".move-line.ui-sortable-handle",window.saturne.utils.draganddrop),$(document).on("change","#element_type",window.saturne.utils.reloadField)},window.saturne.utils.draganddrop=function(){$(this).css("cursor","pointer"),$("#tablelines tbody").sortable(),$("#tablelines tbody").sortable({handle:".move-line",connectWith:"#tablelines tbody .line-row",tolerance:"intersect",over:function(){$(this).css("cursor","grabbing")},stop:function(){$(this).css("cursor","default");var e=$(".fiche").find('input[name="token"]').val();let t="&",n=(document.URL.match(/action=/)&&(document.URL=document.URL.split(/\?/)[0],t="?"),[]);$(".line-row").each(function(){n.push($(this).attr("id"))}),$.ajax({url:document.URL+t+"action=moveLine&token="+e,type:"POST",data:JSON.stringify({order:n}),processData:!1,contentType:!1,success:function(){},error:function(){}})}})},window.saturne.utils.reloadPage=function(e,t,n="",o=""){var a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action="+e+n+"&token="+a,type:"POST",processData:!1,contentType:!1,success:function(e){window.saturne.utils.checkMoreParams(o),$(t).replaceWith($(e).find(t))},error:function(){}})},window.saturne.utils.reloadField=function(){var e=$(this).val(),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".field_element_type")),window.saturne.loader.display($(".field_fk_element")),$.ajax({url:document.URL+n+"element_type="+e+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(e){$(".field_element_type").replaceWith($(e).find(".field_element_type")),$(".field_fk_element").replaceWith($(e).find(".field_fk_element"))},error:function(){}})},window.saturne.utils.enforceMinMax=function(e){""!==e.value&&(parseInt(e.value)parseInt(e.max))&&(e.value=e.max)},window.saturne.utils.checkMoreParams=function(e){e&&e.removeAttr&&$(e.removeAttr.element).removeAttr(e.removeAttr.value)}; \ No newline at end of file +window.saturne||(window.saturne={},window.saturne.scriptsLoaded=!1),window.saturne.scriptsLoaded||(window.saturne.init=function(){window.saturne.load_list_script()},window.saturne.load_list_script=function(){if(!window.saturne.scriptsLoaded){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].init&&window.saturne[e].init(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].init&&window.saturne[e][t].init();window.saturne.scriptsLoaded=!0}},window.saturne.refresh=function(){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].refresh&&window.saturne[e].refresh(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].refresh&&window.saturne[e][t].refresh()},$(document).ready(window.saturne.init)),window.saturne.button={},window.saturne.button.init=function(){window.saturne.button.event()},window.saturne.button.event=function(){$(document).on("click",".wpeo-button:submit, .wpeo-button.auto-download",window.saturne.button.addLoader)},window.saturne.button.addLoader=function(){$(this).hasClass("no-load")||(window.saturne.loader.display($(this)),$(this).toggleClass("button-blue button-disable"))},window.saturne.dashboard={},window.saturne.dashboard.init=function(){window.saturne.dashboard.event()},window.saturne.dashboard.event=function(){$(document).on("change",".add-dashboard-widget",window.saturne.dashboard.addDashBoardInfo),$(document).on("click",".close-dashboard-widget",window.saturne.dashboard.closeDashBoardInfo),$(document).on("click",".select-dataset-dashboard-info",window.saturne.dashboard.selectDatasetDashboardInfo)},window.saturne.dashboard.addDashBoardInfo=function(){var e=document.getElementById("dashBoardForm"),e=new FormData(e).get("boxcombo"),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+n+"action=adddashboardinfo&token="+t,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(){window.location.reload()},error:function(){}})},window.saturne.dashboard.closeDashBoardInfo=function(){let t=$(this);var e=t.attr("data-widgetname"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+o+"action=closedashboardinfo&token="+n,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(e){t.closest(".box-flex-item").fadeOut(400),$(".add-widget-box").attr("style",""),$(".add-widget-box").html($(e).find(".add-widget-box").children())},error:function(){}})},window.saturne.dashboard.selectDatasetDashboardInfo=function(){var e=$("#search_userid").val(),t=$("#search_year").val(),n=$("#search_month").val(),o=window.saturne.toolbox.getToken(),a=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".fichecenter")),$.ajax({url:document.URL+a+"token="+o+"&search_userid="+e+"&search_year="+t+"&search_month="+n,type:"POST",processData:!1,contentType:!1,success:function(e){$(".fichecenter").replaceWith($(e).find(".fichecenter"))},error:function(){}})},window.saturne.document={},window.saturne.document.init=function(){window.saturne.document.event()},window.saturne.document.event=function(){$(document).on("click","#builddoc_generatebutton",window.saturne.document.displayLoader),$(document).on("click",".pdf-generation",window.saturne.document.displayLoader),$(document).on("click",".download-template",window.saturne.document.autoDownloadTemplate),$(document).on("keydown","#change_pagination",window.saturne.document.changePagination),$(document).on("keydown",".saturne-search",window.saturne.document.saturneSearch),$(document).on("click",".saturne-search-button",window.saturne.document.saturneSearch),$(document).on("click",".saturne-cancel-button",window.saturne.document.saturneCancelSearch)},window.saturne.document.displayLoader=function(){window.saturne.loader.display($(this).closest(".div-table-responsive-no-min"))},window.saturne.document.autoDownloadTemplate=function(){let t=window.saturne.toolbox.getToken();var e=document.URL.replace(/#.*$/,"");let n=window.saturne.toolbox.getQuerySeparator(e),o=$(this).closest(".file-generation");var a=o.find(".template-type").attr("value");let i=o.find(".template-name").attr("value");$.ajax({url:e+n+"action=download_template&filename="+i+"&type="+a+"&token="+t,type:"POST",success:function(){var e=o.find(".template-path").attr("value");window.saturne.signature.download(e+i,i),$.ajax({url:document.URL+n+"action=remove_file&filename="+i+"&token="+t,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.document.changePagination=function(e){var t;13===e.keyCode&&(e.preventDefault(),e=e.target,t=$("#page_number").val(),e=parseInt(e.value)<=parseInt(t)?e.value:t,(t=new URL(window.location.href)).searchParams.has("page")?t.searchParams.set("page",e):t.searchParams.append("page",e),window.location.replace(t.toString()))},window.saturne.document.saturneSearch=function(e){var t,n;13!==e.keyCode&&!$(this).hasClass("saturne-search-button")||(e.preventDefault(),e=new URL(window.location.href),t=$("#search_name").val(),n=$("#search_date").val(),""===t&&""===n)||(0body{"+e+n+e+t+n+t)},window.saturne.dropdown.open=function(e){var n=$(this),o=n.find("[data-fa-i2svg]"),t={},a=void 0;window.saturne.dropdown.close(e,$(this)),n.attr("data-action")?(window.saturne.loader.display(n),n.get_data(function(e){for(a in t)e[a]||(e[a]=t[a]);window.saturne.request.send(n,e,function(e,t){n.closest(".wpeo-dropdown").find(".saturne-dropdown-content").html(t.data.view),n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)})})):(n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)),e.stopPropagation()},window.saturne.dropdown.close=function(e){var n=$(this);$(".wpeo-dropdown.dropdown-active:not(.no-close)").each(function(){var e=$(this),t={close:!0};n.trigger("dropdown-before-close",[e,n,t]),t.close&&(e.removeClass("dropdown-active"),t=$(this).find(".dropdown-toggle").find("[data-fa-i2svg]"))&&window.saturne.dropdown.toggleAngleClass(t)})},window.saturne.dropdown.toggleAngleClass=function(e){e.hasClass("fa-caret-down")||e.hasClass("fa-caret-up")?e.toggleClass("fa-caret-down").toggleClass("fa-caret-up"):e.hasClass("fa-caret-circle-down")||e.hasClass("fa-caret-circle-up")?e.toggleClass("fa-caret-circle-down").toggleClass("fa-caret-circle-up"):e.hasClass("fa-angle-down")||e.hasClass("fa-angle-up")?e.toggleClass("fa-angle-down").toggleClass("fa-angle-up"):(e.hasClass("fa-chevron-circle-down")||e.hasClass("fa-chevron-circle-up"))&&e.toggleClass("fa-chevron-circle-down").toggleClass("fa-chevron-circle-up")},window.saturne.keyEvent={},window.saturne.keyEvent.init=function(){window.saturne.keyEvent.event()},window.saturne.keyEvent.event=function(){$(document).on("keydown",window.saturne.keyEvent.keyActions),$(document).on("keyup",".url-container",window.saturne.keyEvent.checkUrlFormat)},window.saturne.keyEvent.keyActions=function(e){0<$(this).find(".modal-active").length?("Escape"===e.key&&$(this).find(".modal-active .modal-close .fas.fa-times").first().click(),"Enter"!==e.key||$("input, textarea").is(":focus")||$(this).find(".modal-active .modal-footer .wpeo-button").not(".button-disable").first().click()):$(e.target).is("input, textarea")||("Enter"===e.key&&$(this).find(".button_search").click(),e.shiftKey&&"Enter"===e.key&&$(this).find(".button_removefilter").click())},window.saturne.keyEvent.checkUrlFormat=function(){$(this).val().match(/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi)?$(this).attr("style","border: solid; border-color: green"):0<$("input:focus").val().length&&$(this).attr("style","border: solid; border-color: red")},window.saturne.loader={},window.saturne.loader.init=function(){window.saturne.loader.event()},window.saturne.loader.event=function(){},window.saturne.loader.display=function(e){var t;e.hasClass("button-progress")?e.addClass("button-load"):(e.addClass("wpeo-loader"),t=$(''),e[0].loaderElement=t,e.append(e[0].loaderElement))},window.saturne.loader.remove=function(e){0"),i===a&&($(".wpeo-loader").removeClass("wpeo-loader"),$("#progressBarContainer").fadeOut(800),$("#progressBarContainer").find(".loader-spin").remove(),window.saturne.loader.display(o.find(".ecm-photo-list-content")),setTimeout(()=>{o.html($(e).find("#media_gallery").children()).promise().done(()=>{1==a&&($("#media_gallery").find(".save-photo").removeClass("button-disable"),$("#media_gallery").find(".delete-photo").removeClass("button-disable"),$("#media_gallery").find(".clickable-photo0").addClass("clicked-photo")),($(e).find(".error-medias").length?($(".messageErrorSendPhoto").find(".notice-subtitle").html(m),$(".messageErrorSendPhoto")):$(".messageSuccessSendPhoto")).removeClass("hidden"),o.attr("data-from-id",r),o.attr("data-from-type",s),o.attr("data-from-subtype",l),o.attr("data-from-subdir",c),o.find(".wpeo-button").attr("value",r)})},800))}})})},window.saturne.mediaGallery.previewPhoto=function(e){var t=setInterval(function(){$(".ui-dialog").length&&(clearInterval(t),$(document).find(".ui-dialog").addClass("preview-photo"))},100)},window.saturne.mediaGallery.unlinkFile=function(e){e.preventDefault();let t=window.saturne.toolbox.getToken();var e=$(this).closest(".modal-active"),n=0<$(this).closest(".modal-active").length;let o=null,a=(o=(n?e:$(this).closest(".linked-medias")).find(".modal-options")).attr("data-from-subtype"),i=o.attr("data-from-type"),d=o.attr("data-from-subdir"),r=o.attr("data-from-id"),s=o.attr("data-photo-class");n=$(this).closest(".media-container");let l=n.find(".file-path").val(),c=n.find(".file-name").val(),u=$(this).closest(".linked-medias").find(".media-gallery-favorite.favorite").closest(".media-container").find(".file-name").val(),w=(window.saturne.loader.display(n),window.saturne.toolbox.getQuerySeparator(document.URL));$(".card__confirmation").css("display","flex"),$(document).on("click",".confirmation-close",function(){$(".wpeo-loader").removeClass("wpeo-loader"),$(".card__confirmation").css("display","none")}),$(document).on("click",".confirmation-delete",function(){$.ajax({url:document.URL+w+"subaction=unlinkFile&token="+t,type:"POST",data:JSON.stringify({filepath:l,filename:c,objectSubtype:a,objectType:i,objectSubdir:d,objectId:r}),processData:!1,success:function(e){$(".card__confirmation").css("display","none"),$("#media_gallery .modal-container").replaceWith($(e).find("#media_gallery .modal-container")),u==c&&(void 0!==s&&0"))[1].match(/>/)&&(n[1]=n[1].replace(/>/,"")),$(this).attr("title",n[1]),$(this).html(n[0])}),t.css("width","30px"),t.find(".blockvmenusearch").hide(),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$(this).find("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),localStorage.setItem("maximized","false")):0<$(this).find("span.vmenu").find(".fa-chevron-circle-right").length&&(e.each(function(){$(this).html($(this).html().replace(">","")+" "+$(this).attr("title"))}),t.css("width","188px"),t.find(".blockvmenusearch").show(),$("div.menu_titre").attr("style","width: 188px !important; cursor : pointer"),$("span.vmenu").attr("title"," Réduire le menu"),$("span.vmenu").html(' Réduire le menu'),localStorage.setItem("maximized","true"),$(this).find("span.vmenu").find(".fa-chevron-circle-right").removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-left"))},window.saturne.menu.setMenu=function(){var e,t,n;0<$(".blockvmenu.blockvmenulast .saturne-toggle-menu").length&&($(".blockvmenu.blockvmenulast .saturne-toggle-menu").closest(".menu_titre").attr("style","cursor:pointer ! important"),"false"==localStorage.maximized&&$("#id-left").attr("style","display:none !important"),"false"==localStorage.maximized&&(e="",t=$("#id-left").find("a.vmenu, span.vmenudisabled, span.vmenu, a.vsmenu"),n=$(document).find("div.vmenu"),t.each(function(){e=$(this).html().split(""),$(this).attr("title",e[1]),$(this).html(e[0]),console.log(e)}),$("#id-left").attr("style","display:block !important"),$("div.menu_titre").attr("style","width: 50px !important"),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),n.css("width","30px"),n.find(".blockvmenusearch").hide()),localStorage.setItem("currentString",""),localStorage.setItem("keypressNumber",0))},window.saturne.modal={},window.saturne.modal.init=function(){window.saturne.modal.event()},window.saturne.modal.event=function(){$(document).on("click",".modal-close, .modal-active:not(.modal-container)",window.saturne.modal.closeModal),$(document).on("click",".modal-open",window.saturne.modal.openModal),$(document).on("click",".modal-refresh",window.saturne.modal.refreshModal)},window.saturne.modal.openModal=function(e){var t=$(this).find(".modal-options"),n=t.attr("data-modal-to-open"),o=t.attr("data-from-id"),a=t.attr("data-from-type"),i=t.attr("data-from-subtype"),d=t.attr("data-from-subdir"),r=t.attr("data-from-module"),t=t.attr("data-photo-class");let s="";s=document.URL.match(/#/)?document.URL.split(/#/)[0]:document.URL,history.pushState({path:document.URL},"",s),$("#"+n).attr("data-from-id",o),$("#"+n).attr("data-from-type",a),$("#"+n).attr("data-from-subtype",i),$("#"+n).attr("data-from-subdir",d),$("#"+n).attr("data-photo-class",t),r&&"function"==typeof window.saturne.modal.addMoreOpenModalData&&window.saturne.modal.addMoreOpenModalData(n,$(this)),$("#"+n).find(".wpeo-button").attr("value",o),$("#"+n).addClass("modal-active"),$(".notice").addClass("hidden")},window.saturne.modal.closeModal=function(e){$("input:focus").length<1&&$("textarea:focus").length<1&&($(e.target).hasClass("modal-active")||$(e.target).hasClass("modal-close")||$(e.target).parent().hasClass("modal-close"))&&($(this).closest(".modal-active").removeClass("modal-active"),$(".clicked-photo").attr("style",""),$(".clicked-photo").removeClass("clicked-photo"),$(".notice").addClass("hidden"))},window.saturne.modal.refreshModal=function(e){window.location.reload()},window.saturne.notice={},window.saturne.notice.init=function(){window.saturne.notice.event()},window.saturne.notice.event=function(){$(document).on("click",".notice-close",window.saturne.notice.closeNotice)},window.saturne.notice.closeNotice=function(){$(this).closest(".wpeo-notice").fadeOut(function(){$(this).closest(".wpeo-notice").addClass("hidden")}),$(this).hasClass("notice-close-forever")&&window.saturne.utils.reloadPage("close_notice",".fiche")},window.saturne.object={},window.saturne.object.init=function(){window.saturne.object.event()},window.saturne.object.event=function(){$(document).on("click",".toggle-object-infos",window.saturne.object.toggleObjectInfos)},window.saturne.object.toggleObjectInfos=function(){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.object-infos").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.object-infos").removeClass("hidden"))},window.saturne.signature={},window.saturne.signature.canvas={},window.saturne.signature.init=function(){window.saturne.signature.event()},window.saturne.signature.event=function(){$(document).on("click",".signature-erase",window.saturne.signature.clearCanvas),$(document).on("click",".signature-validate:not(.button-disable)",window.saturne.signature.createSignature),$(document).on("click",".auto-download",window.saturne.signature.autoDownloadSpecimen),$(document).on("click",".copy-signatureurl",window.saturne.signature.copySignatureUrlClipboard),$(document).on("click",".set-attendance",window.saturne.signature.setAttendance),document.querySelector('script[src*="signature-pad.min.js"]')&&window.saturne.signature.drawSignatureOnCanvas(),$(document).on("touchstart mousedown",".canvas-signature",function(){window.saturne.toolbox.removeAddButtonClass("signature-validate","button-grey button-disable","button-blue")})},window.saturne.signature.drawSignatureOnCanvas=function(){var e;window.saturne.signature.canvas=document.querySelector(".canvas-signature"),window.saturne.signature.canvas&&(e=Math.max(window.devicePixelRatio||1,1),window.saturne.signature.canvas.signaturePad=new SignaturePad(window.saturne.signature.canvas,{penColor:"rgb(0, 0, 0)"}),window.saturne.signature.canvas.width=window.saturne.signature.canvas.offsetWidth*e,window.saturne.signature.canvas.height=window.saturne.signature.canvas.offsetHeight*e,window.saturne.signature.canvas.getContext("2d").scale(e,e))},window.saturne.signature.clearCanvas=function(){window.saturne.signature.canvas.signaturePad.clear(),window.saturne.toolbox.removeAddButtonClass("signature-validate","button-blue","button-grey button-disable")},window.saturne.signature.createSignature=function(){var e,t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.signature.canvas.signaturePad.isEmpty()||(e=window.saturne.signature.canvas.toDataURL()),window.saturne.loader.display($(this)),$.ajax({url:document.URL+n+"action=add_signature&token="+t,type:"POST",processData:!1,contentType:"application/octet-stream",data:JSON.stringify({signature:e}),success:function(e){!0===$(".public-card__container").data("public-interface")?($(".card__confirmation").removeAttr("style"),$(".signature-confirmation-close").attr("onclick","window.close()"),$(".public-card__container").replaceWith($(e).find(".public-card__container"))):window.location.reload()},error:function(){}})},window.saturne.signature.download=function(e,t){var n=document.createElement("a");n.href=e,n.setAttribute("download",t),n.click()},window.saturne.signature.autoDownloadSpecimen=function(){let o=$(this).closest(".file-generation"),a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action=builddoc&token="+a,type:"POST",success:function(e){var t=o.find(".specimen-name").attr("data-specimen-name"),n=o.find(".specimen-path").attr("data-specimen-path");window.saturne.signature.download(n+t,t),$(".file-generation").replaceWith($(e).find(".file-generation")),$.ajax({url:document.URL+i+"action=remove_file&token="+a,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.signature.copySignatureUrlClipboard=function(){var e=$(this).attr("data-signature-url");navigator.clipboard.writeText(e).then(()=>{$(this).attr("class","fas fa-check copy-signatureurl"),$(this).css("color","#59ed9c"),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").attr("style",""),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").fadeOut(2500,()=>{$(this).attr("class","fas fa-clipboard copy-signatureurl"),$(this).css("color","#666")})})},window.saturne.signature.setAttendance=function(){var e=$(this).closest(".attendance-container").find('input[name="signatoryID"]').val(),t=$(this).attr("value"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL),a=String(document.location.href).replace(/#formmail/,"");$.ajax({url:a+o+"action=set_attendance&token="+n,type:"POST",processData:!1,contentType:"",data:JSON.stringify({signatoryID:e,attendance:t}),success:function(e){$(".signatures-container").html($(e).find(".signatures-container"))},error:function(){}})},window.saturne.toolbox={},window.saturne.toolbox.init=function(){},window.saturne.toolbox.getQuerySeparator=function(e){return e.match(/\?/)?"&":"?"},window.saturne.toolbox.getToken=function(){return $('input[name="token"]').val()},window.saturne.toolbox.toggleButtonClass=function(e,t){$("."+e).toggleClass(t)},window.saturne.toolbox.removeAddButtonClass=function(e,t,n){$("."+e).removeClass(t).addClass(n)},window.saturne.tooltip||(window.saturne.tooltip={},window.saturne.tooltip.init=function(){window.saturne.tooltip.event()},window.saturne.tooltip.tabChanged=function(){$(".wpeo-tooltip").remove()},window.saturne.tooltip.event=function(){$(document).on("mouseenter touchstart",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onEnter),$(document).on("mouseleave touchend",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onOut)},window.saturne.tooltip.onEnter=function(e){window.saturne.tooltip.display($(this))},window.saturne.tooltip.onOut=function(e){window.saturne.tooltip.remove($(this))},window.saturne.tooltip.display=function(e){var t=$(e).data("direction")?$(e).data("direction"):"top",n=$(''+$(e).attr("aria-label")+""),o=($(e).position(),$(e).offset()),a=($(e)[0].tooltipElement=n,$("body").append($(e)[0].tooltipElement),$(e).data("color")&&n.addClass("tooltip-"+$(e).data("color")),0),i=0;switch($(e).data("direction")){case"left":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left-n.outerWidth()-10+3+"px";break;case"right":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left+$(e).outerWidth()+8+"px";break;case"bottom":a=o.top+$(e).height()+10+10+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px";break;default:a=o.top-n.outerHeight()-4+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px"}n.css({top:a,left:i,opacity:1}),$(e).on("remove",function(){$($(e)[0].tooltipElement).remove()})},window.saturne.tooltip.remove=function(e){$(e)[0]&&$(e)[0].tooltipElement&&$($(e)[0].tooltipElement).remove()}),window.saturne.utils={},window.saturne.utils.init=function(){window.saturne.utils.event()},window.saturne.utils.event=function(){$(document).on("mouseenter",".move-line.ui-sortable-handle",window.saturne.utils.draganddrop),$(document).on("change","#element_type",window.saturne.utils.reloadField)},window.saturne.utils.draganddrop=function(){$(this).css("cursor","pointer"),$("#tablelines tbody").sortable(),$("#tablelines tbody").sortable({handle:".move-line",connectWith:"#tablelines tbody .line-row",tolerance:"intersect",over:function(){$(this).css("cursor","grabbing")},stop:function(){$(this).css("cursor","default");var e=$(".fiche").find('input[name="token"]').val();let t="&",n=(document.URL.match(/action=/)&&(document.URL=document.URL.split(/\?/)[0],t="?"),[]);$(".line-row").each(function(){n.push($(this).attr("id"))}),$.ajax({url:document.URL+t+"action=moveLine&token="+e,type:"POST",data:JSON.stringify({order:n}),processData:!1,contentType:!1,success:function(){},error:function(){}})}})},window.saturne.utils.reloadPage=function(e,t,n="",o=""){var a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action="+e+n+"&token="+a,type:"POST",processData:!1,contentType:!1,success:function(e){window.saturne.utils.checkMoreParams(o),$(t).replaceWith($(e).find(t))},error:function(){}})},window.saturne.utils.reloadField=function(){var e=$(this).val(),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".field_element_type")),window.saturne.loader.display($(".field_fk_element")),$.ajax({url:document.URL+n+"element_type="+e+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(e){$(".field_element_type").replaceWith($(e).find(".field_element_type")),$(".field_fk_element").replaceWith($(e).find(".field_fk_element"))},error:function(){}})},window.saturne.utils.enforceMinMax=function(e){""!==e.value&&(parseInt(e.value)parseInt(e.max))&&(e.value=e.max)},window.saturne.utils.checkMoreParams=function(e){e&&e.removeAttr&&$(e.removeAttr.element).removeAttr(e.removeAttr.value)}; \ No newline at end of file diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 22b67b46..42c0e2c6 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -94,7 +94,22 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str } else { $fileList = dol_dir_list($filedir, 'files', 0, '(\.jpg|\.jpeg|\.png|\.odt|\.zip|\.pdf)', '', 'date', SORT_DESC, 1); } - } + } + + $fileList = dol_sort_array($fileList, $sortfield, $sortorder); + + $page = GETPOST('page', 'int') ?: 1; + $filePerPage = 20; + $fileListLength = 0; + if (is_array($fileList) && !empty($fileList)) { + $fileListLength = count($fileList); + } + + if ($fileListLength > $filePerPage) { + $fileList = array_slice($fileList, ($page - 1 ) * $filePerPage, $filePerPage); + } + + $pageNumber = ceil($fileListLength / $filePerPage); if ($hideifempty && empty($fileList)) { return ''; @@ -234,6 +249,20 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $genbutton = ''; } $out .= $genbutton; + $querySeparator = (strpos($_SERVER['REQUEST_URI'], '?') === false) ? '?' : '&'; + + $out .= ''; } else { $out .= '
' . $langs->trans('Files') . '
'; } @@ -297,7 +326,6 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= '
'; $out .= '
' . $langs->trans('Name'); - $out .= '' . $langs->trans('Size'); - $out .= '' . $langs->trans('Date'); - $out .= '' . $langs->trans('PDF'); - $out .= '' . $langs->trans('Action'); - $out .= '
'; + if ($sortable) { + $out .= ''; + $out .= ($sortfield == strtolower($name) ? '' : ''); + } + $out .= $langs->trans($name); + if ($sortable) { + $out .= ' ' . ($sortfield == strtolower($name) ? ($sortorder == 'asc' ? '' : '') : ''); + $out .= ($sortfield == strtolower($name) ? '' : ''); + $out .= ''; + } + $out .='
' . "\n"; } - $fileList = dol_sort_array($fileList, $sortfield, $sortorder); // Loop on each file found if (is_array($fileList)) { @@ -442,9 +470,10 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str function get_document_title_field(string $sortfield, string $sortorder, string $name, bool $sortable = true, string $morehtml = ''): string { global $langs; + $querySeparator = (strpos($_SERVER['PHP_SELF'], '?') === false) ? '?' : '&'; $out = ''; $out .= ''; + $out .= get_document_title_search('text', 'Name'); + $out .= ''; + $out .= get_document_title_search('date', 'Date', 'right'); + $out .= ''; + $out .= ''; + + $out .= ''; + $out .= ''; $out .= get_document_title_field($sortfield, $sortorder, 'Name'); $out .= get_document_title_field($sortfield, $sortorder, 'Size', true, 'right'); $out .= get_document_title_field($sortfield, $sortorder, 'Date', true, 'right'); $out .= get_document_title_field($sortfield, $sortorder, 'PDF', false, 'right'); $out .= get_document_title_field($sortfield, $sortorder, 'Action', false, 'right'); -// $out .= ''; $out .= ''; // Execute hooks @@ -467,6 +493,16 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str return $out; } +/** + * Get document title field + * + * @param string $sortfield + * @param string $sortorder + * @param string $name + * @param bool $sortable + * @param string $morehtml + * @return string + */ function get_document_title_field(string $sortfield, string $sortorder, string $name, bool $sortable = true, string $morehtml = ''): string { global $langs; @@ -483,6 +519,23 @@ function get_document_title_field(string $sortfield, string $sortorder, string $ $out .= ''; } $out .=''; + + return $out; +} + +/** + * Get document title search + * + * @param string $type + * @param string $name + * @param string $morehtml + * @return string + */ +function get_document_title_search(string $type, string $name, string $morehtml = ''): string +{ + $out = ''; return $out; } From 0b0590450689cd2e5e551432da742a2cd1190883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 6 Aug 2024 11:05:59 +0200 Subject: [PATCH 05/11] #1045 [QRCode] add: QR Code class --- class/qrcode.class.php | 149 ++++++++++++++++++ sql/qrcode/index.php | 2 + .../llx_saturne_object_documents.key.sql | 19 +++ sql/qrcode/llx_saturne_object_documents.sql | 27 ++++ 4 files changed, 197 insertions(+) create mode 100644 class/qrcode.class.php create mode 100644 sql/qrcode/index.php create mode 100644 sql/qrcode/llx_saturne_object_documents.key.sql create mode 100644 sql/qrcode/llx_saturne_object_documents.sql diff --git a/class/qrcode.class.php b/class/qrcode.class.php new file mode 100644 index 00000000..0ac86cbb --- /dev/null +++ b/class/qrcode.class.php @@ -0,0 +1,149 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file class/saturneqrcode.class.php + * \ingroup saturne + * \brief This file is a CRUD class file for SaturneQRCode (Create/Read/Update/Delete). + */ + +// Load Saturne libraries. +require_once __DIR__ . '/saturneobject.class.php'; + +class SaturneQRCode extends SaturneObject +{ + /** + * @var DoliDB Database handler + */ + public $db; + + /** + * @var string Module name + */ + public $module = 'saturne'; + + /** + * @var string Element type of object + */ + public $element = 'saturne_qrcode'; + + /** + * @var string Name of table without prefix where object is stored This is also the key used for extrafields management + */ + public $table_element = 'saturne_qrcode'; + + /** + * @var int Does this object support multicompany module ? + * 0 = No test on entity, 1 = Test with field entity, 'field@table' = Test with link by field@table + */ + public $ismultientitymanaged = 1; + + /** + * @var int Does object support extrafields ? 0 = No, 1 = Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string Last output from end job execution + */ + public $output = ''; + + /** + * @var string Name of icon for certificate Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'certificate@saturne' if picto is file 'img/object_certificatepng' + */ + public string $picto = 'fontawesome_fa-forward_fas_#d35968'; + + /** + * @var array Array with all fields and their property Do not use it as a static var It may be modified by constructor + */ + public $fields = [ + 'rowid' => ['type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'comment' => 'Id'], + 'entity' => ['type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'position' => 30, 'notnull' => 1, 'visible' => 0, 'index' => 1], + 'date_creation' => ['type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 40, 'notnull' => 1, 'visible' => 0], + 'tms' => ['type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 50, 'notnull' => 1, 'visible' => 0], + 'import_key' => ['type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 0, 'index' => 0], + 'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 2, 'default' => 0, 'index' => 1, 'validate' => 1, 'arrayofkeyval' => [0 => 'StatusDraft', 1 => 'ValidatePendingSignature', 2 => 'Expired', 3 => 'Archived']], + 'module_name' => ['type' => 'varchar(128)', 'label' => 'ModuleName', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 0], + 'url' => ['type' => 'text', 'label' => 'Url', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 0, 'index' => 0], + 'encoded_qr_code' => ['type' => 'text', 'label' => 'EncodedData', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 0, 'index' => 0], + 'fk_user_creat' => ['type' => 'integer:User:user/class/userclassphp', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'position' => 220, 'notnull' => 1, 'visible' => 0, 'foreignkey' => 'userrowid'], + ]; + + /** + * @var int ID + */ + public int $rowid; + + /** + * @var int Entity + */ + public $entity; + + /** + * @var int|string Creation date + */ + public $date_creation; + + /** + * @var int|string Timestamp + */ + public $tms; + + /** + * @var string Import key + */ + public $import_key; + + /** + * @var int Status + */ + public $status; + + /** + * @var string Module name + */ + public $module_name; + + /** + * @var string URL + */ + public $url; + + /** + * @var string QR Code encoded + */ + public $encoded_qr_code; + + /** + * @var int User creator + */ + public $fk_user_creat; + + /** + * Constructor + * + * @param DoliDb $db Database handler + * @param string $moduleNameLowerCase Module name + * @param string $objectType Object element type + */ + public function __construct(DoliDB $db, string $moduleNameLowerCase = 'saturne', string $objectType = 'saturne_qrcode') + { + parent::__construct($db, $moduleNameLowerCase, $objectType); + } +} + +?> diff --git a/sql/qrcode/index.php b/sql/qrcode/index.php new file mode 100644 index 00000000..eda62848 --- /dev/null +++ b/sql/qrcode/index.php @@ -0,0 +1,2 @@ + +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_saturne_qrcode ADD INDEX idx_saturne_object_qrcode_rowid (rowid); +ALTER TABLE llx_saturne_qrcode ADD INDEX idx_saturne_object_qrcode_ref (ref); +ALTER TABLE llx_saturne_qrcode ADD INDEX idx_saturne_object_qrcode_status (status); +ALTER TABLE llx_saturne_qrcode ADD CONSTRAINT llx_saturne_qrcode_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); diff --git a/sql/qrcode/llx_saturne_object_documents.sql b/sql/qrcode/llx_saturne_object_documents.sql new file mode 100644 index 00000000..aa84447e --- /dev/null +++ b/sql/qrcode/llx_saturne_object_documents.sql @@ -0,0 +1,27 @@ +-- Copyright (C) 2021-2023 EVARISK +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_saturne_qrcode( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + import_key varchar(14), + status integer DEFAULT 1 NOT NULL, + module_name varchar(255), + url text, + encoded_qr_code text, + fk_user_creat integer NOT NULL +) ENGINE=innodb; From b4edbc75dfe4738a4500feb19cce0ec4283fcf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 6 Aug 2024 11:22:39 +0200 Subject: [PATCH 06/11] #1045 [QRCode] add: qr code config page & rename sql files --- admin/qrcode.php | 149 ++++++++++++++++++ ...code.class.php => saturneqrcode.class.php} | 17 ++ lib/saturne.lib.php | 5 + ...nts.key.sql => llx_saturne_qrcode.key.sql} | 0 ...t_documents.sql => llx_saturne_qrcode.sql} | 2 +- 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 admin/qrcode.php rename class/{qrcode.class.php => saturneqrcode.class.php} (92%) rename sql/qrcode/{llx_saturne_object_documents.key.sql => llx_saturne_qrcode.key.sql} (100%) rename sql/qrcode/{llx_saturne_object_documents.sql => llx_saturne_qrcode.sql} (97%) diff --git a/admin/qrcode.php b/admin/qrcode.php new file mode 100644 index 00000000..bf8a9e08 --- /dev/null +++ b/admin/qrcode.php @@ -0,0 +1,149 @@ +. + */ + +/** + * \file admin/redirections.php + * \ingroup saturne + * \brief Saturne redirections page + */ + +// Load Saturne environment +if (file_exists('../saturne.main.inc.php')) { + require_once __DIR__ . '/../saturne.main.inc.php'; +} elseif (file_exists('../../saturne.main.inc.php')) { + require_once __DIR__ . '/../../saturne.main.inc.php'; +} else { + die('Include of saturne main fails'); +} + +// Get module parameters +$moduleName = GETPOST('module_name', 'alpha'); +$moduleNameLowerCase = strtolower($moduleName); + +// Load Dolibarr libraries +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/tcpdf_barcodes_2d.php'; + +// Load Module libraries +require_once __DIR__ . '/../lib/saturne.lib.php'; +require_once __DIR__ . '/../class/saturneqrcode.class.php'; + +// Global variables definitions +global $conf, $db, $hookmanager, $langs, $user; + +// Load translation files required by the page +saturne_load_langs(['admin']); + +// Initialize view objects +$form = new Form($db); + +// Get parameters +$action = GETPOST('action', 'alpha'); +$url = GETPOST('url', 'alpha'); + +// Initialize Redirection Manager +$saturneQRCode = new SaturneQRCode($db); + +// Security check - Protection if external user +$permissiontoread = $user->rights->saturne->adminpage->read; +saturne_check_access($permissiontoread); + +/* + * Actions + */ + +// Add a redirection +if ($action == 'add') { + $saturneQRCode->url = $url; + $saturneQRCode->encoded_qr_code = $saturneQRCode->getQRCodeBase64($url); + $saturneQRCode->module_name = 'saturne'; + $saturneQRCode->status = 1; + $saturneQRCode->create($user); +} + +// Remove a redirection +if ($action == 'remove') { + $saturneQRCode->fetch(GETPOST('id')); + $saturneQRCode->delete($user, false, false); +} + +/* + * View + */ + +$title = $langs->trans('RedirectionsSetup', $moduleName); +$help_url = 'FR:Module_' . $moduleName; + +saturne_header(0, '', $title, $help_url); + +print load_fiche_titre($title, '', 'title_setup'); + +// Configuration header +$preHead = $moduleNameLowerCase . '_admin_prepare_head'; +$head = $preHead(); +print dol_get_fiche_head($head, 'qrcode', $title, -1, $moduleNameLowerCase . '_color@' . $moduleNameLowerCase); +$QRCodes = $saturneQRCode->fetchAll(); + +print '
'; if ($sortable) { - $out .= ''; + $out .= ''; $out .= ($sortfield == strtolower($name) ? '' : ''); } $out .= $langs->trans($name); From bb6fc4eddaa871392315343e633b06f1336815cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 23 Jul 2024 17:44:41 +0200 Subject: [PATCH 04/11] #1003 [Documents] fix: add functions documentation --- lib/documents.lib.php | 55 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 42c0e2c6..99e46132 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -96,6 +96,21 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str } } + if (GETPOST('search_name')) { + $fileList = array_filter($fileList, function($file) { + return strpos($file['name'], GETPOST('search_name')) !== false; + }); + } + + if (GETPOST('search_date')) { + $search_date = GETPOST('search_date'); + $fileList = array_filter($fileList, function($file) use ($search_date) { + $file_date = date('Y-m-d', $file['date']); + return $file_date === $search_date; + }); + } + + $fileList = dol_sort_array($fileList, $sortfield, $sortorder); $page = GETPOST('page', 'int') ?: 1; @@ -289,12 +304,23 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str } $out .= '
'; + $out .= ''; + $out .= '   '; + $out .= ''; + $out .= '
'; + $out .= ''; + $out .= '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +if (is_array($QRCodes) && !empty($QRCodes)) { + foreach ($QRCodes as $QRCode) { + print ''; + print ''; + print ''; + print ''; + print ''; + } +} + + +print ''; +print ''; +print ''; + +print ''; + +print '
' . $langs->trans('URL') . '' . $langs->trans('QR Code') . '' . $langs->trans('ModuleName') . '' . $langs->trans('Action') . '
'; + print $QRCode->url; + print ''; + print 'QR Code'; + print ''; + print ucfirst($QRCode->module_name); + print ''; + print ''; + print ''; + print '
'; +print ''; +print " " . $form->textwithpicto($langs->trans('Help'), $langs->trans('HowToUseURLToEncode')); +print ''; +print ''; +print ''; +print ''; +print '
'; +print ''; + +print dol_get_fiche_end(); +llxFooter(); +$db->close(); +?> diff --git a/class/qrcode.class.php b/class/saturneqrcode.class.php similarity index 92% rename from class/qrcode.class.php rename to class/saturneqrcode.class.php index 0ac86cbb..234ffb6a 100644 --- a/class/qrcode.class.php +++ b/class/saturneqrcode.class.php @@ -144,6 +144,23 @@ public function __construct(DoliDB $db, string $moduleNameLowerCase = 'saturne', { parent::__construct($db, $moduleNameLowerCase, $objectType); } + + /** + * Get QR Code base64 + * + * @param string $url URL to encode + * + * @return string Encoded QR Code + */ + public function getQRCodeBase64(string $url): string +{ + // Create QR Code + $barcodeObject = new TCPDF2DBarcode($url, 'QRCODE,H'); + $qrCodePng = $barcodeObject->getBarcodePngData(6, 6); + $qrCodeBase64 = 'data:image/png;base64,' . base64_encode($qrCodePng); + + return $qrCodeBase64; + } } ?> diff --git a/lib/saturne.lib.php b/lib/saturne.lib.php index 797ca035..7b7a3be3 100644 --- a/lib/saturne.lib.php +++ b/lib/saturne.lib.php @@ -53,6 +53,11 @@ function saturne_admin_prepare_head(): array $head[$h][2] = 'information'; $h++; + $head[$h][0] = dol_buildpath('/saturne/admin/qrcode.php', 1) . '?filename=saturne_dev&tab_name=qrcode'; + $head[$h][1] = '' . $langs->trans('QRCode'); + $head[$h][2] = 'qrcode'; + $h++; + $head[$h][0] = dol_buildpath('/saturne/admin/information.php', 1) . '?filename=evarisk_modules&tab_name=evariskModule'; $head[$h][1] = '' . $langs->trans('SaturneModule', 'Evarisk'); $head[$h][2] = 'evariskModule'; diff --git a/sql/qrcode/llx_saturne_object_documents.key.sql b/sql/qrcode/llx_saturne_qrcode.key.sql similarity index 100% rename from sql/qrcode/llx_saturne_object_documents.key.sql rename to sql/qrcode/llx_saturne_qrcode.key.sql diff --git a/sql/qrcode/llx_saturne_object_documents.sql b/sql/qrcode/llx_saturne_qrcode.sql similarity index 97% rename from sql/qrcode/llx_saturne_object_documents.sql rename to sql/qrcode/llx_saturne_qrcode.sql index aa84447e..dea2b39b 100644 --- a/sql/qrcode/llx_saturne_object_documents.sql +++ b/sql/qrcode/llx_saturne_qrcode.sql @@ -22,6 +22,6 @@ CREATE TABLE llx_saturne_qrcode( status integer DEFAULT 1 NOT NULL, module_name varchar(255), url text, - encoded_qr_code text, + encoded_qr_code longtext, fk_user_creat integer NOT NULL ) ENGINE=innodb; From f84423d4b6c83caf04cac881b54a4def6fabdda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 6 Aug 2024 16:15:11 +0200 Subject: [PATCH 07/11] #1045 [QRCode] add: qr code generation --- admin/qrcode.php | 3 +- class/saturneqrcode.class.php | 5 ++- js/modules/qrcode.js | 85 +++++++++++++++++++++++++++++++++++ js/saturne.min.js | 2 +- lib/documents.lib.php | 50 ++++++++++++++++++++- 5 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 js/modules/qrcode.js diff --git a/admin/qrcode.php b/admin/qrcode.php index bf8a9e08..9b0bfec8 100644 --- a/admin/qrcode.php +++ b/admin/qrcode.php @@ -102,7 +102,8 @@ print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/class/saturneqrcode.class.php b/class/saturneqrcode.class.php index 234ffb6a..bf1d2808 100644 --- a/class/saturneqrcode.class.php +++ b/class/saturneqrcode.class.php @@ -21,9 +21,12 @@ * \brief This file is a CRUD class file for SaturneQRCode (Create/Read/Update/Delete). */ -// Load Saturne libraries. +// Load Saturne libraries require_once __DIR__ . '/saturneobject.class.php'; +// Load QRCode library +require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/tcpdf_barcodes_2d.php'; + class SaturneQRCode extends SaturneObject { /** diff --git a/js/modules/qrcode.js b/js/modules/qrcode.js new file mode 100644 index 00000000..c0a3da86 --- /dev/null +++ b/js/modules/qrcode.js @@ -0,0 +1,85 @@ +/* Copyright (C) 2024 EVARISK + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Library javascript to enable Browser notifications + */ + +/** + * \file js/modules/qrcode.js + * \ingroup saturne + * \brief JavaScript qrcode file for module Saturne + */ + +/** + * Init qrcode JS + * + * @since 1.2.0 + * @version 1.2.0 + */ +window.saturne.qrcode = {}; + +/** + * QR Code init + * + * @since 1.2.0 + * @version 1.2.0 + * + * @return {void} + */ +window.saturne.qrcode.init = function() { + window.saturne.qrcode.event(); +}; + +/** + * QR Code event + * + * @since 1.2.0 + * @version 1.2.0 + * + * @return {void} + */ +window.saturne.qrcode.event = function() { + $(document).on('click', '.preview-qr-code', window.saturne.qrcode.previewQRCode); +}; + + +// Fonction pour afficher le QR code dans une modal +window.saturne.qrcode.previewQRCode = function() { + // Obtenir l'image du QR code à partir des données de l'élément + let QRCodeBase64 = $(this).find('.qrcode-base64').val(); + + // Créer un élément d'image + const img = document.createElement('img'); + img.src = QRCodeBase64; + img.alt = 'QR Code'; + img.style.maxWidth = '100%'; + + // Insérer l'image dans le conteneur désigné + const pdfPreview = document.getElementById('pdfPreview'); + pdfPreview.innerHTML = ''; // Vider le conteneur d'abord + pdfPreview.appendChild(img); + + // Afficher la modal + $('#pdfModal').addClass('modal-active'); + + // Ajouter un bouton de téléchargement + const downloadBtn = document.getElementById('downloadBtn'); + downloadBtn.onclick = function() { + const a = document.createElement('a'); + a.href = QRCodeBase64; + a.download = 'QRCode.png'; + a.click(); + }; +}; diff --git a/js/saturne.min.js b/js/saturne.min.js index a587006d..00fe52aa 100644 --- a/js/saturne.min.js +++ b/js/saturne.min.js @@ -1 +1 @@ -window.saturne||(window.saturne={},window.saturne.scriptsLoaded=!1),window.saturne.scriptsLoaded||(window.saturne.init=function(){window.saturne.load_list_script()},window.saturne.load_list_script=function(){if(!window.saturne.scriptsLoaded){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].init&&window.saturne[e].init(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].init&&window.saturne[e][t].init();window.saturne.scriptsLoaded=!0}},window.saturne.refresh=function(){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].refresh&&window.saturne[e].refresh(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].refresh&&window.saturne[e][t].refresh()},$(document).ready(window.saturne.init)),window.saturne.button={},window.saturne.button.init=function(){window.saturne.button.event()},window.saturne.button.event=function(){$(document).on("click",".wpeo-button:submit, .wpeo-button.auto-download",window.saturne.button.addLoader)},window.saturne.button.addLoader=function(){$(this).hasClass("no-load")||(window.saturne.loader.display($(this)),$(this).toggleClass("button-blue button-disable"))},window.saturne.dashboard={},window.saturne.dashboard.init=function(){window.saturne.dashboard.event()},window.saturne.dashboard.event=function(){$(document).on("change",".add-dashboard-widget",window.saturne.dashboard.addDashBoardInfo),$(document).on("click",".close-dashboard-widget",window.saturne.dashboard.closeDashBoardInfo),$(document).on("click",".select-dataset-dashboard-info",window.saturne.dashboard.selectDatasetDashboardInfo)},window.saturne.dashboard.addDashBoardInfo=function(){var e=document.getElementById("dashBoardForm"),e=new FormData(e).get("boxcombo"),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+n+"action=adddashboardinfo&token="+t,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(){window.location.reload()},error:function(){}})},window.saturne.dashboard.closeDashBoardInfo=function(){let t=$(this);var e=t.attr("data-widgetname"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+o+"action=closedashboardinfo&token="+n,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(e){t.closest(".box-flex-item").fadeOut(400),$(".add-widget-box").attr("style",""),$(".add-widget-box").html($(e).find(".add-widget-box").children())},error:function(){}})},window.saturne.dashboard.selectDatasetDashboardInfo=function(){var e=$("#search_userid").val(),t=$("#search_year").val(),n=$("#search_month").val(),o=window.saturne.toolbox.getToken(),a=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".fichecenter")),$.ajax({url:document.URL+a+"token="+o+"&search_userid="+e+"&search_year="+t+"&search_month="+n,type:"POST",processData:!1,contentType:!1,success:function(e){$(".fichecenter").replaceWith($(e).find(".fichecenter"))},error:function(){}})},window.saturne.document={},window.saturne.document.init=function(){window.saturne.document.event()},window.saturne.document.event=function(){$(document).on("click","#builddoc_generatebutton",window.saturne.document.displayLoader),$(document).on("click",".pdf-generation",window.saturne.document.displayLoader),$(document).on("click",".download-template",window.saturne.document.autoDownloadTemplate),$(document).on("keydown","#change_pagination",window.saturne.document.changePagination),$(document).on("keydown",".saturne-search",window.saturne.document.saturneSearch),$(document).on("click",".saturne-search-button",window.saturne.document.saturneSearch),$(document).on("click",".saturne-cancel-button",window.saturne.document.saturneCancelSearch)},window.saturne.document.displayLoader=function(){window.saturne.loader.display($(this).closest(".div-table-responsive-no-min"))},window.saturne.document.autoDownloadTemplate=function(){let t=window.saturne.toolbox.getToken();var e=document.URL.replace(/#.*$/,"");let n=window.saturne.toolbox.getQuerySeparator(e),o=$(this).closest(".file-generation");var a=o.find(".template-type").attr("value");let i=o.find(".template-name").attr("value");$.ajax({url:e+n+"action=download_template&filename="+i+"&type="+a+"&token="+t,type:"POST",success:function(){var e=o.find(".template-path").attr("value");window.saturne.signature.download(e+i,i),$.ajax({url:document.URL+n+"action=remove_file&filename="+i+"&token="+t,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.document.changePagination=function(e){var t;13===e.keyCode&&(e.preventDefault(),e=e.target,t=$("#page_number").val(),e=parseInt(e.value)<=parseInt(t)?e.value:t,(t=new URL(window.location.href)).searchParams.has("page")?t.searchParams.set("page",e):t.searchParams.append("page",e),window.location.replace(t.toString()))},window.saturne.document.saturneSearch=function(e){var t,n;13!==e.keyCode&&!$(this).hasClass("saturne-search-button")||(e.preventDefault(),e=new URL(window.location.href),t=$("#search_name").val(),n=$("#search_date").val(),""===t&&""===n)||(0body{"+e+n+e+t+n+t)},window.saturne.dropdown.open=function(e){var n=$(this),o=n.find("[data-fa-i2svg]"),t={},a=void 0;window.saturne.dropdown.close(e,$(this)),n.attr("data-action")?(window.saturne.loader.display(n),n.get_data(function(e){for(a in t)e[a]||(e[a]=t[a]);window.saturne.request.send(n,e,function(e,t){n.closest(".wpeo-dropdown").find(".saturne-dropdown-content").html(t.data.view),n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)})})):(n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)),e.stopPropagation()},window.saturne.dropdown.close=function(e){var n=$(this);$(".wpeo-dropdown.dropdown-active:not(.no-close)").each(function(){var e=$(this),t={close:!0};n.trigger("dropdown-before-close",[e,n,t]),t.close&&(e.removeClass("dropdown-active"),t=$(this).find(".dropdown-toggle").find("[data-fa-i2svg]"))&&window.saturne.dropdown.toggleAngleClass(t)})},window.saturne.dropdown.toggleAngleClass=function(e){e.hasClass("fa-caret-down")||e.hasClass("fa-caret-up")?e.toggleClass("fa-caret-down").toggleClass("fa-caret-up"):e.hasClass("fa-caret-circle-down")||e.hasClass("fa-caret-circle-up")?e.toggleClass("fa-caret-circle-down").toggleClass("fa-caret-circle-up"):e.hasClass("fa-angle-down")||e.hasClass("fa-angle-up")?e.toggleClass("fa-angle-down").toggleClass("fa-angle-up"):(e.hasClass("fa-chevron-circle-down")||e.hasClass("fa-chevron-circle-up"))&&e.toggleClass("fa-chevron-circle-down").toggleClass("fa-chevron-circle-up")},window.saturne.keyEvent={},window.saturne.keyEvent.init=function(){window.saturne.keyEvent.event()},window.saturne.keyEvent.event=function(){$(document).on("keydown",window.saturne.keyEvent.keyActions),$(document).on("keyup",".url-container",window.saturne.keyEvent.checkUrlFormat)},window.saturne.keyEvent.keyActions=function(e){0<$(this).find(".modal-active").length?("Escape"===e.key&&$(this).find(".modal-active .modal-close .fas.fa-times").first().click(),"Enter"!==e.key||$("input, textarea").is(":focus")||$(this).find(".modal-active .modal-footer .wpeo-button").not(".button-disable").first().click()):$(e.target).is("input, textarea")||("Enter"===e.key&&$(this).find(".button_search").click(),e.shiftKey&&"Enter"===e.key&&$(this).find(".button_removefilter").click())},window.saturne.keyEvent.checkUrlFormat=function(){$(this).val().match(/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi)?$(this).attr("style","border: solid; border-color: green"):0<$("input:focus").val().length&&$(this).attr("style","border: solid; border-color: red")},window.saturne.loader={},window.saturne.loader.init=function(){window.saturne.loader.event()},window.saturne.loader.event=function(){},window.saturne.loader.display=function(e){var t;e.hasClass("button-progress")?e.addClass("button-load"):(e.addClass("wpeo-loader"),t=$(''),e[0].loaderElement=t,e.append(e[0].loaderElement))},window.saturne.loader.remove=function(e){0"),i===a&&($(".wpeo-loader").removeClass("wpeo-loader"),$("#progressBarContainer").fadeOut(800),$("#progressBarContainer").find(".loader-spin").remove(),window.saturne.loader.display(o.find(".ecm-photo-list-content")),setTimeout(()=>{o.html($(e).find("#media_gallery").children()).promise().done(()=>{1==a&&($("#media_gallery").find(".save-photo").removeClass("button-disable"),$("#media_gallery").find(".delete-photo").removeClass("button-disable"),$("#media_gallery").find(".clickable-photo0").addClass("clicked-photo")),($(e).find(".error-medias").length?($(".messageErrorSendPhoto").find(".notice-subtitle").html(m),$(".messageErrorSendPhoto")):$(".messageSuccessSendPhoto")).removeClass("hidden"),o.attr("data-from-id",r),o.attr("data-from-type",s),o.attr("data-from-subtype",l),o.attr("data-from-subdir",c),o.find(".wpeo-button").attr("value",r)})},800))}})})},window.saturne.mediaGallery.previewPhoto=function(e){var t=setInterval(function(){$(".ui-dialog").length&&(clearInterval(t),$(document).find(".ui-dialog").addClass("preview-photo"))},100)},window.saturne.mediaGallery.unlinkFile=function(e){e.preventDefault();let t=window.saturne.toolbox.getToken();var e=$(this).closest(".modal-active"),n=0<$(this).closest(".modal-active").length;let o=null,a=(o=(n?e:$(this).closest(".linked-medias")).find(".modal-options")).attr("data-from-subtype"),i=o.attr("data-from-type"),d=o.attr("data-from-subdir"),r=o.attr("data-from-id"),s=o.attr("data-photo-class");n=$(this).closest(".media-container");let l=n.find(".file-path").val(),c=n.find(".file-name").val(),u=$(this).closest(".linked-medias").find(".media-gallery-favorite.favorite").closest(".media-container").find(".file-name").val(),w=(window.saturne.loader.display(n),window.saturne.toolbox.getQuerySeparator(document.URL));$(".card__confirmation").css("display","flex"),$(document).on("click",".confirmation-close",function(){$(".wpeo-loader").removeClass("wpeo-loader"),$(".card__confirmation").css("display","none")}),$(document).on("click",".confirmation-delete",function(){$.ajax({url:document.URL+w+"subaction=unlinkFile&token="+t,type:"POST",data:JSON.stringify({filepath:l,filename:c,objectSubtype:a,objectType:i,objectSubdir:d,objectId:r}),processData:!1,success:function(e){$(".card__confirmation").css("display","none"),$("#media_gallery .modal-container").replaceWith($(e).find("#media_gallery .modal-container")),u==c&&(void 0!==s&&0"))[1].match(/>/)&&(n[1]=n[1].replace(/>/,"")),$(this).attr("title",n[1]),$(this).html(n[0])}),t.css("width","30px"),t.find(".blockvmenusearch").hide(),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$(this).find("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),localStorage.setItem("maximized","false")):0<$(this).find("span.vmenu").find(".fa-chevron-circle-right").length&&(e.each(function(){$(this).html($(this).html().replace(">","")+" "+$(this).attr("title"))}),t.css("width","188px"),t.find(".blockvmenusearch").show(),$("div.menu_titre").attr("style","width: 188px !important; cursor : pointer"),$("span.vmenu").attr("title"," Réduire le menu"),$("span.vmenu").html(' Réduire le menu'),localStorage.setItem("maximized","true"),$(this).find("span.vmenu").find(".fa-chevron-circle-right").removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-left"))},window.saturne.menu.setMenu=function(){var e,t,n;0<$(".blockvmenu.blockvmenulast .saturne-toggle-menu").length&&($(".blockvmenu.blockvmenulast .saturne-toggle-menu").closest(".menu_titre").attr("style","cursor:pointer ! important"),"false"==localStorage.maximized&&$("#id-left").attr("style","display:none !important"),"false"==localStorage.maximized&&(e="",t=$("#id-left").find("a.vmenu, span.vmenudisabled, span.vmenu, a.vsmenu"),n=$(document).find("div.vmenu"),t.each(function(){e=$(this).html().split(""),$(this).attr("title",e[1]),$(this).html(e[0]),console.log(e)}),$("#id-left").attr("style","display:block !important"),$("div.menu_titre").attr("style","width: 50px !important"),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),n.css("width","30px"),n.find(".blockvmenusearch").hide()),localStorage.setItem("currentString",""),localStorage.setItem("keypressNumber",0))},window.saturne.modal={},window.saturne.modal.init=function(){window.saturne.modal.event()},window.saturne.modal.event=function(){$(document).on("click",".modal-close, .modal-active:not(.modal-container)",window.saturne.modal.closeModal),$(document).on("click",".modal-open",window.saturne.modal.openModal),$(document).on("click",".modal-refresh",window.saturne.modal.refreshModal)},window.saturne.modal.openModal=function(e){var t=$(this).find(".modal-options"),n=t.attr("data-modal-to-open"),o=t.attr("data-from-id"),a=t.attr("data-from-type"),i=t.attr("data-from-subtype"),d=t.attr("data-from-subdir"),r=t.attr("data-from-module"),t=t.attr("data-photo-class");let s="";s=document.URL.match(/#/)?document.URL.split(/#/)[0]:document.URL,history.pushState({path:document.URL},"",s),$("#"+n).attr("data-from-id",o),$("#"+n).attr("data-from-type",a),$("#"+n).attr("data-from-subtype",i),$("#"+n).attr("data-from-subdir",d),$("#"+n).attr("data-photo-class",t),r&&"function"==typeof window.saturne.modal.addMoreOpenModalData&&window.saturne.modal.addMoreOpenModalData(n,$(this)),$("#"+n).find(".wpeo-button").attr("value",o),$("#"+n).addClass("modal-active"),$(".notice").addClass("hidden")},window.saturne.modal.closeModal=function(e){$("input:focus").length<1&&$("textarea:focus").length<1&&($(e.target).hasClass("modal-active")||$(e.target).hasClass("modal-close")||$(e.target).parent().hasClass("modal-close"))&&($(this).closest(".modal-active").removeClass("modal-active"),$(".clicked-photo").attr("style",""),$(".clicked-photo").removeClass("clicked-photo"),$(".notice").addClass("hidden"))},window.saturne.modal.refreshModal=function(e){window.location.reload()},window.saturne.notice={},window.saturne.notice.init=function(){window.saturne.notice.event()},window.saturne.notice.event=function(){$(document).on("click",".notice-close",window.saturne.notice.closeNotice)},window.saturne.notice.closeNotice=function(){$(this).closest(".wpeo-notice").fadeOut(function(){$(this).closest(".wpeo-notice").addClass("hidden")}),$(this).hasClass("notice-close-forever")&&window.saturne.utils.reloadPage("close_notice",".fiche")},window.saturne.object={},window.saturne.object.init=function(){window.saturne.object.event()},window.saturne.object.event=function(){$(document).on("click",".toggle-object-infos",window.saturne.object.toggleObjectInfos)},window.saturne.object.toggleObjectInfos=function(){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.object-infos").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.object-infos").removeClass("hidden"))},window.saturne.signature={},window.saturne.signature.canvas={},window.saturne.signature.init=function(){window.saturne.signature.event()},window.saturne.signature.event=function(){$(document).on("click",".signature-erase",window.saturne.signature.clearCanvas),$(document).on("click",".signature-validate:not(.button-disable)",window.saturne.signature.createSignature),$(document).on("click",".auto-download",window.saturne.signature.autoDownloadSpecimen),$(document).on("click",".copy-signatureurl",window.saturne.signature.copySignatureUrlClipboard),$(document).on("click",".set-attendance",window.saturne.signature.setAttendance),document.querySelector('script[src*="signature-pad.min.js"]')&&window.saturne.signature.drawSignatureOnCanvas(),$(document).on("touchstart mousedown",".canvas-signature",function(){window.saturne.toolbox.removeAddButtonClass("signature-validate","button-grey button-disable","button-blue")})},window.saturne.signature.drawSignatureOnCanvas=function(){var e;window.saturne.signature.canvas=document.querySelector(".canvas-signature"),window.saturne.signature.canvas&&(e=Math.max(window.devicePixelRatio||1,1),window.saturne.signature.canvas.signaturePad=new SignaturePad(window.saturne.signature.canvas,{penColor:"rgb(0, 0, 0)"}),window.saturne.signature.canvas.width=window.saturne.signature.canvas.offsetWidth*e,window.saturne.signature.canvas.height=window.saturne.signature.canvas.offsetHeight*e,window.saturne.signature.canvas.getContext("2d").scale(e,e))},window.saturne.signature.clearCanvas=function(){window.saturne.signature.canvas.signaturePad.clear(),window.saturne.toolbox.removeAddButtonClass("signature-validate","button-blue","button-grey button-disable")},window.saturne.signature.createSignature=function(){var e,t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.signature.canvas.signaturePad.isEmpty()||(e=window.saturne.signature.canvas.toDataURL()),window.saturne.loader.display($(this)),$.ajax({url:document.URL+n+"action=add_signature&token="+t,type:"POST",processData:!1,contentType:"application/octet-stream",data:JSON.stringify({signature:e}),success:function(e){!0===$(".public-card__container").data("public-interface")?($(".card__confirmation").removeAttr("style"),$(".signature-confirmation-close").attr("onclick","window.close()"),$(".public-card__container").replaceWith($(e).find(".public-card__container"))):window.location.reload()},error:function(){}})},window.saturne.signature.download=function(e,t){var n=document.createElement("a");n.href=e,n.setAttribute("download",t),n.click()},window.saturne.signature.autoDownloadSpecimen=function(){let o=$(this).closest(".file-generation"),a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action=builddoc&token="+a,type:"POST",success:function(e){var t=o.find(".specimen-name").attr("data-specimen-name"),n=o.find(".specimen-path").attr("data-specimen-path");window.saturne.signature.download(n+t,t),$(".file-generation").replaceWith($(e).find(".file-generation")),$.ajax({url:document.URL+i+"action=remove_file&token="+a,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.signature.copySignatureUrlClipboard=function(){var e=$(this).attr("data-signature-url");navigator.clipboard.writeText(e).then(()=>{$(this).attr("class","fas fa-check copy-signatureurl"),$(this).css("color","#59ed9c"),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").attr("style",""),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").fadeOut(2500,()=>{$(this).attr("class","fas fa-clipboard copy-signatureurl"),$(this).css("color","#666")})})},window.saturne.signature.setAttendance=function(){var e=$(this).closest(".attendance-container").find('input[name="signatoryID"]').val(),t=$(this).attr("value"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL),a=String(document.location.href).replace(/#formmail/,"");$.ajax({url:a+o+"action=set_attendance&token="+n,type:"POST",processData:!1,contentType:"",data:JSON.stringify({signatoryID:e,attendance:t}),success:function(e){$(".signatures-container").html($(e).find(".signatures-container"))},error:function(){}})},window.saturne.toolbox={},window.saturne.toolbox.init=function(){},window.saturne.toolbox.getQuerySeparator=function(e){return e.match(/\?/)?"&":"?"},window.saturne.toolbox.getToken=function(){return $('input[name="token"]').val()},window.saturne.toolbox.toggleButtonClass=function(e,t){$("."+e).toggleClass(t)},window.saturne.toolbox.removeAddButtonClass=function(e,t,n){$("."+e).removeClass(t).addClass(n)},window.saturne.tooltip||(window.saturne.tooltip={},window.saturne.tooltip.init=function(){window.saturne.tooltip.event()},window.saturne.tooltip.tabChanged=function(){$(".wpeo-tooltip").remove()},window.saturne.tooltip.event=function(){$(document).on("mouseenter touchstart",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onEnter),$(document).on("mouseleave touchend",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onOut)},window.saturne.tooltip.onEnter=function(e){window.saturne.tooltip.display($(this))},window.saturne.tooltip.onOut=function(e){window.saturne.tooltip.remove($(this))},window.saturne.tooltip.display=function(e){var t=$(e).data("direction")?$(e).data("direction"):"top",n=$(''+$(e).attr("aria-label")+""),o=($(e).position(),$(e).offset()),a=($(e)[0].tooltipElement=n,$("body").append($(e)[0].tooltipElement),$(e).data("color")&&n.addClass("tooltip-"+$(e).data("color")),0),i=0;switch($(e).data("direction")){case"left":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left-n.outerWidth()-10+3+"px";break;case"right":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left+$(e).outerWidth()+8+"px";break;case"bottom":a=o.top+$(e).height()+10+10+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px";break;default:a=o.top-n.outerHeight()-4+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px"}n.css({top:a,left:i,opacity:1}),$(e).on("remove",function(){$($(e)[0].tooltipElement).remove()})},window.saturne.tooltip.remove=function(e){$(e)[0]&&$(e)[0].tooltipElement&&$($(e)[0].tooltipElement).remove()}),window.saturne.utils={},window.saturne.utils.init=function(){window.saturne.utils.event()},window.saturne.utils.event=function(){$(document).on("mouseenter",".move-line.ui-sortable-handle",window.saturne.utils.draganddrop),$(document).on("change","#element_type",window.saturne.utils.reloadField)},window.saturne.utils.draganddrop=function(){$(this).css("cursor","pointer"),$("#tablelines tbody").sortable(),$("#tablelines tbody").sortable({handle:".move-line",connectWith:"#tablelines tbody .line-row",tolerance:"intersect",over:function(){$(this).css("cursor","grabbing")},stop:function(){$(this).css("cursor","default");var e=$(".fiche").find('input[name="token"]').val();let t="&",n=(document.URL.match(/action=/)&&(document.URL=document.URL.split(/\?/)[0],t="?"),[]);$(".line-row").each(function(){n.push($(this).attr("id"))}),$.ajax({url:document.URL+t+"action=moveLine&token="+e,type:"POST",data:JSON.stringify({order:n}),processData:!1,contentType:!1,success:function(){},error:function(){}})}})},window.saturne.utils.reloadPage=function(e,t,n="",o=""){var a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action="+e+n+"&token="+a,type:"POST",processData:!1,contentType:!1,success:function(e){window.saturne.utils.checkMoreParams(o),$(t).replaceWith($(e).find(t))},error:function(){}})},window.saturne.utils.reloadField=function(){var e=$(this).val(),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".field_element_type")),window.saturne.loader.display($(".field_fk_element")),$.ajax({url:document.URL+n+"element_type="+e+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(e){$(".field_element_type").replaceWith($(e).find(".field_element_type")),$(".field_fk_element").replaceWith($(e).find(".field_fk_element"))},error:function(){}})},window.saturne.utils.enforceMinMax=function(e){""!==e.value&&(parseInt(e.value)parseInt(e.max))&&(e.value=e.max)},window.saturne.utils.checkMoreParams=function(e){e&&e.removeAttr&&$(e.removeAttr.element).removeAttr(e.removeAttr.value)}; \ No newline at end of file +window.saturne||(window.saturne={},window.saturne.scriptsLoaded=!1),window.saturne.scriptsLoaded||(window.saturne.init=function(){window.saturne.load_list_script()},window.saturne.load_list_script=function(){if(!window.saturne.scriptsLoaded){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].init&&window.saturne[e].init(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].init&&window.saturne[e][t].init();window.saturne.scriptsLoaded=!0}},window.saturne.refresh=function(){var e=void 0,t=void 0;for(e in window.saturne)for(t in window.saturne[e].refresh&&window.saturne[e].refresh(),window.saturne[e])window.saturne[e]&&window.saturne[e][t]&&window.saturne[e][t].refresh&&window.saturne[e][t].refresh()},$(document).ready(window.saturne.init)),window.saturne.button={},window.saturne.button.init=function(){window.saturne.button.event()},window.saturne.button.event=function(){$(document).on("click",".wpeo-button:submit, .wpeo-button.auto-download",window.saturne.button.addLoader)},window.saturne.button.addLoader=function(){$(this).hasClass("no-load")||(window.saturne.loader.display($(this)),$(this).toggleClass("button-blue button-disable"))},window.saturne.dashboard={},window.saturne.dashboard.init=function(){window.saturne.dashboard.event()},window.saturne.dashboard.event=function(){$(document).on("change",".add-dashboard-widget",window.saturne.dashboard.addDashBoardInfo),$(document).on("click",".close-dashboard-widget",window.saturne.dashboard.closeDashBoardInfo),$(document).on("click",".select-dataset-dashboard-info",window.saturne.dashboard.selectDatasetDashboardInfo)},window.saturne.dashboard.addDashBoardInfo=function(){var e=document.getElementById("dashBoardForm"),e=new FormData(e).get("boxcombo"),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+n+"action=adddashboardinfo&token="+t,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(){window.location.reload()},error:function(){}})},window.saturne.dashboard.closeDashBoardInfo=function(){let t=$(this);var e=t.attr("data-widgetname"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+o+"action=closedashboardinfo&token="+n,type:"POST",processData:!1,data:JSON.stringify({dashboardWidgetName:e}),contentType:!1,success:function(e){t.closest(".box-flex-item").fadeOut(400),$(".add-widget-box").attr("style",""),$(".add-widget-box").html($(e).find(".add-widget-box").children())},error:function(){}})},window.saturne.dashboard.selectDatasetDashboardInfo=function(){var e=$("#search_userid").val(),t=$("#search_year").val(),n=$("#search_month").val(),o=window.saturne.toolbox.getToken(),a=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".fichecenter")),$.ajax({url:document.URL+a+"token="+o+"&search_userid="+e+"&search_year="+t+"&search_month="+n,type:"POST",processData:!1,contentType:!1,success:function(e){$(".fichecenter").replaceWith($(e).find(".fichecenter"))},error:function(){}})},window.saturne.document={},window.saturne.document.init=function(){window.saturne.document.event()},window.saturne.document.event=function(){$(document).on("click","#builddoc_generatebutton",window.saturne.document.displayLoader),$(document).on("click",".pdf-generation",window.saturne.document.displayLoader),$(document).on("click",".download-template",window.saturne.document.autoDownloadTemplate),$(document).on("keydown","#change_pagination",window.saturne.document.changePagination),$(document).on("keydown",".saturne-search",window.saturne.document.saturneSearch),$(document).on("click",".saturne-search-button",window.saturne.document.saturneSearch),$(document).on("click",".saturne-cancel-button",window.saturne.document.saturneCancelSearch)},window.saturne.document.displayLoader=function(){window.saturne.loader.display($(this).closest(".div-table-responsive-no-min"))},window.saturne.document.autoDownloadTemplate=function(){let t=window.saturne.toolbox.getToken();var e=document.URL.replace(/#.*$/,"");let n=window.saturne.toolbox.getQuerySeparator(e),o=$(this).closest(".file-generation");var a=o.find(".template-type").attr("value");let i=o.find(".template-name").attr("value");$.ajax({url:e+n+"action=download_template&filename="+i+"&type="+a+"&token="+t,type:"POST",success:function(){var e=o.find(".template-path").attr("value");window.saturne.signature.download(e+i,i),$.ajax({url:document.URL+n+"action=remove_file&filename="+i+"&token="+t,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.document.changePagination=function(e){var t;13===e.keyCode&&(e.preventDefault(),e=e.target,t=$("#page_number").val(),e=parseInt(e.value)<=parseInt(t)?e.value:t,(t=new URL(window.location.href)).searchParams.has("page")?t.searchParams.set("page",e):t.searchParams.append("page",e),window.location.replace(t.toString()))},window.saturne.document.saturneSearch=function(e){var t,n;13!==e.keyCode&&!$(this).hasClass("saturne-search-button")||(e.preventDefault(),e=new URL(window.location.href),t=$("#search_name").val(),n=$("#search_date").val(),""===t&&""===n)||(0body{"+e+n+e+t+n+t)},window.saturne.dropdown.open=function(e){var n=$(this),o=n.find("[data-fa-i2svg]"),t={},a=void 0;window.saturne.dropdown.close(e,$(this)),n.attr("data-action")?(window.saturne.loader.display(n),n.get_data(function(e){for(a in t)e[a]||(e[a]=t[a]);window.saturne.request.send(n,e,function(e,t){n.closest(".wpeo-dropdown").find(".saturne-dropdown-content").html(t.data.view),n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)})})):(n.closest(".wpeo-dropdown").addClass("dropdown-active"),o&&window.saturne.dropdown.toggleAngleClass(o)),e.stopPropagation()},window.saturne.dropdown.close=function(e){var n=$(this);$(".wpeo-dropdown.dropdown-active:not(.no-close)").each(function(){var e=$(this),t={close:!0};n.trigger("dropdown-before-close",[e,n,t]),t.close&&(e.removeClass("dropdown-active"),t=$(this).find(".dropdown-toggle").find("[data-fa-i2svg]"))&&window.saturne.dropdown.toggleAngleClass(t)})},window.saturne.dropdown.toggleAngleClass=function(e){e.hasClass("fa-caret-down")||e.hasClass("fa-caret-up")?e.toggleClass("fa-caret-down").toggleClass("fa-caret-up"):e.hasClass("fa-caret-circle-down")||e.hasClass("fa-caret-circle-up")?e.toggleClass("fa-caret-circle-down").toggleClass("fa-caret-circle-up"):e.hasClass("fa-angle-down")||e.hasClass("fa-angle-up")?e.toggleClass("fa-angle-down").toggleClass("fa-angle-up"):(e.hasClass("fa-chevron-circle-down")||e.hasClass("fa-chevron-circle-up"))&&e.toggleClass("fa-chevron-circle-down").toggleClass("fa-chevron-circle-up")},window.saturne.keyEvent={},window.saturne.keyEvent.init=function(){window.saturne.keyEvent.event()},window.saturne.keyEvent.event=function(){$(document).on("keydown",window.saturne.keyEvent.keyActions),$(document).on("keyup",".url-container",window.saturne.keyEvent.checkUrlFormat)},window.saturne.keyEvent.keyActions=function(e){0<$(this).find(".modal-active").length?("Escape"===e.key&&$(this).find(".modal-active .modal-close .fas.fa-times").first().click(),"Enter"!==e.key||$("input, textarea").is(":focus")||$(this).find(".modal-active .modal-footer .wpeo-button").not(".button-disable").first().click()):$(e.target).is("input, textarea")||("Enter"===e.key&&$(this).find(".button_search").click(),e.shiftKey&&"Enter"===e.key&&$(this).find(".button_removefilter").click())},window.saturne.keyEvent.checkUrlFormat=function(){$(this).val().match(/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi)?$(this).attr("style","border: solid; border-color: green"):0<$("input:focus").val().length&&$(this).attr("style","border: solid; border-color: red")},window.saturne.loader={},window.saturne.loader.init=function(){window.saturne.loader.event()},window.saturne.loader.event=function(){},window.saturne.loader.display=function(e){var t;e.hasClass("button-progress")?e.addClass("button-load"):(e.addClass("wpeo-loader"),t=$(''),e[0].loaderElement=t,e.append(e[0].loaderElement))},window.saturne.loader.remove=function(e){0"),i===a&&($(".wpeo-loader").removeClass("wpeo-loader"),$("#progressBarContainer").fadeOut(800),$("#progressBarContainer").find(".loader-spin").remove(),window.saturne.loader.display(o.find(".ecm-photo-list-content")),setTimeout(()=>{o.html($(e).find("#media_gallery").children()).promise().done(()=>{1==a&&($("#media_gallery").find(".save-photo").removeClass("button-disable"),$("#media_gallery").find(".delete-photo").removeClass("button-disable"),$("#media_gallery").find(".clickable-photo0").addClass("clicked-photo")),($(e).find(".error-medias").length?($(".messageErrorSendPhoto").find(".notice-subtitle").html(m),$(".messageErrorSendPhoto")):$(".messageSuccessSendPhoto")).removeClass("hidden"),o.attr("data-from-id",r),o.attr("data-from-type",s),o.attr("data-from-subtype",l),o.attr("data-from-subdir",c),o.find(".wpeo-button").attr("value",r)})},800))}})})},window.saturne.mediaGallery.previewPhoto=function(e){var t=setInterval(function(){$(".ui-dialog").length&&(clearInterval(t),$(document).find(".ui-dialog").addClass("preview-photo"))},100)},window.saturne.mediaGallery.unlinkFile=function(e){e.preventDefault();let t=window.saturne.toolbox.getToken();var e=$(this).closest(".modal-active"),n=0<$(this).closest(".modal-active").length;let o=null,a=(o=(n?e:$(this).closest(".linked-medias")).find(".modal-options")).attr("data-from-subtype"),i=o.attr("data-from-type"),d=o.attr("data-from-subdir"),r=o.attr("data-from-id"),s=o.attr("data-photo-class");n=$(this).closest(".media-container");let l=n.find(".file-path").val(),c=n.find(".file-name").val(),u=$(this).closest(".linked-medias").find(".media-gallery-favorite.favorite").closest(".media-container").find(".file-name").val(),w=(window.saturne.loader.display(n),window.saturne.toolbox.getQuerySeparator(document.URL));$(".card__confirmation").css("display","flex"),$(document).on("click",".confirmation-close",function(){$(".wpeo-loader").removeClass("wpeo-loader"),$(".card__confirmation").css("display","none")}),$(document).on("click",".confirmation-delete",function(){$.ajax({url:document.URL+w+"subaction=unlinkFile&token="+t,type:"POST",data:JSON.stringify({filepath:l,filename:c,objectSubtype:a,objectType:i,objectSubdir:d,objectId:r}),processData:!1,success:function(e){$(".card__confirmation").css("display","none"),$("#media_gallery .modal-container").replaceWith($(e).find("#media_gallery .modal-container")),u==c&&(void 0!==s&&0"))[1].match(/>/)&&(n[1]=n[1].replace(/>/,"")),$(this).attr("title",n[1]),$(this).html(n[0])}),t.css("width","30px"),t.find(".blockvmenusearch").hide(),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$(this).find("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),localStorage.setItem("maximized","false")):0<$(this).find("span.vmenu").find(".fa-chevron-circle-right").length&&(e.each(function(){$(this).html($(this).html().replace(">","")+" "+$(this).attr("title"))}),t.css("width","188px"),t.find(".blockvmenusearch").show(),$("div.menu_titre").attr("style","width: 188px !important; cursor : pointer"),$("span.vmenu").attr("title"," Réduire le menu"),$("span.vmenu").html(' Réduire le menu'),localStorage.setItem("maximized","true"),$(this).find("span.vmenu").find(".fa-chevron-circle-right").removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-left"))},window.saturne.menu.setMenu=function(){var e,t,n;0<$(".blockvmenu.blockvmenulast .saturne-toggle-menu").length&&($(".blockvmenu.blockvmenulast .saturne-toggle-menu").closest(".menu_titre").attr("style","cursor:pointer ! important"),"false"==localStorage.maximized&&$("#id-left").attr("style","display:none !important"),"false"==localStorage.maximized&&(e="",t=$("#id-left").find("a.vmenu, span.vmenudisabled, span.vmenu, a.vsmenu"),n=$(document).find("div.vmenu"),t.each(function(){e=$(this).html().split(""),$(this).attr("title",e[1]),$(this).html(e[0]),console.log(e)}),$("#id-left").attr("style","display:block !important"),$("div.menu_titre").attr("style","width: 50px !important"),$("span.vmenu").attr("title"," Agrandir le menu"),$("span.vmenu").html($("span.vmenu").html()),$("span.vmenu").find(".fa-chevron-circle-left").removeClass("fa-chevron-circle-left").addClass("fa-chevron-circle-right"),n.css("width","30px"),n.find(".blockvmenusearch").hide()),localStorage.setItem("currentString",""),localStorage.setItem("keypressNumber",0))},window.saturne.modal={},window.saturne.modal.init=function(){window.saturne.modal.event()},window.saturne.modal.event=function(){$(document).on("click",".modal-close, .modal-active:not(.modal-container)",window.saturne.modal.closeModal),$(document).on("click",".modal-open",window.saturne.modal.openModal),$(document).on("click",".modal-refresh",window.saturne.modal.refreshModal)},window.saturne.modal.openModal=function(e){var t=$(this).find(".modal-options"),n=t.attr("data-modal-to-open"),o=t.attr("data-from-id"),a=t.attr("data-from-type"),i=t.attr("data-from-subtype"),d=t.attr("data-from-subdir"),r=t.attr("data-from-module"),t=t.attr("data-photo-class");let s="";s=document.URL.match(/#/)?document.URL.split(/#/)[0]:document.URL,history.pushState({path:document.URL},"",s),$("#"+n).attr("data-from-id",o),$("#"+n).attr("data-from-type",a),$("#"+n).attr("data-from-subtype",i),$("#"+n).attr("data-from-subdir",d),$("#"+n).attr("data-photo-class",t),r&&"function"==typeof window.saturne.modal.addMoreOpenModalData&&window.saturne.modal.addMoreOpenModalData(n,$(this)),$("#"+n).find(".wpeo-button").attr("value",o),$("#"+n).addClass("modal-active"),$(".notice").addClass("hidden")},window.saturne.modal.closeModal=function(e){$("input:focus").length<1&&$("textarea:focus").length<1&&($(e.target).hasClass("modal-active")||$(e.target).hasClass("modal-close")||$(e.target).parent().hasClass("modal-close"))&&($(this).closest(".modal-active").removeClass("modal-active"),$(".clicked-photo").attr("style",""),$(".clicked-photo").removeClass("clicked-photo"),$(".notice").addClass("hidden"))},window.saturne.modal.refreshModal=function(e){window.location.reload()},window.saturne.notice={},window.saturne.notice.init=function(){window.saturne.notice.event()},window.saturne.notice.event=function(){$(document).on("click",".notice-close",window.saturne.notice.closeNotice)},window.saturne.notice.closeNotice=function(){$(this).closest(".wpeo-notice").fadeOut(function(){$(this).closest(".wpeo-notice").addClass("hidden")}),$(this).hasClass("notice-close-forever")&&window.saturne.utils.reloadPage("close_notice",".fiche")},window.saturne.object={},window.saturne.object.init=function(){window.saturne.object.event()},window.saturne.object.event=function(){$(document).on("click",".toggle-object-infos",window.saturne.object.toggleObjectInfos)},window.saturne.object.toggleObjectInfos=function(){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.object-infos").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.object-infos").removeClass("hidden"))},window.saturne.qrcode={},window.saturne.qrcode.init=function(){window.saturne.qrcode.event()},window.saturne.qrcode.event=function(){$(document).on("click",".preview-qr-code",window.saturne.qrcode.previewQRCode)},window.saturne.qrcode.previewQRCode=function(){let t=$(this).find(".qrcode-base64").val();var e=document.createElement("img"),n=(e.src=t,e.alt="QR Code",e.style.maxWidth="100%",document.getElementById("pdfPreview"));n.innerHTML="",n.appendChild(e),$("#pdfModal").addClass("modal-active"),document.getElementById("downloadBtn").onclick=function(){var e=document.createElement("a");e.href=t,e.download="QRCode.png",e.click()}},window.saturne.signature={},window.saturne.signature.canvas={},window.saturne.signature.init=function(){window.saturne.signature.event()},window.saturne.signature.event=function(){$(document).on("click",".signature-erase",window.saturne.signature.clearCanvas),$(document).on("click",".signature-validate:not(.button-disable)",window.saturne.signature.createSignature),$(document).on("click",".auto-download",window.saturne.signature.autoDownloadSpecimen),$(document).on("click",".copy-signatureurl",window.saturne.signature.copySignatureUrlClipboard),$(document).on("click",".set-attendance",window.saturne.signature.setAttendance),document.querySelector('script[src*="signature-pad.min.js"]')&&window.saturne.signature.drawSignatureOnCanvas(),$(document).on("touchstart mousedown",".canvas-signature",function(){window.saturne.toolbox.removeAddButtonClass("signature-validate","button-grey button-disable","button-blue")})},window.saturne.signature.drawSignatureOnCanvas=function(){var e;window.saturne.signature.canvas=document.querySelector(".canvas-signature"),window.saturne.signature.canvas&&(e=Math.max(window.devicePixelRatio||1,1),window.saturne.signature.canvas.signaturePad=new SignaturePad(window.saturne.signature.canvas,{penColor:"rgb(0, 0, 0)"}),window.saturne.signature.canvas.width=window.saturne.signature.canvas.offsetWidth*e,window.saturne.signature.canvas.height=window.saturne.signature.canvas.offsetHeight*e,window.saturne.signature.canvas.getContext("2d").scale(e,e))},window.saturne.signature.clearCanvas=function(){window.saturne.signature.canvas.signaturePad.clear(),window.saturne.toolbox.removeAddButtonClass("signature-validate","button-blue","button-grey button-disable")},window.saturne.signature.createSignature=function(){var e,t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.signature.canvas.signaturePad.isEmpty()||(e=window.saturne.signature.canvas.toDataURL()),window.saturne.loader.display($(this)),$.ajax({url:document.URL+n+"action=add_signature&token="+t,type:"POST",processData:!1,contentType:"application/octet-stream",data:JSON.stringify({signature:e}),success:function(e){!0===$(".public-card__container").data("public-interface")?($(".card__confirmation").removeAttr("style"),$(".signature-confirmation-close").attr("onclick","window.close()"),$(".public-card__container").replaceWith($(e).find(".public-card__container"))):window.location.reload()},error:function(){}})},window.saturne.signature.download=function(e,t){var n=document.createElement("a");n.href=e,n.setAttribute("download",t),n.click()},window.saturne.signature.autoDownloadSpecimen=function(){let o=$(this).closest(".file-generation"),a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action=builddoc&token="+a,type:"POST",success:function(e){var t=o.find(".specimen-name").attr("data-specimen-name"),n=o.find(".specimen-path").attr("data-specimen-path");window.saturne.signature.download(n+t,t),$(".file-generation").replaceWith($(e).find(".file-generation")),$.ajax({url:document.URL+i+"action=remove_file&token="+a,type:"POST",success:function(){},error:function(){}})},error:function(){}})},window.saturne.signature.copySignatureUrlClipboard=function(){var e=$(this).attr("data-signature-url");navigator.clipboard.writeText(e).then(()=>{$(this).attr("class","fas fa-check copy-signatureurl"),$(this).css("color","#59ed9c"),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").attr("style",""),$(this).closest(".copy-signatureurl-container").find(".copied-to-clipboard").fadeOut(2500,()=>{$(this).attr("class","fas fa-clipboard copy-signatureurl"),$(this).css("color","#666")})})},window.saturne.signature.setAttendance=function(){var e=$(this).closest(".attendance-container").find('input[name="signatoryID"]').val(),t=$(this).attr("value"),n=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL),a=String(document.location.href).replace(/#formmail/,"");$.ajax({url:a+o+"action=set_attendance&token="+n,type:"POST",processData:!1,contentType:"",data:JSON.stringify({signatoryID:e,attendance:t}),success:function(e){$(".signatures-container").html($(e).find(".signatures-container"))},error:function(){}})},window.saturne.toolbox={},window.saturne.toolbox.init=function(){},window.saturne.toolbox.getQuerySeparator=function(e){return e.match(/\?/)?"&":"?"},window.saturne.toolbox.getToken=function(){return $('input[name="token"]').val()},window.saturne.toolbox.toggleButtonClass=function(e,t){$("."+e).toggleClass(t)},window.saturne.toolbox.removeAddButtonClass=function(e,t,n){$("."+e).removeClass(t).addClass(n)},window.saturne.tooltip||(window.saturne.tooltip={},window.saturne.tooltip.init=function(){window.saturne.tooltip.event()},window.saturne.tooltip.tabChanged=function(){$(".wpeo-tooltip").remove()},window.saturne.tooltip.event=function(){$(document).on("mouseenter touchstart",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onEnter),$(document).on("mouseleave touchend",'.wpeo-tooltip-event:not([data-tooltip-persist="true"])',window.saturne.tooltip.onOut)},window.saturne.tooltip.onEnter=function(e){window.saturne.tooltip.display($(this))},window.saturne.tooltip.onOut=function(e){window.saturne.tooltip.remove($(this))},window.saturne.tooltip.display=function(e){var t=$(e).data("direction")?$(e).data("direction"):"top",n=$(''+$(e).attr("aria-label")+""),o=($(e).position(),$(e).offset()),a=($(e)[0].tooltipElement=n,$("body").append($(e)[0].tooltipElement),$(e).data("color")&&n.addClass("tooltip-"+$(e).data("color")),0),i=0;switch($(e).data("direction")){case"left":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left-n.outerWidth()-10+3+"px";break;case"right":a=o.top-n.outerHeight()/2+$(e).outerHeight()/2+"px",i=o.left+$(e).outerWidth()+8+"px";break;case"bottom":a=o.top+$(e).height()+10+10+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px";break;default:a=o.top-n.outerHeight()-4+"px",i=o.left-n.outerWidth()/2+$(e).outerWidth()/2+"px"}n.css({top:a,left:i,opacity:1}),$(e).on("remove",function(){$($(e)[0].tooltipElement).remove()})},window.saturne.tooltip.remove=function(e){$(e)[0]&&$(e)[0].tooltipElement&&$($(e)[0].tooltipElement).remove()}),window.saturne.utils={},window.saturne.utils.init=function(){window.saturne.utils.event()},window.saturne.utils.event=function(){$(document).on("mouseenter",".move-line.ui-sortable-handle",window.saturne.utils.draganddrop),$(document).on("change","#element_type",window.saturne.utils.reloadField)},window.saturne.utils.draganddrop=function(){$(this).css("cursor","pointer"),$("#tablelines tbody").sortable(),$("#tablelines tbody").sortable({handle:".move-line",connectWith:"#tablelines tbody .line-row",tolerance:"intersect",over:function(){$(this).css("cursor","grabbing")},stop:function(){$(this).css("cursor","default");var e=$(".fiche").find('input[name="token"]').val();let t="&",n=(document.URL.match(/action=/)&&(document.URL=document.URL.split(/\?/)[0],t="?"),[]);$(".line-row").each(function(){n.push($(this).attr("id"))}),$.ajax({url:document.URL+t+"action=moveLine&token="+e,type:"POST",data:JSON.stringify({order:n}),processData:!1,contentType:!1,success:function(){},error:function(){}})}})},window.saturne.utils.reloadPage=function(e,t,n="",o=""){var a=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+i+"action="+e+n+"&token="+a,type:"POST",processData:!1,contentType:!1,success:function(e){window.saturne.utils.checkMoreParams(o),$(t).replaceWith($(e).find(t))},error:function(){}})},window.saturne.utils.reloadField=function(){var e=$(this).val(),t=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".field_element_type")),window.saturne.loader.display($(".field_fk_element")),$.ajax({url:document.URL+n+"element_type="+e+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(e){$(".field_element_type").replaceWith($(e).find(".field_element_type")),$(".field_fk_element").replaceWith($(e).find(".field_fk_element"))},error:function(){}})},window.saturne.utils.enforceMinMax=function(e){""!==e.value&&(parseInt(e.value)parseInt(e.max))&&(e.value=e.max)},window.saturne.utils.checkMoreParams=function(e){e&&e.removeAttr&&$(e.removeAttr.element).removeAttr(e.removeAttr.value)}; \ No newline at end of file diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 99e46132..86892fe4 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -52,12 +52,15 @@ */ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, string $urlsource, $genallowed, int $delallowed = 0, string $modelselected = '', int $allowgenifempty = 1, int $forcenomultilang = 0, int $notused = 0, int $noform = 0, string $param = '', string $title = '', string $buttonlabel = '', string $codelang = '', string $morepicto = '', $object = null, int $hideifempty = 0, string $removeaction = 'remove_file', int $active = 1, string $tooltiptext = '', string $sortfield = '', string $sortorder = ''): string { - global $conf, $db, $form, $hookmanager, $langs; + global $conf, $db, $form, $hookmanager, $langs, $user; if (!is_object($form)) { $form = new Form($db); } + require_once __DIR__ . '/../class/saturneqrcode.class.php'; + $QRCode = new SaturneQRCode($db); + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; // Add entity in $param if not already exists @@ -288,6 +291,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= $form->textwithpicto($langs->trans('Help'), $htmltooltip, 1, 0); $out .= ''; } + $out .= ''; if (!empty($hookmanager->hooks['formfile'])) { @@ -308,6 +312,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= ''; $out .= get_document_title_search('date', 'Date', 'right'); $out .= ''; + $out .= ''; $out .= ''; @@ -353,6 +359,28 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= '
' . $langs->trans('URL') . '' . $langs->trans('QR Code') . '' . $langs->trans('QR Code') . '' . $langs->trans('ModuleName') . '' . $langs->trans('Action') . '
'; $out .= ''; $out .= ''; $out .= '   '; @@ -320,6 +325,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= get_document_title_field($sortfield, $sortorder, 'Size', true, 'right'); $out .= get_document_title_field($sortfield, $sortorder, 'Date', true, 'right'); $out .= get_document_title_field($sortfield, $sortorder, 'PDF', false, 'right'); + $out .= get_document_title_field($sortfield, $sortorder, 'QRCode', false, 'right'); $out .= get_document_title_field($sortfield, $sortorder, 'Action', false, 'right'); $out .= '
' . "\n"; } + ?> + + + + + '; + + // Loop on each file found if (is_array($fileList)) { foreach ($fileList as $file) { @@ -425,6 +453,26 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= ''; } + //Show QR Code + $documentQRCode = $QRCode->fetchAll('', '', 0, 0, ['url' => $documenturl . '?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')]); + if (is_array($documentQRCode) && !empty($documentQRCode)) { + $documentQRCode = array_shift($documentQRCode); + } else { + $QRCode->url = $documenturl . '?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''); + $QRCode->encoded_qr_code = $QRCode->getQRCodeBase64($QRCode->url); + $QRCode->status = 1; + $QRCode->module_name = $modulepart; + $QRCode->create($user); + $documentQRCode = $QRCode; + + } + + $out .= ''; + if ($delallowed || $morepicto) { $out .= '
'; + $out .= ''; + $out .= img_picto($langs->trans("QRCodeGeneration"), 'fontawesome_fa-qrcode_fas_blue'); + $out .= ' ' . $form->textwithpicto('', $langs->trans('QRCodeGenerationTooltip')); + $out .= ''; if ($delallowed) { From 1440d1df082ad4ac0fe330bdd7dc2564644feced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 6 Aug 2024 16:46:27 +0200 Subject: [PATCH 08/11] #1045 [QRCode] fix: translations --- admin/qrcode.php | 5 ++--- langs/fr_FR/saturne.lang | 8 ++++++++ lib/documents.lib.php | 5 ----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/admin/qrcode.php b/admin/qrcode.php index 9b0bfec8..0fe90aef 100644 --- a/admin/qrcode.php +++ b/admin/qrcode.php @@ -86,7 +86,7 @@ * View */ -$title = $langs->trans('RedirectionsSetup', $moduleName); +$title = $langs->trans('ModuleSetup', 'Saturne'); $help_url = 'FR:Module_' . $moduleName; saturne_header(0, '', $title, $help_url); @@ -102,8 +102,7 @@ print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/langs/fr_FR/saturne.lang b/langs/fr_FR/saturne.lang index c29a723a..37bc7603 100644 --- a/langs/fr_FR/saturne.lang +++ b/langs/fr_FR/saturne.lang @@ -217,6 +217,14 @@ Tools = Outils ExportData = Exporter mes données +# +# +# + +QRCode = QR Code +URLToEncode = URL à encoder +HowToUseURLToEncode = Ecrivez l'URL vers laquelle le QR Code doit pointer + # # Other - Autres diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 86892fe4..2c2b05b4 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -359,11 +359,6 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $out .= '
' . $langs->trans('URL') . '' . $langs->trans('QR Code') . '' . $langs->trans('QR Code') . '' . $langs->trans('ModuleName') . '' . $langs->trans('Action') . '
' . "\n"; } - ?> - - -
'; print ''; print ''; @@ -114,8 +130,12 @@ print ''; print ''; + print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; if (is_array($QRCodes) && !empty($QRCodes)) { foreach ($QRCodes as $QRCode) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($action == 'edit' && $QRCode->id == GETPOST('id')) { + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + } } } diff --git a/class/saturneqrcode.class.php b/class/saturneqrcode.class.php index bf1d2808..0b1b1a90 100644 --- a/class/saturneqrcode.class.php +++ b/class/saturneqrcode.class.php @@ -58,7 +58,7 @@ class SaturneQRCode extends SaturneObject /** * @var int Does object support extrafields ? 0 = No, 1 = Yes */ - public $isextrafieldmanaged = 1; + public $isextrafieldmanaged = 0; /** * @var string Last output from end job execution diff --git a/langs/fr_FR/saturne.lang b/langs/fr_FR/saturne.lang index 37bc7603..f454230c 100644 --- a/langs/fr_FR/saturne.lang +++ b/langs/fr_FR/saturne.lang @@ -224,6 +224,11 @@ ExportData = Exporter mes données QRCode = QR Code URLToEncode = URL à encoder HowToUseURLToEncode = Ecrivez l'URL vers laquelle le QR Code doit pointer +QRCodeCreated = QR Code créé +QRCodeUpdated = QR Code mis à jour +QRCodeRemoved = QR Code supprimé +URLToEncodeRequired = L'URL à encoder est obligatoire +QRCodeGenerationTooltip = Appuyez sur ce bouton pour voir le QR Code # diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 2c2b05b4..481bf1c4 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -453,7 +453,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str if (is_array($documentQRCode) && !empty($documentQRCode)) { $documentQRCode = array_shift($documentQRCode); } else { - $QRCode->url = $documenturl . '?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''); + $QRCode->url = DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''); $QRCode->encoded_qr_code = $QRCode->getQRCodeBase64($QRCode->url); $QRCode->status = 1; $QRCode->module_name = $modulepart; diff --git a/lib/saturne.lib.php b/lib/saturne.lib.php index 7b7a3be3..767bc574 100644 --- a/lib/saturne.lib.php +++ b/lib/saturne.lib.php @@ -53,7 +53,7 @@ function saturne_admin_prepare_head(): array $head[$h][2] = 'information'; $h++; - $head[$h][0] = dol_buildpath('/saturne/admin/qrcode.php', 1) . '?filename=saturne_dev&tab_name=qrcode'; + $head[$h][0] = dol_buildpath('/saturne/admin/qrcode.php', 1); $head[$h][1] = '' . $langs->trans('QRCode'); $head[$h][2] = 'qrcode'; $h++; From 6e3aefbb7167e9c5e376c58f773f5168f0e44ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 10 Sep 2024 11:07:29 +0200 Subject: [PATCH 11/11] #1045 [QRCode] fix: PSR12 & useless fields --- admin/qrcode.php | 17 ++++++++--------- class/saturneqrcode.class.php | 6 ------ lib/saturne_functions.lib.php | 1 - sql/qrcode/llx_saturne_qrcode.key.sql | 2 -- sql/qrcode/llx_saturne_qrcode.sql | 3 +-- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/admin/qrcode.php b/admin/qrcode.php index 3ade663a..0bc605cb 100644 --- a/admin/qrcode.php +++ b/admin/qrcode.php @@ -1,5 +1,5 @@ url = $url; + $saturneQRCode->url = $url; $saturneQRCode->encoded_qr_code = $saturneQRCode->getQRCodeBase64($url); - $saturneQRCode->module_name = 'saturne'; - $saturneQRCode->status = 1; + $saturneQRCode->module_name = 'saturne'; $saturneQRCode->create($user); setEventMessage('QRCodeCreated'); @@ -87,7 +86,7 @@ if ($action == 'update') { $saturneQRCode->fetch(GETPOST('id')); - $saturneQRCode->url = GETPOST('url'); + $saturneQRCode->url = GETPOST('url'); $saturneQRCode->encoded_qr_code = $saturneQRCode->getQRCodeBase64($saturneQRCode->url); $saturneQRCode->update($user); diff --git a/class/saturneqrcode.class.php b/class/saturneqrcode.class.php index 0b1b1a90..11578c98 100644 --- a/class/saturneqrcode.class.php +++ b/class/saturneqrcode.class.php @@ -79,7 +79,6 @@ class SaturneQRCode extends SaturneObject 'date_creation' => ['type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 40, 'notnull' => 1, 'visible' => 0], 'tms' => ['type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 50, 'notnull' => 1, 'visible' => 0], 'import_key' => ['type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 0, 'index' => 0], - 'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 2, 'default' => 0, 'index' => 1, 'validate' => 1, 'arrayofkeyval' => [0 => 'StatusDraft', 1 => 'ValidatePendingSignature', 2 => 'Expired', 3 => 'Archived']], 'module_name' => ['type' => 'varchar(128)', 'label' => 'ModuleName', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 0], 'url' => ['type' => 'text', 'label' => 'Url', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 0, 'index' => 0], 'encoded_qr_code' => ['type' => 'text', 'label' => 'EncodedData', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 0, 'index' => 0], @@ -111,11 +110,6 @@ class SaturneQRCode extends SaturneObject */ public $import_key; - /** - * @var int Status - */ - public $status; - /** * @var string Module name */ diff --git a/lib/saturne_functions.lib.php b/lib/saturne_functions.lib.php index 96ff40c6..8f027707 100644 --- a/lib/saturne_functions.lib.php +++ b/lib/saturne_functions.lib.php @@ -348,7 +348,6 @@ function saturne_load_langs(array $domains = []) global $langs, $moduleNameLowerCase; $langs->loadLangs(['saturne@saturne', 'object@saturne', 'signature@saturne', 'medias@saturne', $moduleNameLowerCase . '@' . $moduleNameLowerCase]); - if (!empty($domains)) { foreach ($domains as $domain) { $langs->load($domain); diff --git a/sql/qrcode/llx_saturne_qrcode.key.sql b/sql/qrcode/llx_saturne_qrcode.key.sql index 8551b3c1..2fc71717 100644 --- a/sql/qrcode/llx_saturne_qrcode.key.sql +++ b/sql/qrcode/llx_saturne_qrcode.key.sql @@ -14,6 +14,4 @@ -- along with this program. If not, see https://www.gnu.org/licenses/. ALTER TABLE llx_saturne_qrcode ADD INDEX idx_saturne_object_qrcode_rowid (rowid); -ALTER TABLE llx_saturne_qrcode ADD INDEX idx_saturne_object_qrcode_ref (ref); -ALTER TABLE llx_saturne_qrcode ADD INDEX idx_saturne_object_qrcode_status (status); ALTER TABLE llx_saturne_qrcode ADD CONSTRAINT llx_saturne_qrcode_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); diff --git a/sql/qrcode/llx_saturne_qrcode.sql b/sql/qrcode/llx_saturne_qrcode.sql index dea2b39b..3b795690 100644 --- a/sql/qrcode/llx_saturne_qrcode.sql +++ b/sql/qrcode/llx_saturne_qrcode.sql @@ -1,4 +1,4 @@ --- Copyright (C) 2021-2023 EVARISK +-- Copyright (C) 2024 EVARISK -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -19,7 +19,6 @@ CREATE TABLE llx_saturne_qrcode( date_creation datetime NOT NULL, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, import_key varchar(14), - status integer DEFAULT 1 NOT NULL, module_name varchar(255), url text, encoded_qr_code longtext,
' . $langs->trans('URL') . '
'; print $QRCode->url; - print ''; - print 'QR Code'; + print ''; + print ''; + print img_picto($langs->trans("QRCodeGeneration"), 'fontawesome_fa-qrcode_fas_blue'); + print ' ' . $form->textwithpicto('', $langs->trans('QRCodeGenerationTooltip')); + print ''; print ucfirst($QRCode->module_name); print ''; From 29599e6aa0e09f15731922d572f5ffb09dd439f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Tue, 6 Aug 2024 17:47:09 +0200 Subject: [PATCH 10/11] #1045 [QRCode] fix: CRUD --- admin/qrcode.php | 88 +++++++++++++++++++++++++++-------- class/saturneqrcode.class.php | 2 +- langs/fr_FR/saturne.lang | 5 ++ lib/documents.lib.php | 2 +- lib/saturne.lib.php | 2 +- 5 files changed, 77 insertions(+), 22 deletions(-) diff --git a/admin/qrcode.php b/admin/qrcode.php index 1f611ba0..3ade663a 100644 --- a/admin/qrcode.php +++ b/admin/qrcode.php @@ -69,17 +69,41 @@ // Add a redirection if ($action == 'add') { + if (dol_strlen($url) == 0) { + setEventMessage('URLToEncodeRequired', 'errors'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; + } $saturneQRCode->url = $url; $saturneQRCode->encoded_qr_code = $saturneQRCode->getQRCodeBase64($url); $saturneQRCode->module_name = 'saturne'; $saturneQRCode->status = 1; $saturneQRCode->create($user); + + setEventMessage('QRCodeCreated'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; +} + +if ($action == 'update') { + $saturneQRCode->fetch(GETPOST('id')); + $saturneQRCode->url = GETPOST('url'); + $saturneQRCode->encoded_qr_code = $saturneQRCode->getQRCodeBase64($saturneQRCode->url); + $saturneQRCode->update($user); + + setEventMessage('QRCodeUpdated'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; } // Remove a redirection if ($action == 'remove') { $saturneQRCode->fetch(GETPOST('id')); $saturneQRCode->delete($user, false, false); + + setEventMessage('QRCodeRemoved'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; } /* @@ -120,29 +144,55 @@ print '' . $langs->trans('URL') . '' . $langs->trans('QR Code') . '' . $langs->trans('ModuleName') . '' . $langs->trans('Action') . '' . $langs->trans('Actions') . '
'; - print $QRCode->url; - print ''; - print ''; - print img_picto($langs->trans("QRCodeGeneration"), 'fontawesome_fa-qrcode_fas_blue'); - print ' ' . $form->textwithpicto('', $langs->trans('QRCodeGenerationTooltip')); - print ''; - print ucfirst($QRCode->module_name); - print ''; - print ''; - print ''; - print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $QRCode->url; + print ''; + print ''; + print img_picto($langs->trans("QRCodeGeneration"), 'fontawesome_fa-qrcode_fas_blue'); + print ' ' . $form->textwithpicto('', $langs->trans('QRCodeGenerationTooltip')); + print ''; + print ucfirst($QRCode->module_name); + print ''; + + // Modify this section to use anchor tags for edit and delete actions + print ''; + print img_picto($langs->trans('Edit'), 'edit'); + print ' '; + // Form for Remove action using a form with token and a styled submit button + print '
'; + print ''; // Token for CSRF protection + print ''; // Action to remove the QR code + print ''; // ID of the QR code to be removed + print ''; + print '
'; + + + print '