29if (!defined(
'NOREQUIRESOC')) {
30 define(
'NOREQUIRESOC',
'1');
32if (!defined(
'NOCSRFCHECK')) {
33 define(
'NOCSRFCHECK', 1);
35if (!defined(
'NOTOKENRENEWAL')) {
36 define(
'NOTOKENRENEWAL', 1);
38if (!defined(
'NOLOGIN')) {
41if (!defined(
'NOREQUIREMENU')) {
42 define(
'NOREQUIREMENU', 1);
44if (!defined(
'NOREQUIREHTML')) {
45 define(
'NOREQUIREHTML', 1);
47if (!defined(
'NOREQUIREAJAX')) {
48 define(
'NOREQUIREAJAX',
'1');
51session_cache_limiter(
'public');
53require_once
'../../main.inc.php';
66if (empty($dolibarr_nocache)) {
67 header(
'Cache-Control: max-age=10800, public, must-revalidate');
69 header(
'Cache-Control: no-cache');
90$tradMonthsShort = array(
91$langs->trans(
"MonthShort01"),
92$langs->trans(
"MonthShort02"),
93$langs->trans(
"MonthShort03"),
94$langs->trans(
"MonthShort04"),
95$langs->trans(
"MonthShort05"),
96$langs->trans(
"MonthShort06"),
97$langs->trans(
"MonthShort07"),
98$langs->trans(
"MonthShort08"),
99$langs->trans(
"MonthShort09"),
100$langs->trans(
"MonthShort10"),
101$langs->trans(
"MonthShort11"),
102$langs->trans(
"MonthShort12")
106$langs->trans(
"Sunday"),
107$langs->trans(
"Monday"),
108$langs->trans(
"Tuesday"),
109$langs->trans(
"Wednesday"),
110$langs->trans(
"Thursday"),
111$langs->trans(
"Friday"),
112$langs->trans(
"Saturday")
115$tradDaysShort = array(
116$langs->trans(
"ShortSunday"),
117$langs->trans(
"ShortMonday"),
118$langs->trans(
"ShortTuesday"),
119$langs->trans(
"ShortWednesday"),
120$langs->trans(
"ShortThursday"),
121$langs->trans(
"ShortFriday"),
122$langs->trans(
"ShortSaturday")
126$langs->trans(
"SundayMin"),
127$langs->trans(
"MondayMin"),
128$langs->trans(
"TuesdayMin"),
129$langs->trans(
"WednesdayMin"),
130$langs->trans(
"ThursdayMin"),
131$langs->trans(
"FridayMin"),
132$langs->trans(
"SaturdayMin")
138if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
139 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
141if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
142 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
144if ($thousand ==
'Space') {
152var tradMonths = <?php echo json_encode($tradMonths) ?>;
153var tradMonthsShort = <?php echo json_encode($tradMonthsShort) ?>;
154var tradDays = <?php echo json_encode($tradDays) ?>;
155var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>;
156var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>;
157var currencyCache = <?php echo json_encode($langs->cache_currencies) ?>;
160$(document).ready(
function() {
161 $.datepicker.setDefaults({
165 altField:
'#timestamp',
171 $.datepicker.regional[
'<?php echo $langs->defaultlang ?>'] = {
172 closeText:
'<?php echo $langs->trans("Close2") ?>',
173 prevText:
'<?php echo $langs->trans("Previous") ?>',
174 nextText:
'<?php echo $langs->trans("Next") ?>',
175 currentText:
'<?php echo $langs->trans("Now") ?>',
176 monthNames: tradMonths,
177 monthNamesShort: tradMonthsShort,
179 dayNamesShort: tradDaysShort,
180 dayNamesMin: tradDaysMin,
181 weekHeader:
'<?php echo $langs->trans("Week"); ?>',
182 dateFormat:
'<?php echo $langs->trans("FormatDateShortJQuery"); ?>',
183 firstDay: <?php echo(isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK :
'1'); ?>,
184 isRTL: <?php echo($langs->trans(
"DIRECTION") ==
'rtl' ?
'true' :
'false'); ?>,
185 showMonthAfterYear:
false,
188 $.datepicker.setDefaults($.datepicker.regional[
'<?php echo $langs->defaultlang ?>']);
197var select2arrayoflanguage = {
198 matches:
function (matches) {
return matches +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2ResultFoundUseArrows
")); ?>"; },
199 noResults:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2NotFound
")); ?>"; },
200 inputTooShort:
function (input) {
201 var n = input.minimum;
203 if (n > 1)
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacters
")); ?>";
204 else return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacter
")); ?>"
206 loadMore:
function (pageNumber) {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2LoadingMoreResults
")); ?>"; },
207 searching:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2SearchInProgress
")); ?>"; }
216function getObjectFromID(
id){
218 if(document.getElementById)
219 theObject=document.getElementById(
id);
221 theObject=document.all[id];
226function dpChangeDay(dateFieldID, format)
229 console.log(
"Call dpChangeDay, we save date into detailed fields from format = "+format);
231 var thefield=getObjectFromID(dateFieldID);
232 var thefieldday=getObjectFromID(dateFieldID+
"day");
233 var thefieldmonth=getObjectFromID(dateFieldID+
"month");
234 var thefieldyear=getObjectFromID(dateFieldID+
"year");
236 var date=getDateFromFormat(thefield.value, format);
240 thefieldday.value=date.getDate();
241 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
242 thefieldmonth.value=date.getMonth()+1;
243 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
244 thefieldyear.value=date.getFullYear();
245 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
249 thefieldday.value=
'';
250 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
251 thefieldmonth.value=
'';
252 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
253 thefieldyear.value=
'';
254 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
272function formatDate(date,format)
281 var year=date.getFullYear();
282 var month=date.getMonth()+1;
283 var day=date.getDate();
284 var hour=date.getHours();
285 var minute=date.getMinutes();
286 var seconde=date.getSeconds();
289 while (i < format.length)
294 while ((format.charAt(j)==c) && (j < format.length))
296 substr += format.charAt(j++);
300 if (substr ==
'yyyy') { result=result+year; }
301 else if (substr ==
'yy') { result=result+year.substring(2,4); }
302 else if (substr ==
'M') { result=result+month; }
303 else if (substr ==
'MM') { result=result+(month<1||month>9?
"":
"0")+month; }
304 else if (substr ==
'd') { result=result+day; }
305 else if (substr ==
'dd') { result=result+(day<1||day>9?
"":
"0")+day; }
306 else if (substr ==
'hh') {
if (hour > 12) hour-=12; result=result+(hour<0||hour>9?
"":
"0")+hour; }
307 else if (substr ==
'HH') { result=result+(hour<0||hour>9?
"":
"0")+hour; }
308 else if (substr ==
'mm') { result=result+(minute<0||minute>9?
"":
"0")+minute; }
309 else if (substr ==
'ss') { result=result+(seconde<0||seconde>9?
"":
"0")+seconde; }
310 else { result=result+substr; }
340function getDateFromFormat(val,format)
348 if (val ==
'')
return 0;
351 var year=now.getFullYear();
352 var month=now.getMonth()+1;
353 var day=now.getDate();
354 var hour=now.getHours();
355 var minute=now.getMinutes();
356 var seconde=now.getSeconds();
362 while (i < format.length)
367 while ((format.charAt(j)==c) && (j < format.length))
371 substr += format.charAt(j++);
375 if (substr ==
"yyyy") year=getIntegerInString(val,d,4,4);
376 if (substr ==
"yy") year=
""+(getIntegerInString(val,d,2,2)-0+2000);
377 if (substr ==
"MM" ||substr ==
"M")
379 month=getIntegerInString(val,d,1,2);
380 if (month) d -= 2- month.length;
384 day=getIntegerInString(val,d,1,2);
385 if (day) d -= 2- day.length;
387 if (substr ==
"HH" ||substr ==
"hh" )
389 hour=getIntegerInString(val,d,1,2);
390 if (dhouray) d -= 2- hour.length;
393 minute=getIntegerInString(val,d,1,2);
394 if (minute) d -= 2- minute.length;
398 seconde=getIntegerInString(val,d,1,2);
399 if (seconde) d -= 2- seconde.length;
407 if (year==
null||year<1) {
return 0; }
408 if (month==
null||(month<1)||(month>12)) {
return 0; }
409 if (day==
null||(day<1)||(day>31)) {
return 0; }
410 if (hour==
null||(hour<0)||(hour>24)) {
return 0; }
411 if (minute==
null||(minute<0)||(minute>60)) {
return 0; }
412 if (seconde==
null||(seconde<0)||(seconde>60)) {
return 0; }
415 return new Date(year,month-1,day,hour,minute,seconde);
424function stringIsInteger(str)
426 var digits=
"1234567890";
427 for (var i=0; i < str.length; i++)
429 if (digits.indexOf(str.charAt(i))==-1)
443function getIntegerInString(str,i,minlength,maxlength)
445 for (var x=maxlength; x>=minlength; x--)
447 var substr=str.substring(i,i+x);
448 if (substr.length < minlength) {
return null; }
449 if (stringIsInteger(substr)) {
return substr; }
463function urlencode(s) {
465 news = news.replace(/\+/gi,
'%2B');
466 news = news.replace(/&/gi,
'%26');
478function htmlEntityDecodeJs(inp){
479 var replacements = {
'<':
'<',
'>':
'>',
'/':
'/',
'"':
'"',
''':
'\'',
'&':
'&',
' ':
' '};
481 for(var r in replacements){
482 inp = inp.replace(
new RegExp(r,
'g'),replacements[r]);
484 return inp.replace(/&#(\d+);/g,
function(match, dec) {
485 return String.fromCharCode(dec);
501 function ac_delay(funct,delay) {
503 setTimeout(funct,delay);
516function cleanSerialize(expr) {
517 if (typeof(expr) !=
'string') {
520 var reg =
new RegExp(
"(&)",
"g");
521 var reg2 =
new RegExp(
"[^A-Z0-9,]",
"g");
522 var liste1 = expr.replace(reg,
",");
523 return liste1.replace(reg2,
"");
537function displayMessage(fieldId,message) {
538 var textbox = document.getElementById(fieldId);
539 if (textbox.value ==
'') {
540 textbox.style.color =
'grey';
541 textbox.value = message;
555function hideMessage(fieldId,message) {
556 var textbox = document.getElementById(fieldId);
557 textbox.style.color =
'black';
558 if (textbox.value == message) textbox.value =
'';
578function setConstant(url, code, input, entity, strict, forcereload, userid, token, value, userconst) {
590 console.log(
"Ajax url request to set constant is a success. Make complementary actions and then forcereload="+forcereload+
" value="+value);
592 $(
"#set_" + code).show();
593 $(
"#del_" + code).hide();
595 $(
"#set_" + code).hide();
596 $(
"#del_" + code).show();
598 $.each(input,
function(
type, data) {
600 if (
type ==
"disabled" && strict != 1) {
601 $.each(data,
function(key, value) {
602 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
603 $(newvalue).removeAttr(
"disabled");
604 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
605 $(newvalue).removeClass(
"butActionRefused");
606 $(newvalue).addClass(
"butAction");
609 }
else if (
type ==
"enabled") {
610 $.each(data,
function(key, value) {
611 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
613 $(newvalue).removeAttr(
"disabled");
615 $(newvalue).attr(
"disabled",
true);
616 if ($(newvalue).hasClass(
"butAction") ==
true) {
617 $(newvalue).removeClass(
"butAction");
618 $(newvalue).addClass(
"butActionRefused");
622 }
else if (
type ==
"showhide" ||
type ==
"show") {
623 $.each(data,
function(key, value) {
624 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
628 }
else if (
type ==
"set") {
629 $.each(data,
function(key, value) {
630 $(
"#set_" + key).hide();
631 $(
"#del_" + key).show();
643 var url = window.location.href;
644 if (url.indexOf(
'dol_resetcache') < 0) {
645 if (url.indexOf(
'?') > -1) {
646 url = url +
"&dol_resetcache=1";
648 url = url +
"?dol_resetcache=1";
651 var page_y = $(document).scrollTop();
652 url = url.replace(/page_y=\d+/g,
'');
654 if (url.indexOf(
'?') > -1) {
655 url = url +
"&page_y="+page_y;
657 url = url +
"?page_y="+page_y;
660 url = url.replace(/&&+/,
'&');
661 console.log(
"url ro redirect = "+url);
663 window.location.href = url;
667 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
687function delConstant(url, code, input, entity, strict, forcereload, userid, token, userconst) {
698 console.log(
"Ajax url request to delete constant is success. Make complementary actions and then forcereload="+forcereload);
699 $(
"#del_" + code).hide();
700 $(
"#set_" + code).show();
701 $.each(input,
function(
type, data) {
703 if (
type ==
"disabled") {
704 $.each(data,
function(key, value) {
705 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
706 $(newvalue).attr(
"disabled",
true);
707 if ($(newvalue).hasClass(
"butAction") ==
true) {
708 $(newvalue).removeClass(
"butAction");
709 $(newvalue).addClass(
"butActionRefused");
712 }
else if (
type ==
"enabled" && strict != 1) {
713 $.each(data,
function(key, value) {
714 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
715 $(newvalue).removeAttr(
"disabled");
716 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
717 $(newvalue).removeClass(
"butActionRefused");
718 $(newvalue).addClass(
"butAction");
722 }
else if (
type ==
"showhide" ||
type ==
"hide") {
723 $.each(data,
function(key, value) {
724 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
728 }
else if (
type ==
"del") {
729 $.each(data,
function(key, value) {
730 $(
"#del_" + value).hide();
731 $(
"#set_" + value).show();
742 var url = window.location.href;
743 if (url.indexOf(
'dol_resetcache') < 0) {
744 if (url.indexOf(
'?') > -1) {
745 url = url +
"&dol_resetcache=1";
747 url = url +
"?dol_resetcache=1";
750 var page_y = $(document).scrollTop();
751 url = url.replace(/page_y=\d+/g,
'');
753 if (url.indexOf(
'?') > -1) {
754 url = url +
"&page_y="+page_y;
756 url = url +
"?page_y="+page_y;
759 url = url.replace(/&&+/,
'&');
760 console.log(
"url ro redirect = "+url);
762 window.location.href = url;
766 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
788function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid, token) {
789 var boxConfirm = box;
790 $(
"#confirm_" + code)
791 .attr(
"title", boxConfirm.title)
792 .html(boxConfirm.content)
800 id :
'yesButton_' + code,
803 if (action ==
"set") {
804 setConstant(url, code, input, entity, strict, 0, userid, token, 1);
805 }
else if (action ==
"del") {
806 delConstant(url, code, input, entity, strict, 0, userid, token);
809 $(
this).dialog(
"close");
811 if (boxConfirm.method) {
812 var fnName = boxConfirm.method;
813 if (window.hasOwnProperty(fnName)) {
820 id :
'noButton_' + code,
823 $(
this).dialog(
"close");
829 if (boxConfirm.info) {
830 $(
"#noButton_" + code).button().hide();
846 $.widget(
"ui.combobox", {
848 minLengthToAutocomplete: 0
850 _create:
function() {
851 var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
853 select = this.element.hide(),
854 selected = select.children(
":selected" ),
855 value = selected.val() ? selected.text() :
"";
856 var input = this.input = $(
"<input>" )
857 .insertAfter( select )
859 .attr(
'id',
'inputautocomplete'+select.attr(
'id'))
862 minLength: this.options.minLengthToAutocomplete,
863 source:
function( request, response ) {
864 var matcher =
new RegExp( $.ui.autocomplete.escapeRegex(request.term),
"i" );
865 response( select.children(
"option:enabled" ).map(
function() {
866 var text = $( this ).text();
867 if ( this.value && ( !request.term || matcher.test(text) ) )
871 "(?![^&;]+;)(?!<[^<>]*)(" +
872 $.ui.autocomplete.escapeRegex(request.term) +
873 ")(?![^<>]*>)(?![^&;]+;)",
"gi"
874 ),
"<strong>$1</strong>" ),
880 select:
function( event, ui ) {
881 ui.item.option.selected =
true;
882 self._trigger(
"selected", event, {
886 change:
function( event, ui ) {
888 var matcher =
new RegExp(
"^" + $.ui.autocomplete.escapeRegex( $(
this).val() ) +
"$",
"i" ),
890 select.children(
"option" ).each(
function() {
891 if ( $(
this ).text().match( matcher ) ) {
892 this.selected = valid =
true;
900 input.data(
"ui-autocomplete").term =
"";
906 .addClass(
"ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
908 input.data(
"ui-autocomplete")._renderItem =
function( ul, item ) {
910 .data(
"ui-autocomplete-item", item )
911 .append(
"<a>" + item.label +
"</a>" )
915 this.
button = $(
"<button type=\'button\'> </button>" )
916 .attr(
"tabIndex", -1 )
917 .attr(
"title",
"Show All Items" )
918 .insertAfter( input )
921 primary:
"ui-icon-triangle-1-s"
925 .removeClass(
"ui-corner-all" )
926 .addClass(
"ui-corner-right ui-button-icon" )
929 if ( input.autocomplete(
"widget" ).is(
":visible" ) ) {
930 input.autocomplete(
"close" );
935 input.autocomplete({ minLength: 0 });
936 input.autocomplete(
"search",
"" );
937 input.autocomplete({ minLength: savMinLengthToAutocomplete });
942 destroy:
function() {
946 $.Widget.prototype.destroy.call(
this );
961 text = text.replace(/<br>/g,
"\n");
962 var newElem =
'<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+
'</textarea><br><br>'+text2;
964 $(
"#dialogforpopup").html(newElem);
965 $(
"#dialogforpopup").dialog();
966 $(
"#coordsforpopup").select();
982 var argc =
newpopup.arguments.length;
984 console.log(
"newpopup "+argv[2]+
" "+argv[3]);
985 var l = (argc > 2) ? argv[2] : 600;
986 var h = (argc > 3) ? argv[3] : 400;
987 var left = (screen.width - l)/2;
988 var top = (screen.height - h)/2;
989 var wfeatures =
"directories=0,menubar=0,status=0,resizable=0,scrollbars=1,toolbar=0,location=0,width=" + l +
",height=" + h +
",left=" + left +
",top=" + top;
990 fen = window.open(tmp, title, wfeatures);
1007 var ValidImageTypes = [
"image/gif",
"image/jpeg",
"image/png",
"image/webp"];
1008 var showOriginalSizeButton =
false;
1010 console.log(
"document_preview A click was done: file="+file+
", type="+
type+
", title="+title);
1012 if ($.inArray(
type, ValidImageTypes) < 0) {
1015 var object_width=
'100%';
1016 var height = ($( window ).height() - 60) * 0.90;
1017 var object_height=
'98%';
1019 show_preview(
'notimage');
1024 var object_height=0;
1026 var img =
new Image();
1028 img.onload =
function() {
1029 object_width = this.width;
1030 object_height = this.height;
1032 width = $( window ).width()*0.90;
1033 console.log(
"object_width="+object_width+
" window width="+width);
1034 if(object_width < width){
1035 console.log(
"Object width is small, we set width of popup according to image width.");
1036 width = object_width + 30
1038 height = $( window ).height()*0.85;
1039 console.log(
"object_height="+object_height+
" window height="+height);
1040 if(object_height < height){
1041 console.log(
"Object height is small, we set height of popup according to image height.");
1042 height = object_height + 80
1046 showOriginalSizeButton =
true;
1049 show_preview(
'image');
1056 function show_preview(mode) {
1058 var newElem =
'<object name="objectpreview" data="'+file+
'" type="'+
type+
'" width="'+object_width+
'" height="'+object_height+
'" param="noparam"></object>';
1061 if (mode ==
'image' && showOriginalSizeButton)
1065 "<?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" }); },
1066 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("RotateImage
")); ?>":
function() { curRot += 90; jQuery(
".ui-dialog-content.ui-widget-content > object").css(
"transform",
"rotate(" + curRot +
"deg)"); },
1067 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("CloseWindow
")); ?>":
function() { $(
this ).dialog(
"close" ); }
1071 $(
"#dialogforpopup").html(newElem);
1073 $(
"#dialogforpopup").dialog({
1074 closeOnEscape:
true,
1080 buttons: optionsbuttons
1083 if (showOriginalSizeButton)
1085 jQuery(
".ui-dialog-content.ui-widget-content > object").css({
"max-height":
"100%",
"width":
"auto",
"margin-left":
"auto",
"margin-right":
"auto",
"display":
"block" });
1097function getParameterByName(
name, valueifnotfound)
1099 name =
name.replace(/[\[]/,
"\\[").replace(/[\]]/,
"\\]");
1100 var regex =
new RegExp(
"[\\?&]" +
name +
"=([^&#]*)"),
1101 results = regex.exec(location.search);
1102 return results ===
null ? valueifnotfound : decodeURIComponent(results[1].replace(/\+/g,
" "));
1110 const operatorList = {
1112 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1113 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1116 Contains:
'<?php print dol_escape_js($langs->trans('Contains
')); ?>',
1117 DoesNotContain:
'<?php print dol_escape_js($langs->trans('DoesNotContain
')); ?>',
1118 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1119 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1120 StartsWith:
'<?php print dol_escape_js($langs->trans('StartsWith
')); ?>',
1121 EndsWith:
'<?php print dol_escape_js($langs->trans('EndsWith
')); ?>'
1124 '=':
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1125 '!=':
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1126 '<':
'<?php print dol_escape_js($langs->trans('IsLowerThan
')); ?>',
1127 '>':
'<?php print dol_escape_js($langs->trans('IsHigherThan
')); ?>',
1128 '<=':
'<?php print dol_escape_js($langs->trans('IsLowerThanOrEqual
')); ?>',
1129 '>=':
'<?php print dol_escape_js($langs->trans('IsHigherThanOrEqual
')); ?>',
1132 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1133 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1134 IsBefore:
'<?php print dol_escape_js($langs->trans('IsBefore
')); ?>',
1135 IsAfter:
'<?php print dol_escape_js($langs->trans('IsAfter
')); ?>',
1136 IsOnOrBefore:
'<?php print dol_escape_js($langs->trans('IsOnOrBefore
')); ?>',
1137 IsOnOrAfter:
'<?php print dol_escape_js($langs->trans('IsOnOrAfter
')); ?>'
1140 Contains:
'<?php print $langs->trans('Contains
'); ?>'
1146 let generalType =
"";
1148 console.log(
'Get list of operators for type='+
type);
1150 if (/^select$/i.test(
type) || /^link$/i.test(
type)) {
1151 generalType =
"selectlink";
1152 }
else if (/^(varchar|
char|text|blob|nchar|mediumtext|longtext)\(\d+\)$/i.test(
type) || /^varchar$/i.test(
type)) {
1153 generalType =
"text";
1154 }
else if (/^(
int|integer|
float|
double|decimal|numeric)(\(\d+,\d+\))?$/i.test(
type)) {
1155 generalType =
"number";
1156 }
else if (/^(date|datetime|timestamp)$/i.test(
type)) {
1157 generalType =
"date";
1158 }
else if (/^(tinyint|smallint)\(\d+\)$/i.test(
type)) {
1159 generalType =
"number";
1160 }
else if (/^html$/i.test(
type)) {
1161 generalType =
"html";
1164 console.log(
"The type of field "+
type+
" is not supported");
1169 return operatorList[generalType] || [];
1180 filter = column +
" like \'%" + context +
"%\'";
1182 case "DoesNotContain":
1183 filter = column +
" notlike \'%" + context +
"%\'";
1186 filter = column +
" = \'" + context +
"\'";
1189 filter = column +
" != \'" + context +
"\'";
1192 filter = column +
" like \'" + context +
"%\'";
1195 filter = column +
" like \'%" + context +
"\'";
1198 filter = column +
" = \'" + context +
"\'";
1201 filter = column +
" != \'" + context +
"\'";
1204 filter = column +
" < \'" + context +
"\'";
1207 filter = column +
" > \'" + context +
"\'";
1210 filter = column +
" <= \'" + context +
"\'";
1213 filter = column +
" >= \'" + context +
"\'";
1216 filter = column +
" < \'" + context +
"\'";
1219 filter = column +
" > \'" + context +
"\'";
1221 case "IsOnOrBefore":
1222 filter = column +
" <= \'" + context +
"\'";
1225 filter = column +
" >= \'" + context +
"\'";
1244 function decimalAdjust(
type, value, exp) {
1246 if (typeof exp ===
'undefined' || +exp === 0) {
1247 return Math[
type](value);
1252 if (isNaN(value) || !(typeof exp ===
'number' && exp % 1 === 0)) {
1256 value = value.toString().split(
'e');
1257 value = Math[
type](+(value[0] +
'e' + (value[1] ? (+value[1] - exp) : -exp)));
1259 value = value.toString().split(
'e');
1260 return +(value[0] +
'e' + (value[1] ? (+value[1] + exp) : exp));
1264 if (!Math.round10) {
1265 Math.round10 =
function(value, exp) {
1266 return decimalAdjust(
'round', value, exp);
1270 if (!Math.floor10) {
1271 Math.floor10 =
function(value, exp) {
1272 return decimalAdjust(
'floor', value, exp);
1277 Math.ceil10 =
function(value, exp) {
1278 return decimalAdjust(
'ceil', value, exp);
1284function dolroundjs(number, decimals) {
return +(Math.round(number +
"e+" + decimals) +
"e-" + decimals); }
1303function pricejs(amount, mode =
'MT', currency_code =
'', force_locale =
'') {
1304 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1305 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1306 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1307 var main_decimal_separator = <?php echo json_encode($dec) ?>;
1308 var main_thousand_separator = <?php echo json_encode($thousand) ?>;
1309 var locale_code = force_locale || <?php echo json_encode($langs->defaultlang) ?>;
1310 var amountAsLocalizedString;
1311 var useIntl = Boolean(Intl && Intl.NumberFormat);
1313 if (currency_code ===
'auto') currency_code = <?php echo json_encode(
$conf->currency) ?>;
1315 if (mode ===
'MU') nDigits = main_rounding_unit;
1316 else if (mode ===
'MT') nDigits = main_rounding_tot;
1317 else return 'Bad value for parameter mode';
1322 var formattingOptions = {
1323 minimumFractionDigits: nDigits,
1324 maximumFractionDigits: nDigits
1326 if (currency_code) {
1327 formattingOptions[
'style'] =
'currency';
1328 formattingOptions[
'currency'] = currency_code;
1330 return Intl.NumberFormat(locale_code.replace(
'_',
'-'), formattingOptions).format(amount);
1334 amountAsLocalizedString = amount.toFixed(nDigits).replace(
1335 /((?!^)(?:\d{3})*)(?:\.(\d+))?$/,
1336 (fullMatch, digitsByThree, decimals) =>
1337 digitsByThree.replace(
1339 (groupOfThree) => main_thousand_separator + groupOfThree
1340 ) + (decimals !== undefined ? main_decimal_separator + decimals :
'')
1341 ).replace(/ /,
' ');
1342 if (!currency_code)
return amountAsLocalizedString;
1345 var currency_symbol = currency_code;
1348 var currencyBeforeAmountCodes = {
1349 currency: [
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD'],
1353 if (currencyCache[currency_code]
1354 && currencyCache[currency_code][
'unicode']
1355 && currencyCache[currency_code][
'unicode'].length) {
1356 currency_symbol = currencyCache[currency_code][
'unicode'].reduce(
function (res, cur) {
return res + cur},
'');
1359 if (currencyBeforeAmountCodes.currency.indexOf(currency_code) >= 0
1360 || currencyBeforeAmountCodes.language.indexOf(locale_code)) {
1362 return currency_symbol + amountAsLocalizedString;
1366 return amountAsLocalizedString +
' ' + currency_symbol;
1377 if (amount ==
'')
return '';
1379 var dec = <?php echo json_encode($dec) ?>;
1380 var thousand = <?php echo json_encode($thousand) ?>;
1382 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1383 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1384 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1386 var amount = amount.toString();
1389 var rounding = main_rounding_unit;
1390 var pos = amount.indexOf(dec);
1393 decpart = amount.substring(pos + 1).replace(
'/0+$/i',
'');
1395 var nbdec = decpart.length;
1396 if (nbdec > rounding) {
1400 if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
1401 if (thousand !=
',' && thousand !=
'.') amount = amount.replace(
',',
'.');
1402 amount = amount.replace(
' ',
'');
1403 amount = amount.replace(thousand,
'');
1404 amount = amount.replace(dec,
'.');
1407 var res = Math.round10(amount, - rounding);
1411 console.log(
"price2numjs text="+amount+
" return="+res);
1418if (!
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
1421$(document).ready(
function() {
1422 if (typeof $.jnotify ==
'function') {
1426 , closeLabel:
"×"
1430 , classContainer:
"jnotify-container"
1431 , classNotification:
"jnotify-notification"
1432 , classBackground:
"jnotify-background"
1433 , classClose:
"jnotify-close"
1434 , classMessage:
"jnotify-message"
1437 , beforeRemove: null
1446jQuery(document).ready(
function() {
1448 if (window.location && window.location.pathname.indexOf(
"externalsite/frametop.php") == -1 && window.location !== window.parent.location ) {
1449 console.log(
"Page is detected to be into an iframe, we hide by CSS the menus");
1451 jQuery(
".side-nav-vert, .side-nav, .websitebar").hide();
1452 jQuery(
".id-container").css(
'width',
'100%');
1457 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")) ?>');
1461jQuery(document).ready(
function() {
1462 jQuery(document).on(
"click",
".butAction.dropdown-toggle",
function(event) {
1463 console.log(
"Click on .butAction.dropdown-toggle");
1464 let parentHolder = jQuery(event.target).parent();
1465 let dropDownContent = parentHolder.children(
".dropdown-content");
1466 let offset = parentHolder.offset();
1467 let widthDocument = $(document).width();
1468 let heightDocument = $(document).height();
1469 let right = widthDocument - offset.left - parentHolder.width();
1470 let widthPopup = parentHolder.children(
".dropdown-content").width();
1471 if (widthPopup + right >= widthDocument) {
1475 parentHolder.toggleClass(
"open");
1478 let dropDownContentTop = dropDownContent.offset().top;
1479 let dropDownContentLeft = dropDownContent.offset().left;
1480 let dropDownContentHeight = dropDownContent.outerHeight();
1481 let dropDownContentBottom = dropDownContentTop + dropDownContentHeight;
1482 let viewportBottom = $(window).scrollTop() + $(window).height();
1485 if(parentHolder.hasClass(
'open')
1486 && dropDownContentBottom > viewportBottom
1487 && dropDownContentTop - dropDownContentHeight > 0
1489 parentHolder.addClass(
"--up");
1491 parentHolder.removeClass(
"--up");
1495 if(parentHolder.hasClass(
'open') && dropDownContentLeft < 0){
1496 parentHolder.addClass(
"--left");
1498 parentHolder.removeClass(
"--left");
1503 jQuery(document).on(
"click",
function(event) {
1505 if (!$(event.target).closest(
'.butAction.dropdown-toggle').length) {
1507 let parentholder = jQuery(
".butAction.dropdown-toggle").closest(
".dropdown.open");
1510 parentholder.removeClass(
"open --up --left");
1518if (!
getDolGlobalString(
'MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined(
'DISABLE_SELECT2_FOCUS_PROTECTION')) {
1528$(document).on(
'select2:open', (e) => {
1529 console.log(
"Execute the focus (click on combo or use space when on component");
1530 const target = $(e.target);
1531 if (target && target.length) {
1532 let
id = target[0].id || target[0].name;
1533 if (
id.substr(-2) ==
"[]")
id =
id.substr(0,
id.length-2);
1534 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.