Qual: Uniformize look of supplier invoice with customer invoice

This commit is contained in:
eldy 2011-10-01 21:55:40 +02:00
parent 4d4be413af
commit 79546fa072
7 changed files with 962 additions and 1026 deletions

View File

@ -79,9 +79,9 @@ $hookmanager=new HookManager($db);
$hookmanager->callHooks(array('invoicecard')); $hookmanager->callHooks(array('invoicecard'));
/******************************************************************************/ /*
/* Actions */ * Actions
/******************************************************************************/ */
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@ -239,7 +239,7 @@ if ($action == 'setmode')
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->mode_reglement($_POST['mode_reglement_id']); $result=$object->mode_reglement($_POST['mode_reglement_id']);
if ($result < 0) dol_print_error($object->db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
if ($action == 'setinvoicedate') if ($action == 'setinvoicedate')
@ -248,7 +248,7 @@ if ($action == 'setinvoicedate')
$object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']); $object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']);
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date;
$result=$object->update($user); $result=$object->update($user);
if ($result < 0) dol_print_error($object->db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
if ($action == 'setpaymentterm') if ($action == 'setpaymentterm')
@ -256,14 +256,14 @@ if ($action == 'setpaymentterm')
$object->fetch($id); $object->fetch($id);
$date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']); $date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
$result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement); $result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement);
if ($result < 0) dol_print_error($object->db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
if ($action == 'setconditions') if ($action == 'setconditions')
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->cond_reglement($_POST['cond_reglement_id']); $result=$object->cond_reglement($_POST['cond_reglement_id']);
if ($result < 0) dol_print_error($object->db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
if ($action == 'setremisepercent' && $user->rights->facture->creer) if ($action == 'setremisepercent' && $user->rights->facture->creer)

View File

@ -97,14 +97,14 @@ class Form
* @param string $preselected Preselected value for parameter * @param string $preselected Preselected value for parameter
* @param string $paramkey Key of parameter (unique if there is several parameter to show) * @param string $paramkey Key of parameter (unique if there is several parameter to show)
* @param boolean $perm Permission to allow button to edit parameter * @param boolean $perm Permission to allow button to edit parameter
* @param string $typeofdata Type of data ('string' by default, 'email', 'text', ...) * @param string $typeofdata Type of data ('string' by default, 'email', 'text', 'day', ...)
* @param string $editvalue Use this value instead $preselected * @param string $editvalue Use this value instead $preselected
* @return string HTML edit field * @return string HTML edit field
* TODO no GET or POST in class file, use a param * TODO no GET or POST in class file, use a param
*/ */
function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='') function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='')
{ {
global $langs; global $langs,$db;
$ret=''; $ret='';
if (GETPOST('action') == 'edit'.$htmlname) if (GETPOST('action') == 'edit'.$htmlname)
{ {
@ -123,14 +123,20 @@ class Form
{ {
$ret.='<textarea name="'.$htmlname.'">'.($editvalue?$editvalue:$preselected).'</textarea>'; $ret.='<textarea name="'.$htmlname.'">'.($editvalue?$editvalue:$preselected).'</textarea>';
} }
else if ($typeofdata == 'day')
{
$html=new Form($db);
$ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname);
}
$ret.='</td>'; $ret.='</td>';
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; if ($typeofdata != 'day') $ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
$ret.='</tr></table>'."\n"; $ret.='</tr></table>'."\n";
$ret.='</form>'."\n"; $ret.='</form>'."\n";
} }
else else
{ {
if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1); if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1);
if ($typeofdata == 'day') $ret.=dol_print_date($preselected,'day');
else $ret.=$preselected; else $ret.=$preselected;
} }
return $ret; return $ret;
@ -238,7 +244,7 @@ class Form
/** /**
* Return combo list of activated countries, into language of user * Return combo list of activated countries, into language of user
* *
* @param selected Id or Code or Label of preselected country * @param selected Id or Code or Label of preselected country
* @param htmlname Name of html select object * @param htmlname Name of html select object
* @param htmloption Options html on select object * @param htmloption Options html on select object
@ -250,7 +256,7 @@ class Form
/** /**
* Return combo list of activated countries, into language of user * Return combo list of activated countries, into language of user
* *
* @param selected Id or Code or Label of preselected country * @param selected Id or Code or Label of preselected country
* @param htmlname Name of html select object * @param htmlname Name of html select object
* @param htmloption Options html on select object * @param htmloption Options html on select object
@ -320,7 +326,7 @@ class Form
/** /**
* Retourne la liste des types de comptes financiers * Retourne la liste des types de comptes financiers
* *
* @param selected Type pre-selectionne * @param selected Type pre-selectionne
* @param htmlname Nom champ formulaire * @param htmlname Nom champ formulaire
*/ */
@ -356,7 +362,7 @@ class Form
/** /**
* Return list of social contributions. * Return list of social contributions.
* Use mysoc->pays_id or mysoc->pays_code so they must be defined. * Use mysoc->pays_id or mysoc->pays_code so they must be defined.
* *
* @param selected Preselected type * @param selected Preselected type
* @param htmlname Name of field in form * @param htmlname Name of field in form
* @param useempty Set to 1 if we want an empty value * @param useempty Set to 1 if we want an empty value
@ -426,7 +432,7 @@ class Form
/** /**
* Return list of types of lines (product or service) * Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module) * Example: 0=product, 1=service, 9=other (for external module)
* *
* @param selected Preselected type * @param selected Preselected type
* @param htmlname Name of field in html form * @param htmlname Name of field in html form
* @param showempty Add an empty field * @param showempty Add an empty field
@ -517,7 +523,7 @@ class Form
/** /**
* Output html form to select a third party * Output html form to select a third party
* *
* @param selected Preselected type * @param selected Preselected type
* @param htmlname Name of field in form * @param htmlname Name of field in form
* @param filter Optionnal filters criteras * @param filter Optionnal filters criteras
@ -532,7 +538,7 @@ class Form
/** /**
* Output html form to select a third party * Output html form to select a third party
* *
* @param selected Preselected type * @param selected Preselected type
* @param htmlname Name of field in form * @param htmlname Name of field in form
* @param filter Optionnal filters criteras * @param filter Optionnal filters criteras
@ -608,7 +614,7 @@ class Form
/** /**
* Return HTML combo list of absolute discounts * Return HTML combo list of absolute discounts
* *
* @param selected Id remise fixe pre-selectionnee * @param selected Id remise fixe pre-selectionnee
* @param htmlname Nom champ formulaire * @param htmlname Nom champ formulaire
* @param filter Criteres optionnels de filtre * @param filter Criteres optionnels de filtre
@ -674,7 +680,7 @@ class Form
/** /**
* Return list of all contacts (for a third party or all) * Return list of all contacts (for a third party or all)
* *
* @param socid Id ot third party or 0 for all * @param socid Id ot third party or 0 for all
* @param selected Id contact pre-selectionne * @param selected Id contact pre-selectionne
* @param htmlname Name of HTML field ('none' for a not editable field) * @param htmlname Name of HTML field ('none' for a not editable field)
@ -900,7 +906,7 @@ class Form
/** /**
* Return list of products for customer in Ajax if Ajax activated or go to select_produits_do * Return list of products for customer in Ajax if Ajax activated or go to select_produits_do
* *
* @param selected Preselected products * @param selected Preselected products
* @param htmlname Name of HTML seletc field (must be unique in page) * @param htmlname Name of HTML seletc field (must be unique in page)
* @param filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
@ -1425,7 +1431,7 @@ class Form
/** /**
* Return list of delivery address * Return list of delivery address
* *
* @param string $selected Id contact pre-selectionn * @param string $selected Id contact pre-selectionn
* @param int $socid Id of company * @param int $socid Id of company
* @param string $htmlname Name of HTML field * @param string $htmlname Name of HTML field
@ -1477,7 +1483,7 @@ class Form
/** /**
* Charge dans cache la liste des conditions de paiements possibles * Charge dans cache la liste des conditions de paiements possibles
* *
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/ */
function load_cache_conditions_paiements() function load_cache_conditions_paiements()
@ -1516,7 +1522,7 @@ class Form
/** /**
* Charge dans cache la liste des délais de livraison possibles * Charge dans cache la liste des délais de livraison possibles
* *
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/ */
function load_cache_availability() function load_cache_availability()
@ -1555,7 +1561,7 @@ class Form
/** /**
* Retourne la liste des types de delais de livraison possibles * Retourne la liste des types de delais de livraison possibles
* *
* @param selected Id du type de delais pre-selectionne * @param selected Id du type de delais pre-selectionne
* @param htmlname Nom de la zone select * @param htmlname Nom de la zone select
* @param filtertype To add a filter * @param filtertype To add a filter
@ -1588,7 +1594,7 @@ class Form
/** /**
* Load into cache cache_demand_reason, array of input reasons * Load into cache cache_demand_reason, array of input reasons
* *
* @return int Nb of lines loaded, 0 if already loaded, <0 if ko * @return int Nb of lines loaded, 0 if already loaded, <0 if ko
*/ */
function load_cache_demand_reason() function load_cache_demand_reason()
@ -1632,7 +1638,7 @@ class Form
/** /**
* Return list of events that triggered an object creation * Return list of events that triggered an object creation
* *
* @param selected Id du type d'origine pre-selectionne * @param selected Id du type d'origine pre-selectionne
* @param htmlname Nom de la zone select * @param htmlname Nom de la zone select
* @param exclude To exclude a code value (Example: SRC_PROP) * @param exclude To exclude a code value (Example: SRC_PROP)
@ -1667,7 +1673,7 @@ class Form
/** /**
* Charge dans cache la liste des types de paiements possibles * Charge dans cache la liste des types de paiements possibles
* *
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/ */
function load_cache_types_paiements() function load_cache_types_paiements()

