]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 14 Feb 2011 13:53:39 +0000 (13:53 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 14 Feb 2011 13:53:39 +0000 (13:53 +0000)
inc/commons/class.common.core.php
inc/ws/Controlleur/class.ws.flash.php
inc/ws/DAO/class.ws.dao.theme.php
inc/ws/Metier/class.ws.theme.php

index fe60dd7b4390b04014c0d830ecfb4d484ce6349c..5f5f47f64c7ed2a582784a80b2127fe86153e57d 100644 (file)
@@ -511,10 +511,11 @@ class commonCore extends cubeCore {
                         . 'LEFT JOIN utilisateurs_entreprise f ON t.facturable_id=f.utilisateur_id '\r
                         . 'LEFT JOIN taches ta ON ta.tache_id=b.tache' ,\r
                        'TEMPTABLE');\r
-               $this->views->createView('themes_vue', 'SELECT t.*,COUNT(*) AS nb_books,GROUP_CONCAT(DISTINCT b.book_id) AS books '\r
+               $this->views->createView('themes_books_nb', 'SELECT theme,COUNT(*) AS nb FROM books GROUP BY theme');\r
+               $this->views->createView('themes_vue', 'SELECT t.*, b.nb as nbBooks, CONCAT(e.prenom,\' \',e.nom,\' (\',e.rs,\')\') AS proprietaire_nom '\r
                         . 'FROM themes t '\r
-                        . 'LEFT JOIN books b ON t.theme_id=b.theme '\r
-                        . 'GROUP BY t.theme_id');\r
+                        . 'LEFT JOIN themes_books_nb b ON t.theme_id=b.theme '\r
+                        . 'LEFT JOIN utilisateurs_entreprise e ON t.proprietaire=e.utilisateur_id');\r
                $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 '\r
                         . 'FROM demandes d '\r
                         . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id '\r
index 612dd0a6c4b2eed2c005cce0c7696e023ef98e41..b43c0bb71971ef0323881950aedd2adf4dcefc27 100644 (file)
@@ -289,10 +289,12 @@ class wsFlash extends cubeFlashGateway {
                if (isset($this->args['book_id'])) {\r
                        $dao = new wsDAOBook($core->con);\r
                        $book = $dao->selectById($this->args['book_id']);\r
+               } else {\r
+                       $this->args['book_id'] = 0;\r
                }\r
 \r
                $dao = new wsDAOTheme($core->con);\r
-               $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,1) DESC, theme_id DESC');\r
+               $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',1) DESC, theme_id DESC', true);\r
                foreach($themes as $theme) {\r
                        $t = $this->xml->addChild('theme');\r
                        $t->addAttribute('id', $theme->theme_id);\r
@@ -309,7 +311,8 @@ class wsFlash extends cubeFlashGateway {
                                $right = 'r';\r
                        }\r
                        $t->addAttribute('right', $right);\r
-                       $t->addAttribute('books', ($theme->nbBooks) - ($mine?'1':'0'));\r
+                       $t->addAttribute('proprietaire', $theme->proprietaire_nom);\r
+                       $t->addAttribute('books', max(($theme->nbBooks) - ($mine?1:0), 0));\r
                }\r
        }\r
 \r
index ab867b9a8114d9324e0d76bf706264e9b085e0ee..5180e1f4579ff1145186f6185e095ce4b6038169 100644 (file)
@@ -7,9 +7,11 @@ class wsDAOTheme extends commonDAO {
                $theme->nom = $r->nom;\r
                $theme->date = $r->date;\r
                $theme->proprietaire = $r->proprietaire;\r
-               if ($r->exists('books')) {\r
-                       $theme->books = explode(',', $r->books);\r
-                       $theme->nbBooks = $r->nb_books;\r
+               if ($r->exists('nbBooks')) {\r
+                       $theme->nbBooks = $r->nbBooks;\r
+               }\r
+               if ($r->exists('proprietaire_nom')) {\r
+                       $theme->proprietaire_nom = $r->proprietaire_nom;\r
                }\r
                $theme->signature = $r->signature;\r
                $theme->icones = $r->icones;\r
@@ -85,6 +87,13 @@ class wsDAOTheme extends commonDAO {
                if (!$onlyFiles) {\r
                        $this->con->execute('DELETE FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
                }\r
+               $fref = WS_THEMES . '/' . $theme_id;\r
+               if (file_exists($fref)) {\r
+                       files::deltree($fref);\r
+               }\r
+               if (file_exists($fref . '.jpg')) {\r
+                       unlink($fref . '.jpg');\r
+               }\r
        }\r
 \r
        public function rename($theme_id, $newname)\r
index 4f04dbbc7e27d3edca2e1b96643f3ac5aaebf673..b926cb9167f6fd2aa7c5569cdfb537e0cbe4fd3a 100644 (file)
@@ -22,8 +22,8 @@ class wsTheme extends cubeMetier {
        protected $nom;\r
        protected $date;\r
        protected $parametres;\r
-       protected $books;\r
-       protected $nbBooks;\r
+       protected $proprietaire_nom;\r
+       protected $nbBooks = 0;\r
 }\r
 \r
 ?>
\ No newline at end of file