diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 87f99716ccb..6afbbd11b5f 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -144,6 +144,7 @@ if ($user->rights->facture->lire) $i = 0; print ''; print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&socidp=$socidp","",$sortfield); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&socidp=$socidp",'align="center"',$sortfield); print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&socidp=$socidp",'align="center"',$sortfield); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index c167a6db217..4479ee2f30f 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -32,6 +32,9 @@ require("./pre.inc.php"); require("../propal.class.php"); require("../facture.class.php"); +$langs->load("bills"); + + $mesg = ''; if (!$user->rights->produit->lire) accessforbidden(); @@ -199,22 +202,6 @@ if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> $langs->trans("Cancel } } } -if ($_GET["action"] == 'remove_fourn') -{ - $product = new Product($db); - if( $product->fetch($_GET["id"]) ) - { - if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0) - { - $_GET["action"] = ''; - $mesg = $langs->trans("SupplierRemoved"); - } - else - { - $_GET["action"] = ''; - } - } -} if ($_POST["cancel"] == $langs->trans("Cancel")) { @@ -233,7 +220,6 @@ llxHeader("","",$langs->trans("CardProduct0")); if ($_GET["action"] == 'create' && $user->rights->produit->creer) { $html = new Form($db); - $nbligne=0; $product = new Product($db); if ($_error == 1) { @@ -356,52 +342,37 @@ if ($_GET["id"]) $head[$h][1] = $langs->trans('Statistics'); $h++; + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Bills'); + $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); - print($mesg); + print '
'; + print ""; - print ''; + + $nblignes=6; + if ($product->type == 0 && $conf->stock->enabled) $nblignes++; + if ($product->type == 1) $nblignes++; + + // Reference + print ''; + print ''; print ''; - print ''; + + // Libellé + print ''; print ''; // Prix print ''; - if ($product->type == 0) $nbligne=5; - else $nbligne=5; - print ''; + print ''; // Statut print ''; + // TVA $langs->load("bills"); print ''; - if ($product->type == 0 && defined("MAIN_MODULE_STOCK")) + + // Stock + if ($product->type == 0 && $conf->stock->enabled) { print ''; if ($product->no_stock) @@ -431,8 +405,11 @@ if ($_GET["id"]) } print ''; } + + // Description print ''; + // Durée if ($product->type == 1) { print ''; } + print "
'.$langs->trans("Ref").''.$product->ref.''.$langs->trans("Ref").''.$product->ref.''; + // Photo + $nbphoto=$product->show_photo($conf->produit->dir_output,1); + print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).''; - - $sql = "SELECT s.nom, s.idp"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf"; - $sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id; - $sql .= " ORDER BY lower(s.nom)"; - - $result=$db->query($sql); - if ($result) - { - $num_fournisseur = $db->num_rows($result); - $i = 0; - print ''; - print ''; - $var=True; - while ($i < $num_fournisseur) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Suppliers").'
'.$objp->nom.''; - print ''; - print img_disable($langs->trans("Remove")).'
'; - $db->free($result); - } - print '
'.$langs->trans("Status").''; @@ -409,9 +380,12 @@ if ($_GET["id"]) else print $langs->trans("NotOnSell"); print '
'.$langs->trans("VATRate").''.$product->tva_tx.' %
'.$langs->trans("Stock").'
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Duration").''.$product->duration_value.' '; @@ -448,36 +425,11 @@ if ($_GET["id"]) print '

\n"; print "\n"; } - - /* - * Ajouter un fournisseur - */ - if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer) - { - $langs->load("suppliers"); - - print_titre($langs->trans("AddSupplier")); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Suppliers").''; - - $html=new Form($db); - $html->select_societes('','id_fourn','fournisseur=1'); - - print ''.$langs->trans("Ref").'
'; - print ' '; - print '
'; - print '
'; - } } /* @@ -587,24 +539,11 @@ if ($_GET["action"] == '') print $langs->trans("AddPhoto").''; } - if ($user->rights->produit->modifier || $user->rights->produit->creer) - { - print ''; - print $langs->trans("AddSupplier").''; - } } print "\n
\n"; -/* - * Photo - */ -if ($_GET["id"] && $_GET["action"]=='') -{ - $nbphoto=$product->show_photo($conf->produit->dir_output,1); -} - if ($_GET["id"] && $_GET["action"] == '' && $product->envente) { $htmls = new Form($db); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 35881eea7f0..ba4dcb95e9f 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -34,6 +34,7 @@ require("../facture.class.php"); $langs->load("products"); $langs->load("suppliers"); +$langs->load("bills"); $user->getrights('produit'); $user->getrights('propale'); @@ -50,6 +51,36 @@ $types[1] = $langs->trans("Service"); * Actions */ +if ($_GET["action"] == 'remove_fourn') +{ + $product = new Product($db); + if( $product->fetch($_GET["id"]) ) + { + if ($_GET["qty"]) { // On supprime une quantité + if ($product->remove_price($user, $_GET["id_fourn"], $_GET["qty"]) > 0) + { + $_GET["action"] = ''; + $mesg = '
'.$langs->trans("PriceRemoved").'.
'; + } + else + { + $_GET["action"] = ''; + } + } + else { // On supprime un fournisseur + if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0) + { + $_GET["action"] = ''; + $mesg = '
'.$langs->trans("SupplierRemoved").'.
'; + } + else + { + $_GET["action"] = ''; + } + } + } +} + if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel")) { @@ -67,8 +98,12 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc $mesg='
'.$product->error.'
'; } } - - if ($_POST["qty"]) { + else { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'
'; + } + + if ($_POST["qty"] && $_POST["price"] > 0) { $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user); if ($ret < 0) { $error++; @@ -164,11 +199,12 @@ if ($_GET["id"]) $head[$h][1] = $langs->trans('Statistics'); $h++; + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Bills'); + $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); - print($mesg); - print ''; print ''; print ''; @@ -179,25 +215,32 @@ if ($_GET["id"]) if ($product->envente) print $langs->trans("OnSell"); else print $langs->trans("NotOnSell"); print ''; - + print '
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'

