From: vincent@cubedesigners.com Date: Thu, 10 Feb 2011 18:21:28 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=0dacc23cc8111ec39c00eb6a22789d0b61d01e88;p=cubeextranet.git --- diff --git a/inc/commons/DAO/class.common.dao.entreprise.php b/inc/commons/DAO/class.common.dao.entreprise.php index 5d6aab916..8515fe538 100644 --- a/inc/commons/DAO/class.common.dao.entreprise.php +++ b/inc/commons/DAO/class.common.dao.entreprise.php @@ -184,9 +184,9 @@ class commonDAOEntreprise extends commonDAO { return true; } - public function count($limitedToUserRights = false) + public function count($limitedToUserRights = false,$table='entreprise_vue') { - $r = $this->con->select('SELECT COUNT(*) AS nb FROM entreprises_vue WHERE ' . $this->makeWhereFromFiltres() . ' ' . $this->limitToUserRights($limitedToUserRights)); + $r = $this->con->select('SELECT COUNT(*) AS nb FROM '.$table.' WHERE ' . $this->makeWhereFromFiltres() . ' ' . $this->limitToUserRights($limitedToUserRights)); return $r->nb; } @@ -194,6 +194,15 @@ class commonDAOEntreprise extends commonDAO { { if (!is_null($this->filtres)) { $w = array('1=1'); + + if (commonFiltre::test('ws_grade', $this->filtres)) { + $w[] = 'ws_grade IN(' . implode(',', array_keys($this->filtres['ws_grade'])) . ')'; + } + + if (commonFiltre::test('admin_client', $this->filtres)) { + $w[] = 'ws_super_admin IN(' . implode(',', array_keys($this->filtres['admin_client'])) . ')'; + } + return implode(' AND ', $w); } else { return '1=1'; diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index f329580e5..fe60dd7b4 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -431,7 +431,7 @@ class commonCore extends cubeCore { . 'GROUP BY e.entreprise_id'); $this->views->createView('entreprises_vue', 'SELECT e.*,i.impaye AS impaye ' . 'FROM entreprises_inter e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise'); - $this->views->createView('entreprises_ws', 'SELECT e.*, a.prenom AS administrateur, r.nom AS revendeur ' + $this->views->createView('entreprises_ws', 'SELECT e.*, a.prenom AS administrateur, r.nom AS revendeur,a.utilisateur_id AS ws_super_admin ' . 'FROM entreprises e ' . 'LEFT JOIN ws_entreprises_tree ri ON ri.entreprise_id=e.entreprise_id ' . 'LEFT JOIN utilisateurs ur ON e.ws_admin=ur.utilisateur_id ' @@ -499,10 +499,15 @@ class commonCore extends cubeCore { . 'FROM projets_vue p, taches_vue t ' . 'WHERE t.projet=p.projet_id ' . 'GROUP BY t.categorie,p.annee_fin'); - $this->views->createView('books_vue', 'SELECT b.*,b.proprietaire AS proprietaire_id,CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS proprietaire_nom, CONCAT(c.prenom,\' \',c.nom) AS proprietaire_utilisateur,c.ws_admin, f.rs AS facturable, t.facturable_id AS facturable_id, ta.projet AS projet ' + $this->views->createView('books_vue', 'SELECT b.*,b.proprietaire AS proprietaire_id,' + . 'CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS proprietaire_nom,' + . 'CONCAT(c.prenom,\' \',c.nom) AS proprietaire_utilisateur,c.ws_admin,' + . 'f.rs AS facturable, t.facturable_id AS facturable_id, ta.projet AS projet,' + . 'IF(c.ws_grade>=5,c.utilisateur_id,a.utilisateur_id) AS super_admin ' . 'FROM books b ' . 'LEFT JOIN utilisateurs_entreprise c ON b.proprietaire=c.utilisateur_id ' . 'LEFT JOIN ws_users_tree t ON t.utilisateur_id=c.utilisateur_id ' + . 'LEFT JOIN utilisateurs a ON t.administrateur_id=a.utilisateur_id ' . 'LEFT JOIN utilisateurs_entreprise f ON t.facturable_id=f.utilisateur_id ' . 'LEFT JOIN taches ta ON ta.tache_id=b.tache' , 'TEMPTABLE'); diff --git a/inc/commons/class.common.filtre.php b/inc/commons/class.common.filtre.php index 2b368a341..c0542847e 100644 --- a/inc/commons/class.common.filtre.php +++ b/inc/commons/class.common.filtre.php @@ -18,7 +18,7 @@ class commonFiltre { protected function getValues() { global $core; - if ($this->varname == 'equipier' || $this->varname == 'equipier_participe') { + if ($this->varname == 'equipier' || $this->varname == 'equipier_participe' || $this->varname == 'admin_book' || $this->varname=='admin_client') { $r = $core->con->select('SELECT prenom,utilisateur_id FROM equipiers'); while ($r->fetch()) { $this->values[$r->prenom] = $r->utilisateur_id; @@ -58,6 +58,8 @@ class commonFiltre { } elseif ($this->varname == 'demande_moi') { $this->values = array(__('Moi') => 'moi', __('Autres') => 'autres'); $this->all = __('Toutes'); + }elseif($this->varname=='ws_grade'){ + $this->values=array_flip($core->ws_grades); } } diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 3684b7771..b839ae9f2 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -115,6 +115,18 @@ class wsAjax extends cubeAjax { $x->addContent('listeClients', wsUrl::listeClients()); } + public static function filtreClients($args, &$x) + { + if (isset($args[1]) && $args[1] == 'efface') { + commonAjax::filtre('clients'); + $x->addReload(); + return; + } else { + commonAjax::filtre('clients', $_POST); + $x->addContent('listeClients', wsUrl::listeClients()); + } + } + public static function supprimeBook($args, &$x) { global $core; diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 3d7a086c8..3b6a449ae 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -15,7 +15,9 @@ class wsUrl { if (wsDroits::revendeur(false)) { $filtres[] = new commonFiltre(__('Status'), 'status_book', $settings['filtres']); } - $filtres[] = new commonFiltre(__('Année'), 'annee_book', $settings['filtres']); + if (wsDroits::admin()) { + $filtres[] = new commonFiltre(__('Administrateur'), 'admin_book', $settings['filtres']); + } $res = commonPage::barre($filtres , 'filtreBooks', 'books', $shortcuts); $res .= commonPage::tMain(null, true); $res .= commonPage::bh(); @@ -672,6 +674,10 @@ html{height:100%}' . "\n"; $shortcuts[] = '' . $core->typo->Ajouter('Créer un nouveau client') . ''; $filtres = array(); + if (wsDroits::admin()) { + $filtres[] = new commonFiltre(__('Grade'), 'ws_grade', $settings['filtres']); + $filtres[] = new commonFiltre(__('Administrateur'), 'admin_client', $settings['filtres']); + } $res = commonPage::barre($filtres, 'filtreClients', 'clients', $shortcuts); $res .= commonPage::tMain(); @@ -709,9 +715,9 @@ html{height:100%}' . "\n"; $res .= '' . commonUrl::orderby(__('Raison sociale'), 'nom', $settings, 'sort' . $change) . ''; $res .= '' . __('Contacts') . ''; if ($admin) { - $res .= '' . commonUrl::orderby(__('Grade'),'ws_grade',$settings,'sort',$change) . ''; - $res .= '' . commonUrl::orderby(__('Revendeur'),'revendeur',$settings,'sort',$change) . ''; - $res .= '' . commonUrl::orderby(__('Administrateur'),'administrateur',$settings,'sort',$change) . ''; + $res .= '' . commonUrl::orderby(__('Grade'), 'ws_grade', $settings, 'sort', $change) . ''; + $res .= '' . commonUrl::orderby(__('Revendeur'), 'revendeur', $settings, 'sort', $change) . ''; + $res .= '' . commonUrl::orderby(__('Administrateur'), 'administrateur', $settings, 'sort', $change) . ''; } $res .= ''; $i = 0; @@ -732,8 +738,8 @@ html{height:100%}' . "\n"; $res .= '' . implode(', ', $contacts) . ''; if ($admin) { - $rev=$client->ws_revendeur==''?'-':$client->ws_revendeur; - $adm=$client->ws_administrateur==''?'-':$client->ws_administrateur; + $rev = $client->ws_revendeur == ''?'-':$client->ws_revendeur; + $adm = $client->ws_administrateur == ''?'-':$client->ws_administrateur; $res .= '' . $core->ws_grades[$client->ws_grade] . ''; $res .= '' . $rev . ''; @@ -750,9 +756,9 @@ html{height:100%}' . "\n"; $odd = cubeMath::isOdd($i)?' class="odd"':''; $res .= ''; if ($admin) { - $res .= commonPage::pager($settings['page'], $dao->count() , $settings['par_page'], 'page' . $change . '/%d'); + $res .= commonPage::pager($settings['page'], $dao->count(null,'entreprises_ws') , $settings['par_page'], 'page' . $change . '/%d'); } else { - $res .= commonPage::pager($settings['page'], $dao->count($core->user) , $settings['par_page'], 'page' . $change . '/%d'); + $res .= commonPage::pager($settings['page'], $dao->count($core->user,'entreprises_ws') , $settings['par_page'], 'page' . $change . '/%d'); } $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('clients')); $res .= ''; diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 5aea76c7c..9be5e46ae 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -177,7 +177,7 @@ class wsDAOBook extends commonDAO { { $where = '(' . $this->makeWhereFromFiltres() . ')'; $where .= $this->limitToUserRights($limitedToUserRights); - $r = $this->con->select('SELECT COUNT(*) AS nb FROM books WHERE ' . $where); + $r = $this->con->select('SELECT COUNT(*) AS nb FROM books_vue WHERE ' . $where); return $r->nb; } @@ -316,8 +316,8 @@ class wsDAOBook extends commonDAO { { if (!is_null($this->filtres)) { $w = array('1=1'); - if (commonFiltre::test('annee_book', $this->filtres)) { - $w[] = 'YEAR(FROM_UNIXTIME(date)) IN (' . implode(',', array_keys($this->filtres['annee_book'])) . ')'; + if (commonFiltre::test('admin_book', $this->filtres)) { + $w[] = 'super_admin IN (' . implode(',', array_keys($this->filtres['admin_book'])) . ')'; } if (commonFiltre::test('status_book', $this->filtres)) { $w[] = 'status IN(' . implode(',', array_keys($this->filtres['status_book'])) . ')';