45 print
"Error, template page ".basename(__FILE__).
" can't be called with no object defined.";
49@phan-var-force ?string $fk_element
50@phan-var-force ?Task[] $tasksarray
54<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on lines of a
table -->
57$redirectURL = empty($urltorefreshaftermove) ? ($_SERVER[
'PHP_SELF'].
'?'.
dol_escape_js($_SERVER[
'QUERY_STRING'])) : $urltorefreshaftermove;
59$redirectURL = preg_replace(
'/(&|\?)action=[^&#]*/',
'', $redirectURL);
60$redirectURL = preg_replace(
'/(&|\?)page_y=[^&#]*/',
'', $redirectURL);
62$nboflines = (isset(
$object->lines) ? count(
$object->lines) : (isset($tasksarray) ? count($tasksarray) : (empty($nboflines) ? 0 : $nboflines)));
67 'fkElement' => empty(
$object->fk_element) ? $fk_element :
$object->fk_element,
68 'tableElementLine' => (empty($table_element_line) ?
$object->table_element_line : $table_element_line),
69 'nbOfLines' => $nboflines,
72 'tagIdForTableDND' => (empty($tagidfortablednd) ?
'tablelines' : $tagidfortablednd),
73 'filePath' => (empty($filepath) ?
'' : $filepath),
74 'activeAjaxReorder' =>
GETPOST(
'action',
'aZ09') !=
'editline' && $nboflines > 1 &&
$conf->browser->layout !=
'phone',
75 'gripImg' => DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/grip.png',
76 'token' => currentToken(),
77 'DOL_URL_ROOT' => DOL_URL_ROOT,
78 'redirectURL' => $redirectURL
82<script nonce=
"<?php print getNonce(); ?>">
83Dolibarr.on(
'Ready',
function() {
105 const jsConf = <?php print json_encode($jsConf); ?>;
107 const applyCssAndDisplay =
function() {
108 $(
".imgupforline").hide();
109 $(
".imgdownforline").hide();
110 $(
".lineupdown").removeAttr(
'href');
112 if(jsConf.activeAjaxReorder) {
113 $(
".tdlineupdown").css(
"background-image",`url(${jsConf.gripImg})`);
114 $(
".tdlineupdown").css(
"background-repeat",
"no-repeat");
115 $(
".tdlineupdown").css(
"background-position",
"center center");
120 let tableDnDInstance =
null;
122 function initTableDnD() {
123 if (!jsConf.activeAjaxReorder)
return;
125 Dolibarr.log(
"Prepare tableDnd for #" + jsConf.tagIdForTableDND);
127 tableDnDInstance = $(
"#" + jsConf.tagIdForTableDND).tableDnD({
128 onDrop:
function (
table, row) {
129 var page_y = jQuery(document).scrollTop();
130 var reloadpage = jsConf.forceReloadPage;
131 Dolibarr.log(
"tableDND onDrop");
132 Dolibarr.log(decodeURI($(
"#" + jsConf.tagIdForTableDND).tableDnDSerialize()));
133 $(`#${jsConf.tagIdForTableDND} tr[data-element=extrafield]`).attr(
'id',
'');
134 $(`#${jsConf.tagIdForTableDND} tr[data-ignoreidfordnd=1]`).attr(
'id',
'');
135 var roworder = cleanSerialize(decodeURI($(`#${jsConf.tagIdForTableDND}`).tableDnDSerialize()));
136 var table_element_line = jsConf.object.tableElementLine;
137 var fk_element = jsConf.object.fkElement;
138 var element_id = jsConf.object.id;
139 var filepath = decodeURIComponent(jsConf.filePath);
143 table_element_line: table_element_line,
144 fk_element: fk_element,
145 element_id: element_id,
150 $.post(`${jsConf.DOL_URL_ROOT}/core/ajax/row.php`,
153 Dolibarr.log(
"tableDND end of ajax call, reloadpage = " + reloadpage);
155 Dolibarr.executeHook(
'documentRowMoved', postData)
157 if (reloadpage == 1) {
158 location.href = jsConf.redirectURL +
'&page_y=' + page_y;
163 onDragClass:
"dragClass",
164 dragHandle:
"td.tdlineupdown"
167 $(
".tdlineupdown").on(
"mouseenter",
function () {
168 $(
this).addClass(
"showDragHandle");
169 }).on(
"mouseleave",
function () {
170 $(
this).removeClass(
"showDragHandle");
174 applyCssAndDisplay();
177 Dolibarr.on(
'reloadDocumentLine',
function (data) {
178 Dolibarr.log(
'triggered by hook reloadDocumentLine : TEMPLATE AJAXROW.TPL.PHP')
179 applyCssAndDisplay();
185<!-- END PHP TEMPLATE AJAXROW.TPL.PHP -->
if(! $sortfield) if(! $sortorder) $object
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
treeview li table
No Email.