mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-16 06:21:28 +01:00
New: Some changes to support the type of line in entities.
This commit is contained in:
@@ -893,6 +893,8 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
if ($mesg) print $mesg."<br>";
|
if ($mesg) print $mesg."<br>";
|
||||||
|
|
||||||
|
$product_static=new Product($db);
|
||||||
|
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->fetch($_GET['propalid'],$_GET['ref']);
|
$propal->fetch($_GET['propalid'],$_GET['ref']);
|
||||||
|
|
||||||
@@ -1230,7 +1232,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes de propale
|
* Lines
|
||||||
*/
|
*/
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
@@ -1292,15 +1294,20 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne;
|
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne;
|
||||||
|
|
||||||
// Affiche ligne produit
|
// Show product and description
|
||||||
$text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
$product_static->type=$objp->fk_product_type;
|
||||||
if ($objp->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
|
$product_static->id=$objp->fk_product;
|
||||||
else $text.= img_object($langs->trans('ShowProduct'),'product');
|
$product_static->ref=$objp->ref;
|
||||||
$text.= ' '.$objp->ref.'</a>';
|
$product_static->libelle=$objp->product;
|
||||||
|
$text=$product_static->getNomUrl(1);
|
||||||
$text.= ' - '.$objp->product;
|
$text.= ' - '.$objp->product;
|
||||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||||
|
|
||||||
|
// Show range
|
||||||
print_date_range($objp->date_start,$objp->date_end);
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
|
|
||||||
|
// Add description in form
|
||||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||||
{
|
{
|
||||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||||
@@ -1333,7 +1340,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print nl2br($objp->description);
|
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||||
|
else $text = img_object($langs->trans('Product'),'product');
|
||||||
|
print $text.' '.nl2br($objp->description);
|
||||||
|
|
||||||
|
// Show range
|
||||||
print_date_range($objp->date_start,$objp->date_end);
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|||||||
@@ -545,7 +545,8 @@ class Commande extends CommonObject
|
|||||||
// Added by Matelli (http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
// Added by Matelli (http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||||
// Add start and end dates to the new line
|
// Add start and end dates to the new line
|
||||||
$this->lines[$i]->date_start,
|
$this->lines[$i]->date_start,
|
||||||
$this->lines[$i]->date_end
|
$this->lines[$i]->date_end,
|
||||||
|
$this->lines[$i]->type
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($resql < 0)
|
if ($resql < 0)
|
||||||
@@ -614,7 +615,7 @@ class Commande extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute une ligne de produit (associe a un produit/service predefini ou non)
|
* \brief Add a line
|
||||||
* \param commandeid Id de la commande
|
* \param commandeid Id de la commande
|
||||||
* \param desc Description de la ligne
|
* \param desc Description de la ligne
|
||||||
* \param pu_ht Prix unitaire HT
|
* \param pu_ht Prix unitaire HT
|
||||||
@@ -626,8 +627,9 @@ class Commande extends CommonObject
|
|||||||
* \param fk_remise_exscept Id remise
|
* \param fk_remise_exscept Id remise
|
||||||
* \param price_base_type HT or TTC
|
* \param price_base_type HT or TTC
|
||||||
* \param pu_ttc Prix unitaire TTC
|
* \param pu_ttc Prix unitaire TTC
|
||||||
* \param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
* \param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||||
* \param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
* \param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||||
|
* \param type Type of line (0=product, 1=service)
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
* \see add_product
|
* \see add_product
|
||||||
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
|
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
|
||||||
@@ -635,9 +637,10 @@ class Commande extends CommonObject
|
|||||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||||
*/
|
*/
|
||||||
function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='')
|
function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0)
|
||||||
{
|
{
|
||||||
dol_syslog("Commande::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end", LOG_DEBUG);
|
dol_syslog("Commande::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type", LOG_DEBUG);
|
||||||
|
|
||||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
@@ -658,6 +661,9 @@ class Commande extends CommonObject
|
|||||||
}
|
}
|
||||||
$desc=trim($desc);
|
$desc=trim($desc);
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if ($type < 0) return -1;
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@@ -697,6 +703,7 @@ class Commande extends CommonObject
|
|||||||
$ligne->total_ht=$total_ht;
|
$ligne->total_ht=$total_ht;
|
||||||
$ligne->total_tva=$total_tva;
|
$ligne->total_tva=$total_tva;
|
||||||
$ligne->total_ttc=$total_ttc;
|
$ligne->total_ttc=$total_ttc;
|
||||||
|
$ligne->product_type=$type;
|
||||||
|
|
||||||
// \TODO Ne plus utiliser
|
// \TODO Ne plus utiliser
|
||||||
$ligne->price=$price;
|
$ligne->price=$price;
|
||||||
@@ -1597,22 +1604,23 @@ class Commande extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mets a jour une ligne de commande
|
* \brief Update a line in database
|
||||||
* \param rowid Id de la ligne de facture
|
* \param rowid Id of line to update
|
||||||
* \param desc Description de la ligne
|
* \param desc Description de la ligne
|
||||||
* \param pu Prix unitaire
|
* \param pu Prix unitaire
|
||||||
* \param qty Quantity
|
* \param qty Quantity
|
||||||
* \param remise_percent Pourcentage de remise de la ligne
|
* \param remise_percent Pourcentage de remise de la ligne
|
||||||
* \param tva_tx Taux TVA
|
* \param tva_tx Taux TVA
|
||||||
* \param price_base_type HT or TTC
|
* \param price_base_type HT or TTC
|
||||||
* \param info_bits Miscellanous informations on line
|
* \param info_bits Miscellanous informations on line
|
||||||
* \param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
* \param date_start Start date of the line
|
||||||
* \param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
* \param date_end End date of the line
|
||||||
* \return int < 0 si erreur, > 0 si ok
|
* \param type Type of line (0=product, 1=service)
|
||||||
|
* \return int < 0 si erreur, > 0 si ok
|
||||||
*/
|
*/
|
||||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='')
|
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0)
|
||||||
{
|
{
|
||||||
dol_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $date_start, $date_end");
|
dol_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $date_start, $date_end, $type");
|
||||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
if ($this->brouillon)
|
if ($this->brouillon)
|
||||||
@@ -1660,17 +1668,11 @@ class Commande extends CommonObject
|
|||||||
$sql.= ",remise_percent='".price2num($remise_percent)."'";
|
$sql.= ",remise_percent='".price2num($remise_percent)."'";
|
||||||
$sql.= ",tva_tx='".price2num($txtva)."'";
|
$sql.= ",tva_tx='".price2num($txtva)."'";
|
||||||
$sql.= ",qty='".price2num($qty)."'";
|
$sql.= ",qty='".price2num($qty)."'";
|
||||||
//if ($date_end) { $sql.= ",date_start='$date_end'"; }
|
$sql.= ",product_type='".$type."'";
|
||||||
//else { $sql.=',date_start=null'; }
|
|
||||||
//if ($date_end) { $sql.= ",date_end='$date_end'"; }
|
|
||||||
//else { $sql.=',date_end=null'; }
|
|
||||||
$sql.= ",info_bits='".$info_bits."'";
|
$sql.= ",info_bits='".$info_bits."'";
|
||||||
$sql.= ",total_ht='".price2num($total_ht)."'";
|
$sql.= ",total_ht='".price2num($total_ht)."'";
|
||||||
$sql.= ",total_tva='".price2num($total_tva)."'";
|
$sql.= ",total_tva='".price2num($total_tva)."'";
|
||||||
$sql.= ",total_ttc='".price2num($total_ttc)."'";
|
$sql.= ",total_ttc='".price2num($total_ttc)."'";
|
||||||
|
|
||||||
// Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
|
||||||
// Save the start and end date in the database
|
|
||||||
if ($date_start) { $sql.= ",date_start='".$this->db->idate($date_start)."'"; }
|
if ($date_start) { $sql.= ",date_start='".$this->db->idate($date_start)."'"; }
|
||||||
else { $sql.=',date_start=null'; }
|
else { $sql.=',date_start=null'; }
|
||||||
if ($date_end) { $sql.= ",date_end='".$this->db->idate($date_end)."'"; }
|
if ($date_end) { $sql.= ",date_end='".$this->db->idate($date_end)."'"; }
|
||||||
@@ -2133,6 +2135,7 @@ class CommandeLigne
|
|||||||
var $fk_facture;
|
var $fk_facture;
|
||||||
var $desc; // Description ligne
|
var $desc; // Description ligne
|
||||||
var $fk_product; // Id produit predefini
|
var $fk_product; // Id produit predefini
|
||||||
|
var $product_type = 0; // Type 0 = product, 1 = Service
|
||||||
|
|
||||||
var $qty; // Quantite (exemple 2)
|
var $qty; // Quantite (exemple 2)
|
||||||
var $tva_tx; // Taux tva produit/service (exemple 19.6)
|
var $tva_tx; // Taux tva produit/service (exemple 19.6)
|
||||||
@@ -2177,7 +2180,7 @@ class CommandeLigne
|
|||||||
*/
|
*/
|
||||||
function fetch($rowid)
|
function fetch($rowid)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.description, cd.price, cd.qty, cd.tva_tx,';
|
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.price, cd.qty, cd.tva_tx,';
|
||||||
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
|
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
|
||||||
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc, cd.marge_tx, cd.marque_tx, cd.rang,';
|
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc, cd.marge_tx, cd.marque_tx, cd.rang,';
|
||||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
||||||
@@ -2202,6 +2205,8 @@ class CommandeLigne
|
|||||||
$this->remise_percent = $objp->remise_percent;
|
$this->remise_percent = $objp->remise_percent;
|
||||||
$this->fk_remise_except = $objp->fk_remise_except;
|
$this->fk_remise_except = $objp->fk_remise_except;
|
||||||
$this->produit_id = $objp->fk_product;
|
$this->produit_id = $objp->fk_product;
|
||||||
|
$this->fk_product = $objp->fk_product;
|
||||||
|
$this->product_type = $objp->product_type;
|
||||||
$this->info_bits = $objp->info_bits;
|
$this->info_bits = $objp->info_bits;
|
||||||
$this->total_ht = $objp->total_ht;
|
$this->total_ht = $objp->total_ht;
|
||||||
$this->total_tva = $objp->total_tva;
|
$this->total_tva = $objp->total_tva;
|
||||||
@@ -2294,7 +2299,7 @@ class CommandeLigne
|
|||||||
// Insertion dans base de la ligne
|
// Insertion dans base de la ligne
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
|
||||||
$sql.= ' (fk_commande, description, qty, tva_tx,';
|
$sql.= ' (fk_commande, description, qty, tva_tx,';
|
||||||
$sql.= ' fk_product, remise_percent, subprice, price, remise, fk_remise_except,';
|
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
|
||||||
$sql.= ' rang, marge_tx, marque_tx,';
|
$sql.= ' rang, marge_tx, marque_tx,';
|
||||||
// Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
// Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||||
// Insert in the database the start and end dates
|
// Insert in the database the start and end dates
|
||||||
@@ -2305,6 +2310,7 @@ class CommandeLigne
|
|||||||
$sql.= " '".price2num($this->tva_tx)."',";
|
$sql.= " '".price2num($this->tva_tx)."',";
|
||||||
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
||||||
else { $sql.='null,'; }
|
else { $sql.='null,'; }
|
||||||
|
$sql.= " '".$this->product_type."',";
|
||||||
$sql.= " '".price2num($this->remise_percent)."',";
|
$sql.= " '".price2num($this->remise_percent)."',";
|
||||||
$sql.= " ".($this->subprice!=''?"'".price2num($this->subprice)."'":"null").",";
|
$sql.= " ".($this->subprice!=''?"'".price2num($this->subprice)."'":"null").",";
|
||||||
$sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").",";
|
$sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").",";
|
||||||
|
|||||||
@@ -289,6 +289,19 @@ if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->facture->creer)
|
|||||||
*/
|
*/
|
||||||
if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
|
$result=0;
|
||||||
|
|
||||||
|
if (empty($_POST['idprod']) && $_POST["type"] < 0)
|
||||||
|
{
|
||||||
|
$fac->error = $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")) ;
|
||||||
|
$result = -1 ;
|
||||||
|
}
|
||||||
|
if (empty($_POST['idprod']) && empty($_POST["pu"]))
|
||||||
|
{
|
||||||
|
$fac->error = $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")) ;
|
||||||
|
$result = -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST['qty'] && (($_POST['pu'] != '' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod']))
|
if ($_POST['qty'] && (($_POST['pu'] != '' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod']))
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
@@ -348,6 +361,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
|||||||
$desc = $prod->description;
|
$desc = $prod->description;
|
||||||
$desc.= ($prod->description && $_POST['np_desc']) ? ((dol_textishtml($prod->description) || dol_textishtml($_POST['np_desc']))?"<br>":"\n") : "";
|
$desc.= ($prod->description && $_POST['np_desc']) ? ((dol_textishtml($prod->description) || dol_textishtml($_POST['np_desc']))?"<br>":"\n") : "";
|
||||||
$desc.= $_POST['np_desc'];
|
$desc.= $_POST['np_desc'];
|
||||||
|
$type = $prod->type;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -355,48 +369,53 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
|||||||
$tva_tx=eregi_replace('\*','',$_POST['tva_tx']);
|
$tva_tx=eregi_replace('\*','',$_POST['tva_tx']);
|
||||||
$tva_npr=eregi('\*',$_POST['tva_tx'])?1:0;
|
$tva_npr=eregi('\*',$_POST['tva_tx'])?1:0;
|
||||||
$desc=$_POST['dp_desc'];
|
$desc=$_POST['dp_desc'];
|
||||||
|
$type=$_POST["type"];
|
||||||
}
|
}
|
||||||
$desc=dol_htmlcleanlastbr($desc);
|
$desc=dol_htmlcleanlastbr($desc);
|
||||||
|
|
||||||
$info_bits=0;
|
$info_bits=0;
|
||||||
if ($tva_npr) $info_bits |= 0x01;
|
if ($tva_npr) $info_bits |= 0x01;
|
||||||
|
|
||||||
if($prod->price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($prod->price_min)))
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
|
if($prod->price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($prod->price_min)))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Insert line
|
|
||||||
$result = $commande->addline(
|
|
||||||
$_POST['id'],
|
|
||||||
$desc,
|
|
||||||
$pu_ht,
|
|
||||||
$_POST['qty'],
|
|
||||||
$tva_tx,
|
|
||||||
$_POST['idprod'],
|
|
||||||
$_POST['remise_percent'],
|
|
||||||
$info_bits,
|
|
||||||
0,
|
|
||||||
$price_base_type,
|
|
||||||
$pu_ttc,
|
|
||||||
$date_start,
|
|
||||||
$date_end
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
{
|
||||||
$outputlangs = $langs;
|
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
|
||||||
if (! empty($_REQUEST['lang_id']))
|
|
||||||
{
|
|
||||||
$outputlangs = new Translate("",$conf);
|
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
|
||||||
}
|
|
||||||
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$commande->error.'</div>';
|
// Insert line
|
||||||
|
$result = $commande->addline(
|
||||||
|
$_POST['id'],
|
||||||
|
$desc,
|
||||||
|
$pu_ht,
|
||||||
|
$_POST['qty'],
|
||||||
|
$tva_tx,
|
||||||
|
$_POST['idprod'],
|
||||||
|
$_POST['remise_percent'],
|
||||||
|
$info_bits,
|
||||||
|
0,
|
||||||
|
$price_base_type,
|
||||||
|
$pu_ttc,
|
||||||
|
$date_start,
|
||||||
|
$date_end,
|
||||||
|
$type
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$outputlangs = $langs;
|
||||||
|
if (! empty($_REQUEST['lang_id']))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||||
|
}
|
||||||
|
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$commande->error.'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,9 +430,11 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
|
|||||||
if (! $commande->fetch($_POST['id']) > 0) dol_print_error($db);
|
if (! $commande->fetch($_POST['id']) > 0) dol_print_error($db);
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$description=dol_htmlcleanlastbr($_POST['eldesc']);
|
$date_start='';
|
||||||
|
$date_end='';
|
||||||
$date_start=dol_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']);
|
$date_start=dol_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']);
|
||||||
$date_end=dol_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']);
|
$date_end=dol_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']);
|
||||||
|
$description=dol_htmlcleanlastbr($_POST['eldesc']);
|
||||||
|
|
||||||
// Define info_bits
|
// Define info_bits
|
||||||
$info_bits=0;
|
$info_bits=0;
|
||||||
@@ -423,11 +444,37 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
|
|||||||
$vat_rate=$_POST['tva_tx'];
|
$vat_rate=$_POST['tva_tx'];
|
||||||
$vat_rate=eregi_replace('\*','',$vat_rate);
|
$vat_rate=eregi_replace('\*','',$vat_rate);
|
||||||
|
|
||||||
if ($pruduct->price_min && ($_POST['productid']!='') && ( price2num($_POST['pu'])*(1-price2num($_POST['elremise_percent'])/100) < price2num($pruduct->price_min)))
|
// Check parameters
|
||||||
|
if (empty($_POST['productid']) && $_POST["type"] < 0)
|
||||||
{
|
{
|
||||||
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($pruduct->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
|
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
|
||||||
|
$result = -1 ;
|
||||||
|
}
|
||||||
|
// Check minimum price
|
||||||
|
if(! empty($_POST['productid']))
|
||||||
|
{
|
||||||
|
$productid = $_POST['productid'];
|
||||||
|
$product = new Product($db);
|
||||||
|
$product->fetch($productid);
|
||||||
|
$type=$product->type;
|
||||||
|
}
|
||||||
|
if ($product->price_min && ($_POST['productid']!='') && ( price2num($_POST['pu'])*(1-price2num($_POST['elremise_percent'])/100) < price2num($product->price_min)))
|
||||||
|
{
|
||||||
|
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
|
||||||
|
$result=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define params
|
||||||
|
if (! empty($_POST['productid']))
|
||||||
|
{
|
||||||
|
$type=$product->type;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
$type=$_POST["type"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$result = $commande->updateline($_POST['elrowid'],
|
$result = $commande->updateline($_POST['elrowid'],
|
||||||
$description,
|
$description,
|
||||||
@@ -438,7 +485,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
|
|||||||
'HT',
|
'HT',
|
||||||
$info_bits,
|
$info_bits,
|
||||||
$date_start,
|
$date_start,
|
||||||
$date_end
|
$date_end,
|
||||||
|
$type
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
@@ -1110,6 +1158,8 @@ else
|
|||||||
{
|
{
|
||||||
if ($mesg) print $mesg.'<br>';
|
if ($mesg) print $mesg.'<br>';
|
||||||
|
|
||||||
|
$product_static=new Product($db);
|
||||||
|
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$result=$commande->fetch($_GET['id'],$_GET['ref']);
|
$result=$commande->fetch($_GET['id'],$_GET['ref']);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@@ -1402,17 +1452,15 @@ else
|
|||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes de commandes
|
* Lines
|
||||||
*/
|
*/
|
||||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, ';
|
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
|
||||||
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,';
|
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,';
|
||||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||||
|
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||||
|
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid, ';
|
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid, ';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
// Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
|
||||||
// Load start and end dates
|
|
||||||
$sql.= ','.$db->pdate('l.date_start').' as date_start,';
|
|
||||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
||||||
$sql.= ' WHERE l.fk_commande = '.$commande->id;
|
$sql.= ' WHERE l.fk_commande = '.$commande->id;
|
||||||
@@ -1443,6 +1491,13 @@ else
|
|||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
|
// Show product and description
|
||||||
|
$type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
|
||||||
|
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||||
|
// was not saved.
|
||||||
|
if (! empty($objp->date_start)) $type=1;
|
||||||
|
if (! empty($objp->date_end)) $type=1;
|
||||||
|
|
||||||
// Ligne en mode visu
|
// Ligne en mode visu
|
||||||
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
|
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
|
||||||
{
|
{
|
||||||
@@ -1452,17 +1507,20 @@ else
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||||
|
|
||||||
// Affiche ligne produit
|
// Show product and description
|
||||||
$text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
$product_static->type=$objp->fk_product_type;
|
||||||
if ($objp->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
|
$product_static->id=$objp->fk_product;
|
||||||
else $text.= img_object($langs->trans('ShowProduct'),'product');
|
$product_static->ref=$objp->ref;
|
||||||
$text.= ' '.$objp->ref.'</a>';
|
$product_static->libelle=$objp->product;
|
||||||
|
$text=$product_static->getNomUrl(1);
|
||||||
$text.= ' - '.$objp->product;
|
$text.= ' - '.$objp->product;
|
||||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||||
// Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
|
||||||
// Print the start and end dates
|
// Show range
|
||||||
print_date_range($objp->date_start,$objp->date_end);
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
|
|
||||||
|
// Add description in form
|
||||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||||
{
|
{
|
||||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||||
@@ -1496,9 +1554,11 @@ else
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print nl2br($objp->description);
|
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||||
// Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
else $text = img_object($langs->trans('Product'),'product');
|
||||||
// Print the start and end dates
|
print $text.' '.nl2br($objp->description);
|
||||||
|
|
||||||
|
// Show range
|
||||||
print_date_range($objp->date_start,$objp->date_end);
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@@ -1592,17 +1652,28 @@ else
|
|||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||||
|
|
||||||
|
|
||||||
|
// Show product and description
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<input type="hidden" name="productid" value="'.$objp->fk_product.'">';
|
print '<input type="hidden" name="productid" value="'.$objp->fk_product.'">';
|
||||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
$product_static->type=$objp->fk_product_type;
|
||||||
if ($objp->fk_product_type==1) print img_object($langs->trans('ShowService'),'service');
|
$product_static->id=$objp->fk_product;
|
||||||
else print img_object($langs->trans('ShowProduct'),'product');
|
$product_static->ref=$objp->ref;
|
||||||
print ' '.$objp->ref.'</a>';
|
$product_static->libelle=$objp->product;
|
||||||
print ' - '.nl2br($objp->product);
|
$text=$product_static->getNomUrl(1);
|
||||||
|
$text.= ' - '.$objp->product;
|
||||||
|
print $text;
|
||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}
|
||||||
// editeur wysiwyg
|
else
|
||||||
|
{
|
||||||
|
print $html->select_type_of_lines($objp->product_type,'type',1);
|
||||||
|
if ($conf->produit->enabled && $conf->service->enabled) print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Editor wysiwyg
|
||||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
|
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||||
@@ -1611,7 +1682,10 @@ else
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<textarea name="eldesc" class="flat" cols="70" rows="1">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>';
|
print '<textarea name="eldesc" class="flat" cols="70" rows="'.ROWS_2.'">';
|
||||||
|
//print $objp->description;
|
||||||
|
print dol_htmlentitiesbr_decode($objp->description);
|
||||||
|
print '</textarea>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.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
|
||||||
@@ -118,6 +118,8 @@ $id = $_GET['id'];
|
|||||||
$ref= $_GET['ref'];
|
$ref= $_GET['ref'];
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
|
$product_static=new Product($db);
|
||||||
|
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
|
if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
|
||||||
{
|
{
|
||||||
@@ -207,7 +209,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<tr><td>'.$langs->trans('Date').'</td>';
|
print '<tr><td>'.$langs->trans('Date').'</td>';
|
||||||
print '<td colspan="2">'.dol_print_date($commande->date,'daytext').'</td>';
|
print '<td colspan="2">'.dol_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);
|
||||||
@@ -345,10 +347,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes de commandes
|
* Lines
|
||||||
*/
|
*/
|
||||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.fk_remise_except, l.remise_percent, l.subprice,';
|
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, l.fk_remise_except, l.remise_percent, l.subprice,';
|
||||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
||||||
|
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||||
|
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l";
|
$sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l";
|
||||||
@@ -381,29 +385,40 @@ if ($id > 0 || ! empty($ref))
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
|
// Show product and description
|
||||||
|
$type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
|
||||||
|
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||||
|
// was not saved.
|
||||||
|
if (! empty($objp->date_start)) $type=1;
|
||||||
|
if (! empty($objp->date_end)) $type=1;
|
||||||
|
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||||
|
|
||||||
// Affiche ligne produit
|
// Show product and description
|
||||||
$text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
$product_static->type=$objp->fk_product_type;
|
||||||
if ($objp->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
|
$product_static->id=$objp->fk_product;
|
||||||
else $text.= img_object($langs->trans('ShowProduct'),'product');
|
$product_static->ref=$objp->ref;
|
||||||
$text.= ' '.$objp->ref.'</a>';
|
$product_static->libelle=$objp->product;
|
||||||
|
$text=$product_static->getNomUrl(1);
|
||||||
$text.= ' - '.$objp->product;
|
$text.= ' - '.$objp->product;
|
||||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||||
// Print the start and end dates
|
|
||||||
|
// Show range
|
||||||
print_date_range($objp->date_start,$objp->date_end);
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
|
|
||||||
|
// Add description in form
|
||||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||||
{
|
{
|
||||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -431,7 +446,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print nl2br($objp->description);
|
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||||
|
else $text = img_object($langs->trans('Product'),'product');
|
||||||
|
print $text.' '.nl2br($objp->description);
|
||||||
|
|
||||||
|
// Show range
|
||||||
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
}
|
}
|
||||||
@@ -446,7 +466,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
else print ' ';
|
else print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if ($objp->remise_percent > 0)
|
if ($objp->remise_percent > 0)
|
||||||
{
|
{
|
||||||
print '<td align="right">'.$objp->remise_percent."%</td>\n";
|
print '<td align="right">'.$objp->remise_percent."%</td>\n";
|
||||||
|
|||||||
@@ -976,10 +976,12 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
|
|||||||
$fac = new Facture($db,'',$_POST['facid']);
|
$fac = new Facture($db,'',$_POST['facid']);
|
||||||
if (! $fac->fetch($_POST['facid']) > 0) dol_print_error($db);
|
if (! $fac->fetch($_POST['facid']) > 0) dol_print_error($db);
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
$date_start='';
|
$date_start='';
|
||||||
$date_end='';
|
$date_end='';
|
||||||
$date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']);
|
$date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']);
|
||||||
$date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']);
|
$date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']);
|
||||||
|
$description=dol_htmlcleanlastbr($_POST['desc']);
|
||||||
|
|
||||||
// Define info_bits
|
// Define info_bits
|
||||||
$info_bits=0;
|
$info_bits=0;
|
||||||
@@ -992,27 +994,27 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
|
|||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($_POST['productid']) && $_POST["type"] < 0)
|
if (empty($_POST['productid']) && $_POST["type"] < 0)
|
||||||
{
|
{
|
||||||
$fac->error = $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")) ;
|
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
|
||||||
$result = -1 ;
|
$result = -1 ;
|
||||||
}
|
}
|
||||||
// Check minimum price
|
// Check minimum price
|
||||||
if(! empty($_POST['productid']))
|
if(! empty($_POST['productid']))
|
||||||
{
|
{
|
||||||
$productid = $_POST['productid'];
|
$productid = $_POST['productid'];
|
||||||
$pruduct = new Product($db);
|
$product = new Product($db);
|
||||||
$pruduct->fetch($productid);
|
$product->fetch($productid);
|
||||||
$type=$pruduct->type;
|
$type=$product->type;
|
||||||
}
|
}
|
||||||
if($pruduct->price_min && ($_POST['productid']!='') && (price2num($_POST['price'])*(1-price2num($_POST['remise_percent'])/100) < price2num($pruduct->price_min)))
|
if($product->price_min && ($_POST['productid']!='') && (price2num($_POST['price'])*(1-price2num($_POST['remise_percent'])/100) < price2num($product->price_min)))
|
||||||
{
|
{
|
||||||
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($pruduct->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>';
|
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>';
|
||||||
$result=-1;
|
$result=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define params
|
// Define params
|
||||||
if (! empty($_POST['productid']))
|
if (! empty($_POST['productid']))
|
||||||
{
|
{
|
||||||
$type=$pruduct->type;
|
$type=$product->type;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1023,7 +1025,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
|
|||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$result = $fac->updateline($_POST['rowid'],
|
$result = $fac->updateline($_POST['rowid'],
|
||||||
$_POST['desc'],
|
$description,
|
||||||
$_POST['price'],
|
$_POST['price'],
|
||||||
$_POST['qty'],
|
$_POST['qty'],
|
||||||
$_POST['remise_percent'],
|
$_POST['remise_percent'],
|
||||||
@@ -2682,7 +2684,7 @@ else
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lines of invoice
|
* Lines
|
||||||
*/
|
*/
|
||||||
$sql = 'SELECT l.fk_product, l.product_type, l.description, l.qty, l.rowid, l.tva_taux,';
|
$sql = 'SELECT l.fk_product, l.product_type, l.description, l.qty, l.rowid, l.tva_taux,';
|
||||||
$sql.= ' l.fk_remise_except,';
|
$sql.= ' l.fk_remise_except,';
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
if ($mesg) print "$mesg<br>";
|
if ($mesg) print "$mesg<br>";
|
||||||
|
|
||||||
|
$product_static=new Product($db);
|
||||||
|
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->fetch($_GET['propalid'],$_GET["ref"]);
|
$propal->fetch($_GET['propalid'],$_GET["ref"]);
|
||||||
|
|
||||||
@@ -310,8 +312,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes de propale
|
* Lines
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
@@ -350,30 +351,40 @@ if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
|
// Show product and description
|
||||||
|
$type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
|
||||||
|
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||||
|
// was not saved.
|
||||||
|
if (! empty($objp->date_start)) $type=1;
|
||||||
|
if (! empty($objp->date_end)) $type=1;
|
||||||
|
|
||||||
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
|
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
|
||||||
{
|
{
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
print '<td>';
|
||||||
if ($objp->fk_product_type==1)
|
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne;
|
||||||
print img_object($langs->trans('ShowService'),'service');
|
|
||||||
else
|
// Show product and description
|
||||||
print img_object($langs->trans('ShowProduct'),'product');
|
$product_static->type=$objp->fk_product_type;
|
||||||
print ' '.$objp->ref.'</a> - '.stripslashes(nl2br($objp->product));
|
$product_static->id=$objp->fk_product;
|
||||||
if ($objp->date_start && $objp->date_end)
|
$product_static->ref=$objp->ref;
|
||||||
|
$product_static->libelle=$objp->product;
|
||||||
|
$text=$product_static->getNomUrl(1);
|
||||||
|
$text.= ' - '.$objp->product;
|
||||||
|
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||||
|
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||||
|
|
||||||
|
// Show range
|
||||||
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
|
|
||||||
|
// Add description in form
|
||||||
|
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||||
{
|
{
|
||||||
print ' (Du '.dol_print_date($objp->date_start).' au '.dol_print_date($objp->date_end).')';
|
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||||
}
|
}
|
||||||
if ($objp->date_start && ! $objp->date_end)
|
|
||||||
{
|
|
||||||
print ' (A partir du '.dol_print_date($objp->date_start).')';
|
|
||||||
}
|
|
||||||
if (! $objp->date_start && $objp->date_end)
|
|
||||||
{
|
|
||||||
print " (Jusqu'au ".dol_print_date($objp->date_end).')';
|
|
||||||
}
|
|
||||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):'';
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -401,19 +412,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print nl2br($objp->description);
|
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||||
if ($objp->date_start && $objp->date_end)
|
else $text = img_object($langs->trans('Product'),'product');
|
||||||
{
|
print $text.' '.nl2br($objp->description);
|
||||||
print ' (Du '.dol_print_date($objp->date_start).' au '.dol_print_date($objp->date_end).')';
|
|
||||||
}
|
// Show range
|
||||||
if ($objp->date_start && ! $objp->date_end)
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
{
|
|
||||||
print ' (A partir du '.dol_print_date($objp->date_start).')';
|
|
||||||
}
|
|
||||||
if (! $objp->date_start && $objp->date_end)
|
|
||||||
{
|
|
||||||
print " (Jusqu'au ".dol_print_date($objp->date_end).')';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
$commande->loadExpeditions(1);
|
$commande->loadExpeditions(1);
|
||||||
|
|
||||||
|
$product_static=new Product($db);
|
||||||
|
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->socid);
|
$soc->fetch($commande->socid);
|
||||||
|
|
||||||
@@ -225,7 +227,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<tr><td>'.$langs->trans('Date').'</td>';
|
print '<tr><td>'.$langs->trans('Date').'</td>';
|
||||||
print '<td colspan="2">'.dol_print_date($commande->date,'daytext').'</td>';
|
print '<td colspan="2">'.dol_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)
|
if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id)
|
||||||
{
|
{
|
||||||
// Si source = propal
|
// Si source = propal
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
@@ -269,11 +271,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||||
print $langs->trans('DeliveryAddress');
|
print $langs->trans('DeliveryAddress');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
print '</td><td colspan="2">';
|
print '</td><td colspan="2">';
|
||||||
|
|
||||||
if ($_GET['action'] == 'editdelivery_adress')
|
if ($_GET['action'] == 'editdelivery_adress')
|
||||||
{
|
{
|
||||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
|
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
|
||||||
@@ -284,7 +286,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conditions et modes de r<>glement
|
// Conditions et modes de r<>glement
|
||||||
print '<tr><td height="10">';
|
print '<tr><td height="10">';
|
||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||||
@@ -371,14 +373,18 @@ if ($id > 0 || ! empty($ref))
|
|||||||
*/
|
*/
|
||||||
print '<table class="liste" width="100%">';
|
print '<table class="liste" width="100%">';
|
||||||
|
|
||||||
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.price, cd.tva_tx, cd.subprice,";
|
$sql = "SELECT cd.rowid, cd.fk_product, cd.product_type, cd.description, cd.price, cd.tva_tx, cd.subprice,";
|
||||||
$sql.= " qty";
|
$sql.= " cd.qty,";
|
||||||
|
$sql.= ' '.$db->pdate('cd.date_start').' as date_start,';
|
||||||
|
$sql.= ' '.$db->pdate('cd.date_end').' as date_end,';
|
||||||
|
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||||
|
$sql.= ' p.description as product_desc';
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||||
$sql.= " WHERE cd.fk_commande = ".$commande->id;
|
$sql.= " WHERE cd.fk_commande = ".$commande->id;
|
||||||
// $sql.= " AND p.fk_product_type <> 1"; Why this line ?
|
// $sql.= " AND p.fk_product_type <> 1"; Why this line ?
|
||||||
$sql.= " GROUP by cd.rowid, cd.fk_product";
|
$sql.= " GROUP by cd.rowid, cd.fk_product";
|
||||||
$sql.= " ORDER BY cd.rowid";
|
$sql.= " ORDER BY cd.rang, cd.rowid";
|
||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
dol_syslog("commande.php sql=".$sql, LOG_DEBUG);
|
dol_syslog("commande.php sql=".$sql, LOG_DEBUG);
|
||||||
@@ -407,28 +413,36 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$reste_a_livrer = array();
|
$reste_a_livrer = array();
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
|
||||||
|
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
|
// Show product and description
|
||||||
|
$type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
|
||||||
|
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||||
|
// was not saved.
|
||||||
|
if (! empty($objp->date_start)) $type=1;
|
||||||
|
if (! empty($objp->date_end)) $type=1;
|
||||||
|
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||||
|
|
||||||
$product->fetch($objp->fk_product);
|
// Show product and description
|
||||||
// LDR Add a product line from object product
|
$product_static->type=$objp->fk_product_type;
|
||||||
$text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$product->id.'">';
|
$product_static->id=$objp->fk_product;
|
||||||
if ($product->type==1) $text.= img_object($langs->trans('ShowService'),'service');
|
$product_static->ref=$objp->ref;
|
||||||
else $text.= img_object($langs->trans('ShowProduct'),'product');
|
$product_static->libelle=$objp->product;
|
||||||
$text.= ' '.$product->ref.'</a>';
|
$text=$product_static->getNomUrl(1);
|
||||||
$text.= ' - '.$product->libelle;
|
$text.= ' - '.$objp->product;
|
||||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||||
// Print the start and end dates
|
|
||||||
|
// Show range
|
||||||
print_date_range($objp->date_start,$objp->date_end);
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
|
|
||||||
|
// Add description in form
|
||||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||||
{
|
{
|
||||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||||
@@ -438,7 +452,14 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<td>".nl2br($objp->description)."</td>\n";
|
print "<td>";
|
||||||
|
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||||
|
else $text = img_object($langs->trans('Product'),'product');
|
||||||
|
print $text.' '.nl2br($objp->description);
|
||||||
|
|
||||||
|
// Show range
|
||||||
|
print_date_range($objp->date_start,$objp->date_end);
|
||||||
|
print "</td>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<td align="center">'.$objp->qty.'</td>';
|
print '<td align="center">'.$objp->qty.'</td>';
|
||||||
|
|||||||
Reference in New Issue
Block a user