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);
251 newformat = format.replace(/yyyy/g,
'yy');
252 if (newformat != format) {
253 console.log(
"dpChangeDay, we try now from format = "+newformat);
255 var date = getDateFromFormat(thefield.value, newformat);
259 thefieldday.value = date.getDate();
260 if (thefieldday.onchange) thefieldday.onchange.call(thefieldday);
261 thefieldmonth.value = date.getMonth()+1;
262 if (thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
263 thefieldyear.value = date.getFullYear();
264 if (thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
270 thefieldday.value =
'';
271 if (thefieldday.onchange) thefieldday.onchange.call(thefieldday);
272 thefieldmonth.value =
'';
273 if (thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
274 thefieldyear.value =
'';
275 if (thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
294function formatDate(date,format)
303 var year=date.getFullYear();
304 var month=date.getMonth()+1;
305 var day=date.getDate();
306 var hour=date.getHours();
307 var minute=date.getMinutes();
308 var seconde=date.getSeconds();
311 while (i < format.length)
316 while ((format.charAt(j)==c) && (j < format.length))
318 substr += format.charAt(j++);
322 if (substr ==
'yyyy') { result=result+year; }
323 else if (substr ==
'yy') { result=result+year.substring(2,4); }
324 else if (substr ==
'M') { result=result+month; }
325 else if (substr ==
'MM') { result=result+(month<1||month>9?
"":
"0")+month; }
326 else if (substr ==
'd') { result=result+day; }
327 else if (substr ==
'dd') { result=result+(day<1||day>9?
"":
"0")+day; }
328 else if (substr ==
'hh') {
if (hour > 12) hour-=12; result=result+(hour<0||hour>9?
"":
"0")+hour; }
329 else if (substr ==
'HH') { result=result+(hour<0||hour>9?
"":
"0")+hour; }
330 else if (substr ==
'mm') { result=result+(minute<0||minute>9?
"":
"0")+minute; }
331 else if (substr ==
'ss') { result=result+(seconde<0||seconde>9?
"":
"0")+seconde; }
332 else { result=result+substr; }
362function getDateFromFormat(val, format)
370 if (val ==
'')
return 0;
373 var year=now.getFullYear();
374 var month=now.getMonth()+1;
375 var day=now.getDate();
376 var hour=now.getHours();
377 var minute=now.getMinutes();
378 var seconde=now.getSeconds();
383 while (i < format.length)
388 while ((format.charAt(j)==c) && (j < format.length))
390 substr += format.charAt(j++);
394 if (substr ==
"yyyy") year=getIntegerInString(val,d,4,4);
395 if (substr ==
"yy") year=
""+(getIntegerInString(val,d,2,2)-0+2000);
396 if (substr ==
"MM" ||substr ==
"M")
398 month=getIntegerInString(val,d,1,2);
399 if (month) d -= 2- month.length;
403 day=getIntegerInString(val,d,1,2);
404 if (day) d -= 2- day.length;
406 if (substr ==
"HH" ||substr ==
"hh" )
408 hour=getIntegerInString(val,d,1,2);
409 if (dhouray) d -= 2- hour.length;
412 minute=getIntegerInString(val,d,1,2);
413 if (minute) d -= 2- minute.length;
417 seconde=getIntegerInString(val,d,1,2);
418 if (seconde) d -= 2- seconde.length;
426 if (year==
null||year<1) {
return 0; }
427 if (month==
null||(month<1)||(month>12)) {
return 0; }
428 if (day==
null||(day<1)||(day>31)) {
return 0; }
429 if (hour==
null||(hour<0)||(hour>24)) {
return 0; }
430 if (minute==
null||(minute<0)||(minute>60)) {
return 0; }
431 if (seconde==
null||(seconde<0)||(seconde>60)) {
return 0; }
434 return new Date(year,month-1,day,hour,minute,seconde);
443function stringIsInteger(str)
445 var digits=
"1234567890";
446 for (var i=0; i < str.length; i++)
448 if (digits.indexOf(str.charAt(i))==-1)
462function getIntegerInString(str,i,minlength,maxlength)
464 for (var x=maxlength; x>=minlength; x--)
466 var substr=str.substring(i,i+x);
467 if (substr.length < minlength) {
return null; }
468 if (stringIsInteger(substr)) {
return substr; }
482function urlencode(s) {
484 news = news.replace(/\+/gi,
'%2B');
485 news = news.replace(/&/gi,
'%26');
497function htmlEntityDecodeJs(inp){
498 var replacements = {
'<':
'<',
'>':
'>',
'/':
'/',
'"':
'"',
''':
'\'',
'&':
'&',
' ':
' '};
500 for(var r in replacements){
501 inp = inp.replace(
new RegExp(r,
'g'),replacements[r]);
503 return inp.replace(/&#(\d+);/g,
function(match, dec) {
504 return String.fromCharCode(dec);
520 function ac_delay(funct,delay) {
522 setTimeout(funct,delay);
535function cleanSerialize(expr) {
536 if (typeof(expr) !=
'string') {
539 var reg =
new RegExp(
"(&)",
"g");
540 var reg2 =
new RegExp(
"[^A-Z0-9,]",
"g");
541 var liste1 = expr.replace(reg,
",");
542 return liste1.replace(reg2,
"");
556function displayMessage(fieldId,message) {
557 var textbox = document.getElementById(fieldId);
558 if (textbox.value ==
'') {
559 textbox.style.color =
'grey';
560 textbox.value = message;
574function hideMessage(fieldId,message) {
575 var textbox = document.getElementById(fieldId);
576 textbox.style.color =
'black';
577 if (textbox.value == message) textbox.value =
'';
597function setConstant(url, code, input, entity, strict, forcereload, userid, token, value, userconst) {
609 console.log(
"Ajax url request to set constant is a success. Make complementary actions and then forcereload="+forcereload+
" value="+value);
611 $(
"#set_" + code).show();
612 $(
"#del_" + code).hide();
614 $(
"#set_" + code).hide();
615 $(
"#del_" + code).show();
617 $.each(input,
function(
type, data) {
619 if (
type ==
"disabled" && strict != 1) {
620 $.each(data,
function(key, value) {
621 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
622 $(newvalue).removeAttr(
"disabled");
623 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
624 $(newvalue).removeClass(
"butActionRefused");
625 $(newvalue).addClass(
"butAction");
628 }
else if (
type ==
"enabled") {
629 $.each(data,
function(key, value) {
630 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
632 $(newvalue).removeAttr(
"disabled");
634 $(newvalue).attr(
"disabled",
true);
635 if ($(newvalue).hasClass(
"butAction") ==
true) {
636 $(newvalue).removeClass(
"butAction");
637 $(newvalue).addClass(
"butActionRefused");
641 }
else if (
type ==
"showhide" ||
type ==
"show") {
642 $.each(data,
function(key, value) {
643 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
647 }
else if (
type ==
"set") {
648 $.each(data,
function(key, value) {
649 $(
"#set_" + key).hide();
650 $(
"#del_" + key).show();
662 var url = window.location.href;
663 if (url.indexOf(
'dol_resetcache') < 0) {
664 if (url.indexOf(
'?') > -1) {
665 url = url +
"&dol_resetcache=1";
667 url = url +
"?dol_resetcache=1";
670 var page_y = $(document).scrollTop();
671 url = url.replace(/page_y=\d+/g,
'');
673 if (url.indexOf(
'?') > -1) {
674 url = url +
"&page_y="+page_y;
676 url = url +
"?page_y="+page_y;
679 url = url.replace(/&&+/,
'&');
680 console.log(
"url ro redirect = "+url);
682 window.location.href = url;
686 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
706function delConstant(url, code, input, entity, strict, forcereload, userid, token, userconst) {
717 console.log(
"Ajax url request to delete constant is success. Make complementary actions and then forcereload="+forcereload);
718 $(
"#del_" + code).hide();
719 $(
"#set_" + code).show();
720 $.each(input,
function(
type, data) {
722 if (
type ==
"disabled") {
723 $.each(data,
function(key, value) {
724 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
725 $(newvalue).attr(
"disabled",
true);
726 if ($(newvalue).hasClass(
"butAction") ==
true) {
727 $(newvalue).removeClass(
"butAction");
728 $(newvalue).addClass(
"butActionRefused");
731 }
else if (
type ==
"enabled" && strict != 1) {
732 $.each(data,
function(key, value) {
733 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
734 $(newvalue).removeAttr(
"disabled");
735 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
736 $(newvalue).removeClass(
"butActionRefused");
737 $(newvalue).addClass(
"butAction");
741 }
else if (
type ==
"showhide" ||
type ==
"hide") {
742 $.each(data,
function(key, value) {
743 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
747 }
else if (
type ==
"del") {
748 $.each(data,
function(key, value) {
749 $(
"#del_" + value).hide();
750 $(
"#set_" + value).show();
761 var url = window.location.href;
762 if (url.indexOf(
'dol_resetcache') < 0) {
763 if (url.indexOf(
'?') > -1) {
764 url = url +
"&dol_resetcache=1";
766 url = url +
"?dol_resetcache=1";
769 var page_y = $(document).scrollTop();
770 url = url.replace(/page_y=\d+/g,
'');
772 if (url.indexOf(
'?') > -1) {
773 url = url +
"&page_y="+page_y;
775 url = url +
"?page_y="+page_y;
778 url = url.replace(/&&+/,
'&');
779 console.log(
"url ro redirect = "+url);
781 window.location.href = url;
785 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
807function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid, token) {
808 var boxConfirm = box;
809 $(
"#confirm_" + code)
810 .attr(
"title", boxConfirm.title)
811 .html(boxConfirm.content)
819 id :
'yesButton_' + code,
822 if (action ==
"set") {
823 setConstant(url, code, input, entity, strict, 0, userid, token, 1);
824 }
else if (action ==
"del") {
825 delConstant(url, code, input, entity, strict, 0, userid, token);
828 $(
this).dialog(
"close");
830 if (boxConfirm.method) {
831 var fnName = boxConfirm.method;
832 if (window.hasOwnProperty(fnName)) {
839 id :
'noButton_' + code,
842 $(
this).dialog(
"close");
848 if (boxConfirm.info) {
849 $(
"#noButton_" + code).button().hide();
865 $.widget(
"ui.combobox", {
867 minLengthToAutocomplete: 0
869 _create:
function() {
870 var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
872 select = this.element.hide(),
873 selected = select.children(
":selected" ),
874 value = selected.val() ? selected.text() :
"";
875 var input = this.input = $(
"<input>" )
876 .insertAfter( select )
878 .attr(
'id',
'inputautocomplete'+select.attr(
'id'))
881 minLength: this.options.minLengthToAutocomplete,
882 source:
function( request, response ) {
883 var matcher =
new RegExp( $.ui.autocomplete.escapeRegex(request.term),
"i" );
884 response( select.children(
"option:enabled" ).map(
function() {
885 var text = $( this ).text();
886 if ( this.value && ( !request.term || matcher.test(text) ) )
890 "(?![^&;]+;)(?!<[^<>]*)(" +
891 $.ui.autocomplete.escapeRegex(request.term) +
892 ")(?![^<>]*>)(?![^&;]+;)",
"gi"
893 ),
"<strong>$1</strong>" ),
899 select:
function( event, ui ) {
900 ui.item.option.selected =
true;
901 self._trigger(
"selected", event, {
905 change:
function( event, ui ) {
907 var matcher =
new RegExp(
"^" + $.ui.autocomplete.escapeRegex( $(
this).val() ) +
"$",
"i" ),
909 select.children(
"option" ).each(
function() {
910 if ( $(
this ).text().match( matcher ) ) {
911 this.selected = valid =
true;
919 input.data(
"ui-autocomplete").term =
"";
925 .addClass(
"ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
927 input.data(
"ui-autocomplete")._renderItem =
function( ul, item ) {
929 .data(
"ui-autocomplete-item", item )
930 .append(
"<a>" + item.label +
"</a>" )
934 this.
button = $(
"<button type=\'button\'> </button>" )
935 .attr(
"tabIndex", -1 )
936 .attr(
"title",
"Show All Items" )
937 .insertAfter( input )
940 primary:
"ui-icon-triangle-1-s"
944 .removeClass(
"ui-corner-all" )
945 .addClass(
"ui-corner-right ui-button-icon" )
948 if ( input.autocomplete(
"widget" ).is(
":visible" ) ) {
949 input.autocomplete(
"close" );
954 input.autocomplete({ minLength: 0 });
955 input.autocomplete(
"search",
"" );
956 input.autocomplete({ minLength: savMinLengthToAutocomplete });
961 destroy:
function() {
965 $.Widget.prototype.destroy.call(
this );
980 text = text.replace(/<br>/g,
"\n");
981 var newElem =
'<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+
'</textarea><br><br>'+text2;
983 $(
"#dialogforpopup").html(newElem);
984 $(
"#dialogforpopup").dialog();
985 $(
"#coordsforpopup").select();
1001 var argc =
newpopup.arguments.length;
1003 console.log(
"newpopup "+argv[2]+
" "+argv[3]);
1004 var l = (argc > 2) ? argv[2] : 600;
1005 var h = (argc > 3) ? argv[3] : 400;
1006 var left = (screen.width - l)/2;
1007 var top = (screen.height - h)/2;
1008 var wfeatures =
"directories=0,menubar=0,status=0,resizable=0,scrollbars=1,toolbar=0,location=0,width=" + l +
",height=" + h +
",left=" + left +
",top=" + top;
1009 fen = window.open(tmp, title, wfeatures);
1026 var ValidImageTypes = [
"image/gif",
"image/jpeg",
"image/png",
"image/webp"];
1027 var showOriginalSizeButton =
false;
1029 console.log(
"document_preview A click was done: file="+file+
", type="+
type+
", title="+title);
1031 if ($.inArray(
type, ValidImageTypes) < 0) {
1034 var object_width=
'100%';
1035 var height = ($( window ).height() - 60) * 0.90;
1036 var object_height=
'98%';
1038 show_preview(
'notimage');
1043 var object_height=0;
1045 var img =
new Image();
1047 img.onload =
function() {
1048 object_width = this.width;
1049 object_height = this.height;
1051 width = $( window ).width()*0.90;
1052 console.log(
"object_width="+object_width+
" window width="+width);
1053 if(object_width < width){
1054 console.log(
"Object width is small, we set width of popup according to image width.");
1055 width = object_width + 30
1057 height = $( window ).height()*0.85;
1058 console.log(
"object_height="+object_height+
" window height="+height);
1059 if(object_height < height){
1060 console.log(
"Object height is small, we set height of popup according to image height.");
1061 height = object_height + 80
1065 showOriginalSizeButton =
true;
1068 show_preview(
'image');
1075 function show_preview(mode) {
1077 var newElem =
'<object name="objectpreview" data="'+file+
'" type="'+
type+
'" width="'+object_width+
'" height="'+object_height+
'" param="noparam"></object>';
1080 if (mode ==
'image' && showOriginalSizeButton)
1084 "<?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" }); },
1085 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("RotateImage
")); ?>":
function() { curRot += 90; jQuery(
".ui-dialog-content.ui-widget-content > object").css(
"transform",
"rotate(" + curRot +
"deg)"); },
1086 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("CloseWindow
")); ?>":
function() { $(
this ).dialog(
"close" ); }
1090 $(
"#dialogforpopup").html(newElem);
1092 $(
"#dialogforpopup").dialog({
1093 closeOnEscape:
true,
1099 buttons: optionsbuttons
1102 if (showOriginalSizeButton)
1104 jQuery(
".ui-dialog-content.ui-widget-content > object").css({
"max-height":
"100%",
"width":
"auto",
"margin-left":
"auto",
"margin-right":
"auto",
"display":
"block" });
1116function getParameterByName(
name, valueifnotfound)
1118 name =
name.replace(/[\[]/,
"\\[").replace(/[\]]/,
"\\]");
1119 var regex =
new RegExp(
"[\\?&]" +
name +
"=([^&#]*)"),
1120 results = regex.exec(location.search);
1121 return results ===
null ? valueifnotfound : decodeURIComponent(results[1].replace(/\+/g,
" "));
1129 const operatorList = {
1131 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1132 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1135 Contains:
'<?php print dol_escape_js($langs->trans('Contains
')); ?>',
1136 DoesNotContain:
'<?php print dol_escape_js($langs->trans('DoesNotContain
')); ?>',
1137 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1138 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1139 StartsWith:
'<?php print dol_escape_js($langs->trans('StartsWith
')); ?>',
1140 EndsWith:
'<?php print dol_escape_js($langs->trans('EndsWith
')); ?>'
1143 '=':
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1144 '!=':
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1145 '<':
'<?php print dol_escape_js($langs->trans('IsLowerThan
')); ?>',
1146 '>':
'<?php print dol_escape_js($langs->trans('IsHigherThan
')); ?>',
1147 '<=':
'<?php print dol_escape_js($langs->trans('IsLowerThanOrEqual
')); ?>',
1148 '>=':
'<?php print dol_escape_js($langs->trans('IsHigherThanOrEqual
')); ?>',
1151 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1152 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1153 IsBefore:
'<?php print dol_escape_js($langs->trans('IsBefore
')); ?>',
1154 IsAfter:
'<?php print dol_escape_js($langs->trans('IsAfter
')); ?>',
1155 IsOnOrBefore:
'<?php print dol_escape_js($langs->trans('IsOnOrBefore
')); ?>',
1156 IsOnOrAfter:
'<?php print dol_escape_js($langs->trans('IsOnOrAfter
')); ?>'
1159 Contains:
'<?php print $langs->trans('Contains
'); ?>'
1165 let generalType =
"";
1167 console.log(
'Get list of operators for type='+
type);
1169 if (/^select$/i.test(
type) || /^link$/i.test(
type)) {
1170 generalType =
"selectlink";
1171 }
else if (/^(varchar|
char|text|blob|nchar|mediumtext|longtext)\(\d+\)$/i.test(
type) || /^varchar$/i.test(
type)) {
1172 generalType =
"text";
1173 }
else if (/^(
int|integer|
float|
double|decimal|numeric)(\(\d+,\d+\))?$/i.test(
type)) {
1174 generalType =
"number";
1175 }
else if (/^(date|datetime|timestamp)$/i.test(
type)) {
1176 generalType =
"date";
1177 }
else if (/^(tinyint|smallint)\(\d+\)$/i.test(
type)) {
1178 generalType =
"number";
1179 }
else if (/^html$/i.test(
type)) {
1180 generalType =
"html";
1183 console.log(
"The type of field "+
type+
" is not supported");
1188 if (maybenull === 1) {
1189 operatorList[generalType][
"IsDefined"] =
'<?php print dol_escape_js($langs->trans('IsDefined
')); ?>';
1190 operatorList[generalType][
"IsNotDefined"] =
'<?php print dol_escape_js($langs->trans('IsNotDefined
')); ?>';
1194 return operatorList[generalType] || [];
1205 filter = column +
" like \'%" + context +
"%\'";
1207 case "DoesNotContain":
1208 filter = column +
" notlike \'%" + context +
"%\'";
1211 filter = column +
" = \'" + context +
"\'";
1214 filter = column +
" != \'" + context +
"\'";
1217 filter = column +
" like \'" + context +
"%\'";
1220 filter = column +
" like \'%" + context +
"\'";
1223 filter = column +
":isnot:null";
1225 case "IsNotDefined":
1226 filter = column +
":is:null";
1229 filter = column +
" = \'" + context +
"\'";
1232 filter = column +
" != \'" + context +
"\'";
1235 filter = column +
" < \'" + context +
"\'";
1238 filter = column +
" > \'" + context +
"\'";
1241 filter = column +
" <= \'" + context +
"\'";
1244 filter = column +
" >= \'" + context +
"\'";
1247 filter = column +
" < \'" + context +
"\'";
1250 filter = column +
" > \'" + context +
"\'";
1252 case "IsOnOrBefore":
1253 filter = column +
" <= \'" + context +
"\'";
1256 filter = column +
" >= \'" + context +
"\'";
1275 function decimalAdjust(
type, value, exp) {
1277 if (typeof exp ===
'undefined' || +exp === 0) {
1278 return Math[
type](value);
1283 if (isNaN(value) || !(typeof exp ===
'number' && exp % 1 === 0)) {
1287 value = value.toString().split(
'e');
1288 value = Math[
type](+(value[0] +
'e' + (value[1] ? (+value[1] - exp) : -exp)));
1290 value = value.toString().split(
'e');
1291 return +(value[0] +
'e' + (value[1] ? (+value[1] + exp) : exp));
1295 if (!Math.round10) {
1296 Math.round10 =
function(value, exp) {
1297 return decimalAdjust(
'round', value, exp);
1301 if (!Math.floor10) {
1302 Math.floor10 =
function(value, exp) {
1303 return decimalAdjust(
'floor', value, exp);
1308 Math.ceil10 =
function(value, exp) {
1309 return decimalAdjust(
'ceil', value, exp);
1315function dolroundjs(number, decimals) {
return +(Math.round(number +
"e+" + decimals) +
"e-" + decimals); }
1334function pricejs(amount, mode =
'MT', currency_code =
'', force_locale =
'') {
1335 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1336 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1337 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1338 var main_decimal_separator = <?php echo json_encode($dec) ?>;
1339 var main_thousand_separator = <?php echo json_encode($thousand) ?>;
1340 var locale_code = force_locale || <?php echo json_encode($langs->defaultlang) ?>;
1341 var amountAsLocalizedString;
1342 var useIntl = Boolean(Intl && Intl.NumberFormat);
1344 if (currency_code ===
'auto') currency_code = <?php echo json_encode(
$conf->currency) ?>;
1346 if (mode ===
'MU') nDigits = main_rounding_unit;
1347 else if (mode ===
'MT') nDigits = main_rounding_tot;
1348 else return 'Bad value for parameter mode';
1353 var formattingOptions = {
1354 minimumFractionDigits: nDigits,
1355 maximumFractionDigits: nDigits
1357 if (currency_code) {
1358 formattingOptions[
'style'] =
'currency';
1359 formattingOptions[
'currency'] = currency_code;
1361 return Intl.NumberFormat(locale_code.replace(
'_',
'-'), formattingOptions).format(amount);
1365 amountAsLocalizedString = amount.toFixed(nDigits).replace(
1366 /((?!^)(?:\d{3})*)(?:\.(\d+))?$/,
1367 (fullMatch, digitsByThree, decimals) =>
1368 digitsByThree.replace(
1370 (groupOfThree) => main_thousand_separator + groupOfThree
1371 ) + (decimals !== undefined ? main_decimal_separator + decimals :
'')
1372 ).replace(/ /,
' ');
1373 if (!currency_code)
return amountAsLocalizedString;
1376 var currency_symbol = currency_code;
1379 var currencyBeforeAmountCodes = {
1380 currency: [
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD'],
1384 if (currencyCache[currency_code]
1385 && currencyCache[currency_code][
'unicode']
1386 && currencyCache[currency_code][
'unicode'].length) {
1387 currency_symbol = currencyCache[currency_code][
'unicode'].reduce(
function (res, cur) {
return res + cur},
'');
1390 if (currencyBeforeAmountCodes.currency.indexOf(currency_code) >= 0
1391 || currencyBeforeAmountCodes.language.indexOf(locale_code)) {
1393 return currency_symbol + amountAsLocalizedString;
1397 return amountAsLocalizedString +
' ' + currency_symbol;
1408 if (amount ==
'')
return '';
1410 var dec = <?php echo json_encode($dec) ?>;
1411 var thousand = <?php echo json_encode($thousand) ?>;
1413 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1414 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1415 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1417 var amount = amount.toString();
1420 var rounding = main_rounding_unit;
1421 var pos = amount.indexOf(dec);
1424 decpart = amount.substring(pos + 1).replace(
'/0+$/i',
'');
1426 var nbdec = decpart.length;
1427 if (nbdec > rounding) {
1431 if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
1432 if (thousand !=
',' && thousand !=
'.') amount = amount.replace(
',',
'.');
1433 amount = amount.replace(
' ',
'');
1434 amount = amount.replace(thousand,
'');
1435 amount = amount.replace(dec,
'.');
1438 var res = Math.round10(amount, - rounding);
1442 console.log(
"price2numjs text="+amount+
" return="+res);
1449if (!
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
1452$(document).ready(
function() {
1453 if (typeof $.jnotify ==
'function') {
1457 , closeLabel:
"×"
1461 , classContainer:
"jnotify-container"
1462 , classNotification:
"jnotify-notification"
1463 , classBackground:
"jnotify-background"
1464 , classClose:
"jnotify-close"
1465 , classMessage:
"jnotify-message"
1468 , beforeRemove: null
1477jQuery(document).ready(
function() {
1479 if (window.location && window.location.pathname.indexOf(
"externalsite/frametop.php") == -1 && window.location !== window.parent.location ) {
1480 console.log(
"Page is detected to be into an iframe, we hide by CSS the menus");
1482 jQuery(
".side-nav-vert, .side-nav, .websitebar").hide();
1483 jQuery(
".id-container").css(
'width',
'100%');
1488 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")) ?>');
1492jQuery(document).ready(
function() {
1493 jQuery(document).on(
"click",
".butAction.dropdown-toggle",
function(event) {
1494 console.log(
"Click on .butAction.dropdown-toggle");
1495 let parentHolder = jQuery(event.target).parent();
1496 let dropDownContent = parentHolder.children(
".dropdown-content");
1497 let offset = parentHolder.offset();
1498 let widthDocument = $(document).width();
1499 let heightDocument = $(document).height();
1500 let right = widthDocument - offset.left - parentHolder.width();
1501 let widthPopup = parentHolder.children(
".dropdown-content").width();
1502 if (widthPopup + right >= widthDocument) {
1506 parentHolder.toggleClass(
"open");
1509 let dropDownContentTop = dropDownContent.offset().top;
1510 let dropDownContentLeft = dropDownContent.offset().left;
1511 let dropDownContentHeight = dropDownContent.outerHeight();
1512 let dropDownContentBottom = dropDownContentTop + dropDownContentHeight;
1513 let viewportBottom = $(window).scrollTop() + $(window).height();
1516 if(parentHolder.hasClass(
'open')
1517 && dropDownContentBottom > viewportBottom
1518 && dropDownContentTop - dropDownContentHeight > 0
1520 parentHolder.addClass(
"--up");
1522 parentHolder.removeClass(
"--up");
1526 if(parentHolder.hasClass(
'open') && dropDownContentLeft < 0){
1527 parentHolder.addClass(
"--left");
1529 parentHolder.removeClass(
"--left");
1534 jQuery(document).on(
"click",
function(event) {
1536 if (!$(event.target).closest(
'.butAction.dropdown-toggle').length) {
1538 let parentholder = jQuery(
".butAction.dropdown-toggle").closest(
".dropdown.open");
1541 parentholder.removeClass(
"open --up --left");
1549if (!
getDolGlobalString(
'MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined(
'DISABLE_SELECT2_FOCUS_PROTECTION')) {
1559$(document).on(
'select2:open', (e) => {
1560 console.log(
"Execute the focus (click on combo or use space when on component)");
1561 const target = $(e.target);
1562 if (target && target.length) {
1563 let
id = target[0].id || target[0].name;
1564 if (
id.substr(-2) ==
"[]") {
1565 id =
id.substr(0,
id.length-2);
1567 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, maybenull=0)
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.