From 2d90256640f987125704f5cdc07065f6fc43cc98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Mar 2015 12:51:29 +0100 Subject: [PATCH] Revert "Refactor 1" --- htdocs/comm/propal/class/propal.class.php | 6 +- htdocs/commande/class/commande.class.php | 74 +++++----- htdocs/compta/facture/class/facture.class.php | 36 ++++- htdocs/core/class/commoninvoice.class.php | 95 ------------ htdocs/core/class/commonobject.class.php | 30 ++-- htdocs/core/class/commonobjectline.class.php | 13 -- htdocs/core/class/commonorder.class.php | 136 +----------------- htdocs/core/lib/functions.lib.php | 4 +- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/core/tpl/objectline_edit.tpl.php | 4 +- htdocs/core/tpl/objectline_view.tpl.php | 16 +-- htdocs/fichinter/class/fichinter.class.php | 1 + htdocs/filefunc.inc.php | 1 + .../class/fournisseur.commande.class.php | 98 ++++++------- .../fourn/class/fournisseur.facture.class.php | 122 ++++++---------- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/margin/admin/margin.php | 3 + htdocs/projet/admin/project.php | 7 +- htdocs/societe/admin/societe.php | 5 +- 20 files changed, 208 insertions(+), 449 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 533df89b773..8909441b9c1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -107,9 +107,6 @@ class Propal extends CommonObject var $products=array(); var $extraparams=array(); - /** - * @var PropaleLigne[] - */ var $lines = array(); var $line; @@ -2804,6 +2801,9 @@ class Propal extends CommonObject */ class PropaleLigne extends CommonObject { + var $db; + var $error; + public $element='propaldet'; public $table_element='propaldet'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2d377758aa5..1bcfa1ee7cb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -104,10 +104,7 @@ class Commande extends CommonOrder var $user_author_id; - /** - * @var OrderLine[] - */ - var $lines = array(); + var $lines = array(); //Incorterms var $fk_incoterms; @@ -1638,12 +1635,12 @@ class Commande extends CommonOrder $line = new OrderLine($this->db); - $line->rowid = $objp->rowid; + $line->rowid = $objp->rowid; // \deprecated $line->id = $objp->rowid; $line->fk_commande = $objp->fk_commande; - $line->commande_id = $objp->fk_commande; + $line->commande_id = $objp->fk_commande; // \deprecated $line->label = $objp->custom_label; - $line->desc = $objp->description; + $line->desc = $objp->description; // Description ligne $line->product_type = $objp->product_type; $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; @@ -1669,11 +1666,11 @@ class Commande extends CommonOrder $line->special_code = $objp->special_code; $line->fk_parent_line = $objp->fk_parent_line; - $line->ref = $objp->product_ref; + $line->ref = $objp->product_ref; // TODO deprecated $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; + $line->libelle = $objp->product_label; // TODO deprecated $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; + $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; // Produit ou service $line->date_start = $this->db->jdate($objp->date_start); @@ -3178,7 +3175,6 @@ class Commande extends CommonOrder $this->lines[$i] = new OrderLine($this->db); $this->lines[$i]->id = $obj->rowid; - $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; $this->lines[$i]->description = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; @@ -3265,44 +3261,56 @@ class Commande extends CommonOrder */ class OrderLine extends CommonOrderLine { + var $db; + var $error; + public $element='commandedet'; public $table_element='commandedet'; var $oldline; - /** - * Id of parent order - * @var int - */ - public $fk_commande; - - /** - * Id of parent order - * @var int - * @deprecated Use fk_commande - */ - public $commande_id; - // From llx_commandedet + var $rowid; var $fk_parent_line; var $fk_facture; var $label; + var $desc; // Description ligne + var $fk_product; // Id produit predefini + var $product_type = 0; // Type 0 = product, 1 = Service + + var $qty; // Quantity (example 2) + var $tva_tx; // VAT Rate for product/service (example 19.6) + var $localtax1_tx; // Local tax 1 + var $localtax2_tx; // Local tax 2 + var $localtax1_type; // Local tax 1 type + var $localtax2_type; // Local tax 2 type + var $subprice; // U.P. HT (example 100) + var $remise_percent; // % for line discount (example 20%) var $fk_remise_except; var $rang = 0; var $fk_fournprice; - - /** - * Buy price without taxes - * @var float - */ var $pa_ht; var $marge_tx; var $marque_tx; + var $info_bits = 0; // Bit 0: 0 si TVA normal - 1 si TVA NPR + // Bit 1: 0 ligne normale - 1 si ligne de remise fixe + var $special_code = 0; + var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + var $total_localtax1; // Total local tax 1 for the line + var $total_localtax2; // Total local tax 2 for the line + var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - /** - * @deprecated - */ - var $remise; + // Ne plus utiliser + var $remise; + var $price; + + // From llx_product + var $ref; // deprecated + var $libelle; // deprecated + var $product_ref; + var $product_label; // Label produit + var $product_desc; // Description produit // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Start and end date of the line diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 38fab4c217c..48955652ac5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3408,7 +3408,6 @@ class Facture extends CommonInvoice $this->lines[$i] = new FactureLigne($this->db); $this->lines[$i]->id = $obj->rowid; - $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; // deprecated $this->lines[$i]->description = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; @@ -3607,12 +3606,16 @@ class Facture extends CommonInvoice */ class FactureLigne extends CommonInvoiceLine { + var $db; + var $error; + public $element='facturedet'; public $table_element='facturedet'; var $oldline; //! From llx_facturedet + var $rowid; //! Id facture var $fk_facture; //! Id parent line @@ -3620,9 +3623,17 @@ class FactureLigne extends CommonInvoiceLine var $label; // deprecated //! Description ligne var $desc; + var $fk_product; // Id of predefined product + var $product_type = 0; // Type 0 = product, 1 = Service + var $qty; // Quantity (example 2) + var $tva_tx; // Taux tva produit/service (example 19.6) + var $localtax1_tx; // Local tax 1 + var $localtax2_tx; // Local tax 2 var $localtax1_type; // Local tax 1 type var $localtax2_type; // Local tax 2 type + var $subprice; // P.U. HT (example 100) + var $remise_percent; // % de la remise ligne (example 20%) var $fk_remise_except; // Link to line into llx_remise_except var $rang = 0; @@ -3631,6 +3642,10 @@ class FactureLigne extends CommonInvoiceLine var $marge_tx; var $marque_tx; + var $info_bits = 0; // Liste d'options cumulables: + // Bit 0: 0 si TVA normal - 1 si TVA NPR + // Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) + var $special_code; // Liste d'options non cumulabels: // 1: frais de port // 2: ecotaxe @@ -3639,6 +3654,15 @@ class FactureLigne extends CommonInvoiceLine var $origin; var $origin_id; + //! Total HT de la ligne toute quantite et incluant la remise ligne + var $total_ht; + //! Total TVA de la ligne toute quantite et incluant la remise ligne + var $total_tva; + var $total_localtax1; //Total Local tax 1 de la ligne + var $total_localtax2; //Total Local tax 2 de la ligne + //! Total TTC de la ligne toute quantite et incluant la remise ligne + var $total_ttc; + var $fk_code_ventilation = 0; var $date_start; @@ -3667,6 +3691,16 @@ class FactureLigne extends CommonInvoiceLine */ public $fk_prev_id; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + /** * Load invoice line from database * diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 1a7ebfc34c8..6087a5a0adb 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -400,100 +400,5 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; */ abstract class CommonInvoiceLine extends CommonObjectLine { - /** - * Quantity - * @var int - */ - public $qty; - - /** - * Unit price before taxes - * @var float - */ - public $subprice; - - /** - * Type of the product. 0 for product 1 for service - * @var int - */ - public $product_type = 0; - - /** - * Id of corresponding product - * @var int - */ - public $fk_product; - - /** - * VAT % - * @var float - */ - public $tva_tx; - - /** - * Local tax 1 % - * @var float - */ - public $localtax1_tx; - - /** - * Local tax 2 % - * @var float - */ - public $localtax2_tx; - - /** - * Percent of discount - * @var float - */ - public $remise_percent; - - /** - * Total amount before taxes - * @var float - */ - public $total_ht; - - /** - * Total VAT amount - * @var float - */ - public $total_tva; - - /** - * Total local tax 1 amount - * @var float - */ - public $total_localtax1; - - /** - * Total local tax 2 amount - * @var float - */ - public $total_localtax2; - - /** - * Total amount with taxes - * @var float - */ - public $total_ttc; - - /** - * Liste d'options cumulables: - * Bit 0: 0 si TVA normal - 1 si TVA NPR - * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) - * @var int - */ - public $info_bits = 0; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; - } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5dc524d964c..97157c6d408 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2685,9 +2685,10 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param string $selected Object line selected * @param int $dateSelector 1=Show also date range input fields + * @param int $permtoedit Permission to edit line * @return void */ - function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) + function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $permtoedit=0) { global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user; @@ -2780,7 +2781,7 @@ abstract class CommonObject } else { - $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline); + $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline,$permtoedit); } $i++; @@ -2792,7 +2793,7 @@ abstract class CommonObject * TODO Move this into an output class file (htmlline.class.php) * * @param string $action GET/POST action - * @param CommonObjectLine $line Selected object line to output + * @param array $line Selected object line to output * @param string $var Is it a an odd line (true) * @param int $num Number of line (0) * @param int $i I @@ -2801,14 +2802,13 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param string $selected Object line selected * @param object $extrafieldsline Object of extrafield line attribute + * @param int $permtoedit Permission to edit * @return void */ - function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) + function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0,$permtoedit=0) { global $conf,$langs,$user,$object,$hookmanager; - global $form,$bc,$bcdd, $object_rights; - - $object_rights = $this->getRights(); + global $form,$bc,$bcdd; $element=$this->element; @@ -2821,7 +2821,7 @@ abstract class CommonObject if (! empty($line->date_end)) $type=1; // deprecated // Ligne en mode visu - if ($action != 'editline' || $selected != $line->rowid) + if ($action != 'editline' || $selected != $line->id) { // Product if ($line->fk_product > 0) @@ -2879,7 +2879,7 @@ abstract class CommonObject } // Ligne en mode update - if ($this->statut == 0 && $action == 'editline' && $selected == $line->rowid) + if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) { $label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : '')); if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"'; @@ -3883,16 +3883,4 @@ abstract class CommonObject return $out; } - /** - * Returns the rights used for this class - * @return stdClass - */ - public function getRights() - { - global $user; - - return $user->rights->{$this->element}; - } - - } diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index b88dfabe83d..c3c8d823a34 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -28,19 +28,6 @@ */ abstract class CommonObjectLine extends CommonObject { - /** - * Id of the line - * @var int - * @deprecated Use $rowid - */ - public $id; - - /** - * Id of the line - * @var int - */ - public $rowid; - // TODO // Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code. diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index b4882af8a58..469e1676a53 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -22,7 +22,6 @@ */ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; /** * \class CommonOrder @@ -37,141 +36,8 @@ abstract class CommonOrder extends CommonObject * \class CommonOrderLine * \brief Superclass for orders classes */ -abstract class CommonOrderLine extends CommonObjectLine +abstract class CommonOrderLine extends CommonObject { - /** - * Product ref - * @var string - * @deprecated Use product_ref - */ - public $ref; - - /** - * Product ref - * @var string - */ - public $product_ref; - - /** - * Product label - * @var string - * @deprecated Use product_label - */ - public $libelle; - - /** - * Product label - * @var string - */ - public $product_label; - - /** - * Product description - * @var string - */ - public $product_desc; - - /** - * Quantity - * @var int - */ - public $qty; - - /** - * @deprecated - */ - var $price; - - /** - * Unit price before taxes - * @var float - */ - public $subprice; - - /** - * Type of the product. 0 for product 1 for service - * @var int - */ - public $product_type = 0; - - /** - * Description of the line - * @var string - */ - public $desc; - - /** - * Id of corresponding product - * @var int - */ - public $fk_product; - - /** - * Percent line discount - * @var float - */ - public $remise_percent; - - /** - * VAT % - * @var float - */ - public $tva_tx; - - /** - * Local tax 1 % - * @var float - */ - public $localtax1_tx; - - /** - * Local tax 2 % - * @var float - */ - public $localtax2_tx; - - public $localtax1_type; - public $localtax2_type; - - /** - * Total amount before taxes - * @var float - */ - public $total_ht; - - /** - * Total VAT amount - * @var float - */ - public $total_tva; - - /** - * Total local tax 1 amount - * @var float - */ - public $total_localtax1; - - /** - * Total local tax 2 amount - * @var float - */ - public $total_localtax2; - - /** - * Total amount with taxes - * @var float - */ - public $total_ttc; - - /** - * Liste d'options cumulables: - * Bit 0: 0 si TVA normal - 1 si TVA NPR - * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) - * @var int - */ - public $info_bits = 0; - - public $special_code = 0; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 73a1633e78c..d2ce8023a65 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3927,7 +3927,9 @@ function dol_htmlcleanlastbr($stringtodecode) */ function dol_html_entity_decode($a,$b,$c='UTF-8') { - return html_entity_decode($a,$b,$c); + // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; + $ret=@html_entity_decode($a,$b,$c); + return $ret; } /** diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 84cc158515d..027e6b3d816 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -286,7 +286,7 @@ else { $newline = new CommandeFournisseurLigne($this->db); } elseif ($this->table_element_line=='facture_fourn_det') { - $newline = new SupplierInvoiceLine($this->db); + $newline = new FactureFournisseurLigne($this->db); } if (is_object($newline)) { print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8)); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 6be8a82d69a..5b895a69da3 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -53,9 +53,9 @@ $coldisplay=-1; // We remove first td ?> > global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>global->MAIN_VIEW_LINE_NUMBER))?2:1; ?> -
+
- + diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index da122306dbc..1fd86ed871d 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -48,11 +48,11 @@ if (empty($usemargins)) $usemargins=0; ?> -> +> global->MAIN_VIEW_LINE_NUMBER)) { ?> -
+
info_bits & 2) == 2) { ?> tva_tx,'%',$line->info_bits); ?> - pu_ht); ?> + pu_ht)?price($line->pu_ht):price($line->subprice)); ?> pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?> @@ -179,11 +179,11 @@ if (empty($usemargins)) $usemargins=0; total_ht); ?> - statut == 0 && ($object_rights->creer)) { ?> + statut == 0 && ($user->rights->$element->creer || $permtoedit)) { ?> info_bits & 2) == 2) { ?> - rowid.'#line_'.$line->rowid; ?>"> + id.'#line_'.$line->id; ?>"> @@ -192,7 +192,7 @@ if (empty($usemargins)) $usemargins=0; situation_counter == 1 || !$this->situation_cycle_ref) { - print 'rowid . '">'; + print 'id . '">'; print img_delete(); print ''; } @@ -202,12 +202,12 @@ if (empty($usemargins)) $usemargins=0; 1 && empty($conf->browser->phone) && ($this->situation_counter == 1 || !$this->situation_cycle_ref)) { ?> 0) { ?> - rowid; ?>"> + id; ?>"> - rowid; ?>"> + id; ?>"> diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index baf2555a905..51d37dcc8ae 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1022,6 +1022,7 @@ class FichinterLigne extends CommonObjectLine var $error; // From llx_fichinterdet + var $rowid; var $fk_fichinter; var $desc; // Description ligne var $datei; // Date intervention diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 15bee891775..7343e65c854 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -83,6 +83,7 @@ if (! empty($dolibarr_strict_mode)) } else { + if (! defined('E_DEPRECATED')) define('E_DEPRECATED',0); // For PHP < 5.3.0 compatibility error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e52b98b7e53..8b7d81fdda0 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -93,16 +93,13 @@ class CommandeFournisseur extends CommonOrder var $extraparams=array(); - /** - * @var CommandeFournisseurLigne[] - */ - public $lines = array(); //Ajout pour askpricesupplier var $origin; var $origin_id; var $linked_objects=array(); + var $lines = array(); - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -113,6 +110,7 @@ class CommandeFournisseur extends CommonOrder $this->db = $db; $this->products = array(); + $this->lines = array(); // List of language codes for status $this->statuts[0] = 'StatusOrderDraft'; @@ -260,15 +258,14 @@ class CommandeFournisseur extends CommonOrder $line = new CommandeFournisseurLigne($this->db); $line->id = $objp->rowid; - $line->rowid = $objp->rowid; - $line->desc = $objp->description; - $line->description = $objp->description; + $line->desc = $objp->description; // Description ligne + $line->description = $objp->description; // Description ligne $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; - $line->subprice = $objp->subprice; - $line->pu_ht = $objp->subprice; + $line->subprice = $objp->subprice; // deprecated + $line->pu_ht = $objp->subprice; // Unit price HT $line->remise_percent = $objp->remise_percent; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -277,16 +274,16 @@ class CommandeFournisseur extends CommonOrder $line->total_ttc = $objp->total_ttc; $line->product_type = $objp->product_type; - $line->fk_product = $objp->fk_product; + $line->fk_product = $objp->fk_product; // Id du produit - $line->libelle = $objp->product_label; - $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; + $line->libelle = $objp->product_label; // TODO deprecated + $line->product_label = $objp->product_label; // Label produit + $line->product_desc = $objp->product_desc; // Description produit - $line->ref = $objp->product_ref; - $line->product_ref = $objp->product_ref; - $line->ref_fourn = $objp->ref_supplier; - $line->ref_supplier = $objp->ref_supplier; + $line->ref = $objp->product_ref; // TODO deprecated + $line->product_ref = $objp->product_ref; // Internal reference + $line->ref_fourn = $objp->ref_supplier; // TODO deprecated + $line->ref_supplier = $objp->ref_supplier; // Reference supplier $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); @@ -1624,6 +1621,7 @@ class CommandeFournisseur extends CommonOrder } } + /** * Return array of dispathed lines waiting to be approved for this order * @@ -2328,18 +2326,6 @@ class CommandeFournisseur extends CommonOrder if ($nb === 0) return $langs->trans('Undefined'); else return $nb.' '.$langs->trans('Days'); } - - /** - * Returns the rights used for this class - * @return stdClass - */ - public function getRights() - { - global $user; - - return $user->rights->fournisseur->commande; - } - } @@ -2349,32 +2335,42 @@ class CommandeFournisseur extends CommonOrder */ class CommandeFournisseurLigne extends CommonOrderLine { + var $db; + var $error; + public $element='commande_fournisseurdet'; public $table_element='commande_fournisseurdet'; - - /** - * Unit price without taxes - * @var float - */ - public $pu_ht; - var $date_start; + var $oldline; + + // From llx_commandedet + var $qty; + var $tva_tx; + var $localtax1_tx; + var $localtax2_tx; + var $localtax1_type; + var $localtax2_type; + var $subprice; + var $remise_percent; + var $desc; // Description ligne + var $fk_product; // Id of predefined product + var $product_type = 0; // Type 0 = product, 1 = Service + var $total_ht; + var $total_tva; + var $total_localtax1; + var $total_localtax2; + var $total_ttc; + var $info_bits; + var $special_code; + var $date_start; var $date_end; + // From llx_product + var $libelle; // Label produit + var $product_desc; // Description produit + // From llx_product_fournisseur_price - - /** - * Supplier ref - * @var string - * @deprecated Use ref_supplier - */ - public $ref_fourn; - - /** - * Supplier reference - * @var string - */ - public $ref_supplier; + var $ref_fourn; // Ref supplier /** @@ -2434,7 +2430,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); - + $this->db->free($result); return 1; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 19cb26cf17b..9cc6b237c41 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -89,12 +89,9 @@ class FactureFournisseur extends CommonInvoice var $mode_reglement_id; var $mode_reglement_code; - /** - * Invoice lines - * @var SupplierInvoiceLine[] - */ - public $lines = array(); + var $lines; var $fournisseur; // deprecated + var $thirdparty; // To store thirdparty //Incorterms var $fk_incoterms; @@ -103,6 +100,31 @@ class FactureFournisseur extends CommonInvoice var $extraparams=array(); + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; + + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; + + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; + + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; + + /** + * Proforma invoice + */ + const TYPE_PROFORMA = 4; + /** * Constructor * @@ -123,6 +145,7 @@ class FactureFournisseur extends CommonInvoice $this->propalid = 0; $this->products = array(); + $this->lines = array(); } /** @@ -473,7 +496,7 @@ class FactureFournisseur extends CommonInvoice */ function fetch_lines() { - $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx'; + $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva'; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; @@ -494,7 +517,7 @@ class FactureFournisseur extends CommonInvoice { $obj = $this->db->fetch_object($resql_rows); - $this->lines[$i] = new SupplierInvoiceLine($this->db); + $this->lines[$i] = new FactureFournisseurLigne($this->db); $this->lines[$i]->id = $obj->rowid; $this->lines[$i]->rowid = $obj->rowid; @@ -504,7 +527,6 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields it into updateline $this->lines[$i]->libelle = $obj->label; // This field may contains label of product (when invoice create from order) $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit - $this->lines[$i]->subprice = $obj->pu_ht; $this->lines[$i]->pu_ht = $obj->pu_ht; $this->lines[$i]->pu_ttc = $obj->pu_ttc; $this->lines[$i]->tva_tx = $obj->tva_tx; @@ -512,7 +534,7 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->localtax2_tx = $obj->localtax2_tx; $this->lines[$i]->qty = $obj->qty; $this->lines[$i]->remise_percent = $obj->remise_percent; - $this->lines[$i]->tva = $obj->total_tva; + $this->lines[$i]->tva = $obj->tva; $this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_localtax1 = $obj->total_localtax1; @@ -1291,7 +1313,7 @@ class FactureFournisseur extends CommonInvoice if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $linetmp = new SupplierInvoiceLine($this->db); + $linetmp = new FactureFournisseurLigne($this->db); $linetmp->id=$this->rowid; $linetmp->array_options = $array_options; $result=$linetmp->insertExtraFields(); @@ -1836,18 +1858,6 @@ class FactureFournisseur extends CommonInvoice return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - /** - * Returns the rights used for this class - * @return stdClass - */ - public function getRights() - { - global $user; - - return $user->rights->fournisseur->facture; - } - - } @@ -1855,70 +1865,20 @@ class FactureFournisseur extends CommonInvoice /** * Class to manage line invoices */ -class SupplierInvoiceLine extends CommonInvoice +class FactureFournisseurLigne extends CommonInvoice { + var $db; + var $error; + + var $pu_ht; + var $pu_ttc; + public $element='facture_fourn_det'; public $table_element='facture_fourn_det'; - var $oldline; + var $oldline; - public $ref; - public $product_ref; - public $ref_supplier; - public $libelle; - public $product_desc; - - /** - * Unit price before taxes - * @var float - * @deprecated Use $subprice - */ - public $pu_ht; - - /** - * Unit price included taxes - * @var float - */ - public $pu_ttc; - - /** - * Total VAT amount - * @var float - * @deprecated Use $total_tva instead - */ - public $tva; - - /** - * Id of the corresponding supplier invoice - * @var int - */ - var $fk_facture_fourn; - - /** - * Product label - * @var string - */ - var $label; // deprecated - - /** - * Description of the line - * @var string - */ - var $description; - - var $skip_update_total; // Skip update price total for special lines - - /** - * @var int Situation advance percentage - */ - public $situation_percent; - - /** - * @var int Previous situation line id reference - */ - public $fk_prev_id; - - /** + /** * Constructor * * @param DoliDB $db Database handler diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 3ca8aae79d5..26a0b5a5438 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2015,7 +2015,7 @@ elseif (! empty($object->id)) // Show object lines $inputalsopricewithtax=0; if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->commande->creer); $num = count($object->lines); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e93d06ad530..a48534b4c24 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2092,7 +2092,7 @@ else // Show object lines if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->facture->creer); $num=count($object->lines); diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index b031a190f44..f8beb7cd1ca 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -72,6 +72,7 @@ if ($action == 'remises') { if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) { + $conf->global->MARGIN_METHODE_FOR_DISCOUNT = $_POST['MARGIN_METHODE_FOR_DISCOUNT']; setEventMessage($langs->trans("RecordModifiedSuccessfully")); } else @@ -84,6 +85,7 @@ if ($action == 'typemarges') { if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { + $conf->global->MARGIN_METHODE_FOR_DISCOUNT = $_POST['MARGIN_TYPE']; setEventMessage($langs->trans("RecordModifiedSuccessfully")); } else @@ -96,6 +98,7 @@ if ($action == 'contact') { if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { + $conf->global->AGENT_CONTACT_TYPE = $_POST['AGENT_CONTACT_TYPE']; setEventMessage($langs->trans("RecordModifiedSuccessfully")); } else diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index a29bb9a2d63..915d4ef69ef 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -237,7 +237,12 @@ if ($action == 'deltask') // Set default model else if ($action == 'setdoc') { - dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity); + if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->PROJECT_ADDON_PDF = $value; + } // On active le modele $ret = delDocumentModel($value, $type); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 881946cb1cd..8fec81c686c 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -165,7 +165,10 @@ if ($action == 'setdoc') $db->begin(); - dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity); + if (dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + $conf->global->COMPANY_ADDON_PDF = $value; + } // On active le modele $type='company';