diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 42c82a1642d..350682ec619 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -306,8 +306,9 @@ if ($action == 'create') print ""; // Auto validate the invoice - print "".$langs->trans("InvoiceAutoValidate").""; - print $form->selectyesno('auto_validate', 0, 1); + print "".$langs->trans("StatusOfGeneratedInvoices").""; + $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); + print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); print ""; print ""; @@ -719,31 +720,65 @@ else //{ // Date when print ''; - print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'dayhour'); + if ($action == 'date_when' || $object->frequency > 0) + { + print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'dayhour'); + } + else + { + print $langs->trans("NextDateToExecution"); + } print ''; - print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'dayhour'); + if ($action == 'date_when' || $object->frequency > 0) + { + print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'dayhour'); + } print ''; print ''; // Max period / Rest period print ''; - print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + if ($action == 'nb_gen_max' || $object->frequency > 0) + { + print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + } + else + { + print $langs->trans("MaxPeriodNumber"); + } print ''; - print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + if ($action == 'nb_gen_max' || $object->frequency > 0) + { + print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + } + else + { + print ''; + } print ''; print ''; + print ''.$langs->trans("RestPeriodNumber").''; print ''; - print ($object->nb_gen_max-$object->nb_gen_done); + if ($object->frequency > 0) + { + print ($object->nb_gen_max-$object->nb_gen_done); + } print ''; - // Auto validate + // Status of generated invoices print ''; - print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); + if ($action == 'auto_validate' || $object->frequency > 0) + print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); + else + print $langs->trans("StatusOfGeneratedInvoices"); print ''; - $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); - print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); + $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); + if ($action == 'auto_validate' || $object->frequency > 0) + { + print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); + } print ''; print ''; //} @@ -869,7 +904,7 @@ else /* * List mode */ - $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc"; + $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; @@ -894,6 +929,7 @@ else print_liste_field_titre($langs->trans("AmountHT"),'','','','','align="right"'); print_liste_field_titre($langs->trans("AmountVAT"),'','','','','align="right"'); print_liste_field_titre($langs->trans("AmountTTC"),'','','','','align="right"'); + print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),'','','','','align="center"'); print_liste_field_titre(''); // Field may contains ling text print "\n"; @@ -917,7 +953,8 @@ else print ''.price($objp->total).''."\n"; print ''.price($objp->total_vat).''."\n"; print ''.price($objp->total_ttc).''."\n"; - + print ''.yn($objp->frequency?1:0).''; + print ''; if ($user->rights->facture->creer) { diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 86bb4fdb238..e7ad861b4c8 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -41,7 +41,8 @@ ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut); UPDATE llx_projet as p set p.opp_percent = (SELECT percent FROM llx_c_lead_status as cls WHERE cls.rowid = p.fk_opp_status) WHERE p.opp_percent IS NULL AND p.fk_opp_status IS NOT NULL; - +ALTER TABLE llx_facturedet ADD COLUMN fk_contract_line integer NULL AFTER rang; +ALTER TABLE llx_facturedet_rec ADD COLUMN import_key varchar(14); CREATE TABLE llx_website ( diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 81074f299e0..d314cae3727 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -57,6 +57,7 @@ create table llx_facturedet fk_code_ventilation integer DEFAULT 0 NOT NULL, special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- position of line + fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines import_key varchar(14), situation_percent real, -- % progression of lines invoicing diff --git a/htdocs/install/mysql/tables/llx_facturedet_rec.sql b/htdocs/install/mysql/tables/llx_facturedet_rec.sql index e0e7358af0c..cea176b2aa8 100644 --- a/htdocs/install/mysql/tables/llx_facturedet_rec.sql +++ b/htdocs/install/mysql/tables/llx_facturedet_rec.sql @@ -47,9 +47,10 @@ create table llx_facturedet_rec info_bits integer DEFAULT 0, -- TVA NPR ou non special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- ordre d'affichage - fk_contract_line integer NULL, -- id of contract line when predefined invoice comes from contract lines - fk_unit integer DEFAULT NULL, - + fk_contract_line integer NULL, -- id of contract line when template invoice comes from contract lines + fk_unit integer DEFAULT NULL, + import_key varchar(14), + fk_multicurrency integer, multicurrency_code varchar(255), multicurrency_subprice double(24,8) DEFAULT 0, diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 88805ece9e6..06f4309acf0 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -140,6 +140,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t BillFrom=From BillTo=To ActionsOnBill=Actions on invoice +RecurringInvoiceTemplate=Recurring invoice NotARecurringInvoiceTemplate=Not a recurring template invoice NewBill=New invoice LastBills=Last %s invoices