diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8909441b9c1..533df89b773 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -107,6 +107,9 @@ class Propal extends CommonObject var $products=array(); var $extraparams=array(); + /** + * @var PropaleLigne[] + */ var $lines = array(); var $line; @@ -2801,9 +2804,6 @@ 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 1bcfa1ee7cb..2d377758aa5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -104,7 +104,10 @@ class Commande extends CommonOrder var $user_author_id; - var $lines = array(); + /** + * @var OrderLine[] + */ + var $lines = array(); //Incorterms var $fk_incoterms; @@ -1635,12 +1638,12 @@ class Commande extends CommonOrder $line = new OrderLine($this->db); - $line->rowid = $objp->rowid; // \deprecated + $line->rowid = $objp->rowid; $line->id = $objp->rowid; $line->fk_commande = $objp->fk_commande; - $line->commande_id = $objp->fk_commande; // \deprecated + $line->commande_id = $objp->fk_commande; $line->label = $objp->custom_label; - $line->desc = $objp->description; // Description ligne + $line->desc = $objp->description; $line->product_type = $objp->product_type; $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; @@ -1666,11 +1669,11 @@ class Commande extends CommonOrder $line->special_code = $objp->special_code; $line->fk_parent_line = $objp->fk_parent_line; - $line->ref = $objp->product_ref; // TODO deprecated + $line->ref = $objp->product_ref; $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; // TODO deprecated + $line->libelle = $objp->product_label; $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; // Description produit + $line->product_desc = $objp->product_desc; $line->fk_product_type = $objp->fk_product_type; // Produit ou service $line->date_start = $this->db->jdate($objp->date_start); @@ -3175,6 +3178,7 @@ 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; @@ -3261,56 +3265,44 @@ 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 - // 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 + /** + * @deprecated + */ + var $remise; // 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 48955652ac5..38fab4c217c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3408,6 +3408,7 @@ 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; @@ -3606,16 +3607,12 @@ 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 @@ -3623,17 +3620,9 @@ 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; @@ -3642,10 +3631,6 @@ 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 @@ -3654,15 +3639,6 @@ 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; @@ -3691,16 +3667,6 @@ 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 6087a5a0adb..1a7ebfc34c8 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -400,5 +400,100 @@ 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 97157c6d408..5dc524d964c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2685,10 +2685,9 @@ 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, $permtoedit=0) + function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user; @@ -2781,7 +2780,7 @@ abstract class CommonObject } else { - $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline,$permtoedit); + $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline); } $i++; @@ -2793,7 +2792,7 @@ abstract class CommonObject * TODO Move this into an output class file (htmlline.class.php) * * @param string $action GET/POST action - * @param array $line Selected object line to output + * @param CommonObjectLine $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 @@ -2802,13 +2801,14 @@ 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,$permtoedit=0) + function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) { global $conf,$langs,$user,$object,$hookmanager; - global $form,$bc,$bcdd; + global $form,$bc,$bcdd, $object_rights; + + $object_rights = $this->getRights(); $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->id) + if ($action != 'editline' || $selected != $line->rowid) { // 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->id) + if ($this->statut == 0 && $action == 'editline' && $selected == $line->rowid) { $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,4 +3883,16 @@ 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 c3c8d823a34..b88dfabe83d 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -28,6 +28,19 @@ */ 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 469e1676a53..b4882af8a58 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -22,6 +22,7 @@ */ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; /** * \class CommonOrder @@ -36,8 +37,141 @@ abstract class CommonOrder extends CommonObject * \class CommonOrderLine * \brief Superclass for orders classes */ -abstract class CommonOrderLine extends CommonObject +abstract class CommonOrderLine extends CommonObjectLine { + /** + * 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 d2ce8023a65..73a1633e78c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3927,9 +3927,7 @@ function dol_htmlcleanlastbr($stringtodecode) */ function dol_html_entity_decode($a,$b,$c='UTF-8') { - // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; - $ret=@html_entity_decode($a,$b,$c); - return $ret; + return html_entity_decode($a,$b,$c); } /** diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 027e6b3d816..84cc158515d 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 FactureFournisseurLigne($this->db); + $newline = new SupplierInvoiceLine($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 5b895a69da3..6be8a82d69a 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 ?>