diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 0acd58f0202..b18c5bf7b48 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -341,6 +341,17 @@ class FactureRec extends CommonInvoice } + /** + * Create an array of invoice lines + * + * @return int >0 if OK, <0 if KO + */ + function getLinesArray() + { + return $this->fetch_lines(); + } + + /** * Recupere les lignes de factures predefinies dans this->lines * @@ -348,16 +359,23 @@ class FactureRec extends CommonInvoice */ function fetch_lines() { + $this->lines=array(); + $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; $sql.= ' l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.total_ht, l.total_tva, l.total_ttc,'; + $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + //$sql.= ' l.situation_percent, l.fk_prev_id,'; + //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; + //$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.fk_unit, l.fk_contract_line,'; + //$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; - + $sql.= ' ORDER BY l.rang'; + dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); if ($result) @@ -387,10 +405,6 @@ class FactureRec extends CommonInvoice $line->remise_percent = $objp->remise_percent; $line->fk_remise_except = $objp->fk_remise_except; $line->fk_product = $objp->fk_product; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -415,7 +429,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error=$this->db-lasterror(); return -3; } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index ad9626718c6..2e595d45daf 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -73,6 +73,13 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } } +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('invoicecard','globalcard')); + +$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php + /* * Actions @@ -101,7 +108,7 @@ if ($action == 'add') $rehour=GETPOST('rehour'); $remin=GETPOST('remin'); $nb_gen_max=GETPOST('nb_gen_max', 'int'); - if (empty($nb_gen_max)) $nb_gen_max =0; + //if (empty($nb_gen_max)) $nb_gen_max =0; if (GETPOST('frequency')) { @@ -111,7 +118,7 @@ if ($action == 'add') $action = "create"; $error++; } - if ($nb_gen_max == '') + if ($nb_gen_max === '') { setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); $action = "create"; @@ -599,7 +606,9 @@ if ($action == 'create') if ($object->fetch($id, $ref) > 0) { - print '
'; + $result = $object->getLinesArray(); + + print ''; print ''; print ''; print ''; @@ -707,10 +716,22 @@ if ($action == 'create') print load_fiche_titre($title, '', ''); - /* * Invoice lines */ + print ''; + // Show object lines + if (! empty($object->lines)) + { + $disableedit=1; + $disablemove=1; + $disableremove=1; + $ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice + } + + print "
\n"; + + /* print ''; print '
'; @@ -877,7 +898,8 @@ if ($action == 'create') print $db->error(); } print "
"; - + */ + print ''; if ($flag_price_may_change) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ec02fce3dae..349ff1e20b1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3236,8 +3236,9 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $langs, $user; - + global $conf, $hookmanager, $langs, $user; + global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! + // Define usemargins $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1; @@ -3366,7 +3367,7 @@ abstract class CommonObject { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; - global $object_rights, $disableedit, $disablemove; // TODO We should not use global var for this ! + global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! $object_rights = $this->getRights(); diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 967d9f81970..559cae91464 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -31,7 +31,7 @@ * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $usemargins (0 to disable all margins columns, 1 to show according to margin setup) * $object_rights->creer initialized from = $object->getRights() - * $disableedit, $disablemove + * $disableedit, $disablemove, $disableremove * * $type, $text, $description, $line */ @@ -46,7 +46,6 @@ if (empty($forceall)) $forceall=0; if (empty($senderissupplier)) $senderissupplier=0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; if (empty($usemargins)) $usemargins=0; - ?> @@ -216,7 +215,7 @@ if (empty($usemargins)) $usemargins=0; situation_counter == 1 || !$this->situation_cycle_ref) { + if (($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) { print 'id . '">'; print img_delete(); print '';