29if (empty($object) || !is_object($object)) {
30 print
"Error, template page ".basename(__FILE__).
" can't be called with no object defined.";
36<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on lines of a table -->
39$fk_element = empty($object->fk_element) ? $fk_element : $object->fk_element;
40$table_element_line = (empty($table_element_line) ? $object->table_element_line : $table_element_line);
41$nboflines = (isset($object->lines) ? count($object->lines) : (isset($tasksarray) ? count($tasksarray) : (empty($nboflines) ? 0 : $nboflines)));
43$tagidfortablednd = (empty($tagidfortablednd) ?
'tablelines' : $tagidfortablednd);
44$filepath = (empty($filepath) ?
'' : $filepath);
46if (
GETPOST(
'action',
'aZ09') !=
'editline' && $nboflines > 1 && $conf->browser->layout !=
'phone') { ?>
48$(document).ready(
function(){
49 $(
".imgupforline").hide();
50 $(
".imgdownforline").hide();
51 $(
".lineupdown").removeAttr(
'href');
52 $(
".tdlineupdown").css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)');
53 $(
".tdlineupdown").css(
"background-repeat",
"no-repeat");
54 $(
".tdlineupdown").css(
"background-position",
"center center");
56 console.log(
"Prepare tableDnd for #<?php echo $tagidfortablednd; ?>");
57 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
58 onDrop:
function(table, row) {
59 var reloadpage =
"<?php echo $forcereloadpage; ?>";
60 console.log(
"tableDND onDrop");
61 console.log(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
62 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
63 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
64 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
65 var table_element_line =
"<?php echo $table_element_line; ?>";
66 var fk_element =
"<?php echo $fk_element; ?>";
67 var element_id =
"<?php echo $id; ?>";
68 var filepath =
"<?php echo urlencode($filepath); ?>";
69 var token =
"<?php echo currentToken(); ?>";
70 $.post(
"<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
73 table_element_line: table_element_line,
74 fk_element: fk_element,
75 element_id: element_id,
80 console.log(
"tableDND end of ajax call");
81 if (reloadpage == 1) {
83 $redirectURL = empty($urltorefreshaftermove) ? ($_SERVER[
'PHP_SELF'].
'?'.
dol_escape_js($_SERVER[
'QUERY_STRING'])) : $urltorefreshaftermove;
85 $redirectURL = preg_replace(
'/(&|\?)action=[^&#]*/',
'', $redirectURL);
87 location.href =
'<?php echo dol_escape_js($redirectURL); ?>';
89 $(
"#<?php echo $tagidfortablednd; ?> .drag").each(
90 function( intIndex ) {
98 onDragClass:
"dragClass",
99 dragHandle:
"td.tdlineupdown"
101 $(
".tdlineupdown").hover(
function() { $(
this).addClass(
'showDragHandle'); },
102 function() { $(
this).removeClass(
'showDragHandle'); }
108$(document).ready(
function(){
109 $(
".imgupforline").hide();
110 $(
".imgdownforline").hide();
111 $(
".lineupdown").removeAttr(
'href');
115<!-- END PHP TEMPLATE AJAXROW.TPL.PHP -->
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.