\r
public function getListe($orderby = null, $sens = null, $limit = null, $limitedToUserRights = false)\r
{\r
- global $core;\r
+\r
if (!is_null($this->q)) {\r
$daoClients = new commonDAOClient($this->con);\r
$where = '';\r
protected function limitToUserRights($user)\r
{\r
if ($user) {\r
- return ' AND entreprise_id IN (SELECT entreprise FROM utilisateurs WHERE utilisateur_id IN(' . $user->ws_rights . ')) ';\r
+ 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).'\') ';\r
}\r
return '';\r
}\r
\r
public function sauve($data)\r
{\r
- global $core;\r
-\r
$c = $this->con->openCursor('entreprises');\r
$c->nom = $data['nom'];\r
\r
}\r
\r
$entreprise = $this->selectById($entreprise_id);\r
- $core->refreshWSUsersTree();\r
return $entreprise;\r
}\r
\r
{\r
$this->con->execute('DELETE FROM utilisateurs WHERE entreprise=\'' . $this->con->escape($entreprise_id) . '\'');\r
$this->con->execute('DELETE FROM entreprises WHERE entreprise_id=\'' . $this->con->escape($entreprise_id) . '\'');\r
- $core->refreshWSUsersTree();\r
return true;\r
}\r
\r
$c->utilisateur_id = $this->getNextId();\r
$c->date_creation = time();\r
$c->insert();\r
- $core->refreshWSUsersTree();\r
return $this->selectById($c->utilisateur_id);\r
} else {\r
// Mise à jour d'un client\r
$c->update('WHERE utilisateur_id=\'' . $this->con->escape($data['utilisateur_id']) . '\'');\r
- $core->refreshWSUsersTree();\r
return $this->selectById($data['utilisateur_id']);\r
}\r
}\r
{\r
global $core;\r
$dao = new commonDAOEntreprise($core->con);\r
+ // Creation de l'entreprise\r
+ if ($_POST['entreprise_id'] == 'new') {\r
+ if (!isset($_POST['ws_admin'])) {\r
+ $_POST['ws_admin'] = $core->user->utilisateur_id;\r
+ $_POST['ws_grade'] = 1;\r
+ }\r
+ }\r
$entreprise = $dao->sauve($_POST);\r
+ // Si c'est une nouvelle entreprise, on crée également le contact\r
if ($_POST['entreprise_id'] == 'new') {\r
$data = $_POST['contact'];\r
$data['entreprise'] = $entreprise->entreprise_id;\r
}\r
}\r
\r
- $x->addContent('listeClients', wsUrl::listeClients());\r
- $x->addClosePopup();\r
- }\r
+ $core->refreshWSUsersTree();\r
\r
- public static function saveNotes($args, &$x)\r
- {\r
- global $core;\r
- $dao = new commonDAOClient($core->con);\r
- $dao->sauveNotes($_POST['utilisateur_id'], $_POST['notes']);\r
+ $x->addContent('listeClients', wsUrl::listeClients());\r
$x->addClosePopup();\r
}\r
\r
foreach($client_contacts as $c) {\r
$contacts[] = '<a href="#" class="popup" rel="formContact/' . $c->utilisateur_id . '">' . $c->prenom . ' ' . $c->nom . '</a>';\r
}\r
+\r
+ $core->refreshWSUsersTree();\r
$x->addContent('contacts_' . $client->entreprise, implode(', ', $contacts));\r
\r
$x->addPopupDimensions();\r
public static function supprimeClient($args, &$x)\r
{\r
global $core;\r
+\r
$dao = new commonDAOEntreprise($core->con);\r
$dao->supprime($args[1]);\r
\r
+ $core->refreshWSUsersTree();\r
+\r
$x->addContent('listeClients', wsUrl::listeClients());\r
}\r
\r
global $core;\r
commonDroits::min(3);\r
\r
- $dao=new wsDAOBook($core->con);\r
- $book=$dao->selectById($book_id);\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($book_id);\r
\r
- $res = '<tr><td>' . __('Propriétaire actuel') . ' : </td><td>'.$book->proprietaire.'</td></tr>';\r
+ $res = '<tr><td>' . __('Propriétaire actuel') . ' : </td><td>' . $book->proprietaire . '</td></tr>';\r
$res .= '<tr><td>' . __('Rechercher un utilisateur') . ' : </td><td>' . form::field('book_proprietaire', 64, 1024) . form::hidden('proprietaire', '') . '</td></tr>';\r
return $res;\r
}\r
\r
$shortcuts = array();\r
$shortcuts[] = '<a href="#" class="popup" rel="formClient/new">' . $core->typo->Ajouter('Créer un nouveau client') . '</a>';\r
+\r
$filtres = array();\r
- $filtres[] = new commonFiltre(__('Ayant un projet'), 'status_client_projet', $settings['filtres']);\r
- $filtres[] = new commonFiltre(__('Ayant des impayés'), 'impaye', $settings['filtres']);\r
+ if (wsDroits::admin(false)) {\r
+ $filtres[] = new commonFiltre(__('Ayant un projet'), 'status_client_projet', $settings['filtres']);\r
+ $filtres[] = new commonFiltre(__('Ayant des impayés'), 'impaye', $settings['filtres']);\r
+ }\r
$res = commonPage::barre($filtres, 'filtreClients', 'clients', $shortcuts);\r
$res .= commonPage::tMain();\r
$res .= commonPage::bh();\r