Fix: Wrong list of product for supplier orders or invoices

This commit is contained in:
Laurent Destailleur 2008-08-06 13:06:58 +00:00
parent 360dd71c58
commit f3566030e0
7 changed files with 86 additions and 86 deletions

View File

@ -382,7 +382,7 @@ if ($socid > 0)
{ {
print " ".img_warning(); print " ".img_warning();
} }
print '</td><td align="right" width="80">'.dolibarr_print_date($objp->dp)."</td>\n"; print '</td><td align="right" width="80">'.dolibarr_print_date($objp->dp,'day')."</td>\n";
print '<td align="right" width="120">'.price($objp->total_ht).'</td>'; print '<td align="right" width="120">'.price($objp->total_ht).'</td>';
print '<td align="right" nowrap="nowrap">'.$propal_static->LibStatut($objp->fk_statut,5).'</td></tr>'; print '<td align="right" nowrap="nowrap">'.$propal_static->LibStatut($objp->fk_statut,5).'</td></tr>';
$var=!$var; $var=!$var;
@ -431,7 +431,7 @@ if ($socid > 0)
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$objp->cid.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$objp->ref."</a>\n"; print '<td nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$objp->cid.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$objp->ref."</a>\n";
print '</td><td align="right" width="80">'.dolibarr_print_date($objp->dc)."</td>\n"; print '</td><td align="right" width="80">'.dolibarr_print_date($objp->dc,'day')."</td>\n";
print '<td align="right" width="120">'.price($objp->total_ht).'</td>'; print '<td align="right" width="120">'.price($objp->total_ht).'</td>';
print '<td align="right" width="100">'.$commande_static->LibStatut($objp->fk_statut,$objp->facture,5).'</td></tr>'; print '<td align="right" width="100">'.$commande_static->LibStatut($objp->fk_statut,$objp->facture,5).'</td></tr>';
$i++; $i++;
@ -445,7 +445,7 @@ if ($socid > 0)
} }
/* /*
* Derniers contrats * Last linked contracts
*/ */
if($conf->contrat->enabled) if($conf->contrat->enabled)
{ {
@ -481,10 +481,10 @@ if ($socid > 0)
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'; print '<td>';
$contrat->id=$objp->id; $contrat->id=$objp->id;
$contrat->ref=$objp->ref; $contrat->ref=$objp->ref?$objp->ref:$objp->id;
print $contrat->getNomUrl(1); print $contrat->getNomUrl(1);
print "</td>\n"; print "</td>\n";
print '<td align="right" width="80">'.dolibarr_print_date($objp->dc)."</td>\n"; print '<td align="right" width="80">'.dolibarr_print_date($objp->dc,'day')."</td>\n";
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '<td align="right" nowrap="nowrap">'; print '<td align="right" nowrap="nowrap">';
$contrat->fetch_lignes(); $contrat->fetch_lignes();
@ -532,7 +532,7 @@ if ($socid > 0)
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td nowrap><a href="'.DOL_URL_ROOT."/fichinter/fiche.php?id=".$objp->id."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."</a>\n"; print '<td nowrap><a href="'.DOL_URL_ROOT."/fichinter/fiche.php?id=".$objp->id."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."</a>\n";
print "</td><td align=\"right\">".dolibarr_print_date($objp->di)."</td>\n"; print "</td><td align=\"right\">".dolibarr_print_date($objp->di,'day')."</td>\n";
print '</tr>'; print '</tr>';
$var=!$var; $var=!$var;
$i++; $i++;
@ -546,7 +546,7 @@ if ($socid > 0)
} }
/* /*
* Derniers projets associ<EFBFBD>s * Last linked projects
*/ */
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {

View File

@ -21,10 +21,10 @@
*/ */
/** /**
\file htdocs/commande/fiche.php * \file htdocs/commande/fiche.php
\ingroup commande * \ingroup commande
\brief Fiche commande client * \brief Fiche commande client
\version $Id$ * \version $Id$
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
@ -1218,7 +1218,7 @@ else
print '<tr><td>'.$langs->trans('Date').'</td>'; print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'daytext').'</td>'; print '<td colspan="2">'.dolibarr_print_date($commande->date,'daytext').'</td>';
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource(); print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0 && $conf->propal->enabled) if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id)
{ {
// Si source = propal // Si source = propal
$propal = new Propal($db); $propal = new Propal($db);

View File

@ -1119,9 +1119,9 @@ else
print '<td colspan="3">'; print '<td colspan="3">';
// multiprix // multiprix
if($conf->global->PRODUIT_MULTIPRICES == 1) if($conf->global->PRODUIT_MULTIPRICES == 1)
$form->select_produits('','p_idprod','',$conf->produit->limit_size,$contrat->societe->price_level); $form->select_produits('','p_idprod',1,$conf->produit->limit_size,$contrat->societe->price_level);
else else
$form->select_produits('','p_idprod','',$conf->produit->limit_size); $form->select_produits('','p_idprod',1,$conf->produit->limit_size);
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>'; if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';
print '<textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea>'; print '<textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea>';
print '</td>'; print '</td>';

View File

@ -20,10 +20,10 @@
*/ */
/** /**
\file htdocs/fourn/commande/fiche.php * \file htdocs/fourn/commande/fiche.php
\ingroup commande * \ingroup commande
\brief Fiche commande * \brief Fiche commande
\version $Id$ * \version $Id$
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
@ -109,42 +109,42 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree
if ($idprod > 0) if ($idprod > 0)
{ {
$prodfournprice->fetch($idprod); $prodfournprice->fetch($idprod);
// cas special pour lequel on a les meme reference que le fournisseur // cas special pour lequel on a les meme reference que le fournisseur
// $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle; // $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle;
$label = $prodfournprice->libelle; $label = $prodfournprice->libelle;
$societe=''; $societe='';
if ($commande->socid) if ($commande->socid)
{ {
$societe=new Societe($db); $societe=new Societe($db);
$societe->fetch($commande->socid); $societe->fetch($commande->socid);
} }
$desc = $prodfournprice->description; $desc = $prodfournprice->description;
$desc.= $prodfournprice->description && $_POST['np_desc'] ? "\n" : ""; $desc.= $prodfournprice->description && $_POST['np_desc'] ? "\n" : "";
$desc.= $_POST['np_desc']; $desc.= $_POST['np_desc'];
$tva_tx = get_default_tva($societe,$mysoc,$prodfournprice->tva_tx,$prodfournprice->id); $tva_tx = get_default_tva($societe,$mysoc,$prodfournprice->tva_tx,$prodfournprice->id);
$result=$commande->addline( $result=$commande->addline(
$desc, $desc,
$pu, $pu,
$_POST['qty'], $_POST['qty'],
$tva_tx, $tva_tx,
$prodfournprice->id, $prodfournprice->id,
$_POST['idprodfournprice'], $_POST['idprodfournprice'],
$prodfournprice->fourn_ref, $prodfournprice->fourn_ref,
$_POST['remise_percent'], $_POST['remise_percent'],
'HT' 'HT'
); );
} }
if ($idprod == -1) if ($idprod == -1)
{ {
// Quantity too low // Quantity too low
$mesg='<div class="error">'.$langs->trans("ErrorQtyTooLowForThisSupplier").'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorQtyTooLowForThisSupplier").'</div>';
} }
} }
else else
{ {
@ -168,20 +168,20 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree
} }
} }
} }
//print "xx".$tva_tx; exit; //print "xx".$tva_tx; exit;
if ($result > 0) if ($result > 0)
{ {
if ($_REQUEST['lang_id']) if ($_REQUEST['lang_id'])
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
} }
else else
{ {
$mesg='<div class="error">'.$commande->error.'</div>'; $mesg='<div class="error">'.$commande->error.'</div>';
} }
} }
} }
@ -896,7 +896,7 @@ if ($id > 0)
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td colspan="3">'; print '<td colspan="3">';
$html->select_produits_fournisseurs($commande->fourn_id,'','idprodfournprice',2,$filtre); $html->select_produits_fournisseurs($commande->fourn_id,'','idprodfournprice','',$filtre);
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>'; if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';

View File

@ -870,7 +870,7 @@ else
$var=! $var; $var=! $var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td colspan="4">'; print '<td colspan="4">';
$html->select_produits_fournisseurs($fac->socid,'','prodfournpriceid',2,$filtre); $html->select_produits_fournisseurs($fac->socid,'','prodfournpriceid','',$filtre);
print '</td>'; print '</td>';
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>'; print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';

View File

@ -932,15 +932,15 @@ class Form
/** /**
\brief Retourne la liste des produits en Ajax si ajax activé ou renvoie à select_produits_do * \brief Retourne la liste des produits en Ajax si ajax activé ou renvoie à select_produits_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 Filter on product type (1=customer, 2=supplier) * \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
\param limit Limite sur le nombre de lignes retournées * \param limit Limite sur le nombre de lignes retournées
\param price_level Niveau de prix en fonction du client * \param price_level Niveau de prix en fonction du client
\param status -1=Return all products, 0=Products not on sell, 1=Products on sell * \param status -1=Return all products, 0=Products not on sell, 1=Products on sell
*/ */
function select_produits($selected='',$htmlname='productid',$filtretype=1,$limit=20,$price_level=0,$status=1) function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1)
{ {
global $langs,$conf; global $langs,$conf;
@ -957,27 +957,27 @@ class Form
print '</tr>'; print '</tr>';
print '<tr class="nocellnopadd">'; print '<tr class="nocellnopadd">';
print '<td class="nobordernopadding" colspan="3">'; print '<td class="nobordernopadding" colspan="3">';
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtretype.'&status='.$status,''); print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status,'');
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} }
else else
{ {
$this->select_produits_do($selected,$htmlname,$filtretype,$limit,$price_level,'',$status); $this->select_produits_do($selected,$htmlname,$filtertype,$limit,$price_level,'',$status);
} }
} }
/** /**
\brief Retourne la liste des produits * \brief Retourne la liste des produits
\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 Filter on product type (1=customer, 2=supplier) * \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
\param limit Limite sur le nombre de lignes retournées * \param limit Limite sur le nombre de lignes retournées
\param price_level Niveau de prix en fonction du client * \param price_level Niveau de prix en fonction du client
\param ajaxkeysearch Filtre des produits si ajax est utilisé * \param ajaxkeysearch Filtre des produits si ajax est utilisé
\param status -1=Return all products, 0=Products not on sell, 1=Products on sell * \param status -1=Return all products, 0=Products not on sell, 1=Products on sell
*/ */
function select_produits_do($selected='',$htmlname='productid',$filtretype=1,$limit=20,$price_level=0,$ajaxkeysearch='',$status=1) function select_produits_do($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$ajaxkeysearch='',$status=1)
{ {
global $langs,$conf,$user; global $langs,$conf,$user;
@ -999,7 +999,7 @@ class Form
{ {
$sql.= ' AND IFNULL(c.visible,1)=1'; $sql.= ' AND IFNULL(c.visible,1)=1';
} }
if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype; if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')"; if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')";
$sql.= " ORDER BY p.nbvente DESC"; $sql.= " ORDER BY p.nbvente DESC";
if ($limit) $sql.= " LIMIT $limit"; if ($limit) $sql.= " LIMIT $limit";
@ -1016,7 +1016,7 @@ class Form
$sqld.= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang='". $langs->getDefaultLang() ."'"; $sqld.= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang='". $langs->getDefaultLang() ."'";
$sqld.= " ORDER BY p.nbvente DESC"; $sqld.= " ORDER BY p.nbvente DESC";
dolibarr_syslog("Form::select_departement sql=".$sql, LOG_DEBUG); dolibarr_syslog("Form::select_produits_do sql=".$sql, LOG_DEBUG);
$resultd = $this->db->query($sqld); $resultd = $this->db->query($sqld);
if ( $resultd ) $objtp = $this->db->fetch_object($resultd); if ( $resultd ) $objtp = $this->db->fetch_object($resultd);
} }
@ -1127,37 +1127,37 @@ 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 socid Id third party * \param socid Id third party
\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 Filter on product type (1=customer, 2=supplier) * \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
\param filtre Pour filtre sql * \param filtre Pour filtre sql
*/ */
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype=2,$filtre) function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtertype='',$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='.$filtretype,'working'); print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&socid='.$socid.'&type='.$filtertype.'&mode=2','working');
} }
else else
{ {
$this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre,''); $this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtertype,$filtre,'');
} }
} }
/** /**
\brief Retourne la liste des produits de fournisseurs * \brief Retourne la liste des produits de fournisseurs
\param socid Id société fournisseur (0 pour aucun filtre) * \param socid Id société fournisseur (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 filtertype Filter on product type (''=nofilter, 0=product, 1=service)
\param filtre Pour filtre sql * \param filtre Pour filtre sql
\param ajaxkeysearch Filtre des produits si ajax est utilisé * \param ajaxkeysearch Filtre des produits si ajax est utilisé
*/ */
function select_produits_fournisseurs_do($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='',$ajaxkeysearch='') function select_produits_fournisseurs_do($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$ajaxkeysearch='')
{ {
global $langs,$conf; global $langs,$conf;
@ -1173,7 +1173,7 @@ class Form
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur";
$sql.= " WHERE p.envente = 1"; $sql.= " WHERE p.envente = 1";
if ($socid) $sql.= " AND pf.fk_soc = ".$socid; if ($socid) $sql.= " AND pf.fk_soc = ".$socid;
if (! empty($filtretype)) $sql.=" AND p.fk_product_type=".$filtretype; if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
if (! empty($filtre)) $sql.=" ".$filtre; if (! empty($filtre)) $sql.=" ".$filtre;
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (pf.ref_fourn like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')"; if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (pf.ref_fourn like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')";
$sql.= " ORDER BY pf.ref_fourn DESC"; $sql.= " ORDER BY pf.ref_fourn DESC";

View File

@ -40,13 +40,13 @@ if (! empty($_GET['keysearch']))
if (isset($_GET['status'])) $status=$_GET['status']; if (isset($_GET['status'])) $status=$_GET['status'];
$form = new Form($db); $form = new Form($db);
if (empty($_GET['type']) || $_GET['type'] == 1) if (empty($_GET['mode']) || $_GET['mode'] == 1)
{ {
$form->select_produits_do("",$_GET["htmlname"],"","",$_GET["price_level"],$_GET["keysearch"],$status); $form->select_produits_do("",$_GET["htmlname"],$_GET["type"],"",$_GET["price_level"],$_GET["keysearch"],$status);
} }
if ($_GET['type'] == 2) if ($_GET['mode'] == 2)
{ {
$form->select_produits_fournisseurs_do($_GET["socid"],"",$_GET["htmlname"],"","",$_GET["keysearch"]); $form->select_produits_fournisseurs_do($_GET["socid"],"",$_GET["htmlname"],$_GET["type"],"",$_GET["keysearch"]);
} }
} }
else if (! empty($_GET['markup'])) else if (! empty($_GET['markup']))