From 1c89213caf8df4b5728290ff53a9d367cb4a5014 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 11 Apr 2011 09:00:13 +0000 Subject: [PATCH] Fix: reorder the lines correctly --- htdocs/comm/propal/class/propal.class.php | 1 + htdocs/commande/class/commande.class.php | 1 + htdocs/compta/facture/class/facture.class.php | 1 + htdocs/core/ajaxrow.php | 8 ++++++-- htdocs/core/class/commonobject.class.php | 4 ---- htdocs/core/tpl/ajaxrow.tpl.php | 10 ++++++---- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index dadc49c7b75..8802eec38cd 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -311,6 +311,7 @@ class Propal extends CommonObject if (empty($qty)) $qty=0; if (empty($info_bits)) $info_bits=0; if (empty($rang)) $rang=0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; $remise_percent=price2num($remise_percent); $qty=price2num($qty); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 47444383269..d8ad0edd742 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -913,6 +913,7 @@ class Commande extends CommonObject if (empty($txtva)) $txtva=0; if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; $remise_percent=price2num($remise_percent); $qty=price2num($qty); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index da5b3f2fcb9..2b1af08cf52 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1717,6 +1717,7 @@ class Facture extends CommonObject if (empty($txtva)) $txtva=0; if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; $remise_percent=price2num($remise_percent); $qty=price2num($qty); diff --git a/htdocs/core/ajaxrow.php b/htdocs/core/ajaxrow.php index 284ba49d935..e4c2a8f992d 100644 --- a/htdocs/core/ajaxrow.php +++ b/htdocs/core/ajaxrow.php @@ -47,7 +47,8 @@ top_httphead(); print ''."\n"; // Registering the location of boxes -if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['element']) && !empty($_GET['element']))) +if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['table_element_line']) && !empty($_GET['table_element_line'])) + && (isset($_GET['fk_element']) && !empty($_GET['fk_element'])) && (isset($_GET['element_id']) && !empty($_GET['element_id'])) ) { $roworder = explode(',',$_GET['roworder']); @@ -64,8 +65,11 @@ if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['elem dol_syslog("AjaxRow roworder=".$_GET['roworder']." neworder=".$roworder." element=".$_GET['element'], LOG_DEBUG); $row=new CommonObject($db); - $row->table_element_line = $_GET['element']; + $row->table_element_line = $_GET['table_element_line']; + $row->fk_element = $_GET['fk_element']; + $row->id = $_GET['element_id']; $result=$row->line_ajaxorder($roworder); + $result=$row->line_order(true); } ?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 11cf3d6bb7f..65d58b8fabe 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -22,11 +22,7 @@ * \file htdocs/core/class/commonobject.class.php * \ingroup core * \brief Fichier de la classe mere des classes metiers (facture, contrat, propal, commande, etc...) -<<<<<<< commonobject.class.php * \version $Id$ -======= - * \version $Id$ ->>>>>>> 1.107 */ diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 2976d05627f..4d0320cc66f 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010 Laurent Destailleur +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2010-2011 Laurent Destailleur * * 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 @@ -34,8 +34,10 @@ jQuery(document).ready(function(){ jQuery("#tablelines").tableDnD({ onDrop: function(table, row) { var roworder = cleanSerialize(jQuery("#tablelines").tableDnDSerialize()); - var element = "table_element_line; ?>"; - jQuery.get("/core/ajaxrow.php?roworder="+roworder+"&element="+element); + var table_element_line = "table_element_line; ?>"; + var fk_element = "fk_element; ?>"; + var element_id = "id; ?>"; + jQuery.get("/core/ajaxrow.php?roworder="+roworder+"&table_element_line="+table_element_line+"&fk_element="+fk_element+"&element_id="+element_id); jQuery("#tablelines .drag").each( function( intIndex ){ jQuery(this).removeClass("pair impair");