diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7193634af54..254185cc63d 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -37,8 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -1279,9 +1279,7 @@ else * Lines of contracts */ - if ($conf->product->enabled || $conf->service->enabled) { - $productstatic=new Product($db); - } + $productstatic=new Product($db); $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; @@ -1343,19 +1341,28 @@ else $productstatic->id=$objp->fk_product; $productstatic->type=$objp->ptype; $productstatic->ref=$objp->pref; - print $productstatic->getNomUrl(1,'',20); + $text = $productstatic->getNomUrl(1,'',20); if ($objp->label) { - print ' - '; + $text .= ' - '; $productstatic->ref=$objp->label; - print $productstatic->getNomUrl(0,'',16); + $text .= $productstatic->getNomUrl(0,'',16); } - if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($objp->description)) - print '
'.dol_nl2br($objp->description); + $description = $objp->description; + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + $text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + $description = ''; // Already added into main visible desc + } + + echo $form->textwithtooltip($text,$description,3,'','',$cursorline,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); + print ''; } else - { + { print ''.dol_htmlentitiesbr($objp->description)."\n"; } // TVA diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index cdf2d789d09..08bc8387387 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -237,8 +237,8 @@ class Contrat extends CommonObject /** * Activate a contract line * - * @param User $user Objet User qui active le contrat - * @param int $line_id Id de la ligne de detail a activer + * @param User $user Objet User who activate contract + * @param int $line_id Id of line to activate * @param int $date Date d'ouverture * @param int|string $date_end Date fin prevue * @param string $comment A comment typed by user @@ -284,9 +284,9 @@ class Contrat extends CommonObject /** * Close a contract line * - * @param User $user Objet User qui active le contrat - * @param int $line_id Id de la ligne de detail a activer - * @param int $date_end Date fin + * @param User $user Objet User who close contract + * @param int $line_id Id of line to close + * @param int $date_end Date end * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ @@ -576,7 +576,7 @@ class Contrat extends CommonObject $result=$this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -3; } @@ -599,7 +599,7 @@ class Contrat extends CommonObject } /** - * Load lignes array into this->lines + * Load lines array into this->lines * * @return ContratLigne[] Return array of contract lines */ @@ -624,7 +624,7 @@ class Contrat extends CommonObject $this->lines=array(); // Selectionne les lignes contrats liees a un produit - $sql = "SELECT p.label, p.description as product_desc, p.ref,"; + $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,"; $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; $sql.= " d.total_ht,"; $sql.= " d.total_tva,"; @@ -684,10 +684,12 @@ class Contrat extends CommonObject $line->fk_user_cloture = $objp->fk_user_cloture; $line->fk_unit = $objp->fk_unit; - $line->ref = $objp->ref; - $line->libelle = $objp->label; // Label produit - $line->label = $objp->label; // For backward compatibility - $line->product_desc = $objp->product_desc; // Description produit + $line->ref = $objp->product_ref; // deprecated + $line->label = $objp->product_label; // deprecated + $line->libelle = $objp->product_label; // deprecated + $line->product_ref = $objp->product_ref; // Ref product + $line->product_desc = $objp->product_desc; // Description product + $line->product_label = $objp->product_label; // Label product $line->description = $objp->description; @@ -2339,7 +2341,10 @@ class ContratLigne extends CommonObjectLine $sql.= " t.fk_contrat,"; $sql.= " t.fk_product,"; $sql.= " t.statut,"; - $sql.= " t.label,"; + $sql.= " t.label,"; // This field is not used. Only label of product + $sql.= " p.ref as product_ref,"; + $sql.= " p.label as product_label,"; + $sql.= " p.description as product_desc,"; $sql.= " t.description,"; $sql.= " t.date_commande,"; $sql.= " t.date_ouverture_prevue as date_ouverture_prevue,"; @@ -2368,7 +2373,7 @@ class ContratLigne extends CommonObjectLine $sql.= " t.fk_user_cloture,"; $sql.= " t.commentaire,"; $sql.= " t.fk_unit"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as t"; + $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as t LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = t.fk_product"; if ($id) $sql.= " WHERE t.rowid = ".$id; if ($ref) $sql.= " WHERE t.rowid = '".$this->db->escape($ref)."'"; @@ -2387,7 +2392,10 @@ class ContratLigne extends CommonObjectLine $this->fk_contrat = $obj->fk_contrat; $this->fk_product = $obj->fk_product; $this->statut = $obj->statut; - $this->label = $obj->label; + $this->product_ref = $obj->product_ref; + $this->product_label = $obj->product_label; + $this->product_description = $obj->product_description; + $this->label = $obj->label; // deprecated. We do not use this field. Only ref and label of product, and description of contract line $this->description = $obj->description; $this->date_commande = $this->db->jdate($obj->date_commande); $this->date_ouverture_prevue = $this->db->jdate($obj->date_ouverture_prevue); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 71cf0c6577d..a6cac8a5276 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -107,7 +107,7 @@ class ExtraFields * @param string $label label of attribute * @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour') * @param int $pos Position of attribute - * @param int $size Size/length of attribute + * @param string $size Size/length of attribute * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not @@ -128,7 +128,7 @@ class ExtraFields // Create field into database except for separator type which is not stored in database if ($type != 'separate') { - $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value, $param, $perms, $list); + $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list); } $err1=$this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') @@ -156,7 +156,7 @@ class ExtraFields * * @param string $attrname code of attribute * @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour') - * @param int $length Size/length of attribute + * @param string $length Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not @@ -233,7 +233,7 @@ class ExtraFields * @param string $label label of attribute * @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour', 'float') * @param int $pos Position of attribute - * @param int $size Size/length of attribute + * @param string $size Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 9b5b80ceeaf..d43e773eb6a 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; /** @@ -253,6 +254,7 @@ class pdf_strato extends ModelePDFContract $objectligne = $object->lines[$i]; $valide = $objectligne->id ? $objectligne->fetch($objectligne->id) : 0; + if ($valide > 0 || $object->specimen) { $curX = $this->posxdesc-1; @@ -278,12 +280,20 @@ class pdf_strato extends ModelePDFContract $durationi = $langs->trans("Unknown"); } + $txtpredefinedservice=''; + $txtpredefinedservice = $objectligne->product_ref; + if ($objectligne->product_label) + { + $txtpredefinedservice .= ' - '; + $txtpredefinedservice .= $objectligne->product_label; + } + $txt=''.dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".$datei." - ".$outputlangs->transnoentities("Duration")." : ".$durationi,1,$outputlangs->charset_output).''; $desc=dol_htmlentitiesbr($objectligne->desc,1); - $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0); + $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,dol_concatdesc($txtpredefinedservice,$desc)), 0, 1, 0); - $nexY = $pdf->GetY(); + $nexY = $pdf->GetY() + 2; $pageposafter=$pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute);