diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index c839aebc324..3827640e145 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -41,7 +41,7 @@ if (!$user->rights->propale->lire) accessforbidden(); if ($conf->projet->enabled) require_once '../project.class.php'; -if($conf->commande->enabled) require_once '../commande/commande.class.php'; +if ($conf->commande->enabled) require_once '../commande/commande.class.php'; require_once('./propal_model_pdf.class.php'); require_once('../propal.class.php'); require_once('../actioncomm.class.php'); @@ -891,19 +891,29 @@ if ($_GET['propalid']) /* - * Si le module commandes est activé ... + * Commandes rattachées */ if($conf->commande->enabled) { - $nb_commande = sizeof($propal->commande_liste_array()); - if ($nb_commande > 0) + $coms = $propal->associated_orders(); + if (sizeof($coms) > 0) { - $coms = $propal->associated_orders(); - print '
'; - print ''; - for ($i = 0 ; $i < $nb_commande ; $i++) + print '
'; + print_titre($langs->trans('RelatedOrders')); + print '
Commande(s) rattachée(s)
'; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + for ($i = 0 ; $i < sizeof($coms) ; $i++) { - print '\n"; + $var=!$var; + print '\n"; + print ''; + print ''; print "\n"; } print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").'
'.$coms[$i]->ref."
'; + print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."'.dolibarr_print_date($coms[$i]->date).''.$coms[$i]->total_ttc.'
'; @@ -927,11 +937,12 @@ if ($_GET['propalid']) print_titre($langs->trans('ActionsOnPropal')); $i = 0; $total = 0; + $var=true; + print ''; print ''; print "\n"; - $var=true; while ($i < $num) { $objp = $db->fetch_object($result); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 55bb5545e4b..7ad0215152e 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -612,63 +612,62 @@ else $var=true; while ($i < $num) - { - $objp = $db->fetch_object($result); - - $var=!$var; - print ""; - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print "\n"; - } - print ''; - print ''; - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - print '\n"; - if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] == '') - { - print ''; - print ''; - } - else - { - print ''; - } - print ""; - - if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) - { - print ""; - print ''; - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print '' . "\n"; - print "\n"; - } - $i++; - $var=!$var; - } + { + $objp = $db->fetch_object($result); + + $var=!$var; + print ""; + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print "\n"; + } + print ''; + print ''; + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] == '') + { + print ''; + print ''; + } + else + { + print ''; + } + print ""; + + if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) + { + print ""; + print ''; + print ''; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print '' . "\n"; + print "\n"; + } + $i++; + } $db->free(); } else @@ -736,7 +735,8 @@ else print ""; } - print "
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->tva_tx.' %'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice)."'; - print img_edit(); - print ''; - print img_delete(); - print '  
%
'; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->tva_tx.'%'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice)."'; + print img_edit(); + print ''; + print img_delete(); + print '  
%

