From: vincent@cubedesigners.com Date: Fri, 23 Jan 2015 16:41:21 +0000 (+0000) Subject: Add fluidbook pages data in "Chiffres" X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1de7e053fad0d0008b4b424fcc2090f22a21de8f;p=cubeextranet.git Add fluidbook pages data in "Chiffres" --- diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 0ce34e21a..393de5b3b 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -31,28 +31,28 @@ class commonCore extends cubeCore { $this->grades = array(0 => __('Client'), 1 => __('Equipier'), 2 => __('Gérant'), 3 => __('Comptable')); $this->categories = array(0 => __('Non défini'), 1 => __('Gestion de projet'), - 2 => __('Design Web'), 3 => __('Design Industriel'), 4 => __('Print'), - 5 => __('Newsletter'), 6 => __('Développement PHP'), 7 => __('Développement Flash'), - 8 => __('Fluidbook'), 9 => __('Formation'), 10 => __('Administratif'), 11 => __('Divers'), - 12 => __('Intégration HTML'), 13 => __('Motion design'), 14 => __('Design graphique'), - 15 => __('Bandeaux de pub'), 16 => __('Applications mobiles'), 17 => __('Prise de vue photo/vidéo'), 18 => __('Hébergement')); + 2 => __('Design Web'), 3 => __('Design Industriel'), 4 => __('Print'), + 5 => __('Newsletter'), 6 => __('Développement PHP'), 7 => __('Développement Flash'), + 8 => __('Fluidbook'), 9 => __('Formation'), 10 => __('Administratif'), 11 => __('Divers'), + 12 => __('Intégration HTML'), 13 => __('Motion design'), 14 => __('Design graphique'), + 15 => __('Bandeaux de pub'), 16 => __('Applications mobiles'), 17 => __('Prise de vue photo/vidéo'), 18 => __('Hébergement')); $this->projets_status = array(0 => __('En cours'), 1 => __('Terminé')); $this->devis_status = array(0 => __('Brouillon'), 1 => __('Envoyé'), - 2 => __('Validé'), 3 => __('Refusé')); + 2 => __('Validé'), 3 => __('Refusé')); $this->demandes_status = array(0 => __('Non traitée'), 1 => __('Confiée à un revendeur'), 2 => __('Traitée')); $this->factures_status = array(0 => __('Brouillon'), 1 => __('Attente'), - 2 => __('Payée'), 3 => __('Annulée'), 4 => __('Avoir'), 5 => __('Impayée')); + 2 => __('Payée'), 3 => __('Annulée'), 4 => __('Avoir'), 5 => __('Impayée')); $this->books_status = array(-1 => __('Brouillon'), 0 => __('Prêt'), 1 => __('Téléchargé'), 2 => __('Facturé')); $this->agences = array('Paris', 'Montpellier'); - $this->client_type=array(0=>__('Non défini'),1=>__('TPE'),2=>__('Startup'),3=>__('PME'),4=>__('Agence'),5=>__('Grande entreprise')); + $this->client_type = array(0 => __('Non défini'), 1 => __('TPE'), 2 => __('Startup'), 3 => __('PME'), 4 => __('Agence'), 5 => __('Grande entreprise')); $this->demandes_type = array(0 => __('Non défini'), - 1 => __('Catalogue'), - 2 => __('Magazine / Presse'), - 3 => __('Rapport annuel'), - 4 => __('Plaquette de société'), - 5 => __('Brochure touristique'), - 6 => __("Manuel d'utilisation"), - 7 => __('Livre')); + 1 => __('Catalogue'), + 2 => __('Magazine / Presse'), + 3 => __('Rapport annuel'), + 4 => __('Plaquette de société'), + 5 => __('Brochure touristique'), + 6 => __("Manuel d'utilisation"), + 7 => __('Livre')); $this->ws_grades = array(0 => __("Pas d'accès"), 1 => __('Client'), 2 => __('Client (droits de création)'), 3 => __('Revendeur'), 4 => __('Revendeur (droits de création)'), 5 => __('Administrateur')); } @@ -170,7 +170,7 @@ class commonCore extends cubeCore { $db->entreprises->date_creation('integer', 0, false); $db->entreprises->notes('text', 0, false); $db->entreprises->site('varchar', 256, false); - $db->entreprises->type('integer',0,false); + $db->entreprises->type('integer', 0, false); $db->entreprises->ws_signatures('text', 0, false); // Clés $db->entreprises->primary('pk_entreprises', 'entreprise_id'); @@ -534,79 +534,79 @@ class commonCore extends cubeCore { $this->views->createView('equipiers', 'SELECT * FROM utilisateurs WHERE grade>=1'); $this->views->createView('gerants', 'SELECT * FROM utilisateurs WHERE grade=2'); $this->views->createView('impayes_entreprises', 'SELECT SUM(total_ht) AS impaye, u.entreprise AS entreprise ' - . 'FROM utilisateurs u LEFT JOIN projets p ON u.utilisateur_id=p.client LEFT JOIN factures f ON f.projet=p.projet_id ' - . 'WHERE f.status=1 GROUP BY u.entreprise'); + . 'FROM utilisateurs u LEFT JOIN projets p ON u.utilisateur_id=p.client LEFT JOIN factures f ON f.projet=p.projet_id ' + . 'WHERE f.status=1 GROUP BY u.entreprise'); $this->views->createView('entreprises_inter', 'SELECT e.*,' - . 'SUM(f.total_ht) AS ca ' - . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND 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 e.entreprise_id'); + . 'SUM(f.total_ht) AS ca ' + . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND 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 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'); + . '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,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 ' - . 'LEFT JOIN entreprises r ON ur.entreprise=r.entreprise_id ' - . 'LEFT JOIN utilisateurs a ON ri.administrateur_id=a.utilisateur_id '); + . '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 ' + . 'LEFT JOIN entreprises r ON ur.entreprise=r.entreprise_id ' + . 'LEFT JOIN utilisateurs a ON ri.administrateur_id=a.utilisateur_id '); $this->views->createView('clients_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, e.site AS site, e.type AS type ' - . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0'); + . '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, ' - . 'e.ws_grade, e.ws_admin, e.ws_signatures AS ws_signatures, e.site AS site ' - . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id'); + . 'e.ws_grade, e.ws_admin, e.ws_signatures AS ws_signatures, e.site AS site ' + . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id'); $this->views->createView('clients', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, e.site AS site, 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'); + . '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'); $this->views->createView('taches_books', 'SELECT tache,GROUP_CONCAT(book_id ORDER BY book_id ASC SEPARATOR ",") AS books FROM books WHERE tache>0 GROUP BY tache'); $this->views->createView('taches_vue', 'SELECT taches.tache_id,taches.nom,taches.categorie,taches.type,taches.budget,taches.projet,taches.taux_journalier,tb.books, ' - . '(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 ' - . 'LEFT JOIN taches_books tb ON tb.tache=taches.tache_id ' - . 'GROUP BY taches.tache_id'); + . '(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 ' + . 'LEFT JOIN taches_books tb ON tb.tache=taches.tache_id ' + . 'GROUP BY taches.tache_id'); $this->views->createView('taches_projet', 'SELECT projet, ' - . 'SUM(jours_prevus) AS jours_prevus,SUM(budget) AS budget, ' - . 'SUM(jours_consommes) AS jours_consommes, (SUM(jours_consommes)/SUM(jours_prevus))*100 AS progression ' - . 'FROM taches_vue GROUP BY projet'); - - $this->views->createView('taches_projet_hf', 'SELECT projet, ' - . 'SUM(jours_prevus) AS jours_prevus,SUM(budget) AS budget, ' - . 'SUM(jours_consommes) AS jours_consommes, (SUM(jours_consommes)/SUM(jours_prevus))*100 AS progression ' - . 'FROM taches_vue WHERE categorie!=8 GROUP BY projet'); - + . 'SUM(jours_prevus) AS jours_prevus,SUM(budget) AS budget, ' + . 'SUM(jours_consommes) AS jours_consommes, (SUM(jours_consommes)/SUM(jours_prevus))*100 AS progression ' + . 'FROM taches_vue GROUP BY projet'); + + $this->views->createView('taches_projet_hf', 'SELECT projet, ' + . 'SUM(jours_prevus) AS jours_prevus,SUM(budget) AS budget, ' + . 'SUM(jours_consommes) AS jours_consommes, (SUM(jours_consommes)/SUM(jours_prevus))*100 AS progression ' + . 'FROM taches_vue WHERE categorie!=8 GROUP BY projet'); + $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 ' - . 'FROM devis,clients,equipiers ' - . 'WHERE devis.client=clients.utilisateur_id AND devis.createur=equipiers.utilisateur_id'); + . 'FROM devis,clients,equipiers ' + . 'WHERE devis.client=clients.utilisateur_id AND devis.createur=equipiers.utilisateur_id'); $this->views->createView('factures_payees', 'SELECT * FROM factures WHERE status=2'); $this->views->createView('factures_valides', 'SELECT * FROM factures WHERE status IN(1,2,5)'); $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,' - . 'YEAR(FROM_UNIXTIME(projets.date_debut)) AS annee_debut,' - . 'IF(date_fin=0,YEAR(NOW()),YEAR(FROM_UNIXTIME(projets.date_fin))) AS annee_fin,' - . 'clients.rs AS client,equipiers.prenom AS chef,equipiers.utilisateur_id AS chef_id,clients.utilisateur_id AS client_id ' - . 'FROM projets JOIN clients_entreprise clients ON projets.client=clients.utilisateur_id ' - . 'JOIN equipiers ON projets.chef=equipiers.utilisateur_id'); + . 'YEAR(FROM_UNIXTIME(projets.date_debut)) AS annee_debut,' + . 'IF(date_fin=0,YEAR(NOW()),YEAR(FROM_UNIXTIME(projets.date_fin))) AS annee_fin,' + . 'clients.rs AS client,equipiers.prenom AS chef,equipiers.utilisateur_id AS chef_id,clients.utilisateur_id AS client_id ' + . 'FROM projets JOIN clients_entreprise clients ON projets.client=clients.utilisateur_id ' + . 'JOIN equipiers ON projets.chef=equipiers.utilisateur_id'); $this->views->createView('projets_facturation', 'SELECT projet,SUM(IF(status IN(1,2,5),total_ht,0)) AS montant_facture, SUM(IF(status=2,total_ht,0)) AS montant_paye FROM factures GROUP BY projet'); $this->views->createView('projets_vue', 'SELECT p.*,f.montant_facture,f.montant_paye, ' - . 't.jours_prevus,t.jours_consommes,t.progression,t.budget AS budget, ' - . 'IF(t.budget>0,f.montant_paye/t.budget,1) AS rapport_paiement, ' - . 'IF(t.budget>0,f.montant_facture/t.budget,1) AS rapport_facturation ' - . 'FROM projets_inter p ' - . 'LEFT JOIN projets_facturation f ON f.projet=p.projet_id ' - . 'LEFT JOIN taches_projet t ON p.projet_id=t.projet'); - - $this->views->createView('projets_vue_hf', 'SELECT p.*,f.montant_facture,f.montant_paye, ' - . 't.jours_prevus,t.jours_consommes,t.progression,t.budget AS budget, ' - . 'IF(t.budget>0,f.montant_paye/t.budget,1) AS rapport_paiement, ' - . 'IF(t.budget>0,f.montant_facture/t.budget,1) AS rapport_facturation ' - . 'FROM projets_inter p ' - . 'LEFT JOIN projets_facturation f ON f.projet=p.projet_id ' - . 'LEFT JOIN taches_projet_hf t ON p.projet_id=t.projet'); - + . 't.jours_prevus,t.jours_consommes,t.progression,t.budget AS budget, ' + . 'IF(t.budget>0,f.montant_paye/t.budget,1) AS rapport_paiement, ' + . 'IF(t.budget>0,f.montant_facture/t.budget,1) AS rapport_facturation ' + . 'FROM projets_inter p ' + . 'LEFT JOIN projets_facturation f ON f.projet=p.projet_id ' + . 'LEFT JOIN taches_projet t ON p.projet_id=t.projet'); + + $this->views->createView('projets_vue_hf', 'SELECT p.*,f.montant_facture,f.montant_paye, ' + . 't.jours_prevus,t.jours_consommes,t.progression,t.budget AS budget, ' + . 'IF(t.budget>0,f.montant_paye/t.budget,1) AS rapport_paiement, ' + . 'IF(t.budget>0,f.montant_facture/t.budget,1) AS rapport_facturation ' + . 'FROM projets_inter p ' + . 'LEFT JOIN projets_facturation f ON f.projet=p.projet_id ' + . 'LEFT JOIN taches_projet_hf t ON p.projet_id=t.projet'); + $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,' - . 'projets.projet_id AS projet_id,projets.nom AS projet,clients.utilisateur_id AS client_id,clients.rs as client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id ' - . 'FROM factures,projets,equipiers,clients ' - . 'WHERE factures.projet=projets.projet_id AND clients.utilisateur_id=projets.client AND factures.createur=equipiers.utilisateur_id AND (factures.facture_id>=0 OR factures.status=1) '); + . 'projets.projet_id AS projet_id,projets.nom AS projet,clients.utilisateur_id AS client_id,clients.rs as client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id ' + . 'FROM factures,projets,equipiers,clients ' + . 'WHERE factures.projet=projets.projet_id AND clients.utilisateur_id=projets.client AND factures.createur=equipiers.utilisateur_id AND (factures.facture_id>=0 OR factures.status=1) '); $this->views->createView('projets_timereport', 'SELECT * FROM projets_vue WHERE status=0'); $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'); $this->views->createView('catype', 'SELECT SUM(total_ht) AS ca, YEAR(FROM_UNIXTIME(date_creation)) annee FROM factures_vue WHERE status BETWEEN 1 AND 4 GROUP BY annee'); @@ -615,60 +615,64 @@ class commonCore extends cubeCore { $this->views->createView('cam', 'SELECT SUM(total_ht) AS ca, DATE_FORMAT(FROM_UNIXTIME(date_creation),\'%Y-%m\') mois FROM factures WHERE status BETWEEN 1 AND 4 GROUP BY mois'); $this->views->createView('cat', 'SELECT SUM(total_ht) AS ca, CONCAT_WS(\'-\',YEAR(FROM_UNIXTIME(date_creation)),QUARTER(FROM_UNIXTIME(date_creation))) trimestre FROM factures WHERE status BETWEEN 1 AND 4 GROUP BY trimestre'); $this->views->createView('ftpaccess', 'SELECT email AS userid,password AS passwd,utilisateur_id AS uid,' - . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell ' - . 'FROM utilisateurs WHERE grade=0 ' - . 'UNION ' - . 'SELECT email AS userid,ws_password AS passwd,utilisateur_id AS uid,' - . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell ' - . 'FROM utilisateurs WHERE grade=0 AND ws_password!=\'\''); + . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell ' + . 'FROM utilisateurs WHERE grade=0 ' + . 'UNION ' + . 'SELECT email AS userid,ws_password AS passwd,utilisateur_id AS uid,' + . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell ' + . 'FROM utilisateurs WHERE grade=0 AND ws_password!=\'\''); $this->views->createView('chiffres_categories', 'SELECT p.annee_fin AS annee, t.categorie, SUM(t.budget) AS ca ' - . 'FROM projets_vue p, taches_vue t ' - . 'WHERE t.projet=p.projet_id ' - . 'GROUP BY t.categorie,p.annee_fin'); + . 'FROM projets_vue p, taches_vue t ' + . 'WHERE t.projet=p.projet_id ' + . 'GROUP BY t.categorie,p.annee_fin'); $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 ' - . 'FROM projets_vue p, taches_vue t ' - . 'WHERE t.projet=p.projet_id ' - . 'GROUP BY t.categorie,p.annee_fin'); + . 'FROM projets_vue p, taches_vue t ' + . 'WHERE t.projet=p.projet_id ' + . 'GROUP BY t.categorie,p.annee_fin'); $this->views->createView('collections_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 ' - . 'FROM book_collection b ' - . 'LEFT JOIN utilisateurs_entreprise c ON b.proprietaire=c.utilisateur_id '); + . 'CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS proprietaire_nom,' + . 'CONCAT(c.prenom,\' \',c.nom) AS proprietaire_utilisateur ' + . 'FROM book_collection b ' + . 'LEFT JOIN utilisateurs_entreprise c ON b.proprietaire=c.utilisateur_id '); $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'); + . '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'); + $this->views->createView('books_nbpages_vue', 'SELECT book_id, MAX(book_page) AS nb_pages ' + . 'FROM book_pages ' + . 'GROUP BY book_id'); + $this->views->createView('books_analysis', 'SELECT b.book_id,p.nb_pages ' + . 'FROM books_vue b LEFT JOIN books_nbpages_vue p ON b.book_id=p.book_id ' + . 'WHERE b.nom NOT LIKE \'%demo%\' AND b.status>0'); $this->views->createView('themes_books_nb', 'SELECT theme,COUNT(*) AS nb FROM books GROUP BY theme'); $this->views->createView('themes_vue', 'SELECT t.*, b.nb as nbBooks, CONCAT(e.prenom,\' \',e.nom,\' (\',e.rs,\')\') AS proprietaire_nom ' - . 'FROM themes t ' - . 'LEFT JOIN themes_books_nb b ON t.theme_id=b.theme ' - . 'LEFT JOIN utilisateurs_entreprise e ON t.proprietaire=e.utilisateur_id'); + . 'FROM themes t ' + . 'LEFT JOIN themes_books_nb b ON t.theme_id=b.theme ' + . 'LEFT JOIN utilisateurs_entreprise e ON t.proprietaire=e.utilisateur_id'); $this->views->createView('demandes_vue', 'SELECT d.*, CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS utilisateur_nom, CONCAT(r.rs,\' (\',r.prenom,\' \',r.nom,\')\') AS revendeur_nom, c.entreprise AS entreprise, a.prenom AS administrateur_nom ' - . 'FROM demandes d ' - . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id ' - . 'LEFT JOIN utilisateurs_entreprise c ON d.utilisateur=c.utilisateur_id ' - . 'LEFT JOIN utilisateurs a ON d.administrateur=a.utilisateur_id'); - - $this->views->createView('chiffres_types','SELECT p.annee_fin AS annee, e.type, SUM(p.budget) AS ca ' - .'FROM projets_vue p, clients_entreprise e ' - .'WHERE p.client_id=e.utilisateur_id ' - .'GROUP BY e.type, p.annee_fin'); - - $this->views->createView('chiffres_types_hf','SELECT p.annee_fin AS annee, e.type, SUM(p.budget) AS ca ' - .'FROM projets_vue_hf p, clients_entreprise e ' - .'WHERE p.client_id=e.utilisateur_id ' - .'GROUP BY e.type, p.annee_fin'); - - + . 'FROM demandes d ' + . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id ' + . 'LEFT JOIN utilisateurs_entreprise c ON d.utilisateur=c.utilisateur_id ' + . 'LEFT JOIN utilisateurs a ON d.administrateur=a.utilisateur_id'); + $this->views->createView('chiffres_types', 'SELECT p.annee_fin AS annee, e.type, SUM(p.budget) AS ca ' + . 'FROM projets_vue p, clients_entreprise e ' + . 'WHERE p.client_id=e.utilisateur_id ' + . 'GROUP BY e.type, p.annee_fin'); + $this->views->createView('chiffres_types_hf', 'SELECT p.annee_fin AS annee, e.type, SUM(p.budget) AS ca ' + . 'FROM projets_vue_hf p, clients_entreprise e ' + . 'WHERE p.client_id=e.utilisateur_id ' + . 'GROUP BY e.type, p.annee_fin'); + + //cubeDb::mysqlConvert($this->con, 'UTF8', 'utf8_general_ci', 'MYISAM'); touch($cache); } diff --git a/inc/extranet/Controlleur/class.extranet.page.chiffres.php b/inc/extranet/Controlleur/class.extranet.page.chiffres.php index 1326d546c..3b5a8d27b 100644 --- a/inc/extranet/Controlleur/class.extranet.page.chiffres.php +++ b/inc/extranet/Controlleur/class.extranet.page.chiffres.php @@ -60,12 +60,13 @@ class extranetPageChiffres { commonDroits::min(2); $res = self::chiffresAnnee($encours); $res .= self::caGlobal($chiffres, $total, $encours); - $res.=self::caTrimestre(); - $res.=self::caMensuel(); + $res .= self::caTrimestre(); + $res .= self::caMensuel(); $res .= self::caCategorie($chiffres, $total); $res .= self::caWorkRate($chiffres, $total); $res .= self::caSegments($chiffres, $total); $res .= self::caSegmentsHf($chiffres, $total); + $res .= self::fluidbookPages(); return $res; } @@ -153,7 +154,7 @@ class extranetPageChiffres { $i = self::format($impayes[$annee]); } $res .= '' . $i . ''; - + } $res .= '' . self::format($total) . ''; $res .= ''; @@ -186,18 +187,18 @@ class extranetPageChiffres { for ($i = 1; $i <= 4; $i++) { $res .= 'T' . $i . ''; } - $res.='' . __('Total') . ''; + $res .= '' . __('Total') . ''; $res .= ''; foreach ($chiffres as $annee => $trimestres) { $res .= ''; $total = 0; - $res.='' . $annee . ''; + $res .= '' . $annee . ''; foreach ($trimestres as $trimestre => $ca) { $res .= '' . self::format($ca) . ''; $total += $ca; } - $res.='' . self::format($total) . ''; + $res .= '' . self::format($total) . ''; $res .= ''; } @@ -230,18 +231,18 @@ class extranetPageChiffres { for ($i = 1; $i <= 12; $i++) { $res .= '' . cubeDate::getMonth($i) . ''; } - $res.='' . __('Total') . ''; + $res .= '' . __('Total') . ''; $res .= ''; foreach ($chiffres as $annee => $moiss) { $res .= ''; $total = 0; - $res.='' . $annee . ''; + $res .= '' . $annee . ''; foreach ($moiss as $mois => $ca) { $res .= '' . self::format($ca) . ''; $total += $ca; } - $res.='' . self::format($total) . ''; + $res .= '' . self::format($total) . ''; $res .= ''; } @@ -312,8 +313,7 @@ class extranetPageChiffres { $res .= commonPage::bf(); return $res; } - - + public static function caCategoriesChart($a, $datas, $type, $width, $height, $max = 7) { global $core; @@ -366,35 +366,55 @@ class extranetPageChiffres { } $chart->addData($cac); $chart->addData($cae); - return $chart->display($title); + return $chart->display($title, '', '', '&chbh=a,5,0'); + } + + public static function fluidbookPagesChart($data) { + global $core; + + $title = __("Répartition des fluidbook par nombre de pages"); + $chart = new cubeGoogleCharts('bvs', 940, 200); + $chart->setTitle($title); + $max = 0; + foreach ($data as $pages => $qty) { + + $max = max($qty, $max); + } + $ratio = floor($max / 100); + $d = array(); + foreach ($data as $pages => $qty) { + $cae[] = ($qty / $ratio); + } + $chart->addData($cae); + return $chart->display($title, '', '', '&chbh=a,0,0'); } - - public static function caSegments($chiffres, $total){ + + public static function caSegments($chiffres, $total) { global $core; - return self::_caSegment('SELECT * FROM chiffres_types ORDER BY annee,type',__("CA par type de client")); + return self::_caSegment('SELECT * FROM chiffres_types ORDER BY annee,type', __("CA par type de client")); } - - - public static function caSegmentsHf($chiffres, $total){ + + + public static function caSegmentsHf($chiffres, $total) { global $core; - return self::_caSegment('SELECT * FROM chiffres_types_hf ORDER BY annee,type',__("CA par type de client").'
('.__('Hors Fluidbook').')'); + return self::_caSegment('SELECT * FROM chiffres_types_hf ORDER BY annee,type', __("CA par type de client") . '
(' . __('Hors Fluidbook') . ')'); } - + public static function caSegmentChart($a, $datas, $type, $width, $height, $max = 7) { global $core; $title = sprintf(__('Répartition pour %d'), $a); $chart = new cubeGoogleCharts($type, $width, $height); $chart->setTitle($title); - + $total = array_sum($datas); $i = 1; $others = 0; - - $types=$core->client_type; - $types[3]='TPE / PME'; - + + $types = $core->client_type; + $types[3] = 'TPE / PME'; + foreach ($datas as $c => $ca) { - if($c==0){ + if ($c == 0) { continue; } if ($i <= $max) { @@ -410,51 +430,51 @@ class extranetPageChiffres { return $chart->display($title); } - - protected static function _caSegment($req,$title){ - global $core; - $r = $core->con->select($req); - $segments=array(); - while($r->fetch()){ - $annees[]=$r->annee; - $segments[$r->type][$r->annee]=$r->ca; - } - - $chiffresa=array(); - $chiffreta=array(); - foreach($segments as $type=>$tab){ - - if($type==1){ - $type=3; - } - foreach($tab as $a=>$ca){ - if(!isset($chiffresa[$a])){ - $chiffresa[$a]=array(); - $chiffreta[$a]=0; + + protected static function _caSegment($req, $title) { + global $core; + $r = $core->con->select($req); + $segments = array(); + while ($r->fetch()) { + $annees[] = $r->annee; + $segments[$r->type][$r->annee] = $r->ca; + } + + $chiffresa = array(); + $chiffreta = array(); + foreach ($segments as $type => $tab) { + + if ($type == 1) { + $type = 3; + } + foreach ($tab as $a => $ca) { + if (!isset($chiffresa[$a])) { + $chiffresa[$a] = array(); + $chiffreta[$a] = 0; } - if(!isset($chiffresa[$a][$type])){ - $chiffresa[$a][$type]=0; + if (!isset($chiffresa[$a][$type])) { + $chiffresa[$a][$type] = 0; } - $chiffresa[$a][$type]+=$ca; - $chiffreta[$a]+=$ca; + $chiffresa[$a][$type] += $ca; + $chiffreta[$a] += $ca; } - + } - - $annees=array_unique($annees); + + $annees = array_unique($annees); sort($annees); - - + + $res = commonPage::bh(); $res .= ''; - + $res .= ''; - + $res .= ''; foreach ($annees as $annee) { $total_annee[$annee] = 0; @@ -469,11 +489,11 @@ class extranetPageChiffres { $res .= ''; $total_type = 0; - + foreach ($annees as $annee) { if (isset($tab[$annee])) { $ca = self::format($tab[$annee], true); - $part=round(($tab[$annee]/$chiffreta[$annee])*100).'%'; + $part = round(($tab[$annee] / $chiffreta[$annee]) * 100) . '%'; $col = $ca . ' (' . $part . ')'; $total_type += $tab[$annee]; $total_annee[$annee] += $tab[$annee]; @@ -484,7 +504,7 @@ class extranetPageChiffres { $res .= ''; } - $res .= ''; + $res .= ''; $res .= ''; $i++; } @@ -493,11 +513,11 @@ class extranetPageChiffres { if (isset($total_annee[$annee])) { $c = $total_consomme_annee[$annee]; $p = $total_prevu_annee[$annee]; - $res .= ''; + $res .= ''; } } - - $res .= ''; + + $res .= ''; $res .= ''; $res .= '
'; $a = date('Y') - 1; $res .= self::caSegmentChart($a, $chiffresa[$a], 'p3', 440, 150); $a++; $res .= self::caSegmentChart($a, $chiffresa[$a], 'p3', 500, 200); $res .= '
' . $title . '' . $core->client_type[$type] . '' . $col . '' . self::format($total_type, true).'' . self::format($total_type, true) . '
' . self::format($total_annee[$annee], true) .'' . self::format($total_annee[$annee], true) . '' . ''.'' . '' . '
'; $res .= commonPage::bf(); @@ -575,6 +595,55 @@ class extranetPageChiffres { return $res; } + public static function fluidbookPages() { + global $core; + + $r = $core->con->select('SELECT * FROM books_analysis'); + $pas = 4; + $precision = 1 / $pas; + $data = array(); + $max = 0; + while ($r->fetch()) { + $n = min(300, cubeMath::round($r->nb_pages, $precision, 'ceil')); + if (!isset($data[$n])) { + $data[$n] = 0; + } + $data[$n]++; + $max = max($max, $n); + } + fb($max); + for ($i = 0; $i <= $max; $i += $pas) { + if (!isset($data[$i])) { + $data[$i] = 0; + } + } + + ksort($data); + + $res = commonPage::bh(); + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + + + foreach ($data as $pages => $qty) { + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + } + + + $res .= '
'; + $res .= self::fluidbookPagesChart($data); + $res .= '
' . __("Nombre de pages des Fluidbook") . '' . __("Nombre de pages") . '' . __("Quantité") . '
' . $pages . '' . $qty . '
'; + $res .= commonPage::bf(); + return $res; + } + public static function format($nb, $euro = true, $ifzero = '-') { if ($euro) { $nb = $nb / 1000;