From b0f8a31e9b9ee6f8cef5e4c173dd7fa8bbeedd45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 May 2005 15:11:52 +0000 Subject: [PATCH] Ajout ligne total --- htdocs/comm/prospect/index.php | 144 ++++++++++++++++++--------------- 1 file changed, 81 insertions(+), 63 deletions(-) diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index fe6ef540cfc..dbac8fe3bf0 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -116,37 +116,46 @@ if ($resql) } -if ($conf->propal->enabled) +/* + * Liste des propal brouillons + */ +if ($conf->propal->enabled && $user->rights->propale->lire) { - $sql = "SELECT p.rowid, p.ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; - $sql .= " WHERE p.fk_statut = 0"; - - $resql=$db->query($sql); - if ($resql) - { - $var=true; + $sql = "SELECT p.rowid, p.ref, p.price, s.nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp"; - $num = $db->num_rows($resql); - $i = 0; - if ($num > 0 ) - { - print ''; - print ""; - print ""; - - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $var=!$var; - print ""; - $i++; - } - print "
".$langs->trans("ProposalsDraft")."
"; - print "rowid."\">".img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.""; - print "

"; - } - $db->free($resql); + $resql=$db->query($sql); + if ($resql) + { + $var=true; + + $total=0; + $num = $db->num_rows($resql); + $i = 0; + if ($num > 0) + { + print ''; + print ""; + print ""; + + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print ""; + $i++; + $total += $obj->price; + } + if ($total>0) { + $var=!$var; + print '"; + } + print "
".$langs->trans("ProposalsDraft")."
"; + print "rowid."\">".img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.""; + print "
'.$langs->trans("Total")."".price($total)."

"; + } + $db->free($resql); } } @@ -198,42 +207,51 @@ else dolibarr_print_error($db); } - -$sql = "SELECT s.nom, s.idp, p.rowid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut = 1"; -if ($socidp) -{ - $sql .= " AND s.idp = $socidp"; -} - -$sql .= " ORDER BY p.rowid DESC"; -$sql .= $db->plimit(5, 0); - -if ( $db->query($sql) ) +/* + * Dernières propales ouvertes + * + */ +if ($conf->propal->enabled && $user->rights->propale->lire) { - $num = $db->num_rows(); - $i = 0; - if ($num > 0 ) + $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut = 1"; + if ($socidp) $sql .= " AND s.idp = $socidp"; + $sql .= " ORDER BY p.rowid DESC"; + $sql .= $db->plimit(5, 0); + + $resql=$db->query($sql); + if ($resql) { - $var=true; - - print ''; - print ''; - - while ($i < $num) - { - $obj = $db->fetch_object(); - $var=!$var; - print "'; - - print "\n"; - print "\n"; - print "\n"; - $i++; - } - print "
'.$langs->trans("ProposalsOpened").'
rowid."\">"; - print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'idp\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.""; - print dolibarr_print_date($obj->dp)."".price($obj->price)."

"; + $total = 0; + $num = $db->num_rows($resql); + $i = 0; + if ($num > 0) + { + $var=true; + + print ''; + print ''; + + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print "'; + + print "\n"; + print "\n"; + print "\n"; + $i++; + $total += $obj->price; + } + if ($total>0) { + print '"; + } + print "
'.$langs->trans("ProposalsOpened").'
rowid."\">"; + print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'idp\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.""; + print dolibarr_print_date($obj->dp)."".price($obj->price)."
'.$langs->trans("Total")."".price($total)."

"; + } } }