"; + print ""; + /* * Fin Ajout ligne * @@ -776,7 +776,7 @@ else $nb_expedition = $commande->nb_expedition(); if ($user->rights->commande->valider && $nb_expedition == 0) { - print ''.$langs->trans("Cancel").''; + print ''.$langs->trans("CancelOrder").''; } } @@ -787,6 +787,75 @@ else print '
'; + /* + * Documents générés + * + */ + $file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; + $relativepath = $commande->ref."/".$commande->ref.".pdf"; + + $var=true; + + if (file_exists($file)) + { + + print_titre($langs->trans("Documents")); + print ''; + + print ""; + print ''; + print ''; + print ''; + print ''; + + print "
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; + + print '
'; + } + + /* + * Liste des factures + */ + $sql = "SELECT f.rowid,f.facnumber, f.total_ttc, ".$db->pdate("f.datef")." as df"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."co_fa as cf"; + $sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + print_titre($langs->trans("RelatedBills")); + $i = 0; $total = 0; + print ''; + print '"; + print ''; + print ''; + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + print ''; + print ''; + print ''; + $i++; + } + print "
'.$langs->trans("Ref")."'.$langs->trans("Date").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.''.dolibarr_print_date($objp->df).''.$objp->total_ttc.'
"; + } + } + else + { + dolibarr_print_error($db); + } + + + print '
'; + /* * Liste des expéditions */ @@ -822,69 +891,9 @@ else { dolibarr_print_error($db); } - print " "; - - /* - * Liste des factures - */ - $sql = "SELECT f.rowid,f.facnumber,".$db->pdate("f.datef")." as df"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."co_fa as cf"; - $sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - if ($num) - { - print_titre($langs->trans("Bills")); - $i = 0; $total = 0; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; - print "\n"; - $i++; - } - print "
".$langs->trans("Bill")."".$langs->trans("Date")."
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.'".dolibarr_print_date($objp->df)."
"; - } - } - else - { - dolibarr_print_error($db); - } - print " 
"; - /* - * Documents générés - * - */ - $file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; - $relativepath = $commande->ref."/".$commande->ref.".pdf"; - - $var=true; - - if (file_exists($file)) - { + print ""; - print_titre($langs->trans("Documents")); - print ''; - - print ""; - print ''; - print ''; - print ''; - print ''; - - print "
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; - print ''; - } /* * Classe la commande dans un projet diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 46fdb423787..475b6ac98db 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -63,26 +63,26 @@ if ($socidp) $sql .= " AND c.fk_soc = $socidp"; } -if ( $db->query($sql) ) +if ( $db->query($sql) ) { - $langs->load("orders"); - $num = $db->num_rows(); - if ($num) + $langs->load("orders"); + $num = $db->num_rows(); + if ($num) { - $i = 0; - print ''; - print ''; - print ''; - $var = True; - while ($i < $num) - { - $var=!$var; - $obj = $db->fetch_object(); - print ""; - print ''; - $i++; - } - print "
'.$langs->trans("OrdersToValid").'
rowid\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'

"; + $i = 0; + print ''; + print ''; + print ''; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object(); + print ""; + print ''; + $i++; + } + print "
'.$langs->trans("DraftOrders").'
rowid\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,24).'

"; } } diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php index 31e18e40572..612fe8d99f5 100644 --- a/htdocs/compta/commande/fiche.php +++ b/htdocs/compta/commande/fiche.php @@ -211,11 +211,11 @@ if ($_GET["id"] > 0) { print "".stripslashes(nl2br($objp->description))."\n"; } - print ''.$objp->tva_tx.' %'; + print ''.$objp->tva_tx.'%'; print ''.$objp->qty.''; if ($objp->remise_percent > 0) { - print ''.$objp->remise_percent." %\n"; + print ''.$objp->remise_percent."%\n"; } else { @@ -226,7 +226,6 @@ if ($_GET["id"] > 0) print ""; $i++; - $var=!$var; } $db->free($result); } @@ -236,11 +235,8 @@ if ($_GET["id"] > 0) } print ''; - /* - * - * - */ - print '
'; + print ''; + /* * Barre d'actions @@ -264,6 +260,8 @@ if ($_GET["id"] > 0) } + print "
"; + /* * Documents générés @@ -276,7 +274,6 @@ if ($_GET["id"] > 0) if (file_exists($file)) { - print "
"; print_titre($langs->trans("Documents")); print ''; @@ -287,75 +284,89 @@ if ($_GET["id"] > 0) print ''; print "
\n"; - 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."co_fa as fp WHERE fp.fk_facture = f.rowid AND fp.fk_commande = ".$commande->id; - - if ($db->query($sql)) - { - $num_fac_asso = $db->num_rows(); - $i = 0; $total = 0; + /* + * Liste des factures + */ + $sql = "SELECT f.rowid,f.facnumber, f.total_ttc, ".$db->pdate("f.datef")." as df"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."co_fa as cf"; + $sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + print '
'; + print_titre($langs->trans("RelatedBills")); + $i = 0; $total = 0; + print ''; + print '"; + print ''; + print ''; + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + print ''; + print ''; + print ''; + $i++; + } + print "
'.$langs->trans("Ref")."'.$langs->trans("Date").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.''.dolibarr_print_date($objp->df).''.$objp->total_ttc.'
"; + } + } + else + { + dolibarr_print_error($db); + } - if ($num_fac_asso) - { - $var=false; - print "
"; + print '
'; - print_titre($langs->trans("Bills")); - - 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").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.''; - if ($objp->paye) - { - print " (payée)"; - } - print "".dolibarr_print_date($objp->df)."".$fuser->fullname."".$user->fullname."'.price($objp->total).'
".$langs->trans("TotalHT").": $total ".$langs->trans("Currency".$conf->monnaie)."
"; - } - $db->free(); - } - else - { - dolibarr_print_error($db); - } + /* + * Liste des expéditions + */ + $sql = "SELECT e.rowid,e.ref,".$db->pdate("e.date_expedition")." as de"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " WHERE e.fk_commande = ". $commande->id; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + print_titre($langs->trans("Sendings")); + $i = 0; $total = 0; + print ''; + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + print ''; + print "\n"; + $i++; + } + print "
".$langs->trans("Sendings")."".$langs->trans("Date")."
'.img_object($langs->trans("ShowSending"),"sending").' '.$objp->ref.'".dolibarr_print_date($objp->de)."
"; + } + } + else + { + dolibarr_print_error($db); + } + print "
"; } else diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b08cf82ae0a..98db9ccc3f8 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1311,25 +1311,21 @@ else } + print '
'; + /* * Documents générés - * * Le fichier de facture détaillée est de la forme - * * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse - * */ $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); $facref = str_replace($forbidden_chars,"_",$fac->ref); $file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf"; - $relativepath = "${facref}/${facref}.pdf"; $var=true; - print '
'; - if (file_exists($file)) { print "
\n"; @@ -1363,6 +1359,53 @@ else print "
\n"; } + + /* + * Propales + */ + $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; $total = 0; + print "
"; + print_titre($langs->trans("RelatedCommercialProposals")); + + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ""; + print ''; + print "\n"; + print ''; + print ""; + $total = $total + $objp->price; + $i++; + } + print "\n"; + print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'".dolibarr_print_date($objp->dp)."'.price($objp->price).'
 ".$langs->trans("TotalHT")."".price($total)."
