Qual: Uniformisation du code. Suppression des ref_url en doublon avec getNomUrl plus souple.
This commit is contained in:
parent
e72404c00f
commit
af57bcfbc8
@ -750,7 +750,7 @@ if ($_GET['propalid'] > 0)
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// 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
|
||||
print '<tr><td>';
|
||||
|
||||
@ -87,7 +87,7 @@ if ($_GET["propalid"] > 0)
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@ if ($id > 0)
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $propal->ref_url;
|
||||
print $propal->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
// Customer
|
||||
|
||||
@ -145,7 +145,7 @@ if ($propalid > 0)
|
||||
print '<table class="border"width="100%">';
|
||||
|
||||
// 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é
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
|
||||
|
||||
@ -109,7 +109,7 @@ if ($_GET['propalid'])
|
||||
|
||||
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é
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
|
||||
|
||||
@ -123,8 +123,8 @@ if ($socid > 0)
|
||||
dolibarr_fiche_head($head, 'compta', $societe->nom);
|
||||
|
||||
|
||||
print "<table width=\"100%\">\n";
|
||||
print '<tr><td valign="top" width="50%">';
|
||||
print '<table width="100%" class="notopnoleftnoright">';
|
||||
print '<tr><td valign="top" width="50%" class="notopnoleft">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@ -218,7 +218,7 @@ if ($socid > 0)
|
||||
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
|
||||
$MAXLIST=5;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
@ -145,7 +145,7 @@ if ($_GET["propalid"] > 0)
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// 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
|
||||
print '<tr><td>';
|
||||
|
||||
@ -168,7 +168,7 @@ if ($id > 0)
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $fichinter->ref_url;
|
||||
print $fichinter->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
// Customer
|
||||
|
||||
@ -363,13 +363,13 @@ elseif ($_GET["id"] > 0)
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// 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
|
||||
print "<tr><td>".$langs->trans("Company")."</td><td>".$fichinter->client->getNomUrl(1)."</td></tr>";
|
||||
|
||||
// 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
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>';
|
||||
|
||||
@ -185,8 +185,6 @@ class Fichinter extends CommonObject
|
||||
$this->note_public = $obj->note_public;
|
||||
$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);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ if ($_GET['id'])
|
||||
|
||||
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é
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -23,9 +23,9 @@
|
||||
|
||||
/**
|
||||
\file htdocs/fourn/commande/fiche.php
|
||||
\ingroup commande
|
||||
\ingroup commande
|
||||
\brief Fiche commande
|
||||
\version $Revision$
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require('./pre.inc.php');
|
||||
@ -425,12 +425,12 @@ else
|
||||
|
||||
/* *************************************************************************** */
|
||||
/* */
|
||||
/* Mode vue et edition */
|
||||
/* Mode vue et edition */
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
$id = $_GET['id'];
|
||||
if ($id > 0)
|
||||
$id = $_GET['id'];
|
||||
if ($id > 0)
|
||||
{
|
||||
//if ($mesg) print $mesg.'<br>';
|
||||
|
||||
|
||||
@ -547,8 +547,8 @@ else
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
print '<table border="0" width="100%">';
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
print '<table width="100%" class="notopnoleftnoright">';
|
||||
print '<tr><td width="50%" valign="top" class="notopnoleft">';
|
||||
|
||||
/*
|
||||
* Facture
|
||||
@ -586,10 +586,10 @@ else
|
||||
|
||||
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
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* 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
|
||||
* 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);
|
||||
|
||||
|
||||
print '<table width="100%">';
|
||||
print '<tr><td valign="top" width="50%">';
|
||||
print '<table width="100%" class="notopnoleftnoright">';
|
||||
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>'.$langs->trans('Prefix').'</td><td colspan="3">'.$societe->prefix_comm.'</td></tr>';
|
||||
@ -123,7 +123,7 @@ if ( $societe->fetch($socid) )
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
print '</td><td valign="top" width="50%" class="notopnoleftnoright">';
|
||||
$var=true;
|
||||
|
||||
$MAXLIST=4;
|
||||
|
||||
@ -1080,30 +1080,30 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\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 htmlname Nom de la zone select
|
||||
\param filtretype Pour filtre sur type de produit
|
||||
\param limit Limite sur le nombre de lignes retournées
|
||||
*/
|
||||
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
|
||||
{
|
||||
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');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre);
|
||||
}
|
||||
}
|
||||
/**
|
||||
\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 htmlname Nom de la zone select
|
||||
\param filtretype Pour filtre sur type de produit
|
||||
\param limit Limite sur le nombre de lignes retournées
|
||||
*/
|
||||
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
|
||||
{
|
||||
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');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\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 htmlname Nom de la zone select
|
||||
\param filtretype Pour filtre sur type de produit
|
||||
@ -1136,42 +1136,50 @@ class Form
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
if ($conf->use_ajax)
|
||||
{
|
||||
if (! $num)
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print '<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'" onchange="publish_selvalue(this);">';
|
||||
print '<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
if (! $selected) print '<option value="0" selected="true"> </option>';
|
||||
else print '<option value="0"> </option>';
|
||||
}
|
||||
{
|
||||
if (! $num)
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print '<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'" onchange="publish_selvalue(this);">';
|
||||
print '<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
if (! $selected) print '<option value="0" selected="true"> </option>';
|
||||
else print '<option value="0"> </option>';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
|
||||
$opt = '<option value="'.$objp->rowid.'"';
|
||||
if ($selected == $objp->rowid) $opt.= ' selected="true"';
|
||||
//$opt.= '>'.$objp->ref.' ('.$objp->ref_fourn.') - ';
|
||||
if ($objp->fprice == '') $opt.=' disabled="disabled"';
|
||||
$opt.= '>'.$objp->ref.' - ';
|
||||
$opt.= dolibarr_trunc($objp->label,24).' - ';
|
||||
$opt.= $objp->fprice.$langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
|
||||
if ($objp->quantity > 1)
|
||||
$opt.= dolibarr_trunc($objp->label,18).' - ';
|
||||
if ($objp->fprice != '')
|
||||
{
|
||||
$opt.=" - ";
|
||||
$opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
|
||||
$opt.= $objp->fprice;
|
||||
$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";
|
||||
|
||||
print $opt;
|
||||
|
||||
@ -191,6 +191,8 @@ DefaultValue=Default value
|
||||
DefaultGlobalValue=Global value
|
||||
Price=Price
|
||||
UnitPrice=Unit price
|
||||
UnitPriceHT=Unit price HT
|
||||
UnitPriceTTC=Unit price TTC
|
||||
PriceU=U.P.
|
||||
PriceUHT=U.P. HT
|
||||
PriceUTTC=U.P. TTC
|
||||
|
||||
@ -110,5 +110,7 @@ NoStockForThisProduct=No stock for this product
|
||||
Restock=Restock
|
||||
ProductSpecial=Special
|
||||
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
|
||||
|
||||
@ -192,6 +192,8 @@ DefaultValue=Valeur par d
|
||||
DefaultGlobalValue=Valeur globale
|
||||
Price=Prix
|
||||
UnitPrice=Prix unitaire
|
||||
UnitPriceHT=Prix unitaire HT
|
||||
UnitPriceTTC=Prix unitaire TTC
|
||||
PriceU=P.U.
|
||||
PriceUHT=P.U. HT
|
||||
PriceUTTC=P.U. TTC
|
||||
|
||||
@ -110,4 +110,7 @@ NoStockForThisProduct=Pas de stock pour ce produit
|
||||
Restock=Réassort
|
||||
ProductSpecial=Special
|
||||
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
|
||||
|
||||
@ -719,104 +719,110 @@ class Product
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Modifie le prix d'achat pour un fournisseur
|
||||
* \param id_fourn Id du 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 update_buyprice($id_fourn, $qty, $buyprice, $user)
|
||||
{
|
||||
$error=0;
|
||||
$this->db->begin();
|
||||
/**
|
||||
* \brief Modifie le prix d'achat pour un fournisseur
|
||||
* \param id_fourn Id du 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
|
||||
* \param price_base_type HT or TTC
|
||||
*/
|
||||
function update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type='HT')
|
||||
{
|
||||
$error=0;
|
||||
$this->db->begin();
|
||||
|
||||
// Supprime prix courant du fournisseur pour cette quantité
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price ";
|
||||
$sql .= " WHERE ";
|
||||
$sql .= " fk_product = ".$this->id;
|
||||
$sql .= " AND fk_soc = ".$id_fourn;
|
||||
$sql .= " AND quantity = ".$qty;
|
||||
// Supprime prix courant du fournisseur pour cette quantité
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price ";
|
||||
$sql .= " WHERE ";
|
||||
$sql .= " fk_product = ".$this->id;
|
||||
$sql .= " AND fk_soc = ".$id_fourn;
|
||||
$sql .= " AND quantity = ".$qty;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
// Ajoute prix courant du fournisseur pour cette quantité
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price ";
|
||||
$sql .= " SET datec = now()";
|
||||
$sql .= " ,fk_product = ".$this->id;
|
||||
$sql .= " ,fk_soc = ".$id_fourn;
|
||||
$sql .= " ,fk_user = ".$user->id;
|
||||
$sql .= " ,price = ".price2num($buyprice);
|
||||
$sql .= " ,quantity = ".$qty;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
// Ajoute prix courant du fournisseur pour cette quantité
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql .= " SET datec = now()";
|
||||
$sql .= " ,fk_product = ".$this->id;
|
||||
$sql .= " ,fk_soc = ".$id_fourn;
|
||||
$sql .= " ,fk_user = ".$user->id;
|
||||
$sql .= " ,price = ".price2num($buyprice);
|
||||
$sql .= " ,quantity = ".$qty;
|
||||
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
// Ajoute modif dans table log
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log ";
|
||||
$sql .= " SET datec = now()";
|
||||
$sql .= " ,fk_product = ".$this->id;
|
||||
$sql .= " ,fk_soc = ".$id_fourn;
|
||||
$sql .= " ,fk_user = ".$user->id;
|
||||
$sql .= " ,price = ".price2num($buyprice);
|
||||
$sql .= " ,quantity = ".$qty;
|
||||
if (! $error) {
|
||||
// Ajoute modif dans table log
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log ";
|
||||
$sql .= " SET datec = now()";
|
||||
$sql .= " ,fk_product = ".$this->id;
|
||||
$sql .= " ,fk_soc = ".$id_fourn;
|
||||
$sql .= " ,fk_user = ".$user->id;
|
||||
$sql .= " ,price = ".price2num($buyprice);
|
||||
$sql .= " ,quantity = ".$qty;
|
||||
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$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";
|
||||
$sql.= " WHERE fk_soc ='".$id_fourn."'";
|
||||
$sql.= " AND ref_fourn='".$product_fourn_ref."';";
|
||||
/**
|
||||
\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 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))
|
||||
{
|
||||
if ($row = $this->db->fetch_row($resql) )
|
||||
{
|
||||
$this->id = $row[0];
|
||||
$errno = $this->update_buyprice($id_fourn, $qty, $buyprice, $user);
|
||||
}
|
||||
}
|
||||
// Recherche id produit pour cette ref et fournisseur
|
||||
$sql = "SELECT fk_product";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
|
||||
$sql.= " WHERE fk_soc ='".$id_fourn."'";
|
||||
$sql.= " AND ref_fourn='".$product_fourn_ref."'";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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) 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"))
|
||||
{
|
||||
|
||||
$product = new Product($db);
|
||||
if( $product->fetch($_GET["id"]) )
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$error=0;
|
||||
|
||||
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)
|
||||
$product = new Product($db);
|
||||
if( $product->fetch($_GET["id"]) )
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$error=0;
|
||||
|
||||
if ($_POST["ref_fourn"])
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$product->error.'</div>';
|
||||
if ($ret == -2)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>';
|
||||
}
|
||||
$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("Price")).'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
|
||||
}
|
||||
|
||||
if (! $error && $_POST["qty"])
|
||||
{
|
||||
if ($_POST["price"] >= 0)
|
||||
{
|
||||
$ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
|
||||
if ($ret < 0)
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$product->error.'</div>';
|
||||
if ($ret == -2)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
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"))
|
||||
@ -249,7 +249,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print '<td>'.$langs->trans("QtyMin").'</td>';
|
||||
$quantity = $_GET["qty"] ? $_GET["qty"] : "1";
|
||||
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 '<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 '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyMin").'</td>';
|
||||
print '<td align="right">'.$langs->trans("PriceHTQty").'</td>';
|
||||
print '<td align="right">'.$langs->trans("UnitPrice").'</td>';
|
||||
print '<td align="right">'.$langs->trans("PriceQtyHT").'</td>';
|
||||
print '<td align="right">'.$langs->trans("UnitPriceHT").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// 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.= " 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";
|
||||
|
||||
@ -851,8 +851,6 @@ class Propal extends CommonObject
|
||||
$this->lignes = array();
|
||||
$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
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user