diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 3f49f6d713e..1d7a75fe76b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -26,7 +26,7 @@ /** \file htdocs/comm/propal.php \ingroup propale - \brief Page liste des propales + \brief Page liste des propales (vision commercial) */ require('./pre.inc.php'); @@ -42,10 +42,10 @@ if (!$user->rights->propale->lire) if ($conf->projet->enabled) require_once '../project.class.php'; if($conf->commande->enabled) require_once '../commande/commande.class.php'; -require('./propal_model_pdf.class.php'); -require('../propal.class.php'); -require('../actioncomm.class.php'); -require(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); +require_once('./propal_model_pdf.class.php'); +require_once('../propal.class.php'); +require_once('../actioncomm.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); /* * Sécurité accés client diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index ee3b350fb14..7a5286e7896 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -710,26 +710,28 @@ if ($_GET["action"] == 'create') /* * Produits */ + print '
'; print_titre($langs->trans("Products")); print ''; print ''; print ''; + // Lignes de propal produits prédéfinis $sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent"; $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt, ".MAIN_DB_PREFIX."product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = ".$_GET["propalid"]; $sql .= " ORDER BY pt.rowid ASC"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows(); + $num = $db->num_rows($result); $i = 0; $var=True; while ($i < $num) { - $objp = $db->fetch_object(); + $objp = $db->fetch_object($result); $var=!$var; - print "\n"; + print "\n"; print ''; print ""; print ''; @@ -737,18 +739,20 @@ if ($_GET["action"] == 'create') $i++; } } + // Lignes de propal non produits prédéfinis $sql = "SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent"; $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt "; $sql .= " WHERE pt.fk_propal = ".$_GET["propalid"]; $sql .= " AND pt.fk_product = 0"; $sql .= " ORDER BY pt.rowid ASC"; - if ($db->query($sql)) + $result=$db->query($sql); + if ($result) { - $num = $db->num_rows(); + $num = $db->num_rows($result); $i = 0; while ($i < $num) { - $objp = $db->fetch_object(); + $objp = $db->fetch_object($result); $var=!$var; print "\n"; print ''; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 3342e8aaf57..165ce23b362 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -132,8 +132,8 @@ if ($conf->facture->enabled && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); $var=!$var; - print ''; - print ''; + print ''; + print ''; $i++; } diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 0039cc5aec2..f2afb6facbf 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -19,11 +19,12 @@ * * $Id$ * $Source$ - * */ - + /** -\todo Ce fichier ne semble plus utilisé. A virer ? NON Il est utilisé ! + \file htdocs/compta/propal.php + \ingroup propale + \brief Page liste des propales (vision compta) */ require("./pre.inc.php"); @@ -31,7 +32,7 @@ require("./pre.inc.php"); $user->getrights('facture'); $user->getrights('propale'); if (!$user->rights->propale->lire) - accessforbidden(); +accessforbidden(); require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); @@ -39,532 +40,504 @@ require_once("../project.class.php"); require_once("../propal.class.php"); require_once("../actioncomm.class.php"); -/* - * Sécurité accés client - */ -if ($user->societe_id > 0) +// Sécurité accés client +if ($user->societe_id > 0) { - $action = ''; - $socidp = $user->societe_id; + $action = ''; + $socidp = $user->societe_id; } if ($_GET["action"] == 'setstatut') { - /* - * Classée la facture comme facturée - */ - $propal = new Propal($db); - $propal->id = $_GET["propalid"]; - $propal->cloture($user, $_GET["statut"], $note); + /* + * Classée la facture comme facturée + */ + $propal = new Propal($db); + $propal->id = $_GET["propalid"]; + $propal->cloture($user, $_GET["statut"], $note); } -llxHeader(); - - - if ( $action == 'delete' ) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = $propalid;"; - if ( $db->query($sql) ) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = $propalid;"; + if ( $db->query($sql) ) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $propalid ;"; - if ( $db->query($sql) ) - { - print "Propal supprimée"; - } - else - { - print $db->error(); - print "

$sql"; - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $propalid ;"; + if ( $db->query($sql) ) + { + print "Propal supprimée"; + } + else + { + dolibarr_print_error($db); + } } - else + else { - print $db->error(); - print "

$sql"; + dolibarr_print_error($db); } - $propalid = 0; - $brouillon = 1; + $propalid = 0; + $brouillon = 1; } + +llxHeader(); + /* * * Mode fiche * - * */ if ($_GET["propalid"]) { - $propal = new Propal($db); - $propal->fetch($_GET["propalid"]); + $propal = new Propal($db); + $propal->fetch($_GET["propalid"]); - if ($valid == 1) + if ($valid == 1) { - $propal->valid($user->id); + $propal->valid($user->id); } - /* - * - */ - print "

'.$langs->trans("Ref").''.$langs->trans("Product").''.$langs->trans("Price").''.$langs->trans("Discount").''.$langs->trans("Qty").'
[$objp->ref]
".img_object($langs->trans(""),"product")." ".$objp->ref."'.$objp->product.'".price($objp->price)."'.$objp->remise_percent.'%
 '.$objp->product.'
'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''.img_object($langs->trans("Showcompany"),"company").' '.dolibarr_trunc($obj->nom,50).'
'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''.img_object($langs->trans("Showcompany"),"company").' '.dolibarr_trunc($obj->nom,44).'
"; - print ""; - print "
Proposition commerciale : $propal->ref
"; - /* - * - */ - $sql = "SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."socpeople as x"; - $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = ".$propal->id; + /* + * + */ + print ""; + print ""; + print "
Proposition commerciale : $propal->ref
"; + /* + * + */ + $sql = "SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."socpeople as x"; + $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = ".$propal->id; - $result = $db->query($sql); + $result = $db->query($sql); - if ( $result ) { - $obj = $db->fetch_object($result); - - if ($db->num_rows()) { - - $color1 = "#e0e0e0"; + if ( $result ) + { + $obj = $db->fetch_object($result); - print ''; + if ($db->num_rows()) + { + $color1 = "#e0e0e0"; - print ''; - print ""; - // + print '
'.$langs->trans("Company").''.$obj->nom.'Note :
". nl2br($obj->note)."
'; - print ''; + print ''; + print ""; + // - if ($obj->fk_projet) - { - $projet = new Project($db); - $projet->fetch($obj->fk_projet); - print ''; - } - print ""; - /* - * - */ + print ''; - print ""; - /* - * - */ + if ($obj->fk_projet) + { + $projet = new Project($db); + $projet->fetch($obj->fk_projet); + print ''; + } + print ""; + /* + * + */ - print ""; + print ""; + /* + * + */ - /* - * - */ + print ""; - $totalht = $propal->price ; + /* + * + */ - print ""; - /* - * - */ - print ''; - /* - * - */ - print ""; - $file = $conf->propal->dir_output. "/$obj->ref/$obj->ref.pdf"; - $relativepath = "$obj->ref/$obj->ref.pdf"; + $totalht = $propal->price ; - if (file_exists($file)) { - print ''; - } - print ''; - /* - * - */ - print ''; + print ""; + /* + * + */ + print ''; + /* + * + */ + print ""; + $file = $conf->propal->dir_output. "/$obj->ref/$obj->ref.pdf"; + $relativepath = "$obj->ref/$obj->ref.pdf"; - print ''; + if (file_exists($file)) { + print ''; + } + print ''; + /* + * + */ + print ''; + + print ''; - print "
'.$langs->trans("Date").''.dolibarr_print_date($obj->dp).'
'.$langs->trans("Company").''.$obj->nom.'Note :
". nl2br($obj->note)."
'.$langs->trans("Project").''; - print ''; - print $projet->title.'
Destinataire$obj->firstname $obj->name <$obj->email>
'.$langs->trans("Date").''.dolibarr_print_date($obj->dp).'
".$langs->trans("AmountHT")."".price($obj->price + $obj->remise)." euros
'.$langs->trans("Project").''; + print ''; + print $projet->title.'
Destinataire$obj->firstname $obj->name <$obj->email>
".$langs->trans("Discount")."".price($obj->remise)." euros
".$langs->trans("AmountHT")."".price($obj->price + $obj->remise)." euros
".$langs->trans("Discount")."".price($obj->remise)." euros
".$langs->trans("TotalHT")."".price($totalht)." euros
'.$langs->trans("Author").''; - $author = new User($db, $obj->fk_user_author); - $author->fetch(''); - print $author->fullname.'
".$langs->trans("Propal")." PDF'.$obj->ref.'.pdf
'.$langs->trans("Status").' :'.$obj->lst.'
".$langs->trans("TotalHT")."".price($totalht)." euros
'.$langs->trans("Author").''; + $author = new User($db, $obj->fk_user_author); + $author->fetch(''); + print $author->fullname.'
".$langs->trans("Propal")." PDF
'.$obj->ref.'.pdf
'.$langs->trans("Status").' :'.$obj->lst.'
"; + print ""; - if ($action == 'statut') - { - print "
id."\" method=\"post\">"; - print ""; - print "'; - print '

'; - print "
"; - } - + if ($action == 'statut') + { + print "
id."\" method=\"post\">"; + print ""; + print "'; + print '

'; + print "
"; + } - print ""; - /* - * - */ - print "
"; - /* - * Factures associees - */ - $sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = ".$propal->id; - $result = $db->query($sql); - if ($result) - { - $num_fac_asso = $db->num_rows(); - $i = 0; $total = 0; - print "
"; - if ($num_fac_asso > 1) - { - print_titre("Factures associées"); - } - else - { - print_titre("Facture associée"); - } - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num_fac_asso) - { - $objp = $db->fetch_object(); - $var=!$var; - print ""; - print "\n"; - print "\n"; - if ($objp->fk_user_author <> $user->id) - { - $fuser = new User($db, $objp->fk_user_author); - $fuser->fetch(); - print "\n"; - } - else - { - print "\n"; - } - print ''; - print ""; - $total = $total + $objp->total; - $i++; - } - print "\n"; - print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Author").''.$langs->trans("Price").'
facid\">$objp->facnumber"; - if ($objp->paye) - { - print " (payée)"; - } - print "".strftime("%d %B %Y",$objp->df)."".$fuser->fullname."".$user->fullname."'.price($objp->total).'
".$langs->trans("TotalHT").": $total ".$conf->monnaie."
"; - $db->free(); - } - print "
"; - /* - * Que si le module commande est actif ! - * - */ - if($conf->commande->enabled) { - $nb_commande = sizeof($propal->commande_liste_array()); - if ($nb_commande > 0) - { - $coms = $propal->commande_liste_array(); - print '
'; - - if ($nb_commande == 1) - - { - print "\n"; - } - else - { - print "\n"; - - for ($i = 0 ; $i < $nb_commande ; $i++) - { - print '\n"; - print "\n"; - } - } - print "
Commande rattachée : "; - print ''; - print img_file(); - print ' '.$coms[$i].""; - print "
Commandes rattachées
'.$coms[$i]."
"; - } - } + print ""; + + print "
"; + + /* + * Factures associees + */ + $sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = ".$propal->id; + + $result = $db->query($sql); + if ($result) + { + $num_fac_asso = $db->num_rows($result); + $i = 0; $total = 0; + print "
"; + if ($num_fac_asso > 1) + { + print_titre("Factures associées"); + } + else + { + print_titre("Facture associée"); + } + print ''; + print ""; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + while ($i < $num_fac_asso) + { + $objp = $db->fetch_object(); + $var=!$var; + print ""; + print "\n"; + print "\n"; + if ($objp->fk_user_author <> $user->id) + { + $fuser = new User($db, $objp->fk_user_author); + $fuser->fetch(); + print "\n"; + } + else + { + print "\n"; + } + print ''; + print ""; + $total = $total + $objp->total; + $i++; + } + print "\n"; + print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Author").''.$langs->trans("Price").'
facid\">$objp->facnumber"; + if ($objp->paye) + { + print " (payée)"; + } + print "".dolibarr_print_date($objp->df)."".$fuser->fullname."".$user->fullname."'.price($objp->total).'
".$langs->trans("TotalHT")."".price($total)."
"; + $db->free(); + } + print "
"; + + /* + * Que si le module commande est actif ! + */ + if($conf->commande->enabled) + { + $nb_commande = sizeof($propal->commande_liste_array()); + if ($nb_commande > 0) + { + $coms = $propal->commande_liste_array(); + print '
'; + + if ($nb_commande == 1) + { + print "\n"; + } + else + { + print "\n"; + + for ($i = 0 ; $i < $nb_commande ; $i++) + { + print '\n"; + print "\n"; + } + } + print "
Commande rattachée : "; + print ''; + print img_file(); + print ' '.$coms[$i].""; + print "
Commandes rattachées
'.$coms[$i]."
"; + } + } + + /* + * + * Actions + * + */ + if ($obj->statut <> 4 && $user->societe_id == 0) + { + print '
'; + + if ($obj->statut == 2 && $user->rights->facture->creer) + { + print '"; + } + else + { + print ''; + } + + print ''; + print ''; + print ''; + + if ($obj->statut == 2 && $num_fac_asso) + { + print ""; + } + else + { + print ''; + } + print "
'; + print "id."&action=create\">Emettre une facture----[id."&action=setstatut&statut=4\">Facturée]-
"; + } + + } else { + print "Num rows = " . $db->num_rows(); + print "

$sql"; + } + + /* + * Produits + */ + print_titre("Produits"); + + print ''; + print ""; + print ''; + print ''; + + $sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt, ".MAIN_DB_PREFIX."product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal =".$propal->id; + $sql .= " ORDER BY pt.rowid ASC"; + if ($db->query($sql)) + { + $num = $db->num_rows(); + $i = 0; + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object(); + $var=!$var; + print "\n"; + print ''; + print ""; + print ''; + print "\n"; + $i++; + } + } + + $sql = "SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt WHERE pt.fk_propal = ".$propal->id." AND pt.fk_product = 0"; + $sql .= " ORDER BY pt.rowid ASC"; + if ($db->query($sql)) + { + $num = $db->num_rows(); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object(); + $var=!$var; + print "\n"; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } + } + else + { + print $sql; + } + + print '
'.$langs->trans("Ref").''.$langs->trans("Product").''.$langs->trans("Price").''.$langs->trans("Discount").''.$langs->trans("Qty").'
[$objp->ref]'.$objp->product.'".price($objp->price)."'.$objp->remise_percent.' %".$objp->qty."
 '.$objp->product.''.price($objp->price).''.$objp->remise_percent.' %".$objp->qty."
