From d43b8af46dcf64c6468aad825c664534f579d28d Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 19 Jan 2011 11:07:41 +0000 Subject: [PATCH] --- .../DAO/class.common.dao.entreprise.php | 8 ++----- .../DAO/class.common.dao.utilisateur.php | 2 -- inc/ws/Controlleur/class.ws.ajax.php | 23 ++++++++++++------- inc/ws/Controlleur/class.ws.url.php | 13 +++++++---- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/inc/commons/DAO/class.common.dao.entreprise.php b/inc/commons/DAO/class.common.dao.entreprise.php index 9fdc46db8..d43d12f78 100644 --- a/inc/commons/DAO/class.common.dao.entreprise.php +++ b/inc/commons/DAO/class.common.dao.entreprise.php @@ -61,7 +61,7 @@ class commonDAOEntreprise extends commonDAO { public function getListe($orderby = null, $sens = null, $limit = null, $limitedToUserRights = false) { - global $core; + if (!is_null($this->q)) { $daoClients = new commonDAOClient($this->con); $where = ''; @@ -111,15 +111,13 @@ class commonDAOEntreprise extends commonDAO { protected function limitToUserRights($user) { if ($user) { - return ' AND entreprise_id IN (SELECT entreprise FROM utilisateurs WHERE utilisateur_id IN(' . $user->ws_rights . ')) '; + return ' AND entreprise_id IN (SELECT entreprise FROM utilisateurs WHERE utilisateur_id IN(' . $user->ws_rights . ') AND utilisateur_id!=\''.$this->con->escape($user->utilisateur_id).'\') '; } return ''; } public function sauve($data) { - global $core; - $c = $this->con->openCursor('entreprises'); $c->nom = $data['nom']; @@ -146,7 +144,6 @@ class commonDAOEntreprise extends commonDAO { } $entreprise = $this->selectById($entreprise_id); - $core->refreshWSUsersTree(); return $entreprise; } @@ -154,7 +151,6 @@ class commonDAOEntreprise extends commonDAO { { $this->con->execute('DELETE FROM utilisateurs WHERE entreprise=\'' . $this->con->escape($entreprise_id) . '\''); $this->con->execute('DELETE FROM entreprises WHERE entreprise_id=\'' . $this->con->escape($entreprise_id) . '\''); - $core->refreshWSUsersTree(); return true; } diff --git a/inc/commons/DAO/class.common.dao.utilisateur.php b/inc/commons/DAO/class.common.dao.utilisateur.php index 4ce39df16..2f6688d19 100644 --- a/inc/commons/DAO/class.common.dao.utilisateur.php +++ b/inc/commons/DAO/class.common.dao.utilisateur.php @@ -206,12 +206,10 @@ class commonDAOUtilisateur extends commonDAO { $c->utilisateur_id = $this->getNextId(); $c->date_creation = time(); $c->insert(); - $core->refreshWSUsersTree(); return $this->selectById($c->utilisateur_id); } else { // Mise à jour d'un client $c->update('WHERE utilisateur_id=\'' . $this->con->escape($data['utilisateur_id']) . '\''); - $core->refreshWSUsersTree(); return $this->selectById($data['utilisateur_id']); } } diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 4ccb57410..554fc43ab 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -26,7 +26,15 @@ class wsAjax extends cubeAjax { { global $core; $dao = new commonDAOEntreprise($core->con); + // Creation de l'entreprise + if ($_POST['entreprise_id'] == 'new') { + if (!isset($_POST['ws_admin'])) { + $_POST['ws_admin'] = $core->user->utilisateur_id; + $_POST['ws_grade'] = 1; + } + } $entreprise = $dao->sauve($_POST); + // Si c'est une nouvelle entreprise, on crée également le contact if ($_POST['entreprise_id'] == 'new') { $data = $_POST['contact']; $data['entreprise'] = $entreprise->entreprise_id; @@ -46,15 +54,9 @@ class wsAjax extends cubeAjax { } } - $x->addContent('listeClients', wsUrl::listeClients()); - $x->addClosePopup(); - } + $core->refreshWSUsersTree(); - public static function saveNotes($args, &$x) - { - global $core; - $dao = new commonDAOClient($core->con); - $dao->sauveNotes($_POST['utilisateur_id'], $_POST['notes']); + $x->addContent('listeClients', wsUrl::listeClients()); $x->addClosePopup(); } @@ -72,6 +74,8 @@ class wsAjax extends cubeAjax { foreach($client_contacts as $c) { $contacts[] = '' . $c->prenom . ' ' . $c->nom . ''; } + + $core->refreshWSUsersTree(); $x->addContent('contacts_' . $client->entreprise, implode(', ', $contacts)); $x->addPopupDimensions(); @@ -80,9 +84,12 @@ class wsAjax extends cubeAjax { public static function supprimeClient($args, &$x) { global $core; + $dao = new commonDAOEntreprise($core->con); $dao->supprime($args[1]); + $core->refreshWSUsersTree(); + $x->addContent('listeClients', wsUrl::listeClients()); } diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index d55efa65c..4caa4767a 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -349,10 +349,10 @@ html{height:100%}' . "\n"; global $core; commonDroits::min(3); - $dao=new wsDAOBook($core->con); - $book=$dao->selectById($book_id); + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($book_id); - $res = '' . __('Propriétaire actuel') . ' : '.$book->proprietaire.''; + $res = '' . __('Propriétaire actuel') . ' : ' . $book->proprietaire . ''; $res .= '' . __('Rechercher un utilisateur') . ' : ' . form::field('book_proprietaire', 64, 1024) . form::hidden('proprietaire', '') . ''; return $res; } @@ -421,9 +421,12 @@ html{height:100%}' . "\n"; $shortcuts = array(); $shortcuts[] = '' . $core->typo->Ajouter('Créer un nouveau client') . ''; + $filtres = array(); - $filtres[] = new commonFiltre(__('Ayant un projet'), 'status_client_projet', $settings['filtres']); - $filtres[] = new commonFiltre(__('Ayant des impayés'), 'impaye', $settings['filtres']); + if (wsDroits::admin(false)) { + $filtres[] = new commonFiltre(__('Ayant un projet'), 'status_client_projet', $settings['filtres']); + $filtres[] = new commonFiltre(__('Ayant des impayés'), 'impaye', $settings['filtres']); + } $res = commonPage::barre($filtres, 'filtreClients', 'clients', $shortcuts); $res .= commonPage::tMain(); $res .= commonPage::bh(); -- 2.39.5