Fix: use PropalLigne class

Works on hook
This commit is contained in:
Regis Houssin 2011-04-08 10:10:08 +00:00
parent 8c2bc07596
commit 83cf657906
6 changed files with 104 additions and 64 deletions

View File

@ -1,11 +1,11 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 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> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* *
* 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

View File

@ -5,7 +5,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* *
* 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
@ -823,7 +823,10 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
$localtax2_rate, $localtax2_rate,
$_POST['desc'], $_POST['desc'],
'HT', 'HT',
$info_bits); $info_bits,
'',
$_POST['fk_parent_line']
);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;

View File

@ -1,12 +1,12 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 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) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* *
* 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
@ -102,6 +102,8 @@ class Propal extends CommonObject
var $lines = array(); var $lines = array();
var $line; var $line;
var $newchild;
var $oldchild;
var $origin; var $origin;
var $origin_id; var $origin_id;
@ -438,7 +440,7 @@ class Propal extends CommonObject
* \param info_bits Miscellanous informations * \param info_bits Miscellanous informations
* \return int 0 en cas de succes * \return int 0 en cas de succes
*/ */
function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0) function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -468,9 +470,6 @@ class Propal extends CommonObject
$total_localtax1 = $tabprice[9]; $total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10]; $total_localtax2 = $tabprice[10];
if (empty($qty) && empty($special_code)) $special_code=3;
// Anciens indicateurs: $price, $remise (a ne plus utiliser) // Anciens indicateurs: $price, $remise (a ne plus utiliser)
$price = $pu; $price = $pu;
if ($remise_percent > 0) if ($remise_percent > 0)
@ -478,41 +477,40 @@ class Propal extends CommonObject
$remise = round(($pu * $remise_percent / 100), 2); $remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise; $price = $pu - $remise;
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet "; // Update line
$sql.= " SET qty='".$qty."'"; $this->line=new PropaleLigne($this->db);
$sql.= " , price='". price2num($price)."'"; // TODO A virer
$sql.= " , remise_percent='".$remise_percent."'"; // TODO A virer $this->line->rowid=$rowid;
$sql.= " , subprice=".price2num($pu); $this->line->desc=$desc;
$sql.= " , tva_tx=".price2num($txtva); $this->line->qty=$qty;
$sql.= " , localtax1_tx=".price2num($txlocaltax1); $this->line->tva_tx=$txtva;
$sql.= " , localtax2_tx=".price2num($txlocaltax2); $this->line->localtax1_tx=$txlocaltax1;
$sql.= " , description='".$this->db->escape($desc)."'"; $this->line->localtax2_tx=$txlocaltax2;
$sql.= " , total_ht=".price2num($total_ht); $this->line->remise_percent=$remise_percent;
$sql.= " , total_tva=".price2num($total_tva); $this->line->subprice=$pu;
$sql.= " , total_localtax1=".price2num($total_localtax1); $this->line->info_bits=$info_bits;
$sql.= " , total_localtax2=".price2num($total_localtax2); $this->line->total_ht=$total_ht;
$sql.= " , total_ttc=".price2num($total_ttc); $this->line->total_tva=$total_tva;
$sql.= " , info_bits=".$info_bits; $this->line->total_localtax1=$total_localtax1;
$sql.= " , special_code=".$special_code; $this->line->total_localtax2=$total_localtax2;
$sql.= " WHERE rowid = '".$rowid."'"; $this->line->total_ttc=$total_ttc;
$this->line->special_code=$special_code;
$result=$this->db->query($sql); $this->line->fk_parent_line=$fk_parent_line;
if (empty($qty) && empty($special_code)) $this->line->special_code=3;
// TODO deprecated
$this->line->price=$price;
$this->line->remise=$remise;
$result=$this->line->update();
if ($result > 0) if ($result > 0)
{ {
$this->update_price(1); $this->update_price(1);
$this->fk_propal = $this->id; $this->fk_propal = $this->id;
$this->rowid = $rowid; $this->rowid = $rowid;
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
$this->db->commit(); $this->db->commit();
return $result; return $result;
@ -2301,6 +2299,12 @@ class PropaleLigne
var $ref; // Reference produit var $ref; // Reference produit
var $libelle; // Label produit var $libelle; // Label produit
var $product_desc; // Description produit var $product_desc; // Description produit
var $localtax1_tx;
var $localtax2_tx;
var $total_localtax1;
var $total_localtax2;
/** /**
@ -2369,7 +2373,7 @@ class PropaleLigne
* \brief Insert object line propal in database * \brief Insert object line propal in database
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK
*/ */
function insert() function insert($notrigger=0)
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
@ -2495,28 +2499,44 @@ class PropaleLigne
* \brief Mise a jour de l'objet ligne de propale en base * \brief Mise a jour de l'objet ligne de propale en base
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function update() function update($notrigger=0)
{ {
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->total_localtax1)) $this->total_localtax1=0;
if (empty($this->total_localtax2)) $this->total_localtax2=0;
if (empty($this->marque_tx)) $this->marque_tx=0;
if (empty($this->marge_tx)) $this->marge_tx=0;
if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
$this->db->begin(); $this->db->begin();
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET";
$sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " description='".$this->db->escape($this->desc)."'";
if ($fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except; $sql.= " , tva_tx='".price2num($this->tva_tx)."'";
else $sql.= ",fk_remise_except=null"; $sql.= " , localtax1_tx=".price2num($this->localtax1_tx);
$sql.= ",tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , localtax2_tx=".price2num($this->localtax2_tx);
$sql.= ",qty='".price2num($this->qty)."'"; $sql.= " , qty='".price2num($this->qty)."'";
$sql.= ",subprice=".price2num($this->subprice).""; $sql.= " , subprice=".price2num($this->subprice)."";
$sql.= ",remise_percent=".price2num($this->remise_percent).""; $sql.= " , remise_percent=".price2num($this->remise_percent)."";
$sql.= ",price=".price2num($this->price).""; // TODO A virer $sql.= " , price=".price2num($this->price).""; // TODO A virer
$sql.= ",remise=".price2num($this->remise).""; // TODO A virer $sql.= " , remise=".price2num($this->remise).""; // TODO A virer
$sql.= ",info_bits='".$this->info_bits."'"; $sql.= " , info_bits='".$this->info_bits."'";
$sql.= ",total_ht=".price2num($this->total_ht).""; $sql.= " , total_ht=".price2num($this->total_ht)."";
$sql.= ",total_tva=".price2num($this->total_tva).""; $sql.= " , total_tva=".price2num($this->total_tva)."";
$sql.= ",total_ttc=".price2num($this->total_ttc).""; $sql.= " , total_ttc=".price2num($this->total_ttc)."";
$sql.= ",rang='".$this->rang."'"; $sql.= " , marge_tx='".$this->marge_tx."'";
$sql.= ",marge_tx='".$this->marge_tx."'"; $sql.= " , marque_tx='".$this->marque_tx."'";
$sql.= ",marque_tx='".$this->marque_tx."'"; $sql.= " , info_bits=".$this->info_bits;
if ($this->special_code != '') $sql.= " , special_code=".$this->special_code;
$sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("PropaleLigne::update sql=$sql"); dol_syslog("PropaleLigne::update sql=$sql");
@ -2524,6 +2544,16 @@ class PropaleLigne
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* *
* 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

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -48,6 +48,13 @@
echo ' - '.nl2br($line->product_label); echo ' - '.nl2br($line->product_label);
echo '<br>'; echo '<br>';
if (! empty($this->hooks)) {
foreach($this->hooks as $module) {
$module->formAddProductOption($this,$line->fk_parent_line);
echo '<br>';
}
}
// editeur wysiwyg // editeur wysiwyg
$nbrows=ROWS_2; $nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;