'; + + + /* + * Voir le suivi des actions + */ + if ($suivi) + { + $validor = new User($db, $obj->fk_user_valid); + $validor->fetch(''); + $cloturor = new User($db, $obj->fk_user_cloture); + $cloturor->fetch(''); + + print '

Cacher le suivi des actions '; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + print '
 NomDate
Création'.$author->fullname.''.$obj->datec.'
Validation'.$validor->fullname.' '.$obj->date_valid.' 
Cloture'.$cloturor->fullname.' '.$obj->date_cloture.' 
'; + } + else + { + print '

Voir le suivi des actions '; + } - /* - * - * Actions - * - */ - if ($obj->statut <> 4 && $user->societe_id == 0) - { - print '
'; - - if ($obj->statut == 2 && $user->rights->facture->creer) - { - print '"; - } - else - { - print ''; - } - - print ''; - print ''; - print ''; - - if ($obj->statut == 2 && $num_fac_asso) - { - print ""; - } - else - { - print ''; - } - print "
'; - print "id."&action=create\">Emettre une facture----[id."&action=setstatut&statut=4\">Facturée]-
"; - } - /* - * - */ - } else { - print "Num rows = " . $db->num_rows(); - print "

$sql"; + dolibarr_print_error($db); } - /* - * Produits - */ - print_titre("Produits"); - - print ''; - print ""; - print ''; - print ''; - - $sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent"; - $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt, ".MAIN_DB_PREFIX."product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal =".$propal->id; - $sql .= " ORDER BY pt.rowid ASC"; - if ($db->query($sql)) - { - $num = $db->num_rows(); - $i = 0; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object(); - $var=!$var; - print "\n"; - print ''; - print ""; - print ''; - print "\n"; - $i++; - } - } - - $sql = "SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent"; - $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt WHERE pt.fk_propal = ".$propal->id." AND pt.fk_product = 0"; - $sql .= " ORDER BY pt.rowid ASC"; - if ($db->query($sql)) - { - $num = $db->num_rows(); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object(); - $var=!$var; - print "\n"; - print ''; - print ''; - print ''; - print "\n"; - $i++; - } - } - else - { - print $sql; - } - - print '
'.$langs->trans("Ref").''.$langs->trans("Product").''.$langs->trans("Price").''.$langs->trans("Discount").''.$langs->trans("Qty").'
[$objp->ref]'.$objp->product.'".price($objp->price)."'.$objp->remise_percent.' %".$objp->qty."
 '.$objp->product.''.price($objp->price).''.$objp->remise_percent.' %".$objp->qty."
