dolibarr 21.0.0-alpha
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 *
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
30// Protection to avoid direct call of template
31if (empty($object) || !is_object($object)) {
32 print "Error, template page ".basename(__FILE__)." can't be called with no object defined.";
33 exit;
34}
35
36?>
37
38<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on lines of a table -->
39<?php
40$id = $object->id;
41$fk_element = empty($object->fk_element) ? $fk_element : $object->fk_element;
42$table_element_line = (empty($table_element_line) ? $object->table_element_line : $table_element_line);
43$nboflines = (isset($object->lines) ? count($object->lines) : (isset($tasksarray) ? count($tasksarray) : (empty($nboflines) ? 0 : $nboflines)));
44$forcereloadpage = !getDolGlobalString('MAIN_FORCE_RELOAD_PAGE') ? 0 : 1;
45$tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
46$filepath = (empty($filepath) ? '' : $filepath);
47
48if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1 && $conf->browser->layout != 'phone') { ?>
49<script>
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");
57
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', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function
65 $('#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr('id', ''); // Set id to empty value in order to ignore them in tableDnDSerialize function
66 var roworder = cleanSerialize(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
67 var table_element_line = "<?php echo $table_element_line; ?>";
68 var fk_element = "<?php echo $fk_element; ?>";
69 var element_id = "<?php echo $id; ?>";
70 var filepath = "<?php echo urlencode($filepath); ?>";
71 var token = "<?php echo currentToken(); ?>"; // We use old 'token' and not 'newtoken' for Ajax call because the ajax page has the NOTOKENRENEWAL constant set.
72 $.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
73 {
74 roworder: roworder,
75 table_element_line: table_element_line,
76 fk_element: fk_element,
77 element_id: element_id,
78 filepath: filepath,
79 token: token
80 },
81 function() {
82 console.log("tableDND end of ajax call");
83 if (reloadpage == 1) {
84 <?php
85 $redirectURL = empty($urltorefreshaftermove) ? ($_SERVER['PHP_SELF'].'?'.dol_escape_js($_SERVER['QUERY_STRING'])) : $urltorefreshaftermove;
86 // remove action parameter from URL
87 $redirectURL = preg_replace('/(&|\?)action=[^&#]*/', '', $redirectURL);
88 ?>
89 location.href = '<?php echo dol_escape_js($redirectURL); ?>';
90 } else {
91 $("#<?php echo $tagidfortablednd; ?> .drag").each(
92 function( intIndex ) {
93 // $(this).removeClass("pair impair");
94 //if (intIndex % 2 == 0) $(this).addClass('impair');
95 //if (intIndex % 2 == 1) $(this).addClass('pair');
96 });
97 }
98 });
99 },
100 onDragClass: "dragClass",
101 dragHandle: "td.tdlineupdown"
102 });
103 $(".tdlineupdown").hover( function() { $(this).addClass('showDragHandle'); },
104 function() { $(this).removeClass('showDragHandle'); }
105 );
106});
107</script>
108<?php } else { ?>
109<script>
110$(document).ready(function(){
111 $(".imgupforline").hide();
112 $(".imgdownforline").hide();
113 $(".lineupdown").removeAttr('href');
114});
115</script>
116<?php } ?>
117<!-- END PHP TEMPLATE AJAXROW.TPL.PHP -->
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.