FIX The unique index on email templates can work now.

This commit is contained in:
Laurent Destailleur 2017-09-27 18:16:28 +02:00
parent f1f4a2fb44
commit 8242469e40
7 changed files with 24 additions and 14 deletions

View File

@ -177,7 +177,7 @@ if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$la
if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
$elementList['all']=$langs->trans('VisibleEverywhere');
$elementList['all'] =$langs->trans('VisibleEverywhere');
$elementList['none']=$langs->trans('VisibleNowhere');
@ -295,7 +295,7 @@ if (empty($reshook))
if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]='';
if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0';
if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1';
if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = ''
if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
else $sql.="'".$db->escape($_POST[$keycode])."'";
$i++;
}
@ -485,7 +485,7 @@ if (! $user->admin)
}
if (empty($conf->global->MAIN_MULTILANGS))
{
$sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL)";
$sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')";
}
if ($search_label) $sql.=natural_search('label', $search_label);
if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_search('type_template', $search_type_template);

View File

@ -5234,7 +5234,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
'__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
'__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
'__MYCOMPANY_CAPITAL__' => $mysoc->capital,
'__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1),
'__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1, ', '),
'__MYCOMPANY_ADDRESS__' => $mysoc->address,
'__MYCOMPANY_ZIP__' => $mysoc->zip,
'__MYCOMPANY_TOWN__' => $mysoc->town,
@ -5395,8 +5395,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
'__USER_FIRSTNAME__' => (string) $user->firstname,
'__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
'__USER_SUPERVISOR_ID__' => (string) $user->fk_user,
'__SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '')
));
'__USER_SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '')
)
);
// For backward compatibility
if ($onlykey != 2)
{
$substitutionarray['__SIGNATURE__'] = (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '');
}
}
if (! empty($conf->multicompany->enabled))
{

View File

@ -20,6 +20,7 @@
-- de l'install et tous les sigles '--' sont supprimés.
--
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(Hello)__<br><br>__(ThisIsContentOfYourCard)__<br>\n__(ID)__ : __ID__<br>\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br>\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br />\n__(Lastname)__ : __MEMBER_LASTNAME__<br />\n__(Fullname)__ : __MEMBER_FULLNAME__<br />\n__(Company)__ : __MEMBER_COMPANY__<br />\n__(Address)__ : __MEMBER_ADDRESS__<br />\n__(Zip)__ : __MEMBER_ZIP__<br />\n__(Town)__ : __MEMBER_TOWN__<br />\n__(Country)__ : __MEMBER_COUNTRY__<br />\n__(Email)__ : __MEMBER_EMAIL__<br />\n__(Birthday)__ : __MEMBER_BIRTH__<br />\n__(Photo)__ : __MEMBER_PHOTO__<br />\n__(Login)__ : __MEMBER_LOGIN__<br />\n__(Password)__ : __MEMBER_PASSWORD__<br />\n__(Phone)__ : __MEMBER_PHONE__<br />\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br />\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null);
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'adherent','member','',0,null,null,'(SendAnEMailToMember)',1,1,1,'__(CardContent)__','__(Hello)__,<br><br>\n\n__(ThisIsContentOfYourCard)__<br>\n__(ID)__ : __ID__<br>\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br>\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br />\n__(Lastname)__ : __MEMBER_LASTNAME__<br />\n__(Fullname)__ : __MEMBER_FULLNAME__<br />\n__(Company)__ : __MEMBER_COMPANY__<br />\n__(Address)__ : __MEMBER_ADDRESS__<br />\n__(Zip)__ : __MEMBER_ZIP__<br />\n__(Town)__ : __MEMBER_TOWN__<br />\n__(Country)__ : __MEMBER_COUNTRY__<br />\n__(Email)__ : __MEMBER_EMAIL__<br />\n__(Birthday)__ : __MEMBER_BIRTH__<br />\n__(Photo)__ : __MEMBER_PHOTO__<br />\n__(Login)__ : __MEMBER_LOGIN__<br />\n__(Password)__ : __MEMBER_PASSWORD__<br />\n__(Phone)__ : __MEMBER_PHONE__<br />\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br />\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null);
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'banque','thirdparty','',0,null,null,'(YourSEPAMandate)',1,1,0,'__(YourSEPAMandate)__','__(Hello)__,<br><br>\n\n__(FindYourSEPAMandate)__ :<br>\n__MYCOMPANY_NAME__<br>\n__MYCOMPANY_FULLADDRESS__<br><br>\n__(Sincerely)__<br>\n__USER_SIGNATURE__',null);
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'thirdparty',null,0,null,null,'(YourSEPAMandate)',1,1,'__(YourSEPAMandate)__','__(Hello)__<br><br>__(PleaseFindYourSEPAMandate)__<br>\n__MYCOMPANY_NAME__<br>\n__MYCOMPANY_FULLADDRESS__',null);

View File

