diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 56efe2b5d7d..7a336e6d4e7 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -82,8 +82,8 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK
if ($action == 'update')
{
- dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["main_lang_default"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["main_multilangs"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity);
@@ -231,14 +231,14 @@ if ($action == 'edit') // Edit
// Default language
print '
| '.$langs->trans("DefaultLanguage").' | ';
- print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'main_lang_default', 1, 0, 0, 0, 0, 'minwidth300');
+ print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300');
print ' | ';
print ' | ';
print '
';
// Multilingual GUI
print '| '.$langs->trans("EnableMultilangInterface").' | ';
- print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1);
+ print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1);
print ' | ';
print ' | ';
print '
';
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index c9b8120bd0f..356f52061f6 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -78,6 +78,9 @@ $offset = $listlimit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
+if (empty($sortfield)) $sortfield='label, lang, position';
+if (empty($sortorder)) $sortorder='ASC';
+
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('emailtemplates'));
@@ -87,7 +90,7 @@ $tabname[25]= MAIN_DB_PREFIX."c_email_templates";
// Criteria to sort dictionaries
$tabsqlsort=array();
-$tabsqlsort[25]="label ASC";
+$tabsqlsort[25]="label ASC, lang ASC, position ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@@ -122,17 +125,30 @@ $formmail=new FormMail($db);
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
$tmp=FormMail::getAvailableSubstitKey('formemail');
- $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
- $helpsubstit = $langs->trans("AvailableVariables").':
'.implode('
', $tmp);
- $helpsubstitforlines = $langs->trans("AvailableVariables").':
'.implode('
', $tmp);
+ $tmp['__(AnyTranslationKey)__']='Translation';
+ $helpsubstit = $langs->trans("AvailableVariables").':
';
+ $helpsubstitforlines = $langs->trans("AvailableVariables").':
';
+ foreach($tmp as $key => $val)
+ {
+ $helpsubstit.=$key.' -> '.$val.'
';
+ $helpsubstitforlines.=$key.' -> '.$val.'
';
+ }
}
else
{
$tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
- $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
- $helpsubstit = $langs->trans("AvailableVariables").':
'.implode('
', $tmp);
+ $tmp['__(AnyTranslationKey)__']='Translation';
+ $helpsubstit = $langs->trans("AvailableVariables").':
';
+ $helpsubstitforlines = $langs->trans("AvailableVariables").':
';
+ foreach($tmp as $key => $val)
+ {
+ $helpsubstit.=$key.' -> '.$val.'
';
+ }
$tmp=FormMail::getAvailableSubstitKey('formemailforlines');
- $helpsubstitforlines = $langs->trans("AvailableVariables").':
'.implode('
', $tmp);
+ foreach($tmp as $key => $val)
+ {
+ $helpsubstitforlines.=$key.' -> '.$val.'
';
+ }
}
@@ -217,7 +233,7 @@ if (empty($reshook))
if ($value == 'content') $value='content-'.$rowid;
if ($value == 'content_lines') $value='content_lines-'.$rowid;
- if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user')
+ if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
{
$ok=0;
$fieldnamekey=$listfield[$f];
@@ -270,10 +286,9 @@ if (empty($reshook))
$i=0;
foreach ($listfieldinsert as $f => $value)
{
+ //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
$keycode=$listfieldvalue[$i];
if ($value == 'lang') $keycode='langcode';
-
- //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
if ($value == 'entity') $_POST[$keycode] = $conf->entity;
if ($i) $sql.=",";
if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]='';
@@ -520,7 +535,7 @@ foreach ($fieldlist as $field => $value)
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$align="left";
if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner");}
- if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
+ if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? ' ' : $langs->trans("Language")); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
@@ -573,7 +588,7 @@ $errors = $hookmanager->errors;
if (empty($reshook))
{
- if ($tabname[$id] == MAIN_DB_PREFIX . 'c_email_templates' && $action == 'edit') {
+ if ($action == 'edit') {
fieldList($fieldlist, $obj, $tabname[$id], 'hide');
} else {
fieldList($fieldlist, $obj, $tabname[$id], 'add');
@@ -681,6 +696,10 @@ if ($resql)
print '';
}
elseif ($value == 'topic') print ' | ';
+ elseif ($value == 'type_template')
+ {
+ print ''.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100onsmartphone').' | ';
+ }
elseif (! in_array($value, array('content', 'content_lines'))) print ' | ';
}
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ' | ';
@@ -829,6 +848,8 @@ if ($resql)
if ($value == 'private')
{
$align="center";
+ if ($valuetoshow) $valuetoshow=yn($valuetoshow);
+ else $valuetoshow='';
}
if ($value == 'position')
{
@@ -1032,9 +1053,17 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
print '';
- if ($fieldlist[$field]=='private' && empty($user->admin))
+ if ($fieldlist[$field]=='private')
{
- print '';
+ if (empty($user->admin))
+ {
+ print $form->selectyesno($fieldlist[$field], '1', 1);
+ }
+ else
+ {
+ //print '';
+ print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
+ }
}
else
{
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index c40192723a8..9f67db88bbb 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -57,24 +57,17 @@ $hookmanager->initHooks(array('mailingcard','globalcard'));
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing');
-$object->substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
-$object->substitutionarrayfortest=array(
- '__ID__' => 'TESTIdRecord',
- //'__EMAIL__' => 'TESTEMail', // Done into "send" action
- '__LASTNAME__' => 'TESTLastname',
- '__FIRSTNAME__' => 'TESTFirstname',
- '__MAILTOEMAIL__' => 'TESTMailtoEmail',
- '__OTHER1__' => 'TESTOther1',
- '__OTHER2__' => 'TESTOther2',
- '__OTHER3__' => 'TESTOther3',
- '__OTHER4__' => 'TESTOther4',
- '__OTHER5__' => 'TESTOther5',
- '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''),
- '__CHECK_READ__' => 'TagCheckMail',
- '__UNSUBSCRIBE__' => 'TagUnsubscribe'
- //,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet
-);
+
+// Set $object->substitutionarrayfortest
+$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
+
+$targetobject = null; // Not defined with mass emailing
+
+$parameters=array('mode'=>'emailing');
+$substitutionarray=FormMail::getAvailableSubstitKey('emailing', $targetobject);
+
+$object->substitutionarrayfortest = $substitutionarray;
// List of sending methods
$listofmethods=array();
@@ -205,24 +198,28 @@ if (empty($reshook))
$tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
+
$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
- // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
- $substitutionarray=array(
- '__ID__' => $obj->source_id,
- '__EMAIL__' => $obj->email,
- '__LASTNAME__' => $obj->lastname,
- '__FIRSTNAME__' => $obj->firstname,
- '__MAILTOEMAIL__' => ''.$obj->email.'',
- '__OTHER1__' => $other1,
- '__OTHER2__' => $other2,
- '__OTHER3__' => $other3,
- '__OTHER4__' => $other4,
- '__OTHER5__' => $other5,
- '__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter)
- '__CHECK_READ__' => ' ',
- '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").''
- );
+ $targetobject = null; // Not defined with mass emailing
+ $parameters=array('mode'=>'emailing');
+ $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object
+
+ // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
+ $substitutionarray['__ID__'] = $obj->source_id;
+ $substitutionarray['__EMAIL__'] = $obj->email;
+ $substitutionarray['__LASTNAME__'] = $obj->lastname;
+ $substitutionarray['__FIRSTNAME__'] = $obj->firstname;
+ $substitutionarray['__MAILTOEMAIL__'] = ''.$obj->email.'';
+ $substitutionarray['__OTHER1__'] = $other1;
+ $substitutionarray['__OTHER2__'] = $other2;
+ $substitutionarray['__OTHER3__'] = $other3;
+ $substitutionarray['__OTHER4__'] = $other4;
+ $substitutionarray['__OTHER5__'] = $other5;
+ $substitutionarray['__SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
+ $substitutionarray['__CHECK_READ__'] = ' ';
+ $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").'';
+
$onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
@@ -230,18 +227,20 @@ if (empty($reshook))
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
-
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
-
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
-
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
-
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
+ {
+ $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
+ $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
+ $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
+ $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
+ }
+ else
+ {
+ $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
+ $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
+ $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
+ $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
+ }
}
/* For backward compatibility */
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
@@ -261,6 +260,7 @@ if (empty($reshook))
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
//$substitutionisok=true;
+
complete_substitutions_array($substitutionarray, $langs);
$newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray);
@@ -431,9 +431,12 @@ if (empty($reshook))
$msgishtml=-1; // Inconnu par defaut
if (preg_match('/[\s\t]*/i',$object->body)) $msgishtml=1;
- $object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; // other are set at begin of page
+ // other are set at begin of page
+ $object->substitutionarrayfortest['__EMAIL__'] = $object->sendto;
+ $object->substitutionarrayfortest['__MAILTOEMAIL__'] = ''.$object->sendto.'';
// Pratique les substitutions sur le sujet et message
+ complete_substitutions_array($object->substitutionarrayfortest, $langs);
$tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest);
$tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest);
@@ -1073,7 +1076,7 @@ else
$formmail->substit=$object->substitutionarrayfortest;
// Tableau des parametres complementaires du post
$formmail->param["action"]="send";
- $formmail->param["models"]="body";
+ $formmail->param["models"]='none';
$formmail->param["mailid"]=$object->id;
$formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id;
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index b3a8a68611d..7c6e0567c24 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -152,8 +152,8 @@ class FactureRec extends CommonInvoice
$sql.= ", '".$this->db->escape($user->id)."'";
$sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null");
$sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null");
- $sql.= ", '".$this->db->escape($facsrc->cond_reglement_id)."'";
- $sql.= ", '".$this->db->escape($facsrc->mode_reglement_id)."'";
+ $sql.= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null");
+ $sql.= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null");
$sql.= ", ".$this->usenewprice;
$sql.= ", ".$this->frequency;
$sql.= ", '".$this->db->escape($this->unit_frequency)."'";
@@ -329,7 +329,6 @@ class FactureRec extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
-
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
@@ -447,7 +446,6 @@ class FactureRec extends CommonInvoice
$line->price = $objp->price;
$line->remise = $objp->remise;
-
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 23356fcf811..58fed19d103 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -70,6 +70,8 @@ $search_societe=GETPOST('search_societe');
$search_montant_ht=GETPOST('search_montant_ht');
$search_montant_vat=GETPOST('search_montant_vat');
$search_montant_ttc=GETPOST('search_montant_ttc');
+$search_payment_mode=GETPOST('search_payment_mode');
+$search_payment_term=GETPOST('search_payment_term');
$day=GETPOST('day');
$year=GETPOST('year');
$month=GETPOST('month');
@@ -113,31 +115,6 @@ $permissionnote = $user->rights->facture->creer; // Used by the include of actio
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
-$arrayfields=array(
- 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
- 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
- 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
- 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
- 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
- 'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
- 'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1),
- 'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1),
- 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1),
- 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1),
- 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1),
- 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
- 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
- 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
-);
-// Extra fields
-if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
-{
- foreach($extrafields->attribute_label as $key => $val)
- {
- $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
- }
-}
-
/*
* Actions
@@ -172,6 +149,8 @@ if (empty($reshook))
$search_montant_ht='';
$search_montant_vat='';
$search_montant_ttc='';
+ $search_montant_mode='';
+ $search_montant_term='';
$day='';
$year='';
$month='';
@@ -991,9 +970,12 @@ if ($action == 'create')
// 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').')',
+ //'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
+ //'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
+ '__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
+ '__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')',
+ '__AMOUNT__' => $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').')',
@@ -1048,7 +1030,7 @@ if ($action == 'create')
// Payment mode
print " | | ".$langs->trans("PaymentMode")." | ";
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1);
print " |
";
// Project
@@ -1187,7 +1169,7 @@ else
// Recurring invoice content
- $linkback = '' . $langs->trans("BackToList") . '';
+ $linkback = '' . $langs->trans("BackToList") . '';
$morehtmlref='';
if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2);
@@ -1313,8 +1295,11 @@ else
$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).')',
+ //'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
+ //'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
+ '__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
+ '__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')',
+ '__AMOUNT__' => $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').')',
@@ -1624,456 +1609,6 @@ else
print '';
}
- 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, f.frequency, f.unit_frequency,";
- $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
- $sql.= " f.datec, f.tms";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
- if (! $user->rights->societe->client->voir && ! $socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- }
- $sql.= " WHERE f.fk_soc = s.rowid";
- $sql.= ' AND f.entity IN ('.getEntity('facture').')';
- if (! $user->rights->societe->client->voir && ! $socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- }
- if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
- if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
- if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
- if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1);
- if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
- if ($search_recurring == '1') $sql.= ' AND f.frequency > 0';
- if ($search_recurring == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)';
- if ($search_frequency != '') $sql.= natural_search('f.frequency', $search_frequency, 1);
- if ($search_unit_frequency != '') $sql.= natural_search('f.unit_frequency', $search_unit_frequency);
-
- if ($month > 0)
- {
- if ($year > 0 && empty($day))
- $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
- else if ($year > 0 && ! empty($day))
- $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
- else
- $sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'";
- }
- else if ($year > 0)
- {
- $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
- }
- if ($month_date_when > 0)
- {
- if ($year_date_when > 0 && empty($day_date_when))
- $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'";
- else if ($year_date_when > 0 && ! empty($day_date_when))
- $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'";
- else
- $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'";
- }
- else if ($year_date_when > 0)
- {
- $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
- }
-
- $nbtotalofrecords = '';
- if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
- {
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
- }
-
- $sql.= $db->order($sortfield, $sortorder);
- $sql.= $db->plimit($limit+1,$offset);
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
-
- $param='';
- if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
- if ($socid) $param.='&socid='.$socid;
- if ($day) $param.='&day='.$day;
- if ($month) $param.='&month='.$month;
- if ($year) $param.='&year=' .$year;
- if ($day_date_when) $param.='&day_date_when='.$day_date_when;
- if ($month_date_when) $param.='&month_date_when='.$month_date_when;
- if ($year_date_when) $param.='&year_date_when=' .$year_date_when;
- if ($search_ref) $param.='&search_ref=' .$search_ref;
- if ($search_societe) $param.='&search_societe=' .$search_societe;
- if ($search_montant_ht != '') $param.='&search_montant_ht=' .$search_montant_ht;
- if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat;
- if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc;
- if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .$search_recurring;
- if ($search_frequency > 0) $param.='&search_frequency=' .$search_frequency;
- if ($search_unit_frequency > 0) $param.='&search_unit_frequency='.$search_unit_frequency;
- if ($option) $param.="&option=".$option;
- if ($optioncss != '') $param.='&optioncss='.$optioncss;
- // Add $param from extra fields
- foreach ($search_array_options as $key => $val)
- {
- $crit=$val;
- $tmpkey=preg_replace('/search_options_/','',$key);
- if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
- }
-
- $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
-
- $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
- $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
- //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
-
- print '";
-
- $db->free($resql);
- }
- else
- {
- dol_print_error($db);
- }
- }
-
}
llxFooter();
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
new file mode 100644
index 00000000000..e911f6eab74
--- /dev/null
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -0,0 +1,700 @@
+
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Juanjo Menent
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2012 Cedric Salvador
+ * Copyright (C) 2015 Alexandre Spangaro
+ * Copyright (C) 2016 Meziane Sof
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/compta/facture/invoicetemplate_list.php
+ * \ingroup facture
+ * \brief Page to show list of template/recurring invoices
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+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/html.formprojet.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
+
+$langs->load('bills');
+$langs->load('compta');
+$langs->load('admin');
+$langs->load('other');
+
+$action = GETPOST('action','alpha');
+$massaction = GETPOST('massaction','alpha');
+$show_files = GETPOST('show_files','int');
+$confirm = GETPOST('confirm','alpha');
+$cancel = GETPOST('cancel', 'alpha');
+$toselect = GETPOST('toselect', 'array');
+$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search
+
+// Security check
+$id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int'));
+$lineid=GETPOST('lineid','int');
+$ref=GETPOST('ref','alpha');
+if ($user->societe_id) $socid=$user->societe_id;
+$objecttype = 'facture_rec';
+if ($action == "create" || $action == "add") $objecttype = '';
+$result = restrictedArea($user, 'facture', $id, $objecttype);
+$projectid = GETPOST('projectid','int');
+
+$search_ref=GETPOST('search_ref');
+$search_societe=GETPOST('search_societe');
+$search_montant_ht=GETPOST('search_montant_ht');
+$search_montant_vat=GETPOST('search_montant_vat');
+$search_montant_ttc=GETPOST('search_montant_ttc');
+$search_payment_mode=GETPOST('search_payment_mode');
+$search_payment_term=GETPOST('search_payment_term');
+$day=GETPOST('day');
+$year=GETPOST('year');
+$month=GETPOST('month');
+$day_date_when=GETPOST('day_date_when');
+$year_date_when=GETPOST('year_date_when');
+$month_date_when=GETPOST('month_date_when');
+$search_recurring=GETPOST('search_recurring','int');
+$search_frequency=GETPOST('search_frequency','alpha');
+$search_unit_frequency=GETPOST('search_unit_frequency','alpha');
+
+$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+$offset = $limit * $page;
+if (! $sortorder) $sortorder='DESC';
+if (! $sortfield) $sortfield='f.titre';
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+$object = new FactureRec($db);
+if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
+{
+ $ret = $object->fetch($id, $ref);
+ if (!$ret)
+ {
+ setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
+ }
+}
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('invoicereccard','globalcard'));
+$extrafields = new ExtraFields($db);
+
+// fetch optionals attributes and labels
+$extralabels = $extrafields->fetch_name_optionals_label('facture_rec');
+$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
+
+$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
+$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
+$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
+
+$arrayfields=array(
+ 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
+ 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
+ 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
+ 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
+ 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
+ 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0),
+ 'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0),
+ 'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
+ 'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1),
+ 'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1),
+ 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1),
+ 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1),
+ 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1),
+ 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
+ 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
+ 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
+);
+// Extra fields
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+{
+ foreach($extrafields->attribute_label as $key => $val)
+ {
+ $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
+ }
+}
+
+
+/*
+ * Actions
+ */
+
+if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
+if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
+
+$parameters = array('socid' => $socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
+{
+ if (GETPOST('cancel','alpha')) $action='';
+
+ // Selection of new fields
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+
+ // Do we click on purge search criteria ?
+ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
+ {
+ $search_ref='';
+ $search_societe='';
+ $search_montant_ht='';
+ $search_montant_vat='';
+ $search_montant_ttc='';
+ $search_payment_mode='';
+ $search_payment_term='';
+ $day='';
+ $year='';
+ $month='';
+ $day_date_when='';
+ $year_date_when='';
+ $month_date_when='';
+ $search_recurring='';
+ $search_frequency='';
+ $search_unit_frequency='';
+ $search_array_options=array();
+ }
+
+ // Mass actions
+ /*$objectclass='MyObject';
+ $objectlabel='MyObject';
+ $permtoread = $user->rights->mymodule->read;
+ $permtodelete = $user->rights->mymodule->delete;
+ $uploaddir = $conf->mymodule->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
+
+}
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec');
+
+$form = new Form($db);
+$formother = new FormOther($db);
+if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
+$companystatic = new Societe($db);
+$invoicerectmp = new FactureRec($db);
+
+$now = dol_now();
+$tmparray=dol_getdate($now);
+$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day
+
+
+/*
+ * 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, f.frequency, f.unit_frequency,";
+$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
+$sql.= " f.datec, f.tms,";
+$sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
+$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
+if (! $user->rights->societe->client->voir && ! $socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+}
+$sql.= " WHERE f.fk_soc = s.rowid";
+$sql.= ' AND f.entity IN ('.getEntity('facture').')';
+if (! $user->rights->societe->client->voir && ! $socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+}
+if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
+if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
+if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1);
+if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1);
+if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
+if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
+if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
+if ($search_recurring == '1') $sql .= ' AND f.frequency > 0';
+if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
+if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1);
+if ($search_unit_frequency != '') $sql .= natural_search('f.unit_frequency', $search_unit_frequency);
+
+if ($month > 0)
+{
+ if ($year > 0 && empty($day))
+ $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
+ else if ($year > 0 && ! empty($day))
+ $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
+ else
+ $sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'";
+}
+else if ($year > 0)
+{
+ $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
+}
+if ($month_date_when > 0)
+{
+ if ($year_date_when > 0 && empty($day_date_when))
+ $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'";
+ else if ($year_date_when > 0 && ! empty($day_date_when))
+ $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'";
+ else
+ $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'";
+}
+else if ($year_date_when > 0)
+{
+ $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
+}
+
+$nbtotalofrecords = '';
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
+}
+
+$sql.= $db->order($sortfield, $sortorder);
+$sql.= $db->plimit($limit+1,$offset);
+
+$resql = $db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+
+ $param='';
+ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+ if ($socid) $param.='&socid='.urlencode($socid);
+ if ($day) $param.='&day='.urlencode($day);
+ if ($month) $param.='&month='.urlencode($month);
+ if ($year) $param.='&year=' .urlencode($year);
+ if ($day_date_when) $param.='&day_date_when='.urlencode($day_date_when);
+ if ($month_date_when) $param.='&month_date_when='.urlencode($month_date_when);
+ if ($year_date_when) $param.='&year_date_when=' .urlencode($year_date_when);
+ if ($search_ref) $param.='&search_ref=' .urlencode($search_ref);
+ if ($search_societe) $param.='&search_societe=' .urlencode($search_societe);
+ if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht);
+ if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat);
+ if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
+ if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode);
+ if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type);
+ if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring);
+ if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency);
+ if ($search_unit_frequency > 0) $param.='&search_unit_frequency='.urlencode($search_unit_frequency);
+ if ($option) $param.="&option=".urlencode($option);
+ if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
+ // Add $param from extra fields
+ foreach ($search_array_options as $key => $val)
+ {
+ $crit=$val;
+ $tmpkey=preg_replace('/search_options_/','',$key);
+ if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
+ }
+
+ $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
+
+ $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
+ $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
+ //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
+
+ print '";
+
+ $db->free($resql);
+}
+else
+{
+ dol_print_error($db);
+}
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 16c843466f9..07a620963da 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -2243,15 +2243,18 @@ else
$formmail->withcancel = 1;
// Array of substitutions
$formmail->setSubstitFromObject($object);
+ $dateplannedstart='';
$datenextexpiration='';
foreach($object->lines as $line)
{
- if ($line->statut != 4) continue;
- if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue;
+ if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue;
+ if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue;
}
- $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
- $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
- $formmail->substit['__PERSONALIZED__']='';
+ $formmail->substit['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc');
+ $formmail->substit['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard');
+ $formmail->substit['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
+ $formmail->substit['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
+ $formmail->substit['__PERSONALIZED__']=''; // deprecated
$formmail->substit['__CONTACTCIVNAME__']='';
$custcontact = '';
@@ -2276,7 +2279,7 @@ else
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
- $formmail->param['models'] = 'contract_send';
+ $formmail->param['models'] = 'contract';
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['contractid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index 144cba07779..fddd6889515 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -351,14 +351,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
+ $dateplannedstart='';
$datenextexpiration='';
foreach($object->lines as $line)
{
- if ($line->statut != 4) continue;
- if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue;
+ if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue;
+ if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue;
}
- $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
- $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
+ $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc');
+ $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard');
+ $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
+ $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
$parameters=array('mode'=>'formemail');
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 628be5660df..ed318bbd900 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2987,13 +2987,15 @@ class Form
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
* See instead to force the default value by the caller.
*
- * @param int $selected Id of payment term to preselect by default
- * @param string $htmlname Nom de la zone select
- * @param int $filtertype Not used
- * @param int $addempty Add an empty entry
+ * @param int $selected Id of payment term to preselect by default
+ * @param string $htmlname Nom de la zone select
+ * @param int $filtertype Not used
+ * @param int $addempty Add an empty entry
+ * @param int $noadmininfo 0=Add admin info, 1=Disable admin info
+ * @param string $morecss Add more CSS on select tag
* @return void
*/
- function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0)
+ function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0, $noinfoadmin=0, $morecss='')
{
global $langs, $user, $conf;
@@ -3004,7 +3006,7 @@ class Form
// Set default value if not already set by caller
if (empty($selected) && ! empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
- print '