diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f2b9048a718..66b0df5969c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2083,8 +2083,9 @@ if ($action == 'create') $(document).ready(function() { $("#socid").change(function() { var socid = $(this).val(); + var fac_rec = $(\'#fac_rec\').val(); // reload page - window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid; + window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec; }); }); '; @@ -2099,6 +2100,8 @@ if ($action == 'create') $invoice_predefined = new FactureRec($db); $invoice_predefined->fetch(GETPOST('fac_rec','int')); + $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later + $sql = 'SELECT r.rowid, r.titre, r.total_ttc'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r'; $sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid; @@ -2112,7 +2115,7 @@ if ($action == 'create') if ($num > 0) { print '' . $langs->trans('CreateFromRepeatableInvoice') . ''; - print ''; print ''; while ($i < $num) { @@ -2123,7 +2126,22 @@ if ($action == 'create') print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')'; $i ++; } - print ''; + print ''; + // Option to reload page to retrieve customer informations. Note, this clear other input + if (!empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE)) + { + print ''; + } + print ''; } $db->free($resql); } else { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index b18c5bf7b48..cddd511dbe4 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -53,7 +53,7 @@ class FactureRec extends CommonInvoice var $propalid; var $date_last_gen; - var $next_gen; + var $date_when; var $nb_gen_done; var $nb_gen_max; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4dbf4b9020a..3e93df70142 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -280,24 +280,27 @@ class Facture extends CommonInvoice $this->socid = $_facrec->socid; + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; - $this->fk_account = $_facrec->fk_account; - $this->cond_reglement_id = $_facrec->cond_reglement_id; - $this->mode_reglement_id = $_facrec->mode_reglement_id; + $this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; + $this->note_private = GETPOST('note_private') ? GETPOST('note_private') : $_facrec->note_private; + $this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf; + $this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id; + $this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; + $this->fk_account = GETPOST('fk_account') > 0 ? GETPOST('fk_account') : $_facrec->fk_account; + + // Fields always coming from template $this->remise_absolue = $_facrec->remise_absolue; $this->remise_percent = $_facrec->remise_percent; $this->fk_incoterms = $_facrec->fk_incoterms; $this->location_incoterms= $_facrec->location_incoterms; - $this->note_public = $_facrec->note_public; - $this->note_private = $_facrec->note_private; - // Clean parameters if (! $this->type) $this->type = self::TYPE_STANDARD; $this->ref_client=trim($this->ref_client); $this->note_public=trim($this->note_public); $this->note_private=trim($this->note_private); - $this->note_private=dol_concatdesc($facture->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); //if (! $this->remise) $this->remise = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;