Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
7e5c347b
Commit
7e5c347b
authored
13 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Fix: correct reorder childrens of lines
parent
f352f5cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
htdocs/core/ajax/row.php
+4
-14
4 additions, 14 deletions
htdocs/core/ajax/row.php
htdocs/core/class/commonobject.class.php
+54
-6
54 additions, 6 deletions
htdocs/core/class/commonobject.class.php
htdocs/core/tpl/ajaxrow.tpl.php
+21
-21
21 additions, 21 deletions
htdocs/core/tpl/ajaxrow.tpl.php
with
79 additions
and
41 deletions
htdocs/core/ajax/row.php
+
4
−
14
View file @
7e5c347b
<?php
<?php
/* Copyright (C) 2010-201
1
Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2010-201
2
Regis Houssin <regis@dolibarr.fr>
*
*
* This program is free software; you can redistribute it and/or modify
* 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
* it under the terms of the GNU General Public License as published by
...
@@ -35,11 +35,6 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
...
@@ -35,11 +35,6 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
* View
* 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
();
top_httphead
();
print
'<!-- Ajax page called with url '
.
$_SERVER
[
"PHP_SELF"
]
.
'?'
.
$_SERVER
[
"QUERY_STRING"
]
.
' -->'
.
"
\n
"
;
print
'<!-- Ajax page called with url '
.
$_SERVER
[
"PHP_SELF"
]
.
'?'
.
$_SERVER
[
"QUERY_STRING"
]
.
' -->'
.
"
\n
"
;
...
@@ -52,21 +47,16 @@ if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['tabl
...
@@ -52,21 +47,16 @@ if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['tabl
foreach
(
$roworder
as
$value
)
foreach
(
$roworder
as
$value
)
{
{
if
(
!
empty
(
$value
))
if
(
!
empty
(
$value
))
$newroworder
[]
=
$value
;
{
$newroworder
[]
=
$value
;
}
}
}
$roworder
=
implode
(
','
,
$newroworder
);
dol_syslog
(
"AjaxRow roworder="
.
$_GET
[
'roworder'
]
.
" fk_element="
.
$_GET
[
'fk_element'
],
LOG_DEBUG
);
dol_syslog
(
"AjaxRow roworder="
.
$_GET
[
'roworder'
]
.
" neworder="
.
$roworder
.
" element="
.
$_GET
[
'element'
],
LOG_DEBUG
);
$row
=
new
GenericObject
(
$db
);
$row
=
new
GenericObject
(
$db
);
$row
->
table_element_line
=
$_GET
[
'table_element_line'
];
$row
->
table_element_line
=
$_GET
[
'table_element_line'
];
$row
->
fk_element
=
$_GET
[
'fk_element'
];
$row
->
fk_element
=
$_GET
[
'fk_element'
];
$row
->
id
=
$_GET
[
'element_id'
];
$row
->
id
=
$_GET
[
'element_id'
];
$result
=
$row
->
line_ajaxorder
(
$roworder
);
$result
=
$row
->
line_ajaxorder
(
$
new
roworder
);
$result
=
$row
->
line_order
(
true
);
$result
=
$row
->
line_order
(
true
);
}
}
...
...
This diff is collapsed.
Click to expand it.
htdocs/core/class/commonobject.class.php
+
54
−
6
View file @
7e5c347b
...
@@ -890,24 +890,74 @@ abstract class CommonObject
...
@@ -890,24 +890,74 @@ abstract class CommonObject
}
}
if
(
$nl
>
0
)
if
(
$nl
>
0
)
{
{
$rows
=
array
();
$sql
=
'SELECT rowid FROM '
.
MAIN_DB_PREFIX
.
$this
->
table_element_line
;
$sql
=
'SELECT rowid FROM '
.
MAIN_DB_PREFIX
.
$this
->
table_element_line
;
$sql
.
=
' WHERE '
.
$this
->
fk_element
.
' = '
.
$this
->
id
;
$sql
.
=
' WHERE '
.
$this
->
fk_element
.
' = '
.
$this
->
id
;
$sql
.
=
' AND fk_parent_line IS NULL'
;
$sql
.
=
' ORDER BY rang ASC, rowid '
.
$rowidorder
;
$sql
.
=
' ORDER BY rang ASC, rowid '
.
$rowidorder
;
dol_syslog
(
get_class
(
$this
)
.
"::line_order sql="
.
$sql
,
LOG_DEBUG
);
dol_syslog
(
get_class
(
$this
)
.
"::line_order sql="
.
$sql
,
LOG_DEBUG
);
$resql
=
$this
->
db
->
query
(
$sql
);
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
$resql
)
if
(
$resql
)
{
{
$i
=
0
;
$num
=
$this
->
db
->
num_rows
(
$resql
);
$num
=
$this
->
db
->
num_rows
(
$resql
);
$i
=
0
;
while
(
$i
<
$num
)
while
(
$i
<
$num
)
{
{
$row
=
$this
->
db
->
fetch_row
(
$resql
);
$row
=
$this
->
db
->
fetch_row
(
$resql
);
$this
->
updateRangOfLine
(
$row
[
0
],
(
$i
+
1
));
$rows
[]
=
$row
[
0
];
$childrens
=
$this
->
getChildrensOfLine
(
$row
[
0
]);
if
(
!
empty
(
$childrens
))
{
foreach
(
$childrens
as
$child
)
{
array_push
(
$rows
,
$child
);
}
}
$i
++
;
$i
++
;
}
}
if
(
!
empty
(
$rows
))
{
foreach
(
$rows
as
$key
=>
$row
)
{
$this
->
updateRangOfLine
(
$row
,
(
$key
+
1
));
}
}
}
}
}
/**
* Get childrens of line
*
* @param int $id Id of parent line
*/
function
getChildrensOfLine
(
$id
)
{
$rows
=
array
();
$sql
=
'SELECT rowid FROM '
.
MAIN_DB_PREFIX
.
$this
->
table_element_line
;
$sql
.
=
' WHERE '
.
$this
->
fk_element
.
' = '
.
$this
->
id
;
$sql
.
=
' AND fk_parent_line = '
.
$id
;
$sql
.
=
' ORDER BY rang ASC'
;
dol_syslog
(
get_class
(
$this
)
.
"::getChildrenOfLines sql="
.
$sql
,
LOG_DEBUG
);
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
$resql
)
{
$i
=
0
;
$num
=
$this
->
db
->
num_rows
(
$resql
);
while
(
$i
<
$num
)
{
$row
=
$this
->
db
->
fetch_row
(
$resql
);
$rows
[
$i
]
=
$row
[
0
];
$i
++
;
}
}
}
}
return
$rows
;
}
}
/**
/**
...
@@ -966,13 +1016,11 @@ abstract class CommonObject
...
@@ -966,13 +1016,11 @@ abstract class CommonObject
/**
/**
* Update position of line with ajax (rang)
* Update position of line with ajax (rang)
*
*
* @param
int $roworder
* @param
array $rows Array of rows
*/
*/
function
line_ajaxorder
(
$row
order
)
function
line_ajaxorder
(
$row
s
)
{
{
$rows
=
explode
(
','
,
$roworder
);
$num
=
count
(
$rows
);
$num
=
count
(
$rows
);
for
(
$i
=
0
;
$i
<
$num
;
$i
++
)
for
(
$i
=
0
;
$i
<
$num
;
$i
++
)
{
{
$this
->
updateRangOfLine
(
$rows
[
$i
],
(
$i
+
1
));
$this
->
updateRangOfLine
(
$rows
[
$i
],
(
$i
+
1
));
...
...
This diff is collapsed.
Click to expand it.
htdocs/core/tpl/ajaxrow.tpl.php
+
21
−
21
View file @
7e5c347b
<?php
<?php
/* Copyright (C) 2010-201
1
Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2010-201
2
Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
...
@@ -21,22 +21,22 @@
...
@@ -21,22 +21,22 @@
<!-- BEGIN PHP TEMPLATE FOR JQUERY -->
<!-- BEGIN PHP TEMPLATE FOR JQUERY -->
<?php
if
(
count
(
$object
->
lines
)
>
1
&&
$_GET
[
'action'
]
!=
'editline'
)
{
?>
<?php
if
(
count
(
$object
->
lines
)
>
1
&&
$_GET
[
'action'
]
!=
'editline'
)
{
?>
<script>
<script>
jQuery
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
jQuery
(
"
.imgup
"
).
hide
();
$
(
"
.imgup
"
).
hide
();
jQuery
(
"
.imgdown
"
).
hide
();
$
(
"
.imgdown
"
).
hide
();
jQuery
(
"
.lineupdown
"
).
removeAttr
(
'
href
'
);
$
(
"
.lineupdown
"
).
removeAttr
(
'
href
'
);
jQuery
(
"
.tdlineupdown
"
).
css
(
"
background-image
"
,
'
url(
<?php
echo
DOL_URL_ROOT
.
'/theme/'
.
$conf
->
theme
.
'/img/grip.png'
;
?>
)
'
);
$
(
"
.tdlineupdown
"
).
css
(
"
background-image
"
,
'
url(
<?php
echo
DOL_URL_ROOT
.
'/theme/'
.
$conf
->
theme
.
'/img/grip.png'
;
?>
)
'
);
jQuery
(
"
.tdlineupdown
"
).
css
(
"
background-repeat
"
,
"
no-repeat
"
);
$
(
"
.tdlineupdown
"
).
css
(
"
background-repeat
"
,
"
no-repeat
"
);
jQuery
(
"
.tdlineupdown
"
).
css
(
"
background-position
"
,
"
center center
"
);
$
(
"
.tdlineupdown
"
).
css
(
"
background-position
"
,
"
center center
"
);
jQuery
(
"
#tablelines
"
).
tableDnD
({
$
(
"
#tablelines
"
).
tableDnD
({
onDrop
:
function
(
table
,
row
)
{
onDrop
:
function
(
table
,
row
)
{
var
reloadpage
=
"
<?php
echo
$conf
->
global
->
MAIN_FORCE_RELOAD_PAGE
;
?>
"
;
var
reloadpage
=
"
<?php
echo
$conf
->
global
->
MAIN_FORCE_RELOAD_PAGE
;
?>
"
;
var
roworder
=
cleanSerialize
(
jQuery
(
"
#tablelines
"
).
tableDnDSerialize
());
var
roworder
=
cleanSerialize
(
$
(
"
#tablelines
"
).
tableDnDSerialize
());
var
table_element_line
=
"
<?php
echo
$object
->
table_element_line
;
?>
"
;
var
table_element_line
=
"
<?php
echo
$object
->
table_element_line
;
?>
"
;
var
fk_element
=
"
<?php
echo
$object
->
fk_element
;
?>
"
;
var
fk_element
=
"
<?php
echo
$object
->
fk_element
;
?>
"
;
var
element_id
=
"
<?php
echo
$object
->
id
;
?>
"
;
var
element_id
=
"
<?php
echo
$object
->
id
;
?>
"
;
jQuery
.
get
(
"
<?php
echo
DOL_URL_ROOT
;
?>
/core/ajax/row.php
"
,
$
.
get
(
"
<?php
echo
DOL_URL_ROOT
;
?>
/core/ajax/row.php
"
,
{
{
roworder
:
roworder
,
roworder
:
roworder
,
table_element_line
:
table_element_line
,
table_element_line
:
table_element_line
,
...
@@ -47,11 +47,11 @@ jQuery(document).ready(function(){
...
@@ -47,11 +47,11 @@ jQuery(document).ready(function(){
if
(
reloadpage
==
1
)
{
if
(
reloadpage
==
1
)
{
location
.
href
=
'
<?php
echo
$_SERVER
[
'PHP_SELF'
]
.
'?'
.
$_SERVER
[
'QUERY_STRING'
];
?>
'
;
location
.
href
=
'
<?php
echo
$_SERVER
[
'PHP_SELF'
]
.
'?'
.
$_SERVER
[
'QUERY_STRING'
];
?>
'
;
}
else
{
}
else
{
jQuery
(
"
#tablelines .drag
"
).
each
(
$
(
"
#tablelines .drag
"
).
each
(
function
(
intIndex
)
{
function
(
intIndex
)
{
jQuery
(
this
).
removeClass
(
"
pair impair
"
);
$
(
this
).
removeClass
(
"
pair impair
"
);
if
(
intIndex
%
2
==
0
)
jQuery
(
this
).
addClass
(
'
impair
'
);
if
(
intIndex
%
2
==
0
)
$
(
this
).
addClass
(
'
impair
'
);
if
(
intIndex
%
2
==
1
)
jQuery
(
this
).
addClass
(
'
pair
'
);
if
(
intIndex
%
2
==
1
)
$
(
this
).
addClass
(
'
pair
'
);
});
});
}
}
});
});
...
@@ -59,17 +59,17 @@ jQuery(document).ready(function(){
...
@@ -59,17 +59,17 @@ jQuery(document).ready(function(){
onDragClass
:
"
dragClass
"
,
onDragClass
:
"
dragClass
"
,
dragHandle
:
"
tdlineupdown
"
dragHandle
:
"
tdlineupdown
"
});
});
jQuery
(
"
.tdlineupdown
"
).
hover
(
function
()
{
jQuery
(
this
).
addClass
(
'
showDragHandle
'
);
},
$
(
"
.tdlineupdown
"
).
hover
(
function
()
{
$
(
this
).
addClass
(
'
showDragHandle
'
);
},
function
()
{
jQuery
(
this
).
removeClass
(
'
showDragHandle
'
);
}
function
()
{
$
(
this
).
removeClass
(
'
showDragHandle
'
);
}
);
);
});
});
</script>
</script>
<?php
}
else
{
?>
<?php
}
else
{
?>
<script>
<script>
jQuery
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
jQuery
(
"
.imgup
"
).
hide
();
$
(
"
.imgup
"
).
hide
();
jQuery
(
"
.imgdown
"
).
hide
();
$
(
"
.imgdown
"
).
hide
();
jQuery
(
"
.lineupdown
"
).
removeAttr
(
'
href
'
);
$
(
"
.lineupdown
"
).
removeAttr
(
'
href
'
);
});
});
</script>
</script>
<?php
}
?>
<?php
}
?>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment