global $core;\r
$dao = new wsDAOBook($core->con);\r
$dao->supprime($args[1]);\r
- $x->addContent('listeBooks', extranetUrl::listeBooks());\r
+ $x->addContent('listeBooks', wsUrl::listeBooks());\r
}\r
\r
public static function searchBooks($args, &$x)\r
2 => __('Validé'), 3 => __('Refusé'));\r
$this->factures_status = array(0 => __('Brouillon'), 1 => __('Attente'),\r
2 => __('Payée'), 3 => __('Annulée'), 4 => __('Avoir'));\r
- $this->books_status = array(0 => __('Prêt'), 1 => __('Téléchargé'), 2 => __('Facturé'));\r
+ $this->books_status = array(-1 => __('Brouillon'), 0 => __('Prêt'), 1 => __('Téléchargé'), 2 => __('Facturé'));\r
$this->agences = array('Paris', 'Montpellier');\r
}\r
\r
. 'GROUP BY u.utilisateur_id');\r
$this->createView('ws_clients', 'SELECT u.*,e.nom AS rs, e1.nom as facturable '\r
. 'FROM ws_utilisateurs u, entreprises e, entreprises e1,ws_utilisateurs u1 '\r
- . 'WHERE u.entreprise=e.entreprise_id AND u1.entreprise=e1.entreprise_id AND u.facturable_id=u1.utilisateur_id AND u.grade=0 ');\r
+ . 'WHERE u.entreprise=e.entreprise_id AND u1.entreprise=e1.entreprise_id AND u.facturable_id=u1.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
. '(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
. '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,c.facturable_id,c.facturable '\r
- . 'FROM books b,ws_clients c WHERE b.proprietaire=c.utilisateur_id');\r
+ . 'FROM books b, ws_clients c WHERE b.proprietaire=c.utilisateur_id');\r
// cubeDb::mysqlConvert($this->con);\r
touch($cache);\r
}\r
$this->all = __('Tous');\r
$this->settings = isset($settings[$varname]) && count($settings[$varname])?$settings[$varname]:null;\r
$this->getValues();\r
- fb($this);\r
}\r
\r
protected function getValues()\r
\r
}\r
\r
- public function testDocuments(){\r
+ public function testDocuments()\r
+ {\r
+ $toload = $this->xml->addChild('toLoad');\r
+ $alreadyLoaded = $this->xml->addChild('alreadyLoaded');\r
+\r
+ foreach($this->args['fileName'] as $k => $name) {\r
+ $toload->addChild('file', $name);\r
+ }\r
+ }\r
\r
+ public function getPagesOfBook()\r
+ {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $pages = $dao->getPagesOfBook($this->args['book_id']);\r
+ $p = $this->xml->addChild('pages');\r
+ $docs = array();\r
+ foreach($pages as $page => $info) {\r
+ $pa = $p->addChild('page');\r
+ $pa->addAttribute('page', $page);\r
+ $pa->addAttribute('document_id', $info['document_id']);\r
+ $pa->addAttribute('document_page', $info['document_page']);\r
+ $docs[] = $info['document_id'];\r
+ }\r
+ $docs = array_unique($docs);\r
+ $p->addAttribute('documents', implode(',', $docs));\r
}\r
}\r
\r
$settings = $core->user->getSettings('books');\r
\r
$shortcuts = array();\r
- $shortcuts[] = '<a href="' . SITE_PATH . 'editebook/new">' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . '</a>';\r
+ $shortcuts[] = '<a href="' . SITE_PATH . 'editbook/new">' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . '</a>';\r
\r
$filtres = array();\r
$filtres[] = new extranetFiltre(__('Status'), 'status_book', $settings['filtres']);\r
$res .= '<td class="bouton"><a href="' . SITE_PATH . 'editbook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Editer('éditer', '', false)) . '</a></td>';\r
$res .= '<td class="bouton"><a href="' . SITE_PATH . 'supprimebook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Stats('stats', '', false)) . '</a></td>';\r
$res .= '<td class="bouton"><a href="' . SITE_PATH . 'supprimebook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Telecharger('télécharger', '', false)) . '</a></td>';\r
- $res .= '<td class="bouton"><a href="' . SITE_PATH . 'supprimebook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)) . '</a></td>';\r
+ $res .= '<td class="bouton"><a href="#" rel="supprimeBook/' . $book->book_id . '" class="ajax" title="'.__('Êtes-vous certain de vouloir supprimer cette publication ?').'">' . cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)) . '</a></td>';\r
$res .= '</tr>';\r
$i++;\r
}\r
{\r
global $core;\r
$book_id = $args[1];\r
+\r
+ if ($book_id == 'new') {\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->creeEmpty($core->user->utilisateur_id);\r
+ http::redirect(SITE_PATH . 'editbook/' . $book->book_id);\r
+ }\r
+\r
$step = isset($args[2])?$args[2]:1;\r
\r
$shortcuts = array();\r
$book->status = $r->status;\r
$book->date_status = $r->date_status;\r
$book->date = $r->date;\r
- $book->parametres = unserialize($r->parametres);\r
+ $book->pages = array();\r
+\r
+ $p = unserialize($r->parametres);\r
+ if (!$p) {\r
+ $p = new wsBookParametres();\r
+ }\r
+ $book->parametres = $p;\r
\r
return $book;\r
}\r
$book->date_status = TIME;\r
$book->date = TIME;\r
$book->parametres = new wsBookParametres();\r
+ $book->pages = array();\r
return $book;\r
}\r
\r
if (is_null($book_id)) {\r
return $this->cree();\r
}\r
-\r
+ $sql = 'SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1';\r
$r = $this->con->select('SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1');\r
return $this->singleton($r);\r
}\r
$c->date = TIME;\r
$c->hash = md5(rand(0, 1234567893));\r
$c->compteur_visites = 20;\r
+ $c->parametres = serialize(new wsParametres());\r
$book_id = $c->book_id = $this->getNextId();\r
+\r
$c->insert();\r
} else {\r
$book_id = $data['book_id'];\r
return $this->selectById($book_id);\r
}\r
\r
- public function supprime($devis_id)\r
+ public function creeEmpty($createur)\r
+ {\r
+ $c = $this->con->openCursor('books');\r
+ $c->proprietaire = $createur;\r
+ $c->date = TIME;\r
+ $c->hash = md5(rand(0, 1234567893));\r
+ $c->compteur_visites = 20;\r
+ $c->status = -1;\r
+ $c->date_status = TIME;\r
+ $c->parametres = serialize(new wsParametres());\r
+ $book_id = $c->book_id = $this->getNextId();\r
+ $c->insert();\r
+ fb($book_id);\r
+ return $this->selectById($book_id);\r
+ }\r
+\r
+ public function supprime($book_id)\r
{\r
return $this->con->execute('DELETE FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
}\r
return $r->nb;\r
}\r
\r
+ public function getPagesOfBook($book_id)\r
+ {\r
+ $pages = array();\r
+ $r = $this->con->select('SELECT * FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page');\r
+ while ($r->fetch()) {\r
+ $pages[$r->book_page] = array('document_id' => $r->document_id, 'document_page' => $r->document_page);\r
+ }\r
+ return $pages;\r
+ }\r
+\r
public function getListe($orderby = null, $sens = null, $limit = null)\r
{\r
if (!is_null($this->q)) {\r
protected $date;\r
\r
protected $parametres;\r
+\r
+ protected $pages;\r
}\r
\r
?>
\ No newline at end of file
$value = intval($value);\r
break;\r
default:\r
-\r
+ $value = (string)$value;\r
+ break;\r
} // switch\r
$this->datas[$varname] = $value;\r
}\r