Minor fixes on recurring invoices

This commit is contained in:
Laurent Destailleur 2016-04-27 11:35:11 +02:00
parent bdb7fe8d29
commit 60e693e9a4
3 changed files with 32 additions and 11 deletions

View File

@ -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;
});
});
</script>';
@ -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 '<tr><td>' . $langs->trans('CreateFromRepeatableInvoice') . '</td><td>';
print '<select class="flat" name="fac_rec">';
print '<select class="flat" id="fac_rec" name="fac_rec">';
print '<option value="0" selected></option>';
while ($i < $num)
{
@ -2123,7 +2126,22 @@ if ($action == 'create')
print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')</option>';
$i ++;
}
print '</select></td></tr>';
print '</select>';
// Option to reload page to retrieve customer informations. Note, this clear other input
if (!empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE))
{
print '<script type="text/javascript">
$(document).ready(function() {
$("#fac_rec").change(function() {
var fac_rec = $(this).val();
var socid = $(\'#socid\').val();
// reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec;
});
});
</script>';
}
print '</td></tr>';
}
$db->free($resql);
} else {

View File

@ -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;

View File

@ -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;