diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 336b2de20c6..306b56ddf13 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -38,69 +38,7 @@ $langs->load("sendings"); $langs->load("companies"); $user->getrights('propale'); -if (!$user->rights->propale->lire) - accessforbidden(); - -// les methodes locales -/** - * \brief Retourne la liste déroulante des sociétés - * \param selected Societe présélectionnée - * \param htmlname Nom champ formulaire - */ -function select_societes_for_newconcat($propal, $selected = '', $htmlname = 'newcompany'){ - // On recherche les societes - $sql = "SELECT s.idp, s.nom FROM"; - $sql .= " ".MAIN_DB_PREFIX."societe as s"; -// if ($filter) $sql .= " WHERE $filter"; - $sql .= " ORDER BY nom ASC"; - - $resql = $propal->db->query($sql); - if ($resql) - { - $javaScript = "window.location='./contact.php?propalid=".$propal->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; - print '\n"; - return $firstCompany; - } else - { - dolibarr_print_error($propal->db); - } -} - -/** - * - */ -function select_type_contact($propal, $defValue, $htmlname = 'type', $source) -{ - $lesTypes = $propal->liste_type_contact($source); - print '\n"; -} - +if (!$user->rights->propale->lire) accessforbidden(); // Sécurité accés client if ($user->societe_id > 0) @@ -291,7 +229,7 @@ if ($id > 0) $html->select_users($user->id,'contactid'); print ''; print ''; - select_type_contact($propal, '', 'type','internal'); + $propal->selectTypeContact($propal, '', 'type','internal'); print ''; print ''; print ''; @@ -313,14 +251,14 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$propal->client->id; - $selectedCompany = select_societes_for_newconcat($propal, $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $propal->selectCompaniesForNewContact($propal, 'propalid', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid'); print ''; print ''; - select_type_contact($propal, '', 'type','external'); + $propal->selectTypeContact($propal, '', 'type','external'); print ''; print ''; print ''; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index eaa5eab728b..9597cfc7884 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -38,69 +38,7 @@ $langs->load("sendings"); $langs->load("companies"); $user->getrights('commande'); -if (!$user->rights->commande->lire) - accessforbidden(); - -// les methodes locales -/** - * \brief Retourne la liste déroulante des sociétés - * \param selected Societe présélectionnée - * \param htmlname Nom champ formulaire - */ -function select_societes_for_newconcat($commande, $selected = '', $htmlname = 'newcompany'){ - // On recherche les societes - $sql = "SELECT s.idp, s.nom FROM"; - $sql .= " ".MAIN_DB_PREFIX."societe as s"; -// if ($filter) $sql .= " WHERE $filter"; - $sql .= " ORDER BY nom ASC"; - - $resql = $commande->db->query($sql); - if ($resql) - { - $javaScript = "window.location='./contact.php?id=".$commande->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; - print '\n"; - return $firstCompany; - } else - { - dolibarr_print_error($commande->db); - } -} - -/** - * - */ -function select_type_contact($commande, $defValue, $htmlname = 'type', $source) -{ - $lesTypes = $commande->liste_type_contact($source); - print '\n"; -} - +if (!$user->rights->commande->lire) accessforbidden(); // Sécurité accés client if ($user->societe_id > 0) @@ -302,7 +240,7 @@ if ($id > 0) $html->select_users($user->id,'contactid'); print ''; print ''; - select_type_contact($commande, '', 'type','internal'); + $commande->selectTypeContact($commande, '', 'type','internal'); print ''; print ''; print ''; @@ -324,14 +262,14 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$commande->client->id; - $selectedCompany = select_societes_for_newconcat($commande, $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $commande->selectCompaniesForNewContact($commande, 'id', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid'); print ''; print ''; - select_type_contact($commande, '', 'type','external'); + $commande->selectTypeContact($commande, '', 'type','external'); print ''; print ''; print ''; diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index c012d0646c4..d999f9a8dda 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -369,11 +369,74 @@ class CommonObject * \param userid Id du contact */ function fetch_adresse_livraison($deliveryaddressid) - { - $address = new Societe($this->db); - $address->fetch_adresse_livraison($deliveryaddressid); - $this->deliveryaddress = $address; - } + { + $address = new Societe($this->db); + $address->fetch_adresse_livraison($deliveryaddressid); + $this->deliveryaddress = $address; + } + +/** + * \brief Retourne la liste déroulante des sociétés + * \param object Fetch du document + * \param var_id Nom de la variable de l'id du document + * \param selected Societe présélectionnée + * \param htmlname Nom champ formulaire + */ + function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany') + { + // On recherche les societes + $sql = "SELECT s.idp, s.nom FROM"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; + //if ($filter) $sql .= " WHERE $filter"; + $sql .= " ORDER BY nom ASC"; + + $resql = $object->db->query($sql); + if ($resql) + { + $javaScript = "window.location='./contact.php?".$var_id."=".$object->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; + print '\n"; + return $firstCompany; + } + else + { + dolibarr_print_error($object->db); + } + } + +/** + * + */ + function selectTypeContact($object, $defValue, $htmlname = 'type', $source) + { + $lesTypes = $object->liste_type_contact($source); + print '\n"; + } } diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 226f448da41..852b34395d5 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -38,70 +38,7 @@ $langs->load("companies"); $user->getrights('facture'); -if (!$user->rights->facture->lire) - accessforbidden(); - -// les methodes locales -/** - * \brief Retourne la liste déroulante des sociétés - * \param selected Societe présélectionnée - * \param htmlname Nom champ formulaire - */ -function select_societes_for_newconcat($facture, $selected = '', $htmlname = 'newcompany') -{ - // On recherche les societes - $sql = "SELECT s.idp, s.nom FROM"; - $sql .= " ".MAIN_DB_PREFIX."societe as s"; -// if ($filter) $sql .= " WHERE $filter"; - $sql .= " ORDER BY nom ASC"; - - $resql = $facture->db->query($sql); - if ($resql) - { - $javaScript = "window.location='./contact.php?facid=".$facture->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; - print '\n"; - return $firstCompany; - } else - { - dolibarr_print_error($facture->db); - } -} - -/** - * - */ -function select_type_contact($facture, $defValue, $htmlname = 'type', $source) -{ - $lesTypes = $facture->liste_type_contact($source); - print '\n"; -} - +if (!$user->rights->facture->lire) accessforbidden(); // Sécurité accés client if ($user->societe_id > 0) @@ -285,7 +222,7 @@ if ($id > 0) $html->select_users($user->id,'contactid'); print ''; print ''; - select_type_contact($facture, '', 'type','internal'); + $facture->selectTypeContact($facture, '', 'type','internal'); print ''; print ''; print ''; @@ -307,14 +244,14 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id; - $selectedCompany = select_societes_for_newconcat($facture, $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $facture->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid'); print ''; print ''; - select_type_contact($facture, '', 'type','external'); + $facture->selectTypeContact($facture, '', 'type','external'); print ''; print ''; print ''; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 4a0b37a2ad0..ba24b2b66ef 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -39,8 +39,7 @@ $langs->load("companies"); $user->getrights('contrat'); -if (!$user->rights->contrat->lire) - accessforbidden(); +if (!$user->rights->contrat->lire) accessforbidden(); // Sécurité accés client et commerciaux $contratid = isset($_GET["id"])?$_GET["id"]:''; @@ -69,69 +68,6 @@ if ($contratid && (!$user->rights->commercial->client->voir || $user->societe_id } } - -// les methodes locales -/** - * \brief Retourne la liste déroulante des sociétés - * \param selected Societe présélectionnée - * \param htmlname Nom champ formulaire - */ -function select_societes_for_newconcat($contrat, $selected = '', $htmlname = 'newcompany') -{ - // On recherche les societes - $sql = "SELECT s.idp, s.nom FROM"; - $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if ($filter) $sql .= " WHERE $filter"; - $sql .= " ORDER BY nom ASC"; - - $resql = $contrat->db->query($sql); - if ($resql) - { - $javaScript = "window.location='./contact.php?id=".$contrat->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; - print '\n"; - return $firstCompany; - } else - { - dolibarr_print_error($contrat->db); - } -} - -/** - * - */ -function select_type_contact($contrat, $defValue, $htmlname = 'type', $source) -{ - $lesTypes = $contrat->liste_type_contact($source); - print '\n"; -} - - /* * Ajout d'un nouveau contact */ @@ -327,7 +263,7 @@ if ($id > 0) $html->select_users($user->id,'contactid'); print ''; print ''; - select_type_contact($contrat, '', 'type','internal'); + $contrat->selectTypeContact($contrat, '', 'type','internal'); print ''; print ''; print ''; @@ -349,14 +285,14 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$contrat->societe->id; - $selectedCompany = select_societes_for_newconcat($contrat, $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $contrat->selectCompaniesForNewContact($contrat, 'id', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid'); print ''; print ''; - select_type_contact($contrat, '', 'type','external'); + $contrat->selectTypeContact($contrat, '', 'type','external'); print ''; print ''; print '';