ordonnancement des factures impayées

This commit is contained in:
marc_ocebo 2005-04-29 00:56:44 +00:00
parent 86fe74f45a
commit 958de03248

View File

@ -1,454 +1,455 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Id$ * $Id$
* $Source$ * $Source$
* *
*/ */
/** /**
\file htdocs/compta/index.php \file htdocs/compta/index.php
\ingroup compta \ingroup compta
\brief Page accueil zone comptabilité \brief Page accueil zone comptabilité
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
$user->getrights(); // On a besoin des permissions sur plusieurs modules $user->getrights(); // On a besoin des permissions sur plusieurs modules
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
/* /*
* Sécurité accés client * Sécurité accés client
*/ */
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socidp = $user->societe_id; $socidp = $user->societe_id;
} }
llxHeader("","Accueil Compta"); llxHeader("","Accueil Compta");
/* /*
* Actions * Actions
*/ */
if ($_GET["action"] == 'add_bookmark') if ($_GET["action"] == 'add_bookmark')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socidp." AND fk_user=".$user->id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socidp." AND fk_user=".$user->id;
if (! $db->query($sql) ) if (! $db->query($sql) )
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");";
if (! $db->query($sql) ) if (! $db->query($sql) )
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
if ($_GET["action"] == 'del_bookmark') if ($_GET["action"] == 'del_bookmark')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"]; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"];
$result = $db->query($sql); $result = $db->query($sql);
} }
/* /*
* Affichage page * Affichage page
* *
*/ */
print_titre($langs->trans("AccountancyTreasuryArea")); print_titre($langs->trans("AccountancyTreasuryArea"));
print '<table border="0" width="100%">'; print '<table border="0" width="100%">';
print '<tr><td valign="top" width="30%">'; print '<tr><td valign="top" width="30%">';
/* /*
* Zone recherche facture * Zone recherche facture
*/ */
if ($conf->facture->anabled) { if ($conf->facture->enabled) {
print '<form method="post" action="facture.php">'; print '<form method="post" action="facture.php">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print '<td colspan="2">'.$langs->trans("SearchABill").'</td></tr>'; print '<td colspan="2">'.$langs->trans("SearchABill").'</td></tr>';
print "<tr $bc[0]><td>"; print "<tr $bc[0]><td>";
print $langs->trans("Ref").': <input type="text" name="sf_ref" class="flat" size="18">&nbsp;<input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; print $langs->trans("Ref").': <input type="text" name="sf_ref" class="flat" size="18">&nbsp;<input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "</table></form><br>"; print "</table></form><br>";
} }
/* /*
* Factures brouillons * Factures brouillons
*/ */
if ($conf->facture->enabled && $user->rights->facture->lire) if ($conf->facture->enabled && $user->rights->facture->lire)
{ {
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp"; $sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0"; $sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0";
if ($socidp) if ($socidp)
{ {
$sql .= " AND f.fk_soc = $socidp"; $sql .= " AND f.fk_soc = $socidp";
} }
$resql = $db->query($sql); $resql = $db->query($sql);
if ( $resql ) if ( $resql )
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num) if ($num)
{ {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>'; print '<td colspan="2">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>';
$var = True; $var = True;
while ($i < $num && $i < 20) while ($i < $num && $i < 20)
{ {
$obj = $db->fetch_object($resql); $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><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>';
$i++; $i++;
} }
print "</table><br>"; print "</table><br>";
} }
$db->free($resql); $db->free($resql);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
if ($conf->compta->enabled) { if ($conf->compta->enabled) {
/* /*
* Charges a payer * Charges a payer
*/ */
if ($user->societe_id == 0) if ($user->societe_id == 0)
{ {
$sql = "SELECT c.amount, cc.libelle"; $sql = "SELECT c.amount, cc.libelle";
$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";
$resql = $db->query($sql); $resql = $db->query($sql);
if ( $resql ) if ( $resql )
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num)
{ {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="2">Charges à payer ('.$num.')</td></tr>'; print '<td colspan="2">Charges à payer ('.$num.')</td></tr>';
$i = 0; $i = 0;
$var = True; $var = True;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $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>';
print '<td align="right">'.price($obj->amount).'</td>'; print '<td align="right">'.price($obj->amount).'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table><br>'; print '</table><br>';
} }
$db->free($resql); $db->free($resql);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
} }
/* /*
* Bookmark * Bookmark
*/ */
$sql = "SELECT s.idp, s.nom,b.rowid as bid"; $sql = "SELECT s.idp, s.nom,b.rowid as bid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; $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";
$resql = $db->query($sql); $resql = $db->query($sql);
if ( $resql ) if ( $resql )
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num) if ($num)
{ {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Bookmarks")."</td></tr>\n"; print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Bookmarks")."</td></tr>\n";
$var = True; $var = True;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $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>';
print '<td align="right"><a href="index.php?action=del_bookmark&amp;bid='.$obj->bid.'">'.img_delete().'</a></td>'; print '<td align="right"><a href="index.php?action=del_bookmark&amp;bid='.$obj->bid.'">'.img_delete().'</a></td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
} }
$db->free($resql); $db->free($resql);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '</td><td valign="top" width="70%">'; print '</td><td valign="top" width="70%">';
/* /*
* Commandes à facturer * Commandes à facturer
*/ */
if ($conf->commande->enabled && $user->rights->commande->lire) if ($conf->commande->enabled && $user->rights->commande->lire)
{ {
$langs->load("orders"); $langs->load("orders");
$sql = "SELECT sum(f.total) as tot_fht,sum(f.total_ttc) as tot_fttc"; $sql = "SELECT sum(f.total) as tot_fht,sum(f.total_ttc) as tot_fttc";
$sql .= " ,s.nom, s.idp, p.rowid, p.ref, p.total_ht, p.total_ttc"; $sql .= " ,s.nom, s.idp, p.rowid, p.ref, p.total_ht, p.total_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."commande AS p, llx_societe AS s"; $sql .= " FROM ".MAIN_DB_PREFIX."commande AS p, llx_societe AS s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid";
$sql .= " WHERE p.fk_soc = s.idp"; $sql .= " WHERE p.fk_soc = s.idp";
if ($socidp) if ($socidp)
{ {
$sql .= " AND p.fk_soc = $socidp"; $sql .= " AND p.fk_soc = $socidp";
} }
$sql .= " AND p.fk_statut >=1 AND p.facture =0"; $sql .= " AND p.fk_statut >=1 AND p.facture =0";
$sql .= " GROUP BY p.rowid"; $sql .= " GROUP BY p.rowid";
$resql = $db->query($sql); $resql = $db->query($sql);
if ( $resql ) if ( $resql )
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num)
{ {
$i = 0; $i = 0;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print '<td colspan="2">'.$langs->trans("OrdersToBill").' ('.$num.')</td>'; print '<td colspan="2">'.$langs->trans("OrdersToBill").' ('.$num.')</td>';
print '<td align="right">'.$langs->trans("AmountHT").'</td>'; print '<td align="right">'.$langs->trans("AmountHT").'</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td>'; print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td align="right">'.$langs->trans("ToBill").'</td>'; print '<td align="right">'.$langs->trans("ToBill").'</td>';
print '</tr>'; print '</tr>';
$var = True; $var = True;
$tot_ht=0; $tot_ht=0;
$tot_ttc=0; $tot_ttc=0;
while ($i < $num) while ($i < $num)
{ {
$var=!$var; $var=!$var;
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td width=\"20%\"><a href=\"commande/fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").'</a>&nbsp;'; print "<td width=\"20%\"><a href=\"commande/fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").'</a>&nbsp;';
print "<a href=\"commande/fiche.php?id=$obj->rowid\">".$obj->ref.'</a></td>'; print "<a href=\"commande/fiche.php?id=$obj->rowid\">".$obj->ref.'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a>&nbsp;'; print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a>&nbsp;';
print '<a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>'; print '<a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
print '<td align="right">'.price($obj->total_ht).'</td>'; print '<td align="right">'.price($obj->total_ht).'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>'; print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>'; print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>';
$tot_ht += $obj->total_ht; $tot_ht += $obj->total_ht;
$tot_ttc += $obj->total_ttc; $tot_ttc += $obj->total_ttc;
$tot_tobill += ($obj->total_ttc-$obj->tot_fttc); $tot_tobill += ($obj->total_ttc-$obj->tot_fttc);
$i++; $i++;
} }
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' &nbsp; ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</i></td>'; print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' &nbsp; ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</i></td>';
print '<td align="right"><i>'.price($tot_ht).'</i></td>'; print '<td align="right"><i>'.price($tot_ht).'</i></td>';
print '<td align="right"><i>'.price($tot_ttc).'</i></td>'; print '<td align="right"><i>'.price($tot_ttc).'</i></td>';
print '<td align="right"><i>'.price($tot_tobill).'</i></td>'; print '<td align="right"><i>'.price($tot_tobill).'</i></td>';
print '</tr>'; print '</tr>';
print '</table><br>'; print '</table><br>';
} }
$db->free($resql); $db->free($resql);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
if ($conf->facture->enabled && $user->rights->facture->lire) if ($conf->facture->enabled && $user->rights->facture->lire)
{ {
/* /*
* Factures impayées * Factures impayées
* *
*/ */
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc, sum(pf.amount) as am"; $sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc, sum(pf.amount) as am";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
$sql .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; $sql .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
if ($socidp) if ($socidp)
{ {
$sql .= " AND f.fk_soc = $socidp"; $sql .= " AND f.fk_soc = $socidp";
} }
$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";
$sql .= " ORDER BY f.datef ASC ";
$resql = $db->query($sql);
$resql = $db->query($sql);
if ( $resql )
{ if ( $resql )
$num = $db->num_rows($resql); {
$i = 0; $num = $db->num_rows($resql);
$i = 0;
if ($num)
{ if ($num)
print '<table class="noborder" width="100%">'; {
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsCustomersUnpayed").' ('.$num.')</td>'; print '<table class="noborder" width="100%">';
print '<td align="right">'.$langs->trans("AmountHT").'</td><td align="right">'.$langs->trans("AmountTTC").'</td><td align="right">'.$langs->trans("Received").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsCustomersUnpayed").' ('.$num.')</td>';
$var = True; print '<td align="right">'.$langs->trans("AmountHT").'</td><td align="right">'.$langs->trans("AmountTTC").'</td><td align="right">'.$langs->trans("Received").'</td></tr>';
$total_ttc = $totalam = $total = 0; $var = True;
while ($i < $num) $total_ttc = $totalam = $total = 0;
{ while ($i < $num)
$obj = $db->fetch_object($resql); {
$obj = $db->fetch_object($resql);
if ($i < $conf->liste_limit)
{ if ($i < $conf->liste_limit)
$var=!$var; {
print '<tr '.$bc[$var].'><td width="20%"><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>'; $var=!$var;
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.$obj->nom.'</a></td>'; print '<tr '.$bc[$var].'><td><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
print '<td align="right">'.price($obj->total).'</td>'; print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.$obj->nom.'</a></td>';
print '<td align="right">'.price($obj->total_ttc).'</td>'; print '<td align="right">'.price($obj->total).'</td>';
print '<td align="right">'.price($obj->am).'</td></tr>'; print '<td align="right">'.price($obj->total_ttc).'</td>';
} print '<td align="right">'.price($obj->am).'</td></tr>';
$total_ttc += $obj->total_ttc; }
$total += $obj->total; $total_ttc += $obj->total_ttc;
$totalam += $obj->am; $total += $obj->total;
$i++; $totalam += $obj->am;
} $i++;
$var=!$var; }
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' &nbsp; ('.$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").' &nbsp; ('.$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($resql); }
} $db->free($resql);
else }
{ else
dolibarr_print_error($db); {
} dolibarr_print_error($db);
} }
}
// \todo Mettre ici recup des actions en rapport avec la compta
$resql = 0; // \todo Mettre ici recup des actions en rapport avec la compta
if ($resql) $resql = 0;
{ if ($resql)
print '<table class="noborder" width="100%">'; {
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TasksToDo").'</td>'; print '<table class="noborder" width="100%">';
print "</tr>\n"; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TasksToDo").'</td>';
$var = True; print "</tr>\n";
$i = 0; $var = True;
while ($i < $db->num_rows($resql) ) $i = 0;
{ while ($i < $db->num_rows($resql) )
$obj = $db->fetch_object($resql); {
$var=!$var; $obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]><td>".strftime("%d %b %Y",$obj->da)."</td><td><a href=\"action/fiche.php\">$obj->libelle $obj->label</a></td></tr>";
$i++; print "<tr $bc[$var]><td>".strftime("%d %b %Y",$obj->da)."</td><td><a href=\"action/fiche.php\">$obj->libelle $obj->label</a></td></tr>";
} $i++;
$db->free($resql); }
print "</table><br>"; $db->free($resql);
} print "</table><br>";
}
/*
* Factures a payer /*
*/ * Factures a payer
if ($conf->facture->enabled) { */
if ($conf->facture->enabled) {
if ($user->societe_id == 0)
{ if ($user->societe_id == 0)
$sql = "SELECT ff.rowid, ff.facnumber, ff.libelle, ff.total_ht, ff.total_ttc, s.nom, s.idp"; {
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql = "SELECT ff.rowid, ff.facnumber, ff.libelle, ff.total_ht, ff.total_ttc, s.nom, s.idp";
$sql .= " WHERE s.idp = ff.fk_soc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
$sql .= " AND ff.paye=0"; $sql .= " WHERE s.idp = ff.fk_soc";
$sql .= " AND ff.paye=0";
$result=$db->query($sql);
if ($result) $result=$db->query($sql);
{ if ($result)
$num = $db->num_rows(); {
if ($num) $num = $db->num_rows();
{ if ($num)
print '<table class="noborder" width="100%">'; {
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsSuppliersUnpayed").' ('.$num.')</td>'; print '<table class="noborder" width="100%">';
print '<td align="right">'.$langs->trans("AmountHT").'</td>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsSuppliersUnpayed").' ('.$num.')</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td></tr>'; print '<td align="right">'.$langs->trans("AmountHT").'</td>';
print "</tr>\n"; print '<td align="right">'.$langs->trans("AmountTTC").'</td></tr>';
$i = 0; print "</tr>\n";
$var = True; $i = 0;
$total = $total_ttc = $totalam = 0; $var = True;
while ($i < $num) $total = $total_ttc = $totalam = 0;
{ while ($i < $num)
$obj = $db->fetch_object($result); {
$var = !$var; $obj = $db->fetch_object($result);
print '<tr '.$bc[$var].'><td width="20%"><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>'; $var = !$var;
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a></td>'; print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
print '<td align="right">'.price($obj->total_ht).'</td>'; print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a></td>';
print '<td align="right">'.price($obj->total_ttc).'</td>'; print '<td align="right">'.price($obj->total_ht).'</td>';
print '</tr>'; print '<td align="right">'.price($obj->total_ttc).'</td>';
$total += $obj->total_ht; print '</tr>';
$total_ttc += $obj->total_ttc; $total += $obj->total_ht;
$totalam += $obj->am; $total_ttc += $obj->total_ttc;
$i++; $totalam += $obj->am;
} $i++;
$var=!$var; }
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' &nbsp; ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</td>'; $var=!$var;
print '<td align="right"><i>'.price($total).'</i></td><td align="right"><i>'.price($total_ttc).'</i></td></tr>'; print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' &nbsp; ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</td>';
print '</table><br>'; print '<td align="right"><i>'.price($total).'</i></td><td align="right"><i>'.price($total_ttc).'</i></td></tr>';
} print '</table><br>';
} }
else }
{ else
dolibarr_print_error($db); {
} dolibarr_print_error($db);
} }
}
}
}
print '</td></tr>';
print '</td></tr>';
print '</table>';
print '</table>';
$db->close();
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?> llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>