-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
html.formmail.class.php
633 lines (577 loc) · 24.9 KB
/
html.formmail.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
<?php
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/class/html.formmail.class.php
* \ingroup core
* \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
/**
* Classe permettant la generation du formulaire html d'envoi de mail unitaire
* Usage: $formail = new FormMail($db)
* $formmail->proprietes=1 ou chaine ou tableau de valeurs
* $formmail->show_form() affiche le formulaire
*/
class FormMail
{
var $db;
var $withform;
var $fromname;
var $frommail;
var $replytoname;
var $replytomail;
var $toname;
var $tomail;
var $withsubstit; // Show substitution array
var $withfrom;
var $withto;
var $withtofree;
var $withtocc;
var $withtoccc;
var $withtopic;
var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
var $withbody;
var $withfromreadonly;
var $withreplytoreadonly;
var $withtoreadonly;
var $withtoccreadonly;
var $withtopicreadonly;
var $withfilereadonly;
var $withdeliveryreceipt;
var $withcancel;
var $withfckeditor;
var $substit=array();
var $param=array();
var $error;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->withform=1;
$this->withfrom=1;
$this->withto=1;
$this->withtofree=1;
$this->withtocc=1;
$this->withtoccc=0;
$this->witherrorsto=0;
$this->withtopic=1;
$this->withfile=0;
$this->withbody=1;
$this->withfromreadonly=1;
$this->withreplytoreadonly=1;
$this->withtoreadonly=0;
$this->withtoccreadonly=0;
$this->witherrorstoreadonly=0;
$this->withtopicreadonly=0;
$this->withfilereadonly=0;
$this->withbodyreadonly=0;
$this->withdeliveryreceiptreadonly=0;
$this->withfckeditor=0;
return 1;
}
/**
* Clear list of attached files in send mail form (stored in session)
*
* @return void
*/
function clear_attached_files()
{
global $conf,$user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Set tmp user directory
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/';
if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
unset($_SESSION["listofpaths"]);
unset($_SESSION["listofnames"]);
unset($_SESSION["listofmimes"]);
}
/**
* Add a file into the list of attached files (stored in SECTION array)
*
* @param string $path Full absolute path on filesystem of file, including file name
* @param string $file Only filename
* @param string $type Mime type
* @return void
*/
function add_attached_files($path,$file,$type)
{
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
if (! in_array($file,$listofnames))
{
$listofpaths[]=$path;
$listofnames[]=$file;
$listofmimes[]=$type;
$_SESSION["listofpaths"]=join(';',$listofpaths);
$_SESSION["listofnames"]=join(';',$listofnames);
$_SESSION["listofmimes"]=join(';',$listofmimes);
}
}
/**
* Remove a file from the list of attached files (stored in SECTION array)
*
* @param string $keytodelete Key in file array
* @return void
*/
function remove_attached_files($keytodelete)
{
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
if ($keytodelete >= 0)
{
unset ($listofpaths[$keytodelete]);
unset ($listofnames[$keytodelete]);
unset ($listofmimes[$keytodelete]);
$_SESSION["listofpaths"]=join(';',$listofpaths);
$_SESSION["listofnames"]=join(';',$listofnames);
$_SESSION["listofmimes"]=join(';',$listofmimes);
//var_dump($_SESSION['listofpaths']);
}
}
/**
* Return list of attached files (stored in SECTION array)
*
* @return array array('paths'=> ,'names'=>, 'mimes'=> )
*/
function get_attached_files()
{
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
}
/**
* Show the form to input an email
* this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
*
* @param string $addfileaction Name of action when posting file attachments
* @param string $removefileaction Name of action when removing file attachments
* @return void
*/
function show_form($addfileaction='addfile',$removefileaction='removefile')
{
print $this->get_form($addfileaction,$removefileaction);
}
/**
* Get the form to input an email
* this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
*
* @param string $addfileaction Name of action when posting file attachments
* @param string $removefileaction Name of action when removing file attachments
* @return string Form to show
*/
function get_form($addfileaction='addfile',$removefileaction='removefile')
{
global $conf, $langs, $user, $hookmanager;
$langs->load("other");
$langs->load("mails");
$hookmanager->initHooks(array('formmail'));
$parameters=array(
'addfileaction' => $addfileaction,
'removefileaction'=> $removefileaction
);
$reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this);
if (!empty($reshook))
{
return $hookmanager->resPrint;
}
else
{
$out='';
// Define list of attached files
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
$form=new Form($this->db);
$out.= "\n<!-- Debut form mail -->\n";
if ($this->withform)
{
$out.= '<form method="POST" name="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
}
foreach ($this->param as $key=>$value)
{
$out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
}
$out.= '<table class="border" width="100%">'."\n";
// Substitution array
if (! empty($this->withsubstit))
{
$out.= '<tr><td colspan="2">';
$help="";
foreach($this->substit as $key => $val)
{
$help.=$key.' -> '.$langs->trans($val).'<br>';
}
$out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help);
$out.= "</td></tr>\n";
}
// From
if (! empty($this->withfrom))
{
if (! empty($this->withfromreadonly))
{
$out.= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />';
$out.= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />';
$out.= '<tr><td width="180">'.$langs->trans("MailFrom").'</td><td>';
if ($this->fromtype == 'user' && $this->fromid > 0)
{
$langs->load("users");
$fuser=new User($this->db);
$fuser->fetch($this->fromid);
$out.= $fuser->getNomUrl(1);
}
else
{
$out.= $this->fromname;
}
if ($this->frommail)
{
$out.= " <".$this->frommail.">";
}
else
{
if ($this->fromtype)
{
$langs->load("errors");
$out.= '<font class="warning"> <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> </font>';
}
}
$out.= "</td></tr>\n";
$out.= "</td></tr>\n";
}
else
{
$out.= "<tr><td>".$langs->trans("MailFrom")."</td><td>";
$out.= $langs->trans("Name").':<input type="text" id="fromname" name="fromname" size="32" value="'.$this->fromname.'" />';
$out.= ' ';
$out.= $langs->trans("EMail").':<<input type="text" id="frommail" name="frommail" size="32" value="'.$this->frommail.'" />>';
$out.= "</td></tr>\n";
}
}
// Replyto
if (! empty($this->withreplyto))
{
if ($this->withreplytoreadonly)
{
$out.= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />';
$out.= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />';
$out.= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):"");
$out.= "</td></tr>\n";
}
}
// Errorsto
if (! empty($this->witherrorsto))
{
//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
$errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail);
if ($this->witherrorstoreadonly)
{
$out.= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= $errorstomail;
$out.= "</td></tr>\n";
}
else
{
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= "</td></tr>\n";
}
}
// To
if (! empty($this->withto) || is_array($this->withto))
{
$out.= '<tr><td width="180">';
if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
else $out.= $langs->trans("MailTo");
$out.= '</td><td>';
if ($this->withtoreadonly)
{
if (! empty($this->toname) && ! empty($this->tomail))
{
$out.= '<input type="hidden" id="toname" name="toname" value="'.$this->toname.'" />';
$out.= '<input type="hidden" id="tomail" name="tomail" value="'.$this->tomail.'" />';
if ($this->totype == 'thirdparty')
{
$soc=new Societe($this->db);
$soc->fetch($this->toid);
$out.= $soc->getNomUrl(1);
}
else if ($this->totype == 'contact')
{
$contact=new Contact($this->db);
$contact->fetch($this->toid);
$out.= $contact->getNomUrl(1);
}
else
{
$out.= $this->toname;
}
$out.= ' <'.$this->tomail.'>';
if ($this->withtofree)
{
$out.= '<br>'.$langs->trans("or").' <input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
}
}
else
{
$out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
}
}
else
{
if (! empty($this->withtofree))
{
$out.= '<input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
}
if (! empty($this->withto) && is_array($this->withto))
{
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1);
}
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
{
$liste=array();
$soc=new Societe($this->db);
$soc->fetch($this->withtosocid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
{
$liste[$key]=$value;
}
if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1);
}
}
$out.= "</td></tr>\n";
}
// CC
if (! empty($this->withtocc) || is_array($this->withtocc))
{
$out.= '<tr><td width="180">';
$out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>';
if ($this->withtoccreadonly)
{
$out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"";
}
else
{
$out.= '<input size="'.(is_array($this->withtocc)?"30":"60").'" id="sendtocc" name="sendtocc" value="'.((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />';
if (! empty($this->withtocc) && is_array($this->withtocc))
{
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1);
}
}
$out.= "</td></tr>\n";
}
// CCC
if (! empty($this->withtoccc) || is_array($this->withtoccc))
{
$out.= '<tr><td width="180">';
$out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>';
if (! empty($this->withtocccreadonly))
{
$out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
}
else
{
$out.= '<input size="'.(is_array($this->withtoccc)?"30":"60").'" id="sendtoccc" name="sendtoccc" value="'.((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />';
if (! empty($this->withtoccc) && is_array($this->withtoccc))
{
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1);
}
}
//if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1);
$out.= "</td></tr>\n";
}
// Ask delivery receipt
if (! empty($this->withdeliveryreceipt))
{
$out.= '<tr><td width="180">'.$langs->trans("DeliveryReceipt").'</td><td>';
if (! empty($this->withdeliveryreceiptreadonly))
{
$out.= yn($this->withdeliveryreceipt);
}
else
{
$out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1);
}
$out.= "</td></tr>\n";
}
// Topic
if (! empty($this->withtopic))
{
$this->withtopic=make_substitutions($this->withtopic,$this->substit);
$out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailTopic").'</td>';
$out.= '<td>';
if ($this->withtopicreadonly)
{
$out.= $this->withtopic;
$out.= '<input type="hidden" size="60" id="subject" name="subject" value="'.$this->withtopic.'" />';
}
else
{
$out.= '<input type="text" size="60" id="subject" name="subject" value="'. (isset($_POST["subject"])?$_POST["subject"]:$this->withtopic) .'" />';
}
$out.= "</td></tr>\n";
}
// Attached files
if (! empty($this->withfile))
{
$out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
$out.= '<td>';
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
$out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
$out.= '<script type="text/javascript" language="javascript">';
$out.= 'jQuery(document).ready(function () {';
$out.= ' jQuery(".removedfile").click(function() {';
$out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
$out.= ' });';
$out.= '})';
$out.= '</script>'."\n";
if (count($listofpaths))
{
foreach($listofpaths as $key => $val)
{
$out.= '<div id="attachfile_'.$key.'">';
$out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
if (! $this->withfilereadonly)
{
$out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
}
$out.= '<br></div>';
}
}
else
{
$out.= $langs->trans("NoAttachedFiles").'<br>';
}
if ($this->withfile == 2) // Can add other files
{
$out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
$out.= ' ';
$out.= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
}
$out.= "</td></tr>\n";
}
// Message
if (! empty($this->withbody))
{
$defaultmessage="";
// TODO A partir du type, proposer liste de messages dans table llx_models
if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); }
elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }
elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); }
elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); }
elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); }
elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); }
elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); }
elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); }
elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; }
// Complete substitution array
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL))
{
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
$langs->load('paypal');
if ($this->param["models"]=='order_send')
{
$url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']);
$this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url);
}
if ($this->param["models"]=='facture_send')
{
$url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']);
$this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url);
}
}
$defaultmessage=make_substitutions($defaultmessage,$this->substit);
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
$out.= '<tr>';
$out.= '<td width="180" valign="top">'.$langs->trans("MailText").'</td>';
$out.= '<td>';
if ($this->withbodyreadonly)
{
$out.= nl2br($defaultmessage);
$out.= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />';
}
else
{
if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
$this->withfckeditor=1;
}
$doleditor=new DolEditor('message',nl2br($defaultmessage),'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72);
$out.= $doleditor->Create(1);
}
$out.= "</td></tr>\n";
}
if (! empty($this->withform))
{
$out.= '<tr><td align="center" colspan="2"><center>';
$out.= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"';
// Add a javascript test to avoid to forget to submit file before sending email
if ($this->withfile == 2 && $conf->use_javascript_ajax)
{
$out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
}
$out.= ' />';
if ($this->withcancel)
{
$out.= ' ';
$out.= '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />';
}
$out.= '</center></td></tr>'."\n";
}
$out.= '</table>'."\n";
if (! empty($this->withform)) $out.= '</form>'."\n";
$out.= "<!-- Fin form mail -->\n";
return $out;
}
}
}
?>