|
@@ -293,13 +293,17 @@ class FormMail extends Form
|
|
|
}
|
|
|
|
|
|
// Get message template for $this->param["models"] into c_email_templates
|
|
|
- $model_id=0;
|
|
|
- if (array_key_exists('models_id',$this->param))
|
|
|
- {
|
|
|
- $model_id=$this->param["models_id"];
|
|
|
- }
|
|
|
- $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
|
|
|
- //var_dump($this->param["models"]);
|
|
|
+ $arraydefaultmessage=array();
|
|
|
+ if ($this->param['models'] != 'none')
|
|
|
+ {
|
|
|
+ $model_id=0;
|
|
|
+ if (array_key_exists('models_id',$this->param))
|
|
|
+ {
|
|
|
+ $model_id=$this->param["models_id"];
|
|
|
+ }
|
|
|
+ $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
|
|
|
+ }
|
|
|
+ //var_dump($this->param["models"]);
|
|
|
//var_dump($model_id);
|
|
|
//var_dump($arraydefaultmessage);
|
|
|
|
|
@@ -325,18 +329,21 @@ class FormMail extends Form
|
|
|
$out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
|
|
|
}
|
|
|
|
|
|
- $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
|
|
|
- if ($result < 0)
|
|
|
+ if ($this->param['models'] != 'none')
|
|
|
{
|
|
|
- setEventMessages($this->error, $this->errors, 'errors');
|
|
|
- }
|
|
|
- $modelmail_array=array();
|
|
|
- foreach($this->lines_model as $line)
|
|
|
- {
|
|
|
- $modelmail_array[$line->id]=$line->label;
|
|
|
- if ($line->lang) $modelmail_array[$line->id].=' ('.$line->lang.')';
|
|
|
- if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private");
|
|
|
- //if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' ';
|
|
|
+ $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
|
|
|
+ if ($result < 0)
|
|
|
+ {
|
|
|
+ setEventMessages($this->error, $this->errors, 'errors');
|
|
|
+ }
|
|
|
+ $modelmail_array=array();
|
|
|
+ foreach($this->lines_model as $line)
|
|
|
+ {
|
|
|
+ $modelmail_array[$line->id]=$line->label;
|
|
|
+ if ($line->lang) $modelmail_array[$line->id].=' ('.$line->lang.')';
|
|
|
+ if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private");
|
|
|
+ //if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' ';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Zone to select its email template
|
|
@@ -769,7 +776,7 @@ class FormMail extends Form
|
|
|
$paymenturl=$url;
|
|
|
}
|
|
|
}
|
|
|
- $this->substit['__PERSONALIZED__']=$paymenturl;
|
|
|
+ $this->substit['__PERSONALIZED__']=$paymenturl; // deprecated
|
|
|
$this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl;
|
|
|
|
|
|
//Add lines substitution key from each line
|
|
@@ -1038,8 +1045,7 @@ class FormMail extends Form
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * Set substit array from object. This is call when suggesting the email template into forms to send email.
|
|
|
- * TODO Replace with getCommonSubstitutionArray with param onlykey = 2
|
|
|
+ * Set substit array from object. This is call when suggesting the email template into forms before sending email.
|
|
|
*
|
|
|
* @param CommonObject $object Object to use
|
|
|
* @param Translate $outputlangs Object lang
|
|
@@ -1049,34 +1055,12 @@ class FormMail extends Form
|
|
|
function setSubstitFromObject($object, $outputlangs=null)
|
|
|
{
|
|
|
global $conf, $user;
|
|
|
- $this->substit['__REF__'] = $object->ref;
|
|
|
- $this->substit['__REFCLIENT__'] = isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '');
|
|
|
- $this->substit['__REFSUPPLIER__'] = isset($object->ref_supplier) ? $object->ref_supplier : '';
|
|
|
-
|
|
|
- $this->substit['__DATE_YMD__'] = isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '';
|
|
|
- $this->substit['__DATE_DUE_YMD__'] = isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '';
|
|
|
- $this->substit['__AMOUNT__'] = price($object->total_ttc);
|
|
|
- $this->substit['__AMOUNT_EXCL_TAX__'] = price($object->total_ht);
|
|
|
- $this->substit['__AMOUNT_VAT__'] = price($object->total_tva);
|
|
|
-
|
|
|
- $this->substit['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:'');
|
|
|
- $this->substit['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:'');
|
|
|
-
|
|
|
- $this->substit['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:'');
|
|
|
- $this->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:'');
|
|
|
- $this->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:'');
|
|
|
-
|
|
|
- $this->substit['__SIGNATURE__'] = $user->signature;
|
|
|
- $this->substit['__PERSONALIZED__'] = '';
|
|
|
- $this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending
|
|
|
-
|
|
|
- // Create dynamic tags for __EXTRAFIELD_FIELD__
|
|
|
- $extrafields = new ExtraFields($this->db);
|
|
|
- $extralabels = $extrafields->fetch_name_optionals_label($object->table_element, true);
|
|
|
- $object->fetch_optionals($object->id, $extralabels);
|
|
|
- foreach ($extrafields->attribute_label as $key => $label) {
|
|
|
- $this->substit['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
|
|
|
- }
|
|
|
+
|
|
|
+ $parameters=array('mode'=>$mode);
|
|
|
+ $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
|
|
+ complete_substitutions_array($tmparray, $outputlangs, null, $parameters);
|
|
|
+
|
|
|
+ $this->substit=$tmparray;
|
|
|
|
|
|
// Fill substit_lines with each object lines content
|
|
|
if (is_array($object->lines))
|
|
@@ -1127,55 +1111,43 @@ class FormMail extends Form
|
|
|
{
|
|
|
global $conf, $langs;
|
|
|
|
|
|
- $vars=array();
|
|
|
-
|
|
|
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines')
|
|
|
{
|
|
|
- $vars=array(
|
|
|
- '__REF__'=>'__REF__',
|
|
|
- '__REFCLIENT__'=>'__REFCLIENT__',
|
|
|
- '__REFSUPPLIER__'=>'__REFSUPPLIER__',
|
|
|
- '__THIRDPARTY_ID__'=>'__THIRDPARTY_ID__',
|
|
|
- '__THIRDPARTY_NAME__'=>'__THIRDPARTY_NAME__',
|
|
|
- '__PROJECT_ID__'=>'__PROJECT_ID__',
|
|
|
- '__PROJECT_REF__'=>'__PROJECT_REF__',
|
|
|
- '__PROJECT_NAME__'=>'__PROJECT_NAME__',
|
|
|
- '__CONTACTCIVNAME__'=>'__CONTACTCIVNAME__',
|
|
|
- '__AMOUNT__'=>'__AMOUNT__',
|
|
|
- '__AMOUNT_EXCL_TAX__'=>'__AMOUNT_EXCL_TAX__',
|
|
|
- '__AMOUNT_VAT__'=>'__AMOUNT_VAT__',
|
|
|
- '__ONLINE_PAYMENT_URL__'=>'__ONLINE_PAYMENT_URL__',
|
|
|
- '__SIGNATURE__'=>'__SIGNATURE__',
|
|
|
- '__PERSONALIZED__'=>'__PERSONALIZED__', // deprecated
|
|
|
- );
|
|
|
+ $parameters=array('mode'=>$mode);
|
|
|
+ $tmparray=getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects
|
|
|
+ complete_substitutions_array($tmparray, $langs, null, $parameters);
|
|
|
+
|
|
|
if ($mode == 'formwithlines')
|
|
|
{
|
|
|
- $vars[] = '__LINES__'; // Will be set by the get_form function
|
|
|
+ $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function
|
|
|
}
|
|
|
if ($mode == 'formforlines')
|
|
|
{
|
|
|
- $vars[] = '__QUANTITY__'; // Will be set by the get_form function
|
|
|
+ $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if ($mode == 'emailing')
|
|
|
{
|
|
|
+ $parameters=array('mode'=>$mode);
|
|
|
+ $tmparray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects
|
|
|
+ complete_substitutions_array($tmparray, $langs, null, $parameters);
|
|
|
+
|
|
|
// For mass emailing, we have different keys
|
|
|
- $vars=array(
|
|
|
- '__ID__' => 'IdRecord',
|
|
|
- '__EMAIL__' => 'EMailRecipient',
|
|
|
- '__LASTNAME__' => 'Lastname',
|
|
|
- '__FIRSTNAME__' => 'Firstname',
|
|
|
- '__MAILTOEMAIL__' => 'TagMailtoEmail',
|
|
|
- '__OTHER1__' => 'Other1',
|
|
|
- '__OTHER2__' => 'Other2',
|
|
|
- '__OTHER3__' => 'Other3',
|
|
|
- '__OTHER4__' => 'Other4',
|
|
|
- '__OTHER5__' => 'Other5',
|
|
|
- '__SIGNATURE__' => 'TagSignature',
|
|
|
- '__CHECK_READ__' => 'TagCheckMail',
|
|
|
- '__UNSUBSCRIBE__' => 'TagUnsubscribe'
|
|
|
+ $tmparray['__ID__'] = 'IdRecord';
|
|
|
+ $tmparray['__EMAIL__'] = 'EMailRecipient';
|
|
|
+ $tmparray['__LASTNAME__'] = 'Lastname';
|
|
|
+ $tmparray['__FIRSTNAME__'] = 'Firstname';
|
|
|
+ $tmparray['__MAILTOEMAIL__'] = 'TagMailtoEmail';
|
|
|
+ $tmparray['__OTHER1__'] = 'Other1';
|
|
|
+ $tmparray['__OTHER2__'] = 'Other2';
|
|
|
+ $tmparray['__OTHER3__'] = 'Other3';
|
|
|
+ $tmparray['__OTHER4__'] = 'Other4';
|
|
|
+ $tmparray['__OTHER5__'] = 'Other5';
|
|
|
+ $tmparray['__SIGNATURE__'] = 'TagSignature';
|
|
|
+ $tmparray['__CHECK_READ__'] = 'TagCheckMail';
|
|
|
+ $tmparray['__UNSUBSCRIBE__'] = 'TagUnsubscribe';
|
|
|
//,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing
|
|
|
- );
|
|
|
|
|
|
$onlinepaymentenabled = 0;
|
|
|
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
|
|
@@ -1183,13 +1155,13 @@ class FormMail extends Form
|
|
|
if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++;
|
|
|
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
|
|
|
{
|
|
|
- $vars['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN;
|
|
|
+ $tmparray['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN;
|
|
|
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
|
|
|
{
|
|
|
- if ($conf->adherent->enabled) $vars['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember';
|
|
|
- if ($conf->facture->enabled) $vars['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice';
|
|
|
- if ($conf->commande->enabled) $vars['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder';
|
|
|
- if ($conf->contrat->enabled) $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine';
|
|
|
+ if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember';
|
|
|
+ if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice';
|
|
|
+ if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder';
|
|
|
+ if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine';
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -1202,36 +1174,16 @@ class FormMail extends Form
|
|
|
$vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='';
|
|
|
*/
|
|
|
}
|
|
|
-
|
|
|
- // Old vars removed from doc
|
|
|
- /*
|
|
|
- if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
|
|
|
- {
|
|
|
- $vars['__SECUREKEYPAYPAL__']='SecureKeyPaypal';
|
|
|
- if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
|
|
|
- {
|
|
|
- if ($conf->adherent->enabled) $vars['__SECUREKEYPAYPAL_MEMBER__']='SecureKeyPaypalUniquePerMember';
|
|
|
- if ($conf->facture->enabled) $vars['__SECUREKEYPAYPAL_INVOICE__']='SecureKeyPaypalUniquePerInvoice';
|
|
|
- if ($conf->commande->enabled) $vars['__SECUREKEYPAYPAL_ORDER__']='SecureKeyPaypalUniquePerOrder';
|
|
|
- if ($conf->contrat->enabled) $vars['__SECUREKEYPAYPAL_CONTRACTLINE__']='SecureKeyPaypalUniquePerContractLine';
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $vars['__SECUREKEYPAYPAL__']='';
|
|
|
- $vars['__SECUREKEYPAYPAL_MEMBER__']='';
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
- $parameters=array('mode'=>$mode);
|
|
|
- $tmparray=getCommonSubstitutionArray($langs, 2, null, $object);
|
|
|
- complete_substitutions_array($tmparray, $langs, null, $parameters);
|
|
|
+ $tmparray['__(AnyTranslationKey)__']="Translation";
|
|
|
+
|
|
|
foreach($tmparray as $key => $val)
|
|
|
{
|
|
|
- $vars[$key]=$key;
|
|
|
+ if (empty($val)) $tmparray[$key]=$key;
|
|
|
}
|
|
|
|
|
|
- return $vars;
|
|
|
+ return $tmparray;
|
|
|
}
|
|
|
|
|
|
}
|