Ajout liste commandes brouillons sur espace fournisseur

This commit is contained in:
Laurent Destailleur 2007-03-29 20:07:44 +00:00
parent 6daa166771
commit 617b2e038f
7 changed files with 173 additions and 55 deletions

View File

@ -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 (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) if ($socid)
{ {
$sql .= " AND c.fk_soc = $socid"; $sql .= " AND c.fk_soc = ".$socid;
} }
$resql = $db->query($sql); $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 (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) if ($socid)
{ {
$sql .= " AND s.idp = $socid"; $sql .= " AND s.idp = ".$socid;
} }
$sql .= " ORDER BY a.datep DESC, a.id DESC"; $sql .= " ORDER BY a.datep DESC, a.id DESC";

View File

@ -2057,6 +2057,31 @@ 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 = '<a href="'.DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$this->id.'">';
$lienfin='</a>';
$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 * \brief Charge les informations d'ordre info dans l'objet commande
* \param id Id de la commande a charger * \param id Id de la commande a charger

View File

@ -374,9 +374,9 @@ class Facture extends CommonObject
if ($this->type == 1) $picto.='r'; if ($this->type == 1) $picto.='r';
if ($this->type == 2) $picto.='a'; if ($this->type == 2) $picto.='a';
$label=$langs->trans("ShowInvoice"); $label=$langs->trans("ShowInvoice").': '.$this->ref;
if ($this->type == 1) $label=$langs->trans("ShowInvoiceReplace"); if ($this->type == 1) $label=$langs->trans("ShowInvoiceReplace").': '.$this->ref;
if ($this->type == 2) $label=$langs->trans("ShowInvoiceAvoir"); if ($this->type == 2) $label=$langs->trans("ShowInvoiceAvoir").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$this->id.'">';
$lienfin='</a>';
$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 * \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 * de numérotation actif défini dans COMMANDE_SUPPLIER_ADDON

View File

@ -29,6 +29,8 @@
*/ */
require("./pre.inc.php"); 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) if (!$user->rights->societe->lire)
accessforbidden(); accessforbidden();
@ -50,7 +52,9 @@ if ($user->societe_id > 0)
* Affichage page * Affichage page
*/ */
$facturestatic=new Facture($db); $commandestatic=new CommandeFournisseur($db);
$facturestatic=new FactureFournisseur($db);
$companystatic=new Societe($db);
llxHeader("",$langs->trans("SuppliersArea")); llxHeader("",$langs->trans("SuppliersArea"));
@ -59,9 +63,10 @@ print_fiche_titre($langs->trans("SuppliersArea"));
print '<table border="0" width="100%" class="notopnoleftnoright">'; print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="30%" class="notopnoleft">'; print '<tr><td valign="top" width="30%" class="notopnoleft">';
/* /*
* Liste des categories * Liste des categories
* * \TODO Il n'y a aucun écran pour les saisir !
*/ */
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."fournisseur_categorie"; $sql.= " FROM ".MAIN_DB_PREFIX."fournisseur_categorie";
@ -73,6 +78,8 @@ if ($resql)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num)
{
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'; print '<tr class="liste_titre"><td colspan="2">';
print $langs->trans("Category"); print $langs->trans("Category");
@ -89,6 +96,8 @@ if ($resql)
print "</tr>\n"; print "</tr>\n";
} }
print "</table>\n"; print "</table>\n";
print "<br>\n";
}
$db->free($resql); $db->free($resql);
} }
@ -115,7 +124,7 @@ if ($resql)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
print '<br/><table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Orders").'</td><td align="center">'.$langs->trans("Nb").'</td><td>&nbsp;</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Orders").'</td><td align="center">'.$langs->trans("Nb").'</td><td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$var=True; $var=True;
@ -128,12 +137,13 @@ if ($resql)
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.$commande->statuts[$row[1]].'</td>'; print '<td>'.$commande->statuts[$row[1]].'</td>';
print '<td align="center">'.$row[0].'</td>'; print '<td align="center">'.$row[0].'</td>';
print '<td align="center"><a href="commande/liste.php?statut='.$row[1].'">'.$commande->LibStatut($row[1],3).'</a></td>'; print '<td align="center"><a href="'.DOL_URL_ROOT.'/fourn/commande/liste.php?statut='.$row[1].'">'.$commande->LibStatut($row[1],3).'</a></td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
print "</table>"; print "</table>";
print "<br>\n";
$db->free($resql); $db->free($resql);
} }
else 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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("DraftOrders").'</td></tr>';
$i = 0;
$var = true;
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td nowrap>";
$commandestatic->id=$obj->rowid;
$commandestatic->ref=$obj->ref;
print $commandestatic->getNomUrl(1,'',16);
print '</td>';
print '<td>';
$companystatic->id=$obj->idp;
$companystatic->nom=$obj->nom;
$companystatic->client=0;
print $companystatic->getNomUrl(1,'',16);
print '</td>';
print '<td align="right" nowrap="nowrap">'.price($obj->total_ttc).'</td></tr>';
$i++;
$total += $obj->total_ttc;
}
if ($total>0)
{
$var=!$var;
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
}
print "</table>";
print "<br>\n";
}
}
}
/** /**
* Factures brouillons * 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 = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,";
$sql.= " s.nom, s.idp"; $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"; $sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0";
if ($socid) if ($socid)
{ {
@ -163,9 +230,7 @@ if ($conf->facture->enabled && $user->rights->fournisseur->facture->lire)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num)
{ {
$companystatic=new Societe($db); print '<table class="noborder" width="100%">';
print '<br/><table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>'; print '<td colspan="3">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>';
$i = 0; $i = 0;
@ -184,7 +249,7 @@ if ($conf->facture->enabled && $user->rights->fournisseur->facture->lire)
print '<td>'; print '<td>';
$companystatic->id=$obj->idp; $companystatic->id=$obj->idp;
$companystatic->nom=$obj->nom; $companystatic->nom=$obj->nom;
$companystatic->client=1; $companystatic->client=0;
print $companystatic->getNomUrl(1,'',16); print $companystatic->getNomUrl(1,'',16);
print '</td>'; print '</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>'; print '<td align="right">'.price($obj->total_ttc).'</td>';
@ -197,7 +262,8 @@ if ($conf->facture->enabled && $user->rights->fournisseur->facture->lire)
print '<td colspan="2" align="right">'.price($tot_ttc).'</td>'; print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
print '</tr>'; print '</tr>';
print "</table><br>"; print "</table>";
print "<br>\n";
} }
$db->free($resql); $db->free($resql);
} }

View File

@ -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 DROP INDEX facnumber;
ALTER TABLE llx_facture_fourn ADD UNIQUE INDEX uk_facture_fourn_ref (facnumber, fk_soc); 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 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 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); ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid);

View File

@ -24,6 +24,7 @@ create table llx_facture_fourn
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
facnumber varchar(50) NOT NULL, facnumber varchar(50) NOT NULL,
type smallint DEFAULT 0 NOT NULL,
fk_soc integer NOT NULL, fk_soc integer NOT NULL,
datec datetime, -- date de creation de la facture datec datetime, -- date de creation de la facture
datef date, -- date de la facture datef date, -- date de la facture