]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 11 Jan 2013 15:34:35 +0000 (15:34 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 11 Jan 2013 15:34:35 +0000 (15:34 +0000)
inc/commons/class.common.tools.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/DAO/class.ws.dao.book.php

index 7ba49c280ae11e01b3ec675c0154a3c7c4f3ccf3..73aad54993c4285af326a46aeffbab32d3d4b96a 100644 (file)
@@ -177,6 +177,54 @@ class commonTools {
                return $res;
        }
 
+       public static function exportClients($args) {
+               global $core;
+
+               $types = array('Cubedesigners' => 'cube', 'Tous les contacts (Clients de revendeurs inclus)' => 'all');
+               $typeexp = array('Entreprises' => 'entreprises', 'Utilisateurs' => 'users');
+
+               $res = commonPage::barre();
+               $res .= commonPage::tMain();
+               $res .= commonPage::bh();
+               $res.='<form action="' . SITE_PATH . 'tools/exportClientsXLS" method="post" class="notajax">';
+               $res.='<table class="liste">';
+               $res.='<tr><th colspan="3"><strong>' . __('Exporter la base clients') . '</strong></th></tr>';
+               $res.='<tr><td>' . __('Type de client') . '</td><td>' . form::combo('type', $types) . '</td></td>';
+               $res.='<tr><td>' . __('Type d\'export') . '</td><td>' . form::combo('typeexp', $typeexp) . '</td></tr>';
+               $res.='<tr class="odd"><td class="right" colspan="2"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Exporter')) . '</a></td></td>';
+               $res.='</table>';
+               $res.='</form>';
+               $res .= '</div>';
+               $res .= commonPage::bf();
+               $res .= commonPage::bMain();
+               return $res;
+       }
+
+       public static function exportClientsXLS($args) {
+               global $core;
+
+               $sql = 'SELECT * FROM entreprises_ws';
+               if ($_POST['type'] == 'cube') {
+                       $sql.=" WHERE revendeur = 'Cubedesigners'";
+               }
+
+               $r = $core->con->select($sql);
+               $entreprises = array();
+               $rows = $r->rows();
+               foreach ($rows as $r) {
+
+                       $entreprises[$r['entreprise_id']] = $r;
+                       $entreprises[$r['entreprise_id']]['utilisateurs'] = array();
+               }
+
+               $r = $core->con->select('SELECT * FROM utilisateurs_entreprise WHERE entreprise IN(' . implode(',', array_keys($entreprises)) . ')');
+               $rows = $r->rows();
+               foreach ($rows as $r) {
+                       $entreprises[$r['entreprise']]['utilisateurs'][$r['utilisateur_id']] = $r;
+               }
+               fb($entreprises);
+       }
+
        public static function favicon($args) {
                global $core;
                $res = commonPage::barre();
@@ -740,5 +788,4 @@ class commonTools {
        }
 
 }
-
 ?>
index ffc3b7a4ed6a4d34ea29ae9be308d84eacf41ee9..45894e8e0c35e5775e15f2edd65166f29cbcefa3 100644 (file)
@@ -254,12 +254,14 @@ class wsServices extends cubeFlashGateway {
                $daoBook = new wsDAOBook($core->con);\r
                $book = $daoBook->selectById($book_id);\r
 \r
+\r
                if (is_null($book)) {\r
                        return;\r
                }\r
 \r
                // Normalize range\r
                $range = cubeArray::parseRange($range);\r
+\r
                if ($k = array_search(0, $range)) {\r
                        $range[$k] = 1;\r
                }\r
@@ -271,7 +273,7 @@ class wsServices extends cubeFlashGateway {
                        return;\r
                }\r
                // Paths init\r
-               $baseDocument = WS_BOOKS . '/final/' . $book->book_id . '/data/document.pdf';\r
+               $baseDocument = WS_BOOKS . '/final/' . $book->book_id . '/data/' . $book->parametres->pdfName;\r
                if (!file_exists($baseDocument)) {\r
                        return;\r
                }\r
index 4dba61203d5e32392d5ca663083e698c260aa104..1b12c79a90883bcb54d20371fa143da9fb86d16a 100644 (file)
@@ -1366,6 +1366,7 @@ class wsDAOBook extends commonDAO {
                                }\r
                        }\r
                } else {\r
+\r
                        if (file_exists($normalPDF)) {\r
                                $fmtime = filemtime($normalPDF);\r
                                if ($fmtime >= $book->composition_update) {\r
@@ -1376,6 +1377,8 @@ class wsDAOBook extends commonDAO {
                                                        $invalid = true;\r
                                                }\r
                                        }\r
+                               } else {\r
+                                       $invalid = true;\r
                                }\r
                        } else {\r
                                $invalid = true;\r