dolibarr 21.0.0-beta
ajaxrow.tpl.php
1<?php
2/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2010-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
39// Protection to avoid direct call of template
40if (empty($object) || !is_object($object)) {
41 print "Error, template page ".basename(__FILE__)." can't be called with no object defined.";
42 exit;
43}
44
45?>
46
47<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on lines of a table -->
48<?php
49$id = $object->id;
50$fk_element = empty($object->fk_element) ? $fk_element : $object->fk_element;
51$table_element_line = (empty($table_element_line) ? $object->table_element_line : $table_element_line);
52$nboflines = (isset($object->lines) ? count($object->lines) : (isset($tasksarray) ? count($tasksarray) : (empty($nboflines) ? 0 : $nboflines)));
53$forcereloadpage = !getDolGlobalString('MAIN_FORCE_RELOAD_PAGE') ? 0 : 1;
54$tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
55$filepath = (empty($filepath) ? '' : $filepath);
56
57if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1 && $conf->browser->layout != 'phone') { ?>
58<script>
59$(document).ready(function(){
60 $(".imgupforline").hide();
61 $(".imgdownforline").hide();
62 $(".lineupdown").removeAttr('href');
63 $(".tdlineupdown").css("background-image",'url(<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/grip.png'; ?>)');
64 $(".tdlineupdown").css("background-repeat","no-repeat");
65 $(".tdlineupdown").css("background-position","center center");
66
67 console.log("Prepare tableDnd for #<?php echo $tagidfortablednd; ?>");
68 $("#<?php echo $tagidfortablednd; ?>").tableDnD({
69 onDrop: function(table, row) {
70 var reloadpage = "<?php echo $forcereloadpage; ?>";
71 console.log("tableDND onDrop");
72 console.log(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
73 $('#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr('id', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function
74 $('#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr('id', ''); // Set id to empty value in order to ignore them in tableDnDSerialize function
75 var roworder = cleanSerialize(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
76 var table_element_line = "<?php echo $table_element_line; ?>";
77 var fk_element = "<?php echo $fk_element; ?>";
78 var element_id = "<?php echo $id; ?>";
79 var filepath = "<?php echo urlencode($filepath); ?>";
80 var token = "<?php echo currentToken(); ?>"; // We use old 'token' and not 'newtoken' for Ajax call because the ajax page has the NOTOKENRENEWAL constant set.
81 $.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
82 {
83 roworder: roworder,
84 table_element_line: table_element_line,
85 fk_element: fk_element,
86 element_id: element_id,
87 filepath: filepath,
88 token: token
89 },
90 function() {
91 console.log("tableDND end of ajax call");
92 if (reloadpage == 1) {
93 <?php
94 $redirectURL = empty($urltorefreshaftermove) ? ($_SERVER['PHP_SELF'].'?'.dol_escape_js($_SERVER['QUERY_STRING'])) : $urltorefreshaftermove;
95 // remove action parameter from URL
96 $redirectURL = preg_replace('/(&|\?)action=[^&#]*/', '', $redirectURL);
97 ?>
98 location.href = '<?php echo dol_escape_js($redirectURL); ?>';
99 } else {
100 $("#<?php echo $tagidfortablednd; ?> .drag").each(
101 function( intIndex ) {
102 // $(this).removeClass("pair impair");
103 //if (intIndex % 2 == 0) $(this).addClass('impair');
104 //if (intIndex % 2 == 1) $(this).addClass('pair');
105 });
106 }
107 });
108 },
109 onDragClass: "dragClass",
110 dragHandle: "td.tdlineupdown"
111 });
112 $(".tdlineupdown").hover( function() { $(this).addClass('showDragHandle'); },
113 function() { $(this).removeClass('showDragHandle'); }
114 );
115});
116</script>
117<?php } else { ?>
118<script>
119$(document).ready(function(){
120 $(".imgupforline").hide();
121 $(".imgdownforline").hide();
122 $(".lineupdown").removeAttr('href');
123});
124</script>
125<?php } ?>
126<!-- END PHP TEMPLATE AJAXROW.TPL.PHP -->
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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 a Dolibarr global constant string value.
treeview li table
No Email.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79