NEW Attaching doc automatically in email is now a parameter of template.

This commit is contained in:
Laurent Destailleur
2017-10-08 16:34:42 +02:00
parent ce7ce82801
commit 33624e1001
10 changed files with 101 additions and 157 deletions

View File

@@ -170,6 +170,7 @@ if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$la
if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember'); if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
$elementList['user']=$langs->trans('MailToUser');
$elementList['all'] =$langs->trans('VisibleEverywhere'); $elementList['all'] =$langs->trans('VisibleEverywhere');
$elementList['none']=$langs->trans('VisibleNowhere'); $elementList['none']=$langs->trans('VisibleNowhere');
@@ -227,7 +228,7 @@ if (empty($reshook))
if ($value == 'content') continue; if ($value == 'content') continue;
if ($value == 'content_lines') continue; if ($value == 'content_lines') continue;
if ($value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
{ {
@@ -857,6 +858,8 @@ if ($resql)
if ($value == 'joinfiles') if ($value == 'joinfiles')
{ {
$align="center"; $align="center";
if ($valuetoshow) $valuetoshow=1;
else $valuetoshow='';
} }
$class='tddict'; $class='tddict';

View File

@@ -113,14 +113,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$result=$object->fetch($id); $result=$object->fetch($id);
$sendtosocid=0; // Thirdparty on object $sendtosocid=0; // Thirdparty on object
if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member'))) if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user')))
{ {
$result=$object->fetch_thirdparty(); $result=$object->fetch_thirdparty();
if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok
$thirdparty=$object->thirdparty; $thirdparty=$object->thirdparty;
$sendtosocid=$thirdparty->id; $sendtosocid=$thirdparty->id;
} }
else if ($object->element == 'member') else if ($object->element == 'member' || $object->element == 'user')
{ {
$thirdparty=$object; $thirdparty=$object;
if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;

View File

@@ -271,16 +271,6 @@ class FormMail extends Form
$disablebademails=1; $disablebademails=1;
// Define list of attached files
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
@@ -307,6 +297,30 @@ class FormMail extends Form
//var_dump($model_id); //var_dump($model_id);
//var_dump($arraydefaultmessage); //var_dump($arraydefaultmessage);
// Define list of attached files
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (GETPOST('mode','alpha') == 'init' || (GETPOST('modelmailselected','alpha') && GETPOST('modelmailselected','alpha') != '-1'))
{
$this->clear_attached_files();
if (! empty($arraydefaultmessage['joinfiles']) && is_array($this->param['fileinit']))
{
foreach($this->param['fileinit'] as $file)
{
$this->add_attached_files($file, basename($file), dol_mimetype($file));
}
}
}
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
$out.= "\n".'<!-- Begin form mail type='.$this->param["models"].' --><div id="mailformdiv"></div>'."\n"; $out.= "\n".'<!-- Begin form mail type='.$this->param["models"].' --><div id="mailformdiv"></div>'."\n";
if ($this->withform == 1) if ($this->withform == 1)
{ {
@@ -369,7 +383,7 @@ class FormMail extends Form
elseif (! empty($this->param['models']) && in_array($this->param['models'], array( elseif (! empty($this->param['models']) && in_array($this->param['models'], array(
'propal_send','order_send','facture_send', 'propal_send','order_send','facture_send',
'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send', 'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send',
'invoice_supplier_send','thirdparty','contract','all' 'invoice_supplier_send','thirdparty','contract','user','all'
))) )))
{ {
// If list of template is empty // If list of template is empty
@@ -922,7 +936,7 @@ class FormMail extends Form
{ {
$ret=array(); $ret=array();
$sql = "SELECT label, topic, content, content_lines, lang"; $sql = "SELECT label, topic, joinfiles, content, content_lines, lang";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
$sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')";
$sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; $sql.= " AND entity IN (".getEntity('c_email_templates', 0).")";
@@ -942,10 +956,11 @@ class FormMail extends Form
if ($obj) if ($obj)
{ {
$ret['label']=$obj->label; $ret['label']=$obj->label;
$ret['lang']=$obj->lang;
$ret['topic']=$obj->topic; $ret['topic']=$obj->topic;
$ret['joinfiles']=$obj->joinfiles;
$ret['content']=$obj->content; $ret['content']=$obj->content;
$ret['content_lines']=$obj->content_lines; $ret['content_lines']=$obj->content_lines;
$ret['lang']=$obj->lang;
} }
else // If there is no template at all else // If there is no template at all
{ {
@@ -963,10 +978,11 @@ class FormMail extends Form
elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); }
$ret['label']='default'; $ret['label']='default';
$ret['lang']=$outputlangs->defaultlang;
$ret['topic']=''; $ret['topic']='';
$ret['joinfiles']=1;
$ret['content']=$defaultmessage; $ret['content']=$defaultmessage;
$ret['content_lines']=''; $ret['content_lines']='';
$ret['lang']=$outputlangs->defaultlang;
} }
$db->free($resql); $db->free($resql);

View File

@@ -5296,6 +5296,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = 'Security key for payment on an order'; $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = 'Security key for payment on an order';
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = 'Security key for payment on an invoice'; $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = 'Security key for payment on an invoice';
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'Security key for payment on a a service'; $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'Security key for payment on a a service';
$substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number';
$substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url';
} }
else else
{ {
@@ -5340,15 +5344,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
$substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); $substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:'');
} }
// Create dynamic tags for __EXTRAFIELD_FIELD__ if (is_object($object) && $object->element == 'shipping')
if ($object->table_element && $object->id > 0)
{ {
$extrafieldstmp = new ExtraFields($db); $substitutionarray['__SHIPPINGTRACKNUM__']=$object->tracking_number;
$extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); $substitutionarray['__SHIPPINGTRACKNUMURL__']=$object->tracking_url;
$object->fetch_optionals($object->id, $extralabels);
foreach ($extrafieldstmp->attribute_label as $key => $label) {
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
}
} }
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
@@ -5366,6 +5365,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
} }
// Create dynamic tags for __EXTRAFIELD_FIELD__
if ($object->table_element && $object->id > 0)
{
$extrafieldstmp = new ExtraFields($db);
$extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true);
$object->fetch_optionals($object->id, $extralabels);
foreach ($extrafieldstmp->attribute_label as $key => $label) {
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
}
}
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'TODO'; $substitutionarray['__ONLINE_PAYMENT_URL__'] = 'TODO';
} }
} }

