Price Fournisseurs: Add ordering fields. Add option FOURN_PRODUCT_AVAILABILITY

This commit is contained in:
Juanjo Menent 2011-08-17 15:22:39 +00:00
parent bf7c7cee3b
commit fe3dfbaebc
8 changed files with 61 additions and 28 deletions

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,7 +22,7 @@
* \file htdocs/fourn/class/fournisseur.product.class.php
* \ingroup produit
* \brief File of class to manage predefined suppliers products
* \version $Id: fournisseur.product.class.php,v 1.7 2011/07/31 23:57:02 eldy Exp $
* \version $Id: fournisseur.product.class.php,v 1.8 2011/08/17 15:22:40 simnandez Exp $
*/
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
@ -42,7 +43,7 @@ class ProductFournisseur extends Product
var $fourn_qty;
var $product_fourn_id;
var $product_fourn_price_id;
var $fk_availability;
function ProductFournisseur($db)
{
@ -250,7 +251,7 @@ class ProductFournisseur extends Product
* \param price_base_type HT or TTC
* \param fourn Supplier
*/
function update_buyprice($qty, $buyprice, $user, $price_base_type='HT', $fourn)
function update_buyprice($qty, $buyprice, $user, $price_base_type='HT', $fourn,$availability)
{
global $mysoc;
@ -286,13 +287,14 @@ class ProductFournisseur extends Product
// Ajoute prix courant du fournisseur pour cette quantite
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
$sql.= "datec, fk_product_fournisseur, fk_user, price, quantity, unitprice)";
$sql.= "datec, fk_product_fournisseur, fk_user, price, quantity, unitprice, fk_availability)";
$sql.= " values('".$this->db->idate($now)."',";
$sql.= " ".$this->product_fourn_id.",";
$sql.= " ".$user->id.",";
$sql.= " ".price2num($buyprice).",";
$sql.= " ".$qty.",";
$sql.= " ".$unitBuyPrice;
$sql.= " ".$unitBuyPrice.",";
$sql.= " ".$availability;
$sql.=")";
dol_syslog("ProductFournisseur::update_buyprice sql=".$sql);
@ -419,7 +421,7 @@ class ProductFournisseur extends Product
*/
function fetch_product_fournisseur_price($rowid)
{
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice";
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability";
$sql.= ", pf.rowid as product_fourn_id, pf.fk_soc, pf.ref_fourn, pf.fk_product";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
@ -441,6 +443,7 @@ class ProductFournisseur extends Product
$this->fourn_unitprice = $obj->unitprice;
$this->product_id = $obj->fk_product; // deprecated
$this->fk_product = $obj->fk_product;
$this->fk_availability = $obj->fk_availability;
return 1;
}
else
@ -456,4 +459,4 @@ class ProductFournisseur extends Product
}
}
}
?>
?>

View File

@ -1,5 +1,5 @@
--
-- $Id: 3.1.0-3.2.0.sql,v 1.1 2011/08/11 01:34:54 eldy Exp $
-- $Id: 3.1.0-3.2.0.sql,v 1.2 2011/08/17 15:22:39 simnandez Exp $
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
@ -11,4 +11,6 @@
-- To change type of field: ALTER TABLE llx_table MODIFY name varchar(60);
--
UPDATE llx_c_paper_format SET active=1 WHERE active=0;
UPDATE llx_c_paper_format SET active=1 WHERE active=0;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_availability integer AFTER fk_product_fournisseur;

View File

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- $Id: llx_product_fournisseur_price.sql,v 1.3 2011/08/03 01:25:32 eldy Exp $
-- $Id: llx_product_fournisseur_price.sql,v 1.4 2011/08/17 15:22:40 simnandez Exp $
-- ============================================================================
create table llx_product_fournisseur_price
@ -24,6 +24,7 @@ create table llx_product_fournisseur_price
datec datetime,
tms timestamp,
fk_product_fournisseur integer NOT NULL,
fk_availability integer,
price double(24,8) DEFAULT 0,
quantity double,
unitprice double(24,8) DEFAULT 0,

View File

@ -21,6 +21,7 @@ NoRecordedSuppliers= Sense proveïdors registrats
SupplierPayment= Pagament a proveïdor
SuppliersArea= Àrea proveïdors
RefSupplierShort= Ref. proveïdor
Availability=Disponibilitat
ExportDataset_fournisseur_1= Factures de proveïdors i línies de factura
ExportDataset_fournisseur_2= Factures proveïdors i pagaments
ApproveThisOrder= Aprovar aquesta comanda

View File

@ -22,6 +22,7 @@ NoRecordedSuppliers=No suppliers recorded
SupplierPayment=Supplier payment
SuppliersArea=Suppliers area
RefSupplierShort=Ref. supplier
Availability=Availability
ExportDataset_fournisseur_1=Supplier invoices list and invoice's lines
ExportDataset_fournisseur_2=Supplier invoices and payments
ApproveThisOrder=Approve this order

