dolibarr  7.0.0-beta
ajaxrow.tpl.php
1 <?php
2 /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.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 abale to drag and drop rows of a table.
20  * You must add id="tablelines" on table level tag and have ($nboflines or count($object->lines) or count($taskarray) > 0)
21  */
22 
23 // Protection to avoid direct call of template
24 if (empty($object) || ! is_object($object))
25 {
26  print "Error, template page can't be called as URL";
27  exit;
28 }
29 
30 ?>
31 
32 <!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on tables -->
33 <?php
34 $id=$object->id;
35 $fk_element=$object->fk_element;
36 $table_element_line=(empty($table_element_line)?$object->table_element_line:$table_element_line);
37 $nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines)));
38 $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
39 $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
40 $filepath=(empty($filepath)?'':$filepath);
41 
42 if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) { ?>
43 <script type="text/javascript">
44 $(document).ready(function(){
45  $(".imgupforline").hide();
46  $(".imgdownforline").hide();
47  $(".lineupdown").removeAttr('href');
48  $(".tdlineupdown").css("background-image",'url(<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/grip.png'; ?>)');
49  $(".tdlineupdown").css("background-repeat","no-repeat");
50  $(".tdlineupdown").css("background-position","center center");
51 
52  console.log("Prepare tableDnd for #<?php echo $tagidfortablednd; ?>");
53  $("#<?php echo $tagidfortablednd; ?>").tableDnD({
54  onDrop: function(table, row) {
55  var reloadpage = "<?php echo $forcereloadpage; ?>";
56  console.log("tableDND onDrop");
57  console.log(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
58  var roworder = cleanSerialize(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
59  var table_element_line = "<?php echo $table_element_line; ?>";
60  var fk_element = "<?php echo $fk_element; ?>";
61  var element_id = "<?php echo $id; ?>";
62  var filepath = "<?php echo urlencode($filepath); ?>";
63  $.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
64  {
65  roworder: roworder,
66  table_element_line: table_element_line,
67  fk_element: fk_element,
68  element_id: element_id,
69  filepath: filepath
70  },
71  function() {
72  console.log("tableDND end of ajax call");
73  if (reloadpage == 1) {
74  location.href = '<?php echo dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']); ?>';
75  } else {
76  $("#<?php echo $tagidfortablednd; ?> .drag").each(
77  function( intIndex ) {
78  // $(this).removeClass("pair impair");
79  //if (intIndex % 2 == 0) $(this).addClass('impair');
80  //if (intIndex % 2 == 1) $(this).addClass('pair');
81  });
82  }
83  });
84  },
85  onDragClass: "dragClass",
86  dragHandle: "td.tdlineupdown"
87  });
88  $(".tdlineupdown").hover( function() { $(this).addClass('showDragHandle'); },
89  function() { $(this).removeClass('showDragHandle'); }
90  );
91 });
92 </script>
93 <?php } else { ?>
94 <script>
95 $(document).ready(function(){
96  $(".imgupforline").hide();
97  $(".imgdownforline").hide();
98  $(".lineupdown").removeAttr('href');
99 });
100 </script>
101 <?php } ?>
102 <!-- 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:283