From 84bc3f5b312ae2699576230b514137953dae6006 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Oct 2009 13:33:06 +0000 Subject: [PATCH] Uniformize code. Attached fils for supplier invoices are shown on invoice card --- htdocs/comm/propal.php | 2 +- htdocs/commande/commande.class.php | 24 +++--- htdocs/commande/fiche.php | 6 +- htdocs/document.php | 2 +- htdocs/fourn/commande/document.php | 1 + htdocs/fourn/facture/contact.php | 2 +- htdocs/fourn/facture/document.php | 4 +- htdocs/fourn/facture/fiche.php | 89 +++++++++++++++++++--- htdocs/fourn/facture/note.php | 4 +- htdocs/fourn/fournisseur.facture.class.php | 31 ++++++++ 10 files changed, 132 insertions(+), 33 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 37892228e9d..a7a3442bcd9 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1009,7 +1009,7 @@ if ($id > 0 || ! empty($ref)) $rowspan=9; - // Societe + // Company print ''.$langs->trans('Company').''.$societe->getNomUrl(1).''; print ''; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 7bc39f37caa..878359f6917 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -1601,14 +1601,14 @@ class Commande extends CommonObject } else { - dol_syslog('Commande::cond_reglement Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + dol_syslog('Commande::cond_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR); + $this->error=$this->db->lasterror(); return -1; } } else { - dol_syslog('Commande::cond_reglement, etat commande incompatible'); + dol_syslog('Commande::cond_reglement, etat commande incompatible', LOG_ERR); $this->error='Etat commande incompatible '.$this->statut; return -2; } @@ -1635,24 +1635,24 @@ class Commande extends CommonObject } else { - dol_syslog('Commande::mode_reglement Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + dol_syslog('Commande::mode_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR); + $this->error=$this->db->lasterror(); return -1; } } else { - dol_syslog('Commande::mode_reglement, etat facture incompatible'); + dol_syslog('Commande::mode_reglement, etat facture incompatible', LOG_ERR); $this->error='Etat commande incompatible '.$this->statut; return -2; } } /** - * \brief Positionne numero reference commande client - * \param user Utilisateur qui modifie - * \param ref_client Reference commande client - * \return int <0 si ko, >0 si ok + * \brief Set customer ref + * \param user User that make change + * \param ref_client Customer ref + * \return int <0 if KO, >0 if OK */ function set_ref_client($user, $ref_client) { @@ -1669,8 +1669,8 @@ class Commande extends CommonObject } else { - $this->error=$this->db->error(); - dol_syslog('Commande::set_ref_client Erreur '.$this->error.' - '.$sql); + $this->error=$this->db->lasterror(); + dol_syslog('Commande::set_ref_client Erreur '.$this->error.' - '.$sql, LOG_ERR); return -2; } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f167f655382..5b9a0544f54 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1297,12 +1297,12 @@ else print ''; - if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; + if ($_GET['action'] != 'refcustomer' && $commande->brouillon) print ''; print '
'; print $langs->trans('RefCustomer').''; print ''.img_edit($langs->trans('Modify')).''.img_edit($langs->trans('Modify')).'
'; print ''; - if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder') + if ($user->rights->commande->creer && $_GET['action'] == 'refcustomer') { - print '
'; + print ''; print ''; print ''; print ''; diff --git a/htdocs/document.php b/htdocs/document.php index abd217bb5a5..f455692ab88 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -195,7 +195,7 @@ if ($modulepart) { $accessallowed=1; } - $original_file=$conf->fournisseur->dir_output.'/facture/'.$original_file; + $original_file=$conf->fournisseur->dir_output.'/facture/'.get_exdir(dirname($original_file),2,1).$original_file; //$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE facnumber='$refname'"; } diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 2fb8a8b5580..759ee20c86e 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -34,6 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"; $langs->load('orders'); +$langs->load('other'); $langs->load('sendings'); $langs->load('companies'); $langs->load('bills'); diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 293544674d8..c2e0ff6d410 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -187,7 +187,7 @@ if ($id > 0) print "\n"; // Third party - print "".$langs->trans("Company").""; + print "".$langs->trans("Supplier").""; print ''.$facture->client->getNomUrl(1,'compta').''; print ""; diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 5da9a038faf..ac5f3e9ee95 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -91,7 +91,7 @@ if ($_POST['sendit'] && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Delete if ($action=='delete') { - $facid=$_GET["id"]; + $facid=$_GET['id']; $facture = new FactureFournisseur($db); if ($facture->fetch($facid)) @@ -148,7 +148,7 @@ if ($facid > 0) print "\n"; // Societe - print ''.$langs->trans('Company').''.$facture->fournisseur->getNomUrl(1).''; + print ''.$langs->trans('Supplier').''.$facture->fournisseur->getNomUrl(1).''; print ''.$langs->trans('NbOfAttachedFiles').''.sizeof($filearray).''; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index dbc3e2379e8..b66994b0f95 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -28,6 +28,7 @@ */ require_once('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/product.class.php'); @@ -127,7 +128,15 @@ if ($_REQUEST['action'] == 'confirm_paid' && $_REQUEST['confirm'] == 'yes' && $u { $facturefourn=new FactureFournisseur($db); $facturefourn->fetch($_GET['facid']); - $facturefourn->set_paid($user); + $result=$facturefourn->set_paid($user); +} + +// Set supplier ref +if ($_POST['action'] == 'set_ref_supplier' && $user->rights->fournisseur->facture->creer) +{ + $facturefourn = new FactureFournisseur($db); + $facturefourn->fetch($_GET['facid']); + $result=$facturefourn->set_ref_supplier($user, $_POST['ref_supplier']); } if($_GET['action'] == 'deletepaiement') @@ -397,6 +406,8 @@ if ($_POST['action'] == 'classin') llxHeader('','',''); +$formfile = new FormFile($db); + // Mode creation if ($_GET['action'] == 'create') @@ -515,8 +526,8 @@ else print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -524,15 +535,15 @@ else // Ref print ''; + $rownb=10; + print ''; print ''; - - $rownb=9; - print ''; + print ''; print ''; @@ -665,11 +676,31 @@ else print "\n"; // Ref supplier - print ''; - print "\n"; + print ''; + print ''; // Third party - print ''; + print ''; // Type print ''; print "\n"; - // Soci�t� - print ''; + // Company + print ''; // Note publique print ''; diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 88a2cd0b468..da636d8471a 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -409,6 +409,37 @@ class FactureFournisseur extends Facture } } + /** + * \brief Set supplier ref + * \param user User that make change + * \param ref_supplier Supplier ref + * \return int <0 if KO, >0 if OK + */ + function set_ref_supplier($user, $ref_supplier) + { + if ($user->rights->fournisseur->facture->creer) + { + dol_syslog('FactureFournisseur::set_ref_supplier this->id='.$this->id.', ref_supplier='.$ref_supplier); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn SET facnumber = '.(empty($ref_supplier) ? 'NULL' : '\''.addslashes($ref_supplier).'\''); + $sql.= ' WHERE rowid = '.$this->id; + if ($this->db->query($sql)) + { + $this->ref_supplier = $ref_supplier; + return 1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog('FactureFournisseur::set_ref_supplier '.$this->error.' - '.$sql, LOG_ERR); + return -2; + } + } + else + { + return -1; + } + } /** * \brief Tag la facture comme payee completement
'.$langs->trans('Company').'
'.$langs->trans('Company').''.$societe->getNomUrl(1).''.$langs->trans('NotePublic').'
'.$langs->trans('Ref').''; print $fac->ref.''; + print '
'.$langs->trans('RefSupplier').''; print ''; - print '
'.$langs->trans('Label').''; print '
'.$langs->trans("RefSupplier").''.$fac->ref_supplier.'
'; + print ''; + if ($_GET['action'] != 'refsupplier' && $fac->brouillon) print ''; + print '
'; + print $langs->trans('RefSupplier').''; + print ''.img_edit($langs->trans('Modify')).'
'; + print '
'; + if ($user->rights->fournisseur->facture->creer && $_GET['action'] == 'refsupplier') + { + print ''; + print ''; + print ''; + print ''; + print ' '; + print ''; + } + else + { + print $fac->ref_supplier; + } + print '
'.$langs->trans('Company').''.$societe->getNomUrl(1).' ('.$langs->trans('OtherBills').')
'.$langs->trans('Supplier').''.$societe->getNomUrl(1).' ('.$langs->trans('OtherBills').')
'.$langs->trans('Type').''; @@ -1153,6 +1184,42 @@ else print ''.$langs->trans('Delete').''; } print ''; + + + + if ($_GET['action'] != 'presend') + { + print '
'; + print ''; // ancre + + /* + * Documents generes + */ + $filename=dol_sanitizeFileName($fac->ref); + $filedir=$conf->fournisseur->dir_output.'/facture/'.get_exdir($fac->id,2).$fac->id; + $urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id; + //$genallowed=$user->rights->fournisseur->facture->creer; + $genallowed=false; // TODO Waiting for supplier invoice generation + $delallowed=$user->rights->fournisseur->facture->supprimer; + + $var=true; + + $somethingshown=$formfile->show_documents('facture_fournisseur',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf); + + + print ''; + + print '
'; + + // List of actions on element + /* + include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($fac,'invoice_supplier',$socid); + */ + + print '
'; + } } } diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 2ff6a173723..69621964908 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -109,8 +109,8 @@ if ($_GET["facid"]) print '
'.$langs->trans("RefSupplier").''.$fac->ref_supplier.'
'.$langs->trans('Company').''.$fac->fournisseur->getNomUrl(1).'
'.$langs->trans('Supplier').''.$fac->fournisseur->getNomUrl(1).'
'.$langs->trans("NotePublic").' :