Clean code
This commit is contained in:
parent
a4563c7ad4
commit
759ddd2d73
@ -188,7 +188,7 @@ if (!empty($number)) {
|
|||||||
} else {
|
} else {
|
||||||
$txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login;
|
$txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login;
|
||||||
dol_syslog($txt);
|
dol_syslog($txt);
|
||||||
print '<body onload="javascript:history.go(-1);">'."\n";
|
print '<body onload="history.go(-1);">'."\n";
|
||||||
print '<!-- '.$txt.' -->';
|
print '<!-- '.$txt.' -->';
|
||||||
fputs($oSocket, "Action: login\r\n");
|
fputs($oSocket, "Action: login\r\n");
|
||||||
fputs($oSocket, "Events: off\r\n");
|
fputs($oSocket, "Events: off\r\n");
|
||||||
|
|||||||
@ -440,7 +440,7 @@ if ($action == 'create') {
|
|||||||
print '<div class="center">';
|
print '<div class="center">';
|
||||||
print '<input type="submit" class="button button-add" value="'.$langs->trans("Add").'">';
|
print '<input type="submit" class="button button-add" value="'.$langs->trans("Add").'">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<input type="button" class="button button-cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
|
print '<input type="button" class="button button-cancel" value="'.$langs->trans("Cancel").'" onClick="history.go(-1)">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|||||||
@ -1115,7 +1115,7 @@ class Form
|
|||||||
$out .= '</select>';
|
$out .= '</select>';
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
|
if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
|
||||||
$out .= ajax_multiautocompleter('location_incoterms', '', DOL_URL_ROOT . '/core/ajax/locationincoterms.php') . "\n";
|
$out .= ajax_multiautocompleter('location_incoterms', array(), DOL_URL_ROOT . '/core/ajax/locationincoterms.php') . "\n";
|
||||||
$moreattrib .= ' autocomplete="off"';
|
$moreattrib .= ' autocomplete="off"';
|
||||||
}
|
}
|
||||||
$out .= '<input id="location_incoterms" class="maxwidthonsmartphone type="text" name="location_incoterms" value="' . $location_incoterms . '">' . "\n";
|
$out .= '<input id="location_incoterms" class="maxwidthonsmartphone type="text" name="location_incoterms" value="' . $location_incoterms . '">' . "\n";
|
||||||
|
|||||||
@ -876,7 +876,7 @@ class FormCompany extends Form
|
|||||||
* @param string $morecss More css
|
* @param string $morecss More css
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
|
public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|||||||
@ -1905,7 +1905,7 @@ class Lessc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// type based operators
|
// type based operators
|
||||||
$fname = "op_${ltype}_${rtype}";
|
$fname = "op_".$ltype."_".$rtype;
|
||||||
if (is_callable(array($this, $fname))) {
|
if (is_callable(array($this, $fname))) {
|
||||||
$out = $this->$fname($op, $left, $right);
|
$out = $this->$fname($op, $left, $right);
|
||||||
if (!is_null($out)) {
|
if (!is_null($out)) {
|
||||||
|
|||||||
@ -104,7 +104,7 @@ oConnector.CurrentFolder = '/' ;
|
|||||||
var sConnUrl = GetUrlParam( 'Connector' );
|
var sConnUrl = GetUrlParam( 'Connector' );
|
||||||
|
|
||||||
// Gecko has some problems when using relative URLs (not starting with slash).
|
// Gecko has some problems when using relative URLs (not starting with slash).
|
||||||
if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
|
if ( sConnUrl.substring(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
|
||||||
sConnUrl = window.location.href.replace( /browser.php.*$/, '' ) + sConnUrl ;
|
sConnUrl = window.location.href.replace( /browser.php.*$/, '' ) + sConnUrl ;
|
||||||
|
|
||||||
oConnector.ConnectorUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' );
|
oConnector.ConnectorUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' );
|
||||||
|
|||||||
@ -225,7 +225,7 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
$(this).find("li ul").slideToggle(200);
|
$(this).find("li ul").slideToggle(200);
|
||||||
|
|
||||||
target = $(this);
|
var target = $(this);
|
||||||
$(\'html, body\').animate({
|
$(\'html, body\').animate({
|
||||||
scrollTop: target.offset().top
|
scrollTop: target.offset().top
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2011-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
// Copyright (C) 2011-2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
// Copyright (C) 2011-2012 Regis Houssin <regis.houssin@inodbox.com>
|
// Copyright (C) 2011-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
// Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
// Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||||
//
|
//
|
||||||
@ -69,7 +69,7 @@ function DisplayDstSwitchDates(firstsecond)
|
|||||||
var lastOffset = 99;
|
var lastOffset = 99;
|
||||||
|
|
||||||
// Loop through every month of the current year
|
// Loop through every month of the current year
|
||||||
for (i = 0; i < 12; i++)
|
for (let i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
// Fetch the timezone value for the month
|
// Fetch the timezone value for the month
|
||||||
var newDate = new Date(Date.UTC(year, i, 0, 0, 0, 0, 0));
|
var newDate = new Date(Date.UTC(year, i, 0, 0, 0, 0, 0));
|
||||||
@ -109,7 +109,7 @@ function FindDstSwitchDate(year, month)
|
|||||||
var dstDate;
|
var dstDate;
|
||||||
|
|
||||||
// Loop to find the exact day a timezone adjust occurs
|
// Loop to find the exact day a timezone adjust occurs
|
||||||
for (day = 0; day < 50; day++)
|
for (let day = 0; day < 50; day++)
|
||||||
{
|
{
|
||||||
var tmpDate = new Date(Date.UTC(year, month, day, 0, 0, 0, 0));
|
var tmpDate = new Date(Date.UTC(year, month, day, 0, 0, 0, 0));
|
||||||
var tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
|
var tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
|
||||||
|
|||||||
@ -1227,7 +1227,7 @@ function pricejs(amount, mode = 'MT', currency_code = '', force_locale = '') {
|
|||||||
* Function similar to PHP price2num()
|
* Function similar to PHP price2num()
|
||||||
*
|
*
|
||||||
* @param {number|string} amount The amount to convert/clean
|
* @param {number|string} amount The amount to convert/clean
|
||||||
* @return {string} The amount in universal numeric format (Example: '99.99999')
|
* @return {number} The amount in universal numeric format (Example: '99.99999')
|
||||||
* @todo Implement rounding parameter
|
* @todo Implement rounding parameter
|
||||||
*/
|
*/
|
||||||
function price2numjs(amount) {
|
function price2numjs(amount) {
|
||||||
@ -1246,20 +1246,27 @@ function price2numjs(amount) {
|
|||||||
var rounding = main_rounding_unit;
|
var rounding = main_rounding_unit;
|
||||||
var pos = amount.indexOf(dec);
|
var pos = amount.indexOf(dec);
|
||||||
var decpart = '';
|
var decpart = '';
|
||||||
if (pos >= 0) decpart = amount.substr(pos + 1).replace('/0+$/i', ''); // Remove 0 for decimal part
|
if (pos >= 0) {
|
||||||
|
decpart = amount.substring(pos + 1).replace('/0+$/i', ''); // Remove 0 for decimal part
|
||||||
|
}
|
||||||
var nbdec = decpart.length;
|
var nbdec = decpart.length;
|
||||||
if (nbdec > rounding) rounding = nbdec;
|
if (nbdec > rounding) {
|
||||||
|
rounding = nbdec;
|
||||||
|
}
|
||||||
// If rounding higher than max shown
|
// If rounding higher than max shown
|
||||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||||
if (thousand != ',' && thousand != '.') amount = amount.replace(',', '.');
|
if (thousand != ',' && thousand != '.') amount = amount.replace(',', '.');
|
||||||
amount = amount.replace(' ', ''); // To avoid spaces
|
amount = amount.replace(' ', ''); // To avoid spaces
|
||||||
amount = amount.replace(thousand, ''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
amount = amount.replace(thousand, ''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||||
amount = amount.replace(dec, '.');
|
amount = amount.replace(dec, '.');
|
||||||
|
|
||||||
//console.log("amount before="+amount+" rouding="+rounding)
|
//console.log("amount before="+amount+" rouding="+rounding)
|
||||||
var res = Math.round10(amount, - rounding);
|
var res = Math.round10(amount, - rounding);
|
||||||
// Other solution is
|
// Other solution is
|
||||||
// var res = dolroundjs(amount, rounding)
|
// var res = dolroundjs(amount, rounding)
|
||||||
|
|
||||||
console.log("price2numjs text="+amount+" return="+res);
|
console.log("price2numjs text="+amount+" return="+res);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@ function regexEvent(objet,evt,type)
|
|||||||
case 'timeChar':
|
case 'timeChar':
|
||||||
//var regex= /^[0-9:]{1}$/;
|
//var regex= /^[0-9:]{1}$/;
|
||||||
//alert(event.charCode);
|
//alert(event.charCode);
|
||||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
||||||
|
|
||||||
if(((charCode >= 48) && (charCode <= 57)) || //num
|
if(((charCode >= 48) && (charCode <= 57)) || //num
|
||||||
(charCode===46) || (charCode===8)||// comma & periode
|
(charCode===46) || (charCode===8)||// comma & periode
|
||||||
|
|||||||
@ -305,7 +305,7 @@ function barcode_encode_upc($upc, $encoding = "UPC")
|
|||||||
if ($a > 1) {
|
if ($a > 1) {
|
||||||
$text .= " ";
|
$text .= " ";
|
||||||
}
|
}
|
||||||
$text .= "$pos:12:{$upc[$a]}";
|
$text .= $pos.":12:".$upc[$a];
|
||||||
if ($a == 1) {
|
if ($a == 1) {
|
||||||
$pos += 15;
|
$pos += 15;
|
||||||
} elseif ($a == 6) {
|
} elseif ($a == 6) {
|
||||||
|
|||||||
@ -1866,8 +1866,8 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di
|
|||||||
console.log("open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
|
console.log("open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
|
||||||
},
|
},
|
||||||
close: function (event, ui) {
|
close: function (event, ui) {
|
||||||
returnedid = jQuery("#varforreturndialogid'.$name.'").text();
|
var returnedid = jQuery("#varforreturndialogid'.$name.'").text();
|
||||||
returnedlabel = jQuery("#varforreturndialoglabel'.$name.'").text();
|
var returnedlabel = jQuery("#varforreturndialoglabel'.$name.'").text();
|
||||||
console.log("popup has been closed. returnedid (js var defined into parent page)="+returnedid+" returnedlabel="+returnedlabel);
|
console.log("popup has been closed. returnedid (js var defined into parent page)="+returnedid+" returnedlabel="+returnedlabel);
|
||||||
if (returnedid != "" && returnedid != "div for returned id") {
|
if (returnedid != "" && returnedid != "div for returned id") {
|
||||||
jQuery("#'.(empty($backtopagejsfieldsid)?"none":$backtopagejsfieldsid).'").val(returnedid);
|
jQuery("#'.(empty($backtopagejsfieldsid)?"none":$backtopagejsfieldsid).'").val(returnedid);
|
||||||
|
|||||||
@ -455,9 +455,10 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
var price = 0;
|
var price = 0;
|
||||||
remisejs = price2numjs(remise.val());
|
remisejs = price2numjs(remise.val());
|
||||||
|
|
||||||
if (remisejs != 100) // If a discount not 100 or no discount
|
if (remisejs != 100) { // If a discount not 100 or no discount
|
||||||
{
|
if (remisejs == '') {
|
||||||
if (remisejs == '') remisejs=0;
|
remisejs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
bpjs=price2numjs(buying_price.val());
|
bpjs=price2numjs(buying_price.val());
|
||||||
ratejs=price2numjs(rate.val());
|
ratejs=price2numjs(rate.val());
|
||||||
|
|||||||
@ -86,8 +86,8 @@ print dol_get_fiche_head($head, 'compare', '', 1);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$userl = $(this).closest('ul');
|
var $userl = $(this).closest('ul');
|
||||||
listname = $userl.attr('name');
|
var listname = $userl.attr('name');
|
||||||
|
|
||||||
var TId = [];
|
var TId = [];
|
||||||
|
|
||||||
|
|||||||
@ -630,7 +630,7 @@ function jscheckparam()
|
|||||||
{
|
{
|
||||||
console.log("Click on jscheckparam");
|
console.log("Click on jscheckparam");
|
||||||
|
|
||||||
ok=true;
|
var ok = true;
|
||||||
|
|
||||||
if (document.forminstall.main_dir.value == '')
|
if (document.forminstall.main_dir.value == '')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2837,18 +2837,18 @@ function top_menu_bookmark()
|
|||||||
|
|
||||||
jQuery("#topmenu-bookmark-dropdown .dropdown-toggle").on("click", function(event) {
|
jQuery("#topmenu-bookmark-dropdown .dropdown-toggle").on("click", function(event) {
|
||||||
console.log("Click on #topmenu-bookmark-dropdown .dropdown-toggle");
|
console.log("Click on #topmenu-bookmark-dropdown .dropdown-toggle");
|
||||||
openBookMarkDropDown();
|
openBookMarkDropDown(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Key map shortcut
|
// Key map shortcut
|
||||||
jQuery(document).keydown(function(e){
|
jQuery(document).keydown(function(event){
|
||||||
if( e.which === 77 && e.ctrlKey && e.shiftKey ){
|
if( event.which === 77 && event.ctrlKey && event.shiftKey ){
|
||||||
console.log(\'control + shift + m : trigger open bookmark dropdown\');
|
console.log("Click on control + shift + m : trigger open bookmark dropdown");
|
||||||
openBookMarkDropDown();
|
openBookMarkDropDown(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var openBookMarkDropDown = function() {
|
var openBookMarkDropDown = function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
jQuery("#topmenu-bookmark-dropdown").toggleClass("open");
|
jQuery("#topmenu-bookmark-dropdown").toggleClass("open");
|
||||||
jQuery("#top-bookmark-search-input").focus();
|
jQuery("#top-bookmark-search-input").focus();
|
||||||
|
|||||||
@ -249,6 +249,8 @@ function AddProductConfirm(placeid, productid){
|
|||||||
});';
|
});';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetQty(place, selectedline, qty){
|
function SetQty(place, selectedline, qty){
|
||||||
@ -278,6 +280,8 @@ function SetQty(place, selectedline, qty){
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
LoadCats();
|
LoadCats();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetNote(place, selectedline){
|
function SetNote(place, selectedline){
|
||||||
|
|||||||
@ -212,19 +212,19 @@ if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->glob
|
|||||||
<div style="position:absolute; top:33%; left:5%; height:52%; width:92%;">
|
<div style="position:absolute; top:33%; left:5%; height:52%; width:92%;">
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(7);">7</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'7\');">7</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(8);">8</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'8\');">8</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(9);">9</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'9\');">9</button>';
|
||||||
print '<button type="button" class="calcbutton2" id="reduction_type_percent" onclick="Edit(\'p\');">'.$htmlReductionPercent.'</button>';
|
print '<button type="button" class="calcbutton2" id="reduction_type_percent" onclick="Edit(\'p\');">'.$htmlReductionPercent.'</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(4);">4</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'4\');">4</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(5);">5</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'5\');">5</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(6);">6</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'6\');">6</button>';
|
||||||
print '<button type="button" class="calcbutton2" id="reduction_type_amount" onclick="Edit(\'a\');">'.$htmlReductionAmount.'</button>';
|
print '<button type="button" class="calcbutton2" id="reduction_type_amount" onclick="Edit(\'a\');">'.$htmlReductionAmount.'</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(1);">1</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'1\');">1</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(2);">2</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'2\');">2</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(3);">3</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'3\');">3</button>';
|
||||||
print '<button type="button" class="calcbutton3 poscolorblue" onclick="Reset();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">C</span></button>';
|
print '<button type="button" class="calcbutton3 poscolorblue" onclick="Reset();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">C</span></button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(0);">0</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'0\');">0</button>';
|
||||||
print '<button type="button" class="calcbutton" onclick="AddReduction(\'.\');">.</button>';
|
print '<button type="button" class="calcbutton" onclick="AddReduction(\'.\');">.</button>';
|
||||||
print '<button type="button" class="calcbutton"> </button>';
|
print '<button type="button" class="calcbutton"> </button>';
|
||||||
print '<button type="button" class="calcbutton3 poscolordelete" onclick="parent.$.colorbox.close();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">X</span></button>';
|
print '<button type="button" class="calcbutton3 poscolordelete" onclick="parent.$.colorbox.close();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">X</span></button>';
|
||||||
|
|||||||
@ -111,4 +111,7 @@ exclude:
|
|||||||
- name: JSUnnecessarySemicolon
|
- name: JSUnnecessarySemicolon
|
||||||
- name: JSPrimitiveTypeWrapperUsage
|
- name: JSPrimitiveTypeWrapperUsage
|
||||||
- name: PhpFullyQualifiedNameUsageInspection
|
- name: PhpFullyQualifiedNameUsageInspection
|
||||||
|
- name: PhpDocMissingThrowsInspection
|
||||||
|
- name: UnnecessaryLabelJS
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user