Clean code

This commit is contained in:
Laurent Destailleur
2023-05-01 14:33:08 +02:00
parent fe816445f5
commit e2ec34e1e5
31 changed files with 93 additions and 62 deletions

View File

@@ -184,7 +184,7 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) {
if ($range->range_active == 1) {
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) {
echo '<input id="" class="button button-save" name="save" value="'.$langs->trans("Save").'" type="submit" />';
echo '<input class="button button-cancel" value="'.$langs->trans("Cancel").'" onclick="javascript:history.go(-1)" type="button" />';
echo '<input class="button button-cancel" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" type="button" />';
} else {
echo '<a class="editfielda marginrightonly paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$range->ik->id.'&fk_c_exp_tax_cat='.$range->fk_c_exp_tax_cat.'&fk_range='.$range->rowid.'">'.img_edit().'</a>';
if (!empty($range->ik->id)) {

View File

@@ -174,7 +174,7 @@ class AssetAccountancyCodes extends CommonObject
public function updateAccountancyCodes($user, $asset_id = 0, $asset_model_id = 0, $notrigger = 0)
{
global $langs, $hookmanager;
dol_syslog(__METHOD__ . " user_id={$user->id}, asset_id=$asset_id, asset_model_id=$asset_model_id, notrigger=$notrigger");
dol_syslog(__METHOD__ . " user_id=".$user->id.", asset_id=".$asset_id.", asset_model_id=".$asset_model_id.", notrigger=".$notrigger);
$error = 0;
$this->errors = array();

View File

@@ -418,7 +418,7 @@ class AssetDepreciationOptions extends CommonObject
public function updateDeprecationOptions($user, $asset_id = 0, $asset_model_id = 0, $notrigger = 0)
{
global $langs, $hookmanager;
dol_syslog(__METHOD__ . " user_id={$user->id}, asset_id=$asset_id, asset_model_id=$asset_model_id, notrigger=$notrigger");
dol_syslog(__METHOD__ . " user_id=".$user->id.", asset_id=".$asset_id.", asset_model_id=".$asset_model_id.", notrigger=".$notrigger);
$error = 0;
$this->errors = array();

View File

@@ -248,7 +248,7 @@ class EvalMath
$matches = array();
if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good
return $this->trigger(4, "illegal character '{$matches[0]}'", $matches[0]);
return $this->trigger(4, "illegal character '".$matches[0]."'", $matches[0]);
}
while (1) { // 1 Infinite Loop ;)

View File

@@ -9181,7 +9181,7 @@ class Form
if (empty($conf->use_javascript_ajax)) {
print '<input type="submit" class="button button-cancel marginleftonly marginrightonly" name="cancel" value="' . $langs->trans("Cancel") . '"></div>';
} else {
print '<input type="submit"; onclick="javascript:jQuery(\'#' . $key . 'list\').toggle(); return false;" class="button button-cancel marginleftonly marginrightonly" name="cancel" value="' . $langs->trans("Cancel") . '"></div>';
print '<input type="submit" onclick="jQuery(\'#' . $key . 'list\').toggle(); return false;" class="button button-cancel marginleftonly marginrightonly" name="cancel" value="' . $langs->trans("Cancel") . '"></div>';
}
print '</form>';
$this->db->free($resqllist);

View File

@@ -873,7 +873,7 @@ class Lessc
break;
default:
$this->throwError("unknown op: {$prop[0]}\n");
$this->throwError("unknown op: $prop[0]\n");
}
}

View File

@@ -1049,7 +1049,7 @@ class Translate
if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode'])) {
foreach ($this->cache_currencies[$currency_code]['unicode'] as $unicode) {
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
$currency_sign .= mb_convert_encoding("&#".$unicode.";", "UTF-8", 'HTML-ENTITIES');
}
}
}

View File

@@ -527,7 +527,7 @@ function ServerMapFolder($resourceType, $folderPath, $sCommand)
// Ensure that the directory exists.
$sErrorMsg = CreateServerFolder($sResourceTypePath);
if ($sErrorMsg != '') {
SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
SendError(1, "Error creating folder \"$sResourceTypePath\" ($sErrorMsg)");
}
// Return the resource type directory combined with the required path.

View File

@@ -565,6 +565,7 @@ function hideMessage(fieldId,message) {
* @param int userid User id
* @param int value Value to set
* @param string token Token
* @retun boolean
*/
function setConstant(url, code, input, entity, strict, forcereload, userid, token, value) {
var saved_url = url; /* avoid undefined url */
@@ -654,20 +655,23 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
return false;
}
}).fail(function(error) { console.log("Error, we force reload"); location.reload(); }); /* When it fails, we always force reload to have setEventErrorMessages in session visible */
return true;
}
/*
* Used by button to set on/off
* Call url then make complementary action (like show/hide, enable/disable or set another option).
*
* @param string url Url (warning: as any url called in ajax mode, the url called here must not renew the token)
* @param string code Code
* @param string intput Array of complementary actions to do if success
* @param int entity Entity
* @param int strict Strict
* @param int forcereload Force reload
* @param int userid User id
* @param string token Token
* @param {string} url Url (warning: as any url called in ajax mode, the url called here must not renew the token)
* @param {string} code Code
* @param {string} intput Array of complementary actions to do if success
* @param {int} entity Entity
* @param {int} strict Strict
* @param {int} forcereload Force reload
* @param {int} userid User id
* @param {string} token Token
* @return boolean
*/
function delConstant(url, code, input, entity, strict, forcereload, userid, token) {
var saved_url = url; /* avoid undefined url */
@@ -747,6 +751,8 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke
return false;
}
}).fail(function(error) { console.log("Error, we force reload"); location.reload(); }); /* When it fails, we always force reload to have setEventErrorMessages in session visible */
return true;
}
/*
@@ -764,6 +770,7 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke
* @param int strict Strict
* @param int userid User id
* @param string token Token
* @return boolean
*/
function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid, token) {
var boxConfirm = box;
@@ -809,6 +816,8 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
if (boxConfirm.info) {
$("#noButton_" + code).button().hide();
}
return true;
}
@@ -931,8 +940,8 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
/**
* Function to output a dialog box for copy/paste
*
* @param string text Text to put into copy/paste area
* @param string text2 Text to put under the copy/paste area
* @param text Text to put into copy/paste area
* @param text2 Text to put under the copy/paste area
*/
function copyToClipboard(text,text2)
{
@@ -942,6 +951,7 @@ function copyToClipboard(text,text2)
$("#dialogforpopup").html(newElem);
$("#dialogforpopup").dialog();
$("#coordsforpopup").select();
return false;
}
@@ -949,8 +959,8 @@ function copyToClipboard(text,text2)
/**
* Show a popup HTML page. Use the "window.open" function.
*
* @param string url Url
* @param string title Title of popup
* @param url Url
* @param title Title of popup
* @return boolean False
* @see document_preview
*/
@@ -965,6 +975,7 @@ function newpopup(url, title) {
var top = (screen.height - h)/2;
var wfeatures = "directories=0,menubar=0,status=0,resizable=0,scrollbars=1,toolbar=0,width=" + l +",height=" + h + ",left=" + left + ",top=" + top;
fen=window.open(tmp,title,wfeatures);
return false;
}
@@ -972,9 +983,9 @@ function newpopup(url, title) {
* Function show document preview. It uses the "dialog" function.
* The a tag around the img must have the src='', class='documentpreview', mime='image/xxx', target='_blank' from getAdvancedPreviewUrl().
*
* @param string file Url
* @param string type Mime file type ("image/jpeg", "application/pdf", "text/html")
* @param string title Title of popup
* @param file Url
* @param type Mime file type ("image/jpeg", "application/pdf", "text/html")
* @param title Title of popup
* @return void
* @see newpopup
*/
@@ -1064,8 +1075,8 @@ function document_preview(file, type, title)
/*
* Provide a function to get an URL GET parameter in javascript
*
* @param string name Name of parameter
* @param mixed valueifnotfound Value if not found
* @param name Name of parameter
* @param valueifnotfound Value if not found
* @return string Value
*/
function getParameterByName(name, valueifnotfound)

View File

@@ -257,7 +257,7 @@ function barcode_encode_ean($ean, $encoding = "EAN-13")
if ($a > 0) {
$text .= " ";
}
$text .= "$pos:12:{$ean[$a]}";
$text .= $pos.":12:".$ean[$a];
if ($a == 0) {
$pos += 12;
} elseif ($a == 6) {

View File

@@ -1837,7 +1837,7 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di
if (empty($conf->use_javascript_ajax)) {
$out .= ' href="'.DOL_URL_ROOT.$url.'" target="_blank"';
} elseif ($jsonopen) {
$out .= ' href="#" onclick="javascript:'.$jsonopen.'"';
$out .= ' href="#" onclick="'.$jsonopen.'"';
} else {
$out .= ' href="#"';
}
@@ -5452,7 +5452,7 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict
* Print a title with navigation controls for pagination
*
* @param string $titre Title to show (required)
* @param int $page Numero of page to show in navigation links (required)
* @param int|null $page Numero of page to show in navigation links (required)
* @param string $file Url of page (required)
* @param string $options More parameters for links ('' by default, does not include sortfield neither sortorder). Value must be 'urlencoded' before calling function.
* @param string $sortfield Field to sort on ('' by default)
@@ -5479,6 +5479,8 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
$savtotalnboflines = $totalnboflines;
$totalnboflines = abs((int) $totalnboflines);
$page = (int) $page;
if ($picto == 'setup') {
$picto = 'title_setup.png';
}
@@ -5529,7 +5531,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
}
// Show navigation bar
$pagelist = '';
if ($savlimit != 0 && ((int) $page > 0 || $num > $limit)) {
if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
if ($totalnboflines) { // If we know total nb of lines
// Define nb of extra page links before and after selected page + ... + first or last
$maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
@@ -5590,7 +5592,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
}
if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
print_fleche_navigation((int) $page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation); // output the div and ul for previous/last completed with page numbers into $pagelist
print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation); // output the div and ul for previous/last completed with page numbers into $pagelist
}
// js to autoselect page field on focus

