diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 6824efce96d..fad875d3ec1 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1244,7 +1244,7 @@ else
print '';
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '';
- if ($objp->description) print ': '.nl2br($objp->description);
+ if ($objp->description) print ' - '.nl2br($objp->description);
}
else
{
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 1010f0e866e..62ea8fbb3d9 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1728,7 +1728,7 @@ else
print '';
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '';
- if ($objp->description) print ': '.nl2br($objp->description);
+ if ($objp->description) print ' - '.nl2br($objp->description);
}
else
{
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 4644b344298..d2ac15e1c74 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -21,7 +21,7 @@
* $Source$
*/
-/**
+/**
\file htdocs/compta/index.php
\ingroup compta
\brief Page accueil zone comptabilité
@@ -29,6 +29,9 @@
*/
require("./pre.inc.php");
+if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
+if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT.'/facture.class.php');
+if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php');
$user->getrights(); // On a besoin des permissions sur plusieurs modules
@@ -98,7 +101,7 @@ print '
| ';
if ($conf->facture->enabled)
{
print ' | ';
*/
if ($conf->facture->enabled && $conf->commande->enabled && $user->rights->commande->lire)
{
- $langs->load("orders");
+ $commandestatic=new Commande($db);
+ $langs->load("orders");
- $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";
- if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."commande AS p";
- if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $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 .= " WHERE p.fk_soc = s.idp";
- if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
- if ($socidp)
- {
- $sql .= " AND p.fk_soc = $socidp";
- }
- $sql .= " AND p.fk_statut >=1 AND p.facture=0";
- $sql .= " GROUP BY p.rowid";
-
- $resql = $db->query($sql);
-
- if ( $resql )
- {
- $num = $db->num_rows($resql);
- if ($num)
+ $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc,";
+ $sql.= " s.nom, s.idp,";
+ $sql.= " p.rowid, p.ref, p.facture, p.fk_statut, p.total_ht, p.total_ttc";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."commande AS p";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $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.= " WHERE p.fk_soc = s.idp";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if ($socidp)
{
- $i = 0;
- print '';
- print "";
- print '| '.$langs->trans("OrdersToBill").' ('.$num.') | ';
- print ''.$langs->trans("AmountHT").' | ';
- print ''.$langs->trans("AmountTTC").' | ';
- print ''.$langs->trans("ToBill").' | ';
- print ' ';
- $var = True;
- $tot_ht=$tot_ttc=$tot_tobill=0;
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
-// if ($obj->total_ttc-$obj->tot_fttc >0)
-// {
- $var=!$var;
+ $sql.= " AND p.fk_soc = $socidp";
+ }
+ $sql.= " AND p.fk_statut = 3 AND p.facture=0";
+ $sql.= " GROUP BY p.rowid";
+
+ $resql = $db->query($sql);
+
+ if ( $resql )
+ {
+ $num = $db->num_rows($resql);
+ if ($num)
+ {
+ $i = 0;
+ print '';
+ print "";
+ print '| '.$langs->trans("OrdersToBill").' ('.$num.') | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.$langs->trans("AmountHT").' | ';
+ print ''.$langs->trans("AmountTTC").' | ';
+ print ''.$langs->trans("ToBill").' | ';
+ print ' | ';
+ print ' ';
+ $var = True;
+ $tot_ht=$tot_ttc=$tot_tobill=0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ // if ($obj->total_ttc-$obj->tot_fttc >0)
+ // {
+ $var=!$var;
print "";
print "| rowid\">".img_object($langs->trans("ShowOrder"),"order").' ';
print "rowid\">".$obj->ref.' | ';
-
+
print ''.img_object($langs->trans("ShowCompany"),"company").' ';
- print ''.dolibarr_trunc($obj->nom,50).' | ';
- print ''.price($obj->total_ht).' | ';
+ print ''.dolibarr_trunc($obj->nom,44).'';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($obj->total_ht).' | ';
print ''.price($obj->total_ttc).' | ';
- print ''.price($obj->total_ttc-$obj->tot_fttc).' | ';
+ print ''.price($obj->total_ttc-$obj->tot_fttc).' | ';
+ print ''.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,3).' | ';
+ print '';
$tot_ht += $obj->total_ht;
$tot_ttc += $obj->total_ttc;
$tot_tobill += ($obj->total_ttc-$obj->tot_fttc);
-// }
- $i++;
- }
- $var=!$var;
+ // }
+ $i++;
+ }
+ $var=!$var;
- print '| '.$langs->trans("Total").' ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') | ';
- print ''.price($tot_ht).' | ';
- print ''.price($tot_ttc).' | ';
- print ''.price($tot_tobill).' | ';
- print ' ';
- print ' ';
+ print '| '.$langs->trans("Total").' ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($tot_ht).' | ';
+ print ''.price($tot_ttc).' | ';
+ print ''.price($tot_tobill).' | ';
+ print ' | ';
+ print ' ';
+ print ' ';
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ dolibarr_print_error($db);
}
- $db->free($resql);
- }
- else
- {
- dolibarr_print_error($db);
- }
}
-
+/*
+ * Factures impayées
+ */
if ($conf->facture->enabled && $user->rights->facture->lire)
{
+ $facstatic=new Facture($db);
- /*
- * Factures impayées
- *
- */
+ $sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.total, f.total_ttc, ".$db->pdate("f.date_lim_reglement")." as datelimite,";
+ $sql.= " sum(pf.amount) as am,";
+ $sql.= " s.nom, s.idp";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if ($socidp) $sql .= " AND f.fk_soc = ".$socidp;
+ $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.total, f.total_ttc, s.nom, s.idp";
+ $sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
- $sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc, ".$db->pdate("f.date_lim_reglement")." as datelimite, sum(pf.amount) as am";
- if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
- $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";
- if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
- if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
- if ($socidp) $sql .= " AND f.fk_soc = $socidp";
- $sql.= " GROUP BY f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc";
- $sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
-
- if ($num)
+ $resql = $db->query($sql);
+ if ($resql)
{
- print '';
- print '| '.$langs->trans("BillsCustomersUnpayed",min($conf->liste_limit,$num)).' ('.$num.') | ';
- print ''.$langs->trans("AmountHT").' | '.$langs->trans("AmountTTC").' | '.$langs->trans("Received").' | ';
- $var = True;
- $total_ttc = $totalam = $total = 0;
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ $num = $db->num_rows($resql);
+ $i = 0;
- if ($i < $conf->liste_limit)
+ if ($num)
{
- $var=!$var;
- print '';
- print '| '.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'';
- if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
- print ' | ';
- print ''.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).' | ';
- print ''.price($obj->total).' | ';
- print ''.price($obj->total_ttc).' | ';
- print ''.price($obj->am).' | ';
- }
- $total_ttc += $obj->total_ttc;
- $total += $obj->total;
- $totalam += $obj->am;
- $i++;
- }
- $var=!$var;
+ print '';
+ print '| '.$langs->trans("BillsCustomersUnpayed",min($conf->liste_limit,$num)).' ('.$num.') | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.$langs->trans("AmountHT").' | ';
+ print ''.$langs->trans("AmountTTC").' | ';
+ print ''.$langs->trans("Received").' | ';
+ print ' | ';
+ print ' ';
+ $var = True;
+ $total_ttc = $totalam = $total = 0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- print '| '.$langs->trans("Total").' ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).') | ';
- print ''.price($total).' | ';
- print ''.price($total_ttc).' | ';
- print ''.price($totalam).' | ';
- print ' ';
- print ' ';
+ if ($i < $conf->liste_limit)
+ {
+ $var=!$var;
+ print '';
+ print '| '.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'';
+ if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
+ print ' | ';
+ print ''.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).' | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($obj->total).' | ';
+ print ''.price($obj->total_ttc).' | ';
+ print ''.price($obj->am).' | ';
+ print ''.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).' | ';
+ print ' ';
+ }
+ $total_ttc += $obj->total_ttc;
+ $total += $obj->total;
+ $totalam += $obj->am;
+ $i++;
+ }
+ $var=!$var;
+
+ print '| '.$langs->trans("Total").' ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).') | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($total).' | ';
+ print ''.price($total_ttc).' | ';
+ print ''.price($totalam).' | ';
+ print ' | ';
+ print ' ';
+ print ' ';
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ dolibarr_print_error($db);
}
- $db->free($resql);
- }
- else
- {
- dolibarr_print_error($db);
- }
}
+/*
+ * Factures a payer
+ */
+if ($conf->facture->enabled && $user->rights->facture->lire)
+{
+ $facstatic=new FactureFournisseur($db);
+
+ if ($user->societe_id == 0)
+ {
+ $sql = "SELECT ff.rowid, ff.facnumber, ff.fk_statut, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc,";
+ $sql.= " sum(pf.amount) as am,";
+ $sql.= " s.nom, s.idp";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE s.idp = ff.fk_soc";
+ $sql.= " AND ff.paye=0 AND ff.fk_statut = 1";
+ if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
+ $sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.total, ff.total_ttc, s.nom, s.idp";
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ if ($num)
+ {
+ print '';
+ print '| '.$langs->trans("BillsSuppliersUnpayed").' ('.$num.') | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.$langs->trans("AmountHT").' | ';
+ print ''.$langs->trans("AmountTTC").' | ';
+ print ''.$langs->trans("Payed").' | ';
+ print ' | ';
+ print " \n";
+ $i = 0;
+ $var = True;
+ $total = $total_ttc = $totalam = 0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ $var = !$var;
+ print '| '.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.' | ';
+ print ''.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,44).' | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($obj->total_ht).' | ';
+ print ''.price($obj->total_ttc).' | ';
+ print ''.price($obj->am).' | ';
+ print ''.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3).' | ';
+ print ' ';
+ $total += $obj->total_ht;
+ $total_ttc += $obj->total_ttc;
+ $totalam += $obj->am;
+ $i++;
+ }
+ $var=!$var;
+
+ print '| '.$langs->trans("Total").' ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).') | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($total).' | ';
+ print ''.price($total_ttc).' | ';
+ print ''.price($totalam).' | ';
+ print ' | ';
+ print ' ';
+ print ' ';
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+ }
+
+}
+
+
// \todo Mettre ici recup des actions en rapport avec la compta
$resql = 0;
@@ -424,81 +514,20 @@ if ($resql)
$obj = $db->fetch_object($resql);
$var=!$var;
- print " |