diff --git a/htdocs/telephonie/facture/liste.php b/htdocs/telephonie/facture/liste.php index 1af4390bbc5..9ff641222c5 100644 --- a/htdocs/telephonie/facture/liste.php +++ b/htdocs/telephonie/facture/liste.php @@ -63,18 +63,21 @@ $pagenext = $page + 1; * */ -$sql = "SELECT f.rowid, f.date, f.ligne, f.fourn_montant, f.cout_vente, f.cout_vente_remise, f.gain, f.fk_facture"; +$sql = "SELECT f.rowid, f.date, f.ligne, f.fourn_montant, f.cout_vente, f.gain, f.fk_facture"; $sql .= " ,s.nom, s.idp"; +$sql .= " , fac.facnumber as ref"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; $sql .= " , ".MAIN_DB_PREFIX."societe as s"; +$sql .= " , ".MAIN_DB_PREFIX."facture as fac"; $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; +$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp"; $sql .= " WHERE s.idp = l.fk_soc_facture AND l.rowid = f.fk_ligne"; +$sql .= " AND l.fk_soc_facture = s.idp"; +$sql .= " AND l.fk_client_comm = sp.fk_soc"; +$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1"; -if ($user->rights->telephonie->ligne->lire_restreint) -{ - $sql .= " AND l.fk_commercial_suiv = ".$user->id; -} +$sql .= " AND f.fk_facture = fac.rowid"; if ($_GET["search_ligne"]) { @@ -86,6 +89,11 @@ if ($_GET["search_client"]) $sql .= " AND s.nom LIKE '%".$_GET["search_client"]."%'"; } +if ($_GET["search_facture"]) +{ + $sql .= " AND fac.facnumber LIKE '%".$_GET["search_facture"]."%'"; +} + $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); $result = $db->query($sql); @@ -102,8 +110,12 @@ if ($result) print_liste_field_titre("Ligne","liste.php","l.ligne"); print '