voucherhistory_card.php 38 KB

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