return;\r
}\r
\r
+ $this->views->dropAllViews();\r
+\r
$db = new CubeDbStruct($this->con);\r
// Table utilisateurs\r
$db->utilisateurs->utilisateur_id('integer', 0, false);\r
$db->projets->client('integer', 0, false);\r
$db->projets->chef('integer', 0, false);\r
$db->projets->status('integer', 1, false);\r
- $db->projets->old('integer', 1, false);\r
// Clés\r
$db->projets->primary('pk_projets', 'projet_id');\r
$db->projets->index('index_projets_status', 'BTREE', 'status');\r
exit;\r
}\r
\r
- $this->createView('equipiers', 'SELECT * FROM utilisateurs WHERE grade>=1');\r
- $this->createView('gerants', 'SELECT * FROM utilisateurs WHERE grade=2');\r
- // $this->createView('ws_top_revendeurs', 'SELECT * FROM utilisateurs WHERE ws_grade=3 AND ws_admin IN(SELECT utilisateur_id FROM equipiers)');\r
- $this->createView('ws_revendeurs', 'SELECT * FROM utilisateurs WHERE ws_grade=3');\r
- $this->createView('ws_facturables', 'SELECT * FROM utilisateurs WHERE ws_grade BETWEEN 0 AND 3 AND ws_admin IN(SELECT utilisateur_id FROM equipiers)');\r
- $this->createView('impayes_entreprises', 'SELECT SUM(total_ht) AS impaye, u.entreprise AS entreprise '\r
+ $this->views->createView('equipiers', 'SELECT * FROM utilisateurs WHERE grade>=1');\r
+ $this->views->createView('gerants', 'SELECT * FROM utilisateurs WHERE grade=2');\r
+ // $this->views->createView('ws_top_revendeurs', 'SELECT * FROM utilisateurs WHERE ws_grade=3 AND ws_admin IN(SELECT utilisateur_id FROM equipiers)');\r
+ $this->views->createView('ws_revendeurs', 'SELECT * FROM utilisateurs WHERE ws_grade=3');\r
+ $this->views->createView('ws_facturables', 'SELECT * FROM utilisateurs WHERE ws_grade BETWEEN 0 AND 3 AND ws_admin IN(SELECT utilisateur_id FROM equipiers)');\r
+ $this->views->createView('impayes_entreprises', 'SELECT SUM(total_ht) AS impaye, u.entreprise AS entreprise '\r
. 'FROM utilisateurs u LEFT JOIN projets p ON u.utilisateur_id=p.client LEFT JOIN factures f ON f.projet=p.projet_id '\r
. 'WHERE f.status=1 GROUP BY u.entreprise');\r
- $this->createView('entreprises_inter', 'SELECT e.*,'\r
+ $this->views->createView('entreprises_inter', 'SELECT e.*,'\r
. 'SUM(f.total_ht) AS ca '\r
. 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND grade=0 '\r
. 'LEFT JOIN projets p ON p.client=u.utilisateur_id '\r
. 'LEFT JOIN factures f ON f.projet=p.projet_id AND f.status IN(1,2) '\r
. 'GROUP BY e.entreprise_id');\r
- $this->createView('entreprises_vue', 'SELECT e.*,i.impaye AS impaye'\r
+ $this->views->createView('entreprises_vue', 'SELECT e.*,i.impaye AS impaye'\r
. ' FROM entreprises_inter e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise');\r
- $this->createView('clients_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation '\r
+ $this->views->createView('clients_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation '\r
. 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0');\r
- $this->createView('clients', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, i.impaye, '\r
+ $this->views->createView('clients', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, i.impaye, '\r
. 'SUM(f.total_ht) AS ca '\r
. '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) '\r
. 'GROUP BY u.utilisateur_id');\r
- $this->createView('taches_vue', 'SELECT taches.tache_id,taches.nom,taches.categorie,taches.type,taches.budget,taches.projet,taches.taux_journalier, '\r
+ $this->views->createView('taches_vue', 'SELECT taches.tache_id,taches.nom,taches.categorie,taches.type,taches.budget,taches.projet,taches.taux_journalier, '\r
. '(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 '\r
. 'FROM taches LEFT JOIN timereport ON taches.tache_id=timereport.tache_id '\r
. 'GROUP BY taches.tache_id');\r
- $this->createView('taches_projet', 'SELECT projet, '\r
+ $this->views->createView('taches_projet', 'SELECT projet, '\r
. 'SUM(jours_prevus) AS jours_prevus,SUM(budget) AS budget,'\r
. 'SUM(jours_consommes) AS jours_consommes, (SUM(jours_consommes)/SUM(jours_prevus))*100 AS progression '\r
. 'FROM taches_vue GROUP BY projet');\r
- $this->createView('devis_vue', 'SELECT devis.devis_id,devis.nom,devis.lignes,devis.status,devis.total_ht,devis.date_creation,devis.email,clients.utilisateur_id AS client_id,clients.rs AS client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id,devis.adresse '\r
+ $this->views->createView('devis_vue', 'SELECT devis.devis_id,devis.nom,devis.lignes,devis.status,devis.total_ht,devis.date_creation,devis.email,clients.utilisateur_id AS client_id,clients.rs AS client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id,devis.adresse '\r
. 'FROM devis,clients,equipiers '\r
. 'WHERE devis.client=clients.utilisateur_id AND devis.createur=equipiers.utilisateur_id');\r
- $this->createView('factures_vue', 'SELECT factures.facture_id,factures.nom,factures.lignes,factures.status,factures.total_ht,factures.date_creation,factures.texte_complementaire,factures.informations_paiement,factures.date_paiement,factures.adresse,factures.avoir,'\r
+ $this->views->createView('factures_vue', 'SELECT factures.facture_id,factures.nom,factures.lignes,factures.status,factures.total_ht,factures.date_creation,factures.texte_complementaire,factures.informations_paiement,factures.date_paiement,factures.adresse,factures.avoir,'\r
. 'projets.projet_id AS projet_id,projets.nom AS projet,projets.client_id AS client_id,projets.client as client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id '\r
. 'FROM factures,projets_vue projets,equipiers '\r
. 'WHERE factures.projet=projets.projet_id AND factures.createur=equipiers.utilisateur_id AND (factures.facture_id>=0 OR factures.status=1) ');\r
- $this->createView('factures_payees', 'SELECT * FROM factures WHERE status=2');\r
- $this->createView('factures_valides', 'SELECT * FROM factures WHERE status=1 OR status=2');\r
- $this->createView('projets_inter', 'SELECT projets.projet_id,projets.nom,projets.status,projets.date_debut,projets.date_fin,projets.date_creation,projets.deadline,projets.devis,projets.old,'\r
+ $this->views->createView('factures_payees', 'SELECT * FROM factures WHERE status=2');\r
+ $this->views->createView('factures_valides', 'SELECT * FROM factures WHERE status IN(1,2)');\r
+ $this->views->createView('projets_inter', 'SELECT projets.projet_id,projets.nom,projets.status,projets.date_debut,projets.date_fin,projets.date_creation,projets.deadline,projets.devis,'\r
. 'YEAR(FROM_UNIXTIME(projets.date_debut)) AS annee_debut,'\r
. 'IF(YEAR(FROM_UNIXTIME(projets.date_fin))=1970,YEAR(NOW()),YEAR(FROM_UNIXTIME(projets.date_fin))) AS annee_fin,'\r
. 'clients.rs AS client,equipiers.prenom AS chef,equipiers.utilisateur_id AS chef_id,clients.utilisateur_id AS client_id '\r
- . 'FROM projets,clients,equipiers '\r
- . 'WHERE clients.utilisateur_id=projets.client AND equipiers.utilisateur_id=projets.chef');\r
- $this->createView('projets_inter1', 'SELECT projets.*,taches.jours_prevus,taches.jours_consommes,taches.progression,taches.budget AS budget, '\r
+ . 'FROM projets,clients_entreprise clients,equipiers '\r
+ . 'WHERE clients.utilisateur_id=projets.client AND equipiers.utilisateur_id=projets.chef','TEMPTABLE');\r
+ $this->views->createView('projets_inter1', 'SELECT projets.*,taches.jours_prevus,taches.jours_consommes,taches.progression,taches.budget AS budget, '\r
. 'IF(taches.budget>0,SUM(factures_valides.total_ht)/taches.budget,1) AS rapport_facturation, '\r
. 'SUM(factures_valides.total_ht) AS montant_facture '\r
. 'FROM projets_inter projets '\r
. 'LEFT JOIN taches_projet taches ON taches.projet=projets.projet_id '\r
. 'LEFT JOIN factures_valides ON factures_valides.projet=projets.projet_id '\r
- . 'GROUP BY projets.projet_id,factures_valides.projet');\r
- $this->createView('projets_vue', 'SELECT p.*,SUM(f.total_ht) AS montant_paye, '\r
+ . 'GROUP BY projets.projet_id,factures_valides.projet','TEMPTABLE');\r
+ $this->views->createView('projets_vue', 'SELECT p.*,SUM(f.total_ht) AS montant_paye, '\r
. 'IF(p.budget>0,SUM(f.total_ht)/p.budget,1) AS rapport_paiement '\r
. 'FROM projets_inter1 p '\r
. 'LEFT JOIN factures_payees f ON f.projet=p.projet_id '\r
- . 'GROUP BY p.projet_id');\r
- $this->createView('projets_timereport', 'SELECT * FROM projets_vue WHERE status=0');\r
- $this->createView('order_timereport', 'SELECT utilisateur_id,projet AS projet_id,MAX(date) AS derniere_activite FROM timereport,taches,projets WHERE taches.tache_id=timereport.tache_id AND taches.projet=projets.projet_id AND projets.status=0 GROUP BY utilisateur_id,taches.projet ORDER BY utilisateur_id ASC,MAX(date) DESC');\r
- $this->createView('ca', 'SELECT SUM(total_ht) AS ca, YEAR(FROM_UNIXTIME(date_creation)) annee FROM factures WHERE status IN(1,2) GROUP BY annee');\r
- $this->createView('ftpaccess', 'SELECT email AS userid,password AS passwd,utilisateur_id AS uid,'\r
+ . 'GROUP BY p.projet_id', 'TEMPTABLE');\r
+ $this->views->createView('projets_timereport', 'SELECT * FROM projets_vue WHERE status=0');\r
+ $this->views->createView('order_timereport', 'SELECT utilisateur_id,projet AS projet_id,MAX(date) AS derniere_activite FROM timereport,taches,projets WHERE taches.tache_id=timereport.tache_id AND taches.projet=projets.projet_id AND projets.status=0 GROUP BY utilisateur_id,taches.projet ORDER BY utilisateur_id ASC,MAX(date) DESC');\r
+ $this->views->createView('ca', 'SELECT SUM(total_ht) AS ca, YEAR(FROM_UNIXTIME(date_creation)) annee FROM factures WHERE status IN(1,2) GROUP BY annee');\r
+ $this->views->createView('ftpaccess', 'SELECT email AS userid,password AS passwd,utilisateur_id AS uid,'\r
. '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell '\r
. 'FROM utilisateurs WHERE grade=0 '\r
. 'UNION '\r
. 'SELECT email AS userid,ws_password AS passwd,utilisateur_id AS uid,'\r
. '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell '\r
. 'FROM utilisateurs WHERE grade=0 AND ws_password!=\'\'');\r
- $this->createView('chiffres_categories', 'SELECT p.annee_fin AS annee, t.categorie, SUM(t.budget) AS ca '\r
+ $this->views->createView('chiffres_categories', 'SELECT p.annee_fin AS annee, t.categorie, SUM(t.budget) AS ca '\r
. 'FROM projets_vue p, taches_vue t '\r
. 'WHERE t.projet=p.projet_id '\r
. 'GROUP BY t.categorie,p.annee_fin');\r
- $this->createView('temps_categories', 'SELECT p.annee_fin AS annee, t.categorie, SUM(t.jours_consommes) AS jours_consommes,SUM(t.jours_prevus) AS jours_prevus '\r
+ $this->views->createView('temps_categories', 'SELECT p.annee_fin AS annee, t.categorie, SUM(t.jours_consommes) AS jours_consommes,SUM(t.jours_prevus) AS jours_prevus '\r
. 'FROM projets_vue p, taches_vue t '\r
. 'WHERE t.projet=p.projet_id '\r
. 'GROUP BY t.categorie,p.annee_fin');\r
- $this->createView('books_vue', 'SELECT b.*,b.proprietaire AS proprietaire_id,c.rs AS proprietaire_nom,c.ws_admin '\r
- . 'FROM books b, clients_entreprise c WHERE b.proprietaire=c.utilisateur_id');\r
- $this->createView('themes_vue', 'SELECT t.*,COUNT(b.book_id) AS nb_books,GROUP_CONCAT(DISTINCT b.book_id ORDER BY b.book_id ASC) AS books '\r
+ $this->views->createView('books_vue', 'SELECT b.*,b.proprietaire AS proprietaire_id,c.rs AS proprietaire_nom,c.ws_admin '\r
+ . 'FROM books b, clients_entreprise c WHERE b.proprietaire=c.utilisateur_id', 'TEMPTABLE');\r
+ $this->views->createView('themes_vue', 'SELECT t.*,COUNT(*) AS nb_books,GROUP_CONCAT(DISTINCT b.book_id) AS books '\r
. 'FROM themes t '\r
. 'LEFT JOIN books b ON t.theme_id=b.theme '\r
. 'GROUP BY t.theme_id');\r