View File

@@ -129,7 +129,7 @@ if ($action == 'presend')
$liste[$key] = $value; $liste[$key] = $value;
} }
} }
elseif ($object->element == 'member') elseif ($object->element == 'user' || $object->element == 'member')
{ {
$liste['thirdparty'] = $object->getFullName($langs)." &lt;".$object->email."&gt;"; $liste['thirdparty'] = $object->getFullName($langs)." &lt;".$object->email."&gt;";
} }
@@ -169,12 +169,15 @@ if ($action == 'presend')
$formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['id'] = $object->id; $formmail->param['id'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
$formmail->param['fileinit'] = array($file);
// Init list of files // Init list of files
if (GETPOST("mode") == 'init') { /*if (GETPOST('mode','alpha') == 'init')
{
$formmail->clear_attached_files(); $formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file)); $formmail->add_attached_files($file, basename($file), dol_mimetype($file));
} }*/
// Show form // Show form
print $formmail->get_form(); print $formmail->get_form();

View File

@@ -2151,6 +2151,16 @@ else if ($id || $ref)
if (GETPOST('modelselected')) { if (GETPOST('modelselected')) {
$action = 'presend'; $action = 'presend';
} }
// Presend form
$modelmail='shipping_send';
$defaulttopic='SendShippingRef';
$diroutput = $conf->expedition->dir_output. '/sending';
$trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
/*
if ($action == 'presend') if ($action == 'presend')
{ {
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
@@ -2278,7 +2288,7 @@ else if ($id || $ref)
print $formmail->get_form(); print $formmail->get_form();
dol_fiche_end(); dol_fiche_end();
} }*/
} }

View File

@@ -1712,6 +1712,7 @@ MailToSendSupplierInvoice=To send supplier invoice
MailToSendContract=To send a contract MailToSendContract=To send a contract
MailToThirdparty=To send email from third party page MailToThirdparty=To send email from third party page
MailToMember=To send email from member page MailToMember=To send email from member page
MailToUser=To send email from user page
ByDefaultInList=Show by default on list view ByDefaultInList=Show by default on list view
YouUseLastStableVersion=You use the latest stable version YouUseLastStableVersion=You use the latest stable version
TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites) TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites)

View File

