30 |
|
|
31 |
require("./pre.inc.php"); |
require("./pre.inc.php"); |
32 |
|
|
33 |
|
$mesg = ''; |
34 |
|
|
35 |
|
$page = $_GET["page"]; |
36 |
|
$sortfield=$_GET["sortfield"]; |
37 |
|
$sortorder=$_GET["sortorder"]; |
38 |
|
if (! $sortorder) $sortorder="DESC"; |
39 |
|
if (! $sortfield) $sortfield="p.datec"; |
40 |
|
if ($page == -1) $page = 0; |
41 |
|
$limit = $conf->liste_limit; |
42 |
|
$offset = $limit * $page ; |
43 |
|
|
44 |
if ($user->societe_id > 0) |
if ($user->societe_id > 0) |
45 |
{ |
{ |
46 |
$action = ''; |
$action = ''; |
47 |
$socid = $user->societe_id; |
$socid = $user->societe_id; |
48 |
} |
} |
49 |
|
else |
50 |
|
{ |
51 |
|
$socid = 0; |
52 |
|
} |
53 |
|
|
|
llxHeader(); |
|
|
|
|
|
$mesg = ''; |
|
54 |
|
|
55 |
/* |
/* |
56 |
* |
* Affiche fiche |
57 |
* |
* |
58 |
*/ |
*/ |
59 |
|
|
60 |
|
llxHeader(); |
61 |
|
|
62 |
if ($_GET["id"]) |
if ($_GET["id"]) |
63 |
{ |
{ |
64 |
$product = new Product($db); |
$product = new Product($db); |
65 |
$result = $product->fetch($_GET["id"]); |
$result = $product->fetch($_GET["id"]); |
66 |
|
|
67 |
if ( $result ) |
if ( $result > 0) |
68 |
{ |
{ |
69 |
print_fiche_titre($langs->trans("Product").': '.$product->ref, $mesg); |
/* |
70 |
|
* En mode visu |
71 |
print '<table class="border" width="100%"><tr>'; |
*/ |
72 |
print '<td width="20%">'.$langs->trans("Ref").'</td><td width="40%"><a href="../fiche.php?id='.$product->id.'">'.$product->ref.'</a></td>'; |
|
73 |
print '<td><a href="fiche.php?id='.$product->id.'">'.$langs->trans("Statistics").'</a></td></tr>'; |
$h=0; |
74 |
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>'; |
|
75 |
print '<td valign="top" rowspan="2">'; |
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; |
76 |
// Propals |
$head[$h][1] = $langs->trans("Card"); |
77 |
if ($conf->propal->enabled) { |
$h++; |
78 |
$langs->load("propal"); |
|
79 |
print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a> : '.$product->count_propale($socid); |
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; |
80 |
print " (Proposé à ".$product->count_propale_client($socid)." clients)<br>"; |
$head[$h][1] = $langs->trans("Price"); |
81 |
} |
$h++; |
82 |
// Commande |
|
83 |
if ($conf->commande->enabled) { |
if($product->type == 0) |
84 |
$langs->load("orders"); |
{ |
85 |
print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a> : '.$product->count_facture($socid)."<br>"; |
if ($user->rights->barcode->lire) |
86 |
} |
{ |
87 |
// Factures |
if ($conf->barcode->enabled) |
88 |
if ($conf->facture->enabled) { |
{ |
89 |
$langs->load("bills"); |
$head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; |
90 |
print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a> : '.$product->count_facture($socid); |
$head[$h][1] = $langs->trans("BarCode"); |
91 |
} |
$h++; |
92 |
print '</td></tr>'; |
} |
93 |
print '<tr><td>'.$langs->trans("CurrentPrice").'</td><td>'.price($product->price).'</td></tr>'; |
} |
94 |
print "</table>"; |
} |
95 |
|
|
96 |
if ($page == -1) |
|
97 |
{ |
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; |
98 |
$page = 0 ; |
$head[$h][1] = $langs->trans("Photos"); |
99 |
} |
$h++; |
100 |
$limit = $conf->liste_limit; |
|
101 |
$offset = $limit * $page ; |
if($product->type == 0) |
102 |
|
{ |
103 |
if ($sortorder == "") |
if ($conf->stock->enabled) |
104 |
{ |
{ |
105 |
$sortorder="DESC"; |
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; |
106 |
} |
$head[$h][1] = $langs->trans("Stock"); |
107 |
if ($sortfield == "") |
$h++; |
108 |
{ |
} |
109 |
$sortfield="p.datep"; |
} |
110 |
} |
|
111 |
|
if ($conf->fournisseur->enabled) |
112 |
print "<br>"; |
{ |
113 |
print_barre_liste($langs->trans("Proposals"),$page,"propal.php","&id=$product->id",$sortfield,$sortorder); |
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; |
114 |
|
$head[$h][1] = $langs->trans("Suppliers"); |
115 |
$sql = "SELECT distinct(p.rowid), s.nom,s.idp, p.ref,".$db->pdate("p.datep")." as df,p.rowid as facid"; |
$h++; |
116 |
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."propaldet as d WHERE p.fk_soc = s.idp"; |
} |
117 |
$sql .= " AND d.fk_propal = p.rowid AND d.fk_product =".$product->id; |
|
118 |
|
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; |
119 |
if ($socid) |
$head[$h][1] = $langs->trans('Statistics'); |
120 |
{ |
$h++; |
121 |
$sql .= " AND p.fk_soc = $socid"; |
|
122 |
} |
//erics: pour créer des produits composés de x 'sous' produits |
123 |
|
$head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; |
124 |
$sql .= " ORDER BY $sortfield $sortorder "; |
$head[$h][1] = $langs->trans('Packs'); |
125 |
$sql .= $db->plimit( $limit ,$offset); |
$h++; |
126 |
|
|
127 |
$result = $db->query($sql); |
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; |
128 |
if ($result) |
$head[$h][1] = $langs->trans('Referers'); |
129 |
{ |
$hselected=$h; |
130 |
$num = $db->num_rows(); |
$h++; |
131 |
|
|
132 |
$i = 0; |
|
133 |
print "<table class=\"noborder\" width=\"100%\">"; |
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); |
134 |
print '<tr class="liste_titre">'; |
|
135 |
print_liste_field_titre($langs->trans("Ref"),"propal.php","p.rowid","","&id=".$_GET["id"],'',$sortfield); |
print '<table class="border" width="100%"><tr>'; |
136 |
print_liste_field_titre($langs->trans("Company"),"propal.php","s.nom","","&id=".$_GET["id"],'',$sortfield); |
print '<td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">'.$product->ref.'</td>'; |
137 |
print_liste_field_titre($langs->trans("Date"),"propal.php","f.datef","","&id=".$_GET["id"],'align="right"',$sortfield); |
print '</tr>'; |
138 |
print "</tr>\n"; |
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td></tr>'; |
139 |
|
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="3">'.price($product->price).'</td></tr>'; |
140 |
if ($num > 0) |
|
141 |
{ |
// Statut |
142 |
$var=True; |
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'; |
143 |
while ($i < $num) |
if ($product->envente) print $langs->trans("OnSell"); |
144 |
{ |
else print $langs->trans("NotOnSell"); |
145 |
$objp = $db->fetch_object( $i); |
print '</td></tr>'; |
146 |
$var=!$var; |
|
147 |
|
print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>'; |
148 |
print "<tr $bc[$var]>"; |
print '<td align="right" width="25%">'.$langs->trans("NbOfCustomers").'</td>'; |
149 |
print '<td><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$objp->facid.'">'; |
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>'; |
150 |
print img_object($langs->trans("ShowPropal"),"propal").' '; |
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>'; |
151 |
print $objp->ref; |
print '</tr>'; |
152 |
print "</a></td>\n"; |
|
153 |
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.'</a></td>'; |
// Propals |
154 |
print "<td align=\"right\">"; |
if ($conf->propal->enabled) |
155 |
print strftime("%d %B %Y",$objp->df)."</td>"; |
{ |
156 |
print "</tr>\n"; |
$ret=$product->load_stats_propale($socid); |
157 |
$i++; |
if ($ret < 0) dolibarr_print_error($db); |
158 |
} |
$langs->load("propal"); |
159 |
} |
print '<tr><td>'; |
160 |
} |
print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a>'; |
161 |
else |
print '</td><td align="right">'; |
162 |
{ |
print $product->stats_propale['customers']; |
163 |
dolibarr_print_error($db); |
print '</td><td align="right">'; |
164 |
} |
print $product->stats_propale['nb']; |
165 |
print "</table>"; |
print '</td><td align="right">'; |
166 |
$db->free(); |
print $product->stats_propale['qty']; |
167 |
|
print '</td>'; |
168 |
|
print '</tr>'; |
169 |
|
} |
170 |
|
// Commandes |
171 |
|
if ($conf->commande->enabled) |
172 |
|
{ |
173 |
|
$ret=$product->load_stats_commande($socid); |
174 |
|
if ($ret < 0) dolibarr_print_error($db); |
175 |
|
$langs->load("orders"); |
176 |
|
print '<tr><td>'; |
177 |
|
print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a>'; |
178 |
|
print '</td><td align="right">'; |
179 |
|
print $product->stats_commande['customers']; |
180 |
|
print '</td><td align="right">'; |
181 |
|
print $product->stats_commande['nb']; |
182 |
|
print '</td><td align="right">'; |
183 |
|
print $product->stats_commande['qty']; |
184 |
|
print '</td>'; |
185 |
|
print '</tr>'; |
186 |
|
} |
187 |
|
// Contrats |
188 |
|
if ($conf->contrat->enabled) |
189 |
|
{ |
190 |
|
$ret=$product->load_stats_contrat($socid); |
191 |
|
if ($ret < 0) dolibarr_print_error($db); |
192 |
|
$langs->load("contracts"); |
193 |
|
print '<tr><td>'; |
194 |
|
print '<a href="contrat.php?id='.$product->id.'">'.$langs->trans("Contracts").'</a>'; |
195 |
|
print '</td><td align="right">'; |
196 |
|
print $product->stats_contrat['customers']; |
197 |
|
print '</td><td align="right">'; |
198 |
|
print $product->stats_contrat['nb']; |
199 |
|
print '</td><td align="right">'; |
200 |
|
print $product->stats_contrat['qty']; |
201 |
|
print '</td>'; |
202 |
|
print '</tr>'; |
203 |
|
} |
204 |
|
// Factures |
205 |
|
if ($conf->facture->enabled) |
206 |
|
{ |
207 |
|
$ret=$product->load_stats_facture($socid); |
208 |
|
if ($ret < 0) dolibarr_print_error($db); |
209 |
|
$langs->load("bills"); |
210 |
|
print '<tr><td>'; |
211 |
|
print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a>'; |
212 |
|
print '</td><td align="right">'; |
213 |
|
print $product->stats_facture['customers']; |
214 |
|
print '</td><td align="right">'; |
215 |
|
print $product->stats_facture['nb']; |
216 |
|
print '</td><td align="right">'; |
217 |
|
print $product->stats_facture['qty']; |
218 |
|
print '</td>'; |
219 |
|
print '</tr>'; |
220 |
|
} |
221 |
|
|
222 |
|
print "</table>"; |
223 |
|
|
224 |
|
print '</div>'; |
225 |
|
|
226 |
|
print_barre_liste($langs->trans("Proposals"),$page,"propal.php","&id=$product->id",$sortfield,$sortorder); |
227 |
|
|
228 |
|
$sql = "SELECT distinct(p.rowid), s.nom,s.idp, p.ref,".$db->pdate("p.datep")." as df,p.rowid as facid"; |
229 |
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."propaldet as d WHERE p.fk_soc = s.idp"; |
230 |
|
$sql .= " AND d.fk_propal = p.rowid AND d.fk_product =".$product->id; |
231 |
|
|
232 |
|
if ($socid) |
233 |
|
{ |
234 |
|
$sql .= " AND p.fk_soc = $socid"; |
235 |
|
} |
236 |
|
|
237 |
|
$sql .= " ORDER BY $sortfield $sortorder "; |
238 |
|
$sql .= $db->plimit( $limit ,$offset); |
239 |
|
|
240 |
|
$result = $db->query($sql); |
241 |
|
if ($result) |
242 |
|
{ |
243 |
|
$num = $db->num_rows($result); |
244 |
|
|
245 |
|
$i = 0; |
246 |
|
print "<table class=\"noborder\" width=\"100%\">"; |
247 |
|
print '<tr class="liste_titre">'; |
248 |
|
print_liste_field_titre($langs->trans("Ref"),"propal.php","p.rowid","","&id=".$_GET["id"],'',$sortfield); |
249 |
|
print_liste_field_titre($langs->trans("Company"),"propal.php","s.nom","","&id=".$_GET["id"],'',$sortfield); |
250 |
|
print_liste_field_titre($langs->trans("Date"),"propal.php","f.datef","","&id=".$_GET["id"],'align="right"',$sortfield); |
251 |
|
print "</tr>\n"; |
252 |
|
|
253 |
|
if ($num > 0) |
254 |
|
{ |
255 |
|
$var=True; |
256 |
|
while ($i < $num) |
257 |
|
{ |
258 |
|
$objp = $db->fetch_object($result); |
259 |
|
$var=!$var; |
260 |
|
|
261 |
|
print "<tr $bc[$var]>"; |
262 |
|
print '<td><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$objp->facid.'">'; |
263 |
|
print img_object($langs->trans("ShowPropal"),"propal").' '; |
264 |
|
print $objp->ref; |
265 |
|
print "</a></td>\n"; |
266 |
|
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.'</a></td>'; |
267 |
|
print "<td align=\"right\">"; |
268 |
|
print strftime("%d %B %Y",$objp->df)."</td>"; |
269 |
|
print "</tr>\n"; |
270 |
|
$i++; |
271 |
|
} |
272 |
|
} |
273 |
|
} |
274 |
|
else |
275 |
|
{ |
276 |
|
dolibarr_print_error($db); |
277 |
|
} |
278 |
|
print "</table>"; |
279 |
|
$db->free($result); |
280 |
} |
} |
281 |
} |
} |
282 |
else |
else |
283 |
{ |
{ |
284 |
print "Error"; |
dolibarr_print_error(); |
285 |
} |
} |
286 |
|
|
287 |
$db->close(); |
$db->close(); |
288 |
|
|
289 |
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>"); |
llxFooter('$Date$ - $Revision$'); |
290 |
?> |
?> |