"; + } + } + else + { + dolibarr_print_error($db); + } + + print '
'; /* @@ -1506,51 +1549,6 @@ else print '
'; } - /* - * Propales - */ - - $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid"; - $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - $i = 0; $total = 0; - print "
"; - print_titre($langs->trans("RelatedCommercialProposals")); - - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ""; - print ''; - print "\n"; - print ''; - print ""; - $total = $total + $objp->price; - $i++; - } - print "\n"; - print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'".dolibarr_print_date($objp->dp)."'.price($objp->price).'
 ".$langs->trans("TotalHT")."".price($total)."
"; - } - } - else - { - dolibarr_print_error($db); - } } else { diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 32828a9ba3a..7a99a62601d 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -32,9 +32,9 @@ require("./pre.inc.php"); $user->getrights('facture'); $user->getrights('propale'); if (!$user->rights->propale->lire) -accessforbidden(); - + accessforbidden(); +if ($conf->commande->enabled) require_once '../commande/commande.class.php'; require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); require_once("../project.class.php"); require_once("../propal.class.php"); @@ -486,6 +486,37 @@ if ($_GET["propalid"]) print ''; } + + /* + * Commandes rattachées + */ + if($conf->commande->enabled) + { + $coms = $propal->associated_orders(); + if (sizeof($coms) > 0) + { + print '
'; + print_titre($langs->trans('RelatedOrders')); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + for ($i = 0 ; $i < sizeof($coms) ; $i++) + { + $var=!$var; + print '\n"; + print ''; + print ''; + print "\n"; + } + print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").'
'; + print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."'.dolibarr_print_date($coms[$i]->date).''.$coms[$i]->total_ttc.'
'; + } + } + /* * Factures associees @@ -504,8 +535,7 @@ if ($_GET["propalid"]) print ''; print ""; print ''; - print ''; - print ''; + print ''; print ''; print "\n"; @@ -521,68 +551,65 @@ if ($_GET["propalid"]) print " (payée)"; } 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 ''; print ""; $total = $total + $objp->total; $i++; } - print "\n"; + print "\n"; print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Author").''.$langs->trans("Date").''.$langs->trans("Price").'
".dolibarr_print_date($objp->df)."".$fuser->fullname."".$user->fullname."'.dolibarr_print_date($objp->df).''.price($objp->total).'
".$langs->trans("TotalHT")."".price($total)."
".$langs->trans("TotalHT")."".price($total)."
"; $db->free(); } - /* - * Commandes associées - */ - 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 '
'; - // \todo Mettre ici les traces des envois par mail - - - - + + /* + * Liste des actions propres à la propal + */ + $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + $sql .= ' WHERE a.fk_soc = '.$obj->idp.' AND a.propalrowid = '.$propal->id ; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + print_titre($langs->trans('ActionsOnPropal')); + $i = 0; + $total = 0; + $var=true; + + print ''; + print ''; + print "\n"; + + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print '\n"; + print ''; + $authoract = new User($db); + $authoract->id = $objp->fk_user_author; + $authoract->fetch(''); + print ''; + print "\n"; + $i++; + } + print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da)."'.stripslashes($objp->label).''.$authoract->code.'
'; + } + } + else + { + dolibarr_print_error($db); + } + print '
';