'; - - - /* - * Voir le suivi des actions - * - * - * - */ - if ($suivi) - { - $validor = new User($db, $obj->fk_user_valid); - $validor->fetch(''); - $cloturor = new User($db, $obj->fk_user_cloture); - $cloturor->fetch(''); - - print '

Cacher le suivi des actions '; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - print '
 NomDate
Création'.$author->fullname.''.$obj->datec.'
Validation'.$validor->fullname.' '.$obj->date_valid.' 
Cloture'.$cloturor->fullname.' '.$obj->date_cloture.' 
'; - } - else - { - print '

Voir le suivi des actions '; - } - - } else { - print $db->error(); - print "

$sql"; - } - - - /* - * - * - * - */ } else { - /* - * - * Mode Liste des propales - * - */ - if ($sortfield == "") + /** + * + * Mode Liste des propales + * + */ + + if (! $sortfield) $sortfield="p.datep"; + if (! $sortorder) $sortorder="DESC"; + if ($page == -1) $page = 0 ; + + $pageprev = $page - 1; + $pagenext = $page + 1; + $limit = $conf->liste_limit; + $offset = $limit * $page ; + + $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 in(2,4)"; + + if ($socidp) { - $sortfield="p.datep"; - } - if ($sortorder == "") - { - $sortorder="DESC"; + $sql .= " AND s.idp = $socidp"; } - if ($page == -1) + if ($viewstatut <> '') { - $page = 0 ; + $sql .= " AND c.id = $viewstatut"; } - $pageprev = $page - 1; - $pagenext = $page + 1; - $limit = $conf->liste_limit; - $offset = $limit * $page ; - - $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 in(2,4)"; - - if ($socidp) - { - $sql .= " AND s.idp = $socidp"; + if ($month > 0) + { + $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; } - if ($viewstatut <> '') + if ($year > 0) { - $sql .= " AND c.id = $viewstatut"; + $sql .= " AND date_format(p.datep, '%Y') = $year"; } - if ($month > 0) + $sql .= " ORDER BY $sortfield $sortorder, p.rowid DESC "; + $sql .= $db->plimit($limit + 1,$offset); + + if ( $db->query($sql) ) { - $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; + $num = $db->num_rows(); + + print_barre_liste("Propositions commerciales", $page, "propal.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); + + $i = 0; + print ""; + print ''; + print_liste_field_titre($langs->trans("Ref"),"propal.php","p.ref","","&year=$year&viewstatut=$viewstatut",'',$sortfield); + print_liste_field_titre($langs->trans("Company"),"propal.php","s.nom","&viewstatut=$viewstatut","",'',$sortfield); + print_liste_field_titre($langs->trans("Date"),"propal.php","p.datep","&viewstatut=$viewstatut","",'align="right" colspan="2"',$sortfield); + print_liste_field_titre($langs->trans("Price"),"propal.php","p.price","&viewstatut=$viewstatut","",'align="right"',$sortfield); + print_liste_field_titre($langs->trans("Status"),"propal.php","p.fk_statut","&viewstatut=$viewstatut","",'align="center"',$sortfield); + print "\n"; + + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object(); + + $var=!$var; + print ""; + + print '\n"; + + print "\n"; + + $now = time(); + $lim = 3600 * 24 * 15 ; + + if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) + { + print ""; + } + else + { + print ""; + } + + print "\n"; + + print "\n"; + print "\n"; + print "\n"; + + $i++; + } + + print "
'.img_object($langs->trans("ShowPropal"),"propal")." \n"; + print ''.$objp->ref."idp\">$objp->nom > 15 jours "; + $y = strftime("%Y",$objp->dp); + $m = strftime("%m",$objp->dp); + + print strftime("%d",$objp->dp)."\n"; + print " "; + print strftime("%B",$objp->dp)."\n"; + print " "; + print strftime("%Y",$objp->dp)."".price($objp->price)."$objp->statut
"; + $db->free(); } - - if ($year > 0) + else { - $sql .= " AND date_format(p.datep, '%Y') = $year"; - } - - $sql .= " ORDER BY $sortfield $sortorder, p.rowid DESC "; - $sql .= $db->plimit($limit + 1,$offset); - - if ( $db->query($sql) ) - { - $num = $db->num_rows(); - - print_barre_liste("Propositions commerciales", $page, "propal.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); - - $i = 0; - print ""; - print ''; - print_liste_field_titre($langs->trans("Ref"),"propal.php","p.ref","","&year=$year&viewstatut=$viewstatut",'',$sortfield); - print_liste_field_titre($langs->trans("Company"),"propal.php","s.nom","&viewstatut=$viewstatut","",'',$sortfield); - print_liste_field_titre($langs->trans("Date"),"propal.php","p.datep","&viewstatut=$viewstatut","",'align="right" colspan="2"',$sortfield); - print_liste_field_titre($langs->trans("Price"),"propal.php","p.price","&viewstatut=$viewstatut","",'align="right"',$sortfield); - print_liste_field_titre($langs->trans("Status"),"propal.php","p.fk_statut","&viewstatut=$viewstatut","",'align="center"',$sortfield); - print "\n"; - - while ($i < min($num, $limit)) - { - $objp = $db->fetch_object(); - - $var=!$var; - print ""; - - print '\n"; - - print "\n"; - - $now = time(); - $lim = 3600 * 24 * 15 ; - - if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) - { - print ""; - } - else - { - print ""; - } - - print "\n"; - - print "\n"; - print "\n"; - print "\n"; - - $i++; - } - - print "
'.img_object($langs->trans("ShowPropal"),"propal")." \n"; - print ''.$objp->ref."idp\">$objp->nom > 15 jours "; - $y = strftime("%Y",$objp->dp); - $m = strftime("%m",$objp->dp); - - print strftime("%d",$objp->dp)."\n"; - print " "; - print strftime("%B",$objp->dp)."\n"; - print " "; - print strftime("%Y",$objp->dp)."".price($objp->price)."$objp->statut
"; - $db->free(); - } - else - { - print $db->error(); - print "
$sql"; + dolibarr_print_error($db); } } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); + +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index cb3215341ab..d0bfc26fa83 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -84,5 +84,5 @@ ToBill= RemainderToBill=Reste à facturer SendBillByMail=Envoyer la facture par mail SendReminderBillByMail=Envoyer une relance par mail -RelatedCommercialProposals=Propositions commercials associées +RelatedCommercialProposals=Propositions commerciales associées MenuToValid=A valider