View File

@@ -2335,7 +2335,7 @@ class ExpenseReport extends CommonObject
// phpcs:enable
$sql = "SELECT rowid, date_debut, date_fin";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE fk_user_author = '{$fuser->id}'";
$sql .= " WHERE fk_user_author = ".((int) $fuser->id);
dol_syslog(get_class($this)."::periode_existe sql=".$sql);
$result = $this->db->query($sql);

View File

@@ -210,7 +210,7 @@ if ($action == 'create') {
print '<div class="center">';
print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
print '&nbsp; ';
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '</div>';
print '</form>';

View File

@@ -279,7 +279,7 @@ if ($action == 'create') {
print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
print '&nbsp; ';
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '</div>';
print '</form>';

View File

@@ -225,7 +225,7 @@ if ($action == 'create') {
print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
print '&nbsp; ';
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '</div>';
print '</form>';

View File

@@ -2864,11 +2864,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') {
dol_include_once($fullpathdirtodescriptor);
$class = 'mod'.$module;
} catch (Throwable $e) { // This is called in PHP 7 only (includes Error and Exception). Never called with PHP 5.6-.
$loadclasserrormessage = $e->getMessage()."<br>\n";
$loadclasserrormessage .= 'File: '.$e->getFile()."<br>\n";
$loadclasserrormessage .= 'Line: '.$e->getLine()."<br>\n";
} catch (Exception $e) { // This is called in PHP 5.6- because not already trapped by previous case in PHP 5.6-.
} catch (Throwable $e) { // This is called in PHP 7 only (includes Error and Exception)
$loadclasserrormessage = $e->getMessage()."<br>\n";
$loadclasserrormessage .= 'File: '.$e->getFile()."<br>\n";
$loadclasserrormessage .= 'Line: '.$e->getLine()."<br>\n";

View File

@@ -537,8 +537,8 @@ if ($id > 0 || $ref) {
rate_options = $.parseHTML(data.value)
rate_options.forEach(opt => {
if (opt.selected) {
replaceVATWithSupplierValue(opt.value)
return
replaceVATWithSupplierValue(opt.value);
return;
}
})
}

View File

@@ -426,7 +426,7 @@ if ($action == 'create') {
print '<div class="center">';
print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
print '&nbsp; ';
print '<input type="'.($backtopage ? "submit" : "button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
print '<input type="'.($backtopage ? "submit" : "button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
print '</div>';
print '</form>';

View File

@@ -1449,8 +1449,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
else
{
console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent);
if ((parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent)));
{
if ((parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))) {
if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+price2numjs(oldpercent)+\' %\');
jQuery("#opp_percent").val(price2numjs(defaultpercent));
}

View File

@@ -98,7 +98,7 @@ dol_syslog("Callback url when a payment was done. query_string=".(dol_escape_htm
$tracepost = "";
foreach ($_POST as $k => $v) {
$tracepost .= "{$k} - {$v}\n";
$tracepost .= "$k - $v\n";
}
dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment');

View File

@@ -132,7 +132,7 @@ dol_syslog("Callback url when an online payment is refused or canceled. query_st
$tracepost = "";
foreach ($_POST as $k => $v) {
if (is_scalar($k) && is_scalar($v)) {
$tracepost .= "{$k} - {$v}\n";
$tracepost .= "$k - $v\n";
}
}
dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment');

View File

@@ -177,14 +177,14 @@ dol_syslog("_SERVER[SERVER_ADDR] = ".(empty($_SERVER["SERVER_ADDR"]) ? '' : dol_
$tracepost = "";
foreach ($_POST as $k => $v) {
if (is_scalar($k) && is_scalar($v)) {
$tracepost .= "{$k} - {$v}\n";
$tracepost .= "$k - $v\n";
}
}
dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment');
$tracesession = "";
foreach ($_SESSION as $k => $v) {
if (is_scalar($k) && is_scalar($v)) {
$tracesession .= "{$k} - {$v}\n";
$tracesession .= "$k - $v\n";
}
}
dol_syslog("SESSION=".$tracesession, LOG_DEBUG, 0, '_payment');

View File

@@ -133,7 +133,7 @@ class ActionsCardCompany extends ActionsCardCommon
$s .= ' ';
if ($conf->use_javascript_ajax) {
$s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$s .= '<a href="#" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else {
$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL", $this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
@@ -161,7 +161,7 @@ class ActionsCardCompany extends ActionsCardCommon
$s .= ' &nbsp; ';
if ($conf->use_javascript_ajax) {
$s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$s .= '<a href="#" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else {
$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL", $this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';

View File

@@ -1722,7 +1722,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "}\n";
print '</script>';
print "\n";
$s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else {
$s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
@@ -2494,7 +2494,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "}\n";
print '</script>';
print "\n";
$s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else {
$s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
@@ -2962,7 +2962,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "}\n";
print '</script>';
print "\n";
$s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans("VATIntraCheck").'</a>';
$s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans("VATIntraCheck").'</a>';
$s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else {
$s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';

View File

@@ -149,7 +149,7 @@ if (!$vatNumber) {
print '<br>';
print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $langs->transnoentitiesnoconv("VATIntraCheckURL")).'<br>';
print '<br>';
print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="javascript: window.close()"></div>';
print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="window.close()"></div>';
if ($messagetoshow) {
print '<br><br>';

View File

@@ -92,6 +92,7 @@ if ($conf->browser->layout == 'phone') {
}
$MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
$MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
$MAXCATEG = 5;
/*
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
@@ -260,8 +261,11 @@ function MoreCategories(moreorless) {
pagecategories=pagecategories-1;
return;
}
for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) == "undefined") {
// complete with empty record
console.log("complete with empty record");
$("#catdivdesc"+i).hide();
$("#catdesc"+i).text("");
$("#catimg"+i).attr("src","genimg/empty.png");
@@ -589,8 +593,8 @@ function New() {
/**
* Search products
*
* @param string keyCodeForEnter Key code for "enter" or '' if not
* @param int moreorless ??
* @param keyCodeForEnter Key code for "enter" or '' if not
* @param moreorless "more" or "less"
* return void
*/
function Search2(keyCodeForEnter, moreorless) {
@@ -875,6 +879,8 @@ function MoreActions(totalactions){
else $("#action"+i).hide();
}
}
return true;
}
function ControlCashOpening()

View File

@@ -1074,16 +1074,19 @@ function SendTicket(id)
{
console.log("Open box to select the Print/Send form");
$.colorbox({href:"send.php?facid="+id, width:"70%", height:"30%", transition:"none", iframe:"true", title:'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
return true;
}
function PrintBox(id, action) {
console.log("Open box before printing");
$.colorbox({href:"printbox.php?facid="+id+"&action="+action+"&token=<?php echo newToken(); ?>", width:"80%", height:"200px", transition:"none", iframe:"true", title:"<?php echo $langs->trans("PrintWithoutDetails"); ?>"});
return true;
}
function Print(id, gift){
console.log("Call Print() to generate the receipt.");
$.colorbox({href:"receipt.php?facid="+id+"&gift="+gift, width:"40%", height:"90%", transition:"none", iframe:"true", title:'<?php echo dol_escape_js($langs->trans("PrintTicket")); ?>'});
return true;
}
function TakeposPrinting(id){
@@ -1097,6 +1100,7 @@ function TakeposPrinting(id){
data: receipt
});
});
return true;
}
function TakeposConnector(id){
@@ -1108,6 +1112,7 @@ function TakeposConnector(id){
data: 'invoice='+data
});
});
return true;
}
function DolibarrTakeposPrinting(id) {
@@ -1117,15 +1122,17 @@ function DolibarrTakeposPrinting(id) {
data: { token: '<?php echo currentToken(); ?>' },
url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '').'&id='; ?>" + id,
});
return true;
}
function CreditNote() {
$("#poslines").load("invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid, function() {
});
$("#poslines").load("invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid, function() { });
return true;
}
function SetNote() {
$("#poslines").load("invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+"&idline="+selectedline, { "addnote": $("#textinput").val() });
return true;
}

View File

@@ -297,6 +297,8 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) {
$('.change2').addClass('colorwhite');
}
}
return true;
}
function reset()
@@ -332,6 +334,8 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) {
location.reload();
}
});
return true;
}
function fetchPaymentIntentClientSecret(amount, invoiceid) {

View File

@@ -186,7 +186,7 @@ if ($action == 'create') {
print '<div class="center">';
print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
print '&nbsp; ';
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '</div>';
print '</form>';

View File

@@ -607,7 +607,7 @@ class ProductAttribute extends CommonObject
public function addLine($ref, $value, $position = -1, $notrigger = 0)
{
global $langs, $user;
dol_syslog(__METHOD__ . " id={$this->id}, ref=$ref, value=$value, notrigger=$notrigger");
dol_syslog(__METHOD__ . " id=".$this->id.", ref=".$ref.", value=".$value.", notrigger=".$notrigger);
$error = 0;
// Clean parameters

View File

@@ -106,3 +106,9 @@ exclude:
- name: JSJQueryEfficiency
- name: JSDuplicatedDeclaration
- name: JSUnresolvedLibraryURL
- name: UnnecessaryReturnJS
- name: UnreachableCodeJS
- name: JSUnnecessarySemicolon
- name: JSPrimitiveTypeWrapperUsage
- name: PhpFullyQualifiedNameUsageInspection