Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2019-11-02 00:17:45 +00:00
parent a14aab5eb1
commit 50f55cac35
3 changed files with 374 additions and 374 deletions

View File

@ -38,10 +38,10 @@ $hookmanager->initHooks(array('thirdpartiesindex'));
$langs->load("companies"); $langs->load("companies");
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid = $user->societe_id;
// Security check // Security check
$result=restrictedArea($user, 'societe', 0, '', '', '', ''); $result = restrictedArea($user, 'societe', 0, '', '', '', '');
$thirdparty_static = new Societe($db); $thirdparty_static = new Societe($db);
@ -51,10 +51,10 @@ $thirdparty_static = new Societe($db);
*/ */
$transAreaType = $langs->trans("ThirdPartiesArea"); $transAreaType = $langs->trans("ThirdPartiesArea");
$helpurl='EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros'; $helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros';
llxHeader("", $langs->trans("ThirdParties"), $helpurl); llxHeader("", $langs->trans("ThirdParties"), $helpurl);
$linkback=''; $linkback = '';
print load_fiche_titre($transAreaType, $linkback, 'companies'); print load_fiche_titre($transAreaType, $linkback, 'companies');
@ -73,26 +73,26 @@ $third = array(
'supplier' => 0, 'supplier' => 0,
'other' =>0 'other' =>0
); );
$total=0; $total = 0;
$sql = "SELECT s.rowid, s.client, s.fournisseur"; $sql = "SELECT s.rowid, s.client, s.fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; $sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql .= " AND s.rowid = ".$socid;
if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
//print $sql; //print $sql;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
while ($objp = $db->fetch_object($result)) while ($objp = $db->fetch_object($result))
{ {
$found=0; $found = 0;
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; } if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; }
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; } if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; }
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; }
if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; }
if ($found) $total++; if ($found) $total++;
} }
} }
@ -101,14 +101,14 @@ else dol_print_error($db);
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover" width="100%">'."\n"; print '<table class="noborder nohover" width="100%">'."\n";
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2)) if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2))
{ {
print '<tr><td class="center" colspan="2">'; print '<tr><td class="center" colspan="2">';
$dataseries=array(); $dataseries = array();
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer']));
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other'])); if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other']));
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph(); $dolgraph = new DolGraph();
$dolgraph->SetData($dataseries); $dolgraph->SetData($dataseries);
@ -122,23 +122,23 @@ if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(rou
} }
else else
{ {
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
{ {
$statstring = "<tr>"; $statstring = "<tr>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td class="right">'.round($third['prospect']).'</td>'; $statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td class="right">'.round($third['prospect']).'</td>';
$statstring.= "</tr>"; $statstring .= "</tr>";
} }
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
{ {
$statstring.= "<tr>"; $statstring .= "<tr>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td class="right">'.round($third['customer']).'</td>'; $statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td class="right">'.round($third['customer']).'</td>';
$statstring.= "</tr>"; $statstring .= "</tr>";
} }
if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) if (!empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
{ {
$statstring2 = "<tr>"; $statstring2 = "<tr>";
$statstring2.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>'; $statstring2 .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>';
$statstring2.= "</tr>"; $statstring2 .= "</tr>";
} }
print $statstring; print $statstring;
print $statstring2; print $statstring2;
@ -149,7 +149,7 @@ print '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
{ {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$elementtype = 'societe'; $elementtype = 'societe';
@ -161,41 +161,41 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
print '<tr><td class="center" colspan="2">'; print '<tr><td class="center" colspan="2">';
$sql = "SELECT c.label, count(*) as nb"; $sql = "SELECT c.label, count(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
$sql.= " WHERE c.type = 2"; $sql .= " WHERE c.type = 2";
if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
$sql.= " AND c.entity IN (".getEntity('category').")"; $sql .= " AND c.entity IN (".getEntity('category').")";
$sql.= " GROUP BY c.label"; $sql .= " GROUP BY c.label";
$total=0; $total = 0;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i=0; $i = 0;
if (! empty($conf->use_javascript_ajax) ) if (!empty($conf->use_javascript_ajax))
{ {
$dataseries=array(); $dataseries = array();
$rest=0; $rest = 0;
$nbmax=10; $nbmax = 10;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if ($i < $nbmax) if ($i < $nbmax)
{ {
$dataseries[]=array($obj->label, round($obj->nb)); $dataseries[] = array($obj->label, round($obj->nb));
} }
else else
{ {
$rest+=$obj->nb; $rest += $obj->nb;
} }
$total+=$obj->nb; $total += $obj->nb;
$i++; $i++;
} }
if ($i > $nbmax) if ($i > $nbmax)
{ {
$dataseries[]=array($langs->trans("Other"), round($rest)); $dataseries[] = array($langs->trans("Other"), round($rest));
} }
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph(); $dolgraph = new DolGraph();
@ -214,7 +214,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>'; print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
$total+=$obj->nb; $total += $obj->nb;
$i++; $i++;
} }
} }
@ -234,20 +234,20 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/* /*
* Latest modified third parties * Latest modified third parties
*/ */
$max=15; $max = 15;
$sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur"; $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
$sql.= ", s.code_client"; $sql .= ", s.code_client";
$sql.= ", s.code_fournisseur"; $sql .= ", s.code_fournisseur";
$sql.= ", s.logo"; $sql .= ", s.logo";
$sql.= ", s.canvas, s.tms as datem, s.status as status"; $sql .= ", s.canvas, s.tms as datem, s.status as status";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; $sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql .= " AND s.rowid = ".$socid;
if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
$sql.= $db->order("s.tms", "DESC"); $sql .= $db->order("s.tms", "DESC");
$sql.= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
//print $sql; //print $sql;
$result = $db->query($sql); $result = $db->query($sql);
@ -274,16 +274,16 @@ if ($result)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$thirdparty_static->id=$objp->rowid; $thirdparty_static->id = $objp->rowid;
$thirdparty_static->name=$objp->name; $thirdparty_static->name = $objp->name;
$thirdparty_static->client=$objp->client; $thirdparty_static->client = $objp->client;
$thirdparty_static->fournisseur=$objp->fournisseur; $thirdparty_static->fournisseur = $objp->fournisseur;
$thirdparty_static->logo = $objp->logo; $thirdparty_static->logo = $objp->logo;
$thirdparty_static->datem=$db->jdate($objp->datem); $thirdparty_static->datem = $db->jdate($objp->datem);
$thirdparty_static->status=$objp->status; $thirdparty_static->status = $objp->status;
$thirdparty_static->code_client = $objp->code_client; $thirdparty_static->code_client = $objp->code_client;
$thirdparty_static->code_fournisseur = $objp->code_fournisseur; $thirdparty_static->code_fournisseur = $objp->code_fournisseur;
$thirdparty_static->canvas=$objp->canvas; $thirdparty_static->canvas = $objp->canvas;
$thirdparty_static->email = $objp->email; $thirdparty_static->email = $objp->email;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -293,21 +293,21 @@ if ($result)
print "</td>\n"; print "</td>\n";
// Type // Type
print '<td class="center">'; print '<td class="center">';
if ($thirdparty_static->client==1 || $thirdparty_static->client==3) if ($thirdparty_static->client == 1 || $thirdparty_static->client == 3)
{ {
$thirdparty_static->name=$langs->trans("Customer"); $thirdparty_static->name = $langs->trans("Customer");
print $thirdparty_static->getNomUrl(0, 'customer', 0, 1); print $thirdparty_static->getNomUrl(0, 'customer', 0, 1);
} }
if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / "; if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / ";
if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) if (($thirdparty_static->client == 2 || $thirdparty_static->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
{ {
$thirdparty_static->name=$langs->trans("Prospect"); $thirdparty_static->name = $langs->trans("Prospect");
print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1); print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1);
} }
if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) if (!empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur)
{ {
if ($thirdparty_static->client) print " / "; if ($thirdparty_static->client) print " / ";
$thirdparty_static->name=$langs->trans("Supplier"); $thirdparty_static->name = $langs->trans("Supplier");
print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1); print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1);
} }
print '</td>'; print '</td>';

View File

@ -55,4 +55,4 @@ else
\Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
\Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version
\Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION)?"2019-05-16":$conf->global->STRIPE_FORCE_VERSION); // force version API \Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION) ? "2019-05-16" : $conf->global->STRIPE_FORCE_VERSION); // force version API