| '.$langs->trans("Entity").' | '."\n";
print '';
- print $html->selectarray('entity',$entity,$lastentity,0,0,0,1,'tabindex="3"');
+ print $mc->select_entities($mc->entities,$lastentity,'tabindex="3"');
print ' |
'."\n";
}
diff --git a/htdocs/multicompany/multicompany.class.php b/htdocs/multicompany/multicompany.class.php
index 06de703b6c9..31849dc9390 100644
--- a/htdocs/multicompany/multicompany.class.php
+++ b/htdocs/multicompany/multicompany.class.php
@@ -34,6 +34,8 @@ class Multicompany
var $error;
//! Numero de l'erreur
var $errno = 0;
+
+ var $entities = array();
/**
* \brief Constructeur de la classe
@@ -78,32 +80,76 @@ class Multicompany
{
}
+
/**
* \brief Supression
*/
- function DeleteCanvas($id)
- {
-
- }
- /**
- * \brief Lecture des donnees dans la base
- */
- function FetchCanvas($id='', $action='')
+ function Delete($id)
{
}
+ /**
+ * \brief List of entities
+ */
+ function getEntities()
+ {
+ global $conf;
+
+ $sql = "SELECT ".$this->db->decrypt('value',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." as value";
+ $sql.= ", entity";
+ $sql.= ", visible";
+ $sql.= " FROM ".MAIN_DB_PREFIX."const";
+ $sql.= " WHERE ".$this->db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." = 'MAIN_INFO_SOCIETE_NOM'";
+ $sql.= " ORDER BY entity ASC";
+
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $num = $this->db->num_rows($result);
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+
+ $active = 1;
+ if ($obj->entity < 0) $active = 0;
+
+ $this->entities[$i]['label'] = $obj->value;
+ $this->entities[$i]['id'] = $obj->entity;
+ $this->entities[$i]['active'] = $active;
+
+ $i++;
+ }
+ }
+
+ }
/**
- * \brief Mise a jour des donnees dans la base
- * \param datas Tableau de donnees
+ * \brief Return combo list of entities.
+ * \param entities Entities array
+ * \param selected Preselected entity
*/
- function UpdateCanvas($datas)
+ function select_entities($entities,$selected='',$option='')
{
-
+ print '