New: Ajout onglet liste des factures lis sur fiche produit
This commit is contained in:
parent
51b81b211a
commit
5c93dea0d6
@ -144,6 +144,7 @@ if ($user->rights->facture->lire)
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
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);
|
||||
|
||||
@ -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 '<table class="border" width="100%">';
|
||||
|
||||
print "<tr>";
|
||||
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
|
||||
|
||||
$nblignes=6;
|
||||
if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
|
||||
if ($product->type == 1) $nblignes++;
|
||||
|
||||
// Reference
|
||||
print '<td width="10%">'.$langs->trans("Ref").'</td><td>'.$product->ref.'</td>';
|
||||
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
|
||||
// Photo
|
||||
$nbphoto=$product->show_photo($conf->produit->dir_output,1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
|
||||
|
||||
// Libellé
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
|
||||
if ($product->type == 0) $nbligne=5;
|
||||
else $nbligne=5;
|
||||
print '<td valign="top" rowspan="'.$nbligne.'">';
|
||||
|
||||
$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 '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Suppliers").'</td></tr>';
|
||||
$var=True;
|
||||
while ($i < $num_fournisseur)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
print '<td align="right">';
|
||||
print '<a href="fiche.php?id='.$product->id.'&action=remove_fourn&id_fourn='.$objp->idp.'">';
|
||||
print img_disable($langs->trans("Remove")).'</a></td></tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
$db->free($result);
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||
@ -409,9 +380,12 @@ if ($_GET["id"])
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
// TVA
|
||||
$langs->load("bills");
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.' %</td></tr>';
|
||||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||||
|
||||
// Stock
|
||||
if ($product->type == 0 && $conf->stock->enabled)
|
||||
{
|
||||
print '<tr><td><a href="stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>';
|
||||
if ($product->no_stock)
|
||||
@ -431,8 +405,11 @@ if ($_GET["id"])
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Description
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
|
||||
|
||||
// Durée
|
||||
if ($product->type == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' ';
|
||||
@ -448,36 +425,11 @@ if ($_GET["id"])
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table><br>\n";
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajouter un fournisseur
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
print_titre($langs->trans("AddSupplier"));
|
||||
print '<form action="fiche.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="add_fourn">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td>'.$langs->trans("Suppliers").'</td><td>';
|
||||
|
||||
$html=new Form($db);
|
||||
$html->select_societes('','id_fourn','fournisseur=1');
|
||||
|
||||
print '</td><td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td><input name="ref_fourn" size="25" value=""></td></tr>';
|
||||
print '<tr><td colspan="4" align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -587,24 +539,11 @@ if ($_GET["action"] == '')
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$product->id.'&action=ajout_fourn">';
|
||||
print $langs->trans("AddSupplier").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "\n</div><br>\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);
|
||||
|
||||
@ -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 = '<div class="ok">'.$langs->trans("PriceRemoved").'.</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
}
|
||||
}
|
||||
else { // On supprime un fournisseur
|
||||
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$mesg = '<div class="ok">'.$langs->trans("SupplierRemoved").'.</div>';
|
||||
}
|
||||
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='<div class="error">'.$product->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["qty"]) {
|
||||
else {
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'</div>';
|
||||
}
|
||||
|
||||
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 '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="2">'.$product->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
|
||||
@ -179,25 +215,32 @@ if ($_GET["id"])
|
||||
if ($product->envente) print $langs->trans("OnSell");
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table><br />';
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($mesg) print($mesg);
|
||||
|
||||
|
||||
// Formulaire ajout prix
|
||||
if ($_GET["action"] == 'add_price' && $user->rights->produit->creer)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
print '<div class="titre">'.$langs->trans("ChangeSupplierPrice").'</div>';
|
||||
|
||||
if ($_GET["id_fourn"]) {
|
||||
print '<div class="titre">'.$langs->trans("ChangeSupplierPrice").'</div>';
|
||||
} else {
|
||||
print '<div class="titre">'.$langs->trans("AddSupplierPrice").'</div>';
|
||||
}
|
||||
print '<table class="border" width="100%">';
|
||||
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updateprice">';
|
||||
|
||||
if ($_GET["id_fourn"]) {
|
||||
print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">';
|
||||
$product->fetch_fourn_data($_GET["id_fourn"]);
|
||||
print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">';
|
||||
} else {
|
||||
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">';
|
||||
$html=new Form($db);
|
||||
@ -210,7 +253,8 @@ if ($_GET["id"])
|
||||
|
||||
print '<tr><td>'.$langs->trans("Qty").'</td>';
|
||||
print '<td><input name="qty" size="5" value="'.$_GET["qty"].'"></td>';
|
||||
print '<td>'.$langs->trans("Price").'</td><td><input name="price" size="8" value="'.price($objp->price).'"></td></tr>';
|
||||
print '<td>'.$langs->trans("Price").'</td>';
|
||||
print '<td><input name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center"><input type="submit" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
@ -229,7 +273,7 @@ if ($_GET["id"])
|
||||
if ($_GET["action"] != 'add_price') {
|
||||
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&action=add_price">';
|
||||
print $langs->trans("AddSupplierPrice").'</a>';
|
||||
print $langs->trans("AddSupplier").'</a>';
|
||||
|
||||
}
|
||||
|
||||
@ -271,7 +315,7 @@ if ($_GET["id"])
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$objp->nom.'</a></td>';
|
||||
|
||||
// Fournisseur
|
||||
print '<td align="left">'.$objp->ref_fourn.'</td>';
|
||||
@ -291,10 +335,13 @@ if ($_GET["id"])
|
||||
print $objp->quantity?price($objp->price / $objp->quantity):" ";
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($user->rights->produit->modifier) {
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=add_price&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'">'.img_edit()."</a>";
|
||||
// Modifier-Supprimer
|
||||
print '<td align="center">';
|
||||
if ($user->rights->produit->creer) {
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=add_price&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'&price='.$objp->price.'">'.img_edit()."</a>";
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=remove_fourn&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'">';
|
||||
}
|
||||
print img_disable($langs->trans("Remove")).'</a>';
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
@ -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 '<div class="photo">';
|
||||
$nbphoto=$product->show_photos($conf->produit->dir_output,1);
|
||||
//print '<br>';
|
||||
//print '<div class="photo">';
|
||||
$nbphoto=$product->show_photos($conf->produit->dir_output,1,0,5);
|
||||
|
||||
|
||||
if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>";
|
||||
print '</div>';
|
||||
//print '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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 '<table class="border" width="100%"><tr>';
|
||||
print '<td width="20%">'.$langs->trans("Ref").'</td><td width="40%"><a href="../fiche.php?id='.$product->id.'">'.$product->ref.'</a></td>';
|
||||
print '<td><a href="fiche.php?id='.$product->id.'">'.$langs->trans("Statistics").'</a></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
|
||||
print '<td valign="top" rowspan="2">';
|
||||
// Propals
|
||||
if ($conf->propal->enabled) {
|
||||
$langs->load("propal");
|
||||
print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a> : '.$product->count_propale($socid);
|
||||
print " (Proposé à ".$product->count_propale_client($socid)." clients)<br>";
|
||||
}
|
||||
// Commande
|
||||
if ($conf->commande->enabled) {
|
||||
$langs->load("orders");
|
||||
print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a> : '.$product->count_facture($socid)."<br>";
|
||||
}
|
||||
// Factures
|
||||
if ($conf->facture->enabled) {
|
||||
$langs->load("bills");
|
||||
print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a> : '.$product->count_facture($socid);
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("CurrentPrice").'</td><td>'.price($product->price).'</td></tr>';
|
||||
print "</table>";
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
|
||||
print "<br>";
|
||||
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 "<table class=\"noborder\" width=\"100%\">";
|
||||
$h=0;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' ';
|
||||
print $objp->facnumber;
|
||||
print "</a></td>\n";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.'</a></td>';
|
||||
|
||||
if ($objp->df > 0 )
|
||||
{
|
||||
print "<td align=\"right\">";
|
||||
print strftime("%d %B %Y",$objp->df)."</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"right\"><b>!!!</b></td>\n";
|
||||
}
|
||||
|
||||
print "<td align=\"right\">".price($objp->amount)."</td>\n";
|
||||
|
||||
$fac=new Facture($db);
|
||||
print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->statut).'</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</table>";
|
||||
$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 '<table class="border" width="100%">';
|
||||
|
||||
print '<tr>';
|
||||
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
if ($product->envente) print $langs->trans("OnSell");
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print "<br>";
|
||||
print '</div>';
|
||||
|
||||
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 "<table class=\"noborder\" width=\"100%\">";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' ';
|
||||
print $objp->facnumber;
|
||||
print "</a></td>\n";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>';
|
||||
print "<td>".$objp->code_client."</td>\n";
|
||||
print "<td align=\"right\">";
|
||||
print dolibarr_print_date($objp->df)."</td>";
|
||||
print "<td align=\"right\">".price($objp->amount)."</td>\n";
|
||||
$fac=new Facture($db);
|
||||
print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->statut).'</td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</table>";
|
||||
print '<br>';
|
||||
$db->free($result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Error";
|
||||
dolibarr_print_error();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user