'; print "\n"; + if ($mesg) print($mesg); + // Formulaire ajout prix if ($_GET["action"] == 'add_price' && $user->rights->produit->creer) { $langs->load("suppliers"); - print '
'.$langs->trans("ChangeSupplierPrice").'
'; - + if ($_GET["id_fourn"]) { + print '
'.$langs->trans("ChangeSupplierPrice").'
'; + } else { + print '
'.$langs->trans("AddSupplierPrice").'
'; + } print ''; print ''; print ''; if ($_GET["id_fourn"]) { print ''; + $product->fetch_fourn_data($_GET["id_fourn"]); + print ''; } else { print ''; print ''; - print ''; + print ''; + print ''; print ''; @@ -229,7 +273,7 @@ if ($_GET["id"]) if ($_GET["action"] != 'add_price') { print ''; - print $langs->trans("AddSupplierPrice").''; + print $langs->trans("AddSupplier").''; } @@ -271,7 +315,7 @@ if ($_GET["id"]) $var=!$var; print ""; - print ''; + print ''; // Fournisseur print ''; @@ -291,10 +335,13 @@ if ($_GET["id"]) print $objp->quantity?price($objp->price / $objp->quantity):" "; print ''; - print ''; print ''; diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 81fb84202bf..1bb0b815731 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -32,6 +32,7 @@ require("../propal.class.php"); require("../facture.class.php"); $langs->load("products"); +$langs->load("bills"); $user->getrights('produit'); $user->getrights('propale'); @@ -115,6 +116,11 @@ if ($_GET["id"]) $head[$h][1] = $langs->trans('Statistics'); $h++; + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Bills'); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); print($mesg); @@ -183,10 +189,13 @@ if ($_GET["id"]) // Affiche photos if ($_GET["action"] != 'ajout_photo') { - print '
'; - $nbphoto=$product->show_photos($conf->produit->dir_output,1); + //print '
'; + //print '
'; + $nbphoto=$product->show_photos($conf->produit->dir_output,1,0,5); + + if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."

