63 |
* |
* |
64 |
*/ |
*/ |
65 |
|
|
66 |
$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"; |
67 |
$sql .= " ,s.nom, s.idp"; |
$sql .= " ,s.nom, s.idp"; |
68 |
|
$sql .= " , fac.facnumber as ref"; |
69 |
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; |
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; |
70 |
$sql .= " , ".MAIN_DB_PREFIX."societe as s"; |
$sql .= " , ".MAIN_DB_PREFIX."societe as s"; |
71 |
|
$sql .= " , ".MAIN_DB_PREFIX."facture as fac"; |
72 |
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; |
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; |
73 |
|
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp"; |
74 |
|
|
75 |
$sql .= " WHERE s.idp = l.fk_soc_facture AND l.rowid = f.fk_ligne"; |
$sql .= " WHERE s.idp = l.fk_soc_facture AND l.rowid = f.fk_ligne"; |
76 |
|
$sql .= " AND l.fk_soc_facture = s.idp"; |
77 |
|
$sql .= " AND l.fk_client_comm = sp.fk_soc"; |
78 |
|
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1"; |
79 |
|
|
80 |
if ($user->rights->telephonie->ligne->lire_restreint) |
$sql .= " AND f.fk_facture = fac.rowid"; |
|
{ |
|
|
$sql .= " AND l.fk_commercial_suiv = ".$user->id; |
|
|
} |
|
81 |
|
|
82 |
if ($_GET["search_ligne"]) |
if ($_GET["search_ligne"]) |
83 |
{ |
{ |
89 |
$sql .= " AND s.nom LIKE '%".$_GET["search_client"]."%'"; |
$sql .= " AND s.nom LIKE '%".$_GET["search_client"]."%'"; |
90 |
} |
} |
91 |
|
|
92 |
|
if ($_GET["search_facture"]) |
93 |
|
{ |
94 |
|
$sql .= " AND fac.facnumber LIKE '%".$_GET["search_facture"]."%'"; |
95 |
|
} |
96 |
|
|
97 |
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); |
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); |
98 |
|
|
99 |
$result = $db->query($sql); |
$result = $db->query($sql); |
110 |
|
|
111 |
print_liste_field_titre("Ligne","liste.php","l.ligne"); |
print_liste_field_titre("Ligne","liste.php","l.ligne"); |
112 |
print '<td align="center">Date</td><td align="right">Montant HT</td>'; |
print '<td align="center">Date</td><td align="right">Montant HT</td>'; |
113 |
print '<td align="right">Coût fournisseur HT</td>'; |
|
114 |
print_liste_field_titre("Gain","liste.php","f.gain",'','','align="right"'); |
if ($user->rights->telephonie->ligne->gain) |
115 |
|
{ |
116 |
|
print '<td align="right">Coût fournisseur HT</td>'; |
117 |
|
print_liste_field_titre("Gain","liste.php","f.gain",'','','align="right"'); |
118 |
|
} |
119 |
print '<td align="center">Facture</td>'; |
print '<td align="center">Facture</td>'; |
120 |
print "</tr>\n"; |
print "</tr>\n"; |
121 |
|
|
127 |
print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>'; |
print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>'; |
128 |
|
|
129 |
print '<td> </td>'; |
print '<td> </td>'; |
130 |
print '<td> </td>'; |
|
131 |
print '<td> </td>'; |
if ($user->rights->telephonie->ligne->gain) |
132 |
print '<td> </td>'; |
{ |
133 |
|
print '<td> </td>'; |
134 |
|
print '<td> </td>'; |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
print '<td align="center" ><input type="text" name="search_facture" size="8" maxlength="10" value="'.$_GET["search_facture"].'"></td>'; |
139 |
print '</form>'; |
print '</form>'; |
140 |
print '</tr>'; |
print '</tr>'; |
141 |
|
|
158 |
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n"; |
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n"; |
159 |
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?numero='.$obj->ligne.'">'.dolibarr_print_phone($obj->ligne)."</a></td>\n"; |
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?numero='.$obj->ligne.'">'.dolibarr_print_phone($obj->ligne)."</a></td>\n"; |
160 |
print '<td align="center">'.$obj->date."</td>\n"; |
print '<td align="center">'.$obj->date."</td>\n"; |
161 |
print '<td align="right">'.sprintf("%01.4f",$obj->cout_vente_remise)."</td>\n"; |
print '<td align="right">'.sprintf("%01.4f",$obj->cout_vente)."</td>\n"; |
|
print '<td align="right">'.sprintf("%01.4f",$obj->fourn_montant)."</td>\n"; |
|
162 |
|
|
163 |
print '<td align="right">'; |
if ($user->rights->telephonie->ligne->gain) |
|
if ($obj->gain < 0 && $obj->cout_vente_remise) |
|
|
{ |
|
|
print '<font color="red"><b>'; |
|
|
print sprintf("%01.4f",$obj->gain); |
|
|
print "</b></font>"; |
|
|
} |
|
|
else |
|
164 |
{ |
{ |
165 |
print sprintf("%01.4f",$obj->gain); |
print '<td align="right">'.sprintf("%01.4f",$obj->fourn_montant)."</td>\n"; |
166 |
|
|
167 |
|
print '<td align="right">'; |
168 |
|
if ($obj->gain < 0 && $obj->cout_vente) |
169 |
|
{ |
170 |
|
print '<font color="red"><b>'; |
171 |
|
print sprintf("%01.4f",$obj->gain); |
172 |
|
print "</b></font>"; |
173 |
|
} |
174 |
|
else |
175 |
|
{ |
176 |
|
print sprintf("%01.4f",$obj->gain); |
177 |
|
} |
178 |
|
print "</td>\n"; |
179 |
} |
} |
180 |
print "</td>\n"; |
print '<td align="center"><a href="'.DOL_URL_ROOT.'/telephonie/client/facture.php?facid='.$obj->fk_facture.'">'.$obj->ref."</a></td>\n"; |
|
print '<td align="center"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->fk_facture.'">'.$obj->fk_facture."</a></td>\n"; |
|
181 |
print "</tr>\n"; |
print "</tr>\n"; |
182 |
$i++; |
$i++; |
183 |
} |
} |