@ -70,8 +70,12 @@ ALTER TABLE llx_contrat MODIFY COLUMN ref_ext varchar(50);
UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL;
UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL;
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(ThisIsContentOfYourCard)__<br />\n__(ID)__ : __ID__<br />\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br />\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br />\n__(Lastname)__ : __MEMBER_LASTNAME__<br />\n__(Fullname)__ : __MEMBER_FULLNAME__<br />\n__(Company)__ : __MEMBER_COMPANY__<br />\n__(Address)__ : __MEMBER_ADDRESS__<br />\n__(Zip)__ : __MEMBER_ZIP__<br />\n__(Town)__ : __MEMBER_TOWN__<br />\n__(Country)__ : __MEMBER_COUNTRY__<br />\n__(Email)__ : __MEMBER_EMAIL__<br />\n__(Birthday)__ : __MEMBER_BIRTH__<br />\n__(Photo)__ : __MEMBER_PHOTO__<br />\n__(Login)__ : __MEMBER_LOGIN__<br />\n__(Password)__ : __MEMBER_PASSWORD__<br />\n__(Phone)__ : __MEMBER_PHONE__<br />\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br />\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null);
ALTER TABLE llx_c_email_templates ADD COLUMN enabled varchar(255) DEFAULT '1';
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'adherent','member','',0,null,null,'(SendAnEMailToMember)',1,1,1,'__(CardContent)__','__(Hello)__,<br><br>\n\n__(ThisIsContentOfYourCard)__<br>\n__(ID)__ : __ID__<br>\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br>\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br />\n__(Lastname)__ : __MEMBER_LASTNAME__<br />\n__(Fullname)__ : __MEMBER_FULLNAME__<br />\n__(Company)__ : __MEMBER_COMPANY__<br />\n__(Address)__ : __MEMBER_ADDRESS__<br />\n__(Zip)__ : __MEMBER_ZIP__<br />\n__(Town)__ : __MEMBER_TOWN__<br />\n__(Country)__ : __MEMBER_COUNTRY__<br />\n__(Email)__ : __MEMBER_EMAIL__<br />\n__(Birthday)__ : __MEMBER_BIRTH__<br />\n__(Photo)__ : __MEMBER_PHOTO__<br />\n__(Login)__ : __MEMBER_LOGIN__<br />\n__(Password)__ : __MEMBER_PASSWORD__<br />\n__(Phone)__ : __MEMBER_PHONE__<br />\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br />\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null);
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'banque','thirdparty','',0,null,null,'(YourSEPAMandate)',1,1,0,'__(YourSEPAMandate)__','__(Hello)__,<br><br>\n\n__(FindYourSEPAMandate)__ :<br>\n__MYCOMPANY_NAME__<br>\n__MYCOMPANY_FULLADDRESS__<br><br>\n__(Sincerely)__<br>\n__USER_SIGNATURE__',null);
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Exemple: 7xxxxx', 0, 0, '', '10', 1, 1);
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Exemple: 6xxxxx', 0, 0, '', '20', 1, 1);

View File

@ -23,13 +23,14 @@ create table llx_c_email_templates
entity integer DEFAULT 1 NOT NULL, -- multi company id
module varchar(32), -- Nom du module en rapport avec le modele
type_template varchar(32), -- template for which type of email (send invoice by email, send order, ...)
lang varchar(6),
lang varchar(6) DEFAULT '', -- We use a default to '' so the unique index that include this field will work
private smallint DEFAULT 0 NOT NULL, -- Template public or private
fk_user integer, -- Id user owner if template is private, or null
datec datetime,
tms timestamp,
label varchar(255), -- Label of predefined email
position smallint, -- Position
enabled varchar(255) DEFAULT '1', -- Condition to have this module visible
active tinyint DEFAULT 1 NOT NULL,
topic text, -- Predefined topic
content text, -- Predefined text

View File

@ -159,4 +159,4 @@ VariousPayments=Miscellaneous payments
ShowVariousPayment=Show miscellaneous payments
AddVariousPayment=Add miscellaneous payments
YourSEPAMandate=Your SEPA mandate
PleaseFindYourSEPAMandate=This is your SEPA mandate. Thanks to return it signed (scan of the signed document) or sent by mail to
FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make direct debit order to your bank. Thanks to return it signed (scan of the signed document) or sent it by mail to

View File

@ -770,6 +770,7 @@ Genderwoman=Woman
ViewList=List view
Mandatory=Mandatory
Hello=Hello
GoodBye=GoodBye
Sincerely=Sincerely
DeleteLine=Delete line
ConfirmDeleteLine=Are you sure you want to delete this line?
@ -814,9 +815,6 @@ Websites=Web sites
Events=Events
EMailTemplates=Emails templates
FileNotShared=File not shared to exernal public
Hello=Hello
Goodbye=Goodbye
Sincerely=Sincerely
# Week day
Monday=Monday
Tuesday=Tuesday