emailcollector_card.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <?php
  2. /* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/emailcollector_card.php
  19. * \ingroup emailcollector
  20. * \brief Page to create/edit/view emailcollector
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
  26. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  27. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  28. include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollector.class.php';
  29. include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectorfilter.class.php';
  30. include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php';
  31. include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
  32. if (!$user->admin)
  33. accessforbidden();
  34. // Load traductions files requiredby by page
  35. $langs->loadLangs(array("admin", "mails", "other"));
  36. // Get parameters
  37. $id = GETPOST('id', 'int');
  38. $ref = GETPOST('ref', 'alpha');
  39. $action = GETPOST('action', 'aZ09');
  40. $confirm = GETPOST('confirm', 'alpha');
  41. $cancel = GETPOST('cancel', 'aZ09');
  42. $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectcard'; // To manage different context of search
  43. $backtopage = GETPOST('backtopage', 'alpha');
  44. // Initialize technical objects
  45. $object = new EmailCollector($db);
  46. $extrafields = new ExtraFields($db);
  47. $diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration/' . $user->id;
  48. $hookmanager->initHooks(array('emailcollectorcard')); // Note that conf->hooks_modules contains array
  49. // Fetch optionals attributes and labels
  50. $extralabels = $extrafields->fetch_name_optionals_label('emailcollector');
  51. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  52. // Initialize array of search criterias
  53. $search_all = trim(GETPOST("search_all", 'alpha'));
  54. $search = array();
  55. foreach ($object->fields as $key => $val) {
  56. if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
  57. }
  58. if (empty($action) && empty($id) && empty($ref)) $action='view';
  59. // Load object
  60. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
  61. // Security check - Protection if external user
  62. //if ($user->societe_id > 0) access_forbidden();
  63. //if ($user->societe_id > 0) $socid = $user->societe_id;
  64. //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
  65. //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
  66. /*
  67. * Actions
  68. */
  69. $parameters = array();
  70. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  71. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  72. if (empty($reshook))
  73. {
  74. $error = 0;
  75. $permissiontoadd=1;
  76. $permissiontodelete=1;
  77. if (empty($backtopage)) $backtopage = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.($id > 0 ? $id : '__ID__');
  78. $backurlforlist = DOL_URL_ROOT.'/admin/emailcollector_list.php';
  79. // Actions cancel, add, update, delete or clone
  80. include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
  81. // Actions when linking object each other
  82. include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
  83. // Actions when printing a doc from card
  84. include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
  85. }
  86. if (GETPOST('addfilter','alpha'))
  87. {
  88. $emailcollectorfilter = new EmailCollectorFilter($db);
  89. $emailcollectorfilter->type = GETPOST('filtertype','az09');
  90. $emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha');
  91. $emailcollectorfilter->fk_emailcollector = $object->id;
  92. $emailcollectorfilter->status = 1;
  93. $result = $emailcollectorfilter->create($user);
  94. if ($result > 0)
  95. {
  96. $object->fetchFilters();
  97. }
  98. else
  99. {
  100. setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
  101. }
  102. }
  103. if ($action == 'deletefilter')
  104. {
  105. $emailcollectorfilter = new EmailCollectorFilter($db);
  106. $emailcollectorfilter->fetch(GETPOST('filterid','int'));
  107. $result = $emailcollectorfilter->delete($user);
  108. if ($result > 0)
  109. {
  110. $object->fetchFilters();
  111. }
  112. else
  113. {
  114. setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
  115. }
  116. }
  117. if (GETPOST('addoperation','alpha'))
  118. {
  119. $emailcollectoroperation = new EmailCollectorAction($db);
  120. $emailcollectoroperation->type = GETPOST('operationtype','az09');
  121. $emailcollectoroperation->actionparam = GETPOST('operationparam', 'none');
  122. $emailcollectoroperation->fk_emailcollector = $object->id;
  123. $emailcollectoroperation->status = 1;
  124. $emailcollectoroperation->position = 50;
  125. $result = $emailcollectoroperation->create($user);
  126. if ($result > 0)
  127. {
  128. $object->fetchActions();
  129. }
  130. else
  131. {
  132. setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
  133. }
  134. }
  135. if ($action == 'deleteoperation')
  136. {
  137. $emailcollectoroperation = new EmailCollectorAction($db);
  138. $emailcollectoroperation->fetch(GETPOST('operationid','int'));
  139. $result = $emailcollectoroperation->delete($user);
  140. if ($result > 0)
  141. {
  142. $object->fetchActions();
  143. }
  144. else
  145. {
  146. setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
  147. }
  148. }
  149. if ($action == 'confirm_collect')
  150. {
  151. dol_include_once('/emailcollector/class/emailcollector.class.php');
  152. $res = $object->doCollectOneCollector();
  153. if ($res > 0)
  154. {
  155. setEventMessages($object->output, null, 'mesgs');
  156. }
  157. else
  158. {
  159. setEventMessages($object->error, null, 'errors');
  160. }
  161. $action = '';
  162. }
  163. /*
  164. * View
  165. */
  166. $form = new Form($db);
  167. $formfile = new FormFile($db);
  168. llxHeader('', 'EmailCollector', '');
  169. // Example : Adding jquery code
  170. print '<script type="text/javascript" language="javascript">
  171. jQuery(document).ready(function() {
  172. function init_myfunc()
  173. {
  174. jQuery("#myid").removeAttr(\'disabled\');
  175. jQuery("#myid").attr(\'disabled\',\'disabled\');
  176. }
  177. init_myfunc();
  178. jQuery("#mybutton").click(function() {
  179. init_myfunc();
  180. });
  181. });
  182. </script>';
  183. // Part to create
  184. if ($action == 'create') {
  185. print load_fiche_titre($langs->trans("NewEmailCollector", $langs->transnoentitiesnoconv("EmailCollector")));
  186. print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
  187. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  188. print '<input type="hidden" name="action" value="add">';
  189. print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
  190. dol_fiche_head(array(), '');
  191. print '<table class="border centpercent">'."\n";
  192. //unset($fields[]);
  193. // Common attributes
  194. include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
  195. // Other attributes
  196. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
  197. print '</table>'."\n";
  198. dol_fiche_end();
  199. print '<div class="center">';
  200. print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
  201. print '&nbsp; ';
  202. print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
  203. print '</div>';
  204. print '</form>';
  205. }
  206. // Part to edit record
  207. if (($id || $ref) && $action == 'edit')
  208. {
  209. print load_fiche_titre($langs->trans("EmailCollector"));
  210. print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
  211. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  212. print '<input type="hidden" name="action" value="update">';
  213. print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
  214. print '<input type="hidden" name="id" value="' . $object->id . '">';
  215. dol_fiche_head();
  216. print '<table class="border centpercent">' . "\n";
  217. // Common attributes
  218. include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
  219. // Other attributes
  220. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
  221. print '</table>';
  222. dol_fiche_end();
  223. print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
  224. print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
  225. print '</div>';
  226. print '</form>';
  227. }
  228. // Part to show record
  229. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
  230. {
  231. $res = $object->fetch_optionals();
  232. $object->fetchFilters();
  233. $object->fetchActions();
  234. $head = emailcollectorPrepareHead($object);
  235. dol_fiche_head($head, 'card', $langs->trans("EmailCollector"), -1, 'emailcollector');
  236. $formconfirm = '';
  237. // Confirmation to delete
  238. if ($action == 'delete')
  239. {
  240. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1);
  241. }
  242. // Clone confirmation
  243. if ($action == 'clone') {
  244. // Create an array for form
  245. $formquestion = array();
  246. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneMyObject'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
  247. }
  248. // Confirmation of action process
  249. if ($action == 'collect') {
  250. $formquestion = array(
  251. 'text' => $langs->trans("EmailCollectorConfirmCollect"),
  252. );
  253. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('EmailCollectorConfirmCollectTitle'), $text, 'confirm_collect', $formquestion, 0, 1, 220);
  254. }
  255. // Call Hook formConfirm
  256. $parameters = array('lineid' => $lineid);
  257. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  258. if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
  259. elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
  260. // Print form confirm
  261. print $formconfirm;
  262. // Object card
  263. // ------------------------------------------------------------
  264. $linkback = '<a href="' . dol_buildpath('/admin/emailcollector_list.php', 1) . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
  265. $morehtmlref = '<div class="refidno">';
  266. /*
  267. // Ref bis
  268. $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->emailcollector->creer, 'string', '', 0, 1);
  269. $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->emailcollector->creer, 'string', '', null, null, '', 1);
  270. // Thirdparty
  271. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
  272. // Project
  273. if (! empty($conf->projet->enabled))
  274. {
  275. $langs->load("projects");
  276. $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
  277. if ($user->rights->emailcollector->creer)
  278. {
  279. if ($action != 'classify')
  280. {
  281. $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  282. if ($action == 'classify') {
  283. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  284. $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  285. $morehtmlref.='<input type="hidden" name="action" value="classin">';
  286. $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  287. $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  288. $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  289. $morehtmlref.='</form>';
  290. } else {
  291. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  292. }
  293. }
  294. } else {
  295. if (! empty($object->fk_project)) {
  296. $proj = new Project($db);
  297. $proj->fetch($object->fk_project);
  298. $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
  299. $morehtmlref.=$proj->ref;
  300. $morehtmlref.='</a>';
  301. } else {
  302. $morehtmlref.='';
  303. }
  304. }
  305. }
  306. */
  307. $morehtmlref .= '</div>';
  308. $morehtml = $langs->trans("NbOfEmailsInInbox").' : ';
  309. $sourcedir = $object->source_directory;
  310. $targetdir = ($object->target_directory ? $object->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag'
  311. $connection = null;
  312. $connectstringserver = '';
  313. $connectstringsource = '';
  314. $connectstringtarget = '';
  315. if (function_exists('imap_open'))
  316. {
  317. $connectstringserver = $object->getConnectStringIMAP();
  318. $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
  319. $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir);
  320. $connection = imap_open($connectstringsource, $object->user, $object->password);
  321. }
  322. else
  323. {
  324. $morehtml .= 'IMAP functions not available on your PHP';
  325. }
  326. if (! $connection)
  327. {
  328. $morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
  329. }
  330. else
  331. {
  332. //$morehtmlstatus .= imap_num_msg($connection).'</div><div class="statusref">';
  333. $morehtml .= imap_num_msg($connection);
  334. }
  335. if ($connection)
  336. {
  337. imap_close($connection);
  338. }
  339. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'<div class="refidno">'.$morehtml.'</div>', '', 0, '', '', 0, '');
  340. print '<div class="fichecenter">';
  341. print '<div class="fichehalfleft">';
  342. print '<div class="underbanner clearboth"></div>';
  343. print '<table class="border centpercent">'."\n";
  344. // Common attributes
  345. //$keyforbreak='fieldkeytoswithonsecondcolumn';
  346. include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
  347. // Other attributes
  348. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  349. print '</table>';
  350. print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
  351. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  352. print '<input type="hidden" name="action" value="updatefiltersactions">';
  353. print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
  354. print '<input type="hidden" name="id" value="' . $object->id . '">';
  355. // Filters
  356. print '<table class="border centpercent">';
  357. print '<tr class="liste_titre">';
  358. print '<td>'.$langs->trans("Filters").'</td><td></td><td></td>';
  359. print '</tr>';
  360. // Add filter
  361. print '<tr class="oddeven">';
  362. print '<td>';
  363. $arrayoftypes=array('from'=>'MailFrom', 'to'=>'MailTo', 'cc'=>'Cc', 'bcc'=>'Bcc', 'subject'=>'Subject', 'body'=>'Body', 'seen'=>'AlreadyRead', 'unseen'=>'NotRead', 'withtrackingid'=>'WithDolTrackingID', 'withouttrackingid'=>'WithoutDolTrackingID');
  364. print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1);
  365. print '</td><td>';
  366. print '<input type="text" name="rulevalue">';
  367. print '</td>';
  368. print '<td align="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>';
  369. print '</tr>';
  370. // List filters
  371. foreach($object->filters as $rulefilter)
  372. {
  373. $rulefilterobj=new EmailCollectorFilter($db);
  374. $rulefilterobj->fetch($rulefilter['id']);
  375. print '<tr class="oddeven">';
  376. print '<td>';
  377. print $langs->trans($arrayoftypes[$rulefilter['type']]);
  378. print '</td>';
  379. print '<td>'.$rulefilter['rulevalue'].'</td>';
  380. print '<td align="right">';
  381. //print $rulefilterobj->getLibStatut(3);
  382. print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deletefilter&filterid='.$rulefilter['id'].'">'.img_delete().'</a>';
  383. print '</td>';
  384. print '</tr>';
  385. }
  386. print '</tr>';
  387. print '</table>';
  388. print '<div class="clearboth"></div><br>';
  389. // Operations
  390. print '<table id="tablelines" class="noborder noshadow">';
  391. print '<tr class="liste_titre">';
  392. print '<td>'.$langs->trans("EmailcollectorOperations").'</td><td></td><td></td><td></td>';
  393. print '</tr>';
  394. // Add operation
  395. print '<tr class="oddeven">';
  396. print '<td>';
  397. $arrayoftypes=array('loadthirdparty'=>'LoadThirdPartyFromName', 'loadandcreatethirdparty'=>'LoadThirdPartyFromNameOrCreate', 'recordevent'=>'RecordEvent');
  398. if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty';
  399. print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1);
  400. print '</td><td>';
  401. print '<input type="text" name="operationparam">';
  402. $htmltext=$langs->transnoentitiesnoconv("OperationParamDesc");
  403. //var_dump($htmltext);
  404. print $form->textwithpicto('', $htmltext);
  405. print '</td>';
  406. print '<td></td>';
  407. print '<td align="right"><input type="submit" name="addoperation" id="addoperation" class="flat button" value="'.$langs->trans("Add").'"></td>';
  408. print '</tr>';
  409. // List operations
  410. $nboflines = count($object->actions);
  411. $table_element_line = 'emailcollector_emailcollectoraction';
  412. $fk_element='position';
  413. $i=0;
  414. foreach($object->actions as $ruleaction)
  415. {
  416. $ruleactionobj=new EmailcollectorAction($db);
  417. $ruleactionobj->fetch($ruleaction['id']);
  418. print '<tr class="drag drop oddeven" id="row-'.$ruleaction['id'].'">';
  419. print '<td>';
  420. print $langs->trans($arrayoftypes[$ruleaction['type']]);
  421. print '</td>';
  422. print '<td>'.$ruleaction['actionparam'].'</td>';
  423. print '<td align="right">';
  424. //print $ruleactionobj->getLibStatut(3);
  425. print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteoperation&operationid='.$ruleaction['id'].'">'.img_delete().'</a>';
  426. print '</td>';
  427. print '<td class="center linecolmove tdlineupdown">';
  428. if ($i > 0)
  429. {
  430. print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=up&amp;rowid='.$ruleaction['id'].'">'.img_up('default', 0, 'imgupforline').'</a>';
  431. }
  432. if ($i < count($object->actions)-1) {
  433. print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=down&amp;rowid='.$ruleaction['id'].'">'.img_down('default', 0, 'imgdownforline').'</a>';
  434. }
  435. print '</td>';
  436. print '</tr>';
  437. $i++;
  438. }
  439. print '</tr>';
  440. print '</table>';
  441. if (! empty($conf->use_javascript_ajax)) {
  442. include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
  443. }
  444. print '</form>';
  445. print '</div>';
  446. print '</div>'; // End <div class="fichecenter">
  447. print '<div class="clearboth"></div><br>';
  448. dol_fiche_end();
  449. // Buttons for actions
  450. if ($action != 'presend' && $action != 'editline') {
  451. print '<div class="tabsAction">' . "\n";
  452. $parameters = array();
  453. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  454. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  455. if (empty($reshook))
  456. {
  457. print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit">' . $langs->trans("Edit") . '</a>' . "\n";
  458. print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=collect">' . $langs->trans("CollectNow") . '</a>' . "\n";
  459. print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a>' . "\n";
  460. }
  461. print '</div>' . "\n";
  462. }
  463. // Select mail models is same action as presend
  464. if (GETPOST('modelselected')) {
  465. $action = 'presend';
  466. }
  467. /*
  468. if ($action != 'presend') {
  469. print '<div class="fichecenter"><div class="fichehalfleft">';
  470. print '<a name="builddoc"></a>'; // ancre
  471. */
  472. // Documents
  473. /*$objref = dol_sanitizeFileName($object->ref);
  474. $relativepath = $comref . '/' . $comref . '.pdf';
  475. $filedir = $conf->emailcollector->dir_output . '/' . $objref;
  476. $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
  477. $genallowed = $user->rights->emailcollector->read; // If you can read, you can build the PDF to read content
  478. $delallowed = $user->rights->emailcollector->create; // If you can create/edit, you can remove a file on card
  479. print $formfile->showdocuments('emailcollector', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
  480. */
  481. /*
  482. // Show links to link elements
  483. $linktoelem = $form->showLinkToObjectBlock($object, null, array('emailcollector'));
  484. $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
  485. print '</div><div class="fichehalfright"><div class="ficheaddleft">';
  486. $MAXEVENT = 10;
  487. $morehtmlright = '<a href="' . dol_buildpath('/emailcollector/emailcollector_info.php', 1) . '?id=' . $object->id . '">';
  488. $morehtmlright .= $langs->trans("SeeAll");
  489. $morehtmlright .= '</a>';
  490. // List of actions on element
  491. include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
  492. $formactions = new FormActions($db);
  493. $somethingshown = $formactions->showactions($object, 'emailcollector_emailcollector', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
  494. print '</div></div></div>';
  495. }
  496. */
  497. //Select mail models is same action as presend
  498. /*
  499. if (GETPOST('modelselected')) $action = 'presend';
  500. // Presend form
  501. $modelmail='inventory';
  502. $defaulttopic='InformationMessage';
  503. $diroutput = $conf->product->dir_output.'/inventory';
  504. $trackid = 'stockinv'.$object->id;
  505. include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
  506. */
  507. }
  508. // End of page
  509. llxFooter();
  510. $db->close();