View File

@ -432,7 +432,7 @@ class FormFile
if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && $modulepart != 'unpaid') if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && $modulepart != 'unpaid')
{ {
$langs->load("errors"); $langs->load("errors");
$out.= ' '.img_warning($langs->trans("WarningNoDocumentModelActivated")); $out.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
} }
$out.= '</td>'; $out.= '</td>';

View File

@ -57,10 +57,10 @@ class FactureFournisseur extends Facture
var $author; var $author;
var $libelle; var $libelle;
var $datec; var $datec; // Creation date
var $tms; var $tms; // Last update date
var $date; var $date; // Invoice date
var $date_echeance; var $date_echeance; // Max payment date
var $amount; var $amount;
var $remise; var $remise;
var $tva; var $tva;
@ -184,17 +184,18 @@ class FactureFournisseur extends Facture
{ {
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
$this->updateline($idligne, $this->updateline(
$this->lines[$i]->description, $idligne,
$this->lines[$i]->pu_ht, $this->lines[$i]->description,
$this->lines[$i]->tva_tx, $this->lines[$i]->pu_ht,
$this->lines[$i]->localtax1_tx, $this->lines[$i]->tva_tx,
$this->lines[$i]->localtax2_tx, $this->lines[$i]->localtax1_tx,
$this->lines[$i]->qty, $this->lines[$i]->localtax2_tx,
$this->lines[$i]->fk_product, $this->lines[$i]->qty,
'HT', $this->lines[$i]->fk_product,
$this->lines[$i]->info_bits, 'HT',
$this->lines[$i]->product_type $this->lines[$i]->info_bits,
$this->lines[$i]->product_type
); );
} }
} }
@ -246,10 +247,12 @@ class FactureFournisseur extends Facture
/** /**
* Load object in memory from database * Load object in memory from database
* @param id id object *
* @return int <0 if KO, >0 if OK * @param int $id Id supplier invoice
* @param string $ref Ref supplier invoice
* @return int <0 if KO, >0 if OK
*/ */
function fetch($id) function fetch($id='',$ref='')
{ {
global $langs; global $langs;
$sql = "SELECT"; $sql = "SELECT";
@ -287,7 +290,9 @@ class FactureFournisseur extends Facture
$sql.= " t.import_key,"; $sql.= " t.import_key,";
$sql.= ' s.nom as socnom, s.rowid as socid'; $sql.= ' s.nom as socnom, s.rowid as socid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t,'.MAIN_DB_PREFIX.'societe as s'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t,'.MAIN_DB_PREFIX.'societe as s';
$sql.= ' WHERE t.rowid='.$id.' AND t.fk_soc = s.rowid'; if ($id) $sql.= " WHERE t.rowid=".$id;
if ($ref) $sql.= " WHERE t.rowid='".$this->db->escape($ref)."'"; // ref is id (facnumber is supplier ref)
$sql.= ' AND t.fk_soc = s.rowid';
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -369,8 +374,9 @@ class FactureFournisseur extends Facture
/** /**
* \brief Load this->lines * Load this->lines
* \return int 1 si ok, < 0 si erreur *
* @return int 1 si ok, < 0 si erreur
*/ */
function fetch_lines() function fetch_lines()
{ {
@ -433,10 +439,11 @@ class FactureFournisseur extends Facture
/** /**
* \brief Update database * Update database
* \param user User that modify *
* \param notrigger 0=launch triggers after, 1=disable triggers * @param User $user User that modify
* \return int <0 if KO, >0 if OK * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/ */
function update($user=0, $notrigger=0) function update($user=0, $notrigger=0)
{ {
@ -486,7 +493,7 @@ class FactureFournisseur extends Facture
$sql.= " fk_soc=".(isset($this->fk_soc)?$this->fk_soc:"null").","; $sql.= " fk_soc=".(isset($this->fk_soc)?$this->fk_soc:"null").",";
$sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql.= " datef=".(dol_strlen($this->date)!=0 ? "'".$this->db->idate($this->date)."'" : 'null').","; $sql.= " datef=".(dol_strlen($this->date)!=0 ? "'".$this->db->idate($this->date)."'" : 'null').",";
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; if (dol_strlen($this->tms) != 0) $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
$sql.= " libelle=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " libelle=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " paye=".(isset($this->paye)?$this->paye:"null").","; $sql.= " paye=".(isset($this->paye)?$this->paye:"null").",";
$sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; $sql.= " amount=".(isset($this->amount)?$this->amount:"null").",";

File diff suppressed because it is too large Load Diff

View File

@ -19,9 +19,16 @@
/** /**
* \file htdocs/lib/fourn.lib.php * \file htdocs/lib/fourn.lib.php
* \brief Ensemble de fonctions de base pour le module fournisseur * \brief Functions used by supplier invoice module
* \ingroup supplier
*/ */
/**
* Initialize the array of tabs for supplier invoice
*
* @param Facture $object Invoice object
* @return array Array of head tabs
*/
function facturefourn_prepare_head($object) function facturefourn_prepare_head($object)
{ {
global $langs, $conf; global $langs, $conf;
@ -29,7 +36,7 @@ function facturefourn_prepare_head($object)
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Card'); $head[$h][1] = $langs->trans('CardBill');
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;

View File

@ -18,10 +18,16 @@
/** /**
* \file htdocs/lib/invoice.lib.php * \file htdocs/lib/invoice.lib.php
* \brief Ensemble de fonctions de base pour le module factures * \brief Functions used by invoice module
* \ingroup invoice * \ingroup invoice
*/ */
/**
* Initialize the array of tabs for customer invoice
*
* @param Facture $object Invoice object
* @return array Array of head tabs
*/
function facture_prepare_head($object) function facture_prepare_head($object)
{ {
global $langs, $conf; global $langs, $conf;