Ajout onglet notes privées/publiques sur factures fournisseurs

This commit is contained in:
Laurent Destailleur 2006-09-03 20:49:27 +00:00
parent 37e69a2bc8
commit b561530aaf
9 changed files with 99 additions and 72 deletions

View File

@ -44,6 +44,8 @@ class Facture extends CommonObject
{ {
var $db; var $db;
var $element='facture'; var $element='facture';
var $table;
var $tabledetail;
var $id; var $id;
@ -92,6 +94,8 @@ class Facture extends CommonObject
function Facture($DB, $socidp='', $facid='') function Facture($DB, $socidp='', $facid='')
{ {
$this->db = $DB; $this->db = $DB;
$this->table = 'facture';
$this->tabledetail = 'facturedet';
$this->id = $facid; $this->id = $facid;
$this->socidp = $socidp; $this->socidp = $socidp;
@ -106,6 +110,7 @@ class Facture extends CommonObject
$this->remise_exceptionnelle = 0; $this->remise_exceptionnelle = 0;
$this->products = array(); // Tableau de lignes de factures $this->products = array(); // Tableau de lignes de factures
$this->lignes = array();
} }
/** /**
@ -1883,10 +1888,11 @@ class Facture extends CommonObject
*/ */
function update_note($note) function update_note($note)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table;
$sql.= " SET note = '".addslashes($note)."'"; $sql.= " SET note = '".addslashes($note)."'";
$sql.= " WHERE rowid =". $this->id; $sql.= " WHERE rowid =". $this->id;
dolibarr_syslog("Facture.class::update_note sql=$sql");
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->note = $note; $this->note = $note;
@ -1906,10 +1912,11 @@ class Facture extends CommonObject
*/ */
function update_note_public($note_public) function update_note_public($note_public)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table;
$sql.= " SET note_public = '".addslashes($note_public)."'"; $sql.= " SET note_public = '".addslashes($note_public)."'";
$sql.= " WHERE rowid =". $this->id; $sql.= " WHERE rowid =". $this->id;
dolibarr_syslog("Facture.class::update_note_public sql=$sql");
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->note_public = $note_public; $this->note_public = $note_public;

View File

@ -107,13 +107,10 @@ if ($facid > 0)
if ($facture->fetch($facid)) if ($facture->fetch($facid))
{ {
$facture->fetch_fournisseur();
$facref = sanitize_string($facture->ref); $facref = sanitize_string($facture->ref);
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($facture->id,2).$facture->id; $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($facture->id,2).$facture->id;
$societe = new Societe($db);
$societe->fetch($facture->socidp);
$head = facturefourn_prepare_head($facture); $head = facturefourn_prepare_head($facture);
dolibarr_fiche_head($head, 'documents', $langs->trans('SupplierInvoice')); dolibarr_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'));
@ -148,12 +145,17 @@ if ($facid > 0)
print '<table class="border"width="100%">'; print '<table class="border"width="100%">';
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$facture->ref.'</td></tr>'; print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$facture->ref.'</td></tr>';
// Société // Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$facture->fournisseur->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans('NbOfAttachedFiles').'</td><td colspan="3">'.sizeof($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans('NbOfAttachedFiles').'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalSizeOfAttachedFiles').'</td><td colspan="3">'.$totalsize.' '.$langs->trans('bytes').'</td></tr>'; print '<tr><td>'.$langs->trans('TotalSizeOfAttachedFiles').'</td><td colspan="3">'.$totalsize.' '.$langs->trans('bytes').'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';

View File

@ -323,7 +323,7 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
$html->select_societes(empty($_GET['socid'])?'':$_GET['socid'],'socidp','s.fournisseur = 1'); $html->select_societes(empty($_GET['socid'])?'':$_GET['socid'],'socidp','s.fournisseur = 1');
} }
print '</td>'; print '</td>';
print '<td width="50%">'.$langs->trans('Note').'</td></tr>'; print '<td width="50%">'.$langs->trans('NotePublic').'</td></tr>';
print '<tr><td>'.$langs->trans('Ref').'</td><td><input name="facnumber" type="text"></td>'; print '<tr><td>'.$langs->trans('Ref').'</td><td><input name="facnumber" type="text"></td>';
@ -347,6 +347,8 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
print '</table><br>'; print '</table><br>';
if ($conf->global->PRODUCT_SHOW_WHEN_CREATE)
{
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>&nbsp;</td><td>'.$langs->trans('Label').'</td>'; print '<td>&nbsp;</td><td>'.$langs->trans('Label').'</td>';
@ -379,6 +381,8 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
} }
print '</table>'; print '</table>';
}
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>'; print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
print '</form>'; print '</form>';
} }
@ -427,7 +431,7 @@ else
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td>'.$societe->getNomUrl(1).'</td>'; print '<td>'.$societe->getNomUrl(1).'</td>';
print '<td width="50%" valign="top">'.$langs->trans('Comments').'</tr>'; print '<td width="50%" valign="top">'.$langs->trans('NotePublic').'</tr>';
print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">'; print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">';
print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>'; print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
@ -634,12 +638,7 @@ else
print '<tr><td>'.$langs->trans('AmountHT').'</td><td><b>'.price($fac->total_ht).'</b></td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountHT').'</td><td><b>'.price($fac->total_ht).'</b></td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($fac->total_tva).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($fac->total_tva).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($fac->total_ttc).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($fac->total_ttc).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
if (strlen($fac->note))
{
print '<tr><td>'.$langs->trans('Comments').'</td><td colspan="3">';
print nl2br(stripslashes($fac->note));
print '</td></tr>';
}
print '</table>'; print '</table>';
print '</td><td valign="top">'; print '</td><td valign="top">';
@ -792,9 +791,11 @@ else
if ($fac->statut == 0 && $user->rights->fournisseur->facture->valider) if ($fac->statut == 0 && $user->rights->fournisseur->facture->valider)
{ {
if ($_GET['action'] <> 'edit') if (sizeof($fac->lignes) && $_GET['action'] <> 'edit')
{
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=valid">'.$langs->trans('Valid').'</a>'; print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=valid">'.$langs->trans('Valid').'</a>';
} }
}
else else
if ($user->rights->fournisseur->facture->creer) if ($user->rights->fournisseur->facture->creer)
{ {

View File

@ -69,8 +69,12 @@ class FactureFournisseur extends Facture
function FactureFournisseur($DB, $socidp='', $facid='') function FactureFournisseur($DB, $socidp='', $facid='')
{ {
$this->db = $DB ; $this->db = $DB ;
$this->table = 'facture_fourn';
$this->tabledetail = 'facture_fourn_det';
$this->id = $facid;
$this->socidp = $socidp; $this->socidp = $socidp;
$this->products = array();
$this->amount = 0; $this->amount = 0;
$this->remise = 0; $this->remise = 0;
$this->tva = 0; $this->tva = 0;
@ -78,8 +82,8 @@ class FactureFournisseur extends Facture
$this->total_tva = 0; $this->total_tva = 0;
$this->total_ttc = 0; $this->total_ttc = 0;
$this->propalid = 0; $this->propalid = 0;
$this->id = $facid;
$this->products = array();
$this->lignes = array(); $this->lignes = array();
} }
@ -160,12 +164,13 @@ class FactureFournisseur extends Facture
*/ */
function fetch($rowid) function fetch($rowid)
{ {
$sql = 'SELECT libelle, facnumber, amount, remise, '.$this->db->pdate(datef).'as df'; $sql = 'SELECT libelle, facnumber, amount, remise, '.$this->db->pdate(datef).'as df,';
$sql .= ', total_ht, total_tva, total_ttc, fk_user_author'; $sql.= ' total_ht, total_tva, total_ttc, fk_user_author,';
$sql .= ', fk_statut, paye, f.note,'.$this->db->pdate('date_lim_reglement').'as de'; $sql.= ' fk_statut, paye, f.note, f.note_public,';
$sql .= ', s.nom as socnom, s.idp as socidp'; $sql.= ' '.$this->db->pdate('date_lim_reglement').'as de,';
$sql.= ' s.nom as socnom, s.idp as socidp';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn 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 f.rowid='.$rowid.' AND f.fk_soc = s.idp ;'; $sql.= ' WHERE f.rowid='.$rowid.' AND f.fk_soc = s.idp';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -194,6 +199,8 @@ class FactureFournisseur extends Facture
$this->socnom = $obj->socnom; $this->socnom = $obj->socnom;
$this->note = $obj->note; $this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->db->free($resql); $this->db->free($resql);
/* /*

View File

@ -159,7 +159,7 @@ Module700Desc=Gestion des dons
Module800Name=OSCommerce 1 Module800Name=OSCommerce 1
Module800Desc=Interface de visualisation d'une boutique OSCommerce par accès direct en base. Module800Desc=Interface de visualisation d'une boutique OSCommerce par accès direct en base.
Module900Name=OSCommerce 2 Module900Name=OSCommerce 2
Module900Desc=Interface de visualisation d'une boutique OSCommerce via des Web services.\nCe module requiert d'installer les composants dans /oscommerce_ws/ws_server sur OSCommerce. Voir fichier README dans /oscommerce_ws/ws_server. Module900Desc=Interface de visualisation d'une boutique OSCommerce par accès via des Web services.\nCe module requiert d'installer les fichiers de /oscommerce_ws/ws_server sur OSCommerce. Voir fichier README dans /oscommerce_ws/ws_server.
Module1780Name=Catégories Module1780Name=Catégories
Module1780Desc=Gestion des catégories Module1780Desc=Gestion des catégories
Permission11=Consulter les factures Permission11=Consulter les factures

View File

@ -40,6 +40,11 @@ function facturefourn_prepare_head($fac)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Note');
$head[$h][2] = 'note';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$fac->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Documents'); $head[$h][1] = $langs->trans('Documents');
$head[$h][2] = 'documents'; $head[$h][2] = 'documents';

View File

@ -108,6 +108,10 @@ ALTER TABLE `llx_commande` ADD `date_livraison` DATE;
update llx_commande set date_livraison = null where date_livraison = '0000-00-00'; update llx_commande set date_livraison = null where date_livraison = '0000-00-00';
update llx_commande set date_livraison = null where date_livraison = '1970-01-01'; 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_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

@ -21,6 +21,8 @@
-- ============================================================================ -- ============================================================================
ALTER TABLE llx_facture_fourn ADD UNIQUE INDEX uk_facture_fourn_ref (facnumber, fk_soc);
ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_fk_soc (fk_soc); ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_fk_soc (fk_soc);
ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_fk_user_author (fk_user_author); ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_fk_user_author (fk_user_author);
ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_fk_user_valid (fk_user_valid); ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_fk_user_valid (fk_user_valid);

View File

@ -48,6 +48,5 @@ create table llx_facture_fourn
date_lim_reglement date, -- date limite de reglement date_lim_reglement date, -- date limite de reglement
note text, note text,
note_public text
UNIQUE INDEX(facnumber, fk_soc)
)type=innodb; )type=innodb;