2
0
forked from Wavyzz/dolibarr

Clean code

This commit is contained in:
Laurent Destailleur
2020-10-06 15:11:45 +02:00
parent 254d9edbb9
commit 95f67309e2
7 changed files with 49 additions and 42 deletions

View File

@@ -20,7 +20,7 @@
/**
* \file htdocs/accountancy/admin/subaccount.php
* \ingroup Accountancy (Double entries)
* \brief List accounting sub-account
* \brief List of accounting sub-account (auxiliary accounts)
*/
require '../../main.inc.php';
@@ -184,7 +184,7 @@ if (strlen(trim($search_subaccount))) {
}
}
if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label);
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$search_type."'";
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
// User
$sql .= " UNION ";
@@ -226,7 +226,7 @@ if (strlen(trim($search_subaccount))) {
}
}
if (strlen(trim($search_label))) $sql .= natural_search("u.lastname", $search_label);
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$search_type."'";
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
$sql .= $db->order($sortfield, $sortorder);

View File

@@ -179,8 +179,8 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
$companystatic->code_compta = $obj->code_compta;
print '<tr class="oddeven">';
print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 16).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$propalstatic->getNomUrl(1).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
print '<td class="nowrap right">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'</td>';
print '</tr>';
@@ -243,8 +243,8 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
$companystatic->email = $obj->email;
print '<tr class="oddeven">';
print '<td class="nowrap">'.$supplierproposalstatic->getNomUrl(1).'</td>';
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'supplier', 16).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$supplierproposalstatic->getNomUrl(1).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
print '<td class="nowrap right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
print '</tr>';
@@ -308,8 +308,8 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
$companystatic->entity = $obj->entity;
print '<tr class="oddeven">';
print '<td class="nowrap">'.$orderstatic->getNomUrl(1).'</td>';
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 16).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$orderstatic->getNomUrl(1).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
print '<td class="nowrap right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
print '</tr>';
@@ -373,8 +373,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$companystatic->email = $obj->email;
print '<tr class="oddeven">';
print '<td class="nowrap">'.$supplierorderstatic->getNomUrl(1).'</td>';
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'supplier', 16).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$supplierorderstatic->getNomUrl(1).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
print '<td class="nowrap right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
print '</tr>';
@@ -441,7 +441,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
$companystatic->email = $objp->email;
print '<tr class="oddeven">';
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 48).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
print '<td class="right" nowrap>'.$companystatic->getLibCustProspStatut().'</td>';
print '<td class="right" nowrap>'.dol_print_date($db->jdate($objp->tms), 'day').'</td>';
print '</tr>';
@@ -493,7 +493,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$companystatic->email = $objp->email;
print '<tr class="oddeven">';
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'supplier', 44).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
print '<td class="right">'.dol_print_date($db->jdate($objp->dm), 'day').'</td>';
print '</tr>';

View File

