Qual: Uniformisation du code. Suppression des ref_url en doublon avec getNomUrl plus souple.

This commit is contained in:
Laurent Destailleur 2007-07-08 12:41:24 +00:00
parent e72404c00f
commit af57bcfbc8
22 changed files with 251 additions and 231 deletions

View File

@ -750,7 +750,7 @@ if ($_GET['propalid'] > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref_url.'</td></tr>'; print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref.'</td></tr>';
// Ref client // Ref client
print '<tr><td>'; print '<tr><td>';

View File

@ -87,7 +87,7 @@ if ($_GET["propalid"] > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref_url.'</td></tr>'; print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref.'</td></tr>';
$rowspan=3; $rowspan=3;

View File

@ -169,7 +169,7 @@ if ($id > 0)
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $propal->ref_url; print $propal->ref;
print "</td></tr>"; print "</td></tr>";
// Customer // Customer

View File

@ -145,7 +145,7 @@ if ($propalid > 0)
print '<table class="border"width="100%">'; print '<table class="border"width="100%">';
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$propal->ref_url.'</td></tr>'; print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$propal->ref.'</td></tr>';
// Société // Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';

View File

@ -109,7 +109,7 @@ if ($_GET['propalid'])
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$propal->ref_url.'</td></tr>'; print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$propal->ref.'</td></tr>';
// Société // Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';

View File

@ -123,8 +123,8 @@ if ($socid > 0)
dolibarr_fiche_head($head, 'compta', $societe->nom); dolibarr_fiche_head($head, 'compta', $societe->nom);
print "<table width=\"100%\">\n"; print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="50%">'; print '<tr><td valign="top" width="50%" class="notopnoleft">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -218,7 +218,7 @@ if ($socid > 0)
print "</td>\n"; print "</td>\n";
print '<td valign="top" width="50%">'; print '<td valign="top" width="50%" class="notopnoleftnoright">';
// Nbre max d'éléments des petites listes // Nbre max d'éléments des petites listes
$MAXLIST=5; $MAXLIST=5;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
* *
@ -145,7 +145,7 @@ if ($_GET["propalid"] > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref_url.'</td></tr>'; print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref.'</td></tr>';
// Ref client // Ref client
print '<tr><td>'; print '<tr><td>';

View File

@ -168,7 +168,7 @@ if ($id > 0)
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $fichinter->ref_url; print $fichinter->ref;
print "</td></tr>"; print "</td></tr>";
// Customer // Customer

View File

@ -363,13 +363,13 @@ elseif ($_GET["id"] > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
// Societe // Societe
print "<tr><td>".$langs->trans("Company")."</td><td>".$fichinter->client->getNomUrl(1)."</td></tr>"; print "<tr><td>".$langs->trans("Company")."</td><td>".$fichinter->client->getNomUrl(1)."</td></tr>";
// Date // Date
print '<tr><td width="20%">'.$langs->trans("Date").'</td><td>'.dolibarr_print_date($fichinter->date,"daytext").'</td></tr>'; print '<tr><td>'.$langs->trans("Date").'</td><td>'.dolibarr_print_date($fichinter->date,"daytext").'</td></tr>';
// Durée // Durée
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>'; print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>';

View File

@ -185,8 +185,6 @@ class Fichinter extends CommonObject
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->ref_url = '<a href="'.DOL_URL_ROOT.'/fichinter/fiche.php?id='.$this->id.'">'.$this->ref.'</a>';
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;
} }

View File

@ -104,7 +104,7 @@ if ($_GET['id'])
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$fichinter->ref_url.'</td></tr>'; print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$fichinter->ref.'</td></tr>';
// Société // Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -23,9 +23,9 @@
/** /**
\file htdocs/fourn/commande/fiche.php \file htdocs/fourn/commande/fiche.php
\ingroup commande \ingroup commande
\brief Fiche commande \brief Fiche commande
\version $Revision$ \version $Revision$
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
@ -425,12 +425,12 @@ else
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
/* Mode vue et edition */ /* Mode vue et edition */
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
$id = $_GET['id']; $id = $_GET['id'];
if ($id > 0) if ($id > 0)
{ {
//if ($mesg) print $mesg.'<br>'; //if ($mesg) print $mesg.'<br>';

View File

@ -547,8 +547,8 @@ else
print '<br />'; print '<br />';
} }
print '<table border="0" width="100%">'; print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td width="50%" valign="top">'; print '<tr><td width="50%" valign="top" class="notopnoleft">';
/* /*
* Facture * Facture
@ -586,10 +586,10 @@ else
print '</table>'; print '</table>';
print '</td><td valign="top">'; print '</td><td valign="top" class="notopnoleftnoright">';
print '<table class="border" width="100%">'; print '<table width="100%" class="noborder">';
/* /*
* Liste des paiements * Liste des paiements

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Éric Seigne <erics@rycks.com> * Copyright (C) 2003 Éric Seigne <erics@rycks.com>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -88,10 +88,10 @@ if ( $societe->fetch($socid) )
dolibarr_fiche_head($head, 'supplier', $societe->nom); dolibarr_fiche_head($head, 'supplier', $societe->nom);
print '<table width="100%">'; print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="50%">'; print '<tr><td valign="top" width="50%" class="notopnoleft">';
print '<table class="border" width="100%">'; print '<table width="100%" class="border">';
print '<tr><td width="20%">'.$langs->trans("Name").'</td><td width="80%" colspan="3">'.$societe->nom.'</td></tr>'; print '<tr><td width="20%">'.$langs->trans("Name").'</td><td width="80%" colspan="3">'.$societe->nom.'</td></tr>';
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$societe->prefix_comm.'</td></tr>'; print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$societe->prefix_comm.'</td></tr>';
@ -123,7 +123,7 @@ if ( $societe->fetch($socid) )
print '</table>'; print '</table>';
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%" class="notopnoleftnoright">';
$var=true; $var=true;
$MAXLIST=4; $MAXLIST=4;

View File

@ -1080,30 +1080,30 @@ class Form
} }
} }
/** /**
\brief Retourne la liste des produits fournisseurs en Ajax si ajax activé ou renvoie à select_produits_fournisseurs_do \brief Retourne la liste des produits fournisseurs en Ajax si ajax activé ou renvoie à select_produits_fournisseurs_do
\param selected Produit présélectionné \param selected Produit présélectionné
\param htmlname Nom de la zone select \param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit \param filtretype Pour filtre sur type de produit
\param limit Limite sur le nombre de lignes retournées \param limit Limite sur le nombre de lignes retournées
*/ */
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='') function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
{ {
global $langs,$conf; global $langs,$conf;
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
{ {
print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'">'; print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'">';
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&socid='.$socid.'&type=2','working'); print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&socid='.$socid.'&type=2','working');
} }
else else
{ {
$this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre); $this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre);
} }
} }
/** /**
\brief Retourne la liste des produits de fournisseurs \brief Retourne la liste des produits de fournisseurs
\param socid Id société (0 pour aucun filtre) \param socid Id société (0 pour aucun filtre)
\param selected Produit présélectionné \param selected Produit présélectionné
\param htmlname Nom de la zone select \param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit \param filtretype Pour filtre sur type de produit
@ -1136,42 +1136,50 @@ class Form
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
if ($conf->use_ajax) if ($conf->use_ajax)
{ {
if (! $num) if (! $num)
{ {
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
print '<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>'; print '<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>';
} }
else else
{ {
print '<select class="flat" name="'.$htmlname.'" onchange="publish_selvalue(this);">'; print '<select class="flat" name="'.$htmlname.'" onchange="publish_selvalue(this);">';
print '<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>'; print '<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>';
} }
} }
else else
{ {
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
if (! $selected) print '<option value="0" selected="true">&nbsp;</option>'; if (! $selected) print '<option value="0" selected="true">&nbsp;</option>';
else print '<option value="0">&nbsp;</option>'; else print '<option value="0">&nbsp;</option>';
} }
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$opt = '<option value="'.$objp->rowid.'"'; $opt = '<option value="'.$objp->rowid.'"';
if ($selected == $objp->rowid) $opt.= ' selected="true"'; if ($selected == $objp->rowid) $opt.= ' selected="true"';
//$opt.= '>'.$objp->ref.' ('.$objp->ref_fourn.') - '; if ($objp->fprice == '') $opt.=' disabled="disabled"';
$opt.= '>'.$objp->ref.' - '; $opt.= '>'.$objp->ref.' - ';
$opt.= dolibarr_trunc($objp->label,24).' - '; $opt.= dolibarr_trunc($objp->label,18).' - ';
$opt.= $objp->fprice.$langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units"); if ($objp->fprice != '')
if ($objp->quantity > 1)
{ {
$opt.=" - "; $opt.= $objp->fprice;
$opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit"); $opt.= $langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
if ($objp->quantity > 1)
{
$opt.=" - ";
$opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
}
if ($objp->duration) $opt .= " - ".$objp->duration;
}
else
{
$opt.= $langs->trans("NoPriceDefinedForThisSupplier");
} }
if ($objp->duration) $opt .= " - ".$objp->duration;
$opt .= "</option>\n"; $opt .= "</option>\n";
print $opt; print $opt;

View File

@ -191,6 +191,8 @@ DefaultValue=Default value
DefaultGlobalValue=Global value DefaultGlobalValue=Global value
Price=Price Price=Price
UnitPrice=Unit price UnitPrice=Unit price
UnitPriceHT=Unit price HT
UnitPriceTTC=Unit price TTC
PriceU=U.P. PriceU=U.P.
PriceUHT=U.P. HT PriceUHT=U.P. HT
PriceUTTC=U.P. TTC PriceUTTC=U.P. TTC

View File

@ -110,5 +110,7 @@ NoStockForThisProduct=No stock for this product
Restock=Restock Restock=Restock
ProductSpecial=Special ProductSpecial=Special
QtyMin=Quantity minimum QtyMin=Quantity minimum
PriceHTQty=Price HT for this quantity PriceQty=Price for this quantity
PriceQtyHT=Price for this quantity HT
PriceQtyTTC=Price for this quantity TTC
NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product

View File

@ -192,6 +192,8 @@ DefaultValue=Valeur par d
DefaultGlobalValue=Valeur globale DefaultGlobalValue=Valeur globale
Price=Prix Price=Prix
UnitPrice=Prix unitaire UnitPrice=Prix unitaire
UnitPriceHT=Prix unitaire HT
UnitPriceTTC=Prix unitaire TTC
PriceU=P.U. PriceU=P.U.
PriceUHT=P.U. HT PriceUHT=P.U. HT
PriceUTTC=P.U. TTC PriceUTTC=P.U. TTC

View File

@ -110,4 +110,7 @@ NoStockForThisProduct=Pas de stock pour ce produit
Restock=Réassort Restock=Réassort
ProductSpecial=Special ProductSpecial=Special
QtyMin=Quantité minimum QtyMin=Quantité minimum
PriceHTQty=Prix HT pour la quantité PriceQty=Prix pour la quantité
PriceQtyHT=Prix pour la quantité HT
PriceQtyTTC=Prix pour la quantité TTC
NoPriceDefinedForThisSupplier=Aucun prix/qté défini pour ce fournisseur/produit

View File

@ -719,104 +719,110 @@ class Product
} }
/** /**
* \brief Modifie le prix d'achat pour un fournisseur * \brief Modifie le prix d'achat pour un fournisseur
* \param id_fourn Id du fournisseur * \param id_fourn Id du fournisseur
* \param qty Quantite pour lequel le prix est valide * \param qty Quantite pour lequel le prix est valide
* \param buyprice Prix d'achat pour la quantité * \param buyprice Prix d'achat pour la quantité
* \param user Objet user de l'utilisateur qui modifie * \param user Objet user de l'utilisateur qui modifie
*/ * \param price_base_type HT or TTC
function update_buyprice($id_fourn, $qty, $buyprice, $user) */
{ function update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type='HT')
$error=0; {
$this->db->begin(); $error=0;
$this->db->begin();
// Supprime prix courant du fournisseur pour cette quantité // Supprime prix courant du fournisseur pour cette quantité
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price "; $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price ";
$sql .= " WHERE "; $sql .= " WHERE ";
$sql .= " fk_product = ".$this->id; $sql .= " fk_product = ".$this->id;
$sql .= " AND fk_soc = ".$id_fourn; $sql .= " AND fk_soc = ".$id_fourn;
$sql .= " AND quantity = ".$qty; $sql .= " AND quantity = ".$qty;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
// Ajoute prix courant du fournisseur pour cette quantité // Ajoute prix courant du fournisseur pour cette quantité
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql .= " SET datec = now()"; $sql .= " SET datec = now()";
$sql .= " ,fk_product = ".$this->id; $sql .= " ,fk_product = ".$this->id;
$sql .= " ,fk_soc = ".$id_fourn; $sql .= " ,fk_soc = ".$id_fourn;
$sql .= " ,fk_user = ".$user->id; $sql .= " ,fk_user = ".$user->id;
$sql .= " ,price = ".price2num($buyprice); $sql .= " ,price = ".price2num($buyprice);
$sql .= " ,quantity = ".$qty; $sql .= " ,quantity = ".$qty;
if (! $this->db->query($sql)) if (! $this->db->query($sql))
{ {
$error++; $error++;
} }
if (! $error) { if (! $error) {
// Ajoute modif dans table log // Ajoute modif dans table log
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log ";
$sql .= " SET datec = now()"; $sql .= " SET datec = now()";
$sql .= " ,fk_product = ".$this->id; $sql .= " ,fk_product = ".$this->id;
$sql .= " ,fk_soc = ".$id_fourn; $sql .= " ,fk_soc = ".$id_fourn;
$sql .= " ,fk_user = ".$user->id; $sql .= " ,fk_user = ".$user->id;
$sql .= " ,price = ".price2num($buyprice); $sql .= " ,price = ".price2num($buyprice);
$sql .= " ,quantity = ".$qty; $sql .= " ,quantity = ".$qty;
if (! $this->db->query($sql)) if (! $this->db->query($sql))
{ {
$error++; $error++;
} }
}
if (! $error)
{
$this->db->commit();
return 0;
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->db->rollback();
return -2;
}
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->db->rollback();
return -1;
}
} }
if (! $error)
{
$this->db->commit();
return 0;
}
else
{
$this->error=$this->db->error()." ($sql)";
$this->db->rollback();
return -2;
}
}
else
{
$this->error=$this->db->error()." ($sql)";
$this->db->rollback();
return -1;
}
}
/**
\brief Modifie le prix d'achat pour un fournisseur par la référecne du produit chez le fournisseur
\param id_fourn Id du fournisseur
\param product_fourn_ref Reference du produit chez le fournisseur
\param qty Quantite pour lequel le prix est valide
\param buyprice Prix d'achat pour la quantité
\param user Objet user de l'utilisateur qui modifie
*/
function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user)
{
$errno=0;
// Supprime prix courant du fournisseur pour cette quantité /**
$sql = "SELECT fk_product FROM ".MAIN_DB_PREFIX."product_fournisseur"; \brief Modifie le prix d'achat pour un fournisseur par la référecne du produit chez le fournisseur
$sql.= " WHERE fk_soc ='".$id_fourn."'"; \param id_fourn Id du fournisseur
$sql.= " AND ref_fourn='".$product_fourn_ref."';"; \param product_fourn_ref Ref du produit chez le fournisseur
\param qty Quantite pour lequel le prix est valide
\param buyprice Prix d'achat pour la quantité
\param user Objet user de l'utilisateur qui modifie
\return int <0 si KO, >0 si OK
*/
function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user, $price_base_type='HT')
{
$result=0;
if ($this->db->query($sql)) // Recherche id produit pour cette ref et fournisseur
{ $sql = "SELECT fk_product";
if ($row = $this->db->fetch_row($resql) ) $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
{ $sql.= " WHERE fk_soc ='".$id_fourn."'";
$this->id = $row[0]; $sql.= " AND ref_fourn='".$product_fourn_ref."'";
$errno = $this->update_buyprice($id_fourn, $qty, $buyprice, $user);
}
}
return $errno; if ($this->db->query($sql))
} {
if ($obj = $this->db->fetch_object($resql))
{
// Met a jour prix pour la qté
$this->id = $obj->fk_product;
$result = $this->update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type);
}
}
return $result;
}
/** /**

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
* *
@ -90,63 +90,63 @@ if ($_GET["action"] == 'remove_fourn')
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel")) if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
{ {
$product = new Product($db); $product = new Product($db);
if( $product->fetch($_GET["id"]) ) if( $product->fetch($_GET["id"]) )
{ {
$db->begin(); $db->begin();
$error=0; $error=0;
if ($_POST["ref_fourn"]) if ($_POST["ref_fourn"])
{
$ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
if ($ret < 0)
{
$error++;
$mesg='<div class="error">'.$product->error.'</div>';
}
}
else
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
}
if ($_POST["qty"])
{
if ($_POST["price"] >= 0)
{
$ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
if ($ret < 0)
{ {
$error++; $ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
$mesg='<div class="error">'.$product->error.'</div>'; if ($ret < 0)
if ($ret == -2) {
{ $error++;
$mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>'; $mesg='<div class="error">'.$product->error.'</div>';
} }
} }
} else
else {
{ $error++;
$error++; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'</div>'; }
}
} if (! $error && $_POST["qty"])
else {
{ if ($_POST["price"] >= 0)
$error++; {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>'; $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
} if ($ret < 0)
{
if (! $error) $error++;
{ $mesg='<div class="error">'.$product->error.'</div>';
$db->commit(); if ($ret == -2)
} {
else { $mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>';
$db->rollback(); }
} }
} }
else
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'</div>';
}
}
else
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>';
}
if (! $error)
{
$db->commit();
}
else {
$db->rollback();
}
}
} }
if ($_POST["cancel"] == $langs->trans("Cancel")) if ($_POST["cancel"] == $langs->trans("Cancel"))
@ -249,7 +249,7 @@ if ($_GET["id"] || $_GET["ref"])
print '<td>'.$langs->trans("QtyMin").'</td>'; print '<td>'.$langs->trans("QtyMin").'</td>';
$quantity = $_GET["qty"] ? $_GET["qty"] : "1"; $quantity = $_GET["qty"] ? $_GET["qty"] : "1";
print '<td><input class="flat" name="qty" size="5" value="'.$quantity.'"></td>'; print '<td><input class="flat" name="qty" size="5" value="'.$quantity.'"></td>';
print '<td>'.$langs->trans("PriceHTQty").'</td>'; print '<td>'.$langs->trans("PriceQtyHT").'</td>';
print '<td><input class="flat" name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>'; print '<td><input class="flat" name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>';
print '<tr><td colspan="6" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">'; print '<tr><td colspan="6" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">';
@ -290,13 +290,14 @@ if ($_GET["id"] || $_GET["ref"])
print $langs->trans("Suppliers").'</td>'; print $langs->trans("Suppliers").'</td>';
print '<td>'.$langs->trans("Ref").'</td>'; print '<td>'.$langs->trans("Ref").'</td>';
print '<td align="center">'.$langs->trans("QtyMin").'</td>'; print '<td align="center">'.$langs->trans("QtyMin").'</td>';
print '<td align="right">'.$langs->trans("PriceHTQty").'</td>'; print '<td align="right">'.$langs->trans("PriceQtyHT").'</td>';
print '<td align="right">'.$langs->trans("UnitPrice").'</td>'; print '<td align="right">'.$langs->trans("UnitPriceHT").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
// Liste des fournisseurs // Liste des fournisseurs
$sql = "SELECT s.nom, s.rowid as socid, pf.ref_fourn, pfp.price, pfp.quantity"; $sql = "SELECT s.nom, s.rowid as socid,";
$sql.= "pf.ref_fourn, pfp.price, pfp.quantity";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product"; $sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";

View File

@ -851,8 +851,6 @@ class Propal extends CommonObject
$this->lignes = array(); $this->lignes = array();
$this->db->free($resql); $this->db->free($resql);
$this->ref_url = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$this->id.'">'.$this->ref.'</a>';
/* /*
* Lignes propales liées à un produit ou non * Lignes propales liées à un produit ou non
*/ */