28if (!defined(
'NOREQUIRESOC')) {
29 define(
'NOREQUIRESOC',
'1');
31if (!defined(
'NOCSRFCHECK')) {
32 define(
'NOCSRFCHECK', 1);
34if (!defined(
'NOTOKENRENEWAL')) {
35 define(
'NOTOKENRENEWAL', 1);
37if (!defined(
'NOLOGIN')) {
40if (!defined(
'NOREQUIREMENU')) {
41 define(
'NOREQUIREMENU', 1);
43if (!defined(
'NOREQUIREHTML')) {
44 define(
'NOREQUIREHTML', 1);
46if (!defined(
'NOREQUIREAJAX')) {
47 define(
'NOREQUIREAJAX',
'1');
50session_cache_limiter(
'public');
52require_once
'../../main.inc.php';
62if (empty($dolibarr_nocache)) {
63 header(
'Cache-Control: max-age=10800, public, must-revalidate');
65 header(
'Cache-Control: no-cache');
86$tradMonthsShort = array(
87$langs->trans(
"MonthShort01"),
88$langs->trans(
"MonthShort02"),
89$langs->trans(
"MonthShort03"),
90$langs->trans(
"MonthShort04"),
91$langs->trans(
"MonthShort05"),
92$langs->trans(
"MonthShort06"),
93$langs->trans(
"MonthShort07"),
94$langs->trans(
"MonthShort08"),
95$langs->trans(
"MonthShort09"),
96$langs->trans(
"MonthShort10"),
97$langs->trans(
"MonthShort11"),
98$langs->trans(
"MonthShort12")
102$langs->trans(
"Sunday"),
103$langs->trans(
"Monday"),
104$langs->trans(
"Tuesday"),
105$langs->trans(
"Wednesday"),
106$langs->trans(
"Thursday"),
107$langs->trans(
"Friday"),
108$langs->trans(
"Saturday")
111$tradDaysShort = array(
112$langs->trans(
"ShortSunday"),
113$langs->trans(
"ShortMonday"),
114$langs->trans(
"ShortTuesday"),
115$langs->trans(
"ShortWednesday"),
116$langs->trans(
"ShortThursday"),
117$langs->trans(
"ShortFriday"),
118$langs->trans(
"ShortSaturday")
122$langs->trans(
"SundayMin"),
123$langs->trans(
"MondayMin"),
124$langs->trans(
"TuesdayMin"),
125$langs->trans(
"WednesdayMin"),
126$langs->trans(
"ThursdayMin"),
127$langs->trans(
"FridayMin"),
128$langs->trans(
"SaturdayMin")
134if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
135 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
137if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
138 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
140if ($thousand ==
'Space') {
148var tradMonths = <?php echo json_encode($tradMonths) ?>;
149var tradMonthsShort = <?php echo json_encode($tradMonthsShort) ?>;
150var tradDays = <?php echo json_encode($tradDays) ?>;
151var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>;
152var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>;
153var currencyCache = <?php echo json_encode($langs->cache_currencies) ?>;
156$(document).ready(
function() {
157 $.datepicker.setDefaults({
161 altField:
'#timestamp',
167 $.datepicker.regional[
'<?php echo $langs->defaultlang ?>'] = {
168 closeText:
'<?php echo $langs->trans("Close2") ?>',
169 prevText:
'<?php echo $langs->trans("Previous") ?>',
170 nextText:
'<?php echo $langs->trans("Next") ?>',
171 currentText:
'<?php echo $langs->trans("Now") ?>',
172 monthNames: tradMonths,
173 monthNamesShort: tradMonthsShort,
175 dayNamesShort: tradDaysShort,
176 dayNamesMin: tradDaysMin,
177 weekHeader:
'<?php echo $langs->trans("Week"); ?>',
178 dateFormat:
'<?php echo $langs->trans("FormatDateShortJQuery"); ?>',
179 firstDay: <?php echo(isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK :
'1'); ?>,
180 isRTL: <?php echo($langs->trans(
"DIRECTION") ==
'rtl' ?
'true' :
'false'); ?>,
181 showMonthAfterYear:
false,
184 $.datepicker.setDefaults($.datepicker.regional[
'<?php echo $langs->defaultlang ?>']);
193var select2arrayoflanguage = {
194 matches:
function (matches) {
return matches +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2ResultFoundUseArrows
")); ?>"; },
195 noResults:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2NotFound
")); ?>"; },
196 inputTooShort:
function (input) {
197 var n = input.minimum;
199 if (n > 1)
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacters
")); ?>";
200 else return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2Enter
")); ?> " + n +
" <?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2MoreCharacter
")); ?>"
202 loadMore:
function (pageNumber) {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2LoadingMoreResults
")); ?>"; },
203 searching:
function () {
return "<?php echo dol_escape_js($langs->transnoentitiesnoconv("Select2SearchInProgress
")); ?>"; }
212function getObjectFromID(
id){
214 if(document.getElementById)
215 theObject=document.getElementById(
id);
217 theObject=document.all[id];
222function dpChangeDay(dateFieldID, format)
225 console.log(
"Call dpChangeDay, we save date into detailed fields from format = "+format);
227 var thefield=getObjectFromID(dateFieldID);
228 var thefieldday=getObjectFromID(dateFieldID+
"day");
229 var thefieldmonth=getObjectFromID(dateFieldID+
"month");
230 var thefieldyear=getObjectFromID(dateFieldID+
"year");
232 var date=getDateFromFormat(thefield.value, format);
236 thefieldday.value=date.getDate();
237 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
238 thefieldmonth.value=date.getMonth()+1;
239 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
240 thefieldyear.value=date.getFullYear();
241 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
245 thefieldday.value=
'';
246 if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
247 thefieldmonth.value=
'';
248 if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
249 thefieldyear.value=
'';
250 if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
268function formatDate(date,format)
277 var year=date.getYear()+
"";
if (year.length < 4) { year=
""+(year-0+2000); }
278 var month=date.getMonth()+1;
279 var day=date.getDate();
280 var hour=date.getHours();
281 var minute=date.getMinutes();
282 var seconde=date.getSeconds();
285 while (i < format.length)
290 while ((format.charAt(j)==c) && (j < format.length))
292 substr += format.charAt(j++);
296 if (substr ==
'yyyy') { result=result+year; }
297 else if (substr ==
'yy') { result=result+year.substring(2,4); }
298 else if (substr ==
'M') { result=result+month; }
299 else if (substr ==
'MM') { result=result+(month<1||month>9?
"":
"0")+month; }
300 else if (substr ==
'd') { result=result+day; }
301 else if (substr ==
'dd') { result=result+(day<1||day>9?
"":
"0")+day; }
302 else if (substr ==
'hh') {
if (hour > 12) hour-=12; result=result+(hour<0||hour>9?
"":
"0")+hour; }
303 else if (substr ==
'HH') { result=result+(hour<0||hour>9?
"":
"0")+hour; }
304 else if (substr ==
'mm') { result=result+(minute<0||minute>9?
"":
"0")+minute; }
305 else if (substr ==
'ss') { result=result+(seconde<0||seconde>9?
"":
"0")+seconde; }
306 else { result=result+substr; }
336function getDateFromFormat(val,format)
344 if (val ==
'')
return 0;
347 var year=now.getYear();
if (year.length < 4) { year=
""+(year-0+2000); }
348 var month=now.getMonth()+1;
349 var day=now.getDate();
350 var hour=now.getHours();
351 var minute=now.getMinutes();
352 var seconde=now.getSeconds();
358 while (i < format.length)
363 while ((format.charAt(j)==c) && (j < format.length))
367 substr += format.charAt(j++);
371 if (substr ==
"yyyy") year=getIntegerInString(val,d,4,4);
372 if (substr ==
"yy") year=
""+(getIntegerInString(val,d,2,2)-0+2000);
373 if (substr ==
"MM" ||substr ==
"M")
375 month=getIntegerInString(val,d,1,2);
376 if (month) d -= 2- month.length;
380 day=getIntegerInString(val,d,1,2);
381 if (day) d -= 2- day.length;
383 if (substr ==
"HH" ||substr ==
"hh" )
385 hour=getIntegerInString(val,d,1,2);
386 if (dhouray) d -= 2- hour.length;
389 minute=getIntegerInString(val,d,1,2);
390 if (minute) d -= 2- minute.length;
394 seconde=getIntegerInString(val,d,1,2);
395 if (seconde) d -= 2- seconde.length;
403 if (year==
null||year<1) {
return 0; }
404 if (month==
null||(month<1)||(month>12)) {
return 0; }
405 if (day==
null||(day<1)||(day>31)) {
return 0; }
406 if (hour==
null||(hour<0)||(hour>24)) {
return 0; }
407 if (minute==
null||(minute<0)||(minute>60)) {
return 0; }
408 if (seconde==
null||(seconde<0)||(seconde>60)) {
return 0; }
411 return new Date(year,month-1,day,hour,minute,seconde);
420function stringIsInteger(str)
422 var digits=
"1234567890";
423 for (var i=0; i < str.length; i++)
425 if (digits.indexOf(str.charAt(i))==-1)
439function getIntegerInString(str,i,minlength,maxlength)
441 for (var x=maxlength; x>=minlength; x--)
443 var substr=str.substring(i,i+x);
444 if (substr.length < minlength) {
return null; }
445 if (stringIsInteger(substr)) {
return substr; }
459function urlencode(s) {
461 news = news.replace(/\+/gi,
'%2B');
462 news = news.replace(/&/gi,
'%26');
474function htmlEntityDecodeJs(inp){
475 var replacements = {
'<':
'<',
'>':
'>',
'/':
'/',
'"':
'"',
''':
'\'',
'&':
'&',
' ':
' '};
477 for(var r in replacements){
478 inp = inp.replace(
new RegExp(r,
'g'),replacements[r]);
480 return inp.replace(/&#(\d+);/g,
function(match, dec) {
481 return String.fromCharCode(dec);
497 function ac_delay(funct,delay) {
499 setTimeout(funct,delay);
512function cleanSerialize(expr) {
513 if (typeof(expr) !=
'string') {
516 var reg =
new RegExp(
"(&)",
"g");
517 var reg2 =
new RegExp(
"[^A-Z0-9,]",
"g");
518 var liste1 = expr.replace(reg,
",");
519 return liste1.replace(reg2,
"");
533function displayMessage(fieldId,message) {
534 var textbox = document.getElementById(fieldId);
535 if (textbox.value ==
'') {
536 textbox.style.color =
'grey';
537 textbox.value = message;
551function hideMessage(fieldId,message) {
552 var textbox = document.getElementById(fieldId);
553 textbox.style.color =
'black';
554 if (textbox.value == message) textbox.value =
'';
573function setConstant(url, code, input, entity, strict, forcereload, userid, token, value) {
583 console.log(
"Ajax url request to set constant is a success. Make complementary actions and then forcereload="+forcereload+
" value="+value);
585 $(
"#set_" + code).show();
586 $(
"#del_" + code).hide();
588 $(
"#set_" + code).hide();
589 $(
"#del_" + code).show();
591 $.each(input,
function(
type, data) {
593 if (
type ==
"disabled" && strict != 1) {
594 $.each(data,
function(key, value) {
595 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
596 $(newvalue).removeAttr(
"disabled");
597 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
598 $(newvalue).removeClass(
"butActionRefused");
599 $(newvalue).addClass(
"butAction");
602 }
else if (
type ==
"enabled") {
603 $.each(data,
function(key, value) {
604 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
606 $(newvalue).removeAttr(
"disabled");
608 $(newvalue).attr(
"disabled",
true);
609 if ($(newvalue).hasClass(
"butAction") ==
true) {
610 $(newvalue).removeClass(
"butAction");
611 $(newvalue).addClass(
"butActionRefused");
615 }
else if (
type ==
"showhide" ||
type ==
"show") {
616 $.each(data,
function(key, value) {
617 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
621 }
else if (
type ==
"set") {
622 $.each(data,
function(key, value) {
623 $(
"#set_" + key).hide();
624 $(
"#del_" + key).show();
636 var url = window.location.href;
637 if (url.indexOf(
'dol_resetcache') < 0) {
638 if (url.indexOf(
'?') > -1) {
639 url = url +
"&dol_resetcache=1";
641 url = url +
"?dol_resetcache=1";
644 var page_y = $(document).scrollTop();
645 url = url.replace(/page_y=\d+/g,
'');
647 if (url.indexOf(
'?') > -1) {
648 url = url +
"&page_y="+page_y;
650 url = url +
"?page_y="+page_y;
653 url = url.replace(/&&+/,
'&');
654 console.log(
"url ro redirect = "+url);
656 window.location.href = url;
660 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
679function delConstant(url, code, input, entity, strict, forcereload, userid, token) {
688 console.log(
"Ajax url request to delete constant is success. Make complementary actions and then forcereload="+forcereload);
689 $(
"#del_" + code).hide();
690 $(
"#set_" + code).show();
691 $.each(input,
function(
type, data) {
693 if (
type ==
"disabled") {
694 $.each(data,
function(key, value) {
695 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
696 $(newvalue).attr(
"disabled",
true);
697 if ($(newvalue).hasClass(
"butAction") ==
true) {
698 $(newvalue).removeClass(
"butAction");
699 $(newvalue).addClass(
"butActionRefused");
702 }
else if (
type ==
"enabled" && strict != 1) {
703 $.each(data,
function(key, value) {
704 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
705 $(newvalue).removeAttr(
"disabled");
706 if ($(newvalue).hasClass(
"butActionRefused") ==
true) {
707 $(newvalue).removeClass(
"butActionRefused");
708 $(newvalue).addClass(
"butAction");
712 }
else if (
type ==
"showhide" ||
type ==
"hide") {
713 $.each(data,
function(key, value) {
714 var newvalue=((value.search(
"^#") < 0 && value.search(
"^\.") < 0) ?
"#" :
"") + value;
718 }
else if (
type ==
"del") {
719 $.each(data,
function(key, value) {
720 $(
"#del_" + value).hide();
721 $(
"#set_" + value).show();
732 var url = window.location.href;
733 if (url.indexOf(
'dol_resetcache') < 0) {
734 if (url.indexOf(
'?') > -1) {
735 url = url +
"&dol_resetcache=1";
737 url = url +
"?dol_resetcache=1";
740 var page_y = $(document).scrollTop();
741 url = url.replace(/page_y=\d+/g,
'');
743 if (url.indexOf(
'?') > -1) {
744 url = url +
"&page_y="+page_y;
746 url = url +
"?page_y="+page_y;
749 url = url.replace(/&&+/,
'&');
750 console.log(
"url ro redirect = "+url);
752 window.location.href = url;
756 }).
fail(
function(error) { console.log(
"Error, we force reload"); location.reload(); });
778function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid, token) {
779 var boxConfirm = box;
780 $(
"#confirm_" + code)
781 .attr(
"title", boxConfirm.title)
782 .html(boxConfirm.content)
790 id :
'yesButton_' + code,
793 if (action ==
"set") {
794 setConstant(url, code, input, entity, strict, 0, userid, token, 1);
795 }
else if (action ==
"del") {
796 delConstant(url, code, input, entity, strict, 0, userid, token);
799 $(
this).dialog(
"close");
801 if (boxConfirm.method) {
802 var fnName = boxConfirm.method;
803 if (window.hasOwnProperty(fnName)) {
810 id :
'noButton_' + code,
813 $(
this).dialog(
"close");
819 if (boxConfirm.info) {
820 $(
"#noButton_" + code).button().hide();
836 $.widget(
"ui.combobox", {
838 minLengthToAutocomplete: 0
840 _create:
function() {
841 var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
843 select = this.element.hide(),
844 selected = select.children(
":selected" ),
845 value = selected.val() ? selected.text() :
"";
846 var input = this.input = $(
"<input>" )
847 .insertAfter( select )
849 .attr(
'id',
'inputautocomplete'+select.attr(
'id'))
852 minLength: this.options.minLengthToAutocomplete,
853 source:
function( request, response ) {
854 var matcher =
new RegExp( $.ui.autocomplete.escapeRegex(request.term),
"i" );
855 response( select.children(
"option:enabled" ).map(
function() {
856 var text = $( this ).text();
857 if ( this.value && ( !request.term || matcher.test(text) ) )
861 "(?![^&;]+;)(?!<[^<>]*)(" +
862 $.ui.autocomplete.escapeRegex(request.term) +
863 ")(?![^<>]*>)(?![^&;]+;)",
"gi"
864 ),
"<strong>$1</strong>" ),
870 select:
function( event, ui ) {
871 ui.item.option.selected =
true;
872 self._trigger(
"selected", event, {
876 change:
function( event, ui ) {
878 var matcher =
new RegExp(
"^" + $.ui.autocomplete.escapeRegex( $(
this).val() ) +
"$",
"i" ),
880 select.children(
"option" ).each(
function() {
881 if ( $(
this ).text().match( matcher ) ) {
882 this.selected = valid =
true;
890 input.data(
"ui-autocomplete").term =
"";
896 .addClass(
"ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
898 input.data(
"ui-autocomplete")._renderItem =
function( ul, item ) {
900 .data(
"ui-autocomplete-item", item )
901 .append(
"<a>" + item.label +
"</a>" )
905 this.
button = $(
"<button type=\'button\'> </button>" )
906 .attr(
"tabIndex", -1 )
907 .attr(
"title",
"Show All Items" )
908 .insertAfter( input )
911 primary:
"ui-icon-triangle-1-s"
915 .removeClass(
"ui-corner-all" )
916 .addClass(
"ui-corner-right ui-button-icon" )
919 if ( input.autocomplete(
"widget" ).is(
":visible" ) ) {
920 input.autocomplete(
"close" );
925 input.autocomplete({ minLength: 0 });
926 input.autocomplete(
"search",
"" );
927 input.autocomplete({ minLength: savMinLengthToAutocomplete });
932 destroy:
function() {
936 $.Widget.prototype.destroy.call(
this );
951 text = text.replace(/<br>/g,
"\n");
952 var newElem =
'<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+
'</textarea><br><br>'+text2;
954 $(
"#dialogforpopup").html(newElem);
955 $(
"#dialogforpopup").dialog();
956 $(
"#coordsforpopup").select();
972 var argc =
newpopup.arguments.length;
974 console.log(
"newpopup "+argv[2]+
" "+argv[3]);
975 var l = (argc > 2) ? argv[2] : 600;
976 var h = (argc > 3) ? argv[3] : 400;
977 var left = (screen.width - l)/2;
978 var top = (screen.height - h)/2;
979 var wfeatures =
"directories=0,menubar=0,status=0,resizable=0,scrollbars=1,toolbar=0,width=" + l +
",height=" + h +
",left=" + left +
",top=" + top;
980 fen=window.open(tmp,title,wfeatures);
997 var ValidImageTypes = [
"image/gif",
"image/jpeg",
"image/png",
"image/webp"];
998 var showOriginalSizeButton =
false;
1000 console.log(
"document_preview A click was done: file="+file+
", type="+
type+
", title="+title);
1002 if ($.inArray(
type, ValidImageTypes) < 0) {
1005 var object_width=
'100%';
1006 var height = ($( window ).height() - 60) * 0.90;
1007 var object_height=
'98%';
1009 show_preview(
'notimage');
1014 var object_height=0;
1016 var img =
new Image();
1018 img.onload =
function() {
1019 object_width = this.width;
1020 object_height = this.height;
1022 width = $( window ).width()*0.90;
1023 console.log(
"object_width="+object_width+
" window width="+width);
1024 if(object_width < width){
1025 console.log(
"Object width is small, we set width of popup according to image width.");
1026 width = object_width + 30
1028 height = $( window ).height()*0.85;
1029 console.log(
"object_height="+object_height+
" window height="+height);
1030 if(object_height < height){
1031 console.log(
"Object height is small, we set height of popup according to image height.");
1032 height = object_height + 80
1036 showOriginalSizeButton =
true;
1039 show_preview(
'image');
1046 function show_preview(mode) {
1048 var newElem =
'<object name="objectpreview" data="'+file+
'" type="'+
type+
'" width="'+object_width+
'" height="'+object_height+
'" param="noparam"></object>';
1051 if (mode ==
'image' && showOriginalSizeButton)
1055 "<?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" }); },
1056 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("RotateImage
")); ?>":
function() { curRot += 90; jQuery(
".ui-dialog-content.ui-widget-content > object").css(
"transform",
"rotate(" + curRot +
"deg)"); },
1057 "<?php echo dol_escape_js($langs->transnoentitiesnoconv("CloseWindow
")); ?>":
function() { $(
this ).dialog(
"close" ); }
1061 $(
"#dialogforpopup").html(newElem);
1063 $(
"#dialogforpopup").dialog({
1064 closeOnEscape:
true,
1070 buttons: optionsbuttons
1073 if (showOriginalSizeButton)
1075 jQuery(
".ui-dialog-content.ui-widget-content > object").css({
"max-height":
"100%",
"width":
"auto",
"margin-left":
"auto",
"margin-right":
"auto",
"display":
"block" });
1089 name =
name.replace(/[\[]/,
"\\[").replace(/[\]]/,
"\\]");
1090 var regex =
new RegExp(
"[\\?&]" +
name +
"=([^&#]*)"),
1091 results = regex.exec(location.search);
1092 return results ===
null ? valueifnotfound : decodeURIComponent(results[1].replace(/\+/g,
" "));
1106 function decimalAdjust(
type, value, exp) {
1108 if (typeof exp ===
'undefined' || +exp === 0) {
1109 return Math[
type](value);
1114 if (isNaN(value) || !(typeof exp ===
'number' && exp % 1 === 0)) {
1118 value = value.toString().split(
'e');
1119 value = Math[
type](+(value[0] +
'e' + (value[1] ? (+value[1] - exp) : -exp)));
1121 value = value.toString().split(
'e');
1122 return +(value[0] +
'e' + (value[1] ? (+value[1] + exp) : exp));
1126 if (!Math.round10) {
1127 Math.round10 =
function(value, exp) {
1128 return decimalAdjust(
'round', value, exp);
1132 if (!Math.floor10) {
1133 Math.floor10 =
function(value, exp) {
1134 return decimalAdjust(
'floor', value, exp);
1139 Math.ceil10 =
function(value, exp) {
1140 return decimalAdjust(
'ceil', value, exp);
1146function dolroundjs(number, decimals) {
return +(Math.round(number +
"e+" + decimals) +
"e-" + decimals); }
1165function pricejs(amount, mode =
'MT', currency_code =
'', force_locale =
'') {
1166 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1167 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1168 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1169 var main_decimal_separator = <?php echo json_encode($dec) ?>;
1170 var main_thousand_separator = <?php echo json_encode($thousand) ?>;
1171 var locale_code = force_locale || <?php echo json_encode($langs->defaultlang) ?>;
1172 var amountAsLocalizedString;
1173 var useIntl = Boolean(Intl && Intl.NumberFormat);
1175 if (currency_code ===
'auto') currency_code = <?php echo json_encode($conf->currency) ?>;
1177 if (mode ===
'MU') nDigits = main_rounding_unit;
1178 else if (mode ===
'MT') nDigits = main_rounding_tot;
1179 else return 'Bad value for parameter mode';
1184 var formattingOptions = {
1185 minimumFractionDigits: nDigits,
1186 maximumFractionDigits: nDigits
1188 if (currency_code) {
1189 formattingOptions[
'style'] =
'currency';
1190 formattingOptions[
'currency'] = currency_code;
1192 return Intl.NumberFormat(locale_code.replace(
'_',
'-'), formattingOptions).format(amount);
1196 amountAsLocalizedString = amount.toFixed(nDigits).replace(
1197 /((?!^)(?:\d{3})*)(?:\.(\d+))?$/,
1198 (fullMatch, digitsByThree, decimals) =>
1199 digitsByThree.replace(
1201 (groupOfThree) => main_thousand_separator + groupOfThree
1202 ) + (decimals !== undefined ? main_decimal_separator + decimals :
'')
1203 ).replace(/ /,
' ');
1204 if (!currency_code)
return amountAsLocalizedString;
1207 var currency_symbol = currency_code;
1210 var currencyBeforeAmountCodes = {
1211 currency: [
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD'],
1215 if (currencyCache[currency_code]
1216 && currencyCache[currency_code][
'unicode']
1217 && currencyCache[currency_code][
'unicode'].length) {
1218 currency_symbol = currencyCache[currency_code][
'unicode'].reduce(
function (res, cur) {
return res + cur},
'');
1221 if (currencyBeforeAmountCodes.currency.indexOf(currency_code) >= 0
1222 || currencyBeforeAmountCodes.language.indexOf(locale_code)) {
1224 return currency_symbol + amountAsLocalizedString;
1228 return amountAsLocalizedString +
' ' + currency_symbol;
1239 if (amount ==
'')
return '';
1241 var dec = <?php echo json_encode($dec) ?>;
1242 var thousand = <?php echo json_encode($thousand) ?>;
1244 var main_max_dec_shown = <?php echo (
int) str_replace(
'.',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN')); ?>;
1245 var main_rounding_unit = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_UNIT'); ?>;
1246 var main_rounding_tot = <?php echo (
int)
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'); ?>;
1248 var amount = amount.toString();
1251 var rounding = main_rounding_unit;
1252 var pos = amount.indexOf(dec);
1255 decpart = amount.substring(pos + 1).replace(
'/0+$/i',
'');
1257 var nbdec = decpart.length;
1258 if (nbdec > rounding) {
1262 if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
1263 if (thousand !=
',' && thousand !=
'.') amount = amount.replace(
',',
'.');
1264 amount = amount.replace(
' ',
'');
1265 amount = amount.replace(thousand,
'');
1266 amount = amount.replace(dec,
'.');
1269 var res = Math.round10(amount, - rounding);
1273 console.log(
"price2numjs text="+amount+
" return="+res);
1280if (!
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
1283$(document).ready(
function() {
1284 if (typeof $.jnotify ==
'function') {
1288 , closeLabel:
"×"
1292 , classContainer:
"jnotify-container"
1293 , classNotification:
"jnotify-notification"
1294 , classBackground:
"jnotify-background"
1295 , classClose:
"jnotify-close"
1296 , classMessage:
"jnotify-message"
1299 , beforeRemove: null
1308jQuery(document).ready(
function() {
1310 if (window.location && window.location.pathname.indexOf(
"externalsite/frametop.php") == -1 && window.location !== window.parent.location ) {
1311 console.log(
"Page is detected to be into an iframe, we hide by CSS the menus");
1313 jQuery(
".side-nav-vert, .side-nav, .websitebar").hide();
1314 jQuery(
".id-container").css(
'width',
'100%');
1319 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")) ?>');
1323jQuery(document).ready(
function() {
1324 jQuery(document).on(
"click",
".butAction.dropdown-toggle",
function(event) {
1325 console.log(
"Click on .butAction.dropdown-toggle");
1326 var parentholder = jQuery(
".butAction.dropdown-toggle").closest(
".dropdown");
1327 var offset = parentholder.offset();
1328 var widthdocument = $(document).width();
1329 var left = offset.left;
1330 var right = widthdocument - offset.left - parentholder.width();
1331 var widthpopup = parentholder.children(
".dropdown-content").width();
1332 console.log(
"left="+left+
" right="+right+
" width="+widthpopup+
" widthdocument="+widthdocument);
1333 if (widthpopup + right >= widthdocument) {
1336 parentholder.toggleClass(
"open");
1337 parentholder.children(
".dropdown-content").css({
"right": right+
"px",
"left":
"auto"});
1343if (!
getDolGlobalString(
'MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined(
'DISABLE_SELECT2_FOCUS_PROTECTION')) {
1353$(document).on(
'select2:open', (e) => {
1354 console.log(
"Execute the focus (click on combo or use space when on component");
1355 const target = $(e.target);
1356 if (target && target.length) {
1357 let
id = target[0].id || target[0].name;
1358 if (
id.substr(-2) ==
"[]")
id =
id.substr(0,
id.length-2);
1359 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 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
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.
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.