dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
17  *
18  * Javascript code to activate drag and drop on lines
19  * You can use this if you want to be able to drag and drop rows of a table.
20  * You must add id="tablelines" on table level tag
21  * and $object and $object->id is defined
22  * and $object->fk_element or $fk_element is defined
23  * and have ($nboflines or count($object->lines) or count($taskarray) > 0)
24  * and have $table_element_line = 'tablename' or $object->table_element_line with line to move
25  *
26  */
27 
28 // Protection to avoid direct call of template
29 if (empty($object) || ! is_object($object))
30 {
31  print "Error, template page can't be called as URL";
32  exit;
33 }
34 
35 ?>
36 
37 <!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on lines of a table -->
38 <?php
39 $id=$object->id;
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);
46 
47 if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) { ?>
48 <script type="text/javascript">
49 $(document).ready(function(){
50  $(".imgupforline").hide();
51  $(".imgdownforline").hide();
52  $(".lineupdown").removeAttr('href');
53  $(".tdlineupdown").css("background-image",'url(<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/grip.png'; ?>)');
54  $(".tdlineupdown").css("background-repeat","no-repeat");
55  $(".tdlineupdown").css("background-position","center center");
56 
57  console.log("Prepare tableDnd for #<?php echo $tagidfortablednd; ?>");
58  $("#<?php echo $tagidfortablednd; ?>").tableDnD({
59  onDrop: function(table, row) {
60  var reloadpage = "<?php echo $forcereloadpage; ?>";
61  console.log("tableDND onDrop");
62  console.log(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
63  $('#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr('id', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function
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  $.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
70  {
71  roworder: roworder,
72  table_element_line: table_element_line,
73  fk_element: fk_element,
74  element_id: element_id,
75  filepath: filepath
76  },
77  function() {
78  console.log("tableDND end of ajax call");
79  if (reloadpage == 1) {
80  //console.log('<?php echo dol_escape_js($_SERVER['QUERY_STRING']); ?>');
81  location.href = '<?php echo dol_escape_js($_SERVER['PHP_SELF']).'?'.dol_escape_js($_SERVER['QUERY_STRING']); ?>';
82  } else {
83  $("#<?php echo $tagidfortablednd; ?> .drag").each(
84  function( intIndex ) {
85  // $(this).removeClass("pair impair");
86  //if (intIndex % 2 == 0) $(this).addClass('impair');
87  //if (intIndex % 2 == 1) $(this).addClass('pair');
88  });
89  }
90  });
91  },
92  onDragClass: "dragClass",
93  dragHandle: "td.tdlineupdown"
94  });
95  $(".tdlineupdown").hover( function() { $(this).addClass('showDragHandle'); },
96  function() { $(this).removeClass('showDragHandle'); }
97  );
98 });
99 </script>
100 <?php } else { ?>
101 <script>
102 $(document).ready(function(){
103  $(".imgupforline").hide();
104  $(".imgdownforline").hide();
105  $(".lineupdown").removeAttr('href');
106 });
107 </script>
108 <?php } ?>
109 <!-- END PHP TEMPLATE AJAXROW.TPL.PHP -->
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
type
Definition: viewcat.php:284