From b561530aaf2ea81e82ecc986ec75a08270637562 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2006 20:49:27 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20onglet=20notes=20priv=E9es/publiques=20?= =?UTF-8?q?sur=20factures=20fournisseurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/facture.class.php | 15 ++- htdocs/fourn/facture/document.php | 14 +-- htdocs/fourn/facture/fiche.php | 101 +++++++++++---------- htdocs/fourn/fournisseur.facture.class.php | 23 +++-- htdocs/langs/fr_FR/admin.lang | 2 +- htdocs/lib/fourn.lib.php | 5 + mysql/migration/2.0.0-2.1.0.sql | 4 + mysql/tables/llx_facture_fourn.key.sql | 2 + mysql/tables/llx_facture_fourn.sql | 5 +- 9 files changed, 99 insertions(+), 72 deletions(-) diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 769e77c06b6..2d1b6444ab1 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -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; diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 5aa08f73dad..8ddd5a4a3f9 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -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 ''; + // Ref print ''; + // Société - print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Ref').''.$facture->ref.'
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans('Company').''.$facture->fournisseur->getNomUrl(1).'
'.$langs->trans('NbOfAttachedFiles').''.sizeof($filearray).'
'.$langs->trans('TotalSizeOfAttachedFiles').''.$totalsize.' '.$langs->trans('bytes').'
'; print ''; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index d8cbc42af7e..a7eb5efd823 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -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='
'.$langs->trans("ErrorQtyTooLowForThisSupplier").'
'; } } @@ -258,7 +258,7 @@ if ($_GET['action'] == 'add_ligne') if (! $_POST['label']) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Label")).'
'; - } + } 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 ''; - print ''.$langs->trans('Note').''; + print ''.$langs->trans('NotePublic').''; print ''.$langs->trans('Ref').''; @@ -347,38 +347,42 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy') print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - 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 ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } + print '
 '.$langs->trans('Label').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('VATRate').''.$langs->trans('PriceUTTC').'
'.$i.''; - $html->select_tva('tauxtva'.$i,'',$societe,$mysoc); - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
 '.$langs->trans('Label').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('VATRate').''.$langs->trans('PriceUTTC').'
'; + 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 ''.$i.''; + print ''; + print ''; + print ''; + print ''; + $html->select_tva('tauxtva'.$i,'',$societe,$mysoc); + print ''; + print ''; + } + + print ''; + } + print '
'; print ''; } @@ -405,7 +409,7 @@ else llxHeader('','', $addons); if ($mesg) { print $mesg.'
'; } - + if ($_GET['action'] == 'edit' || $_GET['action'] == 'delete_product_line') { @@ -427,7 +431,7 @@ else print ''.$langs->trans('Company').''; print ''.$societe->getNomUrl(1).''; - print ''.$langs->trans('Comments').''; + print ''.$langs->trans('NotePublic').''; print ''.$langs->trans('Ref').''; print ''; @@ -567,7 +571,7 @@ else print ''; } - print ''; + print ''; } 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 '
'; } - + /* * Confirmation de la suppression de la facture fournisseur */ @@ -605,7 +609,7 @@ else * Facture */ print ''; - + // Ref print ""; print "\n"; @@ -634,12 +638,7 @@ else print ''; print ''; print ''; - if (strlen($fac->note)) - { - print ''; - } + print '
".$langs->trans("Ref")."".$fac->ref."
'.$langs->trans('AmountHT').''.price($fac->total_ht).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountVAT').''.price($fac->total_tva).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($fac->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Comments').''; - print nl2br(stripslashes($fac->note)); - print '
'; print ''; @@ -792,8 +791,10 @@ else if ($fac->statut == 0 && $user->rights->fournisseur->facture->valider) { - if ($_GET['action'] <> 'edit') - print ''.$langs->trans('Valid').''; + if (sizeof($fac->lignes) && $_GET['action'] <> 'edit') + { + print ''.$langs->trans('Valid').''; + } } else if ($user->rights->fournisseur->facture->creer) diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 8944e76fd8b..b8592e6ac30 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -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); /* diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 23342d9f0fd..e9db6532a78 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -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 diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php index 78c61d78b20..e8c1d930af0 100644 --- a/htdocs/lib/fourn.lib.php +++ b/htdocs/lib/fourn.lib.php @@ -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'; diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 63f910de1aa..e00848d8ef0 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -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); diff --git a/mysql/tables/llx_facture_fourn.key.sql b/mysql/tables/llx_facture_fourn.key.sql index 86d9224e59a..7d8aeb20f6e 100644 --- a/mysql/tables/llx_facture_fourn.key.sql +++ b/mysql/tables/llx_facture_fourn.key.sql @@ -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); diff --git a/mysql/tables/llx_facture_fourn.sql b/mysql/tables/llx_facture_fourn.sql index 4ff8099418c..6eae6680a7c 100644 --- a/mysql/tables/llx_facture_fourn.sql +++ b/mysql/tables/llx_facture_fourn.sql @@ -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;