Fix scrutinizer bugs

This commit is contained in:
Laurent Destailleur 2018-05-16 15:23:52 +02:00
parent ad32b3098a
commit ef395fc36b
16 changed files with 69 additions and 63 deletions

View File

@ -214,7 +214,7 @@ class Asset extends CommonObject
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
//if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
return $result;
}

View File

@ -895,6 +895,7 @@ class Categorie extends CommonObject
$sql.= $this->db->order($sortfield, $sortorder);
$offset = 0;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{

View File

@ -3081,21 +3081,23 @@ class Propal extends CommonObject
*/
function LibStatut($statut,$mode=1)
{
global $conf;
// Init/load array of translation of status
if (empty($this->labelstatut) || empty($this->labelstatut_short))
{
global $langs;
$langs->load("propal");
$this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft"));
$this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated"));
$this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned"));
$this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned"));
$this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled"));
$this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort"));
$this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened"));
$this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort"));
$this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort"));
$this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort"));
$this->labelstatut[0]=$langs->trans("PropalStatusDraft");
$this->labelstatut[1]=$langs->trans("PropalStatusValidated");
$this->labelstatut[2]=$langs->trans("PropalStatusSigned");
$this->labelstatut[3]=$langs->trans("PropalStatusNotSigned");
$this->labelstatut[4]=$langs->trans("PropalStatusBilled");
$this->labelstatut_short[0]=$langs->trans("PropalStatusDraftShort");
$this->labelstatut_short[1]=$langs->trans("Opened");
$this->labelstatut_short[2]=$langs->trans("PropalStatusSignedShort");
$this->labelstatut_short[3]=$langs->trans("PropalStatusNotSignedShort");
$this->labelstatut_short[4]=$langs->trans("PropalStatusBilledShort");
}
$statuttrans='';

View File

@ -1074,7 +1074,7 @@ class Invoices extends DolibarrApi
* Warning: Take care that all invoices are owned by the same customer.
* Example of value for parameter arrayofamounts: {"1": "99.99", "2": "10"}
*
* @param string $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice
* @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice
* @param string $datepaye {@from body} Payment date {@type timestamp}
* @param int $paiementid {@from body} Payment mode Id {@min 1}
* @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no}

View File

@ -979,6 +979,8 @@ class FactureRec extends CommonInvoice
{
global $conf, $langs, $db, $user;
$error=0;
$langs->load("bills");
$nb_create=0;
@ -1010,11 +1012,13 @@ class FactureRec extends CommonInvoice
while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass.
{
$line = $db->fetch_object($resql);
$line = $db->fetch_object($resql);
$db->begin();
$facturerec = new FactureRec($db);
$invoiceidgenerated = 0;
$facturerec = new FactureRec($db);
$facturerec->fetch($line->rowid);
if ($facturerec->id > 0)
@ -1024,8 +1028,6 @@ class FactureRec extends CommonInvoice
dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity);
$error=0;
$facture = new Facture($db);
$facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice
$facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice

View File

@ -164,7 +164,7 @@ if($calc ==0 || $calc == 2)
print "<td align=\"right\">".$vatcust."</td>";
print "</tr>\n";
$coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell');
$coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end, $modetax, 'sell');
$action = "tvaclient";
$object = &$coll_list;
@ -248,7 +248,7 @@ if($calc ==0 || $calc == 1){
$company_static=new Societe($db);
$coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
$coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end,$modetax, 'buy');
$parameters["direction"] = 'buy';
$parameters["type"] = 'localtax'.$local;

View File

@ -107,8 +107,12 @@ function pt ($db, $sql, $date)
$amountpaid = 0;
$previousmonth = '';
$previousmode = '';
$mode = '';
while ($i < $num) {
$obj = $db->fetch_object($result);
$mode = $obj->mode;
//print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
if ($obj->mode == 'claimed' && ! empty($previousmode))
{
@ -154,7 +158,7 @@ function pt ($db, $sql, $date)
$i++;
}
if ($obj->mode == 'claimed' && ! empty($previousmode))
if ($mode == 'claimed' && ! empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
@ -173,6 +177,7 @@ function pt ($db, $sql, $date)
print "</tr>";
print "</table>";
$db->free($result);
}
else {

View File

@ -38,6 +38,7 @@ function dol_encode($chain, $key='1')
{
if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char
{
$output_tab=array();
$strlength=dol_strlen($chain);
for ($i=0; $i < $strlength; $i++)
{
@ -75,6 +76,7 @@ function dol_decode($chain, $key='1')
if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char
{
$output_tab=array();
$strlength=dol_strlen($chain);
for ($i=0; $i < $strlength;$i++)
{

View File

@ -580,7 +580,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$paymentfacturetable='paiement_facture';
$invoicefieldref='facnumber';
}
if ($direction == 'buy')
else
{
$invoicetable='facture_fourn';
$invoicedettable='facture_fourn_det';

View File

@ -482,7 +482,7 @@ class printing_printgcp extends PrintingDriver
}
else
{
$html .= '<tr '.$bc[$var].'>';
$html .= '<tr class="oddeven">';
$html .= '<td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td>';
$html .= '</tr>';
}

View File

@ -1010,7 +1010,7 @@ class Don extends CommonObject
$object=$this;
$classname = $modele;
$obj = new $classname($db);
$obj = new $classname($this->db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
@ -1028,7 +1028,7 @@ class Don extends CommonObject
{
$outputlangs->charset_output=$sav_charset_output;
dol_syslog("Erreur dans don_create");
dol_print_error($db,$obj->error);
dol_print_error($this->db,$obj->error);
return 0;
}
}

View File

@ -573,9 +573,9 @@ class CommandeFournisseur extends CommonOrder
*/
function LibStatut($statut,$mode=0,$billed=0)
{
if (empty($this->statuts) || empty($statutshort))
if (empty($this->statuts) || empty($this->statutshort))
{
global $langs;
global $conf, $langs;
$langs->load('orders');
$this->statuts[0] = 'StatusOrderDraft';
@ -591,19 +591,17 @@ class CommandeFournisseur extends CommonOrder
$this->statuts[9] = 'StatusOrderRefused';
// List of language codes for status
$statutshort[0] = 'StatusOrderDraftShort';
$statutshort[1] = 'StatusOrderValidatedShort';
$statutshort[2] = 'StatusOrderApprovedShort';
$statutshort[3] = 'StatusOrderOnProcessShort';
$statutshort[4] = 'StatusOrderReceivedPartiallyShort';
$statutshort[5] = 'StatusOrderReceivedAllShort';
$statutshort[6] = 'StatusOrderCanceledShort';
$statutshort[7] = 'StatusOrderCanceledShort';
$statutshort[9] = 'StatusOrderRefusedShort';
$this->statutshort[0] = 'StatusOrderDraftShort';
$this->statutshort[1] = 'StatusOrderValidatedShort';
$this->statutshort[2] = 'StatusOrderApprovedShort';
$this->statutshort[3] = 'StatusOrderOnProcessShort';
$this->statutshort[4] = 'StatusOrderReceivedPartiallyShort';
$this->statutshort[5] = 'StatusOrderReceivedAllShort';
$this->statutshort[6] = 'StatusOrderCanceledShort';
$this->statutshort[7] = 'StatusOrderCanceledShort';
$this->statutshort[9] = 'StatusOrderRefusedShort';
}
$langs->load('orders');
$billedtext='';
//if ($statut==5 && $this->billed == 1) $statut = 8;
if ($billed == 1) $billedtext=$langs->trans("Billed");
@ -614,7 +612,7 @@ class CommandeFournisseur extends CommonOrder
}
if ($mode == 1)
{
return $langs->trans($statutshort[$statut]);
return $langs->trans($this->statutshort[$statut]);
}
if ($mode == 2)
{
@ -644,14 +642,14 @@ class CommandeFournisseur extends CommonOrder
}
if ($mode == 5)
{
if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==3) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==4) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==5) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut6');
if ($statut==6 || $statut==7) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
if ($statut==9) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==3) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==4) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==5) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut6');
if ($statut==6 || $statut==7) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
if ($statut==9) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
}
}