@@ -79,14 +79,14 @@ NbOfActiveNotifications=Number of notifications (nb of recipient emails)
PredefinedMailTest=This is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__SIGNATURE__ PredefinedMailTest=This is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__SIGNATURE__
PredefinedMailTestHtml=This is a <b>test</b> mail (the word test must be in bold).<br>The two lines are separated by a carriage return.<br><br>__SIGNATURE__ PredefinedMailTestHtml=This is a <b>test</b> mail (the word test must be in bold).<br>The two lines are separated by a carriage return.<br><br>__SIGNATURE__
PredefinedMailContentSendInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendInvoiceReminder=__CONTACTCIVNAME__\n\nWe would like to warn you that the invoice __REF__ seems to not being payed. So this is the invoice in attachment again, as a reminder.\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendInvoiceReminder=__CONTACTCIVNAME__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendProposal=__CONTACTCIVNAME__\n\nYou will find here the commercial proposal __PROPREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendProposal=__CONTACTCIVNAME__\n\nYou will find here the commercial proposal __PREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendSupplierProposal=__CONTACTCIVNAME__\n\nYou will find here the price request __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendSupplierProposal=__CONTACTCIVNAME__\n\nYou will find here the price request __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendOrder=__CONTACTCIVNAME__\n\nYou will find here the order __ORDERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendOrder=__CONTACTCIVNAME__\n\nYou will find here the order __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nYou will find here our order __ORDERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nYou will find here our order __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentThirdparty=\n\n__SIGNATURE__ PredefinedMailContentThirdparty=\n\n__SIGNATURE__
PredefinedMailContentUser=\n\n__SIGNATURE__ PredefinedMailContentUser=\n\n__SIGNATURE__
DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available.

View File

@@ -440,7 +440,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Documents // Documents
$comref = dol_sanitizeFileName($object->ref); $comref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf'; $relativepath = $comref . '/' . $comref . '.pdf';
$filedir = $conf->inventory->dir_output . '/' . $comref; $filedir = $conf->product->dir_output . '/inventory/' . $comref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->inventory->creer; $genallowed = $user->rights->inventory->creer;
$delallowed = $user->rights->inventory->supprimer; $delallowed = $user->rights->inventory->supprimer;
@@ -463,126 +463,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
//Select mail models is same action as presend
/* /*
* Action presend if (GETPOST('modelselected')) $action = 'presend';
*/
/*
if ($action == 'presend')
{
$object->fetch_projet();
$ref = dol_sanitizeFileName($object->ref); // Presend form
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $modelmail='inventory';
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $defaulttopic='InformationMessage';
$file = $fileparams['fullname']; $diroutput = $conf->product->dir_output.'/inventory';
$trackid = 'stockinv'.$object->id;
// Define output language include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
$outputlangs = $langs; */
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('commercial');
}
// Build document if it not exists
if (! $file || ! is_readable($file)) {
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
dol_print_error($db, $object->error, $object->errors);
exit();
}
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans('SendOrderByMail'));
dol_fiche_head('');
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='ord'.$object->id;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
}
$formmail->withfrom = 1;
$liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
$liste [$key] = $value;
$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
$formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
if (empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__');
} else if (! empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)');
}
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Tableau des substitutions
$formmail->setSubstitFromObject($object, $outputlangs);
$formmail->substit ['__ORDERREF__'] = $object->ref;
$custcontact = '';
$contactarr = array();
$contactarr = $object->liste_contact(- 1, 'external');
if (is_array($contactarr) && count($contactarr) > 0)
{
foreach ($contactarr as $contact)
{
if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { // TODO Use code and not label
$contactstatic = new Contact($db);
$contactstatic->fetch($contact ['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (! empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
$formmail->param['models'] = 'order_send';
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['orderid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
// Show form
print $formmail->get_form();
dol_fiche_end();
}*/
} }

View File

@@ -1723,9 +1723,17 @@ else
//Select mail models is same action as presend //Select mail models is same action as presend
if (GETPOST('modelselected')) { if (GETPOST('modelselected')) $action = 'presend';
$action = 'presend';
} // Presend form
$modelmail='user';
$defaulttopic='Information';
$diroutput = $conf->user->dir_output;
$trackid = 'user'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
/*
if ($action == 'presend') if ($action == 'presend')
{ {
// Show email form // Show email form
@@ -1798,6 +1806,7 @@ else
dol_fiche_end(); dol_fiche_end();
} }
*/
if (GETPOST('action','aZ09') != 'presend' && GETPOST('action','aZ09') != 'send') if (GETPOST('action','aZ09') != 'presend' && GETPOST('action','aZ09') != 'send')
{ {
@@ -2538,7 +2547,7 @@ else
print '</form>'; print '</form>';
} }
if ($action != 'edit') if ($action != 'edit' && $action != 'presend')
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
/* /*