From: vincent@cubedesigners.com Date: Fri, 14 Jan 2011 10:50:00 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=708338d204ed3817b754093f61b02ad02daf1e61;p=cubeextranet.git --- diff --git a/importWs.php b/importWs.php index 99ffd3d93..b661fb96d 100644 --- a/importWs.php +++ b/importWs.php @@ -186,6 +186,11 @@ try { $c->ws_admin = $ws2ext[$r->admin]; $c->update('WHERE entreprise_id=\'' . $utilisateurs_entreprises[$ws2ext[$r->uid]] . '\''); } + // Set cubedesigners AS admin + $core->con->execute('UPDATE entreprises SET ws_grade=5, ws_admin=1 WHERE entreprise_id=7'); + + // Some entreprises are themeselves revendeurs. It's not normal + $core->con->execute('UPDATE entreprises e SET ws_admin=1 WHERE ws_admin IN (SELECT utilisateur_id FROM utilisateurs u WHERE e.entreprise_id=u.entreprise)'); } else { $ws2ext = array(); $r = $core->con->select('SELECT ws_id,utilisateur_id,entreprise FROM utilisateurs WHERE ws_id IS NOT NULL'); @@ -195,8 +200,6 @@ try { } } - exit; - if ($themes) { // Importe les signatures $r = $core->con->select('SELECT * FROM ws.signature'); diff --git a/inc/extranet/Controlleur/class.extranet.url.php b/inc/extranet/Controlleur/class.extranet.url.php index 53cbf6a5c..069c289ee 100644 --- a/inc/extranet/Controlleur/class.extranet.url.php +++ b/inc/extranet/Controlleur/class.extranet.url.php @@ -309,7 +309,14 @@ class extranetUrl { $wsa = $daoUtilisateur->selectById($client->ws_admin, 'utilisateurs_entreprise'); $default = $wsa->utilisateur_id . ' - ' . $wsa->rs . ' (' . $wsa->prenom . ' ' . $wsa->nom . ')'; } + + $d = $dao->getWSDatas($entreprise_id); + $res .= '' . __('Revendeur / Administrateur') . '' . form::field('ws_admin_nom', 60, 128, $default, $class) . form::hidden('ws_admin', $default_id) . ''; + if (!is_null($d)) { + $res .= '' . __('Entité facturable') . '' . $d->facturable->prenom . ' ' . $d->facturable->nom . ' (' . $d->facturable->rs . ')'; + $res .= '' . __('Administrateur responsable') . '' . $d->administrateur->prenom . ' ' . $d->administrateur->nom . ' (' . $d->administrateur->rs . ')'; + } if ($entreprise_id == 'new') { $daoContact = new extranetDAOClient($core->con); $contact = $daoContact->cree(); diff --git a/inc/extranet/DAO/class.extranet.dao.entreprise.php b/inc/extranet/DAO/class.extranet.dao.entreprise.php index 4c30ffc10..b778cf1a4 100644 --- a/inc/extranet/DAO/class.extranet.dao.entreprise.php +++ b/inc/extranet/DAO/class.extranet.dao.entreprise.php @@ -45,6 +45,20 @@ class extranetDAOEntreprise extends extranetDAO { return $this->singleton($r); } + public function getWSDatas($entreprise_id) + { + $r = $this->con->select('SELECT * FROM ws_users_tree WHERE utilisateur_id IN(SELECT utilisateur_id FROM utilisateurs WHERE entreprise=\'' . $this->con->escape($entreprise_id) . '\') LIMIT 1'); + if (!$r->count()) { + return null; + } + $daoUtilisateur = new extranetDAOUtilisateur($this->con); + + $res = new stdClass(); + $res->administrateur = $daoUtilisateur->selectById($r->administrateur_id, 'utilisateurs_entreprise'); + $res->facturable = $daoUtilisateur->selectById($r->facturable_id, 'utilisateurs_entreprise'); + return $res; + } + public function getListe($orderby = null, $sens = null, $limit = null) { global $core; diff --git a/inc/ws/Controlleur/class.ws.users.tree.php b/inc/ws/Controlleur/class.ws.users.tree.php index 0de0bc962..336f73e34 100644 --- a/inc/ws/Controlleur/class.ws.users.tree.php +++ b/inc/ws/Controlleur/class.ws.users.tree.php @@ -6,6 +6,8 @@ class wsUsersTree { protected $grades; protected $facturables; protected $rights; + protected $entreprises; + protected $entreprises_tree; protected $con; @@ -22,11 +24,15 @@ class wsUsersTree { $this->users = array(); $this->admins = array(); $this->grades = array(); + $this->entreprises = array(); + $this->entreprises_tree = array(); $this->rights = array(); $r = $this->con->select('SELECT * FROM utilisateurs u,entreprises e WHERE u.entreprise=e.entreprise_id AND e.ws_grade>0 ORDER BY e.ws_grade DESC'); while ($r->fetch()) { + $this->entreprises_tree[$r->entreprise_id] = $r->ws_admin; + $this->entreprises[$r->utilisateur_id] = $r->entreprise_id; $this->users[$r->utilisateur_id] = $r->ws_admin; $this->grades[$r->utilisateur_id] = $r->ws_grade; if (!isset($this->admins[$r->ws_admin])) { @@ -37,27 +43,32 @@ class wsUsersTree { $this->facturables = $this->getFacturables(); - fb($this->facturables); - return; - $c = $this->con->openCursor('ws_users_tree'); + foreach($this->users as $utilisateur_id => $admin) { - $this->getFacturableOf($utilisateur_id, $facturable_id, $administrateur_id); + $facturable_id = $administrateur_id = 0; + $this->getFacturableOf($utilisateur_id, $facturable_id, $administrateur_id, 1); $c->utilisateur_id = $utilisateur_id; $c->facturable_id = $facturable_id; - $c->administrateur = $administrateur_id; + $c->administrateur_id = $administrateur_id; $c->insert(); } } - protected function getFacturableOf($utilisateur_id, &$facturable_id, &$administrateur_id) + protected function getFacturableOf($utilisateur_id, &$facturable_id, &$administrateur_id, $level) { if (in_array($utilisateur_id, $this->facturables)) { $facturable_id = $utilisateur_id; $administrateur_id = $this->users[$utilisateur_id]; return; } - return $this->getFacturableOf($this->users[$utilisateur_id], $facturable_id, $administrateur_id); + if ($level > 10) { + $facturable_id = -1; + $administrateur_id = -1; + return; + } + + return $this->getFacturableOf($this->users[$utilisateur_id], $facturable_id, $administrateur_id, $level + 1); } protected function getFacturables()