View File

@ -21,6 +21,7 @@ NoRecordedSuppliers= Sin proveedores registrados
SupplierPayment= Pago a proveedor
SuppliersArea= Área proveedores
RefSupplierShort= Ref. proveedor
Availability=Disponibilidad
ExportDataset_fournisseur_1= Facturas de proveedores y lineas de factura
ExportDataset_fournisseur_2= Facturas proveedores y pagos
ApproveThisOrder= Aprobar este pedido

View File

@ -21,6 +21,7 @@ NoRecordedSuppliers=Pas de fournisseur enregistré
SupplierPayment=Paiement fournisseur
SuppliersArea=Espace fournisseurs
RefSupplierShort=Réf. fournisseur
Availability=Disponibilité
ExportDataset_fournisseur_1=Factures fournisseurs et lignes de facture
ExportDataset_fournisseur_2=Factures fournisseurs et règlements
ApproveThisOrder=Approuver la commande

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,7 +23,7 @@
* \file htdocs/product/fournisseurs.php
* \ingroup product
* \brief Page of tab suppliers for products
* \version $Id: fournisseurs.php,v 1.97 2011/07/31 23:19:26 eldy Exp $
* \version $Id: fournisseurs.php,v 1.98 2011/08/17 15:22:39 simnandez Exp $
*/
require("../main.inc.php");
@ -52,6 +52,12 @@ $fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service&fournisseur',$id,'product','','',$fieldid);
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
if (! $sortfield) $sortfield="s.nom";
if (! $sortorder) $sortorder="ASC";
$mesg = '';
@ -140,7 +146,7 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
$supplier=new Fournisseur($db);
$result=$supplier->fetch($id_fourn);
$ret=$product->update_buyprice($_POST["qty"], $_POST["price"], $user, $_POST["price_base_type"], $supplier);
$ret=$product->update_buyprice($_POST["qty"], $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"]);
if ($ret < 0)
{
$error++;
@ -282,7 +288,14 @@ if ($_GET["id"] || $_GET["ref"])
}
print '</td>';
print '</tr>';
//Availability
if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
{
print '<tr><td>'.$langs->trans("Availability").'</td><td colspan="3">';
$html->select_availability($product->fk_availability,"oselDispo",1);
print '</td></tr>'."\n";
}
print '<tr>';
print '<td>'.$langs->trans("QtyMin").'</td>';
print '<td>';
@ -340,19 +353,23 @@ if ($_GET["id"] || $_GET["ref"])
print '<table class="noborder" width="100%">';
if ($product->isproduct()) $nblignefour=4;
else $nblignefour=4;
print '<tr class="liste_titre"><td valign="top">';
print $langs->trans("Suppliers").'</td>';
print '<td>'.$langs->trans("SupplierRef").'</td>';
print '<td align="center">'.$langs->trans("QtyMin").'</td>';
print '<td align="right">'.$langs->trans("PriceQtyMinHT").'</td>';
print '<td align="right">'.$langs->trans("UnitPriceHT").'</td>';
print '<td>&nbsp;</td>';
$param="&id=".$product->id;
print_liste_field_titre($langs->trans("Suppliers"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
print '<td class="liste_titre">'.$langs->trans("SupplierRef").'</td>';
if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
print_liste_field_titre($langs->trans("Availability"),$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,"",$sortfield,$sortorder);
print '<td class="liste_titre" align="right">'.$langs->trans("PriceQtyMinHT").'</td>';
print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder);
print '<td class="liste_titre"></td>';
print '</tr>';
// Suppliers list
$sql = "SELECT s.nom, s.rowid as socid,";
$sql.= " pf.ref_fourn,";
$sql.= " pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice";
$sql.= " pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
@ -360,9 +377,8 @@ if ($_GET["id"] || $_GET["ref"])
$sql.= " WHERE pf.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND pf.fk_product = ".$product->id;
$sql.= " ORDER BY s.nom, pfp.quantity";
$resql="";
//$sql.= " ORDER BY s.nom, pfp.quantity";
$sql.= $db->order($sortfield,$sortorder);
$resql=$db->query($sql);
if ($resql)
{
@ -380,7 +396,14 @@ if ($_GET["id"] || $_GET["ref"])
// Supplier
print '<td align="left">'.$objp->ref_fourn.'</td>';
//Availability
if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
{
$html->load_cache_availability();
$availability= $html->cache_availability[$objp->fk_availability]['label'];
print '<td align="left">'.$availability.'</td>';
}
// Quantity
print '<td align="center">';
print $objp->quantity;
@ -430,5 +453,5 @@ else
$db->close();
llxFooter('$Date: 2011/07/31 23:19:26 $ - $Revision: 1.97 $');
?>
llxFooter('$Date: 2011/08/17 15:22:39 $ - $Revision: 1.98 $');
?>