27if (!defined(
'NOREQUIRESOC')) {
28 define(
'NOREQUIRESOC',
'1');
30if (!defined(
'NOCSRFCHECK')) {
31 define(
'NOCSRFCHECK', 1);
33if (!defined(
'NOTOKENRENEWAL')) {
34 define(
'NOTOKENRENEWAL', 1);
36if (!defined(
'NOLOGIN')) {
39if (!defined(
'NOREQUIREMENU')) {
40 define(
'NOREQUIREMENU', 1);
42if (!defined(
'NOREQUIREHTML')) {
43 define(
'NOREQUIREHTML', 1);
45if (!defined(
'NOREQUIREAJAX')) {
46 define(
'NOREQUIREAJAX',
'1');
49session_cache_limiter(
'public');
51require_once
'../../main.inc.php';
61if (empty($dolibarr_nocache)) {
62 header(
'Cache-Control: max-age=10800, public, must-revalidate');
64 header(
'Cache-Control: no-cache');
85$tradMonthsShort = array(
86$langs->trans(
"MonthShort01"),
87$langs->trans(
"MonthShort02"),
88$langs->trans(
"MonthShort03"),
89$langs->trans(
"MonthShort04"),
90$langs->trans(
"MonthShort05"),
91$langs->trans(
"MonthShort06"),
92$langs->trans(
"MonthShort07"),
93$langs->trans(
"MonthShort08"),
94$langs->trans(
"MonthShort09"),
95$langs->trans(
"MonthShort10"),
96$langs->trans(
"MonthShort11"),
97$langs->trans(
"MonthShort12")
101$langs->trans(
"Sunday"),
102$langs->trans(
"Monday"),
103$langs->trans(
"Tuesday"),
104$langs->trans(
"Wednesday"),
105$langs->trans(
"Thursday"),
106$langs->trans(
"Friday"),
107$langs->trans(
"Saturday")
110$tradDaysShort = array(
111$langs->trans(
"ShortSunday"),
112$langs->trans(
"ShortMonday"),
113$langs->trans(
"ShortTuesday"),
114$langs->trans(
"ShortWednesday"),
115$langs->trans(
"ShortThursday"),
116$langs->trans(
"ShortFriday"),
117$langs->trans(
"ShortSaturday")
121$langs->trans(
"SundayMin"),
122$langs->trans(
"MondayMin"),
123$langs->trans(
"TuesdayMin"),
124$langs->trans(
"WednesdayMin"),
125$langs->trans(
"ThursdayMin"),
126$langs->trans(
"FridayMin"),
127$langs->trans(
"SaturdayMin")
133if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
134 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
136if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
137 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
139if ($thousand ==
'Space') {
147var tradMonths = <?php echo json_encode($tradMonths) ?>;
148var tradMonthsShort = <?php echo json_encode($tradMonthsShort) ?>;
149var tradDays = <?php echo json_encode($tradDays) ?>;
150var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>;
151var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>;
152var currencyCache = <?php echo json_encode($langs->cache_currencies) ?>;
155$(document).ready(
function() {
156 $.datepicker.setDefaults({
160 altField:
'#timestamp',
166 $.datepicker.regional[
'<?php echo $langs->defaultlang ?>'] = {
167 closeText:
'<?php echo $langs->trans("Close2") ?>',
168 prevText:
'<?php echo $langs->trans("Previous") ?>',
169 nextText:
'<?php echo $langs->trans("Next") ?>',
170 currentText:
'<?php echo $langs->trans("Now") ?>',
171 monthNames: tradMonths,
172 monthNamesShort: tradMonthsShort,
174 dayNamesShort: tradDaysShort,
175 dayNamesMin: tradDaysMin,
176 weekHeader:
'<?php echo $langs->trans("Week"); ?>',
177 dateFormat:
'<?php echo $langs->trans("FormatDateShortJQuery"); ?>',
178 firstDay: <?php echo (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK :
'1'); ?>,
179 isRTL: <?php echo ($langs->trans(
"DIRECTION") ==
'rtl' ?
'true' :
'false'); ?>,
180 showMonthAfterYear:
false,
183 $.datepicker.setDefaults($.datepicker.regional[
'<?php echo $langs->defaultlang ?>']);
192var select2arrayoflanguage = {
193 matches:
function (matches) {
return matches +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2ResultFoundUseArrows
")); ?>"; },
194 noResults:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2NotFound
")); ?>"; },
195 inputTooShort:
function (input) {
196 var n = input.minimum;
199 if (n > 1)
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacters
")); ?>";
200 else return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacter
")); ?>"
202 loadMore:
function (pageNumber) {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2LoadingMoreResults
")); ?>"; },
203 searching:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2SearchInProgress
")); ?>"; }
212function getObjectFromID(
id){
214 if(document.getElementById)
215 theObject=document.getElementById(
id);
217 theObject=document.all[id];
222function dpChangeDay(dateFieldID, format)
225 console.log(
"Call dpChangeDay, we save date into detailed fields from format = "+format);
227 var thefield=getObjectFromID(dateFieldID);
228 var thefieldday=getObjectFromID(dateFieldID+
"day");
229 var thefieldmonth=getObjectFromID(dateFieldID+
"month");
230 var thefieldyear=getObjectFromID(dateFieldID+
"year");
232 var date=getDateFromFormat(thefield.value, format);
236 thefieldday.value=date.getDate();
237 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
238 thefieldmonth.value=date.getMonth()+1;
239 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
240 thefieldyear.value=date.getFullYear();
241 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
245 thefieldday.value=
'';
246 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
247 thefieldmonth.value=
'';
248 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
249 thefieldyear.value=
'';
250 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
267function formatDate(date,format)
276 var year=date.getYear()+
"";
if (year.length < 4) { year=
""+(year-0+1900); }
277 var month=date.getMonth()+1;
278 var day=date.getDate();
279 var hour=date.getHours();
280 var minute=date.getMinutes();
281 var seconde=date.getSeconds();
284 while (i < format.length)
289 while ((format.charAt(j)==c) && (j < format.length))
291 substr += format.charAt(j++);
295 if (substr ==
'yyyy') { result=result+year; }
296 else if (substr ==
'yy') { result=result+year.substring(2,4); }
297 else if (substr ==
'M') { result=result+month; }
298 else if (substr ==
'MM') { result=result+(month<1||month>9?
"":
"0")+month; }
299 else if (substr ==
'd') { result=result+day; }
300 else if (substr ==
'dd') { result=result+(day<1||day>9?
"":
"0")+day; }
301 else if (substr ==
'hh') {
if (hour > 12) hour-=12; result=result+(hour<0||hour>9?
"":
"0")+hour; }
302 else if (substr ==
'HH') { result=result+(hour<0||hour>9?
"":
"0")+hour; }
303 else if (substr ==
'mm') { result=result+(minute<0||minute>9?
"":
"0")+minute; }
304 else if (substr ==
'ss') { result=result+(seconde<0||seconde>9?
"":
"0")+seconde; }
305 else { result=result+substr; }
335function getDateFromFormat(val,format)
343 if (val ==
'')
return 0;
346 var year=now.getYear();
if (year.length < 4) { year=
""+(year-0+1900); }
347 var month=now.getMonth()+1;
348 var day=now.getDate();
349 var hour=now.getHours();
350 var minute=now.getMinutes();
351 var seconde=now.getSeconds();
357 while (i < format.length)
362 while ((format.charAt(j)==c) && (j < format.length))
366 substr += format.charAt(j++);
370 if (substr ==
"yyyy") year=getIntegerInString(val,d,4,4);
371 if (substr ==
"yy") year=
""+(getIntegerInString(val,d,2,2)-0+1900);
372 if (substr ==
"MM" ||substr ==
"M")
374 month=getIntegerInString(val,d,1,2);
375 if (month) d -= 2- month.length;
379 day=getIntegerInString(val,d,1,2);
380 if (day) d -= 2- day.length;
382 if (substr ==
"HH" ||substr ==
"hh" )
384 hour=getIntegerInString(val,d,1,2);
385 if (dhouray) d -= 2- hour.length;
388 minute=getIntegerInString(val,d,1,2);
389 if (minute) d -= 2- minute.length;
393 seconde=getIntegerInString(val,d,1,2);
394 if (seconde) d -= 2- seconde.length;
402 if (year==
null||year<1) {
return 0; }
403 if (month==
null||(month<1)||(month>12)) {
return 0; }
404 if (day==
null||(day<1)||(day>31)) {
return 0; }
405 if (hour==
null||(hour<0)||(hour>24)) {
return 0; }
406 if (minute==
null||(minute<0)||(minute>60)) {
return 0; }
407 if (seconde==
null||(seconde<0)||(seconde>60)) {
return 0; }
410 return new Date(year,month-1,day,hour,minute,seconde);
419function stringIsInteger(str)
421 var digits=
"1234567890";
422 for (var i=0; i < str.length; i++)
424 if (digits.indexOf(str.charAt(i))==-1)
438function getIntegerInString(str,i,minlength,maxlength)
440 for (var x=maxlength; x>=minlength; x--)
442 var substr=str.substring(i,i+x);
443 if (substr.length < minlength) {
return null; }
444 if (stringIsInteger(substr)) {
return substr; }
458function urlencode(s) {
460 news = news.replace(/\+/gi,
'%2B');
461 news = news.replace(/&/gi,
'%26');
473function htmlEntityDecodeJs(inp){
474 var replacements = {
'<':
'<',
'>':
'>',
'/':
'/',
'"':
'"',
''':
'\'',
'&':
'&',
' ':
' '};
476 for(var r in replacements){
477 inp = inp.replace(
new RegExp(r,
'g'),replacements[r]);
479 return inp.replace(/&#(\d+);/g,
function(match, dec) {
480 return String.fromCharCode(dec);
496 function ac_delay(funct,delay) {
498 setTimeout(funct,delay);
511function cleanSerialize(expr) {
512 if (typeof(expr) !=
'string') {
515 var reg =
new RegExp(
"(&)",
"g");
516 var reg2 =
new RegExp(
"[^A-Z0-9,]",
"g");
517 var liste1 = expr.replace(reg,
",");
518 return liste1.replace(reg2,
"");
532function displayMessage(fieldId,message) {
533 var textbox = document.getElementById(fieldId);
534 if (textbox.value ==
'') {
535 textbox.style.color =
'grey';
536 textbox.value = message;
550function hideMessage(fieldId,message) {
551 var textbox = document.getElementById(fieldId);
552 textbox.style.color =
'black';
553 if (textbox.value == message) textbox.value =
'';
572function setConstant(url, code, input, entity, strict, forcereload, userid, token, value) {
582 console.log(
"Ajax url request to set constant is a success. Make complementary actions and then forcereload="+forcereload+
" value="+value);
584 $(
"#set_" + code).show();
585 $(
"#del_" + code).hide();
587 $(
"#set_" + code).hide();
588 $(
"#del_" + code).show();
590 $.each(input,
function(
type, data) {
592 if (
type ==
"disabled" && strict != 1) {
593 $.each(data,
function(key, value) {
594 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
595 $(newvalue).removeAttr(
"disabled");
596 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
597 $(newvalue).removeClass(
"butActionRefused");
598 $(newvalue).addClass(
"butAction");
601 }
else if (
type ==
"enabled") {
602 $.each(data,
function(key, value) {
603 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
605 $(newvalue).removeAttr(
"disabled");
607 $(newvalue).attr(
"disabled",
true);
608 if ($(newvalue).hasClass(
"butAction") ==
true) {
609 $(newvalue).removeClass(
"butAction");
610 $(newvalue).addClass(
"butActionRefused");
614 }
else if (
type ==
"showhide" ||
type ==
"show") {
615 $.each(data,
function(key, value) {
616 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
620 }
else if (
type ==
"set") {
621 $.each(data,
function(key, value) {
622 $(
"#set_" + key).hide();
623 $(
"#del_" + key).show();
635 var url = window.location.href;
636 if (url.indexOf(
'dol_resetcache') < 0) {
637 if (url.indexOf(
'?') > -1) {
638 url = url +
"&dol_resetcache=1";
640 url = url +
"?dol_resetcache=1";
643 var page_y = $(document).scrollTop();
644 url = url.replace(/page_y=\d+/g,
'');
646 if (url.indexOf(
'?') > -1) {
647 url = url +
"&page_y="+page_y;
649 url = url +
"?page_y="+page_y;
652 url = url.replace(/&&+/,
'&');
653 console.log(
"url ro redirect = "+url);
655 window.location.href = url;
659 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
678function delConstant(url, code, input, entity, strict, forcereload, userid, token) {
687 console.log(
"Ajax url request to delete constant is success. Make complementary actions and then forcereload="+forcereload);
688 $(
"#del_" + code).hide();
689 $(
"#set_" + code).show();
690 $.each(input,
function(
type, data) {
692 if (
type ==
"disabled") {
693 $.each(data,
function(key, value) {
694 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
695 $(newvalue).attr(
"disabled",
true);
696 if ($(newvalue).hasClass(
"butAction") ==
true) {
697 $(newvalue).removeClass(
"butAction");
698 $(newvalue).addClass(
"butActionRefused");
701 }
else if (
type ==
"enabled" && strict != 1) {
702 $.each(data,
function(key, value) {
703 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
704 $(newvalue).removeAttr(
"disabled");
705 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
706 $(newvalue).removeClass(
"butActionRefused");
707 $(newvalue).addClass(
"butAction");
711 }
else if (
type ==
"showhide" ||
type ==
"hide") {
712 $.each(data,
function(key, value) {
713 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
717 }
else if (
type ==
"del") {
718 $.each(data,
function(key, value) {
719 $(
"#del_" + value).hide();
720 $(
"#set_" + value).show();
731 var url = window.location.href;
732 if (url.indexOf(
'dol_resetcache') < 0) {
733 if (url.indexOf(
'?') > -1) {
734 url = url +
"&dol_resetcache=1";
736 url = url +
"?dol_resetcache=1";
739 var page_y = $(document).scrollTop();
740 url = url.replace(/page_y=\d+/g,
'');
742 if (url.indexOf(
'?') > -1) {
743 url = url +
"&page_y="+page_y;
745 url = url +
"?page_y="+page_y;
748 url = url.replace(/&&+/,
'&');
749 console.log(
"url ro redirect = "+url);
751 window.location.href = url;
755 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
777function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid, token) {
778 var boxConfirm = box;
779 $(
"#confirm_" + code)
780 .attr(
"title", boxConfirm.title)
781 .html(boxConfirm.content)
789 id :
'yesButton_' + code,
792 if (action ==
"set") {
793 setConstant(url, code, input, entity, strict, 0, userid, token, 1);
794 }
else if (action ==
"del") {
795 delConstant(url, code, input, entity, strict, 0, userid, token);
798 $(
this).dialog(
"close");
800 if (boxConfirm.method) {
801 var fnName = boxConfirm.method;
802 if (window.hasOwnProperty(fnName)) {
809 id :
'noButton_' + code,
812 $(
this).dialog(
"close");
818 if (boxConfirm.info) {
819 $(
"#noButton_" + code).button().hide();
835 $.widget(
"ui.combobox", {
837 minLengthToAutocomplete: 0
839 _create:
function() {
840 var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
842 select = this.element.hide(),
843 selected = select.children(
":selected" ),
844 value = selected.val() ? selected.text() :
"";
845 var input = this.input = $(
"<input>" )
846 .insertAfter( select )
848 .attr(
'id',
'inputautocomplete'+select.attr(
'id'))
851 minLength: this.options.minLengthToAutocomplete,
852 source:
function( request, response ) {
853 var matcher =
new RegExp( $.ui.autocomplete.escapeRegex(request.term),
"i" );
854 response( select.children(
"option:enabled" ).map(
function() {
855 var text = $( this ).text();
856 if ( this.value && ( !request.term || matcher.test(text) ) )
860 "(?![^&;]+;)(?!<[^<>]*)(" +
861 $.ui.autocomplete.escapeRegex(request.term) +
862 ")(?![^<>]*>)(?![^&;]+;)",
"gi"
863 ),
"<strong>$1</strong>" ),
869 select:
function( event, ui ) {
870 ui.item.option.selected =
true;
871 self._trigger(
"selected", event, {
875 change:
function( event, ui ) {
877 var matcher =
new RegExp(
"^" + $.ui.autocomplete.escapeRegex( $(
this).val() ) +
"$",
"i" ),
879 select.children(
"option" ).each(
function() {
880 if ( $(
this ).text().match( matcher ) ) {
881 this.selected = valid =
true;
889 input.data(
"ui-autocomplete").term =
"";
895 .addClass(
"ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
897 input.data(
"ui-autocomplete")._renderItem =
function( ul, item ) {
899 .data(
"ui-autocomplete-item", item )
900 .append(
"<a>" + item.label +
"</a>" )
904 this.
button = $(
"<button type=\'button\'> </button>" )
905 .attr(
"tabIndex", -1 )
906 .attr(
"title",
"Show All Items" )
907 .insertAfter( input )
910 primary:
"ui-icon-triangle-1-s"
914 .removeClass(
"ui-corner-all" )
915 .addClass(
"ui-corner-right ui-button-icon" )
918 if ( input.autocomplete(
"widget" ).is(
":visible" ) ) {
919 input.autocomplete(
"close" );
924 input.autocomplete({ minLength: 0 });
925 input.autocomplete(
"search",
"" );
926 input.autocomplete({ minLength: savMinLengthToAutocomplete });
931 destroy:
function() {
935 $.Widget.prototype.destroy.call(
this );
950 text = text.replace(/<br>/g,
"\n");
951 var newElem =
'<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+
'</textarea><br><br>'+text2;
953 $(
"#dialogforpopup").html(newElem);
954 $(
"#dialogforpopup").dialog();
955 $(
"#coordsforpopup").select();
971 var argc =
newpopup.arguments.length;
973 console.log(
"newpopup "+argv[2]+
" "+argv[3]);
974 var l = (argc > 2) ? argv[2] : 600;
975 var h = (argc > 3) ? argv[3] : 400;
976 var left = (screen.width - l)/2;
977 var top = (screen.height - h)/2;
978 var wfeatures =
"directories=0,menubar=0,status=0,resizable=0,scrollbars=1,toolbar=0,width=" + l +
",height=" + h +
",left=" + left +
",top=" + top;
979 fen=window.open(tmp,title,wfeatures);
996 var ValidImageTypes = [
"image/gif",
"image/jpeg",
"image/png",
"image/webp"];
997 var showOriginalSizeButton =
false;
999 console.log(
"document_preview A click was done. file="+file+
", type="+
type+
", title="+title);
1001 if ($.inArray(
type, ValidImageTypes) < 0) {
1004 var object_width=
'100%';
1005 var height = ($( window ).height() - 60) * 0.90;
1006 var object_height=
'98%';
1008 show_preview(
'notimage');
1013 var object_height=0;
1015 var img =
new Image();
1017 img.onload =
function() {
1018 object_width = this.width;
1019 object_height = this.height;
1021 width = $( window ).width()*0.90;
1022 console.log(
"object_width="+object_width+
" window width="+width);
1023 if(object_width < width){
1024 console.log(
"Object width is small, we set width of popup according to image width.");
1025 width = object_width + 30
1027 height = $( window ).height()*0.85;
1028 console.log(
"object_height="+object_height+
" window height="+height);
1029 if(object_height < height){
1030 console.log(
"Object height is small, we set height of popup according to image height.");
1031 height = object_height + 80
1035 showOriginalSizeButton =
true;
1038 show_preview(
'image');
1045 function show_preview(mode) {
1047 var newElem =
'<object name="objectpreview" data="'+file+
'" type="'+
type+
'" width="'+object_width+
'" height="'+object_height+
'" param="noparam"></object>';
1050 if (mode ==
'image' && showOriginalSizeButton)
1053 "<?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" }); },
1054 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("CloseWindow
")); ?>":
function() { $(
this ).dialog(
"close" ); }
1058 $(
"#dialogforpopup").html(newElem);
1060 $(
"#dialogforpopup").dialog({
1061 closeOnEscape:
true,
1067 buttons: optionsbuttons
1070 if (showOriginalSizeButton)
1072 jQuery(
".ui-dialog-content.ui-widget-content > object").css({
"max-height":
"100%",
"width":
"auto",
"margin-left":
"auto",
"margin-right":
"auto",
"display":
"block" });
1086 name =
name.replace(/[\[]/,
"\\[").replace(/[\]]/,
"\\]");
1087 var regex =
new RegExp(
"[\\?&]" +
name +
"=([^&#]*)"),
1088 results = regex.exec(location.search);
1089 return results ===
null ? valueifnotfound : decodeURIComponent(results[1].replace(/\+/g,
" "));
1103 function decimalAdjust(
type, value, exp) {
1105 if (typeof exp ===
'undefined' || +exp === 0) {
1106 return Math[
type](value);
1111 if (isNaN(value) || !(typeof exp ===
'number' && exp % 1 === 0)) {
1115 value = value.toString().split(
'e');
1116 value = Math[
type](+(value[0] +
'e' + (value[1] ? (+value[1] - exp) : -exp)));
1118 value = value.toString().split(
'e');
1119 return +(value[0] +
'e' + (value[1] ? (+value[1] + exp) : exp));
1123 if (!Math.round10) {
1124 Math.round10 =
function(value, exp) {
1125 return decimalAdjust(
'round', value, exp);
1129 if (!Math.floor10) {
1130 Math.floor10 =
function(value, exp) {
1131 return decimalAdjust(
'floor', value, exp);
1136 Math.ceil10 =
function(value, exp) {
1137 return decimalAdjust(
'ceil', value, exp);
1143function dolroundjs(number, decimals) {
return +(Math.round(number +
"e+" + decimals) +
"e-" + decimals); }
1162function pricejs(amount, mode =
'MT', currency_code =
'', force_locale =
'') {
1163 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalInt(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1164 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1165 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1166 var main_decimal_separator = <?php echo json_encode($dec) ?>;
1167 var main_thousand_separator = <?php echo json_encode($thousand) ?>;
1168 var locale_code = force_locale || <?php echo json_encode($langs->defaultlang) ?>;
1169 var amountAsLocalizedString;
1170 var useIntl = Boolean(Intl && Intl.NumberFormat);
1172 if (currency_code ===
'auto') currency_code = <?php echo json_encode($conf->currency) ?>;
1174 if (mode ===
'MU') nDigits = main_rounding_unit;
1175 else if (mode ===
'MT') nDigits = main_rounding_tot;
1176 else return 'Bad value for parameter mode';
1181 var formattingOptions = {
1182 minimumFractionDigits: nDigits,
1183 maximumFractionDigits: nDigits
1185 if (currency_code) {
1186 formattingOptions[
'style'] =
'currency';
1187 formattingOptions[
'currency'] = currency_code;
1189 return Intl.NumberFormat(locale_code.replace(
'_',
'-'), formattingOptions).format(amount);
1193 amountAsLocalizedString = amount.toFixed(nDigits).replace(
1194 /((?!^)(?:\d{3})*)(?:\.(\d+))?$/,
1195 (fullMatch, digitsByThree, decimals) =>
1196 digitsByThree.replace(
1198 (groupOfThree) => main_thousand_separator + groupOfThree
1199 ) + (decimals !== undefined ? main_decimal_separator + decimals :
'')
1200 ).replace(/ /,
' ');
1201 if (!currency_code)
return amountAsLocalizedString;
1204 var currency_symbol = currency_code;
1207 var currencyBeforeAmountCodes = {
1208 currency: [
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD'],
1212 if (currencyCache[currency_code]
1213 && currencyCache[currency_code][
'unicode']
1214 && currencyCache[currency_code][
'unicode'].length) {
1215 currency_symbol = currencyCache[currency_code][
'unicode'].reduce(
function (res, cur) {
return res + cur},
'');
1218 if (currencyBeforeAmountCodes.currency.indexOf(currency_code) >= 0
1219 || currencyBeforeAmountCodes.language.indexOf(locale_code)) {
1221 return currency_symbol + amountAsLocalizedString;
1225 return amountAsLocalizedString +
' ' + currency_symbol;
1236 if (amount ==
'')
return '';
1238 var dec = <?php echo json_encode($dec) ?>;
1239 var thousand = <?php echo json_encode($thousand) ?>;
1241 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalInt(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1242 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1243 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1245 var amount = amount.toString();
1248 var rounding = main_rounding_unit;
1249 var pos = amount.indexOf(dec);
1252 decpart = amount.substring(pos + 1).replace(
'/0+$/i',
'');
1254 var nbdec = decpart.length;
1255 if (nbdec > rounding) {
1259 if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
1260 if (thousand !=
',' && thousand !=
'.') amount = amount.replace(
',',
'.');
1261 amount = amount.replace(
' ',
'');
1262 amount = amount.replace(thousand,
'');
1263 amount = amount.replace(dec,
'.');
1266 var res = Math.round10(amount, - rounding);
1270 console.log(
"price2numjs text="+amount+
" return="+res);
1277if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
1280$(document).ready(
function() {
1281 if (typeof $.jnotify ==
'function') {
1285 , closeLabel:
"×"
1289 , classContainer:
"jnotify-container"
1290 , classNotification:
"jnotify-notification"
1291 , classBackground:
"jnotify-background"
1292 , classClose:
"jnotify-close"
1293 , classMessage:
"jnotify-message"
1296 , beforeRemove: null
1303jQuery(document).ready(
function() {
1305 if (window.location && window.location.pathname.indexOf(
"externalsite/frametop.php") == -1 && window.location !== window.parent.location ) {
1306 console.log(
"Page is detected to be into an iframe, we hide by CSS the menus");
1308 jQuery(
".side-nav-vert, .side-nav, .websitebar").hide();
1309 jQuery(
".id-container").css(
'width',
'100%');
1314 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")) ?>');
1318jQuery(document).ready(
function() {
1319 jQuery(
".butAction.dropdown-toggle").on(
"click",
function(event) {
1320 console.log(
"Click on .butAction.dropdown-toggle");
1321 var parentholder = jQuery(
".butAction.dropdown-toggle").closest(
".dropdown");
1322 var offset = parentholder.offset();
1323 var widthdocument = $(document).width();
1324 var left = offset.left;
1325 var right = widthdocument - offset.left - parentholder.width();
1326 var widthpopup = parentholder.children(
".dropdown-content").width();
1327 console.log(
"left="+left+
" right="+right+
" width="+widthpopup+
" widthdocument="+widthdocument);
1328 if (widthpopup + right >= widthdocument) {
1331 parentholder.toggleClass(
"open");
1332 parentholder.children(
".dropdown-content").css({
"right": right+
"px",
"left":
"auto"});
1338if (empty($conf->global->MAIN_DISABLE_SELECT2_FOCUS_PROTECTION) && !defined(
'DISABLE_SELECT2_FOCUS_PROTECTION')) {
1348$(document).on(
'select2:open', (e) => {
1349 console.log(
"Execute the focus (click on combo or use space when on component");
1350 const target = $(e.target);
1351 if (target && target.length) {
1352 let
id = target[0].id || target[0].name;
1353 if (
id.substr(-2) ==
"[]")
id =
id.substr(0,
id.length-2);
1354 document.querySelector(
'input[aria-controls*='+
id+
']').focus();
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
if(empty($user->rights->takepos->run) &&!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if((getDolGlobalString( 'TAKEPOS_PHONE_BASIC_LAYOUT')==1 &&$conf->browser->layout=='phone')||defined( 'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) fail($message)
Abort invoice creationg with a given error message.
getParameterByName(name, valueifnotfound)
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()
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.
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
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.