@@ -213,11 +213,11 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$companystatic->code_compta = $obj->code_compta;
$companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
print '<tr class="oddeven"><td class="nowrap">';
print '<tr class="oddeven"><td class="nowrap tdoverflowmax100">';
print $facturestatic->getNomUrl(1, '');
print '</td>';
print '<td class="nowrap">';
print $companystatic->getNomUrl(1, 'customer', 16);
print '<td class="nowrap tdoverflowmax100">';
print $companystatic->getNomUrl(1, 'customer');
print '</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
print '</tr>';
@@ -305,11 +305,11 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$companystatic->code_compta = $obj->code_compta;
$companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
print '<tr class="oddeven"><td class="nowrap">';
print $facturesupplierstatic->getNomUrl(1, '', 16);
print '<tr class="oddeven"><td class="nowrap tdoverflowmax100">';
print $facturesupplierstatic->getNomUrl(1, '');
print '</td>';
print '<td>';
print $companystatic->getNomUrl(1, 'supplier', 16);
print '<td class="nowrap tdoverflowmax100">';
print $companystatic->getNomUrl(1, 'supplier');
print '</td>';
print '<td class="right">'.price($obj->total_ttc).'</td>';
print '</tr>';
@@ -550,11 +550,11 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$thirdpartystatic->code_compta = '';
$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
print '<tr class="oddeven nowraponall"><td>';
print '<tr class="oddeven nowraponall tdoverflowmax100"><td>';
print $facstatic->getNomUrl(1, '');
print '</td>';
print '<td>';
print $thirdpartystatic->getNomUrl(1, 'supplier', 44);
print '<td class="nowrap tdoverflowmax100">';
print $thirdpartystatic->getNomUrl(1, 'supplier');
print '</td>';
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
@@ -647,7 +647,7 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire)
$label = $donationstatic->getFullName($langs);
if ($objp->societe) $label .= ($label ? ' - ' : '').$objp->societe;
print '<tr class="oddeven">';
print '<tr class="oddeven tdoverflowmax100">';
print '<td>'.$donationstatic->getNomUrl(1).'</td>';
print '<td>'.$label.'</td>';
print '<td class="nowrap right">'.price($objp->amount).'</td>';
@@ -734,7 +734,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$chargestatic->paye = $obj->paye;
print '<tr class="oddeven">';
print '<td>'.$chargestatic->getNomUrl(1).'</td>';
print '<td class="nowraponall">'.$chargestatic->getNomUrl(1).'</td>';
print '<td class="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
print '<td class="nowrap right">'.price($obj->amount).'</td>';
print '<td class="nowrap right">'.price($obj->sumpaid).'</td>';
@@ -875,8 +875,8 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
print '</td>';
print '<td class="left">';
print $societestatic->getNomUrl(1, 'customer', 44);
print '<td class="nowrap tdoverflowmax100">';
print $societestatic->getNomUrl(1, 'customer');
print '</td>';
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
@@ -1022,8 +1022,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
print '</td></tr></table>';
print '</td>';
print '<td class="left">';
print $societestatic->getNomUrl(1, 'customer', 44);
print '<td class="nowrap tdoverflowmax100">';
print $societestatic->getNomUrl(1, 'customer');
print '</td>';
print '<td class="right">'.dol_print_date($db->jdate($obj->datelimite), 'day').'</td>';
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
@@ -1157,10 +1157,10 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$societestatic->code_compta = $obj->code_compta;
$societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
print '<tr class="oddeven"><td>';
print '<tr class="oddeven"><td class="nowrap tdoverflowmax100">';
print $facstatic->getNomUrl(1, '');
print '</td>';
print '<td>'.$societestatic->getNomUrl(1, 'supplier', 44).'</td>';
print '<td class="nowrap tdoverflowmax100">'.$societestatic->getNomUrl(1, 'supplier').'</td>';
print '<td class="right">'.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').'</td>';
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';

View File

@@ -107,12 +107,17 @@ abstract class DoliDB implements Database
* Sanitize a string for SQL forging
*
* @param string $stringtosanitize String to escape
* @param int $allowsimplequote Allow simple quote
* @return string String escaped
*/
public function sanitize($stringtosanitize)
public function sanitize($stringtosanitize, $allowsimplequote = 0)
{
if ($allowsimplequote) {
return preg_replace('/[^a-z0-9_\-\.,\']/i', '', $stringtosanitize);
} else {
return preg_replace('/[^a-z0-9_\-\.,]/i', '', $stringtosanitize);
}
}
/**
* Start transaction

View File

@@ -7828,7 +7828,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$listofcodes .= "'".$db->escape($val)."'";
}
}
$newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes).")";
$newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1).")";
$i2++; // a criteria was added to string
}
if ($mode == -3) $newres .= ' OR '.$field.' IS NULL';

View File

@@ -1811,8 +1811,8 @@ td.nobordernopadding.widthpictotitle.col-picto {
color: #999;
}
/*
span.widthpictotitle.pictotitle {
/* background: rgba(70, 3, 62, 0.5); */
background: var(--colortexttitlenotab);
opacity: 0.8;
color: #fff !important;
@@ -1821,10 +1821,12 @@ span.widthpictotitle.pictotitle {
min-width: 30px;
text-align: center;
}
*/
.pictotitle {
margin-<?php echo $right; ?>: 8px;
/* margin-bottom: 4px; */
}
.pictoobjectwidth {
width: 14px;
}

View File

@@ -315,14 +315,14 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO =
.infobox-action{
color: #b06080 !important;
}
.infobox-propal,
.infobox-facture,
.infobox-commande{
.infobox-propal:not(.pictotitle),
.infobox-facture:not(.pictotitle),
.infobox-commande:not(.pictotitle) {
color: #65955d !important;
}
.infobox-supplier_proposal,
.infobox-invoice_supplier,
.infobox-order_supplier{
.infobox-supplier_proposal:not(.pictotitle),
.infobox-invoice_supplier:not(.pictotitle),
.infobox-order_supplier:not(.pictotitle){
color: #599caf !important;
}
.infobox-contrat, .infobox-ticket{