eventdetails_card.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2023 Deák Ferenc
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file eventdetails_card.php
  20. * \ingroup eventwizard
  21. * \brief Page to create/edit/view eventdetails
  22. */
  23. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
  24. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
  25. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
  26. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
  27. //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
  28. //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
  29. //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token).
  30. //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
  31. //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
  32. //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
  33. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
  34. //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
  35. //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
  36. //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  37. //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
  38. //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
  39. //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
  40. //if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
  41. //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
  42. //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
  43. //if (! defined('NOSESSION')) define('NOSESSION', '1'); // Disable session
  44. // Load Dolibarr environment
  45. $res = 0;
  46. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  47. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  48. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
  49. }
  50. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  51. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
  52. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  53. $i--; $j--;
  54. }
  55. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
  56. $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
  57. }
  58. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
  59. $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
  60. }
  61. // Try main.inc.php using relative path
  62. if (!$res && file_exists("../main.inc.php")) {
  63. $res = @include "../main.inc.php";
  64. }
  65. if (!$res && file_exists("../../main.inc.php")) {
  66. $res = @include "../../main.inc.php";
  67. }
  68. if (!$res && file_exists("../../../main.inc.php")) {
  69. $res = @include "../../../main.inc.php";
  70. }
  71. if (!$res) {
  72. die("Include of main fails");
  73. }
  74. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  75. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  76. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  77. dol_include_once('/eventwizard/class/eventdetails.class.php');
  78. dol_include_once('/eventwizard/lib/eventwizard_eventdetails.lib.php');
  79. // Load translation files required by the page
  80. $langs->loadLangs(array("eventwizard@eventwizard", "other"));
  81. // Get parameters
  82. $id = GETPOST('id', 'int');
  83. $ref = GETPOST('ref', 'alpha');
  84. $lineid = GETPOST('lineid', 'int');
  85. $action = GETPOST('action', 'aZ09');
  86. $confirm = GETPOST('confirm', 'alpha');
  87. $cancel = GETPOST('cancel', 'aZ09');
  88. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  89. $backtopage = GETPOST('backtopage', 'alpha');
  90. $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
  91. $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
  92. // Initialize technical objects
  93. $object = new EventDetails($db);
  94. $extrafields = new ExtraFields($db);
  95. $diroutputmassaction = $conf->eventwizard->dir_output.'/temp/massgeneration/'.$user->id;
  96. $hookmanager->initHooks(array('eventdetailscard', 'globalcard')); // Note that conf->hooks_modules contains array
  97. // Fetch optionals attributes and labels
  98. $extrafields->fetch_name_optionals_label($object->table_element);
  99. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  100. // Initialize array of search criterias
  101. $search_all = GETPOST("search_all", 'alpha');
  102. $search = array();
  103. foreach ($object->fields as $key => $val) {
  104. if (GETPOST('search_'.$key, 'alpha')) {
  105. $search[$key] = GETPOST('search_'.$key, 'alpha');
  106. }
  107. }
  108. if (empty($action) && empty($id) && empty($ref)) {
  109. $action = 'view';
  110. }
  111. if($action == 'generateEvents'){
  112. // print_r($_POST);
  113. $id = $_POST['id_eventdetails'];
  114. $object->fetch($id);
  115. // $object->fetch_optionals();
  116. // $object->getLinesArray();
  117. // echo json_encode($object);
  118. // print_r($object);
  119. header('Content-Type: application/json; charset=utf-8');
  120. $return = ["s"=>false];
  121. if($_POST['dates'] && (int)$_POST['id_eventdetails']){
  122. $return["s"] = $object->genEvents($_POST);
  123. }
  124. echo json_encode($return);
  125. exit;
  126. }
  127. // Load object
  128. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  129. // There is several ways to check permission.
  130. // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
  131. $enablepermissioncheck = 0;
  132. if ($enablepermissioncheck) {
  133. $permissiontoread = $user->rights->eventwizard->eventdetails->read;
  134. $permissiontoadd = $user->rights->eventwizard->eventdetails->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  135. $permissiontodelete = $user->rights->eventwizard->eventdetails->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  136. $permissionnote = $user->rights->eventwizard->eventdetails->write; // Used by the include of actions_setnotes.inc.php
  137. $permissiondellink = $user->rights->eventwizard->eventdetails->write; // Used by the include of actions_dellink.inc.php
  138. } else {
  139. $permissiontoread = 1;
  140. $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  141. $permissiontodelete = 1;
  142. $permissionnote = 1;
  143. $permissiondellink = 1;
  144. }
  145. $upload_dir = $conf->eventwizard->multidir_output[isset($object->entity) ? $object->entity : 1].'/eventdetails';
  146. // Security check (enable the most restrictive one)
  147. //if ($user->socid > 0) accessforbidden();
  148. //if ($user->socid > 0) $socid = $user->socid;
  149. //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  150. //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
  151. if (empty($conf->eventwizard->enabled)) accessforbidden();
  152. if (!$permissiontoread) accessforbidden();
  153. /*
  154. * Actions
  155. */
  156. $parameters = array();
  157. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  158. if ($reshook < 0) {
  159. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  160. }
  161. if (empty($reshook)) {
  162. $error = 0;
  163. $backurlforlist = dol_buildpath('/eventwizard/eventdetails_list.php', 1);
  164. if (empty($backtopage) || ($cancel && empty($id))) {
  165. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  166. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  167. $backtopage = $backurlforlist;
  168. } else {
  169. $backtopage = dol_buildpath('/eventwizard/eventdetails_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
  170. }
  171. }
  172. }
  173. $triggermodname = 'EVENTWIZARD_EVENTDETAILS_MODIFY'; // Name of trigger action code to execute when we modify record
  174. // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
  175. include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
  176. // Actions when linking object each other
  177. include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
  178. // Actions when printing a doc from card
  179. include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
  180. // Action to move up and down lines of object
  181. //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
  182. // Action to build doc
  183. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  184. if ($action == 'set_thirdparty' && $permissiontoadd) {
  185. $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
  186. }
  187. if ($action == 'classin' && $permissiontoadd) {
  188. $object->setProject(GETPOST('projectid', 'int'));
  189. }
  190. // Actions to send emails
  191. $triggersendname = 'EVENTWIZARD_EVENTDETAILS_SENTBYMAIL';
  192. $autocopy = 'MAIN_MAIL_AUTOCOPY_EVENTDETAILS_TO';
  193. $trackid = 'eventdetails'.$object->id;
  194. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  195. }
  196. /*
  197. * View
  198. *
  199. * Put here all code to build page
  200. */
  201. $form = new Form($db);
  202. $formfile = new FormFile($db);
  203. $formproject = new FormProjets($db);
  204. $title = $langs->trans("EventDetails");
  205. $help_url = '';
  206. llxHeader('', $title, $help_url);
  207. // Example : Adding jquery code
  208. // print '<script type="text/javascript">
  209. // jQuery(document).ready(function() {
  210. // function init_myfunc()
  211. // {
  212. // jQuery("#myid").removeAttr(\'disabled\');
  213. // jQuery("#myid").attr(\'disabled\',\'disabled\');
  214. // }
  215. // init_myfunc();
  216. // jQuery("#mybutton").click(function() {
  217. // init_myfunc();
  218. // });
  219. // });
  220. // </script>';
  221. // Part to create
  222. if ($action == 'create') {
  223. if (empty($permissiontoadd)) {
  224. accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
  225. exit;
  226. }
  227. print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("EventDetails")), '', 'object_'.$object->picto);
  228. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  229. print '<input type="hidden" name="token" value="'.newToken().'">';
  230. print '<input type="hidden" name="action" value="add">';
  231. if ($backtopage) {
  232. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  233. }
  234. if ($backtopageforcancel) {
  235. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  236. }
  237. print dol_get_fiche_head(array(), '');
  238. // Set some default values
  239. //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
  240. print '<table class="border centpercent tableforfieldcreate">'."\n";
  241. // Common attributes
  242. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
  243. // Other attributes
  244. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
  245. print '</table>'."\n";
  246. print dol_get_fiche_end();
  247. print $form->buttonsSaveCancel("Create");
  248. print '</form>';
  249. //dol_set_focus('input[name="ref"]');
  250. }
  251. // Part to edit record
  252. if (($id || $ref) && $action == 'edit') {
  253. print load_fiche_titre($langs->trans("EventDetails"), '', 'object_'.$object->picto);
  254. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  255. print '<input type="hidden" name="token" value="'.newToken().'">';
  256. print '<input type="hidden" name="action" value="update">';
  257. print '<input type="hidden" name="id" value="'.$object->id.'">';
  258. if ($backtopage) {
  259. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  260. }
  261. if ($backtopageforcancel) {
  262. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  263. }
  264. print dol_get_fiche_head();
  265. print '<table class="border centpercent tableforfieldedit">'."\n";
  266. // Common attributes
  267. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
  268. // Other attributes
  269. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
  270. print '</table>';
  271. print dol_get_fiche_end();
  272. print $form->buttonsSaveCancel();
  273. print '</form>';
  274. }
  275. // Part to show record
  276. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
  277. $res = $object->fetch_optionals();
  278. $head = eventdetailsPrepareHead($object);
  279. $head[]=['/custom/eventwizard/eventproduct_list.php?fk_eventdetails='.$object->id,'EventProducts','eventproduct'];
  280. print dol_get_fiche_head($head, 'card', $langs->trans("EventDetails"), -1, $object->picto);
  281. $formconfirm = '';
  282. // Confirmation to delete
  283. if ($action == 'delete') {
  284. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEventDetails'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
  285. }
  286. // Confirmation to delete line
  287. if ($action == 'deleteline') {
  288. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
  289. }
  290. // Clone confirmation
  291. if ($action == 'clone') {
  292. // Create an array for form
  293. $formquestion = array();
  294. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
  295. }
  296. // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
  297. if ($action == 'xxx') {
  298. $text = $langs->trans('ConfirmActionEventDetails', $object->ref);
  299. /*if (! empty($conf->notification->enabled))
  300. {
  301. require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
  302. $notify = new Notify($db);
  303. $text .= '<br>';
  304. $text .= $notify->confirmMessage('EVENTDETAILS_CLOSE', $object->socid, $object);
  305. }*/
  306. $formquestion = array();
  307. /*
  308. $forcecombo=0;
  309. if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
  310. $formquestion = array(
  311. // 'text' => $langs->trans("ConfirmClone"),
  312. // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
  313. // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
  314. // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
  315. );
  316. */
  317. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
  318. }
  319. // Call Hook formConfirm
  320. $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
  321. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  322. if (empty($reshook)) {
  323. $formconfirm .= $hookmanager->resPrint;
  324. } elseif ($reshook > 0) {
  325. $formconfirm = $hookmanager->resPrint;
  326. }
  327. // Print form confirm
  328. print $formconfirm;
  329. // Object card
  330. // ------------------------------------------------------------
  331. $linkback = '<a href="'.dol_buildpath('/eventwizard/eventdetails_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  332. $morehtmlref = '<div class="refidno">';
  333. /*
  334. // Ref customer
  335. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  336. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  337. // Thirdparty
  338. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
  339. // Project
  340. if (! empty($conf->project->enabled)) {
  341. $langs->load("projects");
  342. $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
  343. if ($permissiontoadd) {
  344. //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
  345. $morehtmlref .= ' : ';
  346. if ($action == 'classify') {
  347. //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  348. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  349. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  350. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  351. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  352. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  353. $morehtmlref .= '</form>';
  354. } else {
  355. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  356. }
  357. } else {
  358. if (! empty($object->fk_project)) {
  359. $proj = new Project($db);
  360. $proj->fetch($object->fk_project);
  361. $morehtmlref .= ': '.$proj->getNomUrl();
  362. } else {
  363. $morehtmlref .= '';
  364. }
  365. }
  366. }*/
  367. $morehtmlref.=$object->ref;
  368. $morehtmlref .= '</div>';
  369. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'label', $morehtmlref);
  370. print '<div class="fichecenter">';
  371. print '<div class="fichehalfleft">';
  372. print '<div class="underbanner clearboth"></div>';
  373. print '<table class="border centpercent tableforfield">'."\n";
  374. // Common attributes
  375. //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
  376. //unset($object->fields['fk_project']); // Hide field already shown in banner
  377. //unset($object->fields['fk_soc']); // Hide field already shown in banner
  378. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
  379. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  380. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  381. print '</table>';
  382. print '</div>';
  383. print '</div>';
  384. print '<div class="clearboth"></div>';
  385. print dol_get_fiche_end();
  386. /*
  387. * Lines
  388. */
  389. if (!empty($object->table_element_line)) {
  390. // Show object lines
  391. $result = $object->getLinesArray();
  392. print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
  393. <input type="hidden" name="token" value="' . newToken().'">
  394. <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
  395. <input type="hidden" name="mode" value="">
  396. <input type="hidden" name="page_y" value="">
  397. <input type="hidden" name="id" value="' . $object->id.'">
  398. ';
  399. if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
  400. include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
  401. }
  402. print '<div class="div-table-responsive-no-min">';
  403. if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
  404. print '<table id="tablelines" class="noborder noshadow" width="100%">';
  405. }
  406. if (!empty($object->lines)) {
  407. $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
  408. }
  409. // Form to add new line
  410. if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
  411. if ($action != 'editline') {
  412. // Add products/services form
  413. $parameters = array();
  414. $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  415. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  416. if (empty($reshook))
  417. $object->formAddObjectLine(1, $mysoc, $soc);
  418. }
  419. }
  420. if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
  421. print '</table>';
  422. }
  423. print '</div>';
  424. print "</form>\n";
  425. }
  426. // Buttons for actions
  427. if ($action != 'presend' && $action != 'editline') {
  428. print '<div class="tabsAction">'."\n";
  429. $parameters = array();
  430. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  431. if ($reshook < 0) {
  432. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  433. }
  434. if (empty($reshook)) {
  435. // Send
  436. if (empty($user->socid)) {
  437. // print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
  438. }
  439. // Back to draft
  440. if ($object->status == $object::STATUS_VALIDATED) {
  441. print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
  442. }
  443. print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
  444. // Validate
  445. if ($object->status == $object::STATUS_DRAFT) {
  446. if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
  447. print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
  448. } else {
  449. $langs->load("errors");
  450. print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
  451. }
  452. }
  453. // Clone
  454. print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd);
  455. /*
  456. if ($permissiontoadd) {
  457. if ($object->status == $object::STATUS_ENABLED) {
  458. print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
  459. } else {
  460. print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
  461. }
  462. }
  463. if ($permissiontoadd) {
  464. if ($object->status == $object::STATUS_VALIDATED) {
  465. print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
  466. } else {
  467. print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
  468. }
  469. }
  470. */
  471. // Delete (need delete permission, or if draft, just need create/modify permission)
  472. print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
  473. }
  474. print '</div>'."\n";
  475. }
  476. // Select mail models is same action as presend
  477. if (GETPOST('modelselected')) {
  478. $action = 'presend';
  479. }
  480. if ($action != 'presend') {
  481. print '<div class="fichecenter">
  482. <div>';
  483. print' <table class="centpercent notopnoleftnoright table-fiche-title showlinkedobjectblock">
  484. <tbody>
  485. <tr class="titre">
  486. <td class="nobordernopadding valignmiddle col-title">
  487. <div class="titre inline-block">'.$langs->trans('GenerateEvents').'</div>
  488. </td>
  489. </tr>
  490. </tbody>
  491. </table>';
  492. print'<table class="border centpercent tableforfield">
  493. <tbody>
  494. <tr class="field_label">
  495. <td class="titlefield fieldname_label"><span style="padding: 0px; padding-right: 3px !important;">'.$langs->trans('DateRange').'</span><span class="classfortooltip" style="padding: 0px; padding: 0px; padding-right: 3px !important;" title="' . $langs->trans('DateRangeHelp') . '"><span class="fas fa-info-circle em088 opacityhigh" style=" vertical-align: middle; cursor: help"></span></span></td>
  496. <td style="padding-left:35px;" class="valuefield fieldname_label wordbreak"><input type="text" id="date-range"><i class="fa fa-calendar" style="margin-left: -15px;"></i></td>
  497. </tr>';
  498. for($i=1;$i<=7;$i++){
  499. $key = $i%7;
  500. print '<tr class=""><td class="titlefield">'.$langs->trans('Day'.$key).'</td><td class="dayTime" style="height: 20px;"><input type="checkbox" id="Day'.$key.'" style="float:left; margin:15px;">
  501. <span class="timeSelectBox">'.
  502. // '<span class="time_slider" style="display:inline-block;width:150px;"></span><br/>'.
  503. '<span class="time_slider_details" >' . $langs->trans('StartTime') . ': '.
  504. '<input type="time" pattern="[0-9]+:[0-9]{2}$" placeholder="hh:mm" name="Day'.$key.'-timestart[]" info="0" class="timestart timepicker">'.
  505. '<br/> ' . $langs->trans('Duration') . ': '.
  506. '<input name="Day'.$key.'-time-duration[]" type="text" class="durationtime" pattern="^[0-9]{2}+:[0-9]{2}$" placeholder="hh:mm" style="width:45px !important;"/>'.
  507. '<input type="time" name="Day'.$key.'-timeend[]"class="timeend hide" info="0"/>'.
  508. '</span>'.
  509. '</span>'.
  510. '</td>
  511. <td>
  512. <span style="cursor:pointer;" class="fa fa-plus-circle valignmiddle btnTitle-icon addTime" info="'.$key.'" title="'.$langs->trans('További időpontok').'"></span>
  513. <span style="cursor:pointer;" class="fa fa-minus-circle valignmiddle btnTitle-icon delTime" info="'.$key.'" title="'.$langs->trans('Kevesebb időpont').'"></span>
  514. </td></tr>';
  515. }
  516. print '
  517. </tbody>
  518. </table>
  519. <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
  520. <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
  521. <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
  522. <style>
  523. td.in-range:not(.end-date){background-color: #c8e4f1 !important;}
  524. .hide{display:none;}
  525. .timeSelectBox{
  526. display:inline-block;width:150px;margin: 0 10px 0 0;vertical-align: top;border: 1px silver solid;padding: 5px 10px;
  527. }
  528. input#date-range{
  529. padding: 0 10px;
  530. }
  531. .time_slider{
  532. display:none !important;
  533. height: 0px !important;
  534. }
  535. </style>
  536. <script>
  537. var gen = {
  538. setElem: "ok",
  539. init: function(){
  540. var now = new Date;
  541. $("#date-range").attr("date-start",now.toISOString().slice(0, 10));
  542. $("#date-range").attr("date-end", now.toISOString().slice(0, 10));
  543. $(document).on("click","#eventGen",function(){
  544. var elem = $(this);
  545. var sendAjax = false;
  546. var data = {
  547. action: "generateEvents",
  548. id_eventdetails: '.$object->id.',
  549. token: "'.newToken().'",
  550. // id_eventdetails: $("#addproduct input[name=\'id\').val(),
  551. dates: {},
  552. max_num: (!Number.isNaN(parseInt($("#max_num").val())))? parseInt($("#max_num").val()): 0,
  553. buffer: (!Number.isNaN(parseInt($("#buffer").val())))? parseInt($("#buffer").val()): 0,
  554. participants: (!Number.isNaN(parseInt($("#participants").val())))? parseInt($("#participants").val()): 0,
  555. };
  556. var from = new Date($("#date-range").attr("date-start"));
  557. var to = new Date($("#date-range").attr("date-end"));
  558. var d = from;
  559. while (d <= to) {
  560. // console.log(DAYS[d.getDay()]);
  561. dayNum = d.getDay();
  562. // console.log(d.getDay());
  563. if($("#Day"+dayNum).is(":checked")){
  564. data.dates[d.toISOString().split("T")[0]] = [];
  565. $.each($("input[name=\'Day"+dayNum+"-timestart[]\']"),function(k,v){
  566. if($(v).val() && $("input[name=\'Day"+dayNum+"-time-duration[]\']").eq(k).val()){
  567. timeRange = {
  568. start: $("input[name=\'Day"+dayNum+"-timestart[]\']").eq(k).val(),
  569. // end: $("input[name=\'Day"+dayNum+"-timeend[]\']").eq(k).val(),
  570. duration: $("input[name=\'Day"+dayNum+"-time-duration[]\']").eq(k).val(),
  571. };
  572. data.dates[d.toISOString().split("T")[0]].push(timeRange);
  573. sendAjax = true;
  574. }
  575. });
  576. }
  577. d = new Date(d.getTime() + (24 * 60 * 60 * 1000));
  578. }
  579. if(sendAjax){
  580. $.ajax({
  581. type: "POST",
  582. url: "/custom/eventwizard/eventdetails_card.php",
  583. data: data,
  584. success: function(response) {
  585. if(response.s){
  586. location.href=$("#agenda").attr("href");
  587. }
  588. },
  589. error: function(response){
  590. }
  591. });
  592. }
  593. });
  594. $(document).on("input",".timestart",function(event ){
  595. if(gen.setElem=="ok"){
  596. gen.setElem="input";
  597. var elem = $(this);
  598. var a = (elem.val()).split(":");
  599. var b = (elem.parent().find(".durationtime").val()).split(":");
  600. var time = new Date();
  601. time.setHours(parseInt(a[0]), parseInt(a[1]), 00, 000);
  602. time.setMinutes(time.getMinutes()+parseInt(b[1]));
  603. time.setHours(time.getHours()+parseInt(b[0]));
  604. // var c = [time.getHours(), time.getMinutes()];
  605. elem.parent().find(".timeend").val(time.getHours()+":"+time.getMinutes())
  606. var minutes = [parseInt(a[0]) * 60 + parseInt(a[1]), parseInt(b[0]) * 60 + parseInt(b[1])];
  607. if(isNaN(minutes[0])){minutes[0]=0;}
  608. if(isNaN(minutes[1])){minutes[1]=0;}
  609. elem.parent().parent().find(".time_slider").slider("values",0,minutes[0]);
  610. elem.parent().parent().find(".time_slider").slider("values",1,minutes[0]+minutes[1]);
  611. elem.parent().find(".timestart").attr("info",minutes[0]);
  612. elem.parent().find(".timeend").attr("info",minutes[0]+minutes[1]);
  613. // elem.parent().find(".durationtime").attr("info",minutes[1]);
  614. gen.setElem="ok";
  615. }
  616. });
  617. $(document).on("input",".durationtime",function(event ){
  618. if(gen.setElem=="ok"){
  619. gen.setElem="input";
  620. var elem = $(this);
  621. var a = (elem.parent().find(".timestart").val()).split(":");
  622. var b = (elem.val()).split(":");
  623. var time = new Date();
  624. time.setHours(parseInt(a[0]), parseInt(a[1]), 00, 000);
  625. time.setMinutes(time.getMinutes()+parseInt(b[1]));
  626. time.setHours(time.getHours()+parseInt(b[0]));
  627. // var c = [time.getHours(), time.getMinutes()];
  628. elem.parent().find(".timeend").val(time.getHours()+":"+time.getMinutes())
  629. var minutes = [parseInt(a[0]) * 60 + parseInt(a[1]), parseInt(b[0]) * 60 + parseInt(b[1])];
  630. if(isNaN(minutes[0])){minutes[0]=0;}
  631. if(isNaN(minutes[1])){minutes[1]=0;}
  632. // console.log(minutes);
  633. elem.parent().parent().find(".time_slider").slider("values",0,minutes[0]);
  634. elem.parent().parent().find(".time_slider").slider("values",1,minutes[0]+minutes[1]);
  635. elem.parent().find(".timestart").attr("info",minutes[0]);
  636. elem.parent().find(".timeend").attr("info",minutes[0]+minutes[1]);
  637. // elem.parent().find(".durationtime").attr("info",minutes[1]);
  638. gen.setElem="ok";
  639. }
  640. });
  641. $(document).on("click",".addTime",function(){
  642. var elem = $(this);
  643. // var html = \'<span class="addedTimes"> & <input type="time" name="Day\'+elem.attr("info")+\'-timestart[]"> - <input type="time" name="Day\'+elem.attr("info")+\'-timeend[]">ASD</span>\';
  644. var html = \'<span class="addedTimes timeSelectBox"><span class="time_slider" style="display:inline-block;width:150px;"></span><span class="time_slider_details">'.$langs->trans('StartTime').':<input type="time" name="Day\'+elem.attr("info")+\'-timestart[]" info="0" class="timepicker timestart"><br/> '.$langs->trans('Duration').': <input name="Day\'+elem.attr("info")+\'-time-duration[]" pattern="[0-9]+:[0-9]{2}$" placeholder="hh:mm" type="text" class="durationtime" style="width:45px !important"/><input name="Day\'+elem.attr("info")+\'-timeend[]" class="timeend hide" info="0"/></span></span>\';
  645. elem.parent().parent().find("td.dayTime").append(html);
  646. $(function(){
  647. // gen.setTimeRange(".time_slider");
  648. });
  649. });
  650. $(document).on("click",".delTime",function(){
  651. var elem = $(this);
  652. $(elem.parent().parent().find(\'td.dayTime span.addedTimes\').last()).remove();
  653. // var listTimeStart = elem.parent().parent().find(\'td.dayTime input[name="Day\'+elem.attr("info")+\'-timestart[]"]\');
  654. // var listTimeEnd = elem.parent().parent().find(\'td.dayTime input[name="Day\'+elem.attr("info")+\'-timeend[]"]\');
  655. // if(listTimeStart.length > 1){
  656. // $(listTimeStart.last()).remove();
  657. // }
  658. // if(listTimeEnd.length > 1){
  659. // $(listTimeEnd.last()).remove();
  660. // }
  661. });
  662. var option = {
  663. //autoUpdateInput: false,
  664. locale: {
  665. "format": "'.$langs->trans('DateFormatYYYYMMDD').'",
  666. cancelLabel: "'.$langs->trans('Cancel').'",
  667. applyLabel: "'.$langs->trans('Ok').'",
  668. "monthNames": [
  669. "'.$langs->trans('Month01').'",
  670. "'.$langs->trans('Month02').'",
  671. "'.$langs->trans('Month03').'",
  672. "'.$langs->trans('Month04').'",
  673. "'.$langs->trans('Month05').'",
  674. "'.$langs->trans('Month06').'",
  675. "'.$langs->trans('Month07').'",
  676. "'.$langs->trans('Month08').'",
  677. "'.$langs->trans('Month09').'",
  678. "'.$langs->trans('Month10').'",
  679. "'.$langs->trans('Month11').'",
  680. "'.$langs->trans('Month12').'"
  681. ],
  682. "daysOfWeek": [
  683. "'.$langs->trans('SundayMin').'",
  684. "'.$langs->trans('MondayMin').'",
  685. "'.$langs->trans('TuesdayMin').'",
  686. "'.$langs->trans('WednesdayMin').'",
  687. "'.$langs->trans('ThursdayMin').'",
  688. "'.$langs->trans('FridayMin').'",
  689. "'.$langs->trans('SaturdayMin').'"
  690. ],
  691. }
  692. };
  693. $("#date-range").daterangepicker(option, function(start, end, label) {
  694. $("#date-range").attr("date-start",start.format("YYYY-MM-DD"));
  695. $("#date-range").attr("date-end", end.format("YYYY-MM-DD"));
  696. });
  697. // gen.setTimeRange(".time_slider");
  698. $(document).on("mousewheel",".time_slider", function(event) {
  699. event.preventDefault();
  700. var elem = $(this);
  701. value = elem.slider( "value" );
  702. //console.log(event.deltaX, event.deltaY, event.deltaFactor);
  703. //Mousewheel Scrolled up
  704. if(event.deltaY == -1){
  705. //alert("scrolled down");
  706. value = value+1;
  707. elem.slider("value", value);
  708. // $("#slider_val").html(value);
  709. }
  710. //Mousewheel Scrolled down
  711. else if(event.deltaY == 1){
  712. //alert("scrolled up");
  713. value = value-1;
  714. elem.slider( "value", value );
  715. // $("#slider_val").html(value);
  716. }
  717. });
  718. },
  719. setTimeRange: function(elem){
  720. //".time_slider"
  721. $(elem).slider({
  722. // width: 320px,
  723. // height: 2px,
  724. range: true,
  725. min: 0,
  726. max: 2880,
  727. step: 5,
  728. slide: function(e, ui) {
  729. if(gen.setElem=="ok"){
  730. gen.setElem="slider";
  731. var hours = Math.floor(ui.value / 60);
  732. var minutes = ui.value - (hours * 60);
  733. hours = hours%24;
  734. if(hours.toString().length == 1) hours = "0" + hours;
  735. if(minutes.toString().length == 1) minutes = "0" + minutes;
  736. // $("#something").html(hours+":"+minutes);
  737. if(ui.handleIndex==0){
  738. $(ui.handle).parent().parent().find(".timestart").val(hours+":"+minutes);
  739. $(ui.handle).parent().parent().find(".timestart").attr("info",ui.value);
  740. }
  741. if(ui.handleIndex==1){
  742. $(ui.handle).parent().parent().find(".timeend").val(hours+":"+minutes);
  743. $(ui.handle).parent().parent().find(".timeend").attr("info",ui.value);
  744. }
  745. var diff = parseInt($(ui.handle).parent().parent().find(".timeend").attr("info")) - parseInt($(ui.handle).parent().parent().find(".timestart").attr("info"));
  746. // console.log(parseInt($(ui.handle).parent().parent().find(".timestart").attr("info")));
  747. // console.log(parseInt($(ui.handle).parent().parent().find(".timeend").attr("info")));
  748. // console.log(diff);
  749. if(!isNaN(diff)){
  750. hours = Math.floor(diff / 60);
  751. minutes = diff - (hours * 60);
  752. // hours = hours%24;
  753. if(hours.toString().length == 1) hours = "0" + hours;
  754. if(minutes.toString().length == 1) minutes = "0" + minutes;
  755. $(ui.handle).parent().parent().find(".durationtime").val(hours+":"+minutes+"");
  756. // var start = $(ui.handle).parent().parent().find(".timepicker").val();
  757. // details = "Kezdés: "+start+"<br/>Időtartam: "+hours+"ó "+minutes+"p";
  758. }
  759. // $(ui.handle).parent().parent().find(".time_slider_details").html(details);
  760. // console.log(hours+":"+minutes);
  761. // console.log(ui);
  762. gen.setElem="ok";
  763. }
  764. }
  765. });
  766. },
  767. };
  768. $(function(){gen.init();});
  769. </script>
  770. ';
  771. //$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken()
  772. //!!!
  773. print '<br/><table class="border centpercent tableforfieldedit">
  774. <tbody>
  775. <tr class="field_ref" style="text-align: center;">
  776. <td class="titlefieldcreate fieldrequired">'.$langs->trans('max_num').': <input type="number" id="max_num"></td>
  777. <td class="titlefieldcreate fieldrequired">'.$langs->trans('buffer').': <input type="number" id="buffer"></td>
  778. <!--<td class="titlefieldcreate fieldrequired">'.$langs->trans('participants').': <input type="number" id="participants"></td>-->
  779. </tr>
  780. </tbody></table>';
  781. print '';
  782. print '<br/><button style="width:100%;margin: 0em;" class="butAction" id="eventGen">'.$langs->trans('GenerateEvents').'</button>';
  783. print ' </div>
  784. </div><hr/>';
  785. print '<div class="fichecenter"><div class="fichehalfleft">';
  786. print '<a name="builddoc"></a>'; // ancre
  787. $includedocgeneration = 0;
  788. // Documents
  789. if ($includedocgeneration) {
  790. $objref = dol_sanitizeFileName($object->ref);
  791. $relativepath = $objref.'/'.$objref.'.pdf';
  792. $filedir = $conf->eventwizard->dir_output.'/'.$object->element.'/'.$objref;
  793. $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
  794. $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
  795. $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
  796. print $formfile->showdocuments('eventwizard:EventDetails', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
  797. }
  798. // Show links to link elements
  799. $linktoelem = $form->showLinkToObjectBlock($object, null, array('eventdetails'));
  800. $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
  801. print '</div><div class="fichehalfright">';
  802. $MAXEVENT = 10;
  803. $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/eventwizard/eventdetails_agenda.php', 1).'?id='.$object->id);
  804. // List of actions on element
  805. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  806. $formactions = new FormActions($db);
  807. $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
  808. print '</div></div>';
  809. }
  810. //Select mail models is same action as presend
  811. if (GETPOST('modelselected')) {
  812. $action = 'presend';
  813. }
  814. // Presend form
  815. $modelmail = 'eventdetails';
  816. $defaulttopic = 'InformationMessage';
  817. $diroutput = $conf->eventwizard->dir_output;
  818. $trackid = 'eventdetails'.$object->id;
  819. include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
  820. }
  821. // End of page
  822. llxFooter();
  823. $db->close();