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') {
153function dolBlockUI(message =
'Loading...', indicatorUrl =
'<?php echo DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif" ; ?>') {
154 const block = document.getElementById(
'dol-block-ui');
156 const msgDiv = block.querySelector(
'.message');
157 if (msgDiv !=
null) {
158 msgDiv.innerText = message;
159 msgDiv.style.backgroundImage = `url(
'${indicatorUrl}')`;
160 block.style.display =
'flex';
164function dolUnblockUI() {
165 document.getElementById(
'dol-block-ui').style.display =
'none';
170var tradMonths = <?php echo json_encode($tradMonths) ?>;
171var tradMonthsShort = <?php echo json_encode($tradMonthsShort) ?>;
172var tradDays = <?php echo json_encode($tradDays) ?>;
173var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>;
174var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>;
175var currencyCache = <?php echo json_encode($langs->cache_currencies) ?>;
178$(document).ready(
function() {
179 $.datepicker.setDefaults({
183 altField:
'#timestamp',
189 $.datepicker.regional[
'<?php echo $langs->defaultlang ?>'] = {
190 closeText:
'<?php echo $langs->trans("Close2") ?>',
191 prevText:
'<?php echo $langs->trans("Previous") ?>',
192 nextText:
'<?php echo $langs->trans("Next") ?>',
193 currentText:
'<?php echo $langs->trans("Now") ?>',
194 monthNames: tradMonths,
195 monthNamesShort: tradMonthsShort,
197 dayNamesShort: tradDaysShort,
198 dayNamesMin: tradDaysMin,
199 weekHeader:
'<?php echo $langs->trans("Week"); ?>',
200 dateFormat:
'<?php echo $langs->trans("FormatDateShortJQuery"); ?>',
201 firstDay: <?php echo(isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK :
'1'); ?>,
202 isRTL: <?php echo($langs->trans(
"DIRECTION") ==
'rtl' ?
'true' :
'false'); ?>,
203 showMonthAfterYear:
false,
206 $.datepicker.setDefaults($.datepicker.regional[
'<?php echo $langs->defaultlang ?>']);
215var select2arrayoflanguage = {
216 matches:
function (matches) {
return matches +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2ResultFoundUseArrows
")); ?>"; },
217 noResults:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2NotFound
")); ?>"; },
218 inputTooShort:
function (input) {
219 var n = input.minimum;
221 if (n > 1)
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacters
")); ?>";
222 else return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacter
")); ?>"
224 loadMore:
function (pageNumber) {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2LoadingMoreResults
")); ?>"; },
225 searching:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2SearchInProgress
")); ?>"; }
234function getObjectFromID(
id){
236 if(document.getElementById)
237 theObject=document.getElementById(
id);
239 theObject=document.all[id];
244function dpChangeDay(dateFieldID, format)
246 console.log(
"Call dpChangeDay, we save date from field "+dateFieldID+
" into detailed fields from format = "+format);
248 var thefield = getObjectFromID(dateFieldID);
249 var thefieldday = getObjectFromID(dateFieldID+
"day");
250 var thefieldmonth = getObjectFromID(dateFieldID+
"month");
251 var thefieldyear = getObjectFromID(dateFieldID+
"year");
253 console.log(
"string date value is " + thefield.value);
255 var date = getDateFromFormat(thefield.value, format);
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 newformat = format.replace(/yyyy/g,
'yy');
271 if (newformat != format) {
272 console.log(
"dpChangeDay, we try now from format = "+newformat);
274 var date = getDateFromFormat(thefield.value, newformat);
278 thefieldday.value = date.getDate();
279 if (thefieldday.onchange) thefieldday.onchange.call(thefieldday);
280 thefieldmonth.value = date.getMonth()+1;
281 if (thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
282 thefieldyear.value = date.getFullYear();
283 if (thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
289 thefieldday.value =
'';
290 if (thefieldday.onchange) thefieldday.onchange.call(thefieldday);
291 thefieldmonth.value =
'';
292 if (thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
293 thefieldyear.value =
'';
294 if (thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
313function formatDate(date,format)
322 var year=date.getFullYear();
323 var month=date.getMonth()+1;
324 var day=date.getDate();
325 var hour=date.getHours();
326 var minute=date.getMinutes();
327 var seconde=date.getSeconds();
330 while (i < format.length)
335 while ((format.charAt(j)==c) && (j < format.length))
337 substr += format.charAt(j++);
341 if (substr ==
'yyyy') { result=result+year; }
342 else if (substr ==
'yy') { result=result+year.substring(2,4); }
343 else if (substr ==
'M') { result=result+month; }
344 else if (substr ==
'MM') { result=result+(month<1||month>9?
"":
"0")+month; }
345 else if (substr ==
'd') { result=result+day; }
346 else if (substr ==
'dd') { result=result+(day<1||day>9?
"":
"0")+day; }
347 else if (substr ==
'hh') {
if (hour > 12) hour-=12; result=result+(hour<0||hour>9?
"":
"0")+hour; }
348 else if (substr ==
'HH') { result=result+(hour<0||hour>9?
"":
"0")+hour; }
349 else if (substr ==
'mm') { result=result+(minute<0||minute>9?
"":
"0")+minute; }
350 else if (substr ==
'ss') { result=result+(seconde<0||seconde>9?
"":
"0")+seconde; }
351 else { result=result+substr; }
381function getDateFromFormat(val, format)
389 if (val ==
'')
return 0;
392 var year=now.getFullYear();
393 var month=now.getMonth()+1;
394 var day=now.getDate();
395 var hour=now.getHours();
396 var minute=now.getMinutes();
397 var seconde=now.getSeconds();
402 while (i < format.length)
407 while ((format.charAt(j)==c) && (j < format.length))
409 substr += format.charAt(j++);
413 if (substr ==
"yyyy") year=getIntegerInString(val,d,4,4);
414 if (substr ==
"yy") year=
""+(getIntegerInString(val,d,2,2)-0+2000);
415 if (substr ==
"MM" ||substr ==
"M")
417 month=getIntegerInString(val,d,1,2);
418 if (month) d -= 2- month.length;
422 day=getIntegerInString(val,d,1,2);
423 if (day) d -= 2- day.length;
425 if (substr ==
"HH" ||substr ==
"hh" )
427 hour=getIntegerInString(val,d,1,2);
428 if (dhouray) d -= 2- hour.length;
431 minute=getIntegerInString(val,d,1,2);
432 if (minute) d -= 2- minute.length;
436 seconde=getIntegerInString(val,d,1,2);
437 if (seconde) d -= 2- seconde.length;
445 if (year==
null||year<1) {
return 0; }
446 if (month==
null||(month<1)||(month>12)) {
return 0; }
447 if (day==
null||(day<1)||(day>31)) {
return 0; }
448 if (hour==
null||(hour<0)||(hour>24)) {
return 0; }
449 if (minute==
null||(minute<0)||(minute>60)) {
return 0; }
450 if (seconde==
null||(seconde<0)||(seconde>60)) {
return 0; }
453 return new Date(year,month-1,day,hour,minute,seconde);
462function stringIsInteger(str)
464 var digits=
"1234567890";
465 for (var i=0; i < str.length; i++)
467 if (digits.indexOf(str.charAt(i))==-1)
481function getIntegerInString(str,i,minlength,maxlength)
483 for (var x=maxlength; x>=minlength; x--)
485 var substr=str.substring(i,i+x);
486 if (substr.length < minlength) {
return null; }
487 if (stringIsInteger(substr)) {
return substr; }
501function urlencode(s) {
503 news = news.replace(/\+/gi,
'%2B');
504 news = news.replace(/&/gi,
'%26');
516function htmlEntityDecodeJs(inp){
517 var replacements = {
'<':
'<',
'>':
'>',
'/':
'/',
'"':
'"',
''':
'\'',
'&':
'&',
' ':
' '};
519 for(var r in replacements){
520 inp = inp.replace(
new RegExp(r,
'g'),replacements[r]);
522 return inp.replace(/&#(\d+);/g,
function(match, dec) {
523 return String.fromCharCode(dec);
539 function ac_delay(funct,delay) {
541 setTimeout(funct,delay);
554function cleanSerialize(expr) {
555 if (typeof(expr) !=
'string') {
558 var reg =
new RegExp(
"(&)",
"g");
559 var reg2 =
new RegExp(
"[^A-Z0-9,]",
"g");
560 var liste1 = expr.replace(reg,
",");
561 return liste1.replace(reg2,
"");
576function displayMessage(fieldId,message) {
577 var textbox = document.getElementById(fieldId);
578 if (textbox.value ==
'') {
579 textbox.style.color =
'grey';
580 textbox.value = message;
595function hideMessage(fieldId,message) {
596 var textbox = document.getElementById(fieldId);
597 textbox.style.color =
'black';
598 if (textbox.value == message) textbox.value =
'';
618function setConstant(url, code, input, entity, strict, forcereload, userid, token, value, userconst) {
630 console.log(
"Ajax url request to set constant is a success. Make complementary actions and then forcereload="+forcereload+
" value="+value);
632 $(
"#set_" + code).show();
633 $(
"#del_" + code).hide();
635 $(
"#set_" + code).hide();
636 $(
"#del_" + code).show();
638 $.each(input,
function(
type, data) {
640 if (
type ==
"disabled" && strict != 1) {
641 $.each(data,
function(key, value) {
642 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
643 $(newvalue).removeAttr(
"disabled");
644 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
645 $(newvalue).removeClass(
"butActionRefused");
646 $(newvalue).addClass(
"butAction");
649 }
else if (
type ==
"enabled") {
650 $.each(data,
function(key, value) {
651 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
653 $(newvalue).removeAttr(
"disabled");
655 $(newvalue).attr(
"disabled",
true);
656 if ($(newvalue).hasClass(
"butAction") ==
true) {
657 $(newvalue).removeClass(
"butAction");
658 $(newvalue).addClass(
"butActionRefused");
662 }
else if (
type ==
"showhide" ||
type ==
"show") {
663 $.each(data,
function(key, value) {
664 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
668 }
else if (
type ==
"set") {
669 $.each(data,
function(key, value) {
670 $(
"#set_" + key).hide();
671 $(
"#del_" + key).show();
683 var url = window.location.href;
686 url = url.replace(/action=\w+/g,
'');
689 if (url.indexOf(
'dol_resetcache') < 0) {
690 if (url.indexOf(
'?') > -1) {
691 url = url +
"&dol_resetcache=1";
693 url = url +
"?dol_resetcache=1";
698 var page_y = $(document).scrollTop();
699 url = url.replace(/page_y=\d+/g,
'');
701 if (url.indexOf(
'?') > -1) {
702 url = url +
"&page_y="+page_y;
704 url = url +
"?page_y="+page_y;
707 url = url.replace(/&&+/,
'&');
708 console.log(
"url ro redirect = "+url);
710 window.location.href = url;
714 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
734function delConstant(url, code, input, entity, strict, forcereload, userid, token, userconst) {
745 console.log(
"Ajax url request to delete constant is success. Make complementary actions and then forcereload="+forcereload);
746 $(
"#del_" + code).hide();
747 $(
"#set_" + code).show();
748 $.each(input,
function(
type, data) {
750 if (
type ==
"disabled") {
751 $.each(data,
function(key, value) {
752 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
753 $(newvalue).attr(
"disabled",
true);
754 if ($(newvalue).hasClass(
"butAction") ==
true) {
755 $(newvalue).removeClass(
"butAction");
756 $(newvalue).addClass(
"butActionRefused");
759 }
else if (
type ==
"enabled" && strict != 1) {
760 $.each(data,
function(key, value) {
761 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
762 $(newvalue).removeAttr(
"disabled");
763 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
764 $(newvalue).removeClass(
"butActionRefused");
765 $(newvalue).addClass(
"butAction");
769 }
else if (
type ==
"showhide" ||
type ==
"hide") {
770 $.each(data,
function(key, value) {
771 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
775 }
else if (
type ==
"del") {
776 $.each(data,
function(key, value) {
777 $(
"#del_" + value).hide();
778 $(
"#set_" + value).show();
789 var url = window.location.href;
790 if (url.indexOf(
'dol_resetcache') < 0) {
791 if (url.indexOf(
'?') > -1) {
792 url = url +
"&dol_resetcache=1";
794 url = url +
"?dol_resetcache=1";
797 var page_y = $(document).scrollTop();
798 url = url.replace(/page_y=\d+/g,
'');
800 if (url.indexOf(
'?') > -1) {
801 url = url +
"&page_y="+page_y;
803 url = url +
"?page_y="+page_y;
806 url = url.replace(/&&+/,
'&');
807 console.log(
"url ro redirect = "+url);
809 window.location.href = url;
813 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
835function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid, token) {
836 var boxConfirm = box;
837 $(
"#confirm_" + code)
838 .attr(
"title", boxConfirm.title)
839 .html(boxConfirm.content)
847 id :
'yesButton_' + code,
850 if (action ==
"set") {
851 setConstant(url, code, input, entity, strict, 0, userid, token, 1);
852 }
else if (action ==
"del") {
853 delConstant(url, code, input, entity, strict, 0, userid, token);
856 $(
this).dialog(
"close");
858 if (boxConfirm.method) {
859 var fnName = boxConfirm.method;
860 if (window.hasOwnProperty(fnName)) {
867 id :
'noButton_' + code,
870 $(
this).dialog(
"close");
876 if (boxConfirm.info) {
877 $(
"#noButton_" + code).button().hide();
893 $.widget(
"ui.combobox", {
895 minLengthToAutocomplete: 0
897 _create:
function() {
898 var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
900 select = this.element.hide(),
901 selected = select.children(
":selected" ),
902 value = selected.val() ? selected.text() :
"";
903 var input = this.input = $(
"<input>" )
904 .insertAfter( select )
906 .attr(
'id',
'inputautocomplete'+select.attr(
'id'))
909 minLength: this.options.minLengthToAutocomplete,
910 source:
function( request, response ) {
911 var matcher =
new RegExp( $.ui.autocomplete.escapeRegex(request.term),
"i" );
912 response( select.children(
"option:enabled" ).map(
function() {
913 var text = $( this ).text();
914 if ( this.value && ( !request.term || matcher.test(text) ) )
918 "(?![^&;]+;)(?!<[^<>]*)(" +
919 $.ui.autocomplete.escapeRegex(request.term) +
920 ")(?![^<>]*>)(?![^&;]+;)",
"gi"
921 ),
"<strong>$1</strong>" ),
927 select:
function( event, ui ) {
928 ui.item.option.selected =
true;
929 self._trigger(
"selected", event, {
933 change:
function( event, ui ) {
935 var matcher =
new RegExp(
"^" + $.ui.autocomplete.escapeRegex( $(
this).val() ) +
"$",
"i" ),
937 select.children(
"option" ).each(
function() {
938 if ( $(
this ).text().match( matcher ) ) {
939 this.selected = valid =
true;
947 input.data(
"ui-autocomplete").term =
"";
953 .addClass(
"ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
955 const widgetInstance = input.data(
"ui-autocomplete");
956 if (widgetInstance) {
957 widgetInstance._renderItem =
function( ul, item ) {
959 .data(
"ui-autocomplete-item", item )
960 .append(
"<a>" + item.label +
"</a>" )
965 this.
button = $(
"<button type=\'button\'> </button>" )
966 .attr(
"tabIndex", -1 )
967 .attr(
"title",
"Show All Items" )
968 .insertAfter( input )
971 primary:
"ui-icon-triangle-1-s"
975 .removeClass(
"ui-corner-all" )
976 .addClass(
"ui-corner-right ui-button-icon" )
979 if ( input.autocomplete(
"widget" ).is(
":visible" ) ) {
980 input.autocomplete(
"close" );
985 input.autocomplete({ minLength: 0 });
986 input.autocomplete(
"search",
"" );
987 input.autocomplete({ minLength: savMinLengthToAutocomplete });
992 destroy:
function() {
996 $.Widget.prototype.destroy.call(
this );
1011 text = text.replace(/<br>/g,
"\n");
1012 var newElem =
'<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+
'</textarea><br><br>'+text2;
1014 $(
"#dialogforpopup").html(newElem);
1015 $(
"#dialogforpopup").dialog();
1016 $(
"#coordsforpopup").select();
1032 var argc =
newpopup.arguments.length;
1034 console.log(
"newpopup "+argv[2]+
" "+argv[3]);
1035 var l = (argc > 2) ? argv[2] : 600;
1036 var h = (argc > 3) ? argv[3] : 400;
1037 var left = (screen.width - l)/2;
1038 var top = (screen.height - h)/2;
1039 var wfeatures =
"directories=0,menubar=0,status=0,resizable=0,scrollbars=1,toolbar=0,location=0,width=" + l +
",height=" + h +
",left=" + left +
",top=" + top;
1040 fen = window.open(tmp, title, wfeatures);
1057 var ValidImageTypes = [
"image/gif",
"image/jpeg",
"image/png",
"image/webp"];
1058 var showOriginalSizeButton =
false;
1060 console.log(
"document_preview A click was done: file="+file+
", type="+
type+
", title="+title);
1062 if ($.inArray(
type, ValidImageTypes) < 0) {
1065 var object_width=
'100%';
1066 var height = ($( window ).height() - 60) * 0.90;
1067 var object_height=
'98%';
1069 show_preview(
'notimage');
1074 var object_height=0;
1076 var img =
new Image();
1078 img.onload =
function() {
1079 object_width = this.width;
1080 object_height = this.height;
1082 width = $( window ).width()*0.90;
1083 console.log(
"object_width="+object_width+
" window width="+width);
1084 if(object_width < width){
1085 console.log(
"Object width is small, we set width of popup according to image width.");
1086 width = object_width + 30
1088 height = $( window ).height()*0.85;
1089 console.log(
"object_height="+object_height+
" window height="+height);
1090 if(object_height < height){
1091 console.log(
"Object height is small, we set height of popup according to image height.");
1092 height = object_height + 100
1096 showOriginalSizeButton =
true;
1099 show_preview(
'image');
1106 function show_preview(mode) {
1108 var newElem =
'<object name="objectpreview" data="'+file+
'" type="'+
type+
'" width="'+object_width+
'" height="'+object_height+
'" param="noparam"></object>';
1111 if (mode ==
'image' && showOriginalSizeButton)
1115 "<?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" }); },
1116 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("RotateImage
")); ?>":
function() { curRot += 90; jQuery(
".ui-dialog-content.ui-widget-content > object").css(
"transform",
"rotate(" + curRot +
"deg)"); },
1117 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("CloseWindow
")); ?>":
function() { $(
this ).dialog(
"close" ); }
1121 $(
"#dialogforpopup").addClass(
"center");
1122 $(
"#dialogforpopup").html(newElem);
1124 $(
"#dialogforpopup").dialog({
1125 closeOnEscape:
true,
1131 buttons: optionsbuttons
1134 if (showOriginalSizeButton)
1136 jQuery(
".ui-dialog-content.ui-widget-content > object").css({
"max-height":
"100%",
"width":
"auto",
"margin-left":
"auto",
"margin-right":
"auto",
"display":
"block" });
1148function getParameterByName(
name, valueifnotfound)
1150 name =
name.replace(/[\[]/,
"\\[").replace(/[\]]/,
"\\]");
1151 var regex =
new RegExp(
"[\\?&]" +
name +
"=([^&#]*)"),
1152 results = regex.exec(location.search);
1153 return results ===
null ? valueifnotfound : decodeURIComponent(results[1].replace(/\+/g,
" "));
1160 console.log(
'Get list of operators for type='+
type);
1163 const operatorList = {
1165 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1166 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1169 Contains:
'<?php print dol_escape_js($langs->trans('Contains
')); ?>',
1170 DoesNotContain:
'<?php print dol_escape_js($langs->trans('DoesNotContain
')); ?>',
1171 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1172 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1173 StartsWith:
'<?php print dol_escape_js($langs->trans('StartsWith
')); ?>',
1174 EndsWith:
'<?php print dol_escape_js($langs->trans('EndsWith
')); ?>'
1177 '=':
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1178 '!=':
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1179 '<':
'<?php print dol_escape_js($langs->trans('IsLowerThan
')); ?>',
1180 '>':
'<?php print dol_escape_js($langs->trans('IsHigherThan
')); ?>',
1181 '<=':
'<?php print dol_escape_js($langs->trans('IsLowerThanOrEqual
')); ?>',
1182 '>=':
'<?php print dol_escape_js($langs->trans('IsHigherThanOrEqual
')); ?>',
1185 Is:
'<?php print dol_escape_js($langs->trans('Is
')); ?>',
1186 IsNot:
'<?php print dol_escape_js($langs->trans('IsNot
')); ?>',
1187 IsBefore:
'<?php print dol_escape_js($langs->trans('IsBefore
')); ?>',
1188 IsAfter:
'<?php print dol_escape_js($langs->trans('IsAfter
')); ?>',
1189 IsOnOrBefore:
'<?php print dol_escape_js($langs->trans('IsOnOrBefore
')); ?>',
1190 IsOnOrAfter:
'<?php print dol_escape_js($langs->trans('IsOnOrAfter
')); ?>'
1193 Contains:
'<?php print $langs->trans('Contains
'); ?>'
1198 let generalType =
"";
1200 if (/^select$/i.test(
type) || /^link$/i.test(
type)) {
1201 generalType =
"selectlink";
1202 }
else if (/^(varchar|
char|text|blob|nchar|mediumtext|longtext)\(\d+\)$/i.test(
type) || /^(varchar|mail|phone|ip)$/i.test(
type)) {
1203 generalType =
"text";
1204 }
else if (/^(
int|integer|
float|
double|decimal|numeric)(\(\d+,\d+\))?$/i.test(
type)) {
1205 generalType =
"number";
1206 }
else if (/^(date|datetime|timestamp)$/i.test(
type)) {
1207 generalType =
"date";
1208 }
else if (/^(tinyint|smallint)\(\d+\)$/i.test(
type)) {
1209 generalType =
"number";
1210 }
else if (/^html$/i.test(
type)) {
1211 generalType =
"html";
1214 console.log(
"The type of field "+
type+
" is not supported");
1219 if (maybenull === 1) {
1220 operatorList[generalType][
"IsDefined"] =
'<?php print dol_escape_js($langs->trans('IsDefined
')); ?>';
1221 operatorList[generalType][
"IsNotDefined"] =
'<?php print dol_escape_js($langs->trans('IsNotDefined
')); ?>';
1225 return operatorList[generalType] || [];
1234 console.log(
"generateFilterString column="+column+
" operator="+
operator+
" context="+context+
" fieldType="+fieldType);
1238 filter = column +
" like \'%" + context +
"%\'";
1240 case "DoesNotContain":
1241 filter = column +
" notlike \'%" + context +
"%\'";
1244 filter = column +
" = \'" + context +
"\'";
1247 filter = column +
" != \'" + context +
"\'";
1250 filter = column +
" like \'" + context +
"%\'";
1253 filter = column +
" like \'%" + context +
"\'";
1256 filter = column +
":isnot:null";
1258 case "IsNotDefined":
1259 filter = column +
":is:null";
1262 filter = column +
" = \'" + context +
"\'";
1265 filter = column +
" != \'" + context +
"\'";
1268 filter = column +
" < \'" + context +
"\'";
1271 filter = column +
" > \'" + context +
"\'";
1274 filter = column +
" <= \'" + context +
"\'";
1277 filter = column +
" >= \'" + context +
"\'";
1280 filter = column +
" < \'" + context +
"\'";
1283 filter = column +
" > \'" + context +
"\'";
1285 case "IsOnOrBefore":
1286 filter = column +
" <= \'" + context +
"\'";
1289 filter = column +
" >= \'" + context +
"\'";
1308 function decimalAdjust(
type, value, exp) {
1310 if (typeof exp ===
'undefined' || +exp === 0) {
1311 return Math[
type](value);
1316 if (isNaN(value) || !(typeof exp ===
'number' && exp % 1 === 0)) {
1320 value = value.toString().split(
'e');
1321 value = Math[
type](+(value[0] +
'e' + (value[1] ? (+value[1] - exp) : -exp)));
1323 value = value.toString().split(
'e');
1324 return +(value[0] +
'e' + (value[1] ? (+value[1] + exp) : exp));
1328 if (!Math.round10) {
1329 Math.round10 =
function(value, exp) {
1330 return decimalAdjust(
'round', value, exp);
1334 if (!Math.floor10) {
1335 Math.floor10 =
function(value, exp) {
1336 return decimalAdjust(
'floor', value, exp);
1341 Math.ceil10 =
function(value, exp) {
1342 return decimalAdjust(
'ceil', value, exp);
1348function dolroundjs(number, decimals) {
return +(Math.round(number +
"e+" + decimals) +
"e-" + decimals); }
1367function pricejs(amount, mode =
'MT', currency_code =
'', force_locale =
'') {
1368 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1369 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1370 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1371 var main_decimal_separator = <?php echo json_encode($dec) ?>;
1372 var main_thousand_separator = <?php echo json_encode($thousand) ?>;
1373 var locale_code = force_locale || <?php echo json_encode($langs->defaultlang) ?>;
1374 var amountAsLocalizedString;
1375 var useIntl = Boolean(Intl && Intl.NumberFormat);
1377 if (currency_code ===
'auto') currency_code = <?php echo json_encode(
$conf->currency) ?>;
1379 if (mode ===
'MU') nDigits = main_rounding_unit;
1380 else if (mode ===
'MT') nDigits = main_rounding_tot;
1381 else return 'Bad value for parameter mode';
1386 var formattingOptions = {
1387 minimumFractionDigits: nDigits,
1388 maximumFractionDigits: nDigits
1390 if (currency_code) {
1391 formattingOptions[
'style'] =
'currency';
1392 formattingOptions[
'currency'] = currency_code;
1394 return Intl.NumberFormat(locale_code.replace(
'_',
'-'), formattingOptions).format(amount);
1398 amountAsLocalizedString = amount.toFixed(nDigits).replace(
1399 /((?!^)(?:\d{3})*)(?:\.(\d+))?$/,
1400 (fullMatch, digitsByThree, decimals) =>
1401 digitsByThree.replace(
1403 (groupOfThree) => main_thousand_separator + groupOfThree
1404 ) + (decimals !== undefined ? main_decimal_separator + decimals :
'')
1405 ).replace(/ /,
' ');
1406 if (!currency_code)
return amountAsLocalizedString;
1409 var currency_symbol = currency_code;
1412 var currencyBeforeAmountCodes = {
1413 currency: [
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD'],
1417 if (currencyCache[currency_code]
1418 && currencyCache[currency_code][
'unicode']
1419 && currencyCache[currency_code][
'unicode'].length) {
1420 currency_symbol = currencyCache[currency_code][
'unicode'].reduce(
function (res, cur) {
return res + cur},
'');
1423 if (currencyBeforeAmountCodes.currency.indexOf(currency_code) >= 0
1424 || currencyBeforeAmountCodes.language.indexOf(locale_code)) {
1426 return currency_symbol + amountAsLocalizedString;
1430 return amountAsLocalizedString +
' ' + currency_symbol;
1441 if (amount ==
'')
return '';
1443 var dec = <?php echo json_encode($dec) ?>;
1444 var thousand = <?php echo json_encode($thousand) ?>;
1446 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1447 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1448 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1450 var amount = amount.toString();
1453 var rounding = main_rounding_unit;
1454 var pos = amount.indexOf(dec);
1457 decpart = amount.substring(pos + 1).replace(
'/0+$/i',
'');
1459 var nbdec = decpart.length;
1460 if (nbdec > rounding) {
1464 if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
1465 if (thousand !=
',' && thousand !=
'.') amount = amount.replace(
',',
'.');
1466 amount = amount.replace(
' ',
'');
1467 amount = amount.replace(thousand,
'');
1468 amount = amount.replace(dec,
'.');
1471 var res = Math.round10(amount, - rounding);
1475 console.log(
"price2numjs text="+amount+
" return="+res);
1482if (!
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
1485$(document).ready(
function() {
1486 if (typeof $.jnotify ==
'function') {
1490 , closeLabel:
"×"
1494 , classContainer:
"jnotify-container"
1495 , classNotification:
"jnotify-notification"
1496 , classBackground:
"jnotify-background"
1497 , classClose:
"jnotify-close"
1498 , classMessage:
"jnotify-message"
1501 , beforeRemove: null
1510jQuery(document).ready(
function() {
1512 if (window.location && window.location.pathname.indexOf(
"core/frames.php") == -1 && window.location.pathname.indexOf(
"externalsite/frametop.php") == -1 && window.location !== window.parent.location ) {
1513 console.log(
"Page is detected to be into an iframe, we hide by CSS the menus");
1515 jQuery(
".side-nav-vert, .side-nav, .websitebar").hide();
1516 jQuery(
".id-container").css(
'width',
'100%');
1522 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")) ?>');
1526 jQuery(document).on(
"click",
".butAction.dropdown-toggle",
function(event) {
1527 console.log(
"Click on .butAction.dropdown-toggle");
1528 let parentHolder = jQuery(event.target).parent();
1529 let dropDownContent = parentHolder.children(
".dropdown-content");
1530 let offset = parentHolder.offset();
1531 let widthDocument = $(document).width();
1532 let heightDocument = $(document).height();
1533 let right = widthDocument - offset.left - parentHolder.width();
1534 let widthPopup = parentHolder.children(
".dropdown-content").width();
1535 if (widthPopup + right >= widthDocument) {
1539 parentHolder.toggleClass(
"open");
1542 let dropDownContentTop = dropDownContent.offset().top;
1543 let dropDownContentLeft = dropDownContent.offset().left;
1544 let dropDownContentHeight = dropDownContent.outerHeight();
1545 let dropDownContentBottom = dropDownContentTop + dropDownContentHeight;
1546 let viewportBottom = $(window).scrollTop() + $(window).height();
1549 if (parentHolder.hasClass(
'open')
1550 && dropDownContentBottom > viewportBottom
1551 && dropDownContentTop - dropDownContentHeight > 0
1553 parentHolder.addClass(
"--up");
1555 parentHolder.removeClass(
"--up");
1559 if (parentHolder.hasClass(
'open') && dropDownContentLeft < 0) {
1560 parentHolder.addClass(
"--left");
1562 parentHolder.removeClass(
"--left");
1568 jQuery(document).on(
"click",
function(event) {
1570 if (!$(event.target).closest(
'.butAction.dropdown-toggle').length) {
1572 let parentholder = jQuery(
".butAction.dropdown-toggle").closest(
".dropdown.open");
1575 parentholder.removeClass(
"open --up --left");
1585function showOptions(child_list, parent_list) {
1586 var parentInput = $(
"select[name="+parent_list+
"]");
1587 if (parentInput.length === 0) {
1588 parentInput = $(
"input[name="+parent_list+
"]");
1590 if (parentInput.length > 0) {
1591 var val = parentInput.val();
1592 var parentVal = parent_list +
":" + val;
1594 $(
"select[name=\""+child_list+
"\"] option[parent]").prop(
"disabled",
true).hide();
1595 $(
"select[name=\""+child_list+
"\"] option[parent=\""+parentVal+
"\"]").prop(
'disabled',
false).show();
1597 $(
"select[name=\""+child_list+
"\"] option").prop(
"disabled",
false).show();
1601function setListDependencies() {
1602 console.log(
"setListDependencies");
1603 jQuery(
"select option[parent]").parent().each(
function() {
1604 var child_list = $(
this).attr(
"name");
1605 var parent = $(
this).find(
"option[parent]:first").attr(
"parent");
1606 var infos = parent.split(
":");
1607 var parent_list = infos[0];
1608 showOptions(child_list, parent_list);
1611 $(
"select[name=\""+parent_list+
"\"]").change(
function() {
1612 showOptions(child_list, parent_list);
1619if (!
getDolGlobalString(
'MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined(
'DISABLE_SELECT2_FOCUS_PROTECTION')) {
1630$(document).on(
'select2:open', (e) => {
1631 console.log(
"Execute the focus (click on combo or use space when on component)");
1632 const target = $(e.target);
1633 if (target && target.length) {
1634 let
id = target[0].id || target[0].name;
1635 if (
id.substr(-2) ==
'[]') {
1636 id =
id.substr(0,
id.length-2);
1638 document.querySelector(
'input[aria-controls*='+
id+
']').focus();
1650$(document).ready(
function() {
1651 if ($(
'.kanban .column').length > 0) {
1652 $(
'.kanban .column').sortable({
1653 items:
'.kanban-draggable',
1654 connectWith:
'.kanban .column',
1657 tolerance:
'pointer',
1658 start:
function(_, ui) {
1659 ui.item.data(
'original-column', ui.item.parent());
1660 ui.placeholder.height(ui.item.outerHeight());
1662 receive:
function(_, ui) {
1663 var originalColumn = ui.item.data(
'original-column');
1664 var newColumn = $(
this);
1666 if (!originalColumn.is(newColumn)) {
1667 onKanbanColumnChange(ui.item, newColumn);
1679function onKanbanColumnChange(item, newColumn) {
1680 console.log(
"Call onKanbanColumnChange");
1683 url:
'<?php echo DOL_URL_ROOT; ?>/core/ajax/saveinplace.php',
1685 field:
'editval_'+newColumn.data(
'groupbyfield'),
1686 element: item.data(
'element'),
1687 table_element: item.data(
'tableelement'),
1688 fk_element: item.data(
'itemid'),
1689 value: newColumn.data(
'groupbyid'),
1690 token:
'<?php echo currentToken() ?>'
1692 context: document.body,
1693 success: function() {
1694 if (newColumn.hasClass(
'kanbancollapsed')) {
1699 item.data(
'original-column', newColumn);
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 possible operators for a given field type that we can use in the generic filter.
copyToClipboard(text, text2)
Function to output a dialog box for copy/paste.
document_preview(file, type, title)
Function to show a document preview popup.
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|dolcrypt):/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.
if(empty( $takeposterminal)) fail($message)
Abort invoice creation with a given error message.