View File

@ -1493,9 +1493,10 @@ class FactureFournisseur extends CommonInvoice
*/
public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='')
{
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
global $langs, $mysoc, $conf;
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
global $mysoc, $conf;
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
@ -1514,7 +1515,7 @@ class FactureFournisseur extends CommonInvoice
if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY))
{
// Check quantity is enough
dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier);
dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." qty=".$qty." ref_supplier=".$ref_supplier);
$prod = new Product($this->db, $fk_product);
if ($prod->fetch($fk_product) > 0)
{

View File

@ -352,7 +352,7 @@ class MyObject extends CommonObject
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
static function LibStatut($status, $mode=0)
function LibStatut($status, $mode=0)
{
if (empty($this->labelstatus))
{

View File

@ -403,7 +403,7 @@ class SupplierProposal extends CommonObject
if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY))
{
// Check quantity is enough
dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier);
dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier);
$prod = new Product($this->db, $fk_product);
if ($prod->fetch($fk_product) > 0)
{

View File

@ -20,13 +20,12 @@
require 'ticketsup.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/ticketsup.lib.php';
/**
* API class for ticketsup object
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*
*
*/
class Tickets extends DolibarrApi
{
@ -311,18 +310,14 @@ class Tickets extends DolibarrApi
$sql.= $db->order($sortfield, $sortorder);
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
}
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
$sql .= $this->db->plimit($limit, $offset);
}
$result = $db->query($sql);
if ($result) {