diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 8b31e564f5b..46088ab0484 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -191,7 +191,7 @@ if ($conf->commande->enabled) if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) { - $sql .= " AND c.fk_soc = $socid"; + $sql .= " AND c.fk_soc = ".$socid; } $resql = $db->query($sql); @@ -289,7 +289,7 @@ $sql.= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc"; if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) { - $sql .= " AND s.idp = $socid"; + $sql .= " AND s.idp = ".$socid; } $sql .= " ORDER BY a.datep DESC, a.id DESC"; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 3aca5ff3f86..dcb0053d6ad 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -2057,7 +2057,32 @@ class Commande extends CommonObject } - /** + /** + \brief Renvoie nom clicable (avec eventuellement le picto) + \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + \param option Sur quoi pointe le lien + \return string Chaine avec URL + */ + function getNomUrl($withpicto=0,$option='') + { + global $langs; + + $result=''; + + $lien = ''; + $lienfin=''; + + $picto='order'; + $label=$langs->trans("ShowOrder").': '.$this->ref; + + if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); + if ($withpicto && $withpicto != 2) $result.=' '; + $result.=$lien.$this->ref.$lienfin; + return $result; + } + + + /** * \brief Charge les informations d'ordre info dans l'objet commande * \param id Id de la commande a charger */ diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 5e55a49052c..6b1a80c77d5 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -374,9 +374,9 @@ class Facture extends CommonObject if ($this->type == 1) $picto.='r'; if ($this->type == 2) $picto.='a'; - $label=$langs->trans("ShowInvoice"); - if ($this->type == 1) $label=$langs->trans("ShowInvoiceReplace"); - if ($this->type == 2) $label=$langs->trans("ShowInvoiceAvoir"); + $label=$langs->trans("ShowInvoice").': '.$this->ref; + if ($this->type == 1) $label=$langs->trans("ShowInvoiceReplace").': '.$this->ref; + if ($this->type == 2) $label=$langs->trans("ShowInvoiceAvoir").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 864f9101973..e5f1320356c 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -363,6 +363,31 @@ class CommandeFournisseur extends Commande } + /** + \brief Renvoie nom clicable (avec eventuellement le picto) + \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + \param option Sur quoi pointe le lien + \return string Chaine avec URL + */ + function getNomUrl($withpicto=0,$option='') + { + global $langs; + + $result=''; + + $lien = ''; + $lienfin=''; + + $picto='order'; + $label=$langs->trans("ShowOrder").': '.$this->ref; + + if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); + if ($withpicto && $withpicto != 2) $result.=' '; + $result.=$lien.$this->ref.$lienfin; + return $result; + } + + /** * \brief Renvoie la référence de commande suivante non utilisée en fonction du module * de numérotation actif défini dans COMMANDE_SUPPLIER_ADDON diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index f2c09e73136..22d70e2c4c1 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -29,6 +29,8 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.commande.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php'); if (!$user->rights->societe->lire) accessforbidden(); @@ -50,7 +52,9 @@ if ($user->societe_id > 0) * Affichage page */ -$facturestatic=new Facture($db); +$commandestatic=new CommandeFournisseur($db); +$facturestatic=new FactureFournisseur($db); +$companystatic=new Societe($db); llxHeader("",$langs->trans("SuppliersArea")); @@ -59,9 +63,10 @@ print_fiche_titre($langs->trans("SuppliersArea")); print ''; print '"; + print ''; + print ''; + print ''; + + print "\n"; + $i++; + } + print "
'; + /* * Liste des categories - * + * \TODO Il n'y a aucun écran pour les saisir ! */ $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."fournisseur_categorie"; @@ -70,31 +75,35 @@ $sql.= " ORDER BY label ASC"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - print ''; - print '\n"; - $var=True; + $num = $db->num_rows($resql); + $i = 0; - while ($obj = $db->fetch_object($resql)) - { - $var=!$var; - print "\n"; - print '\n"; - } - print "
'; - print $langs->trans("Category"); - print "
'.stripslashes($obj->label).''; - print ''; - print '('.$langs->trans("Stats").')'; - print "
\n"; + if ($num) + { + print ''; + print '\n"; + $var=True; - $db->free($resql); + while ($obj = $db->fetch_object($resql)) + { + $var=!$var; + print "\n"; + print '\n"; + } + print "
'; + print $langs->trans("Category"); + print "
'.stripslashes($obj->label).''; + print ''; + print '('.$langs->trans("Stats").')'; + print "
\n"; + print "
\n"; + } + + $db->free($resql); } else { - dolibarr_print_error($db); + dolibarr_print_error($db); } @@ -112,29 +121,30 @@ $sql.= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - print '
'; - print ''; - print "\n"; - $var=True; + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $var=!$var; + print '
'.$langs->trans("Orders").''.$langs->trans("Nb").' 
'; + print ''; + print "\n"; + $var=True; - print ""; - print ''; - print ''; - print ''; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $var=!$var; - print "\n"; - $i++; - } - print "
'.$langs->trans("Orders").''.$langs->trans("Nb").' 
'.$commande->statuts[$row[1]].''.$row[0].''.$commande->LibStatut($row[1],3).'
"; - $db->free($resql); + print "
'.$commande->statuts[$row[1]].''.$row[0].''.$commande->LibStatut($row[1],3).'
"; + print "
\n"; + $db->free($resql); } else { @@ -142,14 +152,71 @@ else } +/* + * Commandes brouillons + */ +if ($conf->fournisseur->enabled) +{ + $langs->load("orders"); + $sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.idp"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0"; + if ($socid) + { + $sql .= " AND c.fk_soc = ".$socid; + } + + $resql = $db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + if ($num) + { + print ''; + print ''; + print ''; + + $i = 0; + $var = true; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print "'; + print ''; + print ''; + $i++; + $total += $obj->total_ttc; + } + if ($total>0) + { + $var=!$var; + print '"; + } + print "
'.$langs->trans("DraftOrders").'
"; + $commandestatic->id=$obj->rowid; + $commandestatic->ref=$obj->ref; + print $commandestatic->getNomUrl(1,'',16); + print ''; + $companystatic->id=$obj->idp; + $companystatic->nom=$obj->nom; + $companystatic->client=0; + print $companystatic->getNomUrl(1,'',16); + print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."
"; + print "
\n"; + } + } +} + /** * Factures brouillons */ -if ($conf->facture->enabled && $user->rights->fournisseur->facture->lire) +if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) { $sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,"; $sql.= " s.nom, s.idp"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0"; if ($socid) { @@ -163,9 +230,7 @@ if ($conf->facture->enabled && $user->rights->fournisseur->facture->lire) $num = $db->num_rows($resql); if ($num) { - $companystatic=new Societe($db); - - print '
'; + print '
'; print ''; print ''; $i = 0; @@ -184,7 +249,7 @@ if ($conf->facture->enabled && $user->rights->fournisseur->facture->lire) print ''; print ''; @@ -197,7 +262,8 @@ if ($conf->facture->enabled && $user->rights->fournisseur->facture->lire) print ''; print ''; - print "
'.$langs->trans("DraftBills").' ('.$num.')
'; $companystatic->id=$obj->idp; $companystatic->nom=$obj->nom; - $companystatic->client=1; + $companystatic->client=0; print $companystatic->getNomUrl(1,'',16); print ''.price($obj->total_ttc).''.price($tot_ttc).'

"; + print ""; + print "
\n"; } $db->free($resql); } diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 7f0272093cc..eed942072f8 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -153,6 +153,7 @@ update llx_commande set date_livraison = null where date_livraison = '1970-01-01 ALTER TABLE llx_facture_fourn DROP INDEX facnumber; ALTER TABLE llx_facture_fourn ADD UNIQUE INDEX uk_facture_fourn_ref (facnumber, fk_soc); ALTER TABLE llx_facture_fourn ADD note_public text after note; +alter table llx_facture_fourn add column `type` smallint DEFAULT 0 NOT NULL after facnumber; ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_facture (fk_facture_fourn); ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid); diff --git a/mysql/tables/llx_facture_fourn.sql b/mysql/tables/llx_facture_fourn.sql index 6eae6680a7c..14366933429 100644 --- a/mysql/tables/llx_facture_fourn.sql +++ b/mysql/tables/llx_facture_fourn.sql @@ -24,6 +24,7 @@ create table llx_facture_fourn ( rowid integer AUTO_INCREMENT PRIMARY KEY, facnumber varchar(50) NOT NULL, + type smallint DEFAULT 0 NOT NULL, fk_soc integer NOT NULL, datec datetime, -- date de creation de la facture datef date, -- date de la facture