diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 0c8b6e0c8cb..c1e67b6455e 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -92,4 +92,6 @@ BillingContact=Billing contact TotalSizeOfAttachedFiles=Total size of attached files NbOfAttachedFiles=Number of attached files AttachANewFile=Attached a new file -FileWasRemoved=Files was removed \ No newline at end of file +FileWasRemoved=Files was removed +NoRIB=No RIB defined +NoParentCompany=None \ No newline at end of file diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 0752cad7134..3c79263df84 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -92,4 +92,6 @@ BillingContact=Contact facturation TotalSizeOfAttachedFiles=Taille totale des fichiers joints NbOfAttachedFiles=Nombre de fichiers joints AttachANewFile=Joindre un nouveau fichier -FileWasRemoved=Le fichier a été supprimé \ No newline at end of file +FileWasRemoved=Le fichier a été supprimé +NoRIB=Aucun RIB défini +NoParentCompany=Aucune \ No newline at end of file diff --git a/htdocs/soc.php b/htdocs/soc.php index 00f3908de98..69f04bc67d9 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -566,6 +566,9 @@ else $socm->fetch($soc->parent); print ''.img_object($langs->trans("ShowCompany"),'company').' '.$socm->nom.''.($socm->code_client?"(".$socm->code_client.")":"").' - '.$socm->ville; } + else { + print $langs->trans("NoParentCompany"); + } print ''; // Commerciaux diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 036066bb409..36d815e6a38 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -1092,13 +1092,21 @@ class Societe { function display_rib() { + global $langs; + require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php"; $bac = new CompanyBankAccount($this->db, $this->id); $bac->fetch(); - $rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number." ".$bac->cle_rib; - + if ($bac->code_banque || $bac->code_guichet || $bac->number || $bac->cle_rib) + { + $rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number." (".$bac->cle_rib.")"; + } + else + { + $rib=$langs->trans("NoRIB"); + } return $rib; } @@ -1195,24 +1203,52 @@ class Societe { } /** - * \brief Définit la société mère pour les filiales - * + * \brief Défini la société mère pour les filiales + * \param id id compagnie mère à positionner + * \return int <0 si ko, >0 si ok */ - - function set_parent($id) - { - if ($this->id) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql .= " SET parent = ".$id; - $sql .= " WHERE idp = " . $this->id .";"; - - if ( $this->db->query($sql) ) - { - return 0; - } - } - } + function set_parent($id) + { + if ($this->id) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; + $sql .= " SET parent = ".$id; + $sql .= " WHERE idp = " . $this->id .";"; + + if ( $this->db->query($sql) ) + { + return 1; + } + else + { + return -1; + } + } + } + + /** + * \brief Supprime la société mère + * \param id id compagnie mère à effacer + * \return int <0 si ko, >0 si ok + */ + function remove_parent($id) + { + if ($this->id) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; + $sql .= " SET parent = null"; + $sql .= " WHERE idp = " . $this->id .";"; + + if ( $this->db->query($sql) ) + { + return 1; + } + else + { + return -1; + } + } + } /** * \brief Verifie la validite du siren diff --git a/htdocs/societe/lien.php b/htdocs/societe/lien.php index 05bc90f6134..319822f7593 100644 --- a/htdocs/societe/lien.php +++ b/htdocs/societe/lien.php @@ -21,10 +21,10 @@ */ /** - \file htdocs/societe/lien.php - \ingroup societe - \brief Page des societes - \version $Revision$ + \file htdocs/societe/lien.php + \ingroup societe + \brief Page des societes + \version $Revision$ */ require("./pre.inc.php"); @@ -36,16 +36,19 @@ $langs->load("customers"); $langs->load("suppliers"); $langs->load("banks"); -/* - * Sécurité accés client - */ - +// Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } + +/* + * Actions + */ + +// Positionne companie parente if($_GET["socid"] && $_GET["select"]) { if ($user->rights->societe->creer) @@ -56,13 +59,37 @@ if($_GET["socid"] && $_GET["select"]) $soc->set_parent($_GET["select"]); Header("Location: lien.php?socid=".$soc->id); + exit; } else { Header("Location: lien.php?socid=".$_GET["socid"]); + exit; } } +// Supprime companie parente +if($_GET["socid"] && $_GET["delsocid"]) +{ + if ($user->rights->societe->creer) + { + $soc = new Societe($db); + $soc->id = $_GET["socid"]; + $soc->fetch($_GET["socid"]); + $soc->remove_parent($_GET["delsocid"]); + + Header("Location: lien.php?socid=".$soc->id); + exit; + } + else + { + Header("Location: lien.php?socid=".$_GET["socid"]); + exit; + } +} + + + llxHeader(); @@ -129,12 +156,21 @@ if($_GET["socid"]) print '