diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f4645721185..9fb99f69173 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -916,6 +916,7 @@ abstract class CommonObject // TODO uniformize field name $fieldname = 'fk_mode_reglement'; if ($this->element == 'societe') $fieldname = 'mode_reglement'; + if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET '.$fieldname.' = '.$id; @@ -955,6 +956,7 @@ abstract class CommonObject // TODO uniformize field name $fieldname = 'fk_cond_reglement'; if ($this->element == 'societe') $fieldname = 'cond_reglement'; + if (get_class($this) == 'Fournisseur') $fieldname = 'cond_reglement_supplier'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET '.$fieldname.' = '.$id; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c0d1635a05f..1376a4384cc 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -943,7 +943,8 @@ class CommandeFournisseur extends CommonOrder $sql.= ", fk_statut"; $sql.= ", source"; $sql.= ", model_pdf"; - //$sql.= ", fk_mode_reglement"; + $sql.= ", fk_mode_reglement"; + $sql.= ", fk_cond_reglement"; $sql.= ") "; $sql.= " VALUES ("; $sql.= "''"; @@ -958,7 +959,8 @@ class CommandeFournisseur extends CommonOrder $sql.= ", 0"; $sql.= ", " . $this->source; $sql.= ", '".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."'"; - //$sql.= ", ".$this->mode_reglement_id; + $sql.= ", ".$this->mode_reglement_id; + $sql.= ", ".$this->cond_reglement_id; $sql.= ")"; dol_syslog(get_class($this)."::create sql=".$sql); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1d97c737188..cf514271fd6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -76,6 +76,10 @@ class FactureFournisseur extends CommonInvoice var $note_private; var $note_public; var $propalid; + var $cond_reglement_id; + var $cond_reglement_code; + var $mode_reglement_id; + var $mode_reglement_code; var $lines; var $fournisseur; // deprecated @@ -143,6 +147,8 @@ class FactureFournisseur extends CommonInvoice $sql.= ", datec"; $sql.= ", datef"; $sql.= ", fk_projet"; + $sql.= ", fk_cond_reglement"; + $sql.= ", fk_mode_reglement"; $sql.= ", note_private"; $sql.= ", note_public"; $sql.= ", fk_user_author"; @@ -157,6 +163,8 @@ class FactureFournisseur extends CommonInvoice $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($this->date)."'"; $sql.= ", ".(isset($this->fk_project)?$this->fk_project:"null"); + $sql.= ", ".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null"); + $sql.= ", ".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null"); $sql.= ", '".$this->db->escape($this->note_private)."'"; $sql.= ", '".$this->db->escape($this->note_public)."'"; $sql.= ", ".$user->id.","; @@ -300,17 +308,22 @@ class FactureFournisseur extends CommonInvoice $sql.= " t.fk_facture_source,"; $sql.= " t.fk_projet,"; $sql.= " t.fk_cond_reglement,"; + $sql.= " t.fk_mode_reglement,"; $sql.= " t.date_lim_reglement,"; $sql.= " t.note_private,"; $sql.= " t.note_public,"; $sql.= " t.model_pdf,"; $sql.= " t.import_key,"; $sql.= " t.extraparams,"; + $sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; + $sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle,"; $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'; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id)"; if ($id) $sql.= " WHERE t.rowid=".$id; if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'"; - $sql.= ' AND t.fk_soc = s.rowid'; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); @@ -352,7 +365,13 @@ class FactureFournisseur extends CommonInvoice $this->fk_user_valid = $obj->fk_user_valid; $this->fk_facture_source = $obj->fk_facture_source; $this->fk_project = $obj->fk_projet; - $this->fk_cond_reglement = $obj->fk_cond_reglement; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement_libelle; + $this->cond_reglement_doc = $obj->cond_reglement_libelle; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; $this->date_echeance = $this->db->jdate($obj->date_lim_reglement); $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 00d7589448a..1e932d64827 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -687,6 +687,8 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer) // Creation commande $object->ref_supplier = GETPOST('refsupplier'); $object->socid = $socid; + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); @@ -980,6 +982,9 @@ if ($action=="create") $societe=new Societe($db); $societe->fetch($socid); } + + $cond_reglement_id = $societe->cond_reglement_supplier_id; + $mode_reglement_id = $societe->mode_reglement_supplier_id; print '