"; - print '
'; + //print '
'; } } } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 8279004a527..ce4cc7865dc 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -31,6 +31,7 @@ require("./pre.inc.php"); $langs->load("products"); +$langs->load("bills"); $user->getrights('produit'); @@ -115,6 +116,9 @@ $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans("Statistics"); $h++; +$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; +$head[$h][1] = $langs->trans('Bills'); +$h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 18f8c2b769f..62f5408aca9 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -18,156 +18,191 @@ * * $Id$ * $Source$ - * */ -/** \file htdocs/product/stats/facture.php +/** + \file htdocs/product/stats/facture.php \ingroup product, service - \brief Page des stats des factures pour un produit - \version $Revision$ + \brief Page des stats des factures pour un produit + \version $Revision$ */ require("./pre.inc.php"); require_once("../../facture.class.php"); +$langs->load("bills"); $mesg = ''; -if ($page == -1) -{ -$page = 0 ; -} -$limit = $conf->liste_limit; -$offset = $limit * $page ; - +$page = $_GET["page"]; +$sortfield=$_GET["sortfield"]; +$sortorder=$_GET["sortorder"]; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; +if ($page == -1) $page = 0; +$limit = $conf->liste_limit; +$offset = $limit * $page ; if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } llxHeader(); + /* - * + * Affiche fiche * */ if ($_GET["id"]) { - $product = new Product($db); - $result = $product->fetch($_GET["id"]); - - if ( $result ) - { - print_fiche_titre($langs->trans("Product").': '.$product->ref, $mesg); - - print '
'.$langs->trans("Supplier").''; $html=new Form($db); @@ -210,7 +253,8 @@ if ($_GET["id"]) print '
'.$langs->trans("Qty").''.$langs->trans("Price").'
'.$langs->trans("Price").'
 '; print '
