diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 410d32a7e7a..940960023ae 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -125,94 +125,44 @@ if ($sortfield == "")
$sortfield="a.datea";
}
+$sql = "SELECT s.nom as societe, s.idp as socidp,a.id,".$db->pdate("a.datea")." as da, a.datea, c.libelle, u.code, a.fk_contact ";
+$sql .= " FROM llx_actioncomm as a, c_actioncomm as c, llx_societe as s, llx_user as u";
+$sql .= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid AND a.percent = 100";
+
+if ($type)
+{
+ $sql .= " AND c.id = $type";
+}
if ($socid)
{
- $societe = new Societe($db);
- $societe->fetch($socid);
-
- $sql = "SELECT a.id,".$db->pdate("a.datea")." as da, c.libelle, u.code, a.note, u.name, u.firstname, a.fk_contact ";
- $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 AND a.percent = 100";
-
- if ($type)
- {
- $sql .= " AND c.id = $type";
- }
-
- $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 '
';
- print '';
- print '| Date | ';
- print "Action | ";
- print 'Contact | ';
- print "
\n";
- $var=True;
-
- while ($i < min($num,$limit))
- {
- $obj = $db->fetch_object( $i);
-
- $var=!$var;
-
- print "";
- print "| " .strftime("%Y %b %d %H:%M",$obj->da)." | \n";
- print ''.$obj->libelle.' | ';
- print '';
- if ($obj->fk_contact)
- {
- $cont = new Contact($db);
- $cont->fetch($obj->fk_contact);
- print ''.$cont->fullname.'';
- }
- else
- {
- print " ";
- }
- print ' | ';
- print "
\n";
-
- $i++;
- }
- print "
";
- $db->free();
- } else {
- print $db->error() . '
' . $sql;
- }
-
+ $sql .= " AND s.idp = $socid";
}
-else
+
+$sql .= " ORDER BY a.datea DESC";
+$sql .= $db->plimit( $limit + 1, $offset);
+
+
+if ( $db->query($sql) )
{
- $sql = "SELECT s.nom as societe, s.idp as socidp,a.id,".$db->pdate("a.datea")." as da, a.datea, c.libelle, u.code, a.fk_contact ";
- $sql .= " FROM llx_actioncomm as a, c_actioncomm as c, llx_societe as s, llx_user as u";
- $sql .= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid AND a.percent = 100";
-
- if ($type)
+ $num = $db->num_rows();
+ if ($socid)
{
- $sql .= " AND c.id = $type";
+ $societe = new Societe($db);
+ $societe->fetch($socid);
+
+ print_barre_liste("Liste des actions commerciales effectuées sur " . $societe->nom, $page, $PHP_SELF,'',$sortfield,$sortorder,'',$num);
}
-
- $sql .= " ORDER BY a.datea 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 "";
- print '';
- print '| Date | ';
- print 'Société | ';
- print 'Action | ';
+ else
+ {
+ print_barre_liste("Liste des actions commerciales", $page, $PHP_SELF,'',$sortfield,$sortorder,'',$num);
+ }
+ $i = 0;
+ print "";
+ print '';
+ print '| Date | ';
+ print 'Société | ';
+ print 'Action | ';
print 'Contact | ';
print "Auteur | ";
print "
\n";
@@ -270,6 +220,7 @@ else
/*
*
*/
+ print ''.$obj->libelle.' | ';
print "$obj->code | \n";
print "\n";
@@ -282,7 +233,7 @@ else
{
print $db->error() . ' ' . $sql ;
}
-}
+
$db->close();