26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
31 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollector.class.php';
34 include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectorfilter.class.php';
35 include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectoraction.class.php';
36 include_once DOL_DOCUMENT_ROOT.
'/emailcollector/lib/emailcollector.lib.php';
39 require DOL_DOCUMENT_ROOT.
'/includes/webklex/php-imap/vendor/autoload.php';
40 use Webklex\PHPIMAP\ClientManager;
41 use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
42 use Webklex\PHPIMAP\Exceptions\InvalidWhereQueryCriteriaException;
45 use OAuth\Common\Storage\DoliStorage;
46 use OAuth\Common\Consumer\Credentials;
56 $langs->loadLangs(array(
"admin",
"mails",
"other"));
61 $action =
GETPOST(
'action',
'aZ09');
62 $confirm =
GETPOST(
'confirm',
'alpha');
63 $cancel =
GETPOST(
'cancel',
'aZ09');
64 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'emailcollectorcard';
65 $backtopage =
GETPOST(
'backtopage',
'alpha');
67 $operationid =
GETPOST(
'operationid',
'int');
72 $diroutputmassaction = $conf->emailcollector->dir_output.
'/temp/massgeneration/'.$user->id;
73 $hookmanager->initHooks(array(
'emailcollectorcard'));
76 $extrafields->fetch_name_optionals_label($object->table_element);
78 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
81 $search_all =
GETPOST(
"search_all",
'alpha');
83 foreach ($object->fields as $key => $val) {
84 if (
GETPOST(
'search_'.$key,
'alpha')) {
85 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
89 if (
GETPOST(
'saveoperation2')) {
90 $action =
'updateoperation';
92 if (empty($action) && empty($id) && empty($ref)) {
97 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
105 $permissionnote = $user->admin;
106 $permissiondellink = $user->admin;
107 $permissiontoadd = $user->admin;
117 $parameters = array();
118 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
124 if (empty($reshook)) {
125 $permissiontoadd = 1;
126 $permissiontodelete = 1;
127 if (empty($backtopage)) {
128 $backtopage = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.($id > 0 ? $id :
'__ID__');
130 $backurlforlist = DOL_URL_ROOT.
'/admin/emailcollector_list.php';
133 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
136 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
139 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
142 if (
GETPOST(
'addfilter',
'alpha')) {
144 $emailcollectorfilter->type =
GETPOST(
'filtertype',
'aZ09');
145 $emailcollectorfilter->rulevalue =
GETPOST(
'rulevalue',
'alpha');
146 $emailcollectorfilter->fk_emailcollector = $object->id;
147 $emailcollectorfilter->status = 1;
149 $result = $emailcollectorfilter->create($user);
152 $object->fetchFilters();
154 setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error,
'errors');
158 if ($action ==
'deletefilter') {
160 $emailcollectorfilter->fetch(
GETPOST(
'filterid',
'int'));
161 if ($emailcollectorfilter->id > 0) {
162 $result = $emailcollectorfilter->delete($user);
164 $object->fetchFilters();
166 setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error,
'errors');
171 if (
GETPOST(
'addoperation',
'alpha')) {
173 $emailcollectoroperation->type =
GETPOST(
'operationtype',
'aZ09');
174 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam',
'restricthtml');
175 $emailcollectoroperation->fk_emailcollector = $object->id;
176 $emailcollectoroperation->status = 1;
177 $emailcollectoroperation->position = 50;
179 if ($emailcollectoroperation->type ==
'-1') {
181 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Operation")),
null,
'errors');
184 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
185 && empty($emailcollectoroperation->actionparam)) {
187 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
191 $result = $emailcollectoroperation->create($user);
194 $object->fetchActions();
197 setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error,
'errors');
202 if ($action ==
'updateoperation') {
204 $emailcollectoroperation->fetch(
GETPOST(
'rowidoperation2',
'int'));
206 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam2',
'alphawithlgt');
208 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
209 && empty($emailcollectoroperation->actionparam)) {
211 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
215 $result = $emailcollectoroperation->update($user);
218 $object->fetchActions();
221 setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error,
'errors');
225 if ($action ==
'deleteoperation') {
227 $emailcollectoroperation->fetch(
GETPOST(
'operationid',
'int'));
228 if ($emailcollectoroperation->id > 0) {
229 $result = $emailcollectoroperation->delete($user);
231 $object->fetchActions();
233 setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error,
'errors');
238 if ($action ==
'collecttest') {
241 $res = $object->doCollectOneCollector(1);
243 $debuginfo = $object->debuginfo;
246 $debuginfo = $object->debuginfo;
253 if ($action ==
'confirm_collect') {
256 $res = $object->doCollectOneCollector(0);
258 $debuginfo = $object->debuginfo;
261 $debuginfo = $object->debuginfo;
277 $help_url =
"EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
282 if ($action ==
'create') {
283 print
load_fiche_titre($langs->trans(
"NewEmailCollector", $langs->transnoentitiesnoconv(
"EmailCollector")));
285 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
286 print
'<input type="hidden" name="token" value="'.newToken().
'">';
287 print
'<input type="hidden" name="action" value="add">';
288 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
292 print
'<table class="border centpercent tableforfield">'.
"\n";
297 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
300 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
302 print
'</table>'.
"\n";
306 print
$form->buttonsSaveCancel(
"Create");
312 if (($id || $ref) && $action ==
'edit') {
315 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
316 print
'<input type="hidden" name="token" value="'.newToken().
'">';
317 print
'<input type="hidden" name="action" value="update">';
318 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
319 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
323 print
'<table class="border centpercent tableforfield">'.
"\n";
326 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
329 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
335 print
$form->buttonsSaveCancel();
341 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
342 $res = $object->fetch_optionals();
344 $object->fetchFilters();
345 $object->fetchActions();
348 print
dol_get_fiche_head($head,
'card', $langs->trans(
"EmailCollector"), -1,
'email');
353 if ($action ==
'delete') {
354 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteEmailCollector'), $langs->trans(
'ConfirmDeleteEmailCollector'),
'confirm_delete',
'', 0, 1);
358 if ($action ==
'clone') {
360 $formquestion = array();
361 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEmailCollector', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
365 if ($action ==
'collect') {
366 $formquestion = array();
367 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'EmailCollectorConfirmCollectTitle'), $langs->trans(
'EmailCollectorConfirmCollect'),
'confirm_collect', $formquestion, 0, 1, 220);
372 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
373 if (empty($reshook)) {
375 } elseif ($reshook > 0) {
384 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/emailcollector_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
386 $morehtmlref =
'<div class="refidno">';
387 $morehtmlref .=
'</div>';
391 $sourcedir = $object->source_directory;
392 $targetdir = ($object->target_directory ? $object->target_directory :
'');
395 $connectstringserver =
'';
396 $connectstringsource =
'';
397 $connectstringtarget =
'';
402 $connectstringserver = $object->getConnectStringIMAP($usessl);
404 if ($action ==
'scan') {
405 if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
406 if ($object->acces_type == 1) {
408 require_once DOL_DOCUMENT_ROOT.
'/core/lib/oauth.lib.php';
409 $keyforsupportedoauth2array = $object->oauth_service;
410 if (preg_match(
'/^.*-/', $keyforsupportedoauth2array)) {
411 $keyforprovider = preg_replace(
'/^.*-/',
'', $keyforsupportedoauth2array);
413 $keyforprovider =
'';
415 $keyforsupportedoauth2array = preg_replace(
'/-.*$/',
'', $keyforsupportedoauth2array);
416 $keyforsupportedoauth2array =
'OAUTH_'.$keyforsupportedoauth2array.
'_NAME';
418 $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array][
'name']) ?
'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array][
'name'].($keyforprovider ?
'-'.$keyforprovider :
''));
420 require_once DOL_DOCUMENT_ROOT.
'/includes/OAuth/bootstrap.php';
426 $storage =
new DoliStorage($db, $conf, $keyforprovider);
429 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
437 if (is_object($tokenobj) && $expire) {
438 $credentials =
new Credentials(
443 $serviceFactory = new \OAuth\ServiceFactory();
444 $oauthname = explode(
'-', $OAUTH_SERVICENAME);
447 $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
450 $refreshtoken = $tokenobj->getRefreshToken();
452 $tokenobj = $apiService->refreshAccessToken($tokenobj);
454 $tokenobj->setRefreshToken($refreshtoken);
455 $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
457 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
458 if (is_object($tokenobj)) {
459 $token = $tokenobj->getAccessToken();
462 $morehtml .=
"Token not found";
466 $morehtml .= $e->getMessage();
469 if (empty($object->login)) {
471 $morehtml .=
'Error: Login is empty. Must be email owner when using MAIN_IMAP_USE_PHPIMAP and OAuth.';
474 $cm =
new ClientManager();
475 $client = $cm->make([
476 'host' => $object->host,
477 'port' => $object->port,
478 'encryption' =>
'ssl',
479 'validate_cert' =>
true,
480 'protocol' =>
'imap',
481 'username' => $object->login,
482 'password' => $token,
483 'authentication' =>
"oauth",
487 $cm =
new ClientManager();
488 $client = $cm->make([
489 'host' => $object->host,
490 'port' => $object->port,
491 'encryption' =>
'ssl',
492 'validate_cert' =>
true,
493 'protocol' =>
'imap',
494 'username' => $object->login,
495 'password' => $object->password,
496 'authentication' =>
"login",
512 $f = $client->getFolders(
false, $object->source_directory);
513 $nbemail = $f[0]->examine()[
"exists"];
514 $morehtml .= $nbemail;
515 }
catch (ConnectionFailedException $e) {
516 $morehtml .=
'ConnectionFailedException '.$e->getMessage();
520 if (function_exists(
'imap_open')) {
524 $connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir);
528 $connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
531 $timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT;
532 $timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 20 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT;
534 dol_syslog(
"imap_open connectstring=".$connectstringsource.
" login=".$object->login.
" password=".$object->password.
" timeoutconnect=".$timeoutconnect.
" timeoutread=".$timeoutread);
536 $result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect);
537 $result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
538 $result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
539 $result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
541 dol_syslog(
"result1=".$result1.
" result2=".$result2.
" result3=".$result3.
" result4=".$result4);
543 $connection = imap_open($connectstringsource, $object->login, $object->password);
547 $morehtml .= $e->getMessage();
551 $morehtml .=
'Failed to open IMAP connection '.$connectstringsource;
552 if (function_exists(
'imap_last_error')) {
553 $morehtml .=
'<br>'.imap_last_error();
558 dol_syslog(
"Imap connected. Now we call imap_num_msg()");
559 $morehtml .= imap_num_msg($connection);
564 imap_close($connection);
567 $morehtml .=
'IMAP functions not available on your PHP. ';
572 $morehtml =
$form->textwithpicto($langs->trans(
"NbOfEmailsInInbox"),
'connect string '.$connectstringserver).
': '.($morehtml ? $morehtml :
'?');
573 $morehtml .=
'<a class="flat paddingleft marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=scan&token='.
newToken().
'">'.
img_picto(
'',
'refresh',
'class="paddingrightonly"').$langs->trans(
"Refresh").
'</a>';
575 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref.
'<div class="refidno">'.$morehtml.
'</div>',
'', 0,
'',
'', 0,
'');
577 print
'<div class="fichecenter">';
578 print
'<div class="fichehalfleft">';
579 print
'<div class="underbanner clearboth"></div>';
580 print
'<table class="border centpercent tableforfield">'.
"\n";
584 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
587 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
592 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
593 print
'<input type="hidden" name="token" value="'.newToken().
'">';
594 print
'<input type="hidden" name="action" value="updatefiltersactions">';
595 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
596 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
599 print
'<div class="div-table-responsive-no-min">';
600 print
'<table id="tablelineoffilters" class="noborder margintable noshadow">';
601 print
'<tr class="liste_titre nodrag nodrop">';
602 print
'<td>'.img_picto(
'',
'filter',
'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans(
"Filters"), $langs->trans(
"EmailCollectorFilterDesc")).
'</td><td></td><td></td>';
605 print
'<tr class="oddeven nodrag nodrop">';
607 $arrayoftypes = array(
608 'from'=>array(
'label'=>
'MailFrom',
'data-placeholder'=>$langs->trans(
'SearchString')),
609 'to'=>array(
'label'=>
'MailTo',
'data-placeholder'=>$langs->trans(
'SearchString')),
610 'cc'=>array(
'label'=>
'Cc',
'data-placeholder'=>$langs->trans(
'SearchString')),
611 'bcc'=>array(
'label'=>
'Bcc',
'data-placeholder'=>$langs->trans(
'SearchString')),
612 'subject'=>array(
'label'=>
'Subject',
'data-placeholder'=>$langs->trans(
'SearchString')),
613 'body'=>array(
'label'=>
'Body',
'data-placeholder'=>$langs->trans(
'SearchString')),
620 'seen'=>array(
'label'=>
'AlreadyRead',
'data-noparam'=>1),
621 'unseen'=>array(
'label'=>
'NotRead',
'data-noparam'=>1),
622 'unanswered'=>array(
'label'=>
'Unanswered',
'data-noparam'=>1),
623 'answered'=>array(
'label'=>
'Answered',
'data-noparam'=>1),
624 'smaller'=>array(
'label'=>
'SmallerThan',
'data-placeholder'=>$langs->trans(
'NumberOfBytes')),
625 'larger'=>array(
'label'=>
'LargerThan',
'data-placeholder'=>$langs->trans(
'NumberOfBytes')),
627 'withtrackingid'=>array(
'label'=>
'WithDolTrackingID',
'data-noparam'=>1),
628 'withouttrackingid'=>array(
'label'=>
'WithoutDolTrackingID',
'data-noparam'=>1),
629 'withtrackingidinmsgid'=>array(
'label'=>
'WithDolTrackingIDInMsgId',
'data-noparam'=>1),
630 'withouttrackingidinmsgid'=>array(
'label'=>
'WithoutDolTrackingIDInMsgId',
'data-noparam'=>1),
632 'isnotanswer'=>array(
'label'=>
'IsNotAnAnswer',
'data-noparam'=>1),
633 'isanswer'=>array(
'label'=>
'IsAnAnswer',
'data-noparam'=>1)
635 print
$form->selectarray(
'filtertype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'maxwidth300', 1,
'', 2);
639 print
'jQuery("#filtertype").change(function() {
640 console.log("We change a filter");
641 if (jQuery("#filtertype option:selected").attr("data-noparam")) {
642 jQuery("#rulevalue").attr("placeholder", "");
643 jQuery("#rulevalue").text(""); jQuery("#rulevalue").prop("disabled", true);
645 else { jQuery("#rulevalue").prop("disabled", false); }
646 jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder")));
654 print
'</script>'.
"\n";
657 print
'<input type="text" name="rulevalue" id="rulevalue">';
659 print
'<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button small" value="'.$langs->trans(
"Add").
'"></td>';
662 foreach ($object->filters as $rulefilter) {
664 $rulefilterobj->fetch($rulefilter[
'id']);
666 print
'<tr class="oddeven">';
667 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Filter").
': '.$rulefilter[
'type']).
'">';
668 print $langs->trans($arrayoftypes[$rulefilter[
'type']][
'label']);
670 print
'<td>'.$rulefilter[
'rulevalue'].
'</td>';
671 print
'<td class="right">';
672 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deletefilter&token='.urlencode(
newToken()).
'&filterid='.$rulefilter[
'id'].
'">'.
img_delete().
'</a>';
681 print
'<div class="clearboth"></div><br>';
684 print
'<div class="div-table-responsive">';
685 print
'<table id="tablelines" class="noborder margintable noshadow">';
686 print
'<tr class="liste_titre nodrag nodrop">';
687 print
'<td>'.img_picto(
'',
'technic',
'class="pictofixedwidth"').$form->textwithpicto($langs->trans(
"EmailcollectorOperations"), $langs->trans(
"EmailcollectorOperationsDesc")).
'</td><td></td><td></td><td></td>';
690 $arrayoftypes = array(
691 'loadthirdparty' => $langs->trans(
'LoadThirdPartyFromName', $langs->transnoentities(
"ThirdPartyName")),
692 'loadandcreatethirdparty' => $langs->trans(
'LoadThirdPartyFromNameOrCreate', $langs->transnoentities(
"ThirdPartyName")),
693 'recordjoinpiece' =>
'AttachJoinedDocumentsToObject',
694 'recordevent' =>
'RecordEvent'
696 $arrayoftypesnocondition = $arrayoftypes;
698 $arrayoftypes[
'project'] =
'CreateLeadAndThirdParty';
700 $arrayoftypesnocondition[
'project'] =
'CreateLeadAndThirdParty';
702 $arrayoftypes[
'ticket'] =
'CreateTicketAndThirdParty';
704 $arrayoftypesnocondition[
'ticket'] =
'CreateTicketAndThirdParty';
706 $arrayoftypes[
'candidature'] =
'CreateCandidature';
708 $arrayoftypesnocondition[
'candidature'] =
'CreateCandidature';
711 $parameters = array(
'arrayoftypes' => $arrayoftypes);
712 $res = $hookmanager->executeHooks(
'addMoreActionsEmailCollector', $parameters, $object, $action);
715 $arrayoftypes = $hookmanager->resArray;
717 foreach ($hookmanager->resArray as $k => $desc) {
718 $arrayoftypes[$k] = $desc;
723 print
'<tr class="oddeven nodrag nodrop">';
725 print
$form->selectarray(
'operationtype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'minwidth150 maxwidth300', 1);
728 $htmltext = $langs->transnoentitiesnoconv(
"OperationParamDesc");
729 print
$form->textwithpicto(
'<input type="text" name="operationparam">', $htmltext, 1,
'help',
'', 0, 2,
'operationparamtt');
733 print
'<td class="right"><input type="submit" name="addoperation" id="addoperation" class="flat button small" value="'.$langs->trans(
"Add").
'"></td>';
736 $nboflines = count($object->actions);
737 $table_element_line =
'emailcollector_emailcollectoraction';
738 $fk_element =
'position';
740 foreach ($object->actions as $ruleaction) {
741 $ruleactionobj =
new EmailcollectorAction($db);
742 $ruleactionobj->fetch($ruleaction[
'id']);
744 print
'<tr class="drag drop oddeven" id="row-'.$ruleaction[
'id'].
'">';
745 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Operation").
': '.$ruleaction[
'type']).
'">';
746 print
'<!-- type of action: '.$ruleaction[
'type'].
' -->';
747 if (array_key_exists($ruleaction[
'type'], $arrayoftypes)) {
748 print $langs->trans($arrayoftypes[$ruleaction[
'type']]);
750 if (array_key_exists($ruleaction[
'type'], $arrayoftypesnocondition)) {
751 print
'<span class="opacitymedium">'.$langs->trans($arrayoftypesnocondition[$ruleaction[
'type']]).
' - '.$langs->trans(
"Disabled").
'</span>';
755 if (in_array($ruleaction[
'type'], array(
'recordevent'))) {
756 print
$form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'IfTrackingIDFoundEventWillBeLinked'));
757 } elseif (in_array($ruleaction[
'type'], array(
'loadthirdparty',
'loadandcreatethirdparty'))) {
758 print
$form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'EmailCollectorLoadThirdPartyHelp'));
761 print
'<td class="wordbreak minwidth300 small">';
762 if ($action ==
'editoperation' && $ruleaction[
'id'] == $operationid) {
763 print
'<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.dol_escape_htmltag($ruleaction[
'actionparam']).
'"><br>';
764 print
'<input type="hidden" name="rowidoperation2" value="'.$ruleaction[
'id'].
'">';
765 print
'<input type="submit" class="button small button-save" name="saveoperation2" value="'.$langs->trans(
"Save").
'">';
766 print
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
772 print
'<td class="center linecolmove tdlineupdown">';
774 print
'<a class="lineupdown" href="'.$_SERVER[
'PHP_SELF'].
'?action=up&rowid='.$ruleaction[
'id'].
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
776 if ($i < count($object->actions) - 1) {
777 print
'<a class="lineupdown" href="'.$_SERVER[
'PHP_SELF'].
'?action=down&rowid='.$ruleaction[
'id'].
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
781 print
'<td class="right nowraponall">';
782 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editoperation&token='.
newToken().
'&operationid='.$ruleaction[
'id'].
'">'.
img_edit().
'</a>';
783 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteoperation&token='.
newToken().
'&operationid='.$ruleaction[
'id'].
'">'.
img_delete().
'</a>';
793 if (!empty($conf->use_javascript_ajax)) {
794 $urltorefreshaftermove = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.$id;
795 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
804 print
'<div class="clearboth"></div><br>';
809 if ($action !=
'presend' && $action !=
'editline') {
810 print
'<div class="tabsAction">'.
"\n";
811 $parameters = array();
812 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
817 if (empty($reshook)) {
819 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Edit").
'</a></div>';
822 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=clone&token='.
newToken().
'&object=order">'.$langs->trans(
"ToClone").
'</a></div>';
825 print
'<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=collecttest&token='.
newToken().
'">'.$langs->trans(
"TestCollectNow").
'</a></div>';
827 if (count($object->actions) > 0) {
828 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=collect&token='.
newToken().
'">'.$langs->trans(
"CollectNow").
'</a></div>';
830 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoOperations")).
'">'.$langs->trans(
"CollectNow").
'</a></div>';
833 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.urlencode(
newToken()).
'">'.$langs->trans(
'Delete').
'</a></div>';
838 if (!empty($debuginfo)) {