From 8c4fd1f0ad5063bf62728f02a4f58a9d9402c122 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Oct 2009 02:15:37 +0000 Subject: [PATCH] Qual: Better compatibility with other databases --- htdocs/product.class.php | 4 + htdocs/product/stats/commande.php | 200 +++++++++--------- htdocs/product/stats/commande_fournisseur.php | 30 ++- htdocs/product/stats/contrat.php | 182 ++++++++-------- htdocs/product/stats/facture.php | 18 +- htdocs/product/stats/facture_fournisseur.php | 19 +- htdocs/product/stats/propal.php | 191 ++++++++--------- 7 files changed, 319 insertions(+), 325 deletions(-) diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 64c86848232..b6e4491ee5c 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -2381,6 +2381,8 @@ class Product extends CommonObject */ function is_photo_available($sdir) { + include_once(DOL_DOCUMENT_ROOT ."/lib/files.lib.php"); + $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; $dir = $sdir . '/'. $pdir; @@ -2408,6 +2410,8 @@ class Product extends CommonObject */ function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5) { + include_once(DOL_DOCUMENT_ROOT ."/lib/files.lib.php"); + $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; $dir = $sdir . '/'. $pdir; $dirthumb = $dir.'thumbs/'; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 95fa54dd0a6..f06a43d221a 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,12 +19,11 @@ */ /** - \file htdocs/product/stats/commande.php - \ingroup product, service, commande - \brief Page des stats des commandes clients pour un produit - \version $Id$ -*/ - + * \file htdocs/product/stats/commande.php + * \ingroup product, service, commande + * \brief Page des stats des commandes clients pour un produit + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); @@ -54,54 +53,53 @@ $offset = $conf->liste_limit * $_GET["page"] ; $pageprev = $_GET["page"] - 1; $pagenext = $_GET["page"] + 1; if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="c.date_creation"; +if (! $sortfield) $sortfield="c.date_commande"; /* - * Affiche fiche - * + * View */ -$html = new Form($db); +$html = new Form($db); if ($_GET["id"] || $_GET["ref"]) { - $product = new Product($db); - if ($_GET["ref"]) - { - $result = $product->fetch('',$_GET["ref"]); - $_GET["id"]=$product->id; - } - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); + $product = new Product($db); + if ($_GET["ref"]) + { + $result = $product->fetch('',$_GET["ref"]); + $_GET["id"]=$product->id; + } + if ($_GET["id"]) $result = $product->fetch($_GET["id"]); - llxHeader("","",$langs->trans("CardProduct".$product->type)); + llxHeader("","",$langs->trans("CardProduct".$product->type)); - if ($result > 0) - { - /* - * En mode visu - */ + if ($result > 0) + { + /* + * En mode visu + */ $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); - print ''; + print '
'; - // Reference - print ''; - print ''; + print ''; - print ''; + print ''; + print ''; // Libelle - print ''; - print ''; + print ''; + print ''; - // Prix - print ''; - // Statut - print ''; + print ''; show_stats_for_company($product,$socid); - print "
'.$langs->trans("Ref").''; + // Reference + print '
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''; + // Prix + print '
'.$langs->trans("SellingPrice").''; if ($product->price_base_type == 'TTC') { print price($product->price_ttc).' '.$langs->trans($product->price_base_type); @@ -112,90 +110,90 @@ if ($_GET["id"] || $_GET["ref"]) } print '
'.$langs->trans("Status").''; + // Statut + print '
'.$langs->trans("Status").''; print $product->getLibStatut(2); - print '
"; + print ""; - print ''; + print ''; - $sql = "SELECT distinct(s.nom), s.rowid as socid, s.code_client, c.rowid, c.total_ht as total_ht, c.ref,"; - $sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.facture, c.rowid as commandeid"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."commandedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND s.entity = ".$conf->entity; - $sql.= " AND d.fk_commande = c.rowid"; - $sql.= " AND d.fk_product =".$product->id; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, c.rowid, c.total_ht as total_ht, c.ref,"; + $sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."commandedet as d"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND d.fk_commande = c.rowid"; + $sql.= " AND d.fk_product =".$product->id; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + $sql.= " ORDER BY $sortfield $sortorder "; + $sql.= $db->plimit($conf->liste_limit +1, $offset); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); - print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); - $i = 0; - print ""; + $i = 0; + print "
"; - print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.date_creation","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.total_ht","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print "\n"; + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"c.date_commande","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.total_ht","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); + print "\n"; - $commandestatic=new Commande($db); + $commandestatic=new Commande($db); - if ($num > 0) - { - $var=True; - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($result); - $var=!$var; + if ($num > 0) + { + $var=True; + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($result); + $var=!$var; - print ""; - print '\n"; - print ''; - print "\n"; - print ""; - print "\n"; - print ''; - print "\n"; - $i++; - } - } - } - else - { - dol_print_error($db); - } - print "
'.img_object($langs->trans("ShowOrder"),"order").' '; - print $objp->ref; - print "'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'".$objp->code_client.""; - print dol_print_date($objp->date)."".price($objp->total_ht)."'.$commandestatic->LibStatut($objp->statut,$objp->facture,5).'
"; - print '
'; - $db->free($result); - } + print ""; + print ''.img_object($langs->trans("ShowOrder"),"order").' '; + print $objp->ref; + print "\n"; + print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).''; + print "".$objp->code_client."\n"; + print ""; + print dol_print_date($db->jdate($objp->date_commande)).""; + print "".price($objp->total_ht)."\n"; + print ''.$commandestatic->LibStatut($objp->statut,$objp->facture,5).''; + print "\n"; + $i++; + } + } + } + else + { + dol_print_error($db); + } + print ""; + print '
'; + $db->free($result); + } } else { - dol_print_error(); + dol_print_error(); } $db->close(); diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 65f4d0dc3f9..a1c5b2b0a52 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,13 +19,12 @@ */ /** - \file htdocs/product/stats/commande_fournisseur.php - \ingroup product, service, commande - \brief Page des stats des commandes fournisseurs pour un produit - \version $Id$ + * \file htdocs/product/stats/commande_fournisseur.php + * \ingroup product, service, commande + * \brief Page des stats des commandes fournisseurs pour un produit + * \version $Id$ */ - require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); @@ -54,13 +53,13 @@ $offset = $conf->liste_limit * $_GET["page"] ; $pageprev = $_GET["page"] - 1; $pagenext = $_GET["page"] + 1; if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="c.date_creation"; +if (! $sortfield) $sortfield="c.date_commande"; /* - * Affiche fiche - * + * View */ + $html = new Form($db); if ($_GET["id"] || $_GET["ref"]) @@ -77,9 +76,7 @@ if ($_GET["id"] || $_GET["ref"]) if ($result > 0) { - /* - * En mode visu - */ + $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); @@ -118,8 +115,9 @@ if ($_GET["id"] || $_GET["ref"]) print ""; print ''; - $sql = "SELECT distinct(s.nom), s.rowid as socid, s.code_client, c.rowid, c.total_ht as total_ht, c.ref,"; - $sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.rowid as commandeid"; + $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; + $sql.= " c.rowid, c.total_ht as total_ht, c.ref,"; + $sql.= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; @@ -148,7 +146,7 @@ if ($_GET["id"] || $_GET["ref"]) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.date_creation","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"c.date_commande","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.total_ht","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); print "\n"; @@ -170,7 +168,7 @@ if ($_GET["id"] || $_GET["ref"]) print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).''; print "".$objp->code_client."\n"; print ""; - print dol_print_date($objp->date).""; + print dol_print_date($db->jdate($objp->date_commande)).""; print "".price($objp->total_ht)."\n"; print ''.$commandestatic->LibStatut($objp->statut,$objp->facture,5).''; print "\n"; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index b4261e0b19e..b11a4a0bb51 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -68,40 +68,38 @@ $html = new Form($db); if ($_GET["id"] || $_GET["ref"]) { $product = new Product($db); - if ($_GET["ref"]) - { - $result = $product->fetch('',$_GET["ref"]); - $_GET["id"]=$product->id; - } - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); + if ($_GET["ref"]) + { + $result = $product->fetch('',$_GET["ref"]); + $_GET["id"]=$product->id; + } + if ($_GET["id"]) $result = $product->fetch($_GET["id"]); - llxHeader("","",$langs->trans("CardProduct".$product->type)); + llxHeader("","",$langs->trans("CardProduct".$product->type)); - if ($result > 0) - { - /* - * En mode visu - */ - $head=product_prepare_head($product,$user); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); - dol_fiche_head($head, 'referers', $titre, 0, $picto); + if ($result > 0) + { - print ''; + $head=product_prepare_head($product,$user); + $titre=$langs->trans("CardProduct".$product->type); + $picto=($product->type==1?'service':'product'); + dol_fiche_head($head, 'referers', $titre, 0, $picto); - // Reference - print ''; - print '
'.$langs->trans("Ref").''; + print ''; + + // Reference + print ''; + print ''; - print ''; + print ''; + print ''; - // Libelle - print ''; - print ''; + // Libelle + print ''; + print ''; - // Prix - print ''; - // Statut - print ''; + print ''; show_stats_for_company($product,$socid); - print "
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''; + // Prix + print '
'.$langs->trans("SellingPrice").''; if ($product->price_base_type == 'TTC') { print price($product->price_ttc).' '.$langs->trans($product->price_base_type); @@ -112,97 +110,97 @@ if ($_GET["id"] || $_GET["ref"]) } print '
'.$langs->trans("Status").''; + // Statut + print '
'.$langs->trans("Status").''; print $product->getLibStatut(2); - print '
"; + print "
"; - print ''; + print ''; - $sql = "SELECT"; + $sql = "SELECT"; $sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; $sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > ".$db->idate(mktime()),1,0).') as nb_running,'; $sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= ".$db->idate(mktime()).")",1,0).') as nb_late,'; $sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,'; - $sql.= " ".$db->pdate("c.datec")." as date, c.statut as statut, c.rowid as rowid,"; + $sql.= " c.rowid as rowid, c.date_contrat, c.statut as statut,"; $sql.= " s.nom, s.rowid as socid, s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; - $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd"; + $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; + $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " WHERE c.rowid = cd.fk_contrat"; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND cd.fk_product =".$product->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.rowid"; + $sql.= " GROUP BY c.rowid, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; $sql.= " ORDER BY $sortfield $sortorder"; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql.= $db->plimit($conf->liste_limit +1, $offset); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); - print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); - $i = 0; - print ""; + $i = 0; + print "
"; - print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.datec","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.amount","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print ''; - print ''; - print ''; - print "\n"; + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"c.date_contrat","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.amount","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); + print ''; + print ''; + print ''; + print "\n"; - $contratstatic=new Contrat($db); + $contratstatic=new Contrat($db); - if ($num > 0) - { - $var=True; - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($result); - $var=!$var; + if ($num > 0) + { + $var=True; + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($result); + $var=!$var; - print ""; - print '\n"; - print ''; - print "\n"; - print ""; - //print "\n"; - //print ''; - print ''; - print ''; - //$contratstatic->LibStatut($objp->statut,5).''; - print "\n"; - $i++; - } - } - } - else - { - dol_print_error($db); - } - print "
'.$staticcontratligne->LibStatut(0,3).''.$staticcontratligne->LibStatut(4,3).''.$staticcontratligne->LibStatut(5,3).'
'.$staticcontratligne->LibStatut(0,3).''.$staticcontratligne->LibStatut(4,3).''.$staticcontratligne->LibStatut(5,3).'
'.img_object($langs->trans("ShowContract"),"contract").' '; - print $objp->rowid; - print "'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'".$objp->code_client.""; - print dol_print_date($objp->date)."".price($objp->total_ht)."'; - print ''.($objp->nb_initial>0?$objp->nb_initial:'').''.($objp->nb_running+$objp->nb_late>0?$objp->nb_running+$objp->nb_late:'').''.($objp->nb_closed>0?$objp->nb_closed:'').'
"; - print '
'; - $db->free($result); - } + print ""; + print ''.img_object($langs->trans("ShowContract"),"contract").' '; + print $objp->rowid; + print "\n"; + print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).''; + print "".$objp->code_client."\n"; + print ""; + print dol_print_date($db->jdate($objp->date_contrat)).""; + //print "".price($objp->total_ht)."\n"; + //print ''; + print ''.($objp->nb_initial>0?$objp->nb_initial:'').''; + print ''.($objp->nb_running+$objp->nb_late>0?$objp->nb_running+$objp->nb_late:'').''; + print ''.($objp->nb_closed>0?$objp->nb_closed:'').''; + //$contratstatic->LibStatut($objp->statut,5).''; + print "\n"; + $i++; + } + } + } + else + { + dol_print_error($db); + } + print ""; + print '
'; + $db->free($result); + } } else { diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index b9e360318a5..38c7d4414e8 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -19,13 +19,12 @@ */ /** - \file htdocs/product/stats/facture.php - \ingroup product, service, facture - \brief Page des stats des factures clients pour un produit - \version $Id$ + * \file htdocs/product/stats/facture.php + * \ingroup product, service, facture + * \brief Page des stats des factures clients pour un produit + * \version $Id$ */ - require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); @@ -125,8 +124,9 @@ if ($_GET["id"] || $_GET["ref"]) print ''; - $sql = "SELECT distinct(s.nom), s.rowid as socid, s.code_client, f.facnumber, f.total as total_ht,"; - $sql.= " ".$db->pdate("f.datef")." as date, f.paye, f.fk_statut as statut, f.rowid as facid"; + $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; + $sql.= " f.facnumber, f.total as total_ht,"; + $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -155,7 +155,7 @@ if ($_GET["id"] || $_GET["ref"]) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); print "\n"; @@ -177,7 +177,7 @@ if ($_GET["id"] || $_GET["ref"]) print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).''; print "".$objp->code_client."\n"; print ""; - print dol_print_date($objp->date).""; + print dol_print_date($db->jdate($objp->datef),'day').""; print "".price($objp->total_ht)."\n"; print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).''; print "\n"; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 3d813060a21..b46829f2882 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -19,12 +19,11 @@ */ /** - \file htdocs/product/stats/facture_fournisseur.php - \ingroup product, service, facture - \brief Page des stats des factures fournisseurs pour un produit - \version $Id$ -*/ - + * \file htdocs/product/stats/facture_fournisseur.php + * \ingroup product, service, facture + * \brief Page des stats des factures fournisseurs pour un produit + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); @@ -126,8 +125,8 @@ if ($_GET["id"] || $_GET["ref"]) print ''; - $sql = "SELECT distinct(s.nom), s.rowid as socid, s.code_client, f.facnumber, f.total_ht as total_ht,"; - $sql.= " ".$db->pdate("f.datef")." as date, f.paye, f.fk_statut as statut, f.rowid as facid"; + $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, f.facnumber, f.total_ht as total_ht,"; + $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; @@ -156,7 +155,7 @@ if ($_GET["id"] || $_GET["ref"]) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); print "\n"; @@ -178,7 +177,7 @@ if ($_GET["id"] || $_GET["ref"]) print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).''; print "".$objp->code_client."\n"; print ""; - print dol_print_date($objp->date).""; + print dol_print_date($db->jdate($objp->datef)).""; print "".price($objp->total_ht)."\n"; $fac=new Facture($db); print ''.$fac->LibStatut($objp->paye,$objp->statut,5).''; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 214d265d9d9..d7507d366e1 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,11 +19,11 @@ */ /** - \file htdocs/product/stats/propal.php - \ingroup product, service, propal - \brief Page des stats des propals pour un produit - \version $Id$ -*/ + * \file htdocs/product/stats/propal.php + * \ingroup product, service, propal + * \brief Page des stats des propals pour un produit + * \version $Id$ + */ require("./pre.inc.php"); @@ -53,53 +53,50 @@ $offset = $conf->liste_limit * $_GET["page"] ; $pageprev = $_GET["page"] - 1; $pagenext = $_GET["page"] + 1; if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="p.datec"; +if (! $sortfield) $sortfield="p.datep"; /* - * Affiche fiche - * + * View */ $html = new Form($db); if ($_GET["id"] || $_GET["ref"]) { - $product = new Product($db); - if ($_GET["ref"]) - { - $result = $product->fetch('',$_GET["ref"]); - $_GET["id"]=$product->id; - } - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); + $product = new Product($db); + if ($_GET["ref"]) + { + $result = $product->fetch('',$_GET["ref"]); + $_GET["id"]=$product->id; + } + if ($_GET["id"]) $result = $product->fetch($_GET["id"]); - llxHeader("","",$langs->trans("CardProduct".$product->type)); + llxHeader("","",$langs->trans("CardProduct".$product->type)); + + if ( $result > 0) + { - if ( $result > 0) - { - /* - * En mode visu - */ $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'referers', $titre,0,$picto); - print ''; + print '
'; - // Reference - print ''; - print ''; + print ''; - print ''; + print ''; + print ''; // Libelle - print ''; - print ''; + print ''; + print ''; - // Prix - print ''; - // Statut - print ''; + print ''; show_stats_for_company($product,$socid); - print "
'.$langs->trans("Ref").''; + // Reference + print '
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''; + // Prix + print '
'.$langs->trans("SellingPrice").''; if ($product->price_base_type == 'TTC') { print price($product->price_ttc).' '.$langs->trans($product->price_base_type); @@ -110,87 +107,87 @@ if ($_GET["id"] || $_GET["ref"]) } print '
'.$langs->trans("Status").''; + // Statut + print '
'.$langs->trans("Status").''; print $product->getLibStatut(2); - print '
"; + print ""; - print ''; + print ''; - $sql = "SELECT distinct(s.nom), s.rowid as socid, p.rowid as propalid, p.ref, p.total as amount,"; - $sql.= $db->pdate("p.datec")." as date, p.fk_statut as statut"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ",".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."propaldet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND s.entity = ".$conf->entity; - $sql.= " AND d.fk_propal = p.rowid"; - $sql.= " AND d.fk_product =".$product->id; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND p.fk_soc = ".$socid; - $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql = "SELECT distinct s.nom, s.rowid as socid, p.rowid as propalid, p.ref, p.total as amount,"; + $sql.= "p.datep, p.fk_statut as statut"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ",".MAIN_DB_PREFIX."propal as p"; + $sql.= ", ".MAIN_DB_PREFIX."propaldet as d"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.fk_soc = s.rowid"; + $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND d.fk_propal = p.rowid"; + $sql.= " AND d.fk_product =".$product->id; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND p.fk_soc = ".$socid; + $sql.= " ORDER BY $sortfield $sortorder "; + $sql.= $db->plimit($conf->liste_limit +1, $offset); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); - print_barre_liste($langs->trans("Proposals"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("Proposals"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); - $i = 0; - print ""; - print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"p.datec","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"p.total","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print "\n"; + $i = 0; + print "
"; + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.rowid","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePropal"),$_SERVER["PHP_SELF"],"p.datep","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"p.total","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); + print "\n"; - $propalstatic=new Propal($db); + $propalstatic=new Propal($db); - if ($num > 0) - { - $var=True; - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($result); - $var=!$var; + if ($num > 0) + { + $var=True; + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($result); + $var=!$var; - print ""; - print '\n"; - print ''; - print ""; - print "\n"; - print ''; - print "\n"; - $i++; - } - } - } - else - { - dol_print_error($db); - } - print "
'.img_object($langs->trans("ShowPropal"),"propal").' '; - print $objp->ref; - print "'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'"; - print dol_print_date($objp->date)."".price($objp->amount)."'.$propalstatic->LibStatut($objp->statut,5).'
"; - print '
'; - $db->free($result); - } + print ""; + print ''.img_object($langs->trans("ShowPropal"),"propal").' '; + print $objp->ref; + print "\n"; + print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).''; + print ""; + print dol_print_date($db->jdate($objp->datep)).""; + print "".price($objp->amount)."\n"; + print ''.$propalstatic->LibStatut($objp->statut,5).''; + print "\n"; + $i++; + } + } + } + else + { + dol_print_error($db); + } + print ""; + print '
'; + $db->free($result); + } } else { - dol_print_error(); + dol_print_error(); } $db->close();