From fe3dfbaebca3b91edb66330b2e58cbf84d0f7af5 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 17 Aug 2011 15:22:39 +0000 Subject: [PATCH] Price Fournisseurs: Add ordering fields. Add option FOURN_PRODUCT_AVAILABILITY --- .../fourn/class/fournisseur.product.class.php | 17 +++--- .../install/mysql/migration/3.1.0-3.2.0.sql | 6 +- .../tables/llx_product_fournisseur_price.sql | 3 +- htdocs/langs/ca_ES/suppliers.lang | 1 + htdocs/langs/en_US/suppliers.lang | 1 + htdocs/langs/es_ES/suppliers.lang | 1 + htdocs/langs/fr_FR/suppliers.lang | 1 + htdocs/product/fournisseurs.php | 59 +++++++++++++------ 8 files changed, 61 insertions(+), 28 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index ee4cbef9ede..36f90b795eb 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2009 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * 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 } } } -?> +?> \ No newline at end of file diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index def16980331..0dcec197997 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -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; \ No newline at end of file +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; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 170bd56f390..f46b3aa68bf 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -15,7 +15,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- --- $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, diff --git a/htdocs/langs/ca_ES/suppliers.lang b/htdocs/langs/ca_ES/suppliers.lang index 4b0597b35e8..e1fddec3b75 100644 --- a/htdocs/langs/ca_ES/suppliers.lang +++ b/htdocs/langs/ca_ES/suppliers.lang @@ -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 diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 18c0f38c54f..096c59717d5 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -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 diff --git a/htdocs/langs/es_ES/suppliers.lang b/htdocs/langs/es_ES/suppliers.lang index 394ba22ebc7..91eae1273b8 100644 --- a/htdocs/langs/es_ES/suppliers.lang +++ b/htdocs/langs/es_ES/suppliers.lang @@ -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 diff --git a/htdocs/langs/fr_FR/suppliers.lang b/htdocs/langs/fr_FR/suppliers.lang index 5948c05b02d..9e0ca68fd80 100644 --- a/htdocs/langs/fr_FR/suppliers.lang +++ b/htdocs/langs/fr_FR/suppliers.lang @@ -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 diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 39459f57a6c..f69d42d7226 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2011 Juanjo Menent * * 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 ''; print ''; - + + //Availability + if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) + { + print ''.$langs->trans("Availability").''; + $html->select_availability($product->fk_availability,"oselDispo",1); + print ''."\n"; + } print ''; print ''.$langs->trans("QtyMin").''; print ''; @@ -340,19 +353,23 @@ if ($_GET["id"] || $_GET["ref"]) print ''; if ($product->isproduct()) $nblignefour=4; else $nblignefour=4; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + + $param="&id=".$product->id; + print_liste_field_titre($langs->trans("Suppliers"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); + print ''; + 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 ''; + print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder); + + print ''; print ''; // 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 ''; - + + //Availability + if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) + { + $html->load_cache_availability(); + $availability= $html->cache_availability[$objp->fk_availability]['label']; + print ''; + } // Quantity print '
'; - print $langs->trans("Suppliers").''.$langs->trans("SupplierRef").''.$langs->trans("QtyMin").''.$langs->trans("PriceQtyMinHT").''.$langs->trans("UnitPriceHT").' '.$langs->trans("SupplierRef").''.$langs->trans("PriceQtyMinHT").'
'.$objp->ref_fourn.''.$availability.''; 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 $'); +?> \ No newline at end of file