diff --git a/htdocs/comm/adresse_livraison.class.php b/htdocs/comm/adresse_livraison.class.php new file mode 100644 index 00000000000..109b0fc22db --- /dev/null +++ b/htdocs/comm/adresse_livraison.class.php @@ -0,0 +1,518 @@ + + * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2005-2006 Houssin Régis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/comm/adresse_livraison.class.php + \ingroup societe + \brief Fichier de la classe des adresses de livraison + \version $Revision$ +*/ + + +/** + \class Societe + \brief Classe permettant la gestion des adresses de livraison +*/ + +class Livraison +{ + var $db; + + var $id; + var $label; + var $socid; + var $nom; + var $adresse; + var $cp; + var $ville; + var $departement_id; + var $pays_id; + var $pays_code; + var $note; + + + /** + * \brief Constructeur de la classe + * \param DB handler accès base de données + * \param id id societe (0 par defaut) + */ + function Livraison($DB, $id=0) + { + global $conf; + + $this->db = $DB; + + $this->id = $id; + + return 1; + } + + /** + * \brief Crée l'adresse de livraison de la société en base + * \param user Objet utilisateur qui demande la création + * \return int 0 si ok, < 0 si erreur + */ + + function create($socid, $user='') + { + global $langs,$conf; + + // Nettoyage paramètres + $this->nom=trim($this->nom); + $this->label=trim($this->label); + + dolibarr_syslog("societe.class.php::create delivery adress ".$this->label); + + $this->db->begin(); + + $result = $this->verify(); + + if ($result >= 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_adresse_livraison (label, fk_societe, nom, datec, fk_user_creat) "; + $sql .= " VALUES ('".addslashes($this->label)."', '".$socid."', '".addslashes($this->nom)."', now(), '".$user->id."')"; + + $result=$this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_adresse_livraison"); + + $ret = $this->update($this->id, $socid, $user); + + if ($ret >= 0) + { + dolibarr_syslog("Societe::Create delivery adress success id=".$this->id); + $this->db->commit(); + return 0; + } + else + { + dolibarr_syslog("Societe::Create delivery adress echec update"); + $this->db->rollback(); + return -3; + } + } + else + + { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + + $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->nom); + } + else + { + dolibarr_syslog("Societe::Create echec insert sql=$sql"); + } + $this->db->rollback(); + return -2; + } + + } + else + { + $this->db->rollback(); + dolibarr_syslog("Societe::Create echec verify sql=$sql"); + return -1; + } + } + + +/** + * \brief Verification lors de la modification de l'adresse de livraison + * \return 0 si ok, < 0 en cas d'erreur + */ + function verify() + { + $this->label=trim($this->label); + $this->nom=trim($this->nom); + $result = 0; + if (!$this->nom || !$this->label) + { + $this->error = "Le nom de la société et le label ne peut être vide.\n"; + $result = -2; + } + return $result; + } + + + /** + * \brief Mise a jour des paramètres de l'adresse de livraison + * \param id id adresse de livraison + * \param user Utilisateur qui demande la mise à jour + * \return int <0 si ko, >=0 si ok + */ + function update($idl, $socid, $user='') + { + global $langs; + + dolibarr_syslog("Societe::Update"); + + // Nettoyage des paramètres + + $this->fk_societe=$socid; + $this->label=trim($this->label); + $this->nom=trim($this->nom); + $this->adresse=trim($this->adresse); + $this->cp=trim($this->cp); + $this->ville=trim($this->ville); + $this->departement_id=trim($this->departement_id); + $this->pays_id=trim($this->pays_id); + $this->note=trim($this->note); + + $result = $this->verify(); // Verifie que nom et label obligatoire + + if ($result >= 0) + { + dolibarr_syslog("Societe::Update delivery adress verify ok"); + + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_adresse_livraison"; + $sql.= " SET label = '" . addslashes($this->label) ."'"; // Champ obligatoire + $sql.= ",nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire + $sql.= ",address = '" . addslashes($this->adresse) ."'"; + + if ($this->cp) + { $sql .= ",cp = '" . $this->cp ."'"; } + + if ($this->ville) + { $sql .= ",ville = '" . addslashes($this->ville) ."'"; } + + $sql .= ",fk_departement = '" . ($this->departement_id?$this->departement_id:'0') ."'"; + $sql .= ",fk_pays = '" . ($this->pays_id?$this->pays_id:'0') ."'"; + $sql.= ",note = '" . addslashes($this->note) ."'"; + + if ($user) $sql .= ",fk_user_modif = '".$user->id."'"; + $sql .= " WHERE fk_societe = '" . $socid ."' AND rowid = '" . $idl ."'"; + + $resql=$this->db->query($sql); + if ($resql) + { + $result = 1; + } + else + { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + // Doublon + $this->error = $langs->trans("ErrorDuplicateField"); + $result = -1; + } + else + { + + $this->error = $langs->trans("Error sql=$sql"); + dolibarr_syslog("Societe::Update delivery adress echec sql=$sql"); + $result = -2; + } + } + } + + return $result; + + } + + /** + * \brief Charge depuis la base toutes les adresses de livraison d'une société + * \param socid Id de la société à charger en mémoire + * \param user Objet de l'utilisateur + * \return int >0 si ok, <0 si ko + */ + function fetch($socid, $user=0) + { + global $langs, $conf; + + $sql = 'SELECT s.idp, s.nom'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql .= ' WHERE s.idp = '.$socid; + + $resqlsoc=$this->db->query($sql); + + if ($resqlsoc) + { + if ($this->db->num_rows($resqlsoc)) + { + $obj = $this->db->fetch_object($resqlsoc); + + $this->nom_societe = $obj->nom; + $this->socid = $obj->idp; + $this->id = $obj->idp; + } + + $this->lignes = array(); + $this->db->free($resqlsoc); + + // Adresses de livraison liées à la société + if ($this->socid) + { + $sql = 'SELECT a.rowid as idl, a.label, a.nom, a.address,'.$this->db->pdate('a.datec').' as dc'; + $sql .= ','. $this->db->pdate('a.tms').' as date_update, a.fk_societe'; + $sql .= ', a.cp, a.ville, a.note, a.fk_departement, a.fk_pays'; + $sql .= ', p.code as pays_code, p.libelle as pays'; + $sql .= ', d.code_departement as departement_code, d.nom as departement'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_adresse_livraison as a'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON a.fk_pays = p.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.fk_departement = d.rowid'; + $sql .= ' WHERE a.fk_societe = '.$this->socid; + + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $objp = $this->db->fetch_object($resql); + + $ligne = new AdresseLivraisonLigne(); + + $ligne->idl = $objp->idl; + $ligne->date_creation = $objp->dc; + $ligne->date_update = $objp->date_update; + $ligne->label = stripslashes($objp->label); + $ligne->nom = stripslashes($objp->nom); + $ligne->adresse = stripslashes($objp->address); + $ligne->cp = $objp->cp; + $ligne->ville = stripslashes($objp->ville); + $ligne->adresse_full = stripslashes($objp->address) . "\n". $objp->cp . ' '. stripslashes($objp->ville); + $ligne->pays_id = $objp->fk_pays; + $ligne->pays_code = $objp->fk_pays?$objp->pays_code:''; + $ligne->pays = $objp->fk_pays?($langs->trans('Country'.$objp->pays_code)!='Country'.$objp->pays_code?$langs->trans('Country'.$objp->pays_code):$objp->pays):''; + $ligne->departement_id = $objp->fk_departement; + $ligne->departement = $objp->fk_departement?$objp->departement:''; + $ligne->note = $objp->note; + + $this->lignes[$i] = $ligne; + $i++; + } + $this->db->free($resql); + return 1; + } + else + { + dolibarr_syslog('Erreur AdresseLivraison::Fetch aucune adresse dde livraison'); + return -1; + } + } + else + { + dolibarr_syslog('AdresseLivraison::Societe inconnue'); + return -2; + } + } + else + { + dolibarr_syslog('Erreur Societe::Fetch '.$this->db->error()); + $this->error=$this->db->error(); + } + } + + /** + * \brief Charge depuis la base l'objet adresse de livraison + * \param socid Id de l'adresse de livraison à charger en mémoire + * \param user Objet de l'utilisateur + * \return int >0 si ok, <0 si ko + */ + function fetch_adresse($idl, $user=0) + { + global $langs; + global $conf; + + $sql = 'SELECT a.rowid, a.label, a.nom, a.address,'.$this->db->pdate('a.datec').' as dc'; + $sql .= ','. $this->db->pdate('a.tms').' as date_update'; + $sql .= ', a.cp,a.ville, a.note, a.fk_departement, a.fk_pays'; + $sql .= ', p.code as pays_code, p.libelle as pays'; + $sql .= ', d.code_departement as departement_code, d.nom as departement'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_adresse_livraison as a'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON a.fk_pays = p.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.fk_departement = d.rowid'; + $sql .= ' WHERE a.rowid = '.$idl; + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->idl = $obj->rowid; + + $this->date_update = $obj->date_update; + $this->date_creation = $obj->date_creation; + + $this->label = stripslashes($obj->label); + $this->nom = stripslashes($obj->nom); + $this->adresse = stripslashes($obj->address); + $this->cp = $obj->cp; + $this->ville = stripslashes($obj->ville); + $this->adresse_full = stripslashes($obj->address) . "\n". $obj->cp . ' '. stripslashes($obj->ville); + + $this->pays_id = $obj->fk_pays; + $this->pays_code = $obj->fk_pays?$obj->pays_code:''; + $this->pays = $obj->fk_pays?($langs->trans('Country'.$obj->pays_code)!='Country'.$obj->pays_code?$langs->trans('Country'.$obj->pays_code):$obj->pays):''; + + $this->departement_id = $obj->fk_departement; + $this->departement= $obj->fk_departement?$obj->departement:''; + + $this->note = $obj->note; + + $result = 1; + } + else + { + dolibarr_syslog('Erreur Societe::Fetch aucune adresse de livraison avec id='.$this->id.' - '.$sql); + $this->error='Erreur Societe::Fetch aucune adresse de livraison avec id='.$this->id.' - '.$sql; + $result = -2; + } + + $this->db->free($resql); + } + else + { + dolibarr_syslog('Erreur Societe::Fetch echec sql='.$sql); + dolibarr_syslog('Erreur Societe::Fetch '.$this->db->error()); + $this->error=$this->db->error(); + $result = -3; + } + + return $result; + } + + + /** + * \brief Suppression d'une adresse de livraison + * \param id id de la societe à supprimer + */ + function delete($idl,$socid) + { + dolibarr_syslog("Societe::Delete delivery adress"); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_adresse_livraison"; + $sql .= " WHERE rowid=".$idl." AND fk_societe = ".$socid; + + $result = $this->db->query($sql); + + if (!$result) + { + print $this->db->error() . '
' . $sql; + } + } + + + /** + * \brief Renvoie le nom d'une societe a partir d'un id + * \param id id de la société recherchée + * + */ + function get_nom($id) + { + + $sql = "SELECT nom FROM ".MAIN_DB_PREFIX."societe WHERE idp='$id';"; + + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object($result); + return $obj->nom; + } + $this->db->free(); + } + else { + dolibarr_print_error($this->db); + } + + } + + + /* + * \brief Charge les informations d'ordre info dans l'objet societe + * \param id id de la societe a charger + */ + function info($id) + { + $sql = "SELECT s.idp, s.nom, ".$this->db->pdate("datec")." as datec, ".$this->db->pdate("datea")." as datea,"; + $sql.= " fk_user_creat, fk_user_modif"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.idp = ".$id; + + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->idp; + + if ($obj->fk_user_creat) { + $cuser = new User($this->db, $obj->fk_user_creat); + $cuser->fetch(); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_modif) { + $muser = new User($this->db, $obj->fk_user_modif); + $muser->fetch(); + $this->user_modification = $muser; + } + $this->ref = $obj->nom; + $this->date_creation = $obj->datec; + $this->date_modification = $obj->datea; + } + + $this->db->free($result); + + } + else + { + dolibarr_print_error($this->db); + } + } + +} + +class AdresseLivraisonLigne +{ + + var $idl; + var $date_creation; + var $date_update; + var $label; + var $nom; + var $adresse; + var $cp; + var $ville; + var $adresse_full; + var $pays_id; + var $pays_code; + var $pays; + var $departement_id; + var $departement; + var $note; + + function AdresseLivraisonLigne() + { + } +} +?> \ No newline at end of file diff --git a/htdocs/comm/adresse_livraison.php b/htdocs/comm/adresse_livraison.php new file mode 100644 index 00000000000..9f0b523049c --- /dev/null +++ b/htdocs/comm/adresse_livraison.php @@ -0,0 +1,442 @@ + + * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2005-2006 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/comm/adresse_livraison.php + \ingroup societe + \brief Onglet adresse de livraison d'un client + \version $Revision$ +*/ + +require("pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/comm/adresse_livraison.class.php"); + +$user->getrights('societe'); +$user->getrights('commercial'); + +$langs->load("companies"); +$langs->load("commercial"); + +if (! $user->rights->societe->creer) +{ + if ($_GET["action"] == 'create' || $_POST["action"] == 'create') + { + accessforbidden(); + } +} + +$idl = isset($_GET["idl"])?$_GET["idl"]:''; +$socid = isset($_GET["socid"])?$_GET["socid"]:''; +if (! $socid && ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add' && $_REQUEST["action"] != 'update')) accessforbidden(); + +// Sécurité accés client +if ($user->societe_id > 0) +{ + $_GET["action"] = ''; + $_POST["action"] = ''; + $socid = $user->societe_id; +} + +// Protection restriction commercial +if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0) +{ + $sql = "SELECT sc.fk_soc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_user = ".$user->id; + + if ( $db->query($sql) ) + { + if ( $db->num_rows() == 0) accessforbidden(); + } +} + +$livraison = new Livraison($db); + + + +/* + * Actions + */ + +if ($_POST["action"] == 'add' || $_POST["action"] == 'update') +{ + $livraison->socid = $_POST["socid"]; + $livraison->label = $_POST["label"]; + $livraison->nom = $_POST["nom"]; + $livraison->adresse = $_POST["adresse"]; + $livraison->cp = $_POST["cp"]; + $livraison->ville = $_POST["ville"]; + $livraison->pays_id = $_POST["pays_id"]; + $livraison->departement_id = $_POST["departement_id"]; + $livraison->note = $_POST["note"]; + + if ($_POST["action"] == 'add') + { + $socid = $_POST["socid"]; + $result = $livraison->create($socid, $user); + + if ($result >= 0) + { + Header("Location: adresse_livraison.php?socid=".$socid); + exit; + } + else + { + $mesg=$livraison->error; + $_GET["action"]='create'; + } + } + + if ($_POST["action"] == 'update') + { + $result = $livraison->update($_POST["idl"], $socid, $user); + if ($result >= 0) + { + Header("Location: adresse_livraison.php?socid=".$socid); + exit; + } + else + { + $reload = 0; + $mesg = $livraison->error; + $_GET["action"]= "edit"; + } + } + +} + +if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->supprimer) +{ + $livraison = new Livraison($db); + $result = $livraison->delete($_GET["idl"], $socid); + + if ($result == 0) + { + Header("Location: adresse_livraison.php?socid=".$socid); + exit ; + } + else + { + $reload = 0; + $_GET["action"]=''; + } +} + +/** + * + * + */ + +llxHeader(); + +$form = new Form($db); +$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + + +if ($_GET["action"] == 'create' || $_POST["action"] == 'create') +{ + if ($user->rights->societe->creer) + { + /* + * Fiche adresse de livraison en mode création + */ + + if ($_POST["label"] && $_POST["nom"]) + { + $livraison->socid=$_POST["socid"]; + $livraison->label=$_POST["label"]; + $livraison->nom=$_POST["nom"]; + $livraison->adresse=$_POST["adresse"]; + $livraison->cp=$_POST["cp"]; + $livraison->ville=$_POST["ville"]; + $livraison->departement_id=$_POST["departement_id"]; + $livraison->note=$_POST["note"]; + } + + // On positionne pays_id, pays_code et libelle du pays choisi + $livraison->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + if ($livraison->pays_id) + { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$livraison->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dolibarr_print_error($db); + } + $livraison->pays_code=$obj->code; + $livraison->pays=$obj->libelle; + } + + print_titre($langs->trans("NewDeliveryAdress")); + print "
\n"; + + if ($livraison->error) + { + print '
'; + print nl2br($livraison->error); + print '
'; + } + + print '
'; + print ''; + print ''; + + print ''; + + print ''; + print ''; + + print ''; + + print ''; + print ''; + + print ''; + + print ''; + + print ''; + + print ''."\n"; + + print '
'.$langs->trans('DeliveryAdressLabel').'
'.$langs->trans('Name').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').'use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; + print '>'; + if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' '; + print '
'.$langs->trans('Town').'
'.$langs->trans('Country').''; + $form->select_pays($livraison->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':''); + print '
'.$langs->trans('State').''; + if ($livraison->pays_id) + { + $form->select_departement($livraison->departement_id,$livraison->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans('Note').'
'; + print '
'."\n"; + print '
'."\n"; + + } +} +elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') +{ + /* + * Fiche societe en mode edition + */ + + print_titre($langs->trans("EditDeliveyAdress")); + + if ($socid) + { + if ($reload || ! $_POST["nom"]) + { + $livraison = new Livraison($db); + $livraison->socid = $socid; + $livraison->fetch_adresse($idl); + } + else + { + $livraison->idl=$_POST["idl"]; + $livraison->socid=$_POST["socid"]; + $livraison->label=$_POST["label"]; + $livraison->nom=$_POST["nom"]; + $livraison->adresse=$_POST["adresse"]; + $livraison->zip=$_POST["zip"]; + $livraison->ville=$_POST["ville"]; + $livraison->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + $livraison->departement_id=$_POST["departement_id"]; + $livraison->note=$_POST["note"]; + + // On positionne pays_id, pays_code et libelle du pays choisi + if ($livraison->pays_id) + { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$livraison->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dolibarr_print_error($db); + } + $livraison->pays_code=$obj->code; + $livraison->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + } + } + + if ($livraison->error) + { + print '
'; + print $livraison->error; + print '
'; + } + + print '
'; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print '
'.$langs->trans('DeliveryAdressLabel').'
'.$langs->trans('Name').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').'use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; + print '>'; + if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' '; + print '
'.$langs->trans('Town').'
'.$langs->trans('Country').''; + $form->select_pays($livraison->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_edit()"':''); + print '
'.$langs->trans('State').''; + $form->select_departement($livraison->departement_id,$livraison->pays_code); + print '
'.$langs->trans('Note').'
'; + print '
'; + } +} +else +{ + /* + * Fiche société en mode visu + */ + $livraison = new Livraison($db); + $result=$livraison->fetch($socid); + $nblignes = sizeof($livraison->lignes); + if ($result < 0) + { + dolibarr_print_error($db,$livraison->error); + //exit; + } + + + $head = societe_prepare_head($livraison); + + dolibarr_fiche_head($head, 'company', $livraison->nom_societe); + + + // Confirmation de la suppression de la facture + if ($_GET["action"] == 'delete') + { + $html = new Form($db); + $html->form_confirm("adresse_livraison.php?socid=".$livraison->socid."&idl=".$_GET["idl"],$langs->trans("DeleteDeliveryAdress"),$langs->trans("ConfirmDeleteDeliveryAdress"),"confirm_delete"); + print "
\n"; + } + + + if ($livraison->error) + { + print '
'; + print $livraison->error; + print '
'; + } + + for ($i = 0 ; $i < $nblignes ; $i++) + { + + print ''; + + print ''; + print ''; + print ''; + + print ""; + + print '"; + print '"; + + print ''; + print ''; + + print ''; + + print '
'.$langs->trans('DeliveryAdressLabel').''.$livraison->lignes[$i]->label.''.$langs->trans('Note').' :
'.nl2br($livraison->lignes[$i]->note).'
'.$langs->trans('Name').''.$livraison->lignes[$i]->nom.'
".$langs->trans('Address')."".nl2br($livraison->lignes[$i]->adresse)."
'.$langs->trans('Zip').''.$livraison->lignes[$i]->cp."
'.$langs->trans('Town').''.$livraison->lignes[$i]->ville."
'.$langs->trans('Country').''.$livraison->lignes[$i]->pays.'
'.$langs->trans('State').''.$livraison->lignes[$i]->departement.'
'; + + + /* + * + */ + + print '
'; + + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Edit").''; + } + + if ($user->rights->societe->supprimer) + { + print ''.$langs->trans("Delete").''; + } + + + print '
'; + print '
'; + } + print ''; + if ($_GET["action"] == '') + { + print '
'; + + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Add").''; + } + print '
'; + } + +} + +$db->close(); + + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 28fb6c57fac..0e46183ad69 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -326,6 +326,17 @@ if ($socidp > 0) print ''.$objsoc->price_level.""; print ''; } + + // adresse de livraison + + print ''; + print '
'; + print $langs->trans("DeliveryAdress"); + print ''; + print ''.img_edit($langs->trans("Modify")).''; + print '
'; + print ''; + print ''; print "";