'.$objp->nom.''.img_object($langs->trans("ShowCompany"),'company').' '.$objp->nom.''.$objp->ref_fourn.''; - if ($user->rights->produit->modifier) { - print ''.img_edit().""; + // Modifier-Supprimer + print ''; + if ($user->rights->produit->creer) { + print ''.img_edit().""; + print ''; } + print img_disable($langs->trans("Remove")).''; print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
'.$langs->trans("Ref").''.$product->ref.''.$langs->trans("Statistics").'
'.$langs->trans("Label").''.$product->libelle.''; - // Propals - if ($conf->propal->enabled) { - $langs->load("propal"); - print ''.$langs->trans("Proposals").' : '.$product->count_propale($socid); - print " (Proposé à ".$product->count_propale_client($socid)." clients)
"; - } - // Commande - if ($conf->commande->enabled) { - $langs->load("orders"); - print ''.$langs->trans("Orders").' : '.$product->count_facture($socid)."
"; - } - // Factures - if ($conf->facture->enabled) { - $langs->load("bills"); - print ''.$langs->trans("Bills").' : '.$product->count_facture($socid); - } - print '
'.$langs->trans("CurrentPrice").''.price($product->price).'
"; + $product = new Product($db); + $result = $product->fetch($_GET["id"]); - - print "
"; - print_barre_liste($langs->trans("Bills"),$page,"facture.php","&id=$product->id",$sortfield,$sortorder); - - $sql = "SELECT distinct(f.rowid), s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.fk_statut as statut,f.rowid as facid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d WHERE f.fk_soc = s.idp"; - $sql .= " AND d.fk_facture = f.rowid AND d.fk_product =".$product->id; - if ($socid) - { - $sql .= " AND f.fk_soc = $socid"; - } - $sql .= " ORDER BY $sortfield $sortorder "; - $sql .= $db->plimit( $limit ,$offset); + if ($result > 0) + { + /* + * En mode visu + */ - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - - $i = 0; - print ""; + $h=0; - print ''; - print_liste_field_titre($langs->trans("Ref"),"facture.php","s.idp","","&id=".$_GET["id"],'',$sortfield); - print_liste_field_titre($langs->trans("Company"),"facture.php","s.nom","","&id=".$_GET["id"],'',$sortfield); - print_liste_field_titre($langs->trans("Date"),"facture.php","f.datef","","&id=".$_GET["id"],'align="right"',$sortfield); - print_liste_field_titre($langs->trans("Amount"),"facture.php","f.amount","","&id=".$_GET["id"],'align="right"',$sortfield); - print_liste_field_titre($langs->trans("Status"),"facture.php","f.paye,f.fk_statut","","&id=".$_GET["id"],'align="center"',$sortfield); - print "\n"; - - if ($num > 0) - { - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - - print ""; - print '\n"; - print ''; - - if ($objp->df > 0 ) - { - print ""; - } - else - { - print "\n"; - } - - print "\n"; - - $fac=new Facture($db); - print ''; - - print "\n"; - $i++; - } - } - } - else { - dolibarr_print_error($db); - } - print "
'.img_object($langs->trans("ShowBill"),"bill").' '; - print $objp->facnumber; - print "'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.'"; - print strftime("%d %B %Y",$objp->df)."!!!".price($objp->amount)."'.$fac->LibStatut($objp->paye,$objp->statut).'
"; - $db->free(); + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Card"); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; + $head[$h][1] = $langs->trans("Price"); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $h++; + + if($product->type == 0) + { + if ($conf->stock->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][1] = $langs->trans("Stock"); + $h++; + } + } + + if ($conf->fournisseur->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; + $head[$h][1] = $langs->trans("Suppliers"); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans('Statistics'); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Bills'); + $hselected=$h; + $h++; + + + dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); + + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + + // Prix + print ''; + + // Statut + print ''; + + print "
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; + if ($product->envente) print $langs->trans("OnSell"); + else print $langs->trans("NotOnSell"); + print '
"; + + print "
"; + print ''; + + print_barre_liste($langs->trans("Bills"),$page,"facture.php","&id=$product->id",$sortfield,$sortorder); + + $sql = "SELECT s.nom, s.idp, s.code_client, f.facnumber, f.amount,"; + $sql.= " ".$db->pdate("f.datef")." as df, f.paye, f.fk_statut as statut, f.rowid as facid"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d WHERE f.fk_soc = s.idp"; + $sql.= " AND d.fk_facture = f.rowid AND d.fk_product =".$product->id; + if ($socid) + { + $sql .= " AND f.fk_soc = $socid"; + } + $sql .= " ORDER BY $sortfield $sortorder "; + $sql .= $db->plimit( $limit ,$offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $i = 0; + print ""; + + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.idp","","&id=".$_GET["id"],'',$sortfield); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield); + print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'align="right"',$sortfield); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="right"',$sortfield); + print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"f.amount","","&id=".$_GET["id"],'align="right"',$sortfield); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$_GET["id"],'align="center"',$sortfield); + print "\n"; + + if ($num > 0) + { + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + + print ""; + print '\n"; + print ''; + print "\n"; + print ""; + print "\n"; + $fac=new Facture($db); + print ''; + print "\n"; + $i++; + } + } + } + else { + dolibarr_print_error($db); + } + print "
'.img_object($langs->trans("ShowBill"),"bill").' '; + print $objp->facnumber; + print "'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'".$objp->code_client.""; + print dolibarr_print_date($objp->df)."".price($objp->amount)."'.$fac->LibStatut($objp->paye,$objp->statut).'
"; + print '
'; + $db->free($result); } } else { - print "Error"; + dolibarr_print_error(); } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php index 24227e72e0c..b1693a79918 100644 --- a/htdocs/product/stats/fiche.php +++ b/htdocs/product/stats/fiche.php @@ -145,6 +145,9 @@ if ($_GET["id"]) $hselected=$h; $h++; + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Bills'); + $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);