29 if (empty($object) || !is_object($object))
31 print "Error, template page can't be called as URL";
37 <!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on lines of a table -->
40 $fk_element = empty($object->fk_element) ? $fk_element : $object->fk_element;
41 $table_element_line = (empty($table_element_line) ? $object->table_element_line : $table_element_line);
42 $nboflines = (isset($object->lines) ?count($object->lines) : (isset($tasksarray) ?count($tasksarray) : (empty($nboflines) ? 0 : $nboflines)));
43 $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
44 $tagidfortablednd = (empty($tagidfortablednd) ?
'tablelines' : $tagidfortablednd);
45 $filepath = (empty($filepath) ?
'' : $filepath);
48 if (
GETPOST(
'action',
'aZ09') !=
'editline' && $nboflines > 1 && $conf->browser->layout !=
'phone') { ?>
50 $(document).ready(
function(){
51 $(
".imgupforline").hide();
52 $(
".imgdownforline").hide();
53 $(
".lineupdown").removeAttr(
'href');
54 $(
".tdlineupdown").css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)');
55 $(
".tdlineupdown").css(
"background-repeat",
"no-repeat");
56 $(
".tdlineupdown").css(
"background-position",
"center center");
58 console.log(
"Prepare tableDnd for #<?php echo $tagidfortablednd; ?>");
59 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
60 onDrop:
function(table, row) {
61 var reloadpage =
"<?php echo $forcereloadpage; ?>";
62 console.log(
"tableDND onDrop");
63 console.log(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
64 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
65 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
66 var table_element_line =
"<?php echo $table_element_line; ?>";
67 var fk_element =
"<?php echo $fk_element; ?>";
68 var element_id =
"<?php echo $id; ?>";
69 var filepath =
"<?php echo urlencode($filepath); ?>";
70 var token =
"<?php echo $_SESSION["token
"]; ?>";
71 $.post(
"<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
74 table_element_line: table_element_line,
75 fk_element: fk_element,
76 element_id: element_id,
81 console.log(
"tableDND end of ajax call");
82 if (reloadpage == 1) {
87 $redirectURL = preg_replace(
'/(&|\?)action=[^&#]*/',
'', $redirectURL);
89 location.href =
'<?php echo dol_escape_js($redirectURL); ?>';
91 $(
"#<?php echo $tagidfortablednd; ?> .drag").each(
92 function( intIndex ) {
100 onDragClass:
"dragClass",
101 dragHandle:
"td.tdlineupdown"
103 $(
".tdlineupdown").hover(
function() { $(
this).addClass(
'showDragHandle'); },
104 function() { $(
this).removeClass(
'showDragHandle'); }
110 $(document).ready(
function(){
111 $(
".imgupforline").hide();
112 $(
".imgdownforline").hide();
113 $(
".lineupdown").removeAttr(
'href');
117 <!-- END PHP TEMPLATE AJAXROW.TPL.PHP -->
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.