Test: reorder lines with jquery
This commit is contained in:
parent
adab5f7722
commit
481ecd6a87
@ -1367,16 +1367,10 @@ if ($id > 0 || ! empty($ref))
|
||||
/*
|
||||
* Lines
|
||||
*/
|
||||
// We disable with 1 == 2 because until dev is finished.
|
||||
if (1 == 2 && $conf->use_javascript_ajax && $propal->statut == 0 && $_GET['action'] != 'editline')
|
||||
// We disable with $conf->global->MAIN_FEATURES_LEVEL because until dev is finished.
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL == 2 && $conf->use_javascript_ajax && $propal->statut == 0 && $_GET['action'] != 'editline')
|
||||
{
|
||||
print '<script>
|
||||
jQuery(document).ready(function(){
|
||||
jQuery("#objectline").tableDnD();
|
||||
jQuery(".imgup").hide();
|
||||
jQuery(".imgdown").hide();
|
||||
});
|
||||
</script>';
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php');
|
||||
}
|
||||
|
||||
print '<table id="objectline" class="noborder" width="100%">';
|
||||
|
||||
71
htdocs/core/ajaxrow.php
Normal file
71
htdocs/core/ajaxrow.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/ajaxrow.php
|
||||
* \brief File to return Ajax response on Row move
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
|
||||
require('../main.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
//header('Cache-Control: Public, must-revalidate');
|
||||
//header('Pragma: public');
|
||||
|
||||
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
|
||||
top_httphead();
|
||||
|
||||
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||
|
||||
// Registering the location of boxes
|
||||
if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['element']) && !empty($_GET['element'])))
|
||||
{
|
||||
$roworder = explode(',',$_GET['roworder']);
|
||||
|
||||
foreach($roworder as $value)
|
||||
{
|
||||
if (!empty($value))
|
||||
{
|
||||
$newroworder[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$roworder = implode(',',$newroworder);
|
||||
|
||||
dol_syslog("AjaxRow roworder=".$_GET['roworder']." neworder=".$roworder." element=".$_GET['element'], LOG_DEBUG);
|
||||
|
||||
$row=new CommonObject($db);
|
||||
$row->table_element_line = $_GET['element'];
|
||||
$result=$row->line_ajaxorder($roworder);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -717,12 +717,7 @@ class CommonObject
|
||||
}
|
||||
for ($i = 0 ; $i < sizeof($li) ; $i++)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET rang = '.($i+1);
|
||||
$sql.= ' WHERE rowid = '.$li[$i];
|
||||
if (!$this->db->query($sql) )
|
||||
{
|
||||
dol_syslog($this->db->error());
|
||||
}
|
||||
$this->updateRangOfLine($li[$i], ($i+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -767,11 +762,30 @@ class CommonObject
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET rang = '.$rang;
|
||||
$sql.= ' WHERE rowid = '.$rowid;
|
||||
|
||||
dol_syslog("CommonObject::updateRangOfLine sql=".$sql, LOG_DEBUG);
|
||||
if (! $this->db->query($sql) )
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update position of line with ajax (rang)
|
||||
*/
|
||||
function line_ajaxorder($roworder)
|
||||
{
|
||||
$rows = explode(',',$roworder);
|
||||
$num = sizeof($rows);
|
||||
|
||||
dol_syslog("CommonObject::line_ajaxorder roworder=".$roworder." num=".$num, LOG_DEBUG);
|
||||
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
dol_syslog("CommonObject::line_ajaxorder row=".$rows[$i]." rang=".($i+1), LOG_DEBUG);
|
||||
$this->updateRangOfLine($rows[$i], ($i+1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update position of line up (rang)
|
||||
|
||||
38
htdocs/core/tpl/ajaxrow.tpl.php
Normal file
38
htdocs/core/tpl/ajaxrow.tpl.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function(){
|
||||
jQuery(".imgup").hide();
|
||||
jQuery(".imgdown").hide();
|
||||
jQuery("#objectline").tableDnD({
|
||||
onDrop: function(table, row) {
|
||||
var roworder = cleanSerialize(jQuery("#objectline").tableDnDSerialize());
|
||||
var element = "<?php echo $propal->table_element_line; ?>";
|
||||
jQuery.get("<?php echo DOL_URL_ROOT; ?>/core/ajaxrow.php?roworder="+roworder+"&element="+element);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE freeproductline_view.tpl.php -->
|
||||
|
||||
<tr <?php echo 'id='.$i.' '.$bc[$var]; ?>>
|
||||
<tr <?php echo 'id=row-'.$line->id.' '.$bc[$var]; ?>>
|
||||
<td><a name="<?php echo $line->rowid; ?>"></a>
|
||||
<?php if (($line->info_bits & 2) == 2) { ?>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE predefinedproductline_view.tpl.php -->
|
||||
|
||||
<tr <?php echo 'id='.$i.' '.$bc[$var]; ?>>
|
||||
<tr <?php echo 'id=row-'.$line->id.' '.$bc[$var]; ?>>
|
||||
<td>
|
||||
<a name="<?php echo $line->id; ?>"></a>
|
||||
<?php
|
||||
|
||||
Loading…
Reference in New Issue
Block a user