From 826308b9e22c4dd4f1034dff7acdff6ecedfd0d2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 21 Apr 2006 15:16:34 +0000 Subject: [PATCH] =?UTF-8?q?D=E9but=20ajout=20de=20la=20gestion=20des=20adr?= =?UTF-8?q?esses=20de=20livraison?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/commande/commande.class.php | 46 +++++++++-------- htdocs/commande/fiche.php | 21 +++++++- htdocs/html.form.class.php | 80 +++++++++++++++++++++++++++++- 3 files changed, 123 insertions(+), 24 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 23efefa841c..a63976dd0bb 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -279,13 +279,14 @@ class Commande } $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande ('; - $sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison) '; + $sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison) '; $sql.= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.','; $sql.= ' '.$this->db->idate($this->date_commande).','; $sql.= ' '.$this->source.', '; $sql.= " '".addslashes($this->note)."', "; $sql.= " '".$this->ref_client."', '".$this->modelpdf.'\', \''.$this->cond_reglement_id.'\', \''.$this->mode_reglement_id.'\','; - $sql.= " ".($this->date_livraison?$this->db->idate($this->date_livraison):'null').")"; + $sql.= " '".($this->date_livraison?$this->db->idate($this->date_livraison):'null').'\','; + $sql.= " '".$this->adresse_reglement_id."')"; dolibarr_syslog("Commande.class.php::create sql=$sql"); if ( $this->db->query($sql) ) @@ -606,7 +607,7 @@ class Commande function fetch($id) { $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva, c.fk_cond_reglement, c.fk_mode_reglement'; - $sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.date_livraison'; + $sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.date_livraison, c.fk_adresse_livraison'; $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c'; $sql .= ' WHERE c.rowid = '.$id; @@ -614,25 +615,26 @@ class Commande if ( $result ) { $obj = $this->db->fetch_object(); - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->ref_client = $obj->ref_client; - $this->soc_id = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->user_author_id = $obj->fk_user_author; - $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->tva; - $this->total_ttc = $obj->total_ttc; - $this->date = $obj->date_commande; - $this->remise_percent = $obj->remise_percent; - $this->source = $obj->source; - $this->facturee = $obj->facture; - $this->note = $obj->note; - $this->projet_id = $obj->fk_projet; - $this->modelpdf = $obj->model_pdf; - $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->date_livraison = $obj->date_livraison; + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; + $this->soc_id = $obj->fk_soc; + $this->statut = $obj->fk_statut; + $this->user_author_id = $obj->fk_user_author; + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->tva; + $this->total_ttc = $obj->total_ttc; + $this->date = $obj->date_commande; + $this->remise_percent = $obj->remise_percent; + $this->source = $obj->source; + $this->facturee = $obj->facture; + $this->note = $obj->note; + $this->projet_id = $obj->fk_projet; + $this->modelpdf = $obj->model_pdf; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->date_livraison = $obj->date_livraison; + $this->adresse_livraison_id = $obj->fk_adresse_livraison; $this->db->free(); if ($this->statut == 0) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index ada308a3879..a38c91250b2 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -687,7 +687,7 @@ else print $langs->trans('DateDelivery'); print ''; - if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print 'id.'">'.img_edit($langs->trans('SetConditions'),1).''; + if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print 'id.'">'.img_edit($langs->trans('SetDateDelivery'),1).''; print ''; print ''; if ($_GET['action'] == 'editdate_livraison') @@ -702,6 +702,25 @@ else { print dolibarr_print_date($commande->date_livraison,'%a %d %B %Y'); } + print ''; + + // adresse de livraison + print ''; + print ''; + + if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAdress'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryAdress'),1).'
'; + print ''; + if ($_GET['action'] == 'editdelivery_adress') + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,'adresse_livraison_id'); + } + else + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,'none'); + } print ''; // Conditions et modes de réglement diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 4323372d5de..9f25cf73e5e 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -756,6 +756,48 @@ class Form } } + /** + * \brief Retourne la liste déroulante des adresses de livraison + * \param selected Id contact pré-sélectionn + * \param htmlname Nom champ formulaire + */ + function select_adresse_livraison($selected='', $socid, $htmlname='idl') + { + // On recherche les utilisateurs + $sql = "SELECT a.rowid, a.label"; + $sql .= " FROM ".MAIN_DB_PREFIX ."societe_adresse_livraison as a"; + $sql .= " WHERE a.fk_societe = ".$socid; + $sql .= " ORDER BY a.label ASC"; + + if ($this->db->query($sql)) + { + print ''; + } + else + { + dolibarr_print_error($this->db); + } + } /** * \brief Charge dans cache la liste des conditions de paiements possibles @@ -1535,7 +1577,43 @@ class Form } } } - + + /** + * \brief Affiche formulaire de selection de l'adresse de livraison + * \param page Page + * \param selected Id condition présélectionnée + * \param htmlname Nom du formulaire select + * \param addempty Ajoute entrée vide + */ + function form_adresse_livraison($page, $selected='', $socid, $htmlname='adresse_livraison_id') + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + $this->select_adresse_livraison($selected, $socid, $htmlname); + print '
'; + } + else + { + if ($selected) + { + require_once(DOL_DOCUMENT_ROOT ."/comm/adresse_livraison.class.php"); + $livraison=new Livraison($this->db); + $livraison->fetch_adresse($selected); + print $livraison->label; + } + else + { + print " "; + } + } + } /** * \brief Retourne la liste des devises, dans la langue de l'utilisateur