diff --git a/htdocs/comm/action/index.php3 b/htdocs/comm/action/index.php3 index 79cab5a8216..9944f0e2d0a 100644 --- a/htdocs/comm/action/index.php3 +++ b/htdocs/comm/action/index.php3 @@ -39,9 +39,6 @@ llxHeader(); $db = new Db(); -if ($page == -1) { $page = 0 ; } -$limit = $conf->liste_limit; -$offset = $limit * $page ; /* * * @@ -111,34 +108,46 @@ if ($action=='add_action') } - /* * * Liste * */ +if ($page == -1) { $page = 0 ; } +$limit = $conf->liste_limit; +$offset = $limit * $page ; +if ($sortorder == "") +{ + $sortorder="DESC"; +} +if ($sortfield == "") +{ + $sortfield="a.datea"; +} + + if ($socid) { $societe = new Societe($db); $societe->fetch($socid); - print_barre_liste("Liste des actions commerciales effectuées sur " . $societe->nom,$page, $PHP_SELF); - $sql = "SELECT a.id,".$db->pdate("a.datea")." as da, c.libelle, u.code, a.note, u.name, u.firstname "; $sql .= " FROM llx_actioncomm as a, c_actioncomm as c, llx_user as u"; -$sql .= " WHERE a.fk_soc = $socid AND c.id=a.fk_action AND a.fk_user_author = u.rowid"; + $sql .= " WHERE a.fk_soc = $socid AND c.id=a.fk_action AND a.fk_user_author = u.rowid"; if ($type) { $sql .= " AND c.id = $type"; } - $sql .= " ORDER BY a.datea DESC"; + $sql .= " ORDER BY $sortfield $sortorder, rowid DESC "; + $sql .= $db->plimit($limit + 1,$offset); if ( $db->query($sql) ) { $num = $db->num_rows(); + print_barre_liste("Liste des actions commerciales effectuées sur " . $societe->nom,$page, $PHP_SELF,'',$sortfield,$sortorder,'',$num); $i = 0; print '
| Auteur | "; print "