diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 07cb56b830b..839841e4cf9 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -898,7 +898,7 @@ if (empty($reshook)) } } - // Standard or deposit or proforma invoice + // Standard or deposit or proforma invoice, not from a Predefined template invoice if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT || $_POST['type'] == Facture::TYPE_PROFORMA || ($_POST['type'] == Facture::TYPE_SITUATION && empty($_POST['situations']))) && GETPOST('fac_rec') <= 0) { if (GETPOST('socid', 'int') < 1) @@ -2075,6 +2075,8 @@ if ($action == 'create') } print '' . "\n"; + $exampletemplateinvoice=new FactureRec($db); + // Overwrite value if creation of invoice is from a predefined invoice if (empty($origin) && empty($originid) && GETPOST('fac_rec','int') > 0) { @@ -2109,7 +2111,10 @@ if ($action == 'create') $objp = $db->fetch_object($resql); print ''; $i ++; } @@ -2387,9 +2392,10 @@ if ($action == 'create') print ''; } + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + // Date invoice print '' . $langs->trans('DateInvoice') . ''; - $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); print $form->select_date($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1, 1); print ''; @@ -2474,9 +2480,39 @@ if ($action == 'create') print ''; } + // Help of substitution key + $htmltext=''; + if (GETPOST('fac_rec','int') > 0) + { + $dateexample=dol_now(); + if (! empty($datefacture?$datefacture:$dateinvoice)) $dateexample=($datefacture?$datefacture:$dateinvoice); + $substitutionarray=array( + '__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($exampletemplateinvoice->total_ht).')', + '__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($exampletemplateinvoice->total_ttc).')', + '__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')', + '__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')', + '__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')', + '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')', + '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')', + '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')', + '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')', + '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')', + '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')' + ); + + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; + foreach($substitutionarray as $key => $val) + { + $htmltext.=$key.' = '.$langs->trans($val).'
'; + } + $htmltext.='
'; + } + // Public note print ''; - print '' . $langs->trans('NotePublic') . ''; + print ''; + print $form->textwithpicto($langs->trans('NotePublic'), $htmltext); + print ''; print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -2485,7 +2521,9 @@ if ($action == 'create') if (empty($user->societe_id)) { print ''; - print '' . $langs->trans('NotePrivate') . ''; + print ''; + print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext); + print ''; print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e02ec4541ef..8e443e5f556 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -296,6 +296,10 @@ class Facture extends CommonInvoice $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; + // Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result + $this->total_ht = $_facrec->total_ht; + $this->total_ttc = $_facrec->total_ttc; + // Fields always coming from template $this->remise_absolue = $_facrec->remise_absolue; $this->remise_percent = $_facrec->remise_percent; @@ -314,7 +318,7 @@ class Facture extends CommonInvoice $this->brouillon = 1; $this->linked_objects = $_facrec->linkedObjectsIds; - + $forceduedate = $this->calculate_date_lim_reglement(); // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice @@ -327,6 +331,39 @@ class Facture extends CommonInvoice //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. $result = $_facrec->setNextDate($next_date,1); } + + // Define lang of customer + $outputlangs = $langs; + $newlang=''; + + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + $substitutionarray=array( + '__TOTAL_HT__' => price($this->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency_code), + '__TOTAL_TTC__' => price($this->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code), + '__INVOICE_PREVIOUS_MONTH__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'), + '__INVOICE_MONTH__' => dol_print_date($this->date, '%m'), + '__INVOICE_NEXT_MONTH__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'), + '__INVOICE_PREVIOUS_MONTH_TEXT__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'), + '__INVOICE_MONTH_TEXT__' => dol_print_date($this->date, '%B'), + '__INVOICE_NEXT_MONTH_TEXT__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'), + '__INVOICE_PREVIOUS_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'), + '__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'), + '__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'), + ); + + $substitutionisok=true; + complete_substitutions_array($substitutionarray, $outputlangs); + + $this->note_public=make_substitutions($this->note_public,$substitutionarray); + $this->note_private=make_substitutions($this->note_private,$substitutionarray); } // Define due date if not already defined diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fccb1d00106..83d4535660d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -37,6 +37,7 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } +require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $langs->load('bills'); $langs->load('compta'); @@ -915,15 +916,53 @@ if ($action == 'create') print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; print ''; - // Note public - print ''.$langs->trans("NotePublic").''; - print ''; - print ''; + $note_public=GETPOST('note_public')?GETPOST('note_public'):$object->note_public; + $note_private=GETPOST('note_private')?GETPOST('note_private'):$object->note_private; - // Note private - print ''.$langs->trans("NotePrivate").''; - print ''; - print ''; + // Help of substitution key + $substitutionarray=array( + '__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', + '__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', + '__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')', + '__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')', + '__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')', + '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')', + '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')', + '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')', + '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')', + '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')', + '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')' + ); + + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; + foreach($substitutionarray as $key => $val) + { + $htmltext.=$key.' = '.$langs->trans($val).'
'; + } + $htmltext.='
'; + + // Public note + print ''; + print ''; + print $form->textwithpicto($langs->trans('NotePublic'), $htmltext); + print ''; + print ''; + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + + // Private note + if (empty($user->societe_id)) + { + print ''; + print ''; + print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext); + print ''; + print ''; + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + // print ' + print ''; + } // Author print "".$langs->trans("Author")."".$user->getFullName($langs).""; @@ -941,7 +980,7 @@ if ($action == 'create') // Project if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { - $projectid = $object->fk_project; + $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; $langs->load('projects'); print '' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); @@ -970,7 +1009,7 @@ if ($action == 'create') // Frequency print ''.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency')).""; - print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); print ""; // First date of execution for cron @@ -1130,21 +1169,6 @@ else print '
'; print ''; - - // Ref - /* - print ''; - print ''; - - print ''; - print ''; - */ print '"; @@ -1200,9 +1224,33 @@ else } print ''; + // Help of substitution key + $dateexample=dol_now(); + if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; + $substitutionarray=array( + '__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', + '__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', + '__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')', + '__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')', + '__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')', + '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')', + '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')', + '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')', + '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')', + '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')', + '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')' + ); + + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; + foreach($substitutionarray as $key => $val) + { + $htmltext.=$key.' = '.$langs->trans($val).'
'; + } + $htmltext.='
'; + // Note public print ''; @@ -1210,39 +1258,11 @@ else // Note private print ''; print ''; - - // Project - /* - if (! empty($conf->projet->enabled)) - { - $langs->load('projects'); - print ''; - print ''; - print ''; - }*/ // Bank Account print ''; - print ''; + print ''; print "\n"; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f330fb92e84..082177b5cbc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1216,6 +1216,7 @@ function dol_strftime($fmt, $ts=false, $is_gmt=false) * "%d %b %Y", * "%d/%m/%Y %H:%M", * "%d/%m/%Y %H:%M:%S", + * "%B"=Long text of month, "%A"=Long text of day, "%b"=Short text of month, "%a"=Short text of day * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...reduceformat" * @param string $tzoutput true or 'gmt' => string is for Greenwich location * false or 'tzserver' => output string is for local PHP server TZ usage diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index d1648be1d1b..1e4a745621c 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -321,7 +321,7 @@ ListOfNextSituationInvoices=List of next situation invoices FrequencyPer_d=Every %s days FrequencyPer_m=Every %s months FrequencyPer_y=Every %s years -toolTipFrequency=Examples:
Set 7 / day: give a new invoice every 7 days
Set 3 / month: give a new invoice every 3 month +toolTipFrequency=Examples:
Set 7, Day: give a new invoice every 7 days
Set 3, Month: give a new invoice every 3 month NextDateToExecution=Date for next invoice generation DateLastGeneration=Date of latest generation MaxPeriodNumber=Max nb of invoice generation
'; - //print $langs->trans('Ref'); - print $form->editfieldkey($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer); - print ''; - $morehtmlref = $form->editfieldval($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); - print $form->showrefnav($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref); - print '
'.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').'
'.$langs->trans("Author").''.$author->getFullName($langs)."
'; - print $form->editfieldkey($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer); + print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext), 'note_public', $object->note_public, $object, $user->rights->facture->creer); print ''; print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60'); print '
'; - print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer); + print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext), 'note_private', $object->note_private, $object, $user->rights->facture->creer); print ''; print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60'); print '
'; - - print ''; - if ($action != 'classify') { - print ''; - } - print '
'; - print $langs->trans('Project'); - print 'id . '">'; - print img_edit($langs->trans('SetProject'), 1); - print '
'; - - print '
'; - if ($action == 'classify') { - $form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1); - } else { - $form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0); - } - print '
'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 2d53eb6abbb..3bb65cd0826 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1693,7 +1693,7 @@ else if ($object->statut > 0) { print '