Ajout onglet notes prives/publiques sur factures fournisseurs
This commit is contained in:
parent
37e69a2bc8
commit
b561530aaf
@ -44,7 +44,9 @@ class Facture extends CommonObject
|
||||
{
|
||||
var $db;
|
||||
var $element='facture';
|
||||
|
||||
var $table;
|
||||
var $tabledetail;
|
||||
|
||||
var $id;
|
||||
|
||||
var $socidp; // Id client
|
||||
@ -91,7 +93,9 @@ class Facture extends CommonObject
|
||||
*/
|
||||
function Facture($DB, $socidp='', $facid='')
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->db = $DB;
|
||||
$this->table = 'facture';
|
||||
$this->tabledetail = 'facturedet';
|
||||
|
||||
$this->id = $facid;
|
||||
$this->socidp = $socidp;
|
||||
@ -106,6 +110,7 @@ class Facture extends CommonObject
|
||||
$this->remise_exceptionnelle = 0;
|
||||
|
||||
$this->products = array(); // Tableau de lignes de factures
|
||||
$this->lignes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1883,10 +1888,11 @@ class Facture extends CommonObject
|
||||
*/
|
||||
function update_note($note)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table;
|
||||
$sql.= " SET note = '".addslashes($note)."'";
|
||||
$sql.= " WHERE rowid =". $this->id;
|
||||
|
||||
dolibarr_syslog("Facture.class::update_note sql=$sql");
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->note = $note;
|
||||
@ -1906,10 +1912,11 @@ class Facture extends CommonObject
|
||||
*/
|
||||
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.= " WHERE rowid =". $this->id;
|
||||
|
||||
dolibarr_syslog("Facture.class::update_note_public sql=$sql");
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->note_public = $note_public;
|
||||
|
||||
@ -107,13 +107,10 @@ if ($facid > 0)
|
||||
|
||||
if ($facture->fetch($facid))
|
||||
{
|
||||
$facture->fetch_fournisseur();
|
||||
|
||||
$facref = sanitize_string($facture->ref);
|
||||
|
||||
$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);
|
||||
dolibarr_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'));
|
||||
|
||||
@ -148,12 +145,17 @@ if ($facid > 0)
|
||||
|
||||
|
||||
print '<table class="border"width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$facture->ref.'</td></tr>';
|
||||
|
||||
// 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('TotalSizeOfAttachedFiles').'</td><td colspan="3">'.$totalsize.' '.$langs->trans('bytes').'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
@ -222,7 +222,7 @@ if ($_GET['action'] == 'mod_ligne')
|
||||
if ($_GET['etat'] == '1' && !$_GET['cancel']) // si on valide la modification
|
||||
{
|
||||
$facfou = new FactureFournisseur($db,'',$_GET['facid']);
|
||||
|
||||
|
||||
$facfou->updateline($_GET['ligne_id'], $_POST['label'], $_POST['puht'], $_POST['tauxtva'], $_POST['qty']);
|
||||
}
|
||||
$_GET['action'] = 'edit';
|
||||
@ -236,11 +236,11 @@ if ($_GET['action'] == 'add_ligne')
|
||||
{
|
||||
$nv_prod = new Product($db);
|
||||
$nv_prod->fetch($_POST['idprod']);
|
||||
|
||||
|
||||
// cas spécial pour lequel on a les meme référence que le fournisseur
|
||||
// $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle;
|
||||
$label = $nv_prod->libelle;
|
||||
|
||||
|
||||
$result=$nv_prod->get_buyprice($_POST['fourn_id'], $_POST['qty']);
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -248,7 +248,7 @@ if ($_GET['action'] == 'add_ligne')
|
||||
}
|
||||
if ($result == -1)
|
||||
{
|
||||
// Quantité insuffisante
|
||||
// Quantité insuffisante
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorQtyTooLowForThisSupplier").'</div>';
|
||||
}
|
||||
}
|
||||
@ -258,7 +258,7 @@ if ($_GET['action'] == 'add_ligne')
|
||||
if (! $_POST['label'])
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Label")).'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($_POST['amount']))
|
||||
@ -273,7 +273,7 @@ if ($_GET['action'] == 'add_ligne')
|
||||
$facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$_GET['action'] = 'edit';
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
|
||||
$html->select_societes(empty($_GET['socid'])?'':$_GET['socid'],'socidp','s.fournisseur = 1');
|
||||
}
|
||||
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>';
|
||||
|
||||
@ -347,38 +347,42 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td> </td><td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
for ($i = 1 ; $i < 9 ; $i++)
|
||||
if ($conf->global->PRODUCT_SHOW_WHEN_CREATE)
|
||||
{
|
||||
if ($_GET['action'] == 'copy')
|
||||
{
|
||||
$value_label = $fac_ori->lignes[$i-1][0];
|
||||
$value_pu = $fac_ori->lignes[$i-1][1];
|
||||
$value_qty = $fac_ori->lignes[$i-1][3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value_qty = '1';
|
||||
}
|
||||
print '<tr><td>'.$i.'</td>';
|
||||
print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>';
|
||||
print '<td align="right"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>';
|
||||
print '<td align="right"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva'.$i,'',$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>';
|
||||
}
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td> </td><td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
for ($i = 1 ; $i < 9 ; $i++)
|
||||
{
|
||||
if ($_GET['action'] == 'copy')
|
||||
{
|
||||
$value_label = $fac_ori->lignes[$i-1][0];
|
||||
$value_pu = $fac_ori->lignes[$i-1][1];
|
||||
$value_qty = $fac_ori->lignes[$i-1][3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value_qty = '1';
|
||||
}
|
||||
print '<tr><td>'.$i.'</td>';
|
||||
print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>';
|
||||
print '<td align="right"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>';
|
||||
print '<td align="right"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva'.$i,'',$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
|
||||
print '</form>';
|
||||
}
|
||||
@ -405,7 +409,7 @@ else
|
||||
llxHeader('','', $addons);
|
||||
|
||||
if ($mesg) { print $mesg.'<br>'; }
|
||||
|
||||
|
||||
|
||||
if ($_GET['action'] == 'edit' || $_GET['action'] == 'delete_product_line')
|
||||
{
|
||||
@ -427,7 +431,7 @@ else
|
||||
print '<tr><td>'.$langs->trans('Company').'</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 '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
|
||||
@ -567,7 +571,7 @@ else
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -588,7 +592,7 @@ else
|
||||
$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $fac->ref), 'confirm_valid');
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de la facture fournisseur
|
||||
*/
|
||||
@ -605,7 +609,7 @@ else
|
||||
* Facture
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
||||
// Ref
|
||||
print "<tr><td>".$langs->trans("Ref")."</td><td colspan=\"3\">".$fac->ref."</td>";
|
||||
print "</tr>\n";
|
||||
@ -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('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>';
|
||||
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 '</td><td valign="top">';
|
||||
@ -792,8 +791,10 @@ else
|
||||
|
||||
if ($fac->statut == 0 && $user->rights->fournisseur->facture->valider)
|
||||
{
|
||||
if ($_GET['action'] <> 'edit')
|
||||
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&action=valid">'.$langs->trans('Valid').'</a>';
|
||||
if (sizeof($fac->lignes) && $_GET['action'] <> 'edit')
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&action=valid">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
if ($user->rights->fournisseur->facture->creer)
|
||||
|
||||
@ -69,8 +69,12 @@ class FactureFournisseur extends Facture
|
||||
function FactureFournisseur($DB, $socidp='', $facid='')
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->table = 'facture_fourn';
|
||||
$this->tabledetail = 'facture_fourn_det';
|
||||
|
||||
$this->id = $facid;
|
||||
$this->socidp = $socidp;
|
||||
$this->products = array();
|
||||
|
||||
$this->amount = 0;
|
||||
$this->remise = 0;
|
||||
$this->tva = 0;
|
||||
@ -78,8 +82,8 @@ class FactureFournisseur extends Facture
|
||||
$this->total_tva = 0;
|
||||
$this->total_ttc = 0;
|
||||
$this->propalid = 0;
|
||||
$this->id = $facid;
|
||||
|
||||
$this->products = array();
|
||||
$this->lignes = array();
|
||||
}
|
||||
|
||||
@ -160,12 +164,13 @@ class FactureFournisseur extends Facture
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = 'SELECT libelle, facnumber, amount, remise, '.$this->db->pdate(datef).'as df';
|
||||
$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 .= ', s.nom as socnom, s.idp as socidp';
|
||||
$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 = 'SELECT libelle, facnumber, amount, remise, '.$this->db->pdate(datef).'as df,';
|
||||
$sql.= ' total_ht, total_tva, total_ttc, fk_user_author,';
|
||||
$sql.= ' fk_statut, paye, f.note, f.note_public,';
|
||||
$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.= ' WHERE f.rowid='.$rowid.' AND f.fk_soc = s.idp';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -194,6 +199,8 @@ class FactureFournisseur extends Facture
|
||||
|
||||
$this->socnom = $obj->socnom;
|
||||
$this->note = $obj->note;
|
||||
$this->note_public = $obj->note_public;
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
/*
|
||||
|
||||
@ -159,7 +159,7 @@ Module700Desc=Gestion des dons
|
||||
Module800Name=OSCommerce 1
|
||||
Module800Desc=Interface de visualisation d'une boutique OSCommerce par accès direct en base.
|
||||
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
|
||||
Module1780Desc=Gestion des catégories
|
||||
Permission11=Consulter les factures
|
||||
|
||||
@ -40,6 +40,11 @@ function facturefourn_prepare_head($fac)
|
||||
$head[$h][2] = 'card';
|
||||
$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][1] = $langs->trans('Documents');
|
||||
$head[$h][2] = 'documents';
|
||||
|
||||
@ -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 = '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 CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid);
|
||||
|
||||
|
||||
@ -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_user_author (fk_user_author);
|
||||
ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_fk_user_valid (fk_user_valid);
|
||||
|
||||
@ -47,7 +47,6 @@ create table llx_facture_fourn
|
||||
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)
|
||||
date_lim_reglement date, -- date limite de reglement
|
||||
|
||||
note text,
|
||||
|
||||
UNIQUE INDEX(facnumber, fk_soc)
|
||||
note text,
|
||||
note_public text
|
||||
)type=innodb;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user