From fd084722b831fed3e58308dacf4ac9332039cb1d Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 10 Feb 2011 15:48:36 +0000 Subject: [PATCH] --- inc/commons/DAO/class.common.dao.entreprise.php | 12 ++++++++---- inc/commons/class.common.core.php | 10 ++++++++-- inc/ws/Controlleur/class.ws.url.php | 2 +- inc/ws/Controlleur/class.ws.users.tree.php | 11 ++++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/inc/commons/DAO/class.common.dao.entreprise.php b/inc/commons/DAO/class.common.dao.entreprise.php index e103155b9..ccbb8107b 100644 --- a/inc/commons/DAO/class.common.dao.entreprise.php +++ b/inc/commons/DAO/class.common.dao.entreprise.php @@ -11,8 +11,12 @@ class commonDAOEntreprise extends commonDAO { $entreprise->pays = $r->pays; $entreprise->tva_intra = $r->tva_intra; $entreprise->notes = $r->notes; - $entreprise->impaye = $r->impaye; - $entreprise->ca = $r->ca; + if (isset($r->impaye)) { + $entreprise->impaye = $r->impaye; + } + if (isset($r->ca)) { + $entreprise->ca = $r->ca; + } $entreprise->adresse_facturation = $r->adresse_facturation; $entreprise->ws_admin = $r->ws_admin; $entreprise->ws_grade = $r->ws_grade; @@ -60,7 +64,7 @@ class commonDAOEntreprise extends commonDAO { return $res; } - public function getListe($orderby = null, $sens = null, $limit = null, $limitedToUserRights = false) + public function getListe($orderby = null, $sens = null, $limit = null, $limitedToUserRights = false, $table = 'entreprises_vue') { $where = '('; if (!is_null($this->q)) { @@ -81,7 +85,7 @@ class commonDAOEntreprise extends commonDAO { $sens = is_null($sens)?'DESC':$sens; $limit = is_null($limit)?'':$this->con->limit($limit[0], $limit[1]); - $sql = 'SELECT * FROM entreprises_vue WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit; + $sql = 'SELECT * FROM ' . $table . ' WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit; $r = $this->con->select($sql); $ids = array(); diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index f9a578340..31af511be 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -389,6 +389,12 @@ class commonCore extends cubeCore { $db->ws_users_tree->administrateur_id('integer', 0, false); // Clé $db->ws_users_tree->primary('pk_utilisateur_id', 'utilisateur_id'); + // Table des entreprises + $db->ws_entreprises_tree->entreprise_id('integer', 0, false); + $db->ws_entreprises_tree->facturable_entreprise_id('integer', 0, false); + $db->ws_entreprises_tree->administrateur_id('integer', 0, false); + // Clés + $db->ws_entreprises_tree->primary('pk_entreprise_id', 'entreprise_id'); // Table des demandes de devis $db->demandes->demande_id('integer', 0, false); $db->demandes->type('integer', 0, false); @@ -430,7 +436,7 @@ class commonCore extends cubeCore { . 'LEFT JOIN ws_users_tree ri ON ri.entreprise_id=e.entreprise_id ' . 'LEFT JOIN entreprises r ON ri.facturable_entreprise_id=r.entreprise_id ' . 'LEFT JOIN utilisateurs a ON ri.administrateur_id=a.utilisateur_id ' - . ''); + . 'GROUP BY e.entreprise_id'); $this->views->createView('clients_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation ' . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0'); $this->views->createView('utilisateurs_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, ' @@ -439,7 +445,7 @@ class commonCore extends cubeCore { $this->views->createView('clients', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, i.impaye, ' . 'SUM(f.total_ht) AS ca ' . 'FROM entreprises e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0 LEFT JOIN projets p ON p.client=u.utilisateur_id LEFT JOIN factures f ON f.projet=p.projet_id AND f.status IN(1,2) ' - . 'GROUP BY u.utilisateur_id','TEMPTABLE'); + . 'GROUP BY u.utilisateur_id', 'TEMPTABLE'); $this->views->createView('taches_vue', 'SELECT taches.tache_id,taches.nom,taches.categorie,taches.type,taches.budget,taches.projet,taches.taux_journalier, ' . '(SUM(timereport.heures)/' . JOURNEE . ') AS jours_consommes, ((SUM(timereport.heures)/' . JOURNEE . ')/(taches.budget/taches.taux_journalier))*100 AS progression,(taches.budget/taches.taux_journalier) AS jours_prevus ' . 'FROM taches LEFT JOIN timereport ON taches.tache_id=timereport.tache_id ' diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index cd1c52d4c..2ada646c8 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -705,7 +705,7 @@ html{height:100%}' . "\n"; $i = 0; foreach($liste as $id => $client) { if (!is_array($client->contacts)) { - continue; + $client->contacts=array(); } $odd = cubeMath::isOdd($i)?' class="odd"':''; $res .= ''; diff --git a/inc/ws/Controlleur/class.ws.users.tree.php b/inc/ws/Controlleur/class.ws.users.tree.php index 453ba7f54..925cc7995 100644 --- a/inc/ws/Controlleur/class.ws.users.tree.php +++ b/inc/ws/Controlleur/class.ws.users.tree.php @@ -19,6 +19,7 @@ class wsUsersTree { public function refreshWSUsersTree() { $this->con->execute('TRUNCATE TABLE ws_users_tree'); + $this->con->execute('TRUNCATE TABLE ws_entreprises_tree'); $this->users = array(); $this->admins = array(); @@ -44,16 +45,20 @@ class wsUsersTree { $this->facturables = $this->getFacturables(); // Fabrication de l'arbre $c = $this->con->openCursor('ws_users_tree'); + $ce=$this->con->openCursor('ws_entreprises_tree'); foreach($this->users as $utilisateur_id => $admin) { $facturable_id = $administrateur_id = 0; $this->getFacturableOf($utilisateur_id, $facturable_id, $administrateur_id, 1); $c->utilisateur_id = $utilisateur_id; - $c->entreprise_id = $this->entreprises[$utilisateur_id]; + $ce->entreprise_id=$c->entreprise_id = $this->entreprises[$utilisateur_id]; $c->facturable_id = $facturable_id; - $c->facturable_entreprise_id = $this->entreprises[$facturable_id] ; - $c->administrateur_id = $administrateur_id; + $ce->facturable_entreprise_id=$c->facturable_entreprise_id = $this->entreprises[$facturable_id] ; + $ce->administrateur_id=$c->administrateur_id = $administrateur_id; $c->insert(); + $ce->insert(); + + } // Fabrication de la liste des droits à partir de l'arbre for($i = 1;$i <= 4;$i++) { -- 2.39.5