Mise aux normes SQL
This commit is contained in:
parent
96a2e6870d
commit
bf24cc3147
@ -110,9 +110,11 @@ if ($conf->facture->enabled)
|
|||||||
$sql .= " AND f.fk_soc = $socidp";
|
$sql .= " AND f.fk_soc = $socidp";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
|
if ( $resql )
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -123,7 +125,7 @@ if ($conf->facture->enabled)
|
|||||||
$var = True;
|
$var = True;
|
||||||
while ($i < $num && $i < 20)
|
while ($i < $num && $i < 20)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object();
|
$obj = $db->fetch_object($resql);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="92"><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
print '<tr '.$bc[$var].'><td width="92"><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("Showcompany"),"company").' '.$obj->nom.'</a></td></tr>';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("Showcompany"),"company").' '.$obj->nom.'</a></td></tr>';
|
||||||
@ -132,6 +134,7 @@ if ($conf->facture->enabled)
|
|||||||
|
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
}
|
}
|
||||||
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -151,9 +154,11 @@ if ($user->societe_id == 0)
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc";
|
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc";
|
||||||
$sql .= " WHERE c.fk_type = cc.id AND c.paye=0";
|
$sql .= " WHERE c.fk_type = cc.id AND c.paye=0";
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
|
if ( $resql )
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows($resql);
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
@ -163,7 +168,7 @@ if ($user->societe_id == 0)
|
|||||||
$var = True;
|
$var = True;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object();
|
$obj = $db->fetch_object($resql);
|
||||||
$var = !$var;
|
$var = !$var;
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print '<td>'.$obj->libelle.'</td>';
|
print '<td>'.$obj->libelle.'</td>';
|
||||||
@ -173,6 +178,7 @@ if ($user->societe_id == 0)
|
|||||||
}
|
}
|
||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
}
|
}
|
||||||
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -191,9 +197,11 @@ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b";
|
|||||||
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id;
|
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id;
|
||||||
$sql .= " ORDER BY lower(s.nom) ASC";
|
$sql .= " ORDER BY lower(s.nom) ASC";
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
|
if ( $resql )
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
@ -202,7 +210,7 @@ if ( $db->query($sql) )
|
|||||||
$var = True;
|
$var = True;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object();
|
$obj = $db->fetch_object($resql);
|
||||||
$var = !$var;
|
$var = !$var;
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
|
||||||
@ -212,8 +220,12 @@ if ( $db->query($sql) )
|
|||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
|
$db->free($resql);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</td><td valign="top" width="70%">';
|
print '</td><td valign="top" width="70%">';
|
||||||
|
|
||||||
|
|
||||||
@ -237,9 +249,11 @@ if ($conf->commande->enabled && $user->rights->commande->lire)
|
|||||||
$sql .= " AND p.fk_soc = $socidp";
|
$sql .= " AND p.fk_soc = $socidp";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
|
if ( $resql )
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows($resql);
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -253,26 +267,29 @@ if ($conf->commande->enabled && $user->rights->commande->lire)
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$obj = $db->fetch_object();
|
$obj = $db->fetch_object($resql);
|
||||||
if ($obj->total_ht-$obj->tot_fht) {
|
if ($obj->total_ht-$obj->tot_fht)
|
||||||
print "<tr $bc[$var]>";
|
{
|
||||||
print "<td width=\"20%\"><a href=\"commande.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").'</a> ';
|
print "<tr $bc[$var]>";
|
||||||
print "<a href=\"commande.php?id=$obj->rowid\">".$obj->ref.'</a></td>';
|
print "<td width=\"20%\"><a href=\"commande.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").'</a> ';
|
||||||
|
print "<a href=\"commande.php?id=$obj->rowid\">".$obj->ref.'</a></td>';
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> ';
|
|
||||||
print '<a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> ';
|
||||||
print '<td align="right">'.price($obj->total_ht-$obj->tot_fht).'</td>';
|
print '<a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
|
||||||
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>';
|
print '<td align="right">'.price($obj->total_ht-$obj->tot_fht).'</td>';
|
||||||
$tot_ht += $obj->total_ht-$obj->tot_fht;
|
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>';
|
||||||
$tot_ttc += $obj->total_ttc-$obj->tot_fttc;
|
$tot_ht += $obj->total_ht-$obj->tot_fht;
|
||||||
}
|
$tot_ttc += $obj->total_ttc-$obj->tot_fttc;
|
||||||
$i++;
|
}
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' (Reste à facturer : '.price($tot_ttc).')</i></td><td align="right"><i>'.price($tot_ht)."</i></td><td align=\"right\"><i>".price($tot_ttc)."</i></td></tr>";
|
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' (Reste à facturer : '.price($tot_ttc).')</i></td><td align="right"><i>'.price($tot_ht)."</i></td><td align=\"right\"><i>".price($tot_ttc)."</i></td></tr>";
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
}
|
}
|
||||||
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
dolibarr_print_error($db);
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,9 +312,11 @@ if ($conf->facture->enabled)
|
|||||||
}
|
}
|
||||||
$sql .= " GROUP BY f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc";
|
$sql .= " GROUP BY f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc";
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
|
if ( $resql )
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -309,7 +328,7 @@ if ($conf->facture->enabled)
|
|||||||
$total_ttc = $totalam = $total = 0;
|
$total_ttc = $totalam = $total = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object();
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
if ($i < 20)
|
if ($i < 20)
|
||||||
{
|
{
|
||||||
@ -321,7 +340,7 @@ if ($conf->facture->enabled)
|
|||||||
print '<td align="right">'.price($obj->am).'</td></tr>';
|
print '<td align="right">'.price($obj->am).'</td></tr>';
|
||||||
}
|
}
|
||||||
$total_ttc += $obj->total_ttc;
|
$total_ttc += $obj->total_ttc;
|
||||||
$total += $obj->total;
|
$total += $obj->total;
|
||||||
$totalam += $obj->am;
|
$totalam += $obj->am;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -329,7 +348,7 @@ if ($conf->facture->enabled)
|
|||||||
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</i></td><td align="right"><i>'.price($total)."</i></td><td align=\"right\"><i>".price($total_ttc)."</i></td><td align=\"right\"><i>".price($totalam)."</i></td></tr>";
|
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</i></td><td align="right"><i>'.price($total)."</i></td><td align=\"right\"><i>".price($total_ttc)."</i></td><td align=\"right\"><i>".price($totalam)."</i></td></tr>";
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
}
|
}
|
||||||
$db->free();
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user