integration support multiprix
This commit is contained in:
parent
6c8ef21003
commit
2fbd6ac90c
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -41,8 +42,72 @@ if ($_POST["action"] == 'nbprod')
|
|||||||
Header("Location: produit.php");
|
Header("Location: produit.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
else if ($_POST["action"] == 'multiprix_num')
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", $_POST["value"]);
|
||||||
|
Header("Location: produit.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
if ($_GET["action"] == 'activate_multiprix')
|
||||||
|
{
|
||||||
|
$res=$db -> desc_table(MAIN_DB_PREFIX."product_price","price_level");
|
||||||
|
if(! $db -> fetch_row())
|
||||||
|
{
|
||||||
|
// on ajoute le champ price_level dans la table product_price
|
||||||
|
$field_desc = array('type'=>'TINYINT','value'=>'4','default'=>'1');
|
||||||
|
if(! $db -> add_field(MAIN_DB_PREFIX."product_price","price_level",$field_desc,"after date_price"))
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// on ajoute le champ price_level dans la table societe
|
||||||
|
if(! $db -> add_field(MAIN_DB_PREFIX."societe","price_level",$field_desc))
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
|
||||||
|
}
|
||||||
|
// on crée la table societe_prices
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$table = MAIN_DB_PREFIX."societe_prices";
|
||||||
|
$fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
|
||||||
|
$fields['fk_soc'] = array('type'=>'int','value'=>'11','null'=>'not null','default'=> '0');
|
||||||
|
$fields['tms'] = array('type'=>'timestamp','value'=>'14','null'=>'not null');
|
||||||
|
$fields['datec'] = array('type'=>'datetime','default'=> 'null');
|
||||||
|
$fields['fk_user_author'] = array('type'=>'int','value'=>'11','default'=> 'null');
|
||||||
|
$fields['price_level'] = array('type'=>'tinyint','value'=>'4','default'=> '1');
|
||||||
|
if(! $db -> create_table($table,$fields,"rowid","MyISAM"))
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "PRODUIT_MULTIPRICES", "1");
|
||||||
|
dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6");
|
||||||
|
Header("Location: produit.php");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "PRODUIT_MULTIPRICES", "1");
|
||||||
|
dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6");
|
||||||
|
Header("Location: produit.php");
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else if ($_GET["action"] == 'disable_multiprix')
|
||||||
|
{
|
||||||
|
//"ALTER TABLE ".MAIN_DB_PREFIX."product_price drop price_level"
|
||||||
|
dolibarr_del_const($db, "PRODUIT_MULTIPRICES");
|
||||||
|
dolibarr_del_const($db, "PRODUIT_MULTIPRICES_LIMIT");
|
||||||
|
Header("Location: produit.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affiche page
|
* Affiche page
|
||||||
@ -72,6 +137,54 @@ print '<td><input type="submit" class="button" value="'.$langs->trans("Modify").
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
// multiprix activation/desactivation
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td width="140">'.$langs->trans("Name").'</td>';
|
||||||
|
print '<td align="center"> </td>';
|
||||||
|
print '<td align="center">'.$langs->trans("Active").'</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
print "<form method=\"post\" action=\"produit.php\">";
|
||||||
|
print "<input type=\"hidden\" name=\"action\" value=\"multiprix\">";
|
||||||
|
print "<tr ".$bc[false].">";
|
||||||
|
print '<td width="80%">'.$langs->trans("MultiPricesAbility").'</td>';
|
||||||
|
print '<td align="center">';
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
print img_tick();
|
||||||
|
print '</td>';
|
||||||
|
print "<td align=\"center\">";
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 0)
|
||||||
|
print '<a href="produit.php?action=activate_multiprix">'.$langs->trans("Activate").'</a>';
|
||||||
|
else if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
print '<a href="produit.php?action=disable_multiprix">'.$langs->trans("Disable").'</a>';
|
||||||
|
print "</td>";
|
||||||
|
print '</tr>';
|
||||||
|
print '</table>';
|
||||||
|
print '</form>';
|
||||||
|
// multiprix nombre de prix a proposer
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
print '<br>';
|
||||||
|
print "<form method=\"post\" action=\"produit.php\">";
|
||||||
|
print "<input type=\"hidden\" name=\"action\" value=\"multiprix_num\">";
|
||||||
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
|
print "<tr class=\"liste_titre\">";
|
||||||
|
print ' <td width="80%">'.$langs->trans("Name")."</td>\n";
|
||||||
|
print " <td align=\"left\">".$langs->trans("Value")."</td>\n";
|
||||||
|
print " <td> </td>\n";
|
||||||
|
print "</tr><tr ".$bc[false].">";
|
||||||
|
print '<td>'.$langs->trans("MultiPricesNumPrices").'</td>';
|
||||||
|
print "<td align=\"left\"><input size=\"3\" type=\"text\" class=\"flat\" name=\"value\" value=\"".$conf->global->PRODUIT_MULTIPRICES_LIMIT."\"></td>";
|
||||||
|
print '<td><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '</table>';
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -190,7 +191,11 @@ if ($_GET["action"] == 'create')
|
|||||||
for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
|
for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
|
||||||
{
|
{
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
$form->select_produits('',"idprod".$i,'',$conf->produit->limit_size);
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$form->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level);
|
||||||
|
else
|
||||||
|
$form->select_produits('',"idprod".$i,'',$conf->produit->limit_size);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>';
|
print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>';
|
||||||
print '<td><input type="text" size="3" name="remise'.$i.'" value="'.$soc->remise_client.'"> %</td></tr>';
|
print '<td><input type="text" size="3" name="remise'.$i.'" value="'.$soc->remise_client.'"> %</td></tr>';
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 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) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -308,6 +309,18 @@ if ($_socid > 0)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
print '<tr><td nowrap>';
|
||||||
|
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
|
||||||
|
print $langs->trans("PriceLevel");
|
||||||
|
print '<td><td align="right">';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$objsoc->id.'">'.img_edit($langs->trans("Modify")).'</a>';
|
||||||
|
print '</td></tr></table>';
|
||||||
|
print '</td><td colspan="3">'.$objsoc->price_level."</td>";
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 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 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -882,7 +883,11 @@ if ($_GET['propalid'] > 0)
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$html->select_produits('','idprod','',$conf->produit->limit_size,$societe->price_level);
|
||||||
|
else
|
||||||
|
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea>';
|
print '<textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -216,6 +217,7 @@ class Commande
|
|||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
/* On positionne en mode brouillon la commande */
|
/* On positionne en mode brouillon la commande */
|
||||||
$this->brouillon = 1;
|
$this->brouillon = 1;
|
||||||
if (! $remise)
|
if (! $remise)
|
||||||
@ -241,12 +243,29 @@ class Commande
|
|||||||
$prod = new Product($this->db, $this->products[$i]);
|
$prod = new Product($this->db, $this->products[$i]);
|
||||||
if ($prod->fetch($this->products[$i]))
|
if ($prod->fetch($this->products[$i]))
|
||||||
{
|
{
|
||||||
$this->insert_product_generic($prod->libelle,
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
$this->soc_id;
|
||||||
|
$client = new Societe($this->db);
|
||||||
|
$client->fetch($this->soc_id);
|
||||||
|
//$prod->multiprices[$client->price_level]
|
||||||
|
$this->insert_product_generic($prod->libelle,
|
||||||
|
$prod->multiprices[$client->price_level],
|
||||||
|
$this->products_qty[$i],
|
||||||
|
$prod->tva_tx,
|
||||||
|
$this->products[$i],
|
||||||
|
$this->products_remise_percent[$i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->insert_product_generic($prod->libelle,
|
||||||
$prod->price,
|
$prod->price,
|
||||||
$this->products_qty[$i],
|
$this->products_qty[$i],
|
||||||
$prod->tva_tx,
|
$prod->tva_tx,
|
||||||
$this->products[$i],
|
$this->products[$i],
|
||||||
$this->products_remise_percent[$i]);
|
$this->products_remise_percent[$i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||||
@ -338,6 +357,7 @@ class Commande
|
|||||||
*/
|
*/
|
||||||
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0)
|
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
$qty = ereg_replace(',','.',$qty);
|
$qty = ereg_replace(',','.',$qty);
|
||||||
$pu = ereg_replace(',','.',$pu);
|
$pu = ereg_replace(',','.',$pu);
|
||||||
@ -358,7 +378,16 @@ class Commande
|
|||||||
if ($prod->fetch($fk_product) > 0)
|
if ($prod->fetch($fk_product) > 0)
|
||||||
{
|
{
|
||||||
$desc = $desc?$desc:$prod->libelle;
|
$desc = $desc?$desc:$prod->libelle;
|
||||||
$pu = $prod->price;
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
$client = new Societe($this->db);
|
||||||
|
$client->fetch($this->soc_id);
|
||||||
|
$pu = $prod->multiprices[$client->price_level];
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$pu = $prod->price;
|
||||||
$txtva = $prod->tva_tx;
|
$txtva = $prod->tva_tx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -968,4 +997,4 @@ class CommandeLigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -336,7 +336,11 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
|||||||
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
||||||
{
|
{
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size);
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size,$soc->price_level);
|
||||||
|
else
|
||||||
|
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td>';
|
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td>';
|
||||||
print '<td><input type="text" size="3" name="remise_percent'.$i.'" value="0">%</td></tr>';
|
print '<td><input type="text" size="3" name="remise_percent'.$i.'" value="0">%</td></tr>';
|
||||||
@ -808,7 +812,11 @@ else
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
$html->select_produits('','p_idprod','',$conf->produit->limit_size);
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$html->select_produits('','p_idprod','',$conf->produit->limit_size,$soc->price_level);
|
||||||
|
else
|
||||||
|
$html->select_produits('','p_idprod','',$conf->produit->limit_size);
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<textarea cols="50" name="np_desc" rows="1"></textarea>';
|
print '<textarea cols="50" name="np_desc" rows="1"></textarea>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -763,7 +764,11 @@ if ($_GET['action'] == 'create')
|
|||||||
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
||||||
{
|
{
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
$html->select_produits('','idprod'.$i,'',$conf->produit->limit_size);
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$html->select_produits('','idprod'.$i,'',$conf->produit->limit_size,$soc->price_level);
|
||||||
|
else
|
||||||
|
$html->select_produits('','idprod'.$i,'',$conf->produit->limit_size);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td>';
|
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td>';
|
||||||
print '<td nowrap="nowrap"><input type="text" size="1" name="remise_percent'.$i.'" value="0">%</td>';
|
print '<td nowrap="nowrap"><input type="text" size="1" name="remise_percent'.$i.'" value="0">%</td>';
|
||||||
@ -1568,7 +1573,11 @@ else
|
|||||||
$var=! $var;
|
$var=! $var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$html->select_produits('','idprod','',$conf->produit->limit_size,$soc->price_level);
|
||||||
|
else
|
||||||
|
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea></td>';
|
print '<textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea></td>';
|
||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2005 Destailleur Laurent <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||||
*
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* 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
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -566,6 +566,7 @@ class Contrat
|
|||||||
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart, $dateend)
|
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart, $dateend)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
global $conf;
|
||||||
|
|
||||||
dolibarr_syslog("contrat.class.php::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent, $datestart, $dateend");
|
dolibarr_syslog("contrat.class.php::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent, $datestart, $dateend");
|
||||||
|
|
||||||
@ -580,7 +581,11 @@ class Contrat
|
|||||||
if ($prod->fetch($fk_product) > 0)
|
if ($prod->fetch($fk_product) > 0)
|
||||||
{
|
{
|
||||||
$label = $prod->libelle;
|
$label = $prod->libelle;
|
||||||
$pu = $prod->price;
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$pu = $prod->multiprices[$this ->societe->price_level];
|
||||||
|
else
|
||||||
|
$pu = $prod->price;
|
||||||
$txtva = $prod->tva_tx;
|
$txtva = $prod->tva_tx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* 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
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -809,7 +809,11 @@ else
|
|||||||
|
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
$html->select_produits('','p_idprod','',$conf->produit->limit_size);
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$html->select_produits('','p_idprod','',$conf->produit->limit_size,$contrat->societe->price_level);
|
||||||
|
else
|
||||||
|
$html->select_produits('','p_idprod','',$conf->produit->limit_size);
|
||||||
print '<br>';
|
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>';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -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) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* 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
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -42,6 +42,7 @@ class Product
|
|||||||
var $libelle;
|
var $libelle;
|
||||||
var $description;
|
var $description;
|
||||||
var $price;
|
var $price;
|
||||||
|
var $multiprices=array();
|
||||||
var $tva_tx;
|
var $tva_tx;
|
||||||
var $type;
|
var $type;
|
||||||
var $seuil_stock_alerte;
|
var $seuil_stock_alerte;
|
||||||
@ -248,30 +249,89 @@ class Product
|
|||||||
*/
|
*/
|
||||||
function _log_price($user)
|
function _log_price($user)
|
||||||
{
|
{
|
||||||
// On supprimme ligne existante au cas ou
|
// MultiPrix : si activé, on gère tout ici, même le prix standard
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
|
global $conf;
|
||||||
$sql .= "WHERE date_price = now()";
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
$sql .= " and fk_product = ".$this->id;
|
{
|
||||||
$sql .= " and fk_user_author = ".$user->id;
|
$queryError = false;
|
||||||
$sql .= " and price = ".ereg_replace(",",".",$this->price);
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
$sql .= " and envente = ".$this->envente;
|
{
|
||||||
$sql .= " and tva_tx = ".$this->tva_tx;
|
if($this->multiprices["$i"] != "")
|
||||||
|
{
|
||||||
$this->db->query($sql);
|
// On supprimme ligne existante au cas ou
|
||||||
|
$sql_multiprix = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
|
||||||
// On ajoute nouveau tarif
|
$sql_multiprix .= "WHERE date_price = now()";
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,envente,tva_tx) ";
|
$sql_multiprix .= " and fk_product = ".$this->id;
|
||||||
$sql .= " VALUES(now(),".$this->id.",".$user->id.",".ereg_replace(",",".",$this->price).",".$this->envente.",".$this->tva_tx;
|
$sql_multiprix .= " and fk_user_author = ".$user->id;
|
||||||
$sql .= ")";
|
$sql_multiprix .= " and price = ".ereg_replace(",",".",$this->multiprices["$i"]);
|
||||||
if ($this->db->query($sql) )
|
|
||||||
{
|
$this->db->query($sql_multiprix);
|
||||||
return 1;
|
|
||||||
}
|
// On ajoute nouveau tarif
|
||||||
else
|
$sql_multiprix = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price_level,price) ";
|
||||||
{
|
$sql_multiprix .= " VALUES(now(),".$this->id.",".$user->id.",".$i.",".ereg_replace(",",".",$this->multiprices["$i"]);
|
||||||
dolibarr_print_error($this->db);
|
$sql_multiprix .= ")";
|
||||||
return 0;
|
if (! $this->db->query($sql_multiprix) )
|
||||||
}
|
$queryError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (strlen(trim($this->price)) > 0 )
|
||||||
|
{
|
||||||
|
// On supprimme ligne existante au cas ou
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
|
||||||
|
$sql .= "WHERE date_price = now()";
|
||||||
|
$sql .= " and fk_product = ".$this->id;
|
||||||
|
$sql .= " and fk_user_author = ".$user->id;
|
||||||
|
$sql .= " and price = ".ereg_replace(",",".",$this->price);
|
||||||
|
$sql .= " and envente = ".$this->envente;
|
||||||
|
$sql .= " and tva_tx = ".$this->tva_tx;
|
||||||
|
|
||||||
|
$this->db->query($sql);
|
||||||
|
|
||||||
|
// On ajoute nouveau tarif
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,envente,tva_tx) ";
|
||||||
|
$sql .= " VALUES(now(),".$this->id.",".$user->id.",".ereg_replace(",",".",$this->price).",".$this->envente.",".$this->tva_tx;
|
||||||
|
$sql .= ")";
|
||||||
|
if (! $this->db->query($sql) )
|
||||||
|
$queryError = true;
|
||||||
|
}
|
||||||
|
if($queryError)
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// On supprimme ligne existante au cas ou
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
|
||||||
|
$sql .= "WHERE date_price = now()";
|
||||||
|
$sql .= " and fk_product = ".$this->id;
|
||||||
|
$sql .= " and fk_user_author = ".$user->id;
|
||||||
|
$sql .= " and price = ".ereg_replace(",",".",$this->price);
|
||||||
|
$sql .= " and envente = ".$this->envente;
|
||||||
|
$sql .= " and tva_tx = ".$this->tva_tx;
|
||||||
|
|
||||||
|
$this->db->query($sql);
|
||||||
|
|
||||||
|
// On ajoute nouveau tarif
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,envente,tva_tx) ";
|
||||||
|
$sql .= " VALUES(now(),".$this->id.",".$user->id.",".ereg_replace(",",".",$this->price).",".$this->envente.",".$this->tva_tx;
|
||||||
|
$sql .= ")";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -396,29 +456,67 @@ class Product
|
|||||||
*/
|
*/
|
||||||
function update_price($id, $user)
|
function update_price($id, $user)
|
||||||
{
|
{
|
||||||
if (strlen(trim($this->price)) > 0 )
|
//multiprix
|
||||||
{
|
global $conf;
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
$sql .= " SET price = " . ereg_replace(",",".",$this->price);
|
{
|
||||||
$sql .= " WHERE rowid = " . $id;
|
if (strlen(trim($this->price)) > 0 )
|
||||||
|
{
|
||||||
if ( $this->db->query($sql) )
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
||||||
{
|
$sql .= " SET price = " . ereg_replace(",",".",$this->price);
|
||||||
$this->_log_price($user);
|
$sql .= " WHERE rowid = " . $id;
|
||||||
return 1;
|
|
||||||
}
|
if ( $this->db->query($sql) )
|
||||||
else
|
{
|
||||||
{
|
$this->_log_price($user);
|
||||||
dolibarr_print_error($this->db);
|
return 1;
|
||||||
return -1;
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
else
|
dolibarr_print_error($this->db);
|
||||||
{
|
return -1;
|
||||||
$this->error = "Prix saisi invalide.";
|
}
|
||||||
return -2;
|
}
|
||||||
}
|
else if(count($this->multiprices) > 0)
|
||||||
}
|
{
|
||||||
|
$this->_log_price($user);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error = "Prix saisi invalide.";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (strlen(trim($this->price)) > 0 )
|
||||||
|
{
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
||||||
|
$sql .= " SET price = " . ereg_replace(",",".",$this->price);
|
||||||
|
$sql .= " WHERE rowid = " . $id;
|
||||||
|
|
||||||
|
if ( $this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$this->_log_price($user);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error = "Prix saisi invalide.";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -430,6 +528,7 @@ class Product
|
|||||||
function fetch($id='',$ref='')
|
function fetch($id='',$ref='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
global $conf;
|
||||||
|
|
||||||
// Verification parametres
|
// Verification parametres
|
||||||
if (! $id && ! $ref)
|
if (! $id && ! $ref)
|
||||||
@ -479,7 +578,50 @@ class Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
if ($ref)
|
||||||
|
{
|
||||||
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product ";
|
||||||
|
$sql.= "WHERE ref = '".addslashes($ref)."'";
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$result = $this->db->fetch_array();
|
||||||
|
$prodid = $result["rowid"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
|
{
|
||||||
|
$sql= "SELECT price, tva_tx, envente ";
|
||||||
|
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||||
|
$sql.= "where price_level=".$i." and ";
|
||||||
|
if ($id) $sql.= "fk_product = ".$id." ";
|
||||||
|
if ($ref) $sql.= "fk_product = ".$prodid." ";
|
||||||
|
$sql.= "order by date_price DESC limit 1";
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ( $result )
|
||||||
|
{
|
||||||
|
$result = $this->db->fetch_array();
|
||||||
|
if($result["price"] != "")
|
||||||
|
$this -> multiprices[$i]=$result["price"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT reel, fk_entrepot";
|
$sql = "SELECT reel, fk_entrepot";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock WHERE fk_product = ".$this->id;
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock WHERE fk_product = ".$this->id;
|
||||||
$result = $this->db->query($sql) ;
|
$result = $this->db->query($sql) ;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2005 Régis Houssin <regis.houssin@cap-networks.com>
|
* Copyright (C) 2005 Régis Houssin <regis.houssin@cap-networks.com>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -74,7 +75,17 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
|||||||
$product->duration_value = $_POST["duration_value"];
|
$product->duration_value = $_POST["duration_value"];
|
||||||
$product->duration_unit = $_POST["duration_unit"];
|
$product->duration_unit = $_POST["duration_unit"];
|
||||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
||||||
|
// MultiPrix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
|
{
|
||||||
|
if($_POST["price_".$i])
|
||||||
|
$product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]);
|
||||||
|
else
|
||||||
|
$product->multiprices["$i"] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
$e_product = $product;
|
$e_product = $product;
|
||||||
|
|
||||||
$id = $product->create($user);
|
$id = $product->create($user);
|
||||||
@ -286,8 +297,18 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td><input name="price" size="10" value="'.$product->price.'"></td></tr>';
|
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").' 1</td><td><input name="price" size="10" value="'.$product->price.'"></td></tr>';
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").' '.$i.'</td><td><input name="price_'.$i.'" size="10" value="'.$product->multiprices["$i"].'"></td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PRIX
|
||||||
|
else
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td><input name="price" size="10" value="'.$product->price.'"></td></tr>';
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
||||||
print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
||||||
@ -460,11 +481,25 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
// Libelle
|
// Libelle
|
||||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
|
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Prix
|
// MultiPrix
|
||||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
print '</tr>';
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").' 1</td><td>'.price($product->price).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").' '.$i.'</td><td>'.price($product->multiprices["$i"]).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Prix
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Statut
|
// Statut
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||||
if ($product->envente) print $langs->trans("OnSell");
|
if ($product->envente) print $langs->trans("OnSell");
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2005 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>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -57,9 +58,19 @@ if ($_POST["action"] == 'update_price' &&
|
|||||||
$result = $product->fetch($_GET["id"]);
|
$result = $product->fetch($_GET["id"]);
|
||||||
|
|
||||||
$product->price = ereg_replace(" ","",$_POST["price"]);
|
$product->price = ereg_replace(" ","",$_POST["price"]);
|
||||||
|
// MultiPrix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
|
{
|
||||||
|
if($_POST["price_".$i])
|
||||||
|
$product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]);
|
||||||
|
else
|
||||||
|
$product->multiprices["$i"] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $product->update_price($product->id, $user) > 0 )
|
if ( $product->update_price($product->id, $user) > 0 )
|
||||||
|
|
||||||
{
|
{
|
||||||
$_GET["action"] = '';
|
$_GET["action"] = '';
|
||||||
$mesg = 'Fiche mise à jour';
|
$mesg = 'Fiche mise à jour';
|
||||||
@ -168,9 +179,20 @@ print '</tr>';
|
|||||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
|
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Prix
|
|
||||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
|
||||||
|
|
||||||
|
// MultiPrix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").' 1</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").' '.$i.'</td><td>'.price($product->multiprices["$i"]).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Prix
|
||||||
|
else
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||||
// Statut
|
// Statut
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||||
if ($product->envente) print $langs->trans("OnSell");
|
if ($product->envente) print $langs->trans("OnSell");
|
||||||
@ -213,20 +235,59 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
|||||||
print '<input type="hidden" name="action" value="update_price">';
|
print '<input type="hidden" name="action" value="update_price">';
|
||||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
print '<tr><td width="15%">'.$langs->trans('SellingPrice').' 1</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
||||||
|
else
|
||||||
print '<tr><td width="15%">'.$langs->trans('SellingPrice').'</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
print '<tr><td width="15%">'.$langs->trans('SellingPrice').'</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
||||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
// MultiPrix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
|
{
|
||||||
|
print '<form action="price.php?id='.$product->id.'" method="post">';
|
||||||
|
print '<input type="hidden" name="action" value="update_price">';
|
||||||
|
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
print '<tr><td width="15%">'.$langs->trans("SellingPrice").' '.$i.'</td><td><input name="price_'.$i.'" size="10" value="'.price($product->multiprices["$i"]).'"></td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
|
print '</table>';
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Liste des evolutions du prix
|
// Liste des evolutions du prix
|
||||||
$sql = "SELECT p.rowid, p.price, ".$db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
|
$sql = "SELECT p.rowid, p.price, ";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u";
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
$sql .= " WHERE fk_product = ".$product->id;
|
{
|
||||||
$sql .= " AND p.fk_user_author = u.rowid ";
|
$sql .= "p.price_level, ";
|
||||||
$sql .= " ORDER BY p.date_price DESC ";
|
$sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u";
|
||||||
|
$sql .= " WHERE fk_product = ".$product->id;
|
||||||
|
$sql .= " AND p.fk_user_author = u.rowid ";
|
||||||
|
$sql .= " ORDER BY p.price_level ASC ";
|
||||||
|
$sql .= ",p.date_price DESC ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u";
|
||||||
|
$sql .= " WHERE fk_product = ".$product->id;
|
||||||
|
$sql .= " AND p.fk_user_author = u.rowid ";
|
||||||
|
$sql .= " ORDER BY p.date_price DESC ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sql .= $db->plimit();
|
$sql .= $db->plimit();
|
||||||
$result = $db->query($sql) ;
|
$result = $db->query($sql) ;
|
||||||
|
|
||||||
@ -254,6 +315,8 @@ if ($result)
|
|||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
|
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
print '<td>'.$langs->trans("MultiPriceLevelsName").'</td>';
|
||||||
print '<td>'.$langs->trans("Price").'</td>';
|
print '<td>'.$langs->trans("Price").'</td>';
|
||||||
print '<td>'.$langs->trans("ChangedBy").'</td>';
|
print '<td>'.$langs->trans("ChangedBy").'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -269,6 +332,10 @@ if ($result)
|
|||||||
// Date
|
// Date
|
||||||
print "<td>".dolibarr_print_date($objp->dp,"%d %b %Y %H:%M:%S")."</td>";
|
print "<td>".dolibarr_print_date($objp->dp,"%d %b %Y %H:%M:%S")."</td>";
|
||||||
|
|
||||||
|
// catégorie de Prix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
print "<td>".$objp->price_level."</td>";
|
||||||
|
|
||||||
// Prix
|
// Prix
|
||||||
print "<td>".price($objp->price)."</td>";
|
print "<td>".price($objp->price)."</td>";
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -132,7 +133,8 @@ class Propal
|
|||||||
*/
|
*/
|
||||||
function insert_product($idproduct, $qty, $remise_percent=0, $p_desc='')
|
function insert_product($idproduct, $qty, $remise_percent=0, $p_desc='')
|
||||||
{
|
{
|
||||||
dolibarr_syslog("propal.class.php::insert_product $idproduct, $qty, $remise_percent, $p_desc");
|
global $conf;
|
||||||
|
dolibarr_syslog("propal.class.php::insert_product $idproduct, $qty, $remise_percent, $p_desc");
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
@ -141,13 +143,26 @@ class Propal
|
|||||||
|
|
||||||
if ($idproduct)
|
if ($idproduct)
|
||||||
{
|
{
|
||||||
$prod = new Product($this->db, $idproduct);
|
$prod = new Product($this->db, $idproduct);
|
||||||
if ($prod->fetch($idproduct) > 0)
|
if ($prod->fetch($idproduct) > 0)
|
||||||
{
|
{
|
||||||
$txtva = $prod->tva_tx;
|
// multiprix
|
||||||
$price = price2num($prod->price);
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
$subprice = price2num($prod->price);
|
{
|
||||||
|
$this -> fetch_client();
|
||||||
|
$price = price2num($prod->multiprices[$this->client->price_level]);
|
||||||
|
$subprice = price2num($prod->multiprices[$this->client->price_level]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$price = price2num($prod->price);
|
||||||
|
$subprice = price2num($prod->price);
|
||||||
|
}
|
||||||
|
$txtva = $prod->tva_tx;
|
||||||
|
/*
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
// Calcul remise et nouveau prix
|
// Calcul remise et nouveau prix
|
||||||
$remise = 0;
|
$remise = 0;
|
||||||
if ($remise_percent > 0)
|
if ($remise_percent > 0)
|
||||||
@ -341,7 +356,6 @@ class Propal
|
|||||||
function create()
|
function create()
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
// Définition paramètres
|
// Définition paramètres
|
||||||
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
|
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 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) 2003 Brian Fraval <brian@fraval.org>
|
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
|
||||||
*
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -78,6 +78,8 @@ class Societe {
|
|||||||
|
|
||||||
var $stcomm_id;
|
var $stcomm_id;
|
||||||
var $statut_commercial;
|
var $statut_commercial;
|
||||||
|
|
||||||
|
var $price_level;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -406,7 +408,7 @@ class Societe {
|
|||||||
function fetch($socid, $user=0)
|
function fetch($socid, $user=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
global $conf;
|
||||||
/* Lecture des permissions */
|
/* Lecture des permissions */
|
||||||
if ($user <> 0)
|
if ($user <> 0)
|
||||||
{
|
{
|
||||||
@ -427,6 +429,9 @@ class Societe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT s.idp, s.nom, s.address,'.$this->db->pdate('s.datec').' as dc, prefix_comm';
|
$sql = 'SELECT s.idp, s.nom, s.address,'.$this->db->pdate('s.datec').' as dc, prefix_comm';
|
||||||
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$sql .= ', s.price_level';
|
||||||
$sql .= ','. $this->db->pdate('s.tms').' as date_update';
|
$sql .= ','. $this->db->pdate('s.tms').' as date_update';
|
||||||
$sql .= ', s.tel, s.fax, s.url,s.cp,s.ville, s.note, s.siren, client, fournisseur';
|
$sql .= ', s.tel, s.fax, s.url,s.cp,s.ville, s.note, s.siren, client, fournisseur';
|
||||||
$sql .= ', s.siret, s.capital, s.ape, s.tva_intra, s.rubrique';
|
$sql .= ', s.siret, s.capital, s.ape, s.tva_intra, s.rubrique';
|
||||||
@ -536,6 +541,9 @@ class Societe {
|
|||||||
|
|
||||||
$this->rubrique = $obj->rubrique;
|
$this->rubrique = $obj->rubrique;
|
||||||
$this->note = $obj->note;
|
$this->note = $obj->note;
|
||||||
|
// multiprix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
$this->price_level = $obj->price_level;
|
||||||
|
|
||||||
$result = 1;
|
$result = 1;
|
||||||
}
|
}
|
||||||
@ -849,6 +857,27 @@ class Societe {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function set_price_level($price_level, $user)
|
||||||
|
{
|
||||||
|
if ($this->id)
|
||||||
|
{
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
|
||||||
|
$sql .= " SET price_level = '".$price_level."'";
|
||||||
|
$sql .= " WHERE idp = " . $this->id .";";
|
||||||
|
|
||||||
|
$this->db->query($sql);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices ";
|
||||||
|
$sql .= " ( datec, fk_soc, price_level, fk_user_author )";
|
||||||
|
$sql .= " VALUES (now(),".$this->id.",'".$price_level."',".$user->id.")";
|
||||||
|
|
||||||
|
if (! $this->db->query($sql) )
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user