28if (!defined(
'NOREQUIRESOC')) {
29 define(
'NOREQUIRESOC',
'1');
31if (!defined(
'NOCSRFCHECK')) {
32 define(
'NOCSRFCHECK', 1);
34if (!defined(
'NOTOKENRENEWAL')) {
35 define(
'NOTOKENRENEWAL', 1);
37if (!defined(
'NOLOGIN')) {
40if (!defined(
'NOREQUIREMENU')) {
41 define(
'NOREQUIREMENU', 1);
43if (!defined(
'NOREQUIREHTML')) {
44 define(
'NOREQUIREHTML', 1);
46if (!defined(
'NOREQUIREAJAX')) {
47 define(
'NOREQUIREAJAX',
'1');
50session_cache_limiter(
'public');
52require_once
'../../main.inc.php';
62if (empty($dolibarr_nocache)) {
63 header(
'Cache-Control: max-age=10800, public, must-revalidate');
65 header(
'Cache-Control: no-cache');
86$tradMonthsShort = array(
87$langs->trans(
"MonthShort01"),
88$langs->trans(
"MonthShort02"),
89$langs->trans(
"MonthShort03"),
90$langs->trans(
"MonthShort04"),
91$langs->trans(
"MonthShort05"),
92$langs->trans(
"MonthShort06"),
93$langs->trans(
"MonthShort07"),
94$langs->trans(
"MonthShort08"),
95$langs->trans(
"MonthShort09"),
96$langs->trans(
"MonthShort10"),
97$langs->trans(
"MonthShort11"),
98$langs->trans(
"MonthShort12")
102$langs->trans(
"Sunday"),
103$langs->trans(
"Monday"),
104$langs->trans(
"Tuesday"),
105$langs->trans(
"Wednesday"),
106$langs->trans(
"Thursday"),
107$langs->trans(
"Friday"),
108$langs->trans(
"Saturday")
111$tradDaysShort = array(
112$langs->trans(
"ShortSunday"),
113$langs->trans(
"ShortMonday"),
114$langs->trans(
"ShortTuesday"),
115$langs->trans(
"ShortWednesday"),
116$langs->trans(
"ShortThursday"),
117$langs->trans(
"ShortFriday"),
118$langs->trans(
"ShortSaturday")
122$langs->trans(
"SundayMin"),
123$langs->trans(
"MondayMin"),
124$langs->trans(
"TuesdayMin"),
125$langs->trans(
"WednesdayMin"),
126$langs->trans(
"ThursdayMin"),
127$langs->trans(
"FridayMin"),
128$langs->trans(
"SaturdayMin")
134if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
135 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
137if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
138 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
140if ($thousand ==
'Space') {
148var tradMonths = <?php echo json_encode($tradMonths) ?>;
149var tradMonthsShort = <?php echo json_encode($tradMonthsShort) ?>;
150var tradDays = <?php echo json_encode($tradDays) ?>;
151var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>;
152var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>;
153var currencyCache = <?php echo json_encode($langs->cache_currencies) ?>;
156$(document).ready(
function() {
157 $.datepicker.setDefaults({
161 altField:
'#timestamp',
167 $.datepicker.regional[
'<?php echo $langs->defaultlang ?>'] = {
168 closeText:
'<?php echo $langs->trans("Close2") ?>',
169 prevText:
'<?php echo $langs->trans("Previous") ?>',
170 nextText:
'<?php echo $langs->trans("Next") ?>',
171 currentText:
'<?php echo $langs->trans("Now") ?>',
172 monthNames: tradMonths,
173 monthNamesShort: tradMonthsShort,
175 dayNamesShort: tradDaysShort,
176 dayNamesMin: tradDaysMin,
177 weekHeader:
'<?php echo $langs->trans("Week"); ?>',
178 dateFormat:
'<?php echo $langs->trans("FormatDateShortJQuery"); ?>',
179 firstDay: <?php echo(isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK :
'1'); ?>,
180 isRTL: <?php echo($langs->trans(
"DIRECTION") ==
'rtl' ?
'true' :
'false'); ?>,
181 showMonthAfterYear:
false,
184 $.datepicker.setDefaults($.datepicker.regional[
'<?php echo $langs->defaultlang ?>']);
193var select2arrayoflanguage = {
194 matches:
function (matches) {
return matches +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2ResultFoundUseArrows
")); ?>"; },
195 noResults:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2NotFound
")); ?>"; },
196 inputTooShort:
function (input) {
197 var n = input.minimum;
199 if (n > 1)
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacters
")); ?>";
200 else return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacter
")); ?>"
202 loadMore:
function (pageNumber) {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2LoadingMoreResults
")); ?>"; },
203 searching:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2SearchInProgress
")); ?>"; }
212function getObjectFromID(
id){
214 if(document.getElementById)
215 theObject=document.getElementById(
id);
217 theObject=document.all[id];
222function dpChangeDay(dateFieldID, format)
225 console.log(
"Call dpChangeDay, we save date into detailed fields from format = "+format);
227 var thefield=getObjectFromID(dateFieldID);
228 var thefieldday=getObjectFromID(dateFieldID+
"day");
229 var thefieldmonth=getObjectFromID(dateFieldID+
"month");
230 var thefieldyear=getObjectFromID(dateFieldID+
"year");
232 var date=getDateFromFormat(thefield.value, format);
236 thefieldday.value=date.getDate();
237 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
238 thefieldmonth.value=date.getMonth()+1;
239 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
240 thefieldyear.value=date.getFullYear();
241 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
245 thefieldday.value=
'';
246 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
247 thefieldmonth.value=
'';
248 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
249 thefieldyear.value=
'';
250 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
268function formatDate(date,format)
277 var year=date.getFullYear();
278 var month=date.getMonth()+1;
279 var day=date.getDate();
280 var hour=date.getHours();
281 var minute=date.getMinutes();
282 var seconde=date.getSeconds();
285 while (i < format.length)
290 while ((format.charAt(j)==c) && (j < format.length))
292 substr += format.charAt(j++);
296 if (substr ==
'yyyy') { result=result+year; }
297 else if (substr ==
'yy') { result=result+year.substring(2,4); }
298 else if (substr ==
'M') { result=result+month; }
299 else if (substr ==
'MM') { result=result+(month<1||month>9?
"":
"0")+month; }
300 else if (substr ==
'd') { result=result+day; }
301 else if (substr ==
'dd') { result=result+(day<1||day>9?
"":
"0")+day; }
302 else if (substr ==
'hh') {
if (hour > 12) hour-=12; result=result+(hour<0||hour>9?
"":
"0")+hour; }
303 else if (substr ==
'HH') { result=result+(hour<0||hour>9?
"":
"0")+hour; }
304 else if (substr ==
'mm') { result=result+(minute<0||minute>9?
"":
"0")+minute; }
305 else if (substr ==
'ss') { result=result+(seconde<0||seconde>9?
"":
"0")+seconde; }
306 else { result=result+substr; }
336function getDateFromFormat(val,format)
344 if (val ==
'')
return 0;
347 var year=now.getFullYear();
348 var month=now.getMonth()+1;
349 var day=now.getDate();
350 var hour=now.getHours();
351 var minute=now.getMinutes();
352 var seconde=now.getSeconds();
358 while (i < format.length)
363 while ((format.charAt(j)==c) && (j < format.length))
367 substr += format.charAt(j++);
371 if (substr ==
"yyyy") year=getIntegerInString(val,d,4,4);
372 if (substr ==
"yy") year=
""+(getIntegerInString(val,d,2,2)-0+2000);
373 if (substr ==
"MM" ||substr ==
"M")
375 month=getIntegerInString(val,d,1,2);
376 if (month) d -= 2- month.length;
380 day=getIntegerInString(val,d,1,2);
381 if (day) d -= 2- day.length;
383 if (substr ==
"HH" ||substr ==
"hh" )
385 hour=getIntegerInString(val,d,1,2);
386 if (dhouray) d -= 2- hour.length;
389 minute=getIntegerInString(val,d,1,2);
390 if (minute) d -= 2- minute.length;
394 seconde=getIntegerInString(val,d,1,2);
395 if (seconde) d -= 2- seconde.length;
403 if (year==
null||year<1) {
return 0; }
404 if (month==
null||(month<1)||(month>12)) {
return 0; }
405 if (day==
null||(day<1)||(day>31)) {
return 0; }
406 if (hour==
null||(hour<0)||(hour>24)) {
return 0; }
407 if (minute==
null||(minute<0)||(minute>60)) {
return 0; }
408 if (seconde==
null||(seconde<0)||(seconde>60)) {
return 0; }
411 return new Date(year,month-1,day,hour,minute,seconde);
420function stringIsInteger(str)
422 var digits=
"1234567890";
423 for (var i=0; i < str.length; i++)
425 if (digits.indexOf(str.charAt(i))==-1)
439function getIntegerInString(str,i,minlength,maxlength)
441 for (var x=maxlength; x>=minlength; x--)
443 var substr=str.substring(i,i+x);
444 if (substr.length < minlength) {
return null; }
445 if (stringIsInteger(substr)) {
return substr; }
459function urlencode(s) {
461 news = news.replace(/\+/gi,
'%2B');
462 news = news.replace(/&/gi,
'%26');
474function htmlEntityDecodeJs(inp){
475 var replacements = {
'<':
'<',
'>':
'>',
'/':
'/',
'"':
'"',
''':
'\'',
'&':
'&',
' ':
' '};
477 for(var r in replacements){
478 inp = inp.replace(
new RegExp(r,
'g'),replacements[r]);
480 return inp.replace(/&#(\d+);/g,
function(match, dec) {
481 return String.fromCharCode(dec);
497 function ac_delay(funct,delay) {
499 setTimeout(funct,delay);
512function cleanSerialize(expr) {
513 if (typeof(expr) !=
'string') {
516 var reg =
new RegExp(
"(&)",
"g");
517 var reg2 =
new RegExp(
"[^A-Z0-9,]",
"g");
518 var liste1 = expr.replace(reg,
",");
519 return liste1.replace(reg2,
"");
533function displayMessage(fieldId,message) {
534 var textbox = document.getElementById(fieldId);
535 if (textbox.value ==
'') {
536 textbox.style.color =
'grey';
537 textbox.value = message;
551function hideMessage(fieldId,message) {
552 var textbox = document.getElementById(fieldId);
553 textbox.style.color =
'black';
554 if (textbox.value == message) textbox.value =
'';
574function setConstant(url, code, input, entity, strict, forcereload, userid, token, value, userconst) {
586 console.log(
"Ajax url request to set constant is a success. Make complementary actions and then forcereload="+forcereload+
" value="+value);
588 $(
"#set_" + code).show();
589 $(
"#del_" + code).hide();
591 $(
"#set_" + code).hide();
592 $(
"#del_" + code).show();
594 $.each(input,
function(
type, data) {
596 if (
type ==
"disabled" && strict != 1) {
597 $.each(data,
function(key, value) {
598 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
599 $(newvalue).removeAttr(
"disabled");
600 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
601 $(newvalue).removeClass(
"butActionRefused");
602 $(newvalue).addClass(
"butAction");
605 }
else if (
type ==
"enabled") {
606 $.each(data,
function(key, value) {
607 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
609 $(newvalue).removeAttr(
"disabled");
611 $(newvalue).attr(
"disabled",
true);
612 if ($(newvalue).hasClass(
"butAction") ==
true) {
613 $(newvalue).removeClass(
"butAction");
614 $(newvalue).addClass(
"butActionRefused");
618 }
else if (
type ==
"showhide" ||
type ==
"show") {
619 $.each(data,
function(key, value) {
620 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
624 }
else if (
type ==
"set") {
625 $.each(data,
function(key, value) {
626 $(
"#set_" + key).hide();
627 $(
"#del_" + key).show();
639 var url = window.location.href;
640 if (url.indexOf(
'dol_resetcache') < 0) {
641 if (url.indexOf(
'?') > -1) {
642 url = url +
"&dol_resetcache=1";
644 url = url +
"?dol_resetcache=1";
647 var page_y = $(document).scrollTop();
648 url = url.replace(/page_y=\d+/g,
'');
650 if (url.indexOf(
'?') > -1) {
651 url = url +
"&page_y="+page_y;
653 url = url +
"?page_y="+page_y;
656 url = url.replace(/&&+/,
'&');
657 console.log(
"url ro redirect = "+url);
659 window.location.href = url;
663 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
683function delConstant(url, code, input, entity, strict, forcereload, userid, token, userconst) {
694 console.log(
"Ajax url request to delete constant is success. Make complementary actions and then forcereload="+forcereload);
695 $(
"#del_" + code).hide();
696 $(
"#set_" + code).show();
697 $.each(input,
function(
type, data) {
699 if (
type ==
"disabled") {
700 $.each(data,
function(key, value) {
701 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
702 $(newvalue).attr(
"disabled",
true);
703 if ($(newvalue).hasClass(
"butAction") ==
true) {
704 $(newvalue).removeClass(
"butAction");
705 $(newvalue).addClass(
"butActionRefused");
708 }
else if (
type ==
"enabled" && strict != 1) {
709 $.each(data,
function(key, value) {
710 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
711 $(newvalue).removeAttr(
"disabled");
712 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
713 $(newvalue).removeClass(
"butActionRefused");
714 $(newvalue).addClass(
"butAction");
718 }
else if (
type ==
"showhide" ||
type ==
"hide") {
719 $.each(data,
function(key, value) {
720 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
724 }
else if (
type ==
"del") {
725 $.each(data,
function(key, value) {
726 $(
"#del_" + value).hide();
727 $(
"#set_" + value).show();
738 var url = window.location.href;
739 if (url.indexOf(
'dol_resetcache') < 0) {
740 if (url.indexOf(
'?') > -1) {
741 url = url +
"&dol_resetcache=1";
743 url = url +
"?dol_resetcache=1";
746 var page_y = $(document).scrollTop();
747 url = url.replace(/page_y=\d+/g,
'');
749 if (url.indexOf(
'?') > -1) {
750 url = url +
"&page_y="+page_y;
752 url = url +
"?page_y="+page_y;
755 url = url.replace(/&&+/,
'&');
756 console.log(
"url ro redirect = "+url);
758 window.location.href = url;
762 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
784function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid, token) {
785 var boxConfirm = box;
786 $(
"#confirm_" + code)
787 .attr(
"title", boxConfirm.title)
788 .html(boxConfirm.content)
796 id :
'yesButton_' + code,
799 if (action ==
"set") {
800 setConstant(url, code, input, entity, strict, 0, userid, token, 1);
801 }
else if (action ==
"del") {
802 delConstant(url, code, input, entity, strict, 0, userid, token);
805 $(
this).dialog(
"close");
807 if (boxConfirm.method) {
808 var fnName = boxConfirm.method;
809 if (window.hasOwnProperty(fnName)) {
816 id :
'noButton_' + code,
819 $(
this).dialog(
"close");
825 if (boxConfirm.info) {
826 $(
"#noButton_" + code).button().hide();
842 $.widget(
"ui.combobox", {
844 minLengthToAutocomplete: 0
846 _create:
function() {
847 var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
849 select = this.element.hide(),
850 selected = select.children(
":selected" ),
851 value = selected.val() ? selected.text() :
"";
852 var input = this.input = $(
"<input>" )
853 .insertAfter( select )
855 .attr(
'id',
'inputautocomplete'+select.attr(
'id'))
858 minLength: this.options.minLengthToAutocomplete,
859 source:
function( request, response ) {
860 var matcher =
new RegExp( $.ui.autocomplete.escapeRegex(request.term),
"i" );
861 response( select.children(
"option:enabled" ).map(
function() {
862 var text = $( this ).text();
863 if ( this.value && ( !request.term || matcher.test(text) ) )
867 "(?![^&;]+;)(?!<[^<>]*)(" +
868 $.ui.autocomplete.escapeRegex(request.term) +
869 ")(?![^<>]*>)(?![^&;]+;)",
"gi"
870 ),
"<strong>$1</strong>" ),
876 select:
function( event, ui ) {
877 ui.item.option.selected =
true;
878 self._trigger(
"selected", event, {
882 change:
function( event, ui ) {
884 var matcher =
new RegExp(
"^" + $.ui.autocomplete.escapeRegex( $(
this).val() ) +
"$",
"i" ),
886 select.children(
"option" ).each(
function() {
887 if ( $(
this ).text().match( matcher ) ) {
888 this.selected = valid =
true;
896 input.data(
"ui-autocomplete").term =
"";
902 .addClass(
"ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
904 input.data(
"ui-autocomplete")._renderItem =
function( ul, item ) {
906 .data(
"ui-autocomplete-item", item )
907 .append(
"<a>" + item.label +
"</a>" )
911 this.
button = $(
"<button type=\'button\'> </button>" )
912 .attr(
"tabIndex", -1 )
913 .attr(
"title",
"Show All Items" )
914 .insertAfter( input )
917 primary:
"ui-icon-triangle-1-s"
921 .removeClass(
"ui-corner-all" )
922 .addClass(
"ui-corner-right ui-button-icon" )
925 if ( input.autocomplete(
"widget" ).is(
":visible" ) ) {
926 input.autocomplete(
"close" );
931 input.autocomplete({ minLength: 0 });
932 input.autocomplete(
"search",
"" );
933 input.autocomplete({ minLength: savMinLengthToAutocomplete });
938 destroy:
function() {
942 $.Widget.prototype.destroy.call(
this );
957 text = text.replace(/<br>/g,
"\n");
958 var newElem =
'<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+
'</textarea><br><br>'+text2;
960 $(
"#dialogforpopup").html(newElem);
961 $(
"#dialogforpopup").dialog();
962 $(
"#coordsforpopup").select();
978 var argc =
newpopup.arguments.length;
980 console.log(
"newpopup "+argv[2]+
" "+argv[3]);
981 var l = (argc > 2) ? argv[2] : 600;
982 var h = (argc > 3) ? argv[3] : 400;
983 var left = (screen.width - l)/2;
984 var top = (screen.height - h)/2;
985 var wfeatures =
"directories=0,menubar=0,status=0,resizable=0,scrollbars=1,toolbar=0,location=0,width=" + l +
",height=" + h +
",left=" + left +
",top=" + top;
986 fen = window.open(tmp, title, wfeatures);
1003 var ValidImageTypes = [
"image/gif",
"image/jpeg",
"image/png",
"image/webp"];
1004 var showOriginalSizeButton =
false;
1006 console.log(
"document_preview A click was done: file="+file+
", type="+
type+
", title="+title);
1008 if ($.inArray(
type, ValidImageTypes) < 0) {
1011 var object_width=
'100%';
1012 var height = ($( window ).height() - 60) * 0.90;
1013 var object_height=
'98%';
1015 show_preview(
'notimage');
1020 var object_height=0;
1022 var img =
new Image();
1024 img.onload =
function() {
1025 object_width = this.width;
1026 object_height = this.height;
1028 width = $( window ).width()*0.90;
1029 console.log(
"object_width="+object_width+
" window width="+width);
1030 if(object_width < width){
1031 console.log(
"Object width is small, we set width of popup according to image width.");
1032 width = object_width + 30
1034 height = $( window ).height()*0.85;
1035 console.log(
"object_height="+object_height+
" window height="+height);
1036 if(object_height < height){
1037 console.log(
"Object height is small, we set height of popup according to image height.");
1038 height = object_height + 80
1042 showOriginalSizeButton =
true;
1045 show_preview(
'image');
1052 function show_preview(mode) {
1054 var newElem =
'<object name="objectpreview" data="'+file+
'" type="'+
type+
'" width="'+object_width+
'" height="'+object_height+
'" param="noparam"></object>';
1057 if (mode ==
'image' && showOriginalSizeButton)
1061 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("OriginalSize
")); ?>":
function() { console.log(
"Click on original size"); jQuery(
".ui-dialog-content.ui-widget-content > object").css({
"max-height":
"none" }); },
1062 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("RotateImage
")); ?>":
function() { curRot += 90; jQuery(
".ui-dialog-content.ui-widget-content > object").css(
"transform",
"rotate(" + curRot +
"deg)"); },
1063 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("CloseWindow
")); ?>":
function() { $(
this ).dialog(
"close" ); }
1067 $(
"#dialogforpopup").html(newElem);
1069 $(
"#dialogforpopup").dialog({
1070 closeOnEscape:
true,
1076 buttons: optionsbuttons
1079 if (showOriginalSizeButton)
1081 jQuery(
".ui-dialog-content.ui-widget-content > object").css({
"max-height":
"100%",
"width":
"auto",
"margin-left":
"auto",
"margin-right":
"auto",
"display":
"block" });
1093function getParameterByName(
name, valueifnotfound)
1095 name =
name.replace(/[\[]/,
"\\[").replace(/[\]]/,
"\\]");
1096 var regex =
new RegExp(
"[\\?&]" +
name +
"=([^&#]*)"),
1097 results = regex.exec(location.search);
1098 return results ===
null ? valueifnotfound : decodeURIComponent(results[1].replace(/\+/g,
" "));
1107 const operatorList = {
1109 Contains:
"<?php print $langs->trans('Contains'); ?>",
1110 DoesNotContain:
"<?php print $langs->trans('DoesNotContain'); ?>",
1111 Is:
"<?php print $langs->trans('Is'); ?>",
1112 IsNot:
"<?php print $langs->trans('IsNot'); ?>",
1113 StartsWith:
"<?php print $langs->trans('StartsWith'); ?>",
1114 EndsWith:
"<?php print $langs->trans('EndsWith'); ?>"
1125 Is:
"<?php print $langs->trans('Is'); ?>",
1126 IsNot:
"<?php print $langs->trans('IsNot'); ?>",
1127 IsBefore:
"<?php print $langs->trans('IsBefore'); ?>",
1128 IsAfter:
"<?php print $langs->trans('IsAfter'); ?>",
1129 IsOnOrBefore:
"<?php print $langs->trans('IsOnOrBefore'); ?>",
1130 IsOnOrAfter:
"<?php print $langs->trans('IsOnOrAfter'); ?>"
1133 Contains:
"<?php print $langs->trans('Contains'); ?>"
1139 let generalType =
"";
1141 if (/^(varchar|
char|text|blob|nchar|mediumtext|longtext)\(\d+\)$/i.test(
type) || /^(varchar)$/i.test(
type)) {
1142 generalType =
"text";
1143 }
else if (/^(
int|integer|
float|
double|decimal|numeric)(\(\d+,\d+\))?$/i.test(
type)) {
1144 generalType =
"number";
1145 }
else if (/^(date|datetime|timestamp)$/i.test(
type)) {
1146 generalType =
"date";
1147 }
else if (/^(tinyint|smallint)\(\d+\)$/i.test(
type)) {
1148 generalType =
"number";
1149 }
else if (/^html$/i.test(
type)) {
1150 generalType =
"html";
1157 return operatorList[generalType] || [];
1168 filter = column +
" like \'%" + context +
"%\'";
1170 case "DoesNotContain":
1171 filter = column +
" notlike \'%" + context +
"%\'";
1174 filter = column +
" = \'" + context +
"\'";
1177 filter = column +
" != \'" + context +
"\'";
1180 filter = column +
" like \'" + context +
"%\'";
1183 filter = column +
" like \'%" + context +
"\'";
1186 filter = column +
" = \'" + context +
"\'";
1189 filter = column +
" != \'" + context +
"\'";
1192 filter = column +
" < \'" + context +
"\'";
1195 filter = column +
" > \'" + context +
"\'";
1198 filter = column +
" <= \'" + context +
"\'";
1201 filter = column +
" >= \'" + context +
"\'";
1204 filter = column +
" < \'" + context +
"\'";
1207 filter = column +
" > \'" + context +
"\'";
1209 case "IsOnOrBefore":
1210 filter = column +
" <= \'" + context +
"\'";
1213 filter = column +
" >= \'" + context +
"\'";
1232 function decimalAdjust(
type, value, exp) {
1234 if (typeof exp ===
'undefined' || +exp === 0) {
1235 return Math[
type](value);
1240 if (isNaN(value) || !(typeof exp ===
'number' && exp % 1 === 0)) {
1244 value = value.toString().split(
'e');
1245 value = Math[
type](+(value[0] +
'e' + (value[1] ? (+value[1] - exp) : -exp)));
1247 value = value.toString().split(
'e');
1248 return +(value[0] +
'e' + (value[1] ? (+value[1] + exp) : exp));
1252 if (!Math.round10) {
1253 Math.round10 =
function(value, exp) {
1254 return decimalAdjust(
'round', value, exp);
1258 if (!Math.floor10) {
1259 Math.floor10 =
function(value, exp) {
1260 return decimalAdjust(
'floor', value, exp);
1265 Math.ceil10 =
function(value, exp) {
1266 return decimalAdjust(
'ceil', value, exp);
1272function dolroundjs(number, decimals) {
return +(Math.round(number +
"e+" + decimals) +
"e-" + decimals); }
1291function pricejs(amount, mode =
'MT', currency_code =
'', force_locale =
'') {
1292 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1293 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1294 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1295 var main_decimal_separator = <?php echo json_encode($dec) ?>;
1296 var main_thousand_separator = <?php echo json_encode($thousand) ?>;
1297 var locale_code = force_locale || <?php echo json_encode($langs->defaultlang) ?>;
1298 var amountAsLocalizedString;
1299 var useIntl = Boolean(Intl && Intl.NumberFormat);
1301 if (currency_code ===
'auto') currency_code = <?php echo json_encode($conf->currency) ?>;
1303 if (mode ===
'MU') nDigits = main_rounding_unit;
1304 else if (mode ===
'MT') nDigits = main_rounding_tot;
1305 else return 'Bad value for parameter mode';
1310 var formattingOptions = {
1311 minimumFractionDigits: nDigits,
1312 maximumFractionDigits: nDigits
1314 if (currency_code) {
1315 formattingOptions[
'style'] =
'currency';
1316 formattingOptions[
'currency'] = currency_code;
1318 return Intl.NumberFormat(locale_code.replace(
'_',
'-'), formattingOptions).format(amount);
1322 amountAsLocalizedString = amount.toFixed(nDigits).replace(
1323 /((?!^)(?:\d{3})*)(?:\.(\d+))?$/,
1324 (fullMatch, digitsByThree, decimals) =>
1325 digitsByThree.replace(
1327 (groupOfThree) => main_thousand_separator + groupOfThree
1328 ) + (decimals !== undefined ? main_decimal_separator + decimals :
'')
1329 ).replace(/ /,
' ');
1330 if (!currency_code)
return amountAsLocalizedString;
1333 var currency_symbol = currency_code;
1336 var currencyBeforeAmountCodes = {
1337 currency: [
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD'],
1341 if (currencyCache[currency_code]
1342 && currencyCache[currency_code][
'unicode']
1343 && currencyCache[currency_code][
'unicode'].length) {
1344 currency_symbol = currencyCache[currency_code][
'unicode'].reduce(
function (res, cur) {
return res + cur},
'');
1347 if (currencyBeforeAmountCodes.currency.indexOf(currency_code) >= 0
1348 || currencyBeforeAmountCodes.language.indexOf(locale_code)) {
1350 return currency_symbol + amountAsLocalizedString;
1354 return amountAsLocalizedString +
' ' + currency_symbol;
1365 if (amount ==
'')
return '';
1367 var dec = <?php echo json_encode($dec) ?>;
1368 var thousand = <?php echo json_encode($thousand) ?>;
1370 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1371 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1372 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1374 var amount = amount.toString();
1377 var rounding = main_rounding_unit;
1378 var pos = amount.indexOf(dec);
1381 decpart = amount.substring(pos + 1).replace(
'/0+$/i',
'');
1383 var nbdec = decpart.length;
1384 if (nbdec > rounding) {
1388 if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
1389 if (thousand !=
',' && thousand !=
'.') amount = amount.replace(
',',
'.');
1390 amount = amount.replace(
' ',
'');
1391 amount = amount.replace(thousand,
'');
1392 amount = amount.replace(dec,
'.');
1395 var res = Math.round10(amount, - rounding);
1399 console.log(
"price2numjs text="+amount+
" return="+res);
1406if (!
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
1409$(document).ready(
function() {
1410 if (typeof $.jnotify ==
'function') {
1414 , closeLabel:
"×"
1418 , classContainer:
"jnotify-container"
1419 , classNotification:
"jnotify-notification"
1420 , classBackground:
"jnotify-background"
1421 , classClose:
"jnotify-close"
1422 , classMessage:
"jnotify-message"
1425 , beforeRemove: null
1434jQuery(document).ready(
function() {
1436 if (window.location && window.location.pathname.indexOf(
"externalsite/frametop.php") == -1 && window.location !== window.parent.location ) {
1437 console.log(
"Page is detected to be into an iframe, we hide by CSS the menus");
1439 jQuery(
".side-nav-vert, .side-nav, .websitebar").hide();
1440 jQuery(
".id-container").css(
'width',
'100%');
1445 jQuery(
'table.liste tr.liste_titre_filter td.liste_titre input[name^="search"][type=text]:not(".maxwidthdate")').attr(
'title',
'<?php echo dol_escape_js($langs->transnoentities("SearchSyntaxTooltipForStringOrNum")) ?>');
1449jQuery(document).ready(
function() {
1450 jQuery(document).on(
"click",
".butAction.dropdown-toggle",
function(event) {
1451 console.log(
"Click on .butAction.dropdown-toggle");
1452 let parentHolder = jQuery(event.target).parent();
1453 let dropDownContent = parentHolder.children(
".dropdown-content");
1454 let offset = parentHolder.offset();
1455 let widthDocument = $(document).width();
1456 let heightDocument = $(document).height();
1457 let right = widthDocument - offset.left - parentHolder.width();
1458 let widthPopup = parentHolder.children(
".dropdown-content").width();
1459 if (widthPopup + right >= widthDocument) {
1463 parentHolder.toggleClass(
"open");
1466 let dropDownContentTop = dropDownContent.offset().top;
1467 let dropDownContentLeft = dropDownContent.offset().left;
1468 let dropDownContentHeight = dropDownContent.outerHeight();
1469 let dropDownContentBottom = dropDownContentTop + dropDownContentHeight;
1470 let viewportBottom = $(window).scrollTop() + $(window).height();
1473 if(parentHolder.hasClass(
'open')
1474 && dropDownContentBottom > viewportBottom
1475 && dropDownContentTop - dropDownContentHeight > 0
1477 parentHolder.addClass(
"--up");
1479 parentHolder.removeClass(
"--up");
1483 if(parentHolder.hasClass(
'open') && dropDownContentLeft < 0){
1484 parentHolder.addClass(
"--left");
1486 parentHolder.removeClass(
"--left");
1491 jQuery(document).on(
"click",
function(event) {
1493 if (!$(event.target).closest(
'.butAction.dropdown-toggle').length) {
1495 let parentholder = jQuery(
".butAction.dropdown-toggle").closest(
".dropdown.open");
1498 parentholder.removeClass(
"open --up --left");
1506if (!
getDolGlobalString(
'MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined(
'DISABLE_SELECT2_FOCUS_PROTECTION')) {
1516$(document).on(
'select2:open', (e) => {
1517 console.log(
"Execute the focus (click on combo or use space when on component");
1518 const target = $(e.target);
1519 if (target && target.length) {
1520 let
id = target[0].id || target[0].name;
1521 if (
id.substr(-2) ==
"[]")
id =
id.substr(0,
id.length-2);
1522 document.querySelector(
'input[aria-controls*='+
id+
']').focus();
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
getOperatorsForFieldType(type)
Get the list of operators for a given field type.
copyToClipboard(text, text2)
Function to output a dialog box for copy/paste.
document_preview(file, type, title)
Function show document preview.
pricejs(amount, mode='MT', currency_code='', force_locale='')
Function similar to PHP price()
generateFilterString(column, operator, context, fieldType)
Generate a filter string based on the given column, operator, context and field type.
newpopup(url, title)
Show a popup HTML page.
price2numjs(amount)
Function similar to PHP price2num()
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
fail($message)
Abort invoice creation with a given error message.