diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0e882c9afdfef..0f2669014a8dd 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3806,6 +3806,13 @@ print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
'; } } + + if ($object->fk_fac_rec_source > 0) + { + $tmptemplate = new FactureRec($db); + $result = $tmptemplate->fetch($object->fk_fac_rec_source); + if ($result > 0) print '. '.$langs->trans("GeneratedFromTemplate", $tmptemplate->ref); + } print ''; // Relative and absolute discounts @@ -4018,9 +4025,8 @@ print ''; print '
'; print '
'; - print '
'; - print ''; + print '
'; if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 686190c359b45..fa67f2bf67eb5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -349,7 +349,7 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; $_facrec = new FactureRec($this->db); $result=$_facrec->fetch($this->fac_rec); - $result=$_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds + $result=$_facrec->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); // This load $_facrec->linkedObjectsIds // Define some dates $originaldatewhen = $_facrec->date_when; @@ -392,6 +392,8 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0) $this->brouillon = 1; $this->linked_objects = $_facrec->linkedObjectsIds; + // We do not add link to template invoice or next invoice will be linked to all generated invoices + //$this->linked_objects['facturerec'][0] = $this->fac_rec; $forceduedate = $this->calculate_date_lim_reglement(); @@ -436,7 +438,6 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0) //var_dump($substitutionarray);exit; - $substitutionisok=true; complete_substitutions_array($substitutionarray, $outputlangs); $this->note_public=make_substitutions($this->note_public, $substitutionarray); @@ -564,7 +565,7 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0) require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; $exp = new Expedition($this->db); $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(); + $exp->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); if (count($exp->linkedObjectsIds['commande']) > 0) { foreach ($exp->linkedObjectsIds['commande'] as $key => $value) @@ -1323,7 +1324,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_si $sql.= ', f.date_valid as datev'; $sql.= ', f.tms as datem'; $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; - $sql.= ', f.fk_facture_source'; + $sql.= ', f.fk_facture_source, f.fk_fac_rec_source'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project, f.extraparams'; $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; $sql.= ', f.fk_account'; @@ -1391,6 +1392,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_si $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; $this->fk_project = $obj->fk_project; $this->fk_facture_source = $obj->fk_facture_source; + $this->fk_fac_rec_source = $obj->fk_fac_rec_source; $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 8d9aa039fcd77..17882b3b27083 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -365,6 +365,7 @@ InvoiceAutoValidate=Validate invoices automatically GeneratedFromRecurringInvoice=Generated from template recurring invoice %s DateIsNotEnough=Date not reached yet InvoiceGeneratedFromTemplate=Invoice %s generated from recurring template invoice %s +GeneratedFromTemplate=Generated from template invoice %s WarningInvoiceDateInFuture=Warning, the invoice date is higher than current date WarningInvoiceDateTooFarInFuture=Warning, the invoice date is too far from current date ViewAvailableGlobalDiscounts=View available discounts