]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 15 Sep 2010 10:07:04 +0000 (10:07 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 15 Sep 2010 10:07:04 +0000 (10:07 +0000)
inc/extranet/Controlleur/class.extranet.core.php
inc/extranet/Controlleur/class.extranet.url.php
inc/extranet/DAO/class.extranet.dao.fichier.php
inc/extranet/DAO/class.extranet.dao.projet.php
inc/extranet/Metier/class.extranet.projet.php

index af5c2bb77faedf7d58093cd64099273875c2e3e0..d5cecedd64ba7909cd71d8e2ccc165e33bf47f26 100644 (file)
@@ -107,6 +107,8 @@ class extranetCore extends cubeCore {
                        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
@@ -166,7 +168,6 @@ class extranetCore extends cubeCore {
                $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
@@ -373,84 +374,84 @@ class extranetCore extends cubeCore {
                        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
index 9a153ebb365841114384b7dab493bf98f20b2b14..f21f5e64ec3fbf0d7e702fe022be06f40d576296 100644 (file)
@@ -2122,8 +2122,9 @@ class extranetUrl {
        {\r
                $root = ROOT . '/cache/download/';\r
                cubeFiles::scanRecursiveDir($root, $files);\r
+               $limit = TIME-7200;\r
                foreach($files as $f) {\r
-                       if (filemtime($f) + 7200 < TIME) {\r
+                       if (filemtime($f) < $limit) {\r
                                unlink($f);\r
                        }\r
                }\r
@@ -2134,6 +2135,13 @@ class extranetUrl {
                        }\r
                }\r
        }\r
+\r
+       public static function deleteOldFilesFromFTP($args)\r
+       {\r
+               global $core;\r
+               $dao=new extranetDAOFichier($core->con);\r
+               $dao->deleteOldFiles();\r
+       }\r
 }\r
 \r
 ?>
\ No newline at end of file
index 3913d0382efaae5a404ae30379be8bc28d1c832f..a02c6fa568d0f23a48b0ab21d7e0f2c13369f9fc 100644 (file)
@@ -7,7 +7,7 @@ class extranetDAOFichier extends extranetDAO {
                $rel_path = str_replace(FTPROOT, '', $path);\r
                $fichier = new extranetFichier();\r
                $fichier->contact = $infos['contact'];\r
-               $fichier->destinataire=$infos['destinataire'];\r
+               $fichier->destinataire = $infos['destinataire'];\r
                $e = explode('/', $path);\r
                $fichier->chemin = $path;\r
                $fichier->nom = array_pop($e);\r
@@ -122,6 +122,25 @@ class extranetDAOFichier extends extranetDAO {
                        unlink(FTPROOT . $path);\r
                }\r
        }\r
+\r
+       public function deleteOldFiles()\r
+       {\r
+               $root = FTPROOT;\r
+               cubeFiles::scanRecursiveDir($root, $files);\r
+\r
+               $limit = TIME-3600 * 24 * 60; // 60 days\r
+\r
+               $size = 0;\r
+\r
+               foreach($files as $f) {\r
+                       if (filemtime($f) < $limit) {\r
+                               fb(date('Y-m-d', filemtime($f)), $f);\r
+                               $size += filesize($f);\r
+                               unlink($f);\r
+                       }\r
+               }\r
+               fb(files::size($size), 'Size of files deleted');\r
+       }\r
 }\r
 \r
 ?>
\ No newline at end of file
index f9e992640e2b0eccf1f15b1d886c31944687b108..e87a1a5163f9549470b65b00dd6e8f3cabb717e4 100644 (file)
@@ -27,7 +27,6 @@ class extranetDAOProjet extends extranetDAO {
                $projet->progression = round($r->progression);\r
                $projet->budget = round($r->budget);\r
 \r
-               $projet->old = $r->old;\r
                $projet->rapport_facturation = $r->rapport_facturation;\r
                $projet->rapport_paiement = $r->rapport_paiement;\r
 \r
index 402fc42a2f7d9ac4f74bda4500c5f4e54c6cd8f4..e8cc8260be2bc4496ad2ec074d90a59f6dab8a1d 100644 (file)
@@ -22,7 +22,6 @@ class extranetProjet extends cubeMetier {
        protected $annee_fin;\r
        protected $rapport_facturation;\r
        protected $rapport_paiement;\r
-       protected $old;\r
 }\r
 \r
 ?>
\ No newline at end of file