[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 * $Id: facture.php,v 1.33 2005/12/07 15:42:01 hregis Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stats/facture.php,v $ 22 */ 23 24 /** 25 \file htdocs/product/stats/facture.php 26 \ingroup product, service, facture 27 \brief Page des stats des factures pour un produit 28 \version $Revision: 1.33 $ 29 */ 30 31 32 require ("./pre.inc.php"); 33 require_once (DOL_DOCUMENT_ROOT."/facture.class.php"); 34 require_once(DOL_DOCUMENT_ROOT."/product.class.php"); 35 36 $langs->load("bills"); 37 38 $mesg = ''; 39 40 $page = $_GET["page"]; 41 $sortfield=$_GET["sortfield"]; 42 $sortorder=$_GET["sortorder"]; 43 if ($page == -1) { $page = 0 ; } 44 $offset = $conf->liste_limit * $_GET["page"] ; 45 $pageprev = $_GET["page"] - 1; 46 $pagenext = $_GET["page"] + 1; 47 if (! $sortorder) $sortorder="DESC"; 48 if (! $sortfield) $sortfield="f.datef"; 49 50 // Securite 51 $socid = 0; 52 if ($user->societe_id > 0) 53 { 54 $socid = $user->societe_id; 55 } 56 57 58 /* 59 * Affiche fiche 60 * 61 */ 62 63 llxHeader(); 64 65 66 if ($_GET["id"] || $_GET["ref"]) 67 { 68 $product = new Product($db); 69 if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); 70 if ($_GET["id"]) $result = $product->fetch($_GET["id"]); 71 72 if ($result > 0) 73 { 74 /* 75 * En mode visu 76 */ 77 78 $h=0; 79 80 $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; 81 $head[$h][1] = $langs->trans("Card"); 82 $h++; 83 84 $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; 85 $head[$h][1] = $langs->trans("Price"); 86 $h++; 87 88 if($product->type == 0) 89 { 90 if ($user->rights->barcode->lire) 91 { 92 if ($conf->barcode->enabled) 93 { 94 $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; 95 $head[$h][1] = $langs->trans("BarCode"); 96 $h++; 97 } 98 } 99 } 100 101 $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; 102 $head[$h][1] = $langs->trans("Photos"); 103 $h++; 104 105 if($product->type == 0) 106 { 107 if ($conf->stock->enabled) 108 { 109 $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; 110 $head[$h][1] = $langs->trans("Stock"); 111 $h++; 112 } 113 } 114 115 if ($conf->fournisseur->enabled) 116 { 117 $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; 118 $head[$h][1] = $langs->trans("Suppliers"); 119 $h++; 120 } 121 122 $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; 123 $head[$h][1] = $langs->trans('Statistics'); 124 $h++; 125 126 //erics: pour créer des produits composés de x 'sous' produits 127 /* 128 $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; 129 $head[$h][1] = $langs->trans('Packs'); 130 $h++; 131 */ 132 133 $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; 134 $head[$h][1] = $langs->trans('Referers'); 135 $hselected=$h; 136 $h++; 137 138 $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; 139 $head[$h][1] = $langs->trans('Documents'); 140 $h++; 141 142 $titre=$langs->trans("CardProduct".$product->type); 143 dolibarr_fiche_head($head, $hselected, $titre); 144 145 print '<table class="border" width="100%">'; 146 147 // Reference 148 print '<tr>'; 149 print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="3">'; 150 $product->load_previous_next_ref(); 151 $previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':''; 152 $next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':''; 153 if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">'; 154 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>'; 155 if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>'; 156 print '</td>'; 157 print '</tr>'; 158 159 // Libelle 160 print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td>'; 161 print '</tr>'; 162 163 // Prix 164 print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="3">'.price($product->price).'</td></tr>'; 165 166 // Statut 167 print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'; 168 if ($product->envente) print $langs->trans("OnSell"); 169 else print $langs->trans("NotOnSell"); 170 print '</td></tr>'; 171 172 print '<tr><td valign="top" width="28%">'.$langs->trans("Referers").'</td>'; 173 print '<td align="right" width="24%">'.$langs->trans("NbOfCustomers").'</td>'; 174 print '<td align="right" width="24%">'.$langs->trans("NbOfReferers").'</td>'; 175 print '<td align="right" width="24%">'.$langs->trans("TotalQuantity").'</td>'; 176 print '</tr>'; 177 178 // Propals 179 if ($conf->propal->enabled) 180 { 181 $ret=$product->load_stats_propale($socid); 182 if ($ret < 0) dolibarr_print_error($db); 183 $langs->load("propal"); 184 print '<tr><td>'; 185 print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a>'; 186 print '</td><td align="right">'; 187 print $product->stats_propale['customers']; 188 print '</td><td align="right">'; 189 print $product->stats_propale['nb']; 190 print '</td><td align="right">'; 191 print $product->stats_propale['qty']; 192 print '</td>'; 193 print '</tr>'; 194 } 195 // Commandes 196 if ($conf->commande->enabled) 197 { 198 $ret=$product->load_stats_commande($socid); 199 if ($ret < 0) dolibarr_print_error($db); 200 $langs->load("orders"); 201 print '<tr><td>'; 202 print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a>'; 203 print '</td><td align="right">'; 204 print $product->stats_commande['customers']; 205 print '</td><td align="right">'; 206 print $product->stats_commande['nb']; 207 print '</td><td align="right">'; 208 print $product->stats_commande['qty']; 209 print '</td>'; 210 print '</tr>'; 211 } 212 // Contrats 213 if ($conf->contrat->enabled) 214 { 215 $ret=$product->load_stats_contrat($socid); 216 if ($ret < 0) dolibarr_print_error($db); 217 $langs->load("contracts"); 218 print '<tr><td>'; 219 print '<a href="contrat.php?id='.$product->id.'">'.$langs->trans("Contracts").'</a>'; 220 print '</td><td align="right">'; 221 print $product->stats_contrat['customers']; 222 print '</td><td align="right">'; 223 print $product->stats_contrat['nb']; 224 print '</td><td align="right">'; 225 print $product->stats_contrat['qty']; 226 print '</td>'; 227 print '</tr>'; 228 } 229 // Factures 230 if ($conf->facture->enabled) 231 { 232 $ret=$product->load_stats_facture($socid); 233 if ($ret < 0) dolibarr_print_error($db); 234 $langs->load("bills"); 235 print '<tr><td>'; 236 print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a>'; 237 print '</td><td align="right">'; 238 print $product->stats_facture['customers']; 239 print '</td><td align="right">'; 240 print $product->stats_facture['nb']; 241 print '</td><td align="right">'; 242 print $product->stats_facture['qty']; 243 print '</td>'; 244 print '</tr>'; 245 } 246 247 print "</table>"; 248 249 print '</div>'; 250 251 252 $sql = "SELECT distinct(s.nom), s.idp, s.code_client, f.facnumber, f.amount as amount,"; 253 $sql.= " ".$db->pdate("f.datef")." as date, f.paye, f.fk_statut as statut, f.rowid as facid"; 254 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d"; 255 $sql.= " WHERE f.fk_soc = s.idp"; 256 $sql.= " AND d.fk_facture = f.rowid AND d.fk_product =".$product->id; 257 if ($socid) 258 { 259 $sql .= " AND f.fk_soc = $socid"; 260 } 261 $sql.= " ORDER BY $sortfield $sortorder "; 262 $sql.= $db->plimit($conf->liste_limit +1, $offset); 263 264 $result = $db->query($sql); 265 if ($result) 266 { 267 $num = $db->num_rows($result); 268 269 print_barre_liste($langs->trans("Bills"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num); 270 271 $i = 0; 272 print "<table class=\"noborder\" width=\"100%\">"; 273 274 print '<tr class="liste_titre">'; 275 print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.idp","","&id=".$_GET["id"],'',$sortfield); 276 print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield); 277 print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield); 278 print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="center"',$sortfield); 279 print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.amount","","&id=".$_GET["id"],'align="right"',$sortfield); 280 print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$_GET["id"],'align="center"',$sortfield); 281 print "</tr>\n"; 282 283 if ($num > 0) 284 { 285 $var=True; 286 while ($i < $num && $conf->liste_limit) 287 { 288 $objp = $db->fetch_object($result); 289 $var=!$var; 290 291 print "<tr $bc[$var]>"; 292 print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '; 293 print $objp->facnumber; 294 print "</a></td>\n"; 295 print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>'; 296 print "<td>".$objp->code_client."</td>\n"; 297 print "<td align=\"center\">"; 298 print dolibarr_print_date($objp->date)."</td>"; 299 print "<td align=\"right\">".price($objp->amount)."</td>\n"; 300 $fac=new Facture($db); 301 print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->statut,1).'</td>'; 302 print "</tr>\n"; 303 $i++; 304 } 305 } 306 } 307 else 308 { 309 dolibarr_print_error($db); 310 } 311 print "</table>"; 312 print '<br>'; 313 $db->free($result); 314 } 315 } 316 else 317 { 318 dolibarr_print_error(); 319 } 320 321 $db->close(); 322 323 llxFooter('$Date: 2005/12/07 15:42:01 $ - $Revision: 1.33 $'); 324 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |