-<?php\r
-\r
-class wsUrl {\r
-\r
- public static function publications($args) {\r
- global $core;\r
-\r
- if (isset($args[1])) {\r
- $_SESSION['q'] = $args[1];\r
- }\r
-\r
- $settings = $core->user->getSettings('books');\r
-\r
- $shortcuts = array();\r
- if (wsDroits::creation()) {\r
- $shortcuts[] = '<a href="#" class="popup" rel="newBookForm">' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . '</a>';\r
- }\r
-\r
- $filtres = array();\r
- if (wsDroits::revendeur(false)) {\r
- $filtres[] = new commonFiltre(__('Status'), 'status_book', $settings['filtres']);\r
- }\r
- if (wsDroits::admin()) {\r
- $filtres[] = new commonFiltre(__('Administrateur'), 'admin_book', $settings['filtres']);\r
- $filtres[] = new commonFiltre(__('Revendeur'), 'revendeur_book', $settings['filtres']);\r
- }\r
- $res = commonPage::barre($filtres, 'filtreBooks', 'books', $shortcuts, wsDroits::creation());\r
- $res .= commonPage::tMain(null, wsDroits::creation());\r
- $res .= commonPage::bh();\r
- $res .= '<div id="listeBooks">';\r
- $res .= self::listeBooks();\r
- $res .= '</div>';\r
- $res .= commonPage::bf();\r
- $res .= commonPage::bMain();\r
- return $res;\r
- }\r
-\r
- public static function listeBooks($dashboard = null, $settings = null) {\r
- global $core;\r
- cubePage::truePopup();\r
- cubePage::autocomplete();\r
- cubePage::contextMenu();\r
-\r
- $droits = wsDroits::getDroits();\r
-\r
- commonDroits::min(1);\r
- $settings = is_null($settings) ? $core->user->getSettings('books') : $settings;\r
- $change = is_null($dashboard) ? 'Books' : 'Dashboard/' . $dashboard;\r
- $dao = new wsDAOBook($core->con);\r
- $context_download_id = is_null($dashboard) ? 'contextDownloadBook' : 'contextDashboard_Download' . $dashboard;\r
- $context_status_id = is_null($dashboard) ? 'contextStatusBook' : 'contextDashboard_Status' . $dashboard;\r
- $context_view_id = is_null($dashboard) ? 'contextViewBook' : 'contextView_Status' . $dashboard;\r
-\r
- if (isset($settings['search']) && !is_null($settings['search'])) {\r
- $dao->setSearch($settings['search']);\r
- }\r
- $dao->setFiltres($settings['filtres']);\r
- $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user);\r
-\r
- $res = '';\r
-\r
- $res .= self::contextBookDownload($context_download_id, $droits);\r
- $res .= self::contextBookStatus($context_status_id);\r
- $res .= self::contextBookView($context_view_id);\r
-\r
- $res .= '<table class="liste">';\r
- $res .= '<tr><th>' . commonUrl::orderby('#', 'book_id', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Titre de la publication'), 'nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Date'), 'date', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__(''), 'lang', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . __('Pages') . '</th>';\r
- if ($droits->admin) {\r
- $res .= '<th>' . commonUrl::orderby('C', 'demo_counter', $settings, 'sort' . $change, __('Compteur de démos')) . '</th>';\r
- }\r
- if ($droits->revendeur) {\r
- $res .= '<th>' . commonUrl::orderby(__('Proprietaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '</th>';\r
- } else {\r
- $res .= '<th>' . commonUrl::orderby(__('Proprietaire'), 'proprietaire_utilisateur', $settings, 'sort' . $change) . '</th>';\r
- }\r
- if ($droits->admin) {\r
- $res .= '<th>' . commonUrl::orderby(__('Facturation'), 'facturable', $settings, 'sort' . $change) . '</th>';\r
- }\r
- if ($droits->revendeur) {\r
- $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . __('V') . '</th>';\r
- }\r
- $res .= str_repeat('<th class="min"></th>', 5);\r
- $res .= '</tr>';\r
- $i = 0;\r
-\r
- $btVoir = '<div></div><span>' . __('voir') . '</span>';\r
- $btEdit = '<div></div><span>' . __('éditer') . '</span>';\r
- $btStats = '<div></div><span>' . __('stats') . '</span>';\r
- $btDownload = '<div></div><span>' . __('télécharger') . '</span>';\r
- if ($droits->creation) {\r
- $btDel = '<div></div><span>' . __('suppr.') . '</span>';\r
- }\r
-\r
- foreach ($liste as $id => $book) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '>';\r
- $res .= '<td>' . $book->book_id . '</td>';\r
- $res .= '<td>' . html::escapeHTML($book->nom) . '</td>';\r
- $res .= '<td>' . date('Y-m-d', $book->date) . '</td>';\r
- $res .= '<td>' . mb_strtoupper($book->lang) . '</td>';\r
- $res .= '<td>' . $book->parametres->pages . '</td>';\r
- if ($droits->admin) {\r
- $res.='<td>' . $book->demo_counter . '</td>';\r
- }\r
-\r
- if ($droits->revendeur) {\r
- $p = str_replace(" (", '<br /><em>', html::escapeHTML($book->proprietaire));\r
- $p = str_replace(')', '</em>', $p);\r
- $res .= '<td><a href="#" class="popup" rel="formChangeBookProprietaire/' . $book->book_id . '" title="' . __('Modifier le proprietaire') . '">' . $p . '</a></td>';\r
- } else {\r
- $res .= '<td>' . html::escapeHTML($book->proprietaire_utilisateur) . '</td>';\r
- }\r
- if ($droits->admin) {\r
- $res .= '<td>' . html::escapeHTML($book->facturable) . '</td>';\r
- }\r
- if ($droits->revendeur) {\r
- if ($droits->admin || $book->status < 1) {\r
- $p = '';\r
- if (!is_null($book->projet)) {\r
- $p = ' <a href="' . EXTRANET_URL . '/projet/' . $book->projet . '" title="' . __('Voir les détails du projet') . '" class="blank icon">' . cubeMedia::silk('arrow_right.png') . '</a>';\r
- }\r
- $res .= '<td><a href="#" class="openContextMenu" rel="' . $context_status_id . '" rev="' . $book->book_id . '">' . $core->books_status[$book->status] . '</a>' . $p . '</td>';\r
- } else {\r
- $res .= '<td>' . $core->books_status[1] . '</td>';\r
- }\r
- $res.='<td>' . $book->version . '</td>';\r
- }\r
- if ($book->version > 1 || $droits->admin) {\r
- if ($droits->admin) {\r
- $res .= '<td class="bouton"><a href="/viewer/' . $book->book_id . '_' . $book->hash . '/" class="openContextMenu voir btbook" rel="' . $context_view_id . '" rev="' . $book->book_id . '§' . $book->hash . '§' . TIME . '">' . $btVoir . '</a></td>';\r
- } else {\r
- $viewURL = SITE_PATH . 'viewer/' . $book->book_id . '_' . $book->hash;\r
- if ($book->parametres->version == 1) {\r
- $viewURL = SITE_PATH . 'viewer1/' . $book->book_id . '_' . $book->hash;\r
- }\r
- $res .= '<td class="bouton"><a class="popupFSBar voir btbook" rel="toolbar=yes" rev="viewer_' . $book->book_id . '" href="' . $viewURL . '/">' . $btVoir . '</a></td>';\r
- }\r
- $res .= '<td class="bouton"><a class="popupFSBar edit btbook" rel="toolbar=yes" rev="editor_' . $book->book_id . '" href="' . SITE_PATH . 'editor/' . $book->book_id . '_' . $book->hash . '">' . $btEdit . '</a></td>';\r
- } else {\r
- $res.='<td></td><td></td>';\r
- }\r
- $res .= '<td class="bouton"><a href="' . SITE_PATH . 'stats/' . $book->book_id . '_' . $book->hash . '" class="normallink stats btbook">' . $btStats . '</a></td>';\r
- if ($book->version > 1) {\r
- if ($droits->admin) {\r
- $res .= '<td class="bouton"><a href="#" rel="exportbook/' . $book->book_id . '" class="popup download btbook">' . $btDownload . '</a></td>';\r
- } else {\r
- $res .= '<td class="bouton"><a href="#" class="openContextMenu download btbook" rel="' . $context_download_id . '" rev="' . $book->book_id . '">' . $btDownload . '</a></td>';\r
- }\r
- } else {\r
- $res.='<td></td>';\r
- }\r
- if ($droits->creation && $book->status < 0) {\r
- $res .= '<td class="bouton"><a href="#" rel="supprimeBook/' . $book->book_id . '" class="ajax suppr btbook" title="' . __('Êtes-vous certain de vouloir supprimer cette publication ?') . '">' . $btDel . '</a></td>';\r
- } else {\r
- $res.='<td></td>';\r
- }\r
- $res .= '</tr>';\r
- $i++;\r
- }\r
-\r
- if (!isset($settings['search']) || is_null($settings['search'])) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '><td colspan="15">';\r
- $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d');\r
- $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('publications'), false);\r
- $res .= '</td></tr>';\r
- }\r
- $res .= '</table>';\r
- return $res;\r
- }\r
-\r
- public static function collections() {\r
- global $core;\r
-\r
- if (isset($args[1])) {\r
- $_SESSION['q'] = $args[1];\r
- }\r
-\r
- $settings = $core->user->getSettings('collections');\r
- $shortcuts = array();\r
- if (wsDroits::creation()) {\r
- $shortcuts[] = '<a href="#" class="popup" rel="newCollectionForm">' . $core->typo->Ajouter(__('Créer une nouvelle collection')) . '</a>';\r
- }\r
-\r
- $filtres = array();\r
-\r
- $res = commonPage::barre($filtres, 'filtreCollections', 'collections', $shortcuts);\r
- $res .= commonPage::tMain(null);\r
- $res .= commonPage::bh();\r
- $res .= '<div id="listeCollections">';\r
- $res .= self::listeCollections();\r
- $res .= '</div>';\r
- $res .= commonPage::bf();\r
- $res .= commonPage::bMain();\r
- return $res;\r
- }\r
-\r
- public static function collection($args) {\r
- global $core;\r
- commonDroits::min(1);\r
- cubePage::ui('Sortable');\r
- cubePage::autocomplete();\r
-\r
- $dao = new wsDAOCollection($core->con);\r
- $collection = $dao->selectById($args[1]);\r
-\r
- $shortcuts = array();\r
-\r
- $res = commonPage::barre(null, null, null, $shortcuts);\r
- $res .= commonPage::tMain();\r
- $res .= commonPage::bh();\r
- $res .= '<div id="collection">';\r
- $res .= self::collectionEdit($collection);\r
- $res .= '</div>';\r
- $res .= commonPage::bf();\r
- $res .= commonPage::bMain();\r
- return $res;\r
- }\r
-\r
- public static function collectionEdit($collection) {\r
- global $core;\r
-\r
- $res = '<h1>Gestion de la collection « ' . $collection->nom . ' » <em># ' . $collection->collection_id . '</em></h1>';\r
- $res.='<form method="post" action="saveCollectionComposition" enctype="multipart/form-data">';\r
- $res.='<table class="max">';\r
- $res.='<tr><td class="min nowrap">#</td><td>' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('Nom de la collection') . '</td><td>' . form::field('nom', 20, 64, $collection->nom) . '</td></tr>';\r
- $res.='</table>';\r
- $res.='<h3>' . __('Composition') . '</h3>';\r
- $res.='<a href="#" id="newGroup">' . $core->typo->Ajouter(__('Nouveau groupe')) . '</a><br /><br />';\r
- $res .= '<ul>';\r
-\r
- $dao = new wsDAOCollection($core->con);\r
- $books = $dao->getPublications($collection->collection_id);\r
-\r
- $datas = $collection->datas;\r
- $datas['new_'] = $dao->_emptyGroup();\r
-\r
- $langs = array();\r
-\r
- foreach ($datas as $gid => $group) {\r
- $class = 'group';\r
- if ($gid && $gid == 'new_') {\r
- $class.=' empty';\r
- }\r
- $res.='<li class="' . $class . '" data-group="' . $gid . '">';\r
- $res.='<div class="g">';\r
- $res.='<a href="#" class="move"></a>';\r
- $g = 'group[' . $gid . ']';\r
- $res.=__('Nom du groupe') . ' ' . form::field(array($g . '[label]'), 20, 64, $group['label']);\r
- $res.='<a href="#" class="delete"></a>';\r
- $res.='</div>';\r
- $res.='<ul>';\r
- $res.='<li style="height:2px;"></li>';\r
-\r
- $publications = array_values($group['publications']);\r
- foreach ($publications as $pid => $publication) {\r
- if ($gid && $gid == 'new_') {\r
- $pid = 'pnew_';\r
- }\r
- $p = $g . '[publications][' . $pid . ']';\r
- $res.='<li class="publication" data-publication="' . $pid . '"><div>';\r
- if (isset($books[$publication['id']])) {\r
- $book = $books[$publication['id']];\r
- $langs[] = $book->lang;\r
- } else {\r
- $book = new stdClass();\r
- $book->lang = '';\r
- $book->nom = '';\r
- }\r
- $res.='<a href="#" class="move"></a>';\r
- $res.='<span class="lang">' . mb_strtoupper($book->lang) . '</span>';\r
- $res.='<span class="id"># ' . form::field(array($p . '[s]'), 64, 256, trim($publication['id'] . ' - ' . $book->nom, ' -'), 'publication_id') . form::hidden(array($p . '[id]'), $publication['id']) . '</span>';\r
- $res.='<span class="label">' . __('Label') . ' ' . form::field(array($p . '[label]'), 20, 64, $publication['label']) . '</span>';\r
- $res.='<a href="#" class="delete"></a>';\r
- $res.='<a href="#" class="add"></a>';\r
- $res.='<span class="online">' . form::checkbox(array($p . '[online]'), '1', $publication['online']) . '</span>';\r
- $res.='</div></li>';\r
- }\r
- $res.='</ul>';\r
- $res.='</li>';\r
- }\r
-\r
- $langs = array_unique($langs);\r
-\r
- $res.='</ul>';\r
-\r
- foreach ($langs as $l) {\r
- $res.='<h3>' . __('Contenus') . ' [' . $l . ']</h3>';\r
- $res.='<table class="max">';\r
- $res.='<tr><td class="min nowrap">' . __('Titre') . '</td><td>' . form::field(array('contents[' . $l . '][titre]', 'contents_' . $l . '_titre'), 64, 64, $collection->contents[$l]['titre']) . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('A propos') . '</td><td>' . form::textarea(array('contents[' . $l . '][apropos]', 'contents_' . $l . '_apropos'), 60, 10, $collection->contents[$l]['apropos']) . '</td></tr>';\r
- //'splash' => \r
- $res.='<tr><td class="min nowrap">' . __('Ecran de lancement') . ' (2048x2048px)</td><td><input type="file" name="splash_' . $l . '" />' . form::hidden(array('theme[splash_' . $l . ']', 'splash_' . $l), $collection->theme['splash_' . $l]) . '</td></tr>';\r
- $res.='</table>';\r
- }\r
-\r
- $v = wsHTML5Compiler::getPhonegapVersions();\r
- $phonegapVersions = array_combine($v, $v);\r
-\r
- $res.='<h3>' . __('Paramètres avancés') . '</h3>';\r
- $res.='<table class="max">';\r
- $res.='<tr><td class="min nowrap">' . __('Full offline') . '</td><td>' . form::checkbox(array('settings[offline]', 'offline'), 1, $collection->settings['offline']) . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('Version phonegap') . '</td><td>' . form::combo(array('settings[phonegap]', 'phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('Identifiant de l\'application') . '</td><td>' . form::field(array('settings[namespace]', 'namespace'), 64, 64, $collection->settings['namespace']) . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Dev (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_dev" /></td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Prod (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_prod" /></td></tr>';\r
- $res.='</table>';\r
-\r
- $res.='<h3>' . __('Applications offline') . '</h3>';\r
- $res.='<table class="max">';\r
- $res.='<tr><td class="min nowrap">' . __("Filtres d'exclusion") . '</td><td>' . form::textarea(array('settings[offline_exclude]', 'offline_exclude'), 30, 3, $collection->settings['offline_exclude']) . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __("Synchronisations supplémentaires") . '</td><td>' . form::textarea(array('settings[offline_syncs]', 'offline_syncs'), 30, 3, $collection->settings['offline_syncs']) . '</td></tr>';\r
- $res.='</table>';\r
-\r
- $res.='<h3>' . __('Thème') . '</h3>';\r
- $res.='<table class="max">';\r
- $images = array('back' => __('Image de fond'), 'etagere' => __("Image de l'étagère"), 'icon' => __("Icône de l'application") . ' (1024x1024px)');\r
- foreach ($images as $i => $label) {\r
- $res.='<tr><td class="min nowrap">' . $label . '</td><td><input type="file" name="' . $i . '" />' . form::hidden(array('theme[' . $i . ']', 'theme_' . $i), $collection->theme[$i]) . '</td></tr>';\r
- }\r
- $res.='<tr><td class="min nowrap">' . __('Couleur principale') . '</td><td>#' . form::field(array('settings[couleurA]', 'couleurA'), 6, 6, $collection->settings['couleurA']) . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('Couleur secondaire') . '</td><td>#' . form::field(array('settings[couleurB]', 'couleurB'), 6, 6, $collection->settings['couleurB']) . '</td></tr>';\r
- $res.='<tr><td class="min nowrap">' . __('Couleur des textes') . '</td><td>#' . form::field(array('settings[couleurC]', 'couleurC'), 6, 6, $collection->settings['couleurC']) . '</td></tr>';\r
-\r
- $res.='</table>';\r
-\r
- $res.='<a href="#" class="submit right">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>';\r
- $res.='</form>';\r
- $res.='<p class="clear"></p>';\r
- $res.='<h3>' . __('Versions') . '</h3>';\r
- $res.='<a href="#" class="ajax" rel="collectionVersionCreate/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Créer une version')) . '</a><br /><br />';\r
- $r = $core->con->select('SELECT * FROM book_collection_compile WHERE collection_id=\'' . $collection->collection_id . '\' ORDER BY compile_date DESC');\r
- if (!$r->count()) {\r
- $res.=__('Aucune version de la collection n\'a été crée');\r
- } else {\r
- $res.='<table class="max">';\r
- $res.='<tr><th class="left">' . __('Date') . '</th><th class="left">iOS</th><th class="left">Android</th><th class="min nowrap"></th></tr>';\r
- while ($r->fetch()) {\r
-\r
- if ($r->online_ios || $r->online_android) {\r
- $del = '';\r
- } else {\r
- $del = '<a class="ajax suppr btbook" rel="collectionVersionDelete/' . $r->collection_id . '/' . $r->compile_date . '" href="#" title="' . __('Êtes-vous certain de vouloir supprimer cette version ?') . '"><div></div><span>' . __('Effacer') . '</span></a>';\r
- }\r
-\r
- if ($r->online_ios) {\r
- $pub_ios = __('Publiée');\r
- } else {\r
- $pub_ios = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/ios" href="#"><div></div><span>' . __('Publier') . '</span></a>';\r
- }\r
-\r
- if ($r->online_android) {\r
- $pub_android = __('Publiée');\r
- } else {\r
- $pub_android = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/android" href="#"><div></div><span>' . __('Publier') . '</span></a>';\r
- }\r
- $res.='<tr><td>' . date('Y-m-d H:i:s', $r->compile_date) . '</td><td>' . $pub_ios . '</td><td>' . $pub_android . '</td><td class="min nowrap">' . $del . '</td></tr>';\r
- }\r
- $res.='</table>';\r
- }\r
-\r
- $res.='<h3>' . __('Notifications') . '</h3>';\r
- $res.='<p>' . __('Indiquez le texte de la notification à envoyer aux utilisateurs') . ' (' . __('Max 200 caractères') . ').<br />' . __('Laissez vide si vous souhaitez simplement afficher un badge') . '</p>';\r
- $res.='<form method="post" action="publishCollection">';\r
- $res.=form::hidden('collection', $collection->collection_id);\r
- $res.='<table class="max">';\r
- foreach ($langs as $lang) {\r
- $res.='<tr><td class="min nowrap">' . __('Notification') . '[' . $lang . ']</td><td class="pad">' . form::textArea(array('notification[' . $lang . ']'), 60, 3) . '</td></tr>';\r
- }\r
- $res.='<tr><td colspan="2" class="right"></td><a href="#" class="submit">' . $core->typo->Ajouter(__('Publier et notifier les utilisateurs')) . '</a></tr>';\r
- $res.='</table>';\r
- $res.='</form>';\r
- $res.='<h3>' . __('Export') . '</h3>';\r
- $res.='<a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/android">' . $core->typo->Ajouter(__('Exporter pour Android')) . '</a> <a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/ios">' . $core->typo->Ajouter(__('Exporter pour iOS')) . '</a>';\r
-\r
- return $res;\r
- }\r
-\r
- public static function listeCollections($dashboard = null, $settings = null) {\r
- global $core;\r
-\r
- cubePage::truePopup();\r
-\r
- $droits = wsDroits::getDroits();\r
-\r
- commonDroits::min(3);\r
- $settings = is_null($settings) ? $core->user->getSettings('collections') : $settings;\r
- $change = is_null($dashboard) ? 'Collections' : 'Dashboard/' . $dashboard;\r
- $dao = new wsDAOCollection($core->con);\r
- if (isset($settings['search']) && !is_null($settings['search'])) {\r
- $dao->setSearch($settings['search']);\r
- }\r
- $dao->setFiltres($settings['filtres']);\r
- $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user);\r
-\r
- $btVoir = '<div></div><span>' . __('voir') . '</span>';\r
- $btEdit = '<div></div><span>' . __('éditer') . '</span>';\r
- $btStats = '<div></div><span>' . __('stats') . '</span>';\r
- $btDownload = '<div></div><span>' . __('télécharger') . '</span>';\r
- if ($droits->creation) {\r
- $btDel = '<div></div><span>' . __('suppr.') . '</span>';\r
- }\r
-\r
-\r
- $res = '<table class="liste">';\r
- $res .= '<tr><th>' . commonUrl::orderby('#', 'collection_id', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Nom de la collection'), 'nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Propriétaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= str_repeat('<th class="min"></th>', 4);\r
- $res.='</tr>';\r
-\r
- $i = 0;\r
- foreach ($liste as $collection) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res.='<tr>';\r
- $res.='<td>' . $collection->collection_id . '</td>';\r
- $res.='<td>' . $collection->nom . '</td>';\r
- if ($droits->revendeur) {\r
- $p = str_replace(" (", '<br /><em>', html::escapeHTML($collection->proprietaire_nom));\r
- $p = str_replace(')', '</em>', $p);\r
- $res .= '<td><a href="#" class="popup" rel="formChangeCollectionProprietaire/' . $collection->collection_id . '" title="' . __('Modifier le proprietaire') . '">' . $p . '</a></td>';\r
- } else {\r
- $res .= '<td>' . html::escapeHTML($collection->proprietaire_utilisateur) . '</td>';\r
- }\r
-\r
- $res .= '<td class="bouton"><!--<a href="#" class="normallink voir btbook">' . $btVoir . '</a>--></td>';\r
- $res .= '<td class="bouton"><a href="/collection/' . $collection->collection_id . '" class="normallink edit btbook">' . $btEdit . '</a></td>';\r
- $res .= '<td class="bouton"><!--<a href="#" class="normallink download btbook">' . $btDownload . '</a>--></td>';\r
- $res .= '<td class="bouton"><!--<a href="#" class="normallink suppr btbook">' . $btDel . '</a>--></td>';\r
-\r
- $res.='</tr>';\r
-\r
- $i++;\r
- }\r
-\r
- if (!isset($settings['search']) || is_null($settings['search'])) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '><td colspan="7">';\r
- $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d');\r
- $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('collections'), false);\r
- $res .= '</td></tr>';\r
- }\r
- $res .= '</table>';\r
-\r
- return $res;\r
- }\r
-\r
- public static function getFluidbookVersions($select = false) {\r
- $droits = wsDroits::getDroits();\r
-\r
- $chooseVersion = wsDroits::admin();\r
-\r
- if ($chooseVersion) {\r
- $default = ' - ' . __('Version par défaut');\r
- } else {\r
- $default = '';\r
- }\r
-\r
- $versions = array();\r
- $versions['online'] = array('title' => __('Version online') . $default, 'icon' => cubeMedia::silk('page_world.png'));\r
- if ($chooseVersion) {\r
- $versions['v1'] = array('title' => __('Version online') . ' - V1', 'icon' => cubeMedia::silk('page_white_world.png'));\r
- $versions['v2'] = array('title' => __('Version online') . ' - V2', 'icon' => cubeMedia::silk('page_white_world.png'));\r
- }\r
- $versions['win-exe'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png'));\r
- $versions['win-ins'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png'));\r
- $versions['mac-exe'] = array('title' => __('Version offline') . ' - ' . __('Exécutable Mac OS X'), 'icon' => cubeMedia::image(IMG . '/macos.png'));\r
- $versions['win-cd'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('Clé USB'), 'icon' => cubeMedia::silk('cd.png'));\r
- if ($droits->admin) {\r
- $versions['phonegap'] = array('title' => __('Version offline') . ' - ' . __('Application mobile'), 'icon' => cubeMedia::image(IMG . '/phonegap.png'));\r
- }\r
-\r
- if (!$select) {\r
- return $versions;\r
- }\r
-\r
- $res = array();\r
- foreach ($versions as $id => $d) {\r
- $t = explode('-', $d['title'], 2);\r
- $meta = trim($t[0]);\r
- if (isset($t[1])) {\r
- $title = trim($t[1]);\r
- } else {\r
- $title = $meta;\r
- }\r
-\r
- if (!isset($res[$meta])) {\r
- $res[$meta] = array();\r
- }\r
- $res[$meta][$title] = $id;\r
- }\r
- return $res;\r
- }\r
-\r
- public static function contextBookDownload($id, $droits) {\r
- global $core;\r
-\r
- $versions = self::getFluidbookVersions();\r
-\r
- $res = '<div class="contextMenu downbookContextMenu" id="' . $id . '">';\r
- $res .= '<ul>';\r
- $res .= '<li class="head">' . __("Sélectionnez une version") . '</li>';\r
- foreach ($versions as $k => $v) {\r
- $res .= '<li><a href="#" rel="downbook/$1/' . $k . '" class="ajax">' . $v['icon'] . $v['title'] . '</a></li>';\r
- }\r
- if ($droits->admin) {\r
- $res .= '<li class="head">' . __("Installer sur ...") . '</li>';\r
- $versions = array();\r
- $versions['hosting'] = array('title' => __("Le serveur d'hébergement"), 'icon' => cubeMedia::silk('server_go.png'));\r
- $versions['references'] = array('title' => __("L'espace références"), 'icon' => cubeMedia::silk('server_add.png'));\r
- $versions['external'] = array('title' => __("Serveur FTP"), 'icon' => cubeMedia::silk('server_add.png'));\r
- $versions['macbook_phonegap_ios'] = array('title' => __("Projet Phonegap IOS"), 'icon' => cubeMedia::image(IMG . '/ios.png'));\r
- $versions['phonegap_android'] = array('title' => __("Projet Phonegap Android"), 'icon' => cubeMedia::image(IMG . '/android.png'));\r
-\r
- foreach ($versions as $k => $v) {\r
- $res .= '<li><a href="#" rel="instbook/$1/' . $k . '" class="ajax">' . $v['icon'] . $v['title'] . '</a></li>';\r
- }\r
- }\r
- $res .= '</ul></div>';\r
- return $res;\r
- }\r
-\r
- public static function contextBookStatus($id) {\r
- global $core;\r
-\r
- if (wsDroits::admin()) {\r
- $status = $core->books_status;\r
- $status[2] = __('Facturé (associé à un projet)');\r
- } else {\r
- $status = array();\r
- $status[-1] = $core->books_status[-1];\r
- $status[0] = $core->books_status[0];\r
- }\r
-\r
- $res = '<div class="contextMenu statusbookContextMenu" id="' . $id . '">';\r
- $res .= '<ul>';\r
- $res .= '<li class="head">' . __("Changer le status de la publication") . '</li>';\r
- foreach ($status as $s => $title) {\r
- $res .= '<li><a href="#" rel="statusBook/$1/' . $s . '" class="ajax">' . $title . '</a></li>';\r
- }\r
- $res .= '</ul></div>';\r
- return $res;\r
- }\r
-\r
- public static function contextBookView($id) {\r
- global $core;\r
-\r
- if (wsDroits::admin()) {\r
- $viewers = array(array('version' => 'viewer', 'title' => __('Version Flash'), 'icon' => cubeMedia::image(IMG . '/flash.png')),\r
- array('version' => 'viewerh', 'title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')),\r
- array('version' => 'vieweru', 'title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')),\r
- array('version' => 'viewerhu', 'title' => __('Version HTML5') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/html5bug.png')),\r
- //array('version' => 'viewerhu', 'title' => __('Widget HTML5'), 'icon' => cubeMedia::image(IMG . '/html5bug.png'), 'file' => 'widget.html', 'pattern' => '$1_$2_$3'),\r
- array('version' => 'viewer1', 'title' => __('Version 1'), 'icon' => cubeMedia::image(IMG . '/flash.png'))\r
- );\r
- }\r
-\r
- $res = '<div class="contextMenu viewbookContextMenu" id="' . $id . '">';\r
- $res .= '<ul>';\r
- $res .= '<li class="head">' . __("Sélectionnez la version") . '</li>';\r
- if (isset($viewers)) {\r
- foreach ($viewers as $infos) {\r
- if (!isset($infos['file'])) {\r
- $infos['file'] = '';\r
- }\r
- if (!isset($infos['pattern'])) {\r
- $infos['pattern'] = '$1_$2';\r
- }\r
- $res .= '<li><a class="popupFSBar" rel="toolbar=1,scrollbars=1" rev="' . $infos['version'] . '_$1" href="' . SITE_PATH . $infos['version'] . '/' . $infos['pattern'] . '/' . $infos['file'] . '">' . $infos['icon'] . $infos['title'] . '</a></li>';\r
- }\r
- }\r
- $res .= '</ul></div>';\r
- return $res;\r
- }\r
-\r
- public static function traductions($args) {\r
- global $core;\r
-\r
- commonDroits::min(5);\r
-\r
- if (count($args) < 2) {\r
- $args[1] = 'fr';\r
- }\r
-\r
- $allLangs = cubeLang::getCodes($core->user->lang);\r
- $existingLangs = array();\r
-\r
- $dao = new wsDAOLang($core->con);\r
- $langs = $dao->selectAll();\r
- foreach ($langs as $lang) {\r
- if (!isset($allLangs[$lang->lang_id])) {\r
- continue;\r
- }\r
- $existingLangs[$lang->lang_id] = $allLangs[$lang->lang_id];\r
-\r
- unset($allLangs[$lang->lang_id]);\r
- }\r
-\r
- $langs = array(__('Langues configurées') => array_flip($existingLangs), __('Autres langues') => array_flip($allLangs));\r
-\r
- $res = commonPage::barre();\r
- $res .= commonPage::tMain(null, false);\r
-\r
- $res .= commonPage::bh();\r
- $res .= '<form action="changeLang" method="post" class="submitonchange">';\r
- $res .= '<table class="liste">';\r
- $res .= '<tr><td class="center">' . __('Sélectionnez la langue à configurer') . ' : ' . form::combo('lang', $langs, $args[1]) . ' </td></tr>';\r
- $res .= '</table>';\r
- $res .= '</form>';\r
- $res .= commonPage::bf();\r
-\r
- $res .= '<div id="formLang">';\r
- $res .= self::formLang($args[1]);\r
- $res .= '</div>';\r
- $res .= commonPage::bMain(true);\r
-\r
- return $res;\r
- }\r
-\r
- public static function formLang($lang_id) {\r
- commonDroits::min(5);\r
- global $core;\r
- $dao = new wsDAOLang($core->con);\r
- $lang = $dao->selectById($lang_id);\r
-\r
- $res = commonPage::bh();\r
- $res .= '<table class="liste">';\r
- $res .= '<tr><td><a href="' . SITE_PATH . 'exportLangAsExcel/' . $lang_id . '">' . __('Exporter au format Excel') . '</a>';\r
- $res.=' | <a href="' . SITE_PATH . 'exportAllLangsAsExcel/' . $lang_id . '">' . __('Exporter toutes les langues au format Excel') . '</a>';\r
- $res.='</td></tr>';\r
- $res .= '</table>';\r
- $res .= commonPage::bf();\r
-\r
- $res .= '<form action="saveLang" method="post">';\r
-\r
- $res .= commonPage::bh();\r
- $res .= '<table class="liste">';\r
- $res .= '<tr><td>' . __('Police de caractères') . ' : </td><td>' . form::hidden('lang', $lang_id) . form::combo('font', self::getFonts(), $lang->font) . '</td></tr>';\r
- $res .= '<tr class="odd"><td>' . __('Jeux de caractères') . ' : </td><td>' . form::combo('charset', self::getCharsets(), $lang->charset) . '</td></tr>';\r
- $res .= '<tr><td>' . __("Langue de l'installeur") . ' : </td><td>' . form::combo('nsis', self::getNSISLangs(), $lang->nsis) . '</td></tr>';\r
- $res .= '<tr><td colspan="2" class="right odd"><a href="#" class="submit">' . $core->typo->Ajouter('Valider') . '</a></td></tr>';\r
- $res .= '</table>';\r
- $res .= commonPage::bf();\r
-\r
- $res .= commonPage::bh();\r
- $res .= cubeLang::translationForm(array(__('Version Flash') => PLAYER_SOURCES, __('Version HTML5') => WS_COMPILE_ASSETS . '/_html5', __('Compilateur HTML5') => ROOT . '/inc/ws/Util/html5', __('Application') => WS_COMPILE_ASSETS . '/_html5app'), $lang_id, null, 'liste', array(), '<a href="#" class="submit">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>', $lang->traductions);\r
- $res .= commonPage::bf();\r
- $res .= '</form>';\r
- return $res;\r
- }\r
-\r
- public static function exportLangAsExcel($args) {\r
- global $core;\r
-\r
- $lang_id = $args[1];\r
-\r
- $xls = new PHPExcel();\r
- $s = $xls->setActiveSheetIndex(0);\r
-\r
- $lang_name = self::exportLangAsSheet($s, $lang_id, 'en');\r
-\r
- $xls->setActiveSheetIndex(0);\r
-\r
- ob_end_clean();\r
- files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'));\r
- cubeHTTP::forceDownload('Fluidbook_' . $lang_name . '.xlsx', false);\r
-\r
- $writer = new PHPExcel_Writer_Excel2007($xls);\r
- $writer->save('php://output');\r
-\r
- exit;\r
- }\r
-\r
- public static function exportAllLangsAsExcel($args) {\r
- global $core;\r
-\r
- $xls = new PHPExcel();\r
-\r
- $dao = new wsDAOLang($core->con);\r
- $all = $dao->selectAll();\r
-\r
- $i = 0;\r
- foreach ($all as $l) {\r
- try {\r
- $s = $xls->getSheet($i);\r
- } catch (Exception $e) {\r
- $s = $xls->createSheet($i);\r
- }\r
- self::exportLangAsSheet($s, $l->lang_id, 'en');\r
- $i++;\r
- }\r
-\r
- $xls->setActiveSheetIndex(0);\r
-\r
- ob_end_clean();\r
- files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'));\r
- cubeHTTP::forceDownload('Fluidbook_All_Languages.xlsx', false);\r
-\r
- $writer = new PHPExcel_Writer_Excel2007($xls);\r
- $writer->save('php://output');\r
- }\r
-\r
- public static function exportLangAsSheet($s, $lang_id, $ref_id = 'en') {\r
- global $core;\r
- $dao = new wsDAOLang($core->con);\r
-\r
-\r
- $lang = $dao->selectById($lang_id);\r
- $ref = $dao->selectById($ref_id);\r
-\r
- $lang_name = cubeLang::getNameByCode($lang_id, 'en');\r
- $ref_name = cubeLang::getNameByCode($ref_id, 'en');\r
-\r
- $s->setTitle(cubeText::str2URL($lang_name));\r
-\r
- $tab = cubeLang::getTranslationsList(array(PLAYER_SOURCES, WS_COMPILE_ASSETS . '/_html5/js', ROOT . '/inc/ws/Util/html5'), array('php', 'as', 'js'), array(), $lang->traductions);\r
-\r
- $s->setCellValueByColumnAndRow(0, 1, 'ID', true);\r
- $s->setCellValueByColumnAndRow(1, 1, $ref_name, true);\r
- $s->setCellValueByColumnAndRow(2, 1, $lang_name, true);\r
-\r
- $j = 2;\r
- foreach ($tab as $msgid => $msgstr) {\r
- $s->setCellValueByColumnAndRow(0, $j, $msgid);\r
- $s->setCellValueByColumnAndRow(1, $j, $ref->traductions[$msgid]);\r
- $s->setCellValueByColumnAndRow(2, $j, $msgstr);\r
-\r
- if ($msgstr == '') {\r
- $s->getStyleByColumnAndRow(2, $j)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);\r
- $s->getStyleByColumnAndRow(2, $j)->getFill()->getStartColor()->setARGB('FFFFFF00');\r
- }\r
- $j++;\r
- }\r
-\r
- $s->getColumnDimensionByColumn(0)->setAutoSize(true);\r
- $s->getColumnDimensionByColumn(1)->setAutoSize(true);\r
- $s->getColumnDimensionByColumn(2)->setAutoSize(true);\r
-\r
- return $lang_name;\r
- }\r
-\r
- public static function getFonts() {\r
- $formats = array('ttf', 'otf', 'TTF', 'OTF');\r
-\r
- $dr = opendir(FONT_PATH);\r
- $fonts = array('Arial (police système)' => "system");\r
- while ($file = readdir($dr)) {\r
- if ($file == '.' || $file == '..' || !in_array(files::getExtension($file), $formats)) {\r
- continue;\r
- }\r
- $fonts[$file] = $file;\r
- }\r
- return $fonts;\r
- }\r
-\r
- protected static function getCharsets() {\r
- $sets = cubeFlexFontAsset::getSets();\r
- $res = array();\r
- foreach ($sets as $k => $v) {\r
- $res[$k] = $k;\r
- }\r
- return $res;\r
- }\r
-\r
- protected static function getNSISLangs() {\r
- $res = array();\r
- $dir = WS_FILES . '/nsislangs';\r
- $dr = opendir($dir);\r
- while ($file = readdir($dr)) {\r
- if ($file == '.' || $file == '..') {\r
- continue;\r
- }\r
- $e = explode('.', $file);\r
- $res[$e[0]] = $e[0];\r
- }\r
-\r
- ksort($res);\r
- return $res;\r
- }\r
-\r
- public static function editor($args) {\r
- commonDroits::min(1);\r
-\r
- global $core;\r
-\r
- $args = cubePage::getArgs($args);\r
- $e = explode('_', $args[0]);\r
- $book_id = $e[0];\r
- $hash = isset($e[1]) ? $e[1] : '';\r
-\r
-\r
- self::checkDocumentVersionOfBook($book_id);\r
-\r
- if ($book_id == 'new') {\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang);\r
- http::redirect(SITE_PATH . 'editor/' . $book->book_id . '_' . $book->hash);\r
- }\r
-\r
- $res = '<html><head><style type="text/css">';\r
- $res .= '#composerSwf{width:100%;height:100%;margin:0 auto;}\r
-body{margin:0;padding:0;height:100%;overflow:hidden;background:#d2d3c7;}\r
-html{height:100%}' . "\n";\r
- $res .= '</style>';\r
- $res .= '<title>' . __('Edition de la publication') . ' #' . $args[0] . '</title>';\r
- $res .= '</head>';\r
- $res .= '<body onload="this.focus();">';\r
- $res .= self::editComposition($book_id, $hash);\r
- $res .= '</body>';\r
- $res .= '</html>';\r
- echo $res;\r
- }\r
-\r
- /**\r
- * wsUrl::restoreLinks()\r
- *\r
- * @param mixed $args\r
- * @return\r
- */\r
- public static function restoreLinks($args) {\r
- commonDroits::min(1);\r
-\r
- global $core;\r
-\r
- $args = cubePage::getArgs($args);\r
- $book_id = $args[0];\r
-\r
- $dao = new wsDAODocument($core->con);\r
- $updates = $dao->getLinksVersions($book_id);\r
- krsort($updates);\r
-\r
- $res = '<html><head>';\r
- $res .= '<title>' . __('Restauration des liens de la publication') . ' #' . $args[0] . '</title>';\r
- $res .= '</head>';\r
- $res .= '<body onload="this.focus();">';\r
- $res .= '<div id="restoreLinks">';\r
- $res.='<div>';\r
- $res.='<h2>' . __('Import') . '</h2>';\r
- $res.='<div class="center">';\r
- $res.='<form action="importLinksAsExcel/' . $book_id . '" method="post" enctype="multipart/form-data" class="notajax" id="importLinksAsExcel">';\r
- $res.=__("Importer des liens à partir d'un fichier Excel") . ' : <input type="file" name="file" accept="*.xlsx" />';\r
- $res.='<input type="submit" value="' . __('Importer') . '" />';\r
- $res.='</form>';\r
- $res.='</div>';\r
- $res.='</div>';\r
- $res.='<hr />';\r
-\r
- $res.='<div id="linksOffset">';\r
- $res.='<h2>' . __('Décalage de pages') . '</h2>';\r
- $res.='<form action="offsetLinks/' . $book_id . '" method="post" id="offsetLinks">';\r
- $offset = form::field('offset', 3, 5);\r
- $from = form::field('from', 3, 5);\r
- $res.=sprintf(__('Décaler les liens de %s pages à partir de la page %s'), $offset, $from) . '<br />';\r
- $res.='<label>' . form::checkbox('internal', 1, true) . ' ' . __('Appliquer le décalages sur les numéros de pages dans les liens internes') . '</label><br />';\r
- $res.='<input type="submit" value="' . __('Procéder au décalage') . '" />';\r
- $res.='</form>';\r
- $res.='</div>';\r
- $res.='<hr />';\r
-\r
- $res.='<h2>' . __('Réimporter les liens du fichier PDF') . '</h2>';\r
- $res.='<a class="restoreLink" rel="' . $book_id . '/pdf" href="#">Restaurer</a>';\r
- $res.='<hr />';\r
-\r
- $res.='<h2>' . __('Historique') . '</h2>';\r
- $res .= '<table class="liste" style="width:100%;min-width:0;">';\r
- $res .= '<tr>';\r
- $res .= '<th>' . __('Date') . '</th>';\r
- $res .= '<th class="center">' . __('Liens') . '</th>';\r
- $res .= '<th class="center">' . __('Règles') . '</th>';\r
- $res.='<th class="center">' . __('Utilisateur') . '</th>';\r
- $res.='<th class="center">' . __('Informations') . '</th>';\r
- $res .= '<th class="min"></th>';\r
- $res .= '<th class="min"></th>';\r
- $res .= '</tr>';\r
- $i = 0;\r
- foreach ($updates as $time => $infos) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '>';\r
- $res .= '<td>' . date('Y-m-d H:i:s', $time) . '</td>';\r
- $res .= '<td class="center">' . $infos['links'] . '</td>';\r
- $res .= '<td class="center">' . $infos['rulers'] . '</td>';\r
- $res.='<td class="center">' . $infos['user'] . '</td>';\r
- $res.='<td class="center">' . $infos['comments'] . '</td>';\r
- $res .= '<td><a href="#" rel="' . $book_id . '/' . $time . '" class="restoreLink">' . __('Restaurer') . '</a></td>';\r
- $res .= '<td><a href="' . SITE_PATH . 'exportLinksAsExcel/' . $book_id . '/' . $time . '">' . str_replace(' ', ' ', __('Export Excel')) . '</a></td>';\r
- $res .= '</tr>';\r
- $i++;\r
- }\r
-\r
- $res .= '</table>';\r
- $res .= '</div>';\r
- $res .= '</body>';\r
- $res .= '</html>';\r
-\r
- echo $res;\r
- }\r
-\r
- public static function exportLinksAsExcel($args) {\r
- global $core;\r
-\r
- cubePHP::neverStop();\r
-\r
- $book_id = $args[1];\r
- $time = $args[2];\r
-\r
- $dao = new wsDAODocument($core->con);\r
- $dao->getLinksAndRulers($book_id, $links, $rulers, $time);\r
- $xls = $dao->getLinksAsExcel($links, $rulers);\r
-\r
- ob_end_clean();\r
- files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'));\r
- cubeHTTP::forceDownload('links_' . $book_id . '_' . $time . '.xlsx', false);\r
-\r
- $writer = new PHPExcel_Writer_Excel2007($xls);\r
- $writer->save('php://output');\r
-\r
- exit;\r
- }\r
-\r
- public static function editComposition($book_id, $hash) {\r
-\r
- $fv = array(session_name() => session_id(),\r
- 'book_id' => $book_id,\r
- 'hash' => $hash,\r
- 'url' => '/');\r
-\r
- $mtime = filemtime(ROOT . '/swf/composer.swf');\r
- return cubeMedia::flash2(WEBROOT . '/swf/composer.swf?junk=' . $mtime, '100%', '100%', $fv, 'composerSwf', 'swfPanel', 10, '#d2d3c7', '', 'false', 'noscale', 'normal', array(), false, true, false);\r
- }\r
-\r
- public static function stats($args) {\r
- global $core;\r
- $bid = (isset($args[1])) ? $args[1] : null;\r
-\r
- list($bid, $hash) = explode('_', $bid);\r
-\r
- $r = $core->con->select('SELECT * FROM books WHERE book_id=\'' . $core->con->escape($bid) . '\' AND hash=\'' . $core->con->escape($hash) . '\'');\r
- if (!$r->count()) {\r
- return;\r
- }\r
-\r
- $annee = (isset($args[2])) ? $args[2] : null;\r
- $mois = (isset($args[3])) ? $args[3] : null;\r
- return wsStats::display($bid . '_' . $hash, $annee, $mois);\r
- }\r
-\r
- public static function viewerp($args) {\r
- commonDroits::min(5);\r
-\r
- $args = cubePage::getArgs($args);\r
-\r
-\r
- $e = explode('_', $args[0]);\r
- if (count($e) == 2 || $e[2] < TIME - 10) {\r
- $e[2] = TIME;\r
- http::redirect(SITE_PATH . 'viewerp/' . implode('_', $e) . '/');\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
-\r
- self::checkDocumentVersionOfBook($book_id);\r
-\r
- echo self::commonViewer($book_id, $e[1], true);\r
- }\r
-\r
- public static function vieweru($args) {\r
- commonDroits::min(5);\r
-\r
- $args = cubePage::getArgs($args);\r
-\r
- $qs = '';\r
- if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {\r
- $qs = '?' . $_SERVER['QUERY_STRING'];\r
- }\r
-\r
- $e = explode('_', $args[0]);\r
- if (count($e) == 2 || $e[2] < TIME - 10) {\r
- $e[2] = TIME;\r
- http::redirect(SITE_PATH . 'vieweru/' . implode('_', $e) . '/' . $qs);\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
-\r
- self::checkDocumentVersionOfBook($book_id);\r
-\r
- echo self::commonViewer($book_id, $e[1], false, 'default', true);\r
- }\r
-\r
- public static function viewerh($args) {\r
- global $core;\r
-\r
- $args = cubePage::getArgs($args);\r
-\r
- $e = explode('_', $args[0]);\r
-\r
- $book_id = $e[0];\r
- $hash = $e[1];\r
-\r
- $dao = new wsDAOBook($core->con);\r
-\r
- $book = $dao->selectById($book_id);\r
- if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
- commonDroits::error();\r
- }\r
-\r
- if (!wsDroits::admin()) {\r
- if ($book->parametres->redirectDemo != '') {\r
- http::redirect($book->parametres->redirectDemo);\r
- exit;\r
- }\r
- if ($book->parametres->disableDemo) {\r
- commonDroits::error();\r
- }\r
- }\r
-\r
- $dao->compile($book_id, 'html5');\r
- $time = self::getHTML5CacheTime($book_id);\r
-\r
- if (count($e) == 2 || $e[2] != $time) {\r
- $e[2] = $time;\r
- http::redirect(SITE_PATH . 'viewerh/' . implode('_', $e) . '/index.html');\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
- $hash = $e[1];\r
- self::commonHTML5Viewer($book_id, $hash);\r
- }\r
-\r
- public static function getHTML5CacheTime($book_id) {\r
- $cacheFile = WS_BOOKS . '/html5/' . $book_id . '/cache.appcache';\r
- if (file_exists($cacheFile)) {\r
- return filemtime($cacheFile);\r
- }\r
- return TIME;\r
- }\r
-\r
- public static function viewerhu($args) {\r
- global $core;\r
-\r
- commonDroits::min(5);\r
- $args = cubePage::getArgs($args);\r
- if (!isset($args[1])) {\r
- $args[1] = '';\r
- }\r
-\r
- $dao = new wsDAOBook($core->con);\r
- $e = explode('_', $args[0]);\r
- $dao->compile($e[0], 'html5');\r
- $time = self::getHTML5CacheTime($e[0]);\r
-\r
- if (count($e) == 2 || $e[2] != $time) {\r
- $e[2] = $time;\r
- http::redirect(SITE_PATH . 'viewerhu/' . implode('_', $e) . '/' . $args[1]);\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
- $hash = $e[1];\r
- self::commonHTML5Viewer($book_id, $hash, 'u');\r
- }\r
-\r
- public static function viewerha($args) {\r
- global $core;\r
-\r
-\r
- $args = cubePage::getArgs($args);\r
- if (!isset($args[1])) {\r
- $args[1] = '';\r
- }\r
-\r
- $dao = new wsDAOBook($core->con);\r
- $e = explode('_', $args[0]);\r
- $dao->compileTemp($e[0], 'ha', WS_BOOKS . '/html5a/' . $e[0]);\r
- $time = time();\r
-\r
- if (count($e) == 2 || $e[2] < $time - 20) {\r
- $e[2] = $time;\r
- http::redirect(SITE_PATH . 'viewerha/' . implode('_', $e) . '/' . $args[1]);\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
- $hash = $e[1];\r
- self::commonHTML5Viewer($book_id, $hash, 'a');\r
- }\r
-\r
- public static function viewerht($args) {\r
- commonDroits::min(5);\r
- $args = cubePage::getArgs($args);\r
-\r
- $e = explode('_', $args[0]);\r
- $dao->compile($e[0], 'html5');\r
- $time = self::getHTML5CacheTime($e[0]);\r
-\r
- if (count($e) == 2 || $e[2] != $time) {\r
- $e[2] = $time;\r
- http::redirect(SITE_PATH . 'viewerht/' . implode('_', $e) . '/');\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
- $hash = $e[1];\r
- self::commonHTML5Viewer($book_id, $hash, 't');\r
- }\r
-\r
- public static function commonHTML5Viewer($book_id, $hash, $version = '') {\r
- global $core;\r
- self::checkDocumentVersionOfBook($book_id);\r
-\r
- $dao = new wsDAOBook($core->con);\r
-\r
- $dir = '';\r
- if ($version == 'a') {\r
- $version = '';\r
- $dir = 'a';\r
- }\r
-\r
- $book = $dao->selectById($book_id);\r
- if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
- commonDroits::error();\r
- }\r
-\r
- if (!wsDroits::admin()) {\r
- if ($book->parametres->redirectDemo != '') {\r
- http::redirect($book->parametres->redirectDemo);\r
- exit;\r
- }\r
- if ($book->parametres->disableDemo) {\r
- commonDroits::error();\r
- }\r
- }\r
-\r
-\r
- echo file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html');\r
- exit;\r
- }\r
-\r
- public static function viewer1($args) {\r
- $args = cubePage::getArgs($args);\r
-\r
- $wmode = isset($args[1]) ? $args[1] : '';\r
-\r
- $e = explode('_', $args[0]);\r
-\r
- $newurl = null;\r
- if (count($e) == 2 || $e[2] < TIME - 10) {\r
- $e[2] = TIME;\r
- http::redirect(SITE_PATH . 'viewer1/' . implode('_', $e) . '/' . $wmode);\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
-\r
- $wmode = $wmode != '' ? $wmode : 'default';\r
-\r
- echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl, '1');\r
- }\r
-\r
- public static function viewer($args) {\r
- $args = cubePage::getArgs($args);\r
-\r
-\r
- $qs = '';\r
- if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {\r
- $qs = '?' . $_SERVER['QUERY_STRING'];\r
- }\r
-\r
- $e = explode('_', $args[0]);\r
- $newurl = null;\r
- if (count($e) == 2 || $e[2] < TIME - 10) {\r
- $e[2] = TIME;\r
- http::redirect(SITE_PATH . 'viewer/' . implode('_', $e) . '/' . $qs);\r
- exit;\r
- }\r
-\r
- $book_id = $e[0];\r
-\r
- $wmode = (isset($wmode) && $wmode != '') ? $wmode : 'default';\r
-\r
- self::checkDocumentVersionOfBook($book_id);\r
- wsSecureSWF::checkProtectedSWF();\r
-\r
- echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl);\r
- }\r
-\r
- public static function commonViewer($book_id, $hash, $standalone = false, $wmode = 'default', $fps = false, $version = 2) {\r
- if (!defined('MINIMIZE_JS')) {\r
- define('MINIMIZE_JS', false);\r
- }\r
- if (!defined('MINIMIZE_CSS')) {\r
- define('MINIMIZE_CSS', false);\r
- }\r
- if (!defined('JQUERY')) {\r
- define('JQUERY', false);\r
- }\r
-\r
- global $core;\r
- global $css;\r
- global $js;\r
- global $standard;\r
- global $meta;\r
- global $jsvar;\r
-\r
- if ($version == 2) {\r
- $flashVersion = '10.0.22';\r
- } else {\r
- $flashVersion = '8';\r
- }\r
-\r
- cubePage::swfobject(2);\r
-\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($book_id);\r
-\r
- if (!wsDroits::admin()) {\r
- if ($book->parametres->redirectDemo != '') {\r
- http::redirect($book->parametres->redirectDemo);\r
- exit;\r
- }\r
- if ($book->parametres->disableDemo) {\r
- commonDroits::error();\r
- }\r
- }\r
-\r
- if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
- commonDroits::error();\r
- }\r
-\r
-\r
- if (is_null($core->user)) {\r
- $dao->addDemoCount($book_id);\r
- }\r
-\r
- $dao->compile($book_id, (string) $version);\r
-\r
- $daoTheme = new wsDAOTheme($core->con);\r
- $theme = $daoTheme->selectById($book->theme, 'themes');\r
-\r
- $webcompile = WEBROOT . '/fluidbook/compile/';\r
-\r
- $standard = 'XHTML 1.0 Transitional';\r
- $css = $js = array();\r
- $css[] = $webcompile . 'style.css';\r
- $fv = $_GET;\r
- if ($standalone) {\r
- $fv['base'] = $_SERVER['REQUEST_URI'];\r
- }\r
- if ($fps) {\r
- $fv['monitoring'] = '1';\r
- }\r
-\r
- if ($version == 1) {\r
- $fv['id'] = $book_id;\r
- $fv['mail'] = '0';\r
- $fv['onlineFlag'] = '1';\r
- $fv['loaderColor'] = $theme->parametres->loadingBackColor;\r
- }\r
-\r
- $res = '<html>';\r
- $res .= '<head>';\r
- $res .= '<title>' . $book->parametres->title . '</title>';\r
- $res.='<meta name="google" value="notranslate">';\r
- $res.='<style type="text/css" media="print">*{ visibility: hidden; display: none }</style>';\r
- // Entêtes Facebook\r
- if ($book->parametres->facebook) {\r
- $meta['og:title'] = ($book->parametres->facebook_title == '') ? $book->parametres->title : $book->parametres->facebook_title;\r
- if ($book->parametres->facebook_description != '') {\r
- $meta['og:description'] = $book->parametres->facebook_description;\r
- }\r
- $meta['og:image'] = 'http://workshop.fluidbook.com/services/facebook_thumbnail?id=' . $book->book_id . '&j=' . TIME;\r
- }\r
-\r
- $redirectPDF = 'window.location="data/document.pdf"';\r
-\r
- if ($book->parametres->mobileVersion == 'pdf') {\r
- $redirectMobile = $redirectPDF;\r
- } else {\r
- $redirectMobile = 'window.location="/viewerh/' . $book_id . '_' . $hash . '_' . TIME . '/";';\r
- }\r
-\r
- $alt = '<div style="width:734px;margin:100px auto;"><a href="http://get.adobe.com/flashplayer/" target="_blank">' . cubeMedia::image($webcompile . 'getflash.gif', 734, 409, '') . '</a></div>';\r
-\r
- $res .= '</head>';\r
- $res .= '<body style="background-color:#' . $theme->parametres->loadingBackColor . '" onload="this.focus();">';\r
- $res .= '<div id="fluidbook"><div style="width:734px;margin:100px auto;"><a href="http://get.adobe.com/flashplayer/" target="_blank"></a></div></div>';\r
- $res .= "\n" . '<script type="text/javascript">' . "\n";\r
- $res.='if(isMobile()){' . "\n";\r
- $res.="\t" . $redirectMobile . "\n";\r
- $res.='} else if(isBadMobile()) {' . "\n";\r
- $res.="\t" . $redirectPDF . "\n";\r
- $res.='} else {' . "\n";\r
- $res .= "\t" . 'swfobject.embedSWF("index.swf", "fluidbook", "100%", "100%", "' . $flashVersion . '",';\r
- $res .= '"", ' . json_encode($fv) . ',';\r
- $res .= '{"allowScriptAccess":"always","quality":"high","scale":"noscale","wmode":getWmode(),"allowFullScreen":"true","allowFullScreenInteractive":"true"},{"bgcolor":"#' . $theme->parametres->loadingBackColor . '"}';\r
- $res .= ');' . "\n";\r
- $res.='}' . "\n";\r
- $res .= '</script>';\r
- $js = array('fluidbook.js');\r
- $jsvar = array();\r
-\r
- $gacodes = array(GA);\r
- if ($book->parametres->googleAnalytics != '') {\r
- $gacodes[] = $book->parametres->googleAnalytics;\r
- }\r
- $res .= cubePage::googleAnalytics($gacodes, false);\r
- $res .= '</body>';\r
- $res .= '</html>';\r
-\r
- return $res;\r
- }\r
-\r
- public static function statsxls($args) {\r
- $bid = (isset($args[1])) ? $args[1] : null;\r
- $annee = (isset($args[2])) ? $args[2] : null;\r
- $mois = (isset($args[3])) ? $args[3] : null;\r
- wsStats::exportXLS($bid, $annee, $mois);\r
- }\r
-\r
- public static function chooseExistingBook() {\r
- wsDroits::creation(true);\r
- $res = '<tr><td colspan="2"><p style="width:600px;text-align:justify;"><em>a' . __("Si votre nouvelle publication a des paramètres en commun avec une publication existante, veuillez rechercher cette publication afin d'attribuer par défaut à votre nouvelle publication les paramètres de l'existante") . '</em></p></td></tr>';\r
- $res .= '<tr><td>' . __('Rechercher une publication') . ' : </td><td>' . form::field('book_nom', 64, 1024) . form::hidden('book', '') . '</td></tr>';\r
- $res .= '<tr><td>' . __('Indiquez le titre de votre nouvelle publication') . '</td><td>' . form::field('title', 64, 1024) . '</td></tr>';\r
- $res .= '<tr><td colspan="2"><label>' . form::checkbox('settings', '1', true, '', '', true, '') . __('Importer les paramètres de la publication') . '</td></tr>';\r
- $res .= '<tr><td colspan="2"><label>' . form::checkbox('pages', '1', false) . __('Importer les pages et les liens') . '</td></tr>';\r
- return $res;\r
- }\r
-\r
- public static function changeBookProprietaire($book_id) {\r
- global $core;\r
- commonDroits::min(3);\r
-\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($book_id);\r
-\r
- return self::_changeProprietaire($book->proprietaire);\r
- }\r
-\r
- public static function changeCollectionProprietaire($collection_id) {\r
- global $core;\r
- commonDroits::min(3);\r
-\r
- $dao = new wsDAOCollection($core->con);\r
- $collection = $dao->selectById($collection_id);\r
-\r
- return self::_changeProprietaire($collection->proprietaire_nom);\r
- }\r
-\r
- protected static function _changeProprietaire($proprietaire) {\r
- $res = '<tr><td>' . __('Propriétaire actuel') . ' : </td><td>' . $proprietaire . '</td></tr>';\r
- $res .= '<tr><td>' . __('Rechercher un utilisateur') . ' : </td><td>' . form::field('book_proprietaire', 64, 1024) . form::hidden('proprietaire', '') . '</td></tr>';\r
- return $res;\r
- }\r
-\r
- public static function chooseBookProject($book_id) {\r
- global $core;\r
-\r
- wsDroits::admin(true);\r
-\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($book_id);\r
-\r
- $projects = array("--" => '0');\r
-\r
- $proprietaire = 'SELECT facturable_id FROM ws_users_tree WHERE utilisateur_id=\'' . $core->con->escape($book->proprietaire_id) . '\'';\r
- $entreprise = 'SELECT entreprise FROM utilisateurs WHERE utilisateur_id IN (' . $proprietaire . ')';\r
- $collegues = 'SELECT utilisateur_id FROM utilisateurs WHERE entreprise IN(' . $entreprise . ')';\r
-\r
- $r = $core->con->select('SELECT * FROM projets WHERE client IN(' . $collegues . ') ORDER BY projet_id DESC');\r
- while ($r->fetch()) {\r
- $projects[$r->projet_id . ' - ' . $r->nom] = $r->projet_id;\r
- }\r
-\r
- $res = '<tr><td>' . __('Choisir un projet') . ' : </td><td>' . form::hidden('book_id', $book_id) . form::combo('book_project', $projects, $book->projet, 'hide_new_value') . '</td></tr>';\r
- $res .= '<tr class="new"><td>' . __('ou créer un nouveau projet') . ' : </td><td>' . form::field('new_book_project_nom', 64, 1024, $book->nom) . '</td></tr>';\r
- return $res;\r
- }\r
-\r
- public static function chooseBookTache($book_id, $projet_id) {\r
- global $core;\r
- wsDroits::admin(true);\r
-\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($book_id);\r
-\r
- $taches = array("--" => '0');\r
- $r = $core->con->select('SELECT * FROM taches WHERE projet=\'' . $core->con->escape($projet_id) . '\' AND categorie=8');\r
- while ($r->fetch()) {\r
- $taches[$r->nom] = $r->tache_id;\r
- }\r
-\r
- $res = '';\r
-\r
- if ($r->count() > 0) {\r
- $res .= '<tr><td>' . __('Choisir une tâche') . ' : </td><td>' . form::hidden('book_id', $book_id) . form::hidden('projet_id', $projet_id) . form::combo('tache', $taches, '0', 'hide_new_value') . '</td></tr>';\r
- $res .= '<tr class="new"><td>' . __('ou créer une nouvelle tâche') . ' : </td><td>' . form::field('nom', 32, 1024, 'Fluidbook #' . $book->book_id . ' : ' . $book->nom) . ' ' . __('ayant le budget suivant') . ' ' . form::field('budget', 6, 6) . '</td></tr>';\r
- } else {\r
- $res .= '<tr><td>' . __('Créer une tâche') . ' : </td><td>'\r
- . form::hidden('book_id', $book_id)\r
- . form::hidden('projet_id', $projet_id)\r
- . form::hidden('tache', '0')\r
- . form::field('nom', 32, 1024, 'Fluidbook #' . $book->book_id . ' : ' . $book->nom)\r
- . ' ' . __('ayant le budget suivant')\r
- . ' ' . form::field('budget', 6, 6) . '</td></tr>';\r
- }\r
-\r
- return $res;\r
- }\r
-\r
- public static function valideDownload() {\r
- global $core;\r
-\r
- $res = '<tr><td>' . __("Le téléchargement du fluidbook implique qu'il a été testé et définitivement validé.") . '<br />' . __("Si vous le téléchargez, il vous sera facturé selon les conditions stipulées dans votre contrat.") . '</td></tr>';\r
- $res .= '<tr><td class="right"><label>' . __("Oui, ce fluidbook est validé, je souhaite le télécharger et il me sera facturé.") . ' ' . form::checkbox('valide', 1, false) . '</label></td></tr>';\r
-\r
- return $res;\r
- }\r
-\r
- public static function formInstall($book, $server) {\r
- if ($server == 'references') {\r
- $s = __('Espace des références');\r
- $dir = $book->dir_references;\r
- } elseif ($server == 'hosting') {\r
- $s = __("Serveur d'hébergement");\r
- $dir = $book->dir_hosting;\r
- } elseif ($server == 'macbook_phonegap_ios') {\r
- $s = __("Projet Phonegap iOS");\r
- $dir = $book->dir_macbook_phonegap_ios;\r
- } elseif ($server == 'phonegap_android') {\r
- $s = __("Projet Phonegap Android");\r
- $dir = $book->dir_phonegap_android;\r
- } elseif ($server == 'external') {\r
- $s = __('Serveur FTP externe') . ' : ftp://';\r
- $dir = $book->dir_external;\r
- }\r
-\r
- if ($dir == '') {\r
- $dir = cubeText::str2URL($book->parametres->title);\r
- }\r
-\r
- $res = '<tr><td>' . __("Dossier d'installation") . '</td><td><em>' . $s . '</em> ' . form::field('dir', 60, 128, $dir) . '</td></tr>';\r
- $res.='<tr><td colspan="2">' . __("A l'issue de l'installation, vous serez dirigé vers le serveur sur lequel la publication a été installée") . '</td></tr>';\r
- return $res;\r
- }\r
-\r
- public static function testAS($args) {\r
- global $core;\r
- commonDroits::min(5);\r
- if (!isset($args[1])) {\r
- $args[1] = 2964;\r
- }\r
- self::checkDocumentVersionOfBook($args[1]);\r
- wsSecureSWF::checkProtectedSWF();\r
- cubePHP::neverStop();\r
- $dao = new wsDAOBook($core->con);\r
-\r
- header('Content-type: text/plain');\r
- ob_end_clean();\r
- echo $dao->compile($args[1], 3, false, true);\r
- exit;\r
- }\r
-\r
- public static function testAIR($args) {\r
- global $core;\r
- commonDroits::min(5);\r
- if (!isset($args[1])) {\r
- $args[1] = 2964;\r
- }\r
- self::checkDocumentVersionOfBook($args[1]);\r
- cubePHP::neverStop();\r
- $dao = new wsDAOBook($core->con);\r
-\r
- header('Content-type: text/plain');\r
- ob_end_clean();\r
- echo $dao->compileAIR($args[1]);\r
- exit;\r
- }\r
-\r
- public static function testLinksCSV($args) {\r
- global $core;\r
- commonDroits::min(5);\r
-\r
- $dao = new wsDAODocument($core->con);\r
- header('Content-type: text/plain');\r
- ob_clean();\r
- echo $dao->putLinksFromCSV($args[1]);\r
- }\r
-\r
- protected static function checkDocumentVersionOfBook($book_id) {\r
- global $core;\r
- cubePHP::neverStop();\r
- $daoBook = new wsDAOBook($core->con);\r
-\r
-\r
- $toUpdate = $daoBook->getDocumentsToUpdate($book_id);\r
- foreach ($toUpdate as $document_id) {\r
- self::updateDocument($document_id);\r
- }\r
-\r
- if (count($toUpdate) > 0) {\r
- $daoBook->setChaptersFromOldFluidbook($book_id);\r
- $daoDoc = new wsDAODocument($core->con);\r
- $daoDoc->setLinksFromOldFluidbook($book_id);\r
- }\r
-\r
- $daoBook->setVersion($book_id, 2);\r
- }\r
-\r
- public static function testOldLink($args) {\r
- global $core;\r
- $daoDoc = new wsDAODocument($core->con);\r
- $daoDoc->setLinksFromOldFluidbook($args[1]);\r
- }\r
-\r
- protected static function updateDocument($document_id) {\r
- global $core;\r
-\r
- $dao = new wsDAODocument($core->con);\r
- $doc = $dao->selectById($document_id);\r
-\r
- $doc->copyOriginalFromOlderVersion();\r
- $doc->globalOperations();\r
-\r
- for ($i = 1; $i <= $doc->generalInfos['pages']; $i++) {\r
- $doc->processOnePage($i);\r
- }\r
-\r
- $doc->version = 2;\r
- $dao->updateFromObject($doc);\r
- }\r
-\r
- public static function testFontExtraction($args) {\r
- $documentId = $args[1];\r
-\r
- header('Content-type: text/plain');\r
- ob_clean();\r
-\r
-\r
-\r
- $extractor = new wsPDFFontExtractor(WS_DOCS . '/' . $documentId);\r
- $extractor->extract();\r
-\r
- exit;\r
- }\r
-\r
- public static function getParamsHelp($args) {\r
- commonDroits::min(5);\r
- global $core;\r
-\r
- $res = '';\r
-\r
- if (isset($args[1]) && $args[1] != '') {\r
- $dao = new wsDAOBook($core->con);\r
- $b = $dao->selectById($args[1]);\r
-\r
- $daoTheme = new wsDAOTheme($core->con);\r
- $t = $daoTheme->getThemeOfBook($args[1], true);\r
-\r
- $book = $b->parametres;\r
- $theme = $t->parametres;\r
- } else {\r
- $theme = new wsThemeParametres(new wsTheme());\r
- $book = new wsBookParametres(new wsBook());\r
- }\r
-\r
- $res = commonPage::barre();\r
- $res .= commonPage::tMain();\r
- $res.=commonPage::bh();\r
- $res.='<table class="liste">';\r
- $res.= self::formatHelp($theme->getHelp());\r
- $res.='</table>';\r
- $res.=commonPage::bf();\r
- $res.=commonPage::bh();\r
- $res.='<table class="liste">';\r
- $res.= self::formatHelp($book->getHelp());\r
- $res.='</table>';\r
- $res.=commonPage::bf();\r
- $res .= commonPage::bMain();\r
-\r
- return $res;\r
- }\r
-\r
- public static function formatHelp($rubriques) {\r
- commonDroits::min(5);\r
-\r
- $res = '';\r
- foreach ($rubriques as $label => $fields) {\r
- $res.='<tr class="odd"><th colspan="5">' . $label . '</th></tr>';\r
- foreach ($fields as $name => $t) {\r
- if (is_string($t) && $t == '|') {\r
- $res .= '<tr class="odd"><th></th></tr>';\r
- } else {\r
- $res.= '<tr>';\r
- foreach ($t as $tt) {\r
- $res.='<td>' . $tt . '</td>';\r
- }\r
- $res.='</tr>';\r
- }\r
- }\r
- }\r
- return $res;\r
- }\r
-\r
- public static function clients($args) {\r
- global $core;\r
- cubePage::truePopup();\r
- cubePage::autoComplete();\r
- cubePage::emptyfield();\r
- commonDroits::min(3);\r
- $settings = $core->user->getSettings('clients_ws');\r
-\r
- $shortcuts = array();\r
- $shortcuts[] = '<a href="#" class="popup" rel="formClient/new">' . $core->typo->Ajouter('Créer un nouveau client') . '</a>';\r
-\r
- $filtres = array();\r
- if (wsDroits::admin()) {\r
- $filtres[] = new commonFiltre(__('Grade'), 'ws_grade', $settings['filtres']);\r
- $filtres[] = new commonFiltre(__('Administrateur'), 'admin_client', $settings['filtres']);\r
- }\r
-\r
- $res = commonPage::barre($filtres, 'filtreClients', 'clients', $shortcuts);\r
- $res .= commonPage::tMain();\r
- $res .= commonPage::bh();\r
- $res .= '<div id="listeClients">';\r
- $res .= self::listeClients();\r
- $res .= '</div>';\r
- $res .= commonPage::bf();\r
- $res .= commonPage::bMain();\r
- return $res;\r
- }\r
-\r
- public static function listeClients($dashboard = null, $settings = null) {\r
- global $core;\r
- commonDroits::min(3);\r
- $settings = is_null($settings) ? $core->user->getSettings('clients_ws') : $settings;\r
- $change = is_null($dashboard) ? 'Client' : 'Dashboard/' . $dashboard;\r
- $dao = new commonDAOEntreprise($core->con);\r
- if (isset($settings['search']) && !is_null($settings['search'])) {\r
- $dao->setSearch($settings['search']);\r
- }\r
- $dao->setFiltres($settings['filtres']);\r
-\r
- $admin = wsDroits::admin();\r
-\r
- if ($admin) {\r
- $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], null, 'entreprises_ws');\r
- } else {\r
- $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user, 'entreprises_ws');\r
- }\r
-\r
- $res = '<table class="liste">';\r
- $res .= '<tr><th>' . commonUrl::orderby('#', 'entreprise_id', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Raison sociale'), 'nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . __('Contacts') . '</th>';\r
- if ($admin) {\r
- $res .= '<th>' . commonUrl::orderby(__('Grade'), 'ws_grade', $settings, 'sort', $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Revendeur'), 'revendeur', $settings, 'sort', $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Administrateur'), 'administrateur', $settings, 'sort', $change) . '</th>';\r
- }\r
- $res .= '<th class="min"></th><th class="min"></th></tr>';\r
- $i = 0;\r
- foreach ($liste as $id => $client) {\r
- if (!is_array($client->contacts)) {\r
- $client->contacts = array();\r
- }\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '>';\r
- $res .= '<td>' . $client->entreprise_id . '</td>';\r
- $res .= '<td>' . $client->nom . '</td>';\r
- $contacts = array();\r
-\r
- foreach ($client->contacts as $c) {\r
- $contacts[] = '<a href="#" class="popup" rel="formContact/' . $c->utilisateur_id . '">' . $c->prenom . ' ' . $c->nom . '</a>';\r
- }\r
-\r
- $res .= '<td id="contacts_' . $client->entreprise_id . '">' . implode(', ', $contacts) . '</td>';\r
-\r
- if ($admin) {\r
- $rev = $client->ws_revendeur == '' ? '-' : $client->ws_revendeur;\r
- $adm = $client->ws_administrateur == '' ? '-' : $client->ws_administrateur;\r
-\r
- if ($client->ws_grade == 0) {\r
- $rev = $adm = '-';\r
- }\r
-\r
- $res .= '<td>' . $core->ws_grades[$client->ws_grade] . '</td>';\r
- $res .= '<td>' . $rev . '</td>';\r
- $res .= '<td>' . $adm . '</td>';\r
- }\r
-\r
- $res .= '<td class="nowrap">';\r
- $res .= '</td>';\r
- $res .= '<td class="action"><a href="#" class="popup" rel="formClient/' . $client->entreprise_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';\r
- $res .= '</tr>';\r
- $i++;\r
- }\r
- if (!isset($settings['search']) || is_null($settings['search'])) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '><td colspan="10">';\r
- if ($admin) {\r
- $res .= commonPage::pager($settings['page'], $dao->count(null, 'entreprises_ws'), $settings['par_page'], 'page' . $change . '/%d');\r
- } else {\r
- $res .= commonPage::pager($settings['page'], $dao->count($core->user, 'entreprises_ws'), $settings['par_page'], 'page' . $change . '/%d');\r
- }\r
- $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('clients'));\r
- $res .= '</td></tr>';\r
- }\r
- $res .= '</table>';\r
- return $res;\r
- }\r
-\r
- public static function formClient($entreprise_id = 'new') {\r
- global $core;\r
- commonDroits::min(3);\r
- $dao = new commonDAOEntreprise($core->con);\r
- $daoUtilisateur = new commonDAOUtilisateur($core->con);\r
- if ($entreprise_id == 'new') {\r
- $client = $dao->cree();\r
- } else {\r
- $client = $dao->selectById($entreprise_id);\r
- }\r
-\r
- $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('entreprise_id', $client->entreprise_id) . '' . $client->entreprise_id . '</td></tr>';\r
- $res .= '<tr><td>' . __('Raison sociale') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Site internet') . '</td><td>' . form::field('site', 30, 128, $client->site) . '</td></tr>';\r
- if (wsDroits::admin(false)) {\r
- $res .= '<tr><td>' . __('Adresse de facturation') . '</td><td>' . form::textarea('adresse_facturation', 40, 3, $client->adresse_facturation) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Numéro de TVA intracommunautaire') . '</td><td>' . form::field('tva_intra', 15, 13, $client->tva_intra) . '</td></tr>';\r
- }\r
- // Bloc Fluidbook Workshop\r
- if (wsDroits::admin(false)) {\r
- $res .= '<tr class="light"><th colspan="2" class="light"><strong>' . __('Fluidbook Workshop') . '</strong></th></tr>';\r
- $res .= '<tr class="odd"><td>' . __('Grade') . '</td><td>' . form::combo('ws_grade', array_flip($core->ws_grades), $client->ws_grade) . '</td></tr>';\r
- if ($entreprise_id == 'new' || !$client->ws_admin) {\r
- $class = 'empty-field';\r
- $default_id = '';\r
- $default = __("Entrez le nom du revendeur ou de l'administrateur");\r
- } else {\r
- $class = '';\r
- $default_id = $client->ws_admin;\r
- $wsa = $daoUtilisateur->selectById($client->ws_admin, 'utilisateurs_entreprise');\r
- $default = $wsa->utilisateur_id . ' - ' . $wsa->rs . ' (' . $wsa->prenom . ' ' . $wsa->nom . ')';\r
- }\r
-\r
- $d = $dao->getWSDatas($entreprise_id);\r
-\r
- $res .= '<tr class="odd"><td>' . __('Revendeur / Administrateur') . '</td><td>' . form::field('ws_admin_nom', 60, 128, $default, $class) . form::hidden('ws_admin', $default_id) . '</td></tr>';\r
- if (!is_null($d)) {\r
- $res .= '<tr class="odd"><td>' . __('Entité facturable') . '</td><td>' . $d->facturable->prenom . ' ' . $d->facturable->nom . ' (' . $d->facturable->rs . ')</td></tr>';\r
- $res .= '<tr class="odd"><td>' . __('Administrateur responsable') . '</td><td>' . $d->administrateur->prenom . ' ' . $d->administrateur->nom . ' (' . $d->administrateur->rs . ')</td></tr>';\r
- }\r
-\r
- $daoSignature = new wsDAOSignature($core->con);\r
- $signaturesList = $daoSignature->selectAll();\r
-\r
- $signatures = array();\r
- foreach ($signaturesList as $s) {\r
- $signatures[$s->nom] = $s->signature_id;\r
- }\r
-\r
- $res .= '<tr class="odd"><td>' . __('Signatures Fluidbook') . '</td><td>' . cubeForm::checkMultiple('ws_signatures', $signatures, 5, explode(',', $client->ws_signatures)) . '</td></tr>';\r
- }\r
- if ($entreprise_id == 'new') {\r
- $daoContact = new commonDAOClient($core->con);\r
- $contact = $daoContact->cree();\r
- $res .= '<tr><th colspan="2" class="light"><strong>' . __('Contact') . '</strong></th></tr>';\r
- $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field(array('contact[email]'), 30, 128, $contact->email) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field(array('contact[password]'), 30, 128, $contact->password) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Prénom') . '</td><td>' . form::field(array('contact[prenom]'), 30, 128, $contact->prenom) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Nom') . '</td><td>' . form::field(array('contact[nom]'), 30, 128, $contact->nom) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field(array('contact[telephone]'), 20, 128, $contact->telephone) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field(array('contact[mobile]'), 20, 128, $contact->mobile) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field(array('contact[fax]'), 20, 128, $contact->fax) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo(array('contact[lang]'), cubeLang::getAvailableLangs(true), $contact->lang) . '</td></tr>';\r
- }\r
- return $res;\r
- }\r
-\r
- public static function listeContacts($entreprise_id) {\r
- global $core;\r
- commonDroits::min(3);\r
- $dao = new commonDAOEntreprise($core->con);\r
- $contacts = $dao->getContacts($entreprise_id);\r
-\r
- $res = '<table class="liste light">';\r
- $res .= '<tr class="light"><th colspan="4"><a href="" class="popup" rel="formContact/new/' . $entreprise_id . '">' . $core->typo->Contact('Ajouter un contact') . '</a></th></tr>';\r
- $i = 0;\r
- foreach ($contacts as $contact) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '><td>' . trim($contact->prenom . ' ' . $contact->nom) . '</td>';\r
- $res .= '<td><a href="mailto:' . trim($contact->prenom . ' ' . $contact->nom) . '<' . $contact->email . '>">' . $contact->email . '</a></td>';\r
- $res .= '<td class="min"><a href="' . SITE_PATH . 'fichiers/' . $contact->utilisateur_id . '">FTP</a></td>';\r
- $res .= '<td><a class="ajax" href="#" rel="connectAs/' . $contact->utilisateur_id . '">Se connecter comme ...</a></td>';\r
- $res .= '<td class="right"><a href="#" rel="formContact/' . $contact->utilisateur_id . '" class="popup">' . cubeMedia::image(IMG . '/edit.png') . '</a></td></tr>';\r
- $i++;\r
- }\r
- $res .= '</table>';\r
- return $res;\r
- }\r
-\r
- public static function formCollection($collection_id = 'new') {\r
- global $core;\r
- commonDroits::min(3);\r
- $dao = new wsDAOCollection($core->con);\r
- if ($collection_id != 'new') {\r
- $collection = $dao->selectById($collection_id);\r
- } else {\r
- $collection = $dao->cree();\r
- }\r
-\r
- $res.='<tr><td>#</td><td>' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '</td></tr>';\r
- $res .= '<tr><td>Nom de la collection</td><td>' . form::field('nom', 20, 64, $collection->nom) . '</td></tr>';\r
- return $res;\r
- }\r
-\r
- public static function formContact($client_id = 'new', $entreprise_id = null) {\r
- global $core;\r
- commonDroits::min(3);\r
-\r
- $dao = new commonDAOClient($core->con);\r
- if ($client_id == 'new') {\r
- $client = $dao->creeFromEntreprise($entreprise_id);\r
- } else {\r
- $client = $dao->selectById($client_id);\r
- }\r
-\r
- $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('grade', 0) . form::hidden('entreprise', $client->entreprise) . form::hidden('utilisateur_id', $client->utilisateur_id) . '' . $client->utilisateur_id . '</td></tr>';\r
- $res .= '<tr><td>' . __('Login activé') . '</td><td>' . form::hidden('enabled', 0) . form::checkbox('enabled', 1, $client->enabled) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field('email', 30, 128, $client->email) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field('password', 30, 128, $client->password) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Prénom du contact') . '</td><td>' . form::field('prenom', 30, 128, $client->prenom) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Nom du contact') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field('telephone', 20, 128, $client->telephone) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field('mobile', 20, 128, $client->mobile) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field('fax', 20, 128, $client->fax) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo('lang', cubeLang::getAvailableLangs(true), $client->lang) . '</td></tr>';\r
- if ($client_id != 'new') {\r
- $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';\r
- $res .= '<tr><td></td><td><a href="' . SITE_PATH . 'fichiers/' . $client->utilisateur_id . '">' . __('FTP') . '</a></td></tr>';\r
- $res .= '<tr><td></td><td><a href="#" class="ajax" rel="connectAs/' . $client->utilisateur_id . '">' . __('Se connecter comme ...') . '</a></td></tr>';\r
- $res .= '<tr><td>' . __("Paramètres de connexion au Fluidbook Workshop") . '</td><td>' . __('Adresse') . ' : http://' . $_SERVER['HTTP_HOST'] . '/<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . $client->password . '</td></tr>';\r
- $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';\r
- }\r
- return $res;\r
- }\r
-\r
- public static function demandes() {\r
- global $core;\r
- cubePage::truePopup();\r
- cubePage::autoComplete();\r
- cubePage::emptyfield();\r
- commonDroits::min(5);\r
- $settings = $core->user->getSettings('demandes');\r
-\r
- $shortcuts = array();\r
-\r
- $filtres = array();\r
- $filtres[] = new commonFiltre(__('Statut'), 'status_demande', $settings['filtres']);\r
- $filtres[] = new commonFiltre(__('Confiées à'), 'demande_moi', $settings['filtres']);\r
-\r
- $res = commonPage::barre($filtres, 'filtreDemandes', 'demandes', $shortcuts);\r
- $res .= commonPage::tMain();\r
- $res .= commonPage::bh();\r
- $res .= '<div id="listeDemandes">';\r
- $res .= self::listeDemandes();\r
- $res .= '</div>';\r
- $res .= commonPage::bf();\r
- $res .= commonPage::bMain();\r
- return $res;\r
- }\r
-\r
- public static function listeDemandes($dashboard = null, $settings = null) {\r
- global $core;\r
- commonDroits::min(5);\r
- $settings = is_null($settings) ? $core->user->getSettings('demandes') : $settings;\r
- $change = is_null($dashboard) ? 'Demandes' : 'Dashboard/' . $dashboard;\r
- $dao = new wsDAODemande($core->con);\r
- if (isset($settings['search']) && !is_null($settings['search'])) {\r
- $dao->setSearch($settings['search']);\r
- }\r
- $dao->setFiltres($settings['filtres']);\r
- $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user);\r
-\r
- $res = '<table class="liste">';\r
- $res .= '<tr><th>' . commonUrl::orderby('#', 'demande_id', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Date'), 'date', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Type'), 'type', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Prospect') . '/' . __('Client'), 'utilisateur_nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Confiée à'), 'revendeur_nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Gérée par'), 'administrateur_nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . commonUrl::orderby(__('Statut'), 'status', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th class="min"></th><th class="min"></th></tr>';\r
- $i = 0;\r
- foreach ($liste as $id => $demande) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '>';\r
- $res .= '<td>' . $demande->demande_id . '</td>';\r
- $res .= '<td>' . date(__('d/m/Y H:i'), $demande->date) . '</td>';\r
- $res .= '<td>' . $core->demandes_type[$demande->type] . '</td>';\r
- $res .= '<td><a href="#" class="popup" rel="formClient/' . $demande->entreprise . '">' . $demande->utilisateur_nom . '</a></td>';\r
- $revendeur = $demande->revendeur == 0 ? '-' : $demande->revendeur_nom;\r
- $res .= '<td>' . $revendeur . '</td>';\r
- $administrateur = $demande->administrateur == 0 ? '-' : $demande->administrateur_nom;\r
- $res .= '<td>' . $administrateur . '</td>';\r
- // Affichage du status\r
- // Si non traitée ou traitée, pas la possibilité de changer le status\r
- if ($demande->status == 0 || $demande->status == 2) {\r
- $res .= '<td>' . $core->demandes_status[$demande->status] . '</td>';\r
- } else if ($demande->status == 1) {\r
- if ($demande->revendeur == $core->user->utilisateur_id) {\r
- $res .= '<td><a href="#" class="ajax" rel="reponseDemande/' . $demande->demande_id . '/' . $demande->revendeur . '/1/1">' . __('Je me suis chargé de cette demande') . '</a></td>';\r
- } else {\r
- $res .= '<td>' . $core->demandes_status[$demande->status] . ' (<a href="#" class="ajax" rel="resetDemande/' . $demande->demande_id . '" title="' . __('Réinitialiser la demande') . '">x</a>)</td>';\r
- }\r
- }\r
- // On ne peut éditer que si la facture est non traitée et qu'elle n'a pas commencé à être éditée par un autre administrateur\r
- if (($demande->administrateur == 0 || $demande->administrateur == $core->user->utilisateur_id) && $demande->status == 0) {\r
- $res .= '<td class="action"><a href="#" class="popup" rel="formDemande/' . $demande->demande_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';\r
- } else {\r
- $res .= '<td></td>';\r
- }\r
- // On n'affiche le bouton "Supprimer" que si la demande est non-traitée\r
- if (($demande->administrateur == 0 || $demande->administrateur == $core->user->utilisateur_id) && $demande->status == 0) {\r
- $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeDemande/' . $demande->demande_id . '" title="' . __('Êtes-vous certain de vouloir supprimer cette demande ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';\r
- } else {\r
- $res .= '<td></td>';\r
- }\r
- $res .= '</tr>';\r
- $i++;\r
- }\r
- if (!isset($settings['search']) || is_null($settings['search'])) {\r
- $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';\r
- $res .= '<tr' . $odd . '><td colspan="10">';\r
- $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d');\r
- $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('demandes'));\r
- $res .= '</td></tr>';\r
- }\r
- $res .= '</table>';\r
- return $res;\r
- }\r
-\r
- public static function formDemande($demande_id = 'new') {\r
- global $core;\r
- commonDroits::min(5);\r
- $dao = new wsDAODemande($core->con);\r
- $demande = $dao->selectById($demande_id);\r
-\r
- if ($demande->administrateur != 0 && $demande->administrateur != $core->user->utilisateur_id) {\r
- $action = __("Cette demande est actuellement en cours d'édition par un autre administrateur");\r
- } elseif ($demande->status > 1) {\r
- $action = __("Cette demande est actuellement en cours de traitement");\r
- } else {\r
- $action = '<a href="#" rel="lockDemande/' . $demande->demande_id . '" class="ajax">' . __("Cliquez-ici pour effectuer une action") . '</a>';\r
- }\r
-\r
-\r
- $res = '<tr><td>' . __('Numéro de demande') . '</td><td>' . form::hidden('demande_id', $demande->demande_id) . '' . $demande->demande_id . '</td></tr>';\r
- $res .= '<tr><td>' . __('Date de la demande') . '</td><td>' . date(__('d/m/Y H:i'), $demande->date) . '</td></tr>';\r
- $res .= '<tr><td>' . __('Emetteur de la demande') . '</td><td><a href="#" class="popup" rel="formClient/' . $demande->entreprise . '">' . $demande->utilisateur_nom . '</a></td></tr>';\r
- $res .= '<tr><td>' . __('Nombre de pages') . '</td><td>' . $demande->pages . '</td></tr>';\r
- $res .= '<tr><td>' . __('Nombre de liens') . '</td><td>' . $demande->liens . '</td></tr>';\r
- $res .= '<tr><td>' . __('Nombre de langues') . '</td><td>' . $demande->langues . '</td></tr>';\r
- $res .= '<tr><td>' . __('Détails') . '</td><td>' . $demande->details . '</td></tr>';\r
- $res .= '<tr><td>' . __('Action') . '</td><td><div id="actionDemande">' . $action . '</div></td></tr>';\r
- $res .= '<tr><td></td></tr>';\r
-\r
- return $res;\r
- }\r
-\r
- public static function reponseDemande($args) {\r
- global $core;\r
-\r
- commonDroits::min(3);\r
-\r
-\r
- $demande_id = $args[1];\r
- $revendeur_id = $args[2];\r
-\r
- $dao = new wsDAODemande($core->con);\r
- $demande = $dao->selectById($demande_id);\r
-\r
- $res = commonPage::barre();\r
- $res .= commonPage::tMain();\r
- $res .= commonPage::bh();\r
- $res .= '<div id="accepteDemandes">';\r
- $res .= '<h1>' . __('Prendre en charge une demande de devis') . '</h1>';\r
- $res .= '<br /><br />';\r
-\r
- if ($demande->revendeur != $revendeur_id || $demande->revendeur != $core->user->utilisateur_id || $demande->status == 0) {\r
- $res.='<p class="center">' . __('Cette demande de devis ne vous est pas adressée.') . '</p>';\r
- } else if ($demande->status == 2) {\r
- $res.='<p class="center">' . __('Merci ! Nous avons bien pris en compte votre réponse.') . '<br /><br />';\r
- $res.='<a href="' . $dao->getMailto($demande_id) . '">' . __("Ouvrir l'email de réponse") . '</a>';\r
- $res.='</p>';\r
- } else {\r
- $res .= '<p>' . __('Si vous acceptez de traiter la demande suivante, veuillez cliquer sur le bouton "Accepter la demande" situé à droite de la description.');\r
- $res .= ' ' . __('Vous avez également la possibilité de décliner la demande en cliquant sur le bouton "Décliner la demande"') . "</p>";\r
- $res .= '<br /><br />';\r
-\r
- $res .= '<table>';\r
- $res .= '<tr><th class="left" colspan="2">' . __("Détails de la demande") . '</th><th class="left" style="width:40%">' . __('Votre action') . '</th></tr>';\r
- $res .= '<tr><td>' . __('Numéro de demande') . '</td><td>' . $demande->demande_id . '</td>';\r
- $res .= '<td>' . '<a href="#" class="ajax download btbook" rel="reponseDemande/' . $demande_id . '/' . $revendeur_id . '/1" ><div></div><span>' . __('Accepter la demande') . '</span></a>' . '</td></tr>';\r
- $res .= '<tr><td>' . __('Date de la demande') . '</td><td>' . date(__('d/m/Y H:i'), $demande->date) . '</td></tr>';\r
- $res .= '</tr>';\r
- $res .= '<tr><td>' . __('Client') . ' / ' . __('Prospect') . '</td><td><a href="#" class="popup" rel="formClient/' . $demande->entreprise . '">' . $demande->utilisateur_nom . '</a></td></tr>';\r
- $res .= '<tr><td>' . __('Nombre de pages') . '</td><td>' . $demande->pages . '</td>';\r
- $res .= '<td>' . '<a href="#" class="ajax suppr btbook" rel="reponseDemande/' . $demande_id . '/' . $revendeur_id . '/0"><div></div><span>' . __('Décliner la demande') . '</span></a>' . '</td>';\r
- $res .='</tr>';\r
- $res .= '<tr><td>' . __('Nombre de liens') . '</td><td>' . $demande->liens . '</td></tr>';\r
- $res .= '<tr><td>' . __('Nombre de langues') . '</td><td>' . $demande->langues . '</td></tr>';\r
- $res .= '<tr><td>' . __('Détails') . '</td><td>' . $demande->details . '</td></tr>';\r
- $res .= '</table>';\r
- }\r
-\r
- $res .= '</div>';\r
- $res .= commonPage::bf();\r
- $res .= commonPage::bMain();\r
- return $res;\r
- }\r
-\r
-}\r
-\r
+<?php
+
+class wsUrl {
+
+ public static function publications($args) {
+ global $core;
+
+ if (isset($args[1])) {
+ $_SESSION['q'] = $args[1];
+ }
+
+ $settings = $core->user->getSettings('books');
+
+ $shortcuts = array();
+ if (wsDroits::creation()) {
+ $shortcuts[] = '<a href="#" class="popup" rel="newBookForm">' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . '</a>';
+ }
+
+ $filtres = array();
+ if (wsDroits::revendeur(false)) {
+ $filtres[] = new commonFiltre(__('Status'), 'status_book', $settings['filtres']);
+ }
+ if (wsDroits::admin()) {
+ $filtres[] = new commonFiltre(__('Administrateur'), 'admin_book', $settings['filtres']);
+ $filtres[] = new commonFiltre(__('Revendeur'), 'revendeur_book', $settings['filtres']);
+ }
+ $res = commonPage::barre($filtres, 'filtreBooks', 'books', $shortcuts, wsDroits::creation());
+ $res .= commonPage::tMain(null, wsDroits::creation());
+ $res .= commonPage::bh();
+ $res .= '<div id="listeBooks">';
+ $res .= self::listeBooks();
+ $res .= '</div>';
+ $res .= commonPage::bf();
+ $res .= commonPage::bMain();
+ return $res;
+ }
+
+ public static function listeBooks($dashboard = null, $settings = null) {
+ global $core;
+ cubePage::truePopup();
+ cubePage::autocomplete();
+ cubePage::contextMenu();
+
+ $droits = wsDroits::getDroits();
+
+ commonDroits::min(1);
+ $settings = is_null($settings) ? $core->user->getSettings('books') : $settings;
+ $change = is_null($dashboard) ? 'Books' : 'Dashboard/' . $dashboard;
+ $dao = new wsDAOBook($core->con);
+ $context_download_id = is_null($dashboard) ? 'contextDownloadBook' : 'contextDashboard_Download' . $dashboard;
+ $context_status_id = is_null($dashboard) ? 'contextStatusBook' : 'contextDashboard_Status' . $dashboard;
+ $context_view_id = is_null($dashboard) ? 'contextViewBook' : 'contextView_Status' . $dashboard;
+
+ if (isset($settings['search']) && !is_null($settings['search'])) {
+ $dao->setSearch($settings['search']);
+ }
+ $dao->setFiltres($settings['filtres']);
+ $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user);
+
+ $res = '';
+
+ $res .= self::contextBookDownload($context_download_id, $droits);
+ $res .= self::contextBookStatus($context_status_id);
+ $res .= self::contextBookView($context_view_id);
+
+ $res .= '<table class="liste">';
+ $res .= '<tr><th>' . commonUrl::orderby('#', 'book_id', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Titre de la publication'), 'nom', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Date'), 'date', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__(''), 'lang', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . __('Pages') . '</th>';
+ if ($droits->admin) {
+ $res .= '<th>' . commonUrl::orderby('C', 'demo_counter', $settings, 'sort' . $change, __('Compteur de démos')) . '</th>';
+ }
+ if ($droits->revendeur) {
+ $res .= '<th>' . commonUrl::orderby(__('Proprietaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '</th>';
+ } else {
+ $res .= '<th>' . commonUrl::orderby(__('Proprietaire'), 'proprietaire_utilisateur', $settings, 'sort' . $change) . '</th>';
+ }
+ if ($droits->admin) {
+ $res .= '<th>' . commonUrl::orderby(__('Facturation'), 'facturable', $settings, 'sort' . $change) . '</th>';
+ }
+ if ($droits->revendeur) {
+ $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . __('V') . '</th>';
+ }
+ $res .= str_repeat('<th class="min"></th>', 5);
+ $res .= '</tr>';
+ $i = 0;
+
+ $btVoir = '<div></div><span>' . __('voir') . '</span>';
+ $btEdit = '<div></div><span>' . __('éditer') . '</span>';
+ $btStats = '<div></div><span>' . __('stats') . '</span>';
+ $btDownload = '<div></div><span>' . __('télécharger') . '</span>';
+ if ($droits->creation) {
+ $btDel = '<div></div><span>' . __('suppr.') . '</span>';
+ }
+
+ foreach ($liste as $id => $book) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '>';
+ $res .= '<td>' . $book->book_id . '</td>';
+ $res .= '<td>' . html::escapeHTML($book->nom) . '</td>';
+ $res .= '<td>' . date('Y-m-d', $book->date) . '</td>';
+ $res .= '<td>' . mb_strtoupper($book->lang) . '</td>';
+ $res .= '<td>' . $book->parametres->pages . '</td>';
+ if ($droits->admin) {
+ $res.='<td>' . $book->demo_counter . '</td>';
+ }
+
+ if ($droits->revendeur) {
+ $p = str_replace(" (", '<br /><em>', html::escapeHTML($book->proprietaire));
+ $p = str_replace(')', '</em>', $p);
+ $res .= '<td><a href="#" class="popup" rel="formChangeBookProprietaire/' . $book->book_id . '" title="' . __('Modifier le proprietaire') . '">' . $p . '</a></td>';
+ } else {
+ $res .= '<td>' . html::escapeHTML($book->proprietaire_utilisateur) . '</td>';
+ }
+ if ($droits->admin) {
+ $res .= '<td>' . html::escapeHTML($book->facturable) . '</td>';
+ }
+ if ($droits->revendeur) {
+ if ($droits->admin || $book->status < 1) {
+ $p = '';
+ if (!is_null($book->projet)) {
+ $p = ' <a href="' . EXTRANET_URL . '/projet/' . $book->projet . '" title="' . __('Voir les détails du projet') . '" class="blank icon">' . cubeMedia::silk('arrow_right.png') . '</a>';
+ }
+ $res .= '<td><a href="#" class="openContextMenu" rel="' . $context_status_id . '" rev="' . $book->book_id . '">' . $core->books_status[$book->status] . '</a>' . $p . '</td>';
+ } else {
+ $res .= '<td>' . $core->books_status[1] . '</td>';
+ }
+ $res.='<td>' . $book->version . '</td>';
+ }
+ if ($book->version > 1 || $droits->admin) {
+ if ($droits->admin) {
+ $res .= '<td class="bouton"><a href="/viewer/' . $book->book_id . '_' . $book->hash . '/" class="openContextMenu voir btbook" rel="' . $context_view_id . '" rev="' . $book->book_id . '§' . $book->hash . '§' . TIME . '">' . $btVoir . '</a></td>';
+ } else {
+ $viewURL = SITE_PATH . 'viewer/' . $book->book_id . '_' . $book->hash;
+ if ($book->parametres->version == 1) {
+ $viewURL = SITE_PATH . 'viewer1/' . $book->book_id . '_' . $book->hash;
+ }
+ $res .= '<td class="bouton"><a class="popupFSBar voir btbook" rel="toolbar=yes" rev="viewer_' . $book->book_id . '" href="' . $viewURL . '/">' . $btVoir . '</a></td>';
+ }
+ $res .= '<td class="bouton"><a class="popupFSBar edit btbook" rel="toolbar=yes" rev="editor_' . $book->book_id . '" href="' . SITE_PATH . 'editor/' . $book->book_id . '_' . $book->hash . '">' . $btEdit . '</a></td>';
+ } else {
+ $res.='<td></td><td></td>';
+ }
+ $res .= '<td class="bouton"><a href="' . SITE_PATH . 'stats/' . $book->book_id . '_' . $book->hash . '" class="normallink stats btbook">' . $btStats . '</a></td>';
+ if ($book->version > 1) {
+ if ($droits->admin) {
+ $res .= '<td class="bouton"><a href="#" rel="exportbook/' . $book->book_id . '" class="popup download btbook">' . $btDownload . '</a></td>';
+ } else {
+ $res .= '<td class="bouton"><a href="#" class="openContextMenu download btbook" rel="' . $context_download_id . '" rev="' . $book->book_id . '">' . $btDownload . '</a></td>';
+ }
+ } else {
+ $res.='<td></td>';
+ }
+ if ($droits->creation && $book->status < 0) {
+ $res .= '<td class="bouton"><a href="#" rel="supprimeBook/' . $book->book_id . '" class="ajax suppr btbook" title="' . __('Êtes-vous certain de vouloir supprimer cette publication ?') . '">' . $btDel . '</a></td>';
+ } else {
+ $res.='<td></td>';
+ }
+ $res .= '</tr>';
+ $i++;
+ }
+
+ if (!isset($settings['search']) || is_null($settings['search'])) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '><td colspan="15">';
+ $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d');
+ $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('publications'), false);
+ $res .= '</td></tr>';
+ }
+ $res .= '</table>';
+ return $res;
+ }
+
+ public static function collections() {
+ global $core;
+
+ if (isset($args[1])) {
+ $_SESSION['q'] = $args[1];
+ }
+
+ $settings = $core->user->getSettings('collections');
+ $shortcuts = array();
+ if (wsDroits::creation()) {
+ $shortcuts[] = '<a href="#" class="popup" rel="newCollectionForm">' . $core->typo->Ajouter(__('Créer une nouvelle collection')) . '</a>';
+ }
+
+ $filtres = array();
+
+ $res = commonPage::barre($filtres, 'filtreCollections', 'collections', $shortcuts);
+ $res .= commonPage::tMain(null);
+ $res .= commonPage::bh();
+ $res .= '<div id="listeCollections">';
+ $res .= self::listeCollections();
+ $res .= '</div>';
+ $res .= commonPage::bf();
+ $res .= commonPage::bMain();
+ return $res;
+ }
+
+ public static function collection($args) {
+ global $core;
+ commonDroits::min(1);
+ cubePage::ui('Sortable');
+ cubePage::autocomplete();
+
+ $dao = new wsDAOCollection($core->con);
+ $collection = $dao->selectById($args[1]);
+
+ $shortcuts = array();
+
+ $res = commonPage::barre(null, null, null, $shortcuts);
+ $res .= commonPage::tMain();
+ $res .= commonPage::bh();
+ $res .= '<div id="collection">';
+ $res .= self::collectionEdit($collection);
+ $res .= '</div>';
+ $res .= commonPage::bf();
+ $res .= commonPage::bMain();
+ return $res;
+ }
+
+ public static function collectionEdit($collection) {
+ global $core;
+
+ $res = '<h1>Gestion de la collection « ' . $collection->nom . ' » <em># ' . $collection->collection_id . '</em></h1>';
+ $res.='<form method="post" action="saveCollectionComposition" enctype="multipart/form-data">';
+ $res.='<table class="max">';
+ $res.='<tr><td class="min nowrap">#</td><td>' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Nom de la collection') . '</td><td>' . form::field('nom', 20, 64, $collection->nom) . '</td></tr>';
+ $res.='</table>';
+ $res.='<h3>' . __('Composition') . '</h3>';
+ $res.='<a href="#" id="newGroup">' . $core->typo->Ajouter(__('Nouveau groupe')) . '</a><br /><br />';
+ $res .= '<ul>';
+
+ $dao = new wsDAOCollection($core->con);
+ $books = $dao->getPublications($collection->collection_id);
+
+ $datas = $collection->datas;
+ $datas['new_'] = $dao->_emptyGroup();
+
+ $langs = array();
+
+ foreach ($datas as $gid => $group) {
+ $class = 'group';
+ if ($gid && $gid == 'new_') {
+ $class.=' empty';
+ }
+ $res.='<li class="' . $class . '" data-group="' . $gid . '">';
+ $res.='<div class="g">';
+ $res.='<a href="#" class="move"></a>';
+ $g = 'group[' . $gid . ']';
+ $res.=__('Nom du groupe') . ' ' . form::field(array($g . '[label]'), 20, 64, $group['label']);
+ $res.='<a href="#" class="delete"></a>';
+ $res.='</div>';
+ $res.='<ul>';
+ $res.='<li style="height:2px;"></li>';
+
+ $publications = array_values($group['publications']);
+ foreach ($publications as $pid => $publication) {
+ if ($gid && $gid == 'new_') {
+ $pid = 'pnew_';
+ }
+ $p = $g . '[publications][' . $pid . ']';
+ $res.='<li class="publication" data-publication="' . $pid . '"><div>';
+ if (isset($books[$publication['id']])) {
+ $book = $books[$publication['id']];
+ $langs[] = $book->lang;
+ } else {
+ $book = new stdClass();
+ $book->lang = '';
+ $book->nom = '';
+ }
+ $res.='<a href="#" class="move"></a>';
+ $res.='<span class="lang">' . mb_strtoupper($book->lang) . '</span>';
+ $res.='<span class="id"># ' . form::field(array($p . '[s]'), 64, 256, trim($publication['id'] . ' - ' . $book->nom, ' -'), 'publication_id') . form::hidden(array($p . '[id]'), $publication['id']) . '</span>';
+ $res.='<span class="label">' . __('Label') . ' ' . form::field(array($p . '[label]'), 20, 64, $publication['label']) . '</span>';
+ $res.='<a href="#" class="delete"></a>';
+ $res.='<a href="#" class="add"></a>';
+ $res.='<span class="online">' . form::checkbox(array($p . '[online]'), '1', $publication['online']) . '</span>';
+ $res.='</div></li>';
+ }
+ $res.='</ul>';
+ $res.='</li>';
+ }
+
+ $langs = array_unique($langs);
+
+ $res.='</ul>';
+
+ foreach ($langs as $l) {
+ $res.='<h3>' . __('Contenus') . ' [' . $l . ']</h3>';
+ $res.='<table class="max">';
+ $res.='<tr><td class="min nowrap">' . __('Titre') . '</td><td>' . form::field(array('contents[' . $l . '][titre]', 'contents_' . $l . '_titre'), 64, 64, $collection->contents[$l]['titre']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('A propos') . '</td><td>' . form::textarea(array('contents[' . $l . '][apropos]', 'contents_' . $l . '_apropos'), 60, 10, $collection->contents[$l]['apropos']) . '</td></tr>';
+ //'splash' =>
+ $res.='<tr><td class="min nowrap">' . __('Ecran de lancement') . ' (2048x2048px)</td><td><input type="file" name="splash_' . $l . '" />' . form::hidden(array('theme[splash_' . $l . ']', 'splash_' . $l), $collection->theme['splash_' . $l]) . '</td></tr>';
+ $res.='</table>';
+ }
+
+ $v = wsHTML5Compiler::getPhonegapVersions();
+ $phonegapVersions = array_combine($v, $v);
+
+ $res.='<h3>' . __('Paramètres avancés') . '</h3>';
+ $res.='<table class="max">';
+ $res.='<tr><td class="min nowrap">' . __('Build') . '</td><td>' . form::field(array('settings[build]', 'build'), 10, 64, $collection->settings['build']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Version') . '</td><td>' . form::field(array('settings[version]', 'version'), 10, 64, $collection->settings['version']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Full offline') . '</td><td>' . form::checkbox(array('settings[offline]', 'offline'), 1, $collection->settings['offline']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Version phonegap') . '</td><td>' . form::combo(array('settings[phonegap]', 'phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Identifiant de l\'application') . '</td><td>' . form::field(array('settings[namespace]', 'namespace'), 64, 64, $collection->settings['namespace']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Dev (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_dev" /></td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Prod (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_prod" /></td></tr>';
+ $res.='</table>';
+
+ $res.='<h3>' . __('Applications offline') . '</h3>';
+ $res.='<table class="max">';
+ $res.='<tr><td class="min nowrap">' . __("Filtres d'exclusion") . '</td><td>' . form::textarea(array('settings[offline_exclude]', 'offline_exclude'), 30, 3, $collection->settings['offline_exclude']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __("Synchronisations supplémentaires") . '</td><td>' . form::textarea(array('settings[offline_syncs]', 'offline_syncs'), 30, 3, $collection->settings['offline_syncs']) . '</td></tr>';
+ $res.='</table>';
+
+ $res.='<h3>' . __('Thème') . '</h3>';
+ $res.='<table class="max">';
+ $images = array('back' => __('Image de fond'), 'etagere' => __("Image de l'étagère"), 'icon' => __("Icône de l'application") . ' (1024x1024px)');
+ foreach ($images as $i => $label) {
+ $res.='<tr><td class="min nowrap">' . $label . '</td><td><input type="file" name="' . $i . '" />' . form::hidden(array('theme[' . $i . ']', 'theme_' . $i), $collection->theme[$i]) . '</td></tr>';
+ }
+ $res.='<tr><td class="min nowrap">' . __('Couleur principale') . '</td><td>#' . form::field(array('settings[couleurA]', 'couleurA'), 6, 6, $collection->settings['couleurA']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Couleur secondaire') . '</td><td>#' . form::field(array('settings[couleurB]', 'couleurB'), 6, 6, $collection->settings['couleurB']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Couleur des textes') . '</td><td>#' . form::field(array('settings[couleurC]', 'couleurC'), 6, 6, $collection->settings['couleurC']) . '</td></tr>';
+
+ $res.='</table>';
+
+ $res.='<a href="#" class="submit right">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>';
+ $res.='</form>';
+ $res.='<p class="clear"></p>';
+ $res.='<h3>' . __('Versions') . '</h3>';
+ $res.='<a href="#" class="ajax" rel="collectionVersionCreate/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Créer une version')) . '</a><br /><br />';
+ $r = $core->con->select('SELECT * FROM book_collection_compile WHERE collection_id=\'' . $collection->collection_id . '\' ORDER BY compile_date DESC');
+ if (!$r->count()) {
+ $res.=__('Aucune version de la collection n\'a été crée');
+ } else {
+ $res.='<table class="max">';
+ $res.='<tr><th class="left">' . __('Date') . '</th><th class="left">iOS</th><th class="left">Android</th><th class="min nowrap"></th></tr>';
+ while ($r->fetch()) {
+
+ if ($r->online_ios || $r->online_android) {
+ $del = '';
+ } else {
+ $del = '<a class="ajax suppr btbook" rel="collectionVersionDelete/' . $r->collection_id . '/' . $r->compile_date . '" href="#" title="' . __('Êtes-vous certain de vouloir supprimer cette version ?') . '"><div></div><span>' . __('Effacer') . '</span></a>';
+ }
+
+ if ($r->online_ios) {
+ $pub_ios = __('Publiée');
+ } else {
+ $pub_ios = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/ios" href="#"><div></div><span>' . __('Publier') . '</span></a>';
+ }
+
+ if ($r->online_android) {
+ $pub_android = __('Publiée');
+ } else {
+ $pub_android = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/android" href="#"><div></div><span>' . __('Publier') . '</span></a>';
+ }
+ $res.='<tr><td>' . date('Y-m-d H:i:s', $r->compile_date) . '</td><td>' . $pub_ios . '</td><td>' . $pub_android . '</td><td class="min nowrap">' . $del . '</td></tr>';
+ }
+ $res.='</table>';
+ }
+
+ $res.='<h3>' . __('Notifications') . '</h3>';
+ $res.='<p>' . __('Indiquez le texte de la notification à envoyer aux utilisateurs') . ' (' . __('Max 200 caractères') . ').<br />' . __('Laissez vide si vous souhaitez simplement afficher un badge') . '</p>';
+ $res.='<form method="post" action="publishCollection">';
+ $res.=form::hidden('collection', $collection->collection_id);
+ $res.='<table class="max">';
+ foreach ($langs as $lang) {
+ $res.='<tr><td class="min nowrap">' . __('Notification') . '[' . $lang . ']</td><td class="pad">' . form::textArea(array('notification[' . $lang . ']'), 60, 3) . '</td></tr>';
+ }
+ $res.='<tr><td colspan="2" class="right"></td><a href="#" class="submit">' . $core->typo->Ajouter(__('Publier et notifier les utilisateurs')) . '</a></tr>';
+ $res.='</table>';
+ $res.='</form>';
+ $res.='<h3>' . __('Export') . '</h3>';
+ $res.='<a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/android">' . $core->typo->Ajouter(__('Exporter pour Android')) . '</a> <a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/ios">' . $core->typo->Ajouter(__('Exporter pour iOS')) . '</a>';
+
+ return $res;
+ }
+
+ public static function listeCollections($dashboard = null, $settings = null) {
+ global $core;
+
+ cubePage::truePopup();
+
+ $droits = wsDroits::getDroits();
+
+ commonDroits::min(3);
+ $settings = is_null($settings) ? $core->user->getSettings('collections') : $settings;
+ $change = is_null($dashboard) ? 'Collections' : 'Dashboard/' . $dashboard;
+ $dao = new wsDAOCollection($core->con);
+ if (isset($settings['search']) && !is_null($settings['search'])) {
+ $dao->setSearch($settings['search']);
+ }
+ $dao->setFiltres($settings['filtres']);
+ $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user);
+
+ $btVoir = '<div></div><span>' . __('voir') . '</span>';
+ $btEdit = '<div></div><span>' . __('éditer') . '</span>';
+ $btStats = '<div></div><span>' . __('stats') . '</span>';
+ $btDownload = '<div></div><span>' . __('télécharger') . '</span>';
+ if ($droits->creation) {
+ $btDel = '<div></div><span>' . __('suppr.') . '</span>';
+ }
+
+
+ $res = '<table class="liste">';
+ $res .= '<tr><th>' . commonUrl::orderby('#', 'collection_id', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Nom de la collection'), 'nom', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Propriétaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '</th>';
+ $res .= str_repeat('<th class="min"></th>', 4);
+ $res.='</tr>';
+
+ $i = 0;
+ foreach ($liste as $collection) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res.='<tr>';
+ $res.='<td>' . $collection->collection_id . '</td>';
+ $res.='<td>' . $collection->nom . '</td>';
+ if ($droits->revendeur) {
+ $p = str_replace(" (", '<br /><em>', html::escapeHTML($collection->proprietaire_nom));
+ $p = str_replace(')', '</em>', $p);
+ $res .= '<td><a href="#" class="popup" rel="formChangeCollectionProprietaire/' . $collection->collection_id . '" title="' . __('Modifier le proprietaire') . '">' . $p . '</a></td>';
+ } else {
+ $res .= '<td>' . html::escapeHTML($collection->proprietaire_utilisateur) . '</td>';
+ }
+
+ $res .= '<td class="bouton"><!--<a href="#" class="normallink voir btbook">' . $btVoir . '</a>--></td>';
+ $res .= '<td class="bouton"><a href="/collection/' . $collection->collection_id . '" class="normallink edit btbook">' . $btEdit . '</a></td>';
+ $res .= '<td class="bouton"><!--<a href="#" class="normallink download btbook">' . $btDownload . '</a>--></td>';
+ $res .= '<td class="bouton"><!--<a href="#" class="normallink suppr btbook">' . $btDel . '</a>--></td>';
+
+ $res.='</tr>';
+
+ $i++;
+ }
+
+ if (!isset($settings['search']) || is_null($settings['search'])) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '><td colspan="7">';
+ $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d');
+ $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('collections'), false);
+ $res .= '</td></tr>';
+ }
+ $res .= '</table>';
+
+ return $res;
+ }
+
+ public static function getFluidbookVersions($select = false) {
+ $droits = wsDroits::getDroits();
+
+ $chooseVersion = wsDroits::admin();
+
+ if ($chooseVersion) {
+ $default = ' - ' . __('Version par défaut');
+ } else {
+ $default = '';
+ }
+
+ $versions = array();
+ $versions['online'] = array('title' => __('Version online') . $default, 'icon' => cubeMedia::silk('page_world.png'));
+ if ($chooseVersion) {
+ $versions['v1'] = array('title' => __('Version online') . ' - V1', 'icon' => cubeMedia::silk('page_white_world.png'));
+ $versions['v2'] = array('title' => __('Version online') . ' - V2', 'icon' => cubeMedia::silk('page_white_world.png'));
+ }
+ $versions['win-exe'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png'));
+ $versions['win-ins'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png'));
+ $versions['mac-exe'] = array('title' => __('Version offline') . ' - ' . __('Exécutable Mac OS X'), 'icon' => cubeMedia::image(IMG . '/macos.png'));
+ $versions['win-cd'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('Clé USB'), 'icon' => cubeMedia::silk('cd.png'));
+ if ($droits->admin) {
+ $versions['phonegap'] = array('title' => __('Version offline') . ' - ' . __('Application mobile'), 'icon' => cubeMedia::image(IMG . '/phonegap.png'));
+ }
+
+ if (!$select) {
+ return $versions;
+ }
+
+ $res = array();
+ foreach ($versions as $id => $d) {
+ $t = explode('-', $d['title'], 2);
+ $meta = trim($t[0]);
+ if (isset($t[1])) {
+ $title = trim($t[1]);
+ } else {
+ $title = $meta;
+ }
+
+ if (!isset($res[$meta])) {
+ $res[$meta] = array();
+ }
+ $res[$meta][$title] = $id;
+ }
+ return $res;
+ }
+
+ public static function contextBookDownload($id, $droits) {
+ global $core;
+
+ $versions = self::getFluidbookVersions();
+
+ $res = '<div class="contextMenu downbookContextMenu" id="' . $id . '">';
+ $res .= '<ul>';
+ $res .= '<li class="head">' . __("Sélectionnez une version") . '</li>';
+ foreach ($versions as $k => $v) {
+ $res .= '<li><a href="#" rel="downbook/$1/' . $k . '" class="ajax">' . $v['icon'] . $v['title'] . '</a></li>';
+ }
+ if ($droits->admin) {
+ $res .= '<li class="head">' . __("Installer sur ...") . '</li>';
+ $versions = array();
+ $versions['hosting'] = array('title' => __("Le serveur d'hébergement"), 'icon' => cubeMedia::silk('server_go.png'));
+ $versions['references'] = array('title' => __("L'espace références"), 'icon' => cubeMedia::silk('server_add.png'));
+ $versions['external'] = array('title' => __("Serveur FTP"), 'icon' => cubeMedia::silk('server_add.png'));
+ $versions['macbook_phonegap_ios'] = array('title' => __("Projet Phonegap IOS"), 'icon' => cubeMedia::image(IMG . '/ios.png'));
+ $versions['phonegap_android'] = array('title' => __("Projet Phonegap Android"), 'icon' => cubeMedia::image(IMG . '/android.png'));
+
+ foreach ($versions as $k => $v) {
+ $res .= '<li><a href="#" rel="instbook/$1/' . $k . '" class="ajax">' . $v['icon'] . $v['title'] . '</a></li>';
+ }
+ }
+ $res .= '</ul></div>';
+ return $res;
+ }
+
+ public static function contextBookStatus($id) {
+ global $core;
+
+ if (wsDroits::admin()) {
+ $status = $core->books_status;
+ $status[2] = __('Facturé (associé à un projet)');
+ } else {
+ $status = array();
+ $status[-1] = $core->books_status[-1];
+ $status[0] = $core->books_status[0];
+ }
+
+ $res = '<div class="contextMenu statusbookContextMenu" id="' . $id . '">';
+ $res .= '<ul>';
+ $res .= '<li class="head">' . __("Changer le status de la publication") . '</li>';
+ foreach ($status as $s => $title) {
+ $res .= '<li><a href="#" rel="statusBook/$1/' . $s . '" class="ajax">' . $title . '</a></li>';
+ }
+ $res .= '</ul></div>';
+ return $res;
+ }
+
+ public static function contextBookView($id) {
+ global $core;
+
+ if (wsDroits::admin()) {
+ $viewers = array(array('version' => 'viewer', 'title' => __('Version Flash'), 'icon' => cubeMedia::image(IMG . '/flash.png')),
+ array('version' => 'viewerh', 'title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')),
+ array('version' => 'vieweru', 'title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')),
+ array('version' => 'viewerhu', 'title' => __('Version HTML5') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/html5bug.png')),
+ //array('version' => 'viewerhu', 'title' => __('Widget HTML5'), 'icon' => cubeMedia::image(IMG . '/html5bug.png'), 'file' => 'widget.html', 'pattern' => '$1_$2_$3'),
+ array('version' => 'viewer1', 'title' => __('Version 1'), 'icon' => cubeMedia::image(IMG . '/flash.png'))
+ );
+ }
+
+ $res = '<div class="contextMenu viewbookContextMenu" id="' . $id . '">';
+ $res .= '<ul>';
+ $res .= '<li class="head">' . __("Sélectionnez la version") . '</li>';
+ if (isset($viewers)) {
+ foreach ($viewers as $infos) {
+ if (!isset($infos['file'])) {
+ $infos['file'] = '';
+ }
+ if (!isset($infos['pattern'])) {
+ $infos['pattern'] = '$1_$2';
+ }
+ $res .= '<li><a class="popupFSBar" rel="toolbar=1,scrollbars=1" rev="' . $infos['version'] . '_$1" href="' . SITE_PATH . $infos['version'] . '/' . $infos['pattern'] . '/' . $infos['file'] . '">' . $infos['icon'] . $infos['title'] . '</a></li>';
+ }
+ }
+ $res .= '</ul></div>';
+ return $res;
+ }
+
+ public static function traductions($args) {
+ global $core;
+
+ commonDroits::min(5);
+
+ if (count($args) < 2) {
+ $args[1] = 'fr';
+ }
+
+ $allLangs = cubeLang::getCodes($core->user->lang);
+ $existingLangs = array();
+
+ $dao = new wsDAOLang($core->con);
+ $langs = $dao->selectAll();
+ foreach ($langs as $lang) {
+ if (!isset($allLangs[$lang->lang_id])) {
+ continue;
+ }
+ $existingLangs[$lang->lang_id] = $allLangs[$lang->lang_id];
+
+ unset($allLangs[$lang->lang_id]);
+ }
+
+ $langs = array(__('Langues configurées') => array_flip($existingLangs), __('Autres langues') => array_flip($allLangs));
+
+ $res = commonPage::barre();
+ $res .= commonPage::tMain(null, false);
+
+ $res .= commonPage::bh();
+ $res .= '<form action="changeLang" method="post" class="submitonchange">';
+ $res .= '<table class="liste">';
+ $res .= '<tr><td class="center">' . __('Sélectionnez la langue à configurer') . ' : ' . form::combo('lang', $langs, $args[1]) . ' </td></tr>';
+ $res .= '</table>';
+ $res .= '</form>';
+ $res .= commonPage::bf();
+
+ $res .= '<div id="formLang">';
+ $res .= self::formLang($args[1]);
+ $res .= '</div>';
+ $res .= commonPage::bMain(true);
+
+ return $res;
+ }
+
+ public static function formLang($lang_id) {
+ commonDroits::min(5);
+ global $core;
+ $dao = new wsDAOLang($core->con);
+ $lang = $dao->selectById($lang_id);
+
+ $res = commonPage::bh();
+ $res .= '<table class="liste">';
+ $res .= '<tr><td><a href="' . SITE_PATH . 'exportLangAsExcel/' . $lang_id . '">' . __('Exporter au format Excel') . '</a>';
+ $res.=' | <a href="' . SITE_PATH . 'exportAllLangsAsExcel/' . $lang_id . '">' . __('Exporter toutes les langues au format Excel') . '</a>';
+ $res.='</td></tr>';
+ $res .= '</table>';
+ $res .= commonPage::bf();
+
+ $res .= '<form action="saveLang" method="post">';
+
+ $res .= commonPage::bh();
+ $res .= '<table class="liste">';
+ $res .= '<tr><td>' . __('Police de caractères') . ' : </td><td>' . form::hidden('lang', $lang_id) . form::combo('font', self::getFonts(), $lang->font) . '</td></tr>';
+ $res .= '<tr class="odd"><td>' . __('Jeux de caractères') . ' : </td><td>' . form::combo('charset', self::getCharsets(), $lang->charset) . '</td></tr>';
+ $res .= '<tr><td>' . __("Langue de l'installeur") . ' : </td><td>' . form::combo('nsis', self::getNSISLangs(), $lang->nsis) . '</td></tr>';
+ $res .= '<tr><td colspan="2" class="right odd"><a href="#" class="submit">' . $core->typo->Ajouter('Valider') . '</a></td></tr>';
+ $res .= '</table>';
+ $res .= commonPage::bf();
+
+ $res .= commonPage::bh();
+ $res .= cubeLang::translationForm(array(__('Version Flash') => PLAYER_SOURCES, __('Version HTML5') => WS_COMPILE_ASSETS . '/_html5', __('Compilateur HTML5') => ROOT . '/inc/ws/Util/html5', __('Application') => WS_COMPILE_ASSETS . '/_html5app'), $lang_id, null, 'liste', array(), '<a href="#" class="submit">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>', $lang->traductions);
+ $res .= commonPage::bf();
+ $res .= '</form>';
+ return $res;
+ }
+
+ public static function exportLangAsExcel($args) {
+ global $core;
+
+ $lang_id = $args[1];
+
+ $xls = new PHPExcel();
+ $s = $xls->setActiveSheetIndex(0);
+
+ $lang_name = self::exportLangAsSheet($s, $lang_id, 'en');
+
+ $xls->setActiveSheetIndex(0);
+
+ ob_end_clean();
+ files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'));
+ cubeHTTP::forceDownload('Fluidbook_' . $lang_name . '.xlsx', false);
+
+ $writer = new PHPExcel_Writer_Excel2007($xls);
+ $writer->save('php://output');
+
+ exit;
+ }
+
+ public static function exportAllLangsAsExcel($args) {
+ global $core;
+
+ $xls = new PHPExcel();
+
+ $dao = new wsDAOLang($core->con);
+ $all = $dao->selectAll();
+
+ $i = 0;
+ foreach ($all as $l) {
+ try {
+ $s = $xls->getSheet($i);
+ } catch (Exception $e) {
+ $s = $xls->createSheet($i);
+ }
+ self::exportLangAsSheet($s, $l->lang_id, 'en');
+ $i++;
+ }
+
+ $xls->setActiveSheetIndex(0);
+
+ ob_end_clean();
+ files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'));
+ cubeHTTP::forceDownload('Fluidbook_All_Languages.xlsx', false);
+
+ $writer = new PHPExcel_Writer_Excel2007($xls);
+ $writer->save('php://output');
+ }
+
+ public static function exportLangAsSheet($s, $lang_id, $ref_id = 'en') {
+ global $core;
+ $dao = new wsDAOLang($core->con);
+
+
+ $lang = $dao->selectById($lang_id);
+ $ref = $dao->selectById($ref_id);
+
+ $lang_name = cubeLang::getNameByCode($lang_id, 'en');
+ $ref_name = cubeLang::getNameByCode($ref_id, 'en');
+
+ $s->setTitle(cubeText::str2URL($lang_name));
+
+ $tab = cubeLang::getTranslationsList(array(PLAYER_SOURCES, WS_COMPILE_ASSETS . '/_html5/js', ROOT . '/inc/ws/Util/html5'), array('php', 'as', 'js'), array(), $lang->traductions);
+
+ $s->setCellValueByColumnAndRow(0, 1, 'ID', true);
+ $s->setCellValueByColumnAndRow(1, 1, $ref_name, true);
+ $s->setCellValueByColumnAndRow(2, 1, $lang_name, true);
+
+ $j = 2;
+ foreach ($tab as $msgid => $msgstr) {
+ $s->setCellValueByColumnAndRow(0, $j, $msgid);
+ $s->setCellValueByColumnAndRow(1, $j, $ref->traductions[$msgid]);
+ $s->setCellValueByColumnAndRow(2, $j, $msgstr);
+
+ if ($msgstr == '') {
+ $s->getStyleByColumnAndRow(2, $j)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
+ $s->getStyleByColumnAndRow(2, $j)->getFill()->getStartColor()->setARGB('FFFFFF00');
+ }
+ $j++;
+ }
+
+ $s->getColumnDimensionByColumn(0)->setAutoSize(true);
+ $s->getColumnDimensionByColumn(1)->setAutoSize(true);
+ $s->getColumnDimensionByColumn(2)->setAutoSize(true);
+
+ return $lang_name;
+ }
+
+ public static function getFonts() {
+ $formats = array('ttf', 'otf', 'TTF', 'OTF');
+
+ $dr = opendir(FONT_PATH);
+ $fonts = array('Arial (police système)' => "system");
+ while ($file = readdir($dr)) {
+ if ($file == '.' || $file == '..' || !in_array(files::getExtension($file), $formats)) {
+ continue;
+ }
+ $fonts[$file] = $file;
+ }
+ return $fonts;
+ }
+
+ protected static function getCharsets() {
+ $sets = cubeFlexFontAsset::getSets();
+ $res = array();
+ foreach ($sets as $k => $v) {
+ $res[$k] = $k;
+ }
+ return $res;
+ }
+
+ protected static function getNSISLangs() {
+ $res = array();
+ $dir = WS_FILES . '/nsislangs';
+ $dr = opendir($dir);
+ while ($file = readdir($dr)) {
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
+ $e = explode('.', $file);
+ $res[$e[0]] = $e[0];
+ }
+
+ ksort($res);
+ return $res;
+ }
+
+ public static function editor($args) {
+ commonDroits::min(1);
+
+ global $core;
+
+ $args = cubePage::getArgs($args);
+ $e = explode('_', $args[0]);
+ $book_id = $e[0];
+ $hash = isset($e[1]) ? $e[1] : '';
+
+
+ self::checkDocumentVersionOfBook($book_id);
+
+ if ($book_id == 'new') {
+ $dao = new wsDAOBook($core->con);
+ $book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang);
+ http::redirect(SITE_PATH . 'editor/' . $book->book_id . '_' . $book->hash);
+ }
+
+ $res = '<html><head><style type="text/css">';
+ $res .= '#composerSwf{width:100%;height:100%;margin:0 auto;}
+body{margin:0;padding:0;height:100%;overflow:hidden;background:#d2d3c7;}
+html{height:100%}' . "\n";
+ $res .= '</style>';
+ $res .= '<title>' . __('Edition de la publication') . ' #' . $args[0] . '</title>';
+ $res .= '</head>';
+ $res .= '<body onload="this.focus();">';
+ $res .= self::editComposition($book_id, $hash);
+ $res .= '</body>';
+ $res .= '</html>';
+ echo $res;
+ }
+
+ /**
+ * wsUrl::restoreLinks()
+ *
+ * @param mixed $args
+ * @return
+ */
+ public static function restoreLinks($args) {
+ commonDroits::min(1);
+
+ global $core;
+
+ $args = cubePage::getArgs($args);
+ $book_id = $args[0];
+
+ $dao = new wsDAODocument($core->con);
+ $updates = $dao->getLinksVersions($book_id);
+ krsort($updates);
+
+ $res = '<html><head>';
+ $res .= '<title>' . __('Restauration des liens de la publication') . ' #' . $args[0] . '</title>';
+ $res .= '</head>';
+ $res .= '<body onload="this.focus();">';
+ $res .= '<div id="restoreLinks">';
+ $res.='<div>';
+ $res.='<h2>' . __('Import') . '</h2>';
+ $res.='<div class="center">';
+ $res.='<form action="importLinksAsExcel/' . $book_id . '" method="post" enctype="multipart/form-data" class="notajax" id="importLinksAsExcel">';
+ $res.=__("Importer des liens à partir d'un fichier Excel") . ' : <input type="file" name="file" accept="*.xlsx" />';
+ $res.='<input type="submit" value="' . __('Importer') . '" />';
+ $res.='</form>';
+ $res.='</div>';
+ $res.='</div>';
+ $res.='<hr />';
+
+ $res.='<div id="linksOffset">';
+ $res.='<h2>' . __('Décalage de pages') . '</h2>';
+ $res.='<form action="offsetLinks/' . $book_id . '" method="post" id="offsetLinks">';
+ $offset = form::field('offset', 3, 5);
+ $from = form::field('from', 3, 5);
+ $res.=sprintf(__('Décaler les liens de %s pages à partir de la page %s'), $offset, $from) . '<br />';
+ $res.='<label>' . form::checkbox('internal', 1, true) . ' ' . __('Appliquer le décalages sur les numéros de pages dans les liens internes') . '</label><br />';
+ $res.='<input type="submit" value="' . __('Procéder au décalage') . '" />';
+ $res.='</form>';
+ $res.='</div>';
+ $res.='<hr />';
+
+ $res.='<h2>' . __('Réimporter les liens du fichier PDF') . '</h2>';
+ $res.='<a class="restoreLink" rel="' . $book_id . '/pdf" href="#">Restaurer</a>';
+ $res.='<hr />';
+
+ $res.='<h2>' . __('Historique') . '</h2>';
+ $res .= '<table class="liste" style="width:100%;min-width:0;">';
+ $res .= '<tr>';
+ $res .= '<th>' . __('Date') . '</th>';
+ $res .= '<th class="center">' . __('Liens') . '</th>';
+ $res .= '<th class="center">' . __('Règles') . '</th>';
+ $res.='<th class="center">' . __('Utilisateur') . '</th>';
+ $res.='<th class="center">' . __('Informations') . '</th>';
+ $res .= '<th class="min"></th>';
+ $res .= '<th class="min"></th>';
+ $res .= '</tr>';
+ $i = 0;
+ foreach ($updates as $time => $infos) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '>';
+ $res .= '<td>' . date('Y-m-d H:i:s', $time) . '</td>';
+ $res .= '<td class="center">' . $infos['links'] . '</td>';
+ $res .= '<td class="center">' . $infos['rulers'] . '</td>';
+ $res.='<td class="center">' . $infos['user'] . '</td>';
+ $res.='<td class="center">' . $infos['comments'] . '</td>';
+ $res .= '<td><a href="#" rel="' . $book_id . '/' . $time . '" class="restoreLink">' . __('Restaurer') . '</a></td>';
+ $res .= '<td><a href="' . SITE_PATH . 'exportLinksAsExcel/' . $book_id . '/' . $time . '">' . str_replace(' ', ' ', __('Export Excel')) . '</a></td>';
+ $res .= '</tr>';
+ $i++;
+ }
+
+ $res .= '</table>';
+ $res .= '</div>';
+ $res .= '</body>';
+ $res .= '</html>';
+
+ echo $res;
+ }
+
+ public static function exportLinksAsExcel($args) {
+ global $core;
+
+ cubePHP::neverStop();
+
+ $book_id = $args[1];
+ $time = $args[2];
+
+ $dao = new wsDAODocument($core->con);
+ $dao->getLinksAndRulers($book_id, $links, $rulers, $time);
+ $xls = $dao->getLinksAsExcel($links, $rulers);
+
+ ob_end_clean();
+ files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'));
+ cubeHTTP::forceDownload('links_' . $book_id . '_' . $time . '.xlsx', false);
+
+ $writer = new PHPExcel_Writer_Excel2007($xls);
+ $writer->save('php://output');
+
+ exit;
+ }
+
+ public static function editComposition($book_id, $hash) {
+
+ $fv = array(session_name() => session_id(),
+ 'book_id' => $book_id,
+ 'hash' => $hash,
+ 'url' => '/');
+
+ $mtime = filemtime(ROOT . '/swf/composer.swf');
+ return cubeMedia::flash2(WEBROOT . '/swf/composer.swf?junk=' . $mtime, '100%', '100%', $fv, 'composerSwf', 'swfPanel', 10, '#d2d3c7', '', 'false', 'noscale', 'normal', array(), false, true, false);
+ }
+
+ public static function stats($args) {
+ global $core;
+ $bid = (isset($args[1])) ? $args[1] : null;
+
+ list($bid, $hash) = explode('_', $bid);
+
+ $r = $core->con->select('SELECT * FROM books WHERE book_id=\'' . $core->con->escape($bid) . '\' AND hash=\'' . $core->con->escape($hash) . '\'');
+ if (!$r->count()) {
+ return;
+ }
+
+ $annee = (isset($args[2])) ? $args[2] : null;
+ $mois = (isset($args[3])) ? $args[3] : null;
+ return wsStats::display($bid . '_' . $hash, $annee, $mois);
+ }
+
+ public static function viewerp($args) {
+ commonDroits::min(5);
+
+ $args = cubePage::getArgs($args);
+
+
+ $e = explode('_', $args[0]);
+ if (count($e) == 2 || $e[2] < TIME - 10) {
+ $e[2] = TIME;
+ http::redirect(SITE_PATH . 'viewerp/' . implode('_', $e) . '/');
+ exit;
+ }
+
+ $book_id = $e[0];
+
+ self::checkDocumentVersionOfBook($book_id);
+
+ echo self::commonViewer($book_id, $e[1], true);
+ }
+
+ public static function vieweru($args) {
+ commonDroits::min(5);
+
+ $args = cubePage::getArgs($args);
+
+ $qs = '';
+ if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
+ $qs = '?' . $_SERVER['QUERY_STRING'];
+ }
+
+ $e = explode('_', $args[0]);
+ if (count($e) == 2 || $e[2] < TIME - 10) {
+ $e[2] = TIME;
+ http::redirect(SITE_PATH . 'vieweru/' . implode('_', $e) . '/' . $qs);
+ exit;
+ }
+
+ $book_id = $e[0];
+
+ self::checkDocumentVersionOfBook($book_id);
+
+ echo self::commonViewer($book_id, $e[1], false, 'default', true);
+ }
+
+ public static function viewerh($args) {
+ global $core;
+
+ $args = cubePage::getArgs($args);
+
+ $e = explode('_', $args[0]);
+
+ $book_id = $e[0];
+ $hash = $e[1];
+
+ $dao = new wsDAOBook($core->con);
+
+ $book = $dao->selectById($book_id);
+ if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {
+ commonDroits::error();
+ }
+
+ if (!wsDroits::admin()) {
+ if ($book->parametres->redirectDemo != '') {
+ http::redirect($book->parametres->redirectDemo);
+ exit;
+ }
+ if ($book->parametres->disableDemo) {
+ commonDroits::error();
+ }
+ }
+
+ $dao->compile($book_id, 'html5');
+ $time = self::getHTML5CacheTime($book_id);
+
+ if (count($e) == 2 || $e[2] != $time) {
+ $e[2] = $time;
+ http::redirect(SITE_PATH . 'viewerh/' . implode('_', $e) . '/index.html');
+ exit;
+ }
+
+ $book_id = $e[0];
+ $hash = $e[1];
+ self::commonHTML5Viewer($book_id, $hash);
+ }
+
+ public static function getHTML5CacheTime($book_id) {
+ $cacheFile = WS_BOOKS . '/html5/' . $book_id . '/cache.appcache';
+ if (file_exists($cacheFile)) {
+ return filemtime($cacheFile);
+ }
+ return TIME;
+ }
+
+ public static function viewerhu($args) {
+ global $core;
+
+ commonDroits::min(5);
+ $args = cubePage::getArgs($args);
+ if (!isset($args[1])) {
+ $args[1] = '';
+ }
+
+ $dao = new wsDAOBook($core->con);
+ $e = explode('_', $args[0]);
+ $dao->compile($e[0], 'html5');
+ $time = self::getHTML5CacheTime($e[0]);
+
+ if (count($e) == 2 || $e[2] != $time) {
+ $e[2] = $time;
+ http::redirect(SITE_PATH . 'viewerhu/' . implode('_', $e) . '/' . $args[1]);
+ exit;
+ }
+
+ $book_id = $e[0];
+ $hash = $e[1];
+ self::commonHTML5Viewer($book_id, $hash, 'u');
+ }
+
+ public static function viewerha($args) {
+ global $core;
+
+
+ $args = cubePage::getArgs($args);
+ if (!isset($args[1])) {
+ $args[1] = '';
+ }
+
+ $dao = new wsDAOBook($core->con);
+ $e = explode('_', $args[0]);
+ $dao->compileTemp($e[0], 'ha', WS_BOOKS . '/html5a/' . $e[0]);
+ $time = time();
+
+ if (count($e) == 2 || $e[2] < $time - 20) {
+ $e[2] = $time;
+ http::redirect(SITE_PATH . 'viewerha/' . implode('_', $e) . '/' . $args[1]);
+ exit;
+ }
+
+ $book_id = $e[0];
+ $hash = $e[1];
+ self::commonHTML5Viewer($book_id, $hash, 'a');
+ }
+
+ public static function viewerht($args) {
+ commonDroits::min(5);
+ $args = cubePage::getArgs($args);
+
+ $e = explode('_', $args[0]);
+ $dao->compile($e[0], 'html5');
+ $time = self::getHTML5CacheTime($e[0]);
+
+ if (count($e) == 2 || $e[2] != $time) {
+ $e[2] = $time;
+ http::redirect(SITE_PATH . 'viewerht/' . implode('_', $e) . '/');
+ exit;
+ }
+
+ $book_id = $e[0];
+ $hash = $e[1];
+ self::commonHTML5Viewer($book_id, $hash, 't');
+ }
+
+ public static function commonHTML5Viewer($book_id, $hash, $version = '') {
+ global $core;
+ self::checkDocumentVersionOfBook($book_id);
+
+ $dao = new wsDAOBook($core->con);
+
+ $dir = '';
+ if ($version == 'a') {
+ $version = '';
+ $dir = 'a';
+ }
+
+ $book = $dao->selectById($book_id);
+ if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {
+ commonDroits::error();
+ }
+
+ if (!wsDroits::admin()) {
+ if ($book->parametres->redirectDemo != '') {
+ http::redirect($book->parametres->redirectDemo);
+ exit;
+ }
+ if ($book->parametres->disableDemo) {
+ commonDroits::error();
+ }
+ }
+
+
+ echo file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html');
+ exit;
+ }
+
+ public static function viewer1($args) {
+ $args = cubePage::getArgs($args);
+
+ $wmode = isset($args[1]) ? $args[1] : '';
+
+ $e = explode('_', $args[0]);
+
+ $newurl = null;
+ if (count($e) == 2 || $e[2] < TIME - 10) {
+ $e[2] = TIME;
+ http::redirect(SITE_PATH . 'viewer1/' . implode('_', $e) . '/' . $wmode);
+ exit;
+ }
+
+ $book_id = $e[0];
+
+ $wmode = $wmode != '' ? $wmode : 'default';
+
+ echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl, '1');
+ }
+
+ public static function viewer($args) {
+ $args = cubePage::getArgs($args);
+
+
+ $qs = '';
+ if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
+ $qs = '?' . $_SERVER['QUERY_STRING'];
+ }
+
+ $e = explode('_', $args[0]);
+ $newurl = null;
+ if (count($e) == 2 || $e[2] < TIME - 10) {
+ $e[2] = TIME;
+ http::redirect(SITE_PATH . 'viewer/' . implode('_', $e) . '/' . $qs);
+ exit;
+ }
+
+ $book_id = $e[0];
+
+ $wmode = (isset($wmode) && $wmode != '') ? $wmode : 'default';
+
+ self::checkDocumentVersionOfBook($book_id);
+ wsSecureSWF::checkProtectedSWF();
+
+ echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl);
+ }
+
+ public static function commonViewer($book_id, $hash, $standalone = false, $wmode = 'default', $fps = false, $version = 2) {
+ if (!defined('MINIMIZE_JS')) {
+ define('MINIMIZE_JS', false);
+ }
+ if (!defined('MINIMIZE_CSS')) {
+ define('MINIMIZE_CSS', false);
+ }
+ if (!defined('JQUERY')) {
+ define('JQUERY', false);
+ }
+
+ global $core;
+ global $css;
+ global $js;
+ global $standard;
+ global $meta;
+ global $jsvar;
+
+ if ($version == 2) {
+ $flashVersion = '10.0.22';
+ } else {
+ $flashVersion = '8';
+ }
+
+ cubePage::swfobject(2);
+
+ $dao = new wsDAOBook($core->con);
+ $book = $dao->selectById($book_id);
+
+ if (!wsDroits::admin()) {
+ if ($book->parametres->redirectDemo != '') {
+ http::redirect($book->parametres->redirectDemo);
+ exit;
+ }
+ if ($book->parametres->disableDemo) {
+ commonDroits::error();
+ }
+ }
+
+ if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {
+ commonDroits::error();
+ }
+
+
+ if (is_null($core->user)) {
+ $dao->addDemoCount($book_id);
+ }
+
+ $dao->compile($book_id, (string) $version);
+
+ $daoTheme = new wsDAOTheme($core->con);
+ $theme = $daoTheme->selectById($book->theme, 'themes');
+
+ $webcompile = WEBROOT . '/fluidbook/compile/';
+
+ $standard = 'XHTML 1.0 Transitional';
+ $css = $js = array();
+ $css[] = $webcompile . 'style.css';
+ $fv = $_GET;
+ if ($standalone) {
+ $fv['base'] = $_SERVER['REQUEST_URI'];
+ }
+ if ($fps) {
+ $fv['monitoring'] = '1';
+ }
+
+ if ($version == 1) {
+ $fv['id'] = $book_id;
+ $fv['mail'] = '0';
+ $fv['onlineFlag'] = '1';
+ $fv['loaderColor'] = $theme->parametres->loadingBackColor;
+ }
+
+ $res = '<html>';
+ $res .= '<head>';
+ $res .= '<title>' . $book->parametres->title . '</title>';
+ $res.='<meta name="google" value="notranslate">';
+ $res.='<style type="text/css" media="print">*{ visibility: hidden; display: none }</style>';
+ // Entêtes Facebook
+ if ($book->parametres->facebook) {
+ $meta['og:title'] = ($book->parametres->facebook_title == '') ? $book->parametres->title : $book->parametres->facebook_title;
+ if ($book->parametres->facebook_description != '') {
+ $meta['og:description'] = $book->parametres->facebook_description;
+ }
+ $meta['og:image'] = 'http://workshop.fluidbook.com/services/facebook_thumbnail?id=' . $book->book_id . '&j=' . TIME;
+ }
+
+ $redirectPDF = 'window.location="data/document.pdf"';
+
+ if ($book->parametres->mobileVersion == 'pdf') {
+ $redirectMobile = $redirectPDF;
+ } else {
+ $redirectMobile = 'window.location="/viewerh/' . $book_id . '_' . $hash . '_' . TIME . '/";';
+ }
+
+ $alt = '<div style="width:734px;margin:100px auto;"><a href="http://get.adobe.com/flashplayer/" target="_blank">' . cubeMedia::image($webcompile . 'getflash.gif', 734, 409, '') . '</a></div>';
+
+ $res .= '</head>';
+ $res .= '<body style="background-color:#' . $theme->parametres->loadingBackColor . '" onload="this.focus();">';
+ $res .= '<div id="fluidbook"><div style="width:734px;margin:100px auto;"><a href="http://get.adobe.com/flashplayer/" target="_blank"></a></div></div>';
+ $res .= "\n" . '<script type="text/javascript">' . "\n";
+ $res.='if(isMobile()){' . "\n";
+ $res.="\t" . $redirectMobile . "\n";
+ $res.='} else if(isBadMobile()) {' . "\n";
+ $res.="\t" . $redirectPDF . "\n";
+ $res.='} else {' . "\n";
+ $res .= "\t" . 'swfobject.embedSWF("index.swf", "fluidbook", "100%", "100%", "' . $flashVersion . '",';
+ $res .= '"", ' . json_encode($fv) . ',';
+ $res .= '{"allowScriptAccess":"always","quality":"high","scale":"noscale","wmode":getWmode(),"allowFullScreen":"true","allowFullScreenInteractive":"true"},{"bgcolor":"#' . $theme->parametres->loadingBackColor . '"}';
+ $res .= ');' . "\n";
+ $res.='}' . "\n";
+ $res .= '</script>';
+ $js = array('fluidbook.js');
+ $jsvar = array();
+
+ $gacodes = array(GA);
+ if ($book->parametres->googleAnalytics != '') {
+ $gacodes[] = $book->parametres->googleAnalytics;
+ }
+ $res .= cubePage::googleAnalytics($gacodes, false);
+ $res .= '</body>';
+ $res .= '</html>';
+
+ return $res;
+ }
+
+ public static function statsxls($args) {
+ $bid = (isset($args[1])) ? $args[1] : null;
+ $annee = (isset($args[2])) ? $args[2] : null;
+ $mois = (isset($args[3])) ? $args[3] : null;
+ wsStats::exportXLS($bid, $annee, $mois);
+ }
+
+ public static function chooseExistingBook() {
+ wsDroits::creation(true);
+ $res = '<tr><td colspan="2"><p style="width:600px;text-align:justify;"><em>a' . __("Si votre nouvelle publication a des paramètres en commun avec une publication existante, veuillez rechercher cette publication afin d'attribuer par défaut à votre nouvelle publication les paramètres de l'existante") . '</em></p></td></tr>';
+ $res .= '<tr><td>' . __('Rechercher une publication') . ' : </td><td>' . form::field('book_nom', 64, 1024) . form::hidden('book', '') . '</td></tr>';
+ $res .= '<tr><td>' . __('Indiquez le titre de votre nouvelle publication') . '</td><td>' . form::field('title', 64, 1024) . '</td></tr>';
+ $res .= '<tr><td colspan="2"><label>' . form::checkbox('settings', '1', true, '', '', true, '') . __('Importer les paramètres de la publication') . '</td></tr>';
+ $res .= '<tr><td colspan="2"><label>' . form::checkbox('pages', '1', false) . __('Importer les pages et les liens') . '</td></tr>';
+ return $res;
+ }
+
+ public static function changeBookProprietaire($book_id) {
+ global $core;
+ commonDroits::min(3);
+
+ $dao = new wsDAOBook($core->con);
+ $book = $dao->selectById($book_id);
+
+ return self::_changeProprietaire($book->proprietaire);
+ }
+
+ public static function changeCollectionProprietaire($collection_id) {
+ global $core;
+ commonDroits::min(3);
+
+ $dao = new wsDAOCollection($core->con);
+ $collection = $dao->selectById($collection_id);
+
+ return self::_changeProprietaire($collection->proprietaire_nom);
+ }
+
+ protected static function _changeProprietaire($proprietaire) {
+ $res = '<tr><td>' . __('Propriétaire actuel') . ' : </td><td>' . $proprietaire . '</td></tr>';
+ $res .= '<tr><td>' . __('Rechercher un utilisateur') . ' : </td><td>' . form::field('book_proprietaire', 64, 1024) . form::hidden('proprietaire', '') . '</td></tr>';
+ return $res;
+ }
+
+ public static function chooseBookProject($book_id) {
+ global $core;
+
+ wsDroits::admin(true);
+
+ $dao = new wsDAOBook($core->con);
+ $book = $dao->selectById($book_id);
+
+ $projects = array("--" => '0');
+
+ $proprietaire = 'SELECT facturable_id FROM ws_users_tree WHERE utilisateur_id=\'' . $core->con->escape($book->proprietaire_id) . '\'';
+ $entreprise = 'SELECT entreprise FROM utilisateurs WHERE utilisateur_id IN (' . $proprietaire . ')';
+ $collegues = 'SELECT utilisateur_id FROM utilisateurs WHERE entreprise IN(' . $entreprise . ')';
+
+ $r = $core->con->select('SELECT * FROM projets WHERE client IN(' . $collegues . ') ORDER BY projet_id DESC');
+ while ($r->fetch()) {
+ $projects[$r->projet_id . ' - ' . $r->nom] = $r->projet_id;
+ }
+
+ $res = '<tr><td>' . __('Choisir un projet') . ' : </td><td>' . form::hidden('book_id', $book_id) . form::combo('book_project', $projects, $book->projet, 'hide_new_value') . '</td></tr>';
+ $res .= '<tr class="new"><td>' . __('ou créer un nouveau projet') . ' : </td><td>' . form::field('new_book_project_nom', 64, 1024, $book->nom) . '</td></tr>';
+ return $res;
+ }
+
+ public static function chooseBookTache($book_id, $projet_id) {
+ global $core;
+ wsDroits::admin(true);
+
+ $dao = new wsDAOBook($core->con);
+ $book = $dao->selectById($book_id);
+
+ $taches = array("--" => '0');
+ $r = $core->con->select('SELECT * FROM taches WHERE projet=\'' . $core->con->escape($projet_id) . '\' AND categorie=8');
+ while ($r->fetch()) {
+ $taches[$r->nom] = $r->tache_id;
+ }
+
+ $res = '';
+
+ if ($r->count() > 0) {
+ $res .= '<tr><td>' . __('Choisir une tâche') . ' : </td><td>' . form::hidden('book_id', $book_id) . form::hidden('projet_id', $projet_id) . form::combo('tache', $taches, '0', 'hide_new_value') . '</td></tr>';
+ $res .= '<tr class="new"><td>' . __('ou créer une nouvelle tâche') . ' : </td><td>' . form::field('nom', 32, 1024, 'Fluidbook #' . $book->book_id . ' : ' . $book->nom) . ' ' . __('ayant le budget suivant') . ' ' . form::field('budget', 6, 6) . '</td></tr>';
+ } else {
+ $res .= '<tr><td>' . __('Créer une tâche') . ' : </td><td>'
+ . form::hidden('book_id', $book_id)
+ . form::hidden('projet_id', $projet_id)
+ . form::hidden('tache', '0')
+ . form::field('nom', 32, 1024, 'Fluidbook #' . $book->book_id . ' : ' . $book->nom)
+ . ' ' . __('ayant le budget suivant')
+ . ' ' . form::field('budget', 6, 6) . '</td></tr>';
+ }
+
+ return $res;
+ }
+
+ public static function valideDownload() {
+ global $core;
+
+ $res = '<tr><td>' . __("Le téléchargement du fluidbook implique qu'il a été testé et définitivement validé.") . '<br />' . __("Si vous le téléchargez, il vous sera facturé selon les conditions stipulées dans votre contrat.") . '</td></tr>';
+ $res .= '<tr><td class="right"><label>' . __("Oui, ce fluidbook est validé, je souhaite le télécharger et il me sera facturé.") . ' ' . form::checkbox('valide', 1, false) . '</label></td></tr>';
+
+ return $res;
+ }
+
+ public static function formInstall($book, $server) {
+ if ($server == 'references') {
+ $s = __('Espace des références');
+ $dir = $book->dir_references;
+ } elseif ($server == 'hosting') {
+ $s = __("Serveur d'hébergement");
+ $dir = $book->dir_hosting;
+ } elseif ($server == 'macbook_phonegap_ios') {
+ $s = __("Projet Phonegap iOS");
+ $dir = $book->dir_macbook_phonegap_ios;
+ } elseif ($server == 'phonegap_android') {
+ $s = __("Projet Phonegap Android");
+ $dir = $book->dir_phonegap_android;
+ } elseif ($server == 'external') {
+ $s = __('Serveur FTP externe') . ' : ftp://';
+ $dir = $book->dir_external;
+ }
+
+ if ($dir == '') {
+ $dir = cubeText::str2URL($book->parametres->title);
+ }
+
+ $res = '<tr><td>' . __("Dossier d'installation") . '</td><td><em>' . $s . '</em> ' . form::field('dir', 60, 128, $dir) . '</td></tr>';
+ $res.='<tr><td colspan="2">' . __("A l'issue de l'installation, vous serez dirigé vers le serveur sur lequel la publication a été installée") . '</td></tr>';
+ return $res;
+ }
+
+ public static function testAS($args) {
+ global $core;
+ commonDroits::min(5);
+ if (!isset($args[1])) {
+ $args[1] = 2964;
+ }
+ self::checkDocumentVersionOfBook($args[1]);
+ wsSecureSWF::checkProtectedSWF();
+ cubePHP::neverStop();
+ $dao = new wsDAOBook($core->con);
+
+ header('Content-type: text/plain');
+ ob_end_clean();
+ echo $dao->compile($args[1], 3, false, true);
+ exit;
+ }
+
+ public static function testAIR($args) {
+ global $core;
+ commonDroits::min(5);
+ if (!isset($args[1])) {
+ $args[1] = 2964;
+ }
+ self::checkDocumentVersionOfBook($args[1]);
+ cubePHP::neverStop();
+ $dao = new wsDAOBook($core->con);
+
+ header('Content-type: text/plain');
+ ob_end_clean();
+ echo $dao->compileAIR($args[1]);
+ exit;
+ }
+
+ public static function testLinksCSV($args) {
+ global $core;
+ commonDroits::min(5);
+
+ $dao = new wsDAODocument($core->con);
+ header('Content-type: text/plain');
+ ob_clean();
+ echo $dao->putLinksFromCSV($args[1]);
+ }
+
+ protected static function checkDocumentVersionOfBook($book_id) {
+ global $core;
+ cubePHP::neverStop();
+ $daoBook = new wsDAOBook($core->con);
+
+
+ $toUpdate = $daoBook->getDocumentsToUpdate($book_id);
+ foreach ($toUpdate as $document_id) {
+ self::updateDocument($document_id);
+ }
+
+ if (count($toUpdate) > 0) {
+ $daoBook->setChaptersFromOldFluidbook($book_id);
+ $daoDoc = new wsDAODocument($core->con);
+ $daoDoc->setLinksFromOldFluidbook($book_id);
+ }
+
+ $daoBook->setVersion($book_id, 2);
+ }
+
+ public static function testOldLink($args) {
+ global $core;
+ $daoDoc = new wsDAODocument($core->con);
+ $daoDoc->setLinksFromOldFluidbook($args[1]);
+ }
+
+ protected static function updateDocument($document_id) {
+ global $core;
+
+ $dao = new wsDAODocument($core->con);
+ $doc = $dao->selectById($document_id);
+
+ $doc->copyOriginalFromOlderVersion();
+ $doc->globalOperations();
+
+ for ($i = 1; $i <= $doc->generalInfos['pages']; $i++) {
+ $doc->processOnePage($i);
+ }
+
+ $doc->version = 2;
+ $dao->updateFromObject($doc);
+ }
+
+ public static function testFontExtraction($args) {
+ $documentId = $args[1];
+
+ header('Content-type: text/plain');
+ ob_clean();
+
+
+
+ $extractor = new wsPDFFontExtractor(WS_DOCS . '/' . $documentId);
+ $extractor->extract();
+
+ exit;
+ }
+
+ public static function getParamsHelp($args) {
+ commonDroits::min(5);
+ global $core;
+
+ $res = '';
+
+ if (isset($args[1]) && $args[1] != '') {
+ $dao = new wsDAOBook($core->con);
+ $b = $dao->selectById($args[1]);
+
+ $daoTheme = new wsDAOTheme($core->con);
+ $t = $daoTheme->getThemeOfBook($args[1], true);
+
+ $book = $b->parametres;
+ $theme = $t->parametres;
+ } else {
+ $theme = new wsThemeParametres(new wsTheme());
+ $book = new wsBookParametres(new wsBook());
+ }
+
+ $res = commonPage::barre();
+ $res .= commonPage::tMain();
+ $res.=commonPage::bh();
+ $res.='<table class="liste">';
+ $res.= self::formatHelp($theme->getHelp());
+ $res.='</table>';
+ $res.=commonPage::bf();
+ $res.=commonPage::bh();
+ $res.='<table class="liste">';
+ $res.= self::formatHelp($book->getHelp());
+ $res.='</table>';
+ $res.=commonPage::bf();
+ $res .= commonPage::bMain();
+
+ return $res;
+ }
+
+ public static function formatHelp($rubriques) {
+ commonDroits::min(5);
+
+ $res = '';
+ foreach ($rubriques as $label => $fields) {
+ $res.='<tr class="odd"><th colspan="5">' . $label . '</th></tr>';
+ foreach ($fields as $name => $t) {
+ if (is_string($t) && $t == '|') {
+ $res .= '<tr class="odd"><th></th></tr>';
+ } else {
+ $res.= '<tr>';
+ foreach ($t as $tt) {
+ $res.='<td>' . $tt . '</td>';
+ }
+ $res.='</tr>';
+ }
+ }
+ }
+ return $res;
+ }
+
+ public static function clients($args) {
+ global $core;
+ cubePage::truePopup();
+ cubePage::autoComplete();
+ cubePage::emptyfield();
+ commonDroits::min(3);
+ $settings = $core->user->getSettings('clients_ws');
+
+ $shortcuts = array();
+ $shortcuts[] = '<a href="#" class="popup" rel="formClient/new">' . $core->typo->Ajouter('Créer un nouveau client') . '</a>';
+
+ $filtres = array();
+ if (wsDroits::admin()) {
+ $filtres[] = new commonFiltre(__('Grade'), 'ws_grade', $settings['filtres']);
+ $filtres[] = new commonFiltre(__('Administrateur'), 'admin_client', $settings['filtres']);
+ }
+
+ $res = commonPage::barre($filtres, 'filtreClients', 'clients', $shortcuts);
+ $res .= commonPage::tMain();
+ $res .= commonPage::bh();
+ $res .= '<div id="listeClients">';
+ $res .= self::listeClients();
+ $res .= '</div>';
+ $res .= commonPage::bf();
+ $res .= commonPage::bMain();
+ return $res;
+ }
+
+ public static function listeClients($dashboard = null, $settings = null) {
+ global $core;
+ commonDroits::min(3);
+ $settings = is_null($settings) ? $core->user->getSettings('clients_ws') : $settings;
+ $change = is_null($dashboard) ? 'Client' : 'Dashboard/' . $dashboard;
+ $dao = new commonDAOEntreprise($core->con);
+ if (isset($settings['search']) && !is_null($settings['search'])) {
+ $dao->setSearch($settings['search']);
+ }
+ $dao->setFiltres($settings['filtres']);
+
+ $admin = wsDroits::admin();
+
+ if ($admin) {
+ $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], null, 'entreprises_ws');
+ } else {
+ $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user, 'entreprises_ws');
+ }
+
+ $res = '<table class="liste">';
+ $res .= '<tr><th>' . commonUrl::orderby('#', 'entreprise_id', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Raison sociale'), 'nom', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . __('Contacts') . '</th>';
+ if ($admin) {
+ $res .= '<th>' . commonUrl::orderby(__('Grade'), 'ws_grade', $settings, 'sort', $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Revendeur'), 'revendeur', $settings, 'sort', $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Administrateur'), 'administrateur', $settings, 'sort', $change) . '</th>';
+ }
+ $res .= '<th class="min"></th><th class="min"></th></tr>';
+ $i = 0;
+ foreach ($liste as $id => $client) {
+ if (!is_array($client->contacts)) {
+ $client->contacts = array();
+ }
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '>';
+ $res .= '<td>' . $client->entreprise_id . '</td>';
+ $res .= '<td>' . $client->nom . '</td>';
+ $contacts = array();
+
+ foreach ($client->contacts as $c) {
+ $contacts[] = '<a href="#" class="popup" rel="formContact/' . $c->utilisateur_id . '">' . $c->prenom . ' ' . $c->nom . '</a>';
+ }
+
+ $res .= '<td id="contacts_' . $client->entreprise_id . '">' . implode(', ', $contacts) . '</td>';
+
+ if ($admin) {
+ $rev = $client->ws_revendeur == '' ? '-' : $client->ws_revendeur;
+ $adm = $client->ws_administrateur == '' ? '-' : $client->ws_administrateur;
+
+ if ($client->ws_grade == 0) {
+ $rev = $adm = '-';
+ }
+
+ $res .= '<td>' . $core->ws_grades[$client->ws_grade] . '</td>';
+ $res .= '<td>' . $rev . '</td>';
+ $res .= '<td>' . $adm . '</td>';
+ }
+
+ $res .= '<td class="nowrap">';
+ $res .= '</td>';
+ $res .= '<td class="action"><a href="#" class="popup" rel="formClient/' . $client->entreprise_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+ $res .= '</tr>';
+ $i++;
+ }
+ if (!isset($settings['search']) || is_null($settings['search'])) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '><td colspan="10">';
+ if ($admin) {
+ $res .= commonPage::pager($settings['page'], $dao->count(null, 'entreprises_ws'), $settings['par_page'], 'page' . $change . '/%d');
+ } else {
+ $res .= commonPage::pager($settings['page'], $dao->count($core->user, 'entreprises_ws'), $settings['par_page'], 'page' . $change . '/%d');
+ }
+ $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('clients'));
+ $res .= '</td></tr>';
+ }
+ $res .= '</table>';
+ return $res;
+ }
+
+ public static function formClient($entreprise_id = 'new') {
+ global $core;
+ commonDroits::min(3);
+ $dao = new commonDAOEntreprise($core->con);
+ $daoUtilisateur = new commonDAOUtilisateur($core->con);
+ if ($entreprise_id == 'new') {
+ $client = $dao->cree();
+ } else {
+ $client = $dao->selectById($entreprise_id);
+ }
+
+ $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('entreprise_id', $client->entreprise_id) . '' . $client->entreprise_id . '</td></tr>';
+ $res .= '<tr><td>' . __('Raison sociale') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';
+ $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';
+ $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';
+ $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';
+ $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';
+ $res .= '<tr><td>' . __('Site internet') . '</td><td>' . form::field('site', 30, 128, $client->site) . '</td></tr>';
+ if (wsDroits::admin(false)) {
+ $res .= '<tr><td>' . __('Adresse de facturation') . '</td><td>' . form::textarea('adresse_facturation', 40, 3, $client->adresse_facturation) . '</td></tr>';
+ $res .= '<tr><td>' . __('Numéro de TVA intracommunautaire') . '</td><td>' . form::field('tva_intra', 15, 13, $client->tva_intra) . '</td></tr>';
+ }
+ // Bloc Fluidbook Workshop
+ if (wsDroits::admin(false)) {
+ $res .= '<tr class="light"><th colspan="2" class="light"><strong>' . __('Fluidbook Workshop') . '</strong></th></tr>';
+ $res .= '<tr class="odd"><td>' . __('Grade') . '</td><td>' . form::combo('ws_grade', array_flip($core->ws_grades), $client->ws_grade) . '</td></tr>';
+ if ($entreprise_id == 'new' || !$client->ws_admin) {
+ $class = 'empty-field';
+ $default_id = '';
+ $default = __("Entrez le nom du revendeur ou de l'administrateur");
+ } else {
+ $class = '';
+ $default_id = $client->ws_admin;
+ $wsa = $daoUtilisateur->selectById($client->ws_admin, 'utilisateurs_entreprise');
+ $default = $wsa->utilisateur_id . ' - ' . $wsa->rs . ' (' . $wsa->prenom . ' ' . $wsa->nom . ')';
+ }
+
+ $d = $dao->getWSDatas($entreprise_id);
+
+ $res .= '<tr class="odd"><td>' . __('Revendeur / Administrateur') . '</td><td>' . form::field('ws_admin_nom', 60, 128, $default, $class) . form::hidden('ws_admin', $default_id) . '</td></tr>';
+ if (!is_null($d)) {
+ $res .= '<tr class="odd"><td>' . __('Entité facturable') . '</td><td>' . $d->facturable->prenom . ' ' . $d->facturable->nom . ' (' . $d->facturable->rs . ')</td></tr>';
+ $res .= '<tr class="odd"><td>' . __('Administrateur responsable') . '</td><td>' . $d->administrateur->prenom . ' ' . $d->administrateur->nom . ' (' . $d->administrateur->rs . ')</td></tr>';
+ }
+
+ $daoSignature = new wsDAOSignature($core->con);
+ $signaturesList = $daoSignature->selectAll();
+
+ $signatures = array();
+ foreach ($signaturesList as $s) {
+ $signatures[$s->nom] = $s->signature_id;
+ }
+
+ $res .= '<tr class="odd"><td>' . __('Signatures Fluidbook') . '</td><td>' . cubeForm::checkMultiple('ws_signatures', $signatures, 5, explode(',', $client->ws_signatures)) . '</td></tr>';
+ }
+ if ($entreprise_id == 'new') {
+ $daoContact = new commonDAOClient($core->con);
+ $contact = $daoContact->cree();
+ $res .= '<tr><th colspan="2" class="light"><strong>' . __('Contact') . '</strong></th></tr>';
+ $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field(array('contact[email]'), 30, 128, $contact->email) . '</td></tr>';
+ $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field(array('contact[password]'), 30, 128, $contact->password) . '</td></tr>';
+ $res .= '<tr><td>' . __('Prénom') . '</td><td>' . form::field(array('contact[prenom]'), 30, 128, $contact->prenom) . '</td></tr>';
+ $res .= '<tr><td>' . __('Nom') . '</td><td>' . form::field(array('contact[nom]'), 30, 128, $contact->nom) . '</td></tr>';
+ $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field(array('contact[telephone]'), 20, 128, $contact->telephone) . '</td></tr>';
+ $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field(array('contact[mobile]'), 20, 128, $contact->mobile) . '</td></tr>';
+ $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field(array('contact[fax]'), 20, 128, $contact->fax) . '</td></tr>';
+ $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo(array('contact[lang]'), cubeLang::getAvailableLangs(true), $contact->lang) . '</td></tr>';
+ }
+ return $res;
+ }
+
+ public static function listeContacts($entreprise_id) {
+ global $core;
+ commonDroits::min(3);
+ $dao = new commonDAOEntreprise($core->con);
+ $contacts = $dao->getContacts($entreprise_id);
+
+ $res = '<table class="liste light">';
+ $res .= '<tr class="light"><th colspan="4"><a href="" class="popup" rel="formContact/new/' . $entreprise_id . '">' . $core->typo->Contact('Ajouter un contact') . '</a></th></tr>';
+ $i = 0;
+ foreach ($contacts as $contact) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '><td>' . trim($contact->prenom . ' ' . $contact->nom) . '</td>';
+ $res .= '<td><a href="mailto:' . trim($contact->prenom . ' ' . $contact->nom) . '<' . $contact->email . '>">' . $contact->email . '</a></td>';
+ $res .= '<td class="min"><a href="' . SITE_PATH . 'fichiers/' . $contact->utilisateur_id . '">FTP</a></td>';
+ $res .= '<td><a class="ajax" href="#" rel="connectAs/' . $contact->utilisateur_id . '">Se connecter comme ...</a></td>';
+ $res .= '<td class="right"><a href="#" rel="formContact/' . $contact->utilisateur_id . '" class="popup">' . cubeMedia::image(IMG . '/edit.png') . '</a></td></tr>';
+ $i++;
+ }
+ $res .= '</table>';
+ return $res;
+ }
+
+ public static function formCollection($collection_id = 'new') {
+ global $core;
+ commonDroits::min(3);
+ $dao = new wsDAOCollection($core->con);
+ if ($collection_id != 'new') {
+ $collection = $dao->selectById($collection_id);
+ } else {
+ $collection = $dao->cree();
+ }
+
+ $res.='<tr><td>#</td><td>' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '</td></tr>';
+ $res .= '<tr><td>Nom de la collection</td><td>' . form::field('nom', 20, 64, $collection->nom) . '</td></tr>';
+ return $res;
+ }
+
+ public static function formContact($client_id = 'new', $entreprise_id = null) {
+ global $core;
+ commonDroits::min(3);
+
+ $dao = new commonDAOClient($core->con);
+ if ($client_id == 'new') {
+ $client = $dao->creeFromEntreprise($entreprise_id);
+ } else {
+ $client = $dao->selectById($client_id);
+ }
+
+ $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('grade', 0) . form::hidden('entreprise', $client->entreprise) . form::hidden('utilisateur_id', $client->utilisateur_id) . '' . $client->utilisateur_id . '</td></tr>';
+ $res .= '<tr><td>' . __('Login activé') . '</td><td>' . form::hidden('enabled', 0) . form::checkbox('enabled', 1, $client->enabled) . '</td></tr>';
+ $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field('email', 30, 128, $client->email) . '</td></tr>';
+ $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field('password', 30, 128, $client->password) . '</td></tr>';
+ $res .= '<tr><td>' . __('Prénom du contact') . '</td><td>' . form::field('prenom', 30, 128, $client->prenom) . '</td></tr>';
+ $res .= '<tr><td>' . __('Nom du contact') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';
+ $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';
+ $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';
+ $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';
+ $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';
+ $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field('telephone', 20, 128, $client->telephone) . '</td></tr>';
+ $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field('mobile', 20, 128, $client->mobile) . '</td></tr>';
+ $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field('fax', 20, 128, $client->fax) . '</td></tr>';
+ $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo('lang', cubeLang::getAvailableLangs(true), $client->lang) . '</td></tr>';
+ if ($client_id != 'new') {
+ $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
+ $res .= '<tr><td></td><td><a href="' . SITE_PATH . 'fichiers/' . $client->utilisateur_id . '">' . __('FTP') . '</a></td></tr>';
+ $res .= '<tr><td></td><td><a href="#" class="ajax" rel="connectAs/' . $client->utilisateur_id . '">' . __('Se connecter comme ...') . '</a></td></tr>';
+ $res .= '<tr><td>' . __("Paramètres de connexion au Fluidbook Workshop") . '</td><td>' . __('Adresse') . ' : http://' . $_SERVER['HTTP_HOST'] . '/<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . $client->password . '</td></tr>';
+ $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
+ }
+ return $res;
+ }
+
+ public static function demandes() {
+ global $core;
+ cubePage::truePopup();
+ cubePage::autoComplete();
+ cubePage::emptyfield();
+ commonDroits::min(5);
+ $settings = $core->user->getSettings('demandes');
+
+ $shortcuts = array();
+
+ $filtres = array();
+ $filtres[] = new commonFiltre(__('Statut'), 'status_demande', $settings['filtres']);
+ $filtres[] = new commonFiltre(__('Confiées à'), 'demande_moi', $settings['filtres']);
+
+ $res = commonPage::barre($filtres, 'filtreDemandes', 'demandes', $shortcuts);
+ $res .= commonPage::tMain();
+ $res .= commonPage::bh();
+ $res .= '<div id="listeDemandes">';
+ $res .= self::listeDemandes();
+ $res .= '</div>';
+ $res .= commonPage::bf();
+ $res .= commonPage::bMain();
+ return $res;
+ }
+
+ public static function listeDemandes($dashboard = null, $settings = null) {
+ global $core;
+ commonDroits::min(5);
+ $settings = is_null($settings) ? $core->user->getSettings('demandes') : $settings;
+ $change = is_null($dashboard) ? 'Demandes' : 'Dashboard/' . $dashboard;
+ $dao = new wsDAODemande($core->con);
+ if (isset($settings['search']) && !is_null($settings['search'])) {
+ $dao->setSearch($settings['search']);
+ }
+ $dao->setFiltres($settings['filtres']);
+ $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user);
+
+ $res = '<table class="liste">';
+ $res .= '<tr><th>' . commonUrl::orderby('#', 'demande_id', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Date'), 'date', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Type'), 'type', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Prospect') . '/' . __('Client'), 'utilisateur_nom', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Confiée à'), 'revendeur_nom', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Gérée par'), 'administrateur_nom', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th>' . commonUrl::orderby(__('Statut'), 'status', $settings, 'sort' . $change) . '</th>';
+ $res .= '<th class="min"></th><th class="min"></th></tr>';
+ $i = 0;
+ foreach ($liste as $id => $demande) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '>';
+ $res .= '<td>' . $demande->demande_id . '</td>';
+ $res .= '<td>' . date(__('d/m/Y H:i'), $demande->date) . '</td>';
+ $res .= '<td>' . $core->demandes_type[$demande->type] . '</td>';
+ $res .= '<td><a href="#" class="popup" rel="formClient/' . $demande->entreprise . '">' . $demande->utilisateur_nom . '</a></td>';
+ $revendeur = $demande->revendeur == 0 ? '-' : $demande->revendeur_nom;
+ $res .= '<td>' . $revendeur . '</td>';
+ $administrateur = $demande->administrateur == 0 ? '-' : $demande->administrateur_nom;
+ $res .= '<td>' . $administrateur . '</td>';
+ // Affichage du status
+ // Si non traitée ou traitée, pas la possibilité de changer le status
+ if ($demande->status == 0 || $demande->status == 2) {
+ $res .= '<td>' . $core->demandes_status[$demande->status] . '</td>';
+ } else if ($demande->status == 1) {
+ if ($demande->revendeur == $core->user->utilisateur_id) {
+ $res .= '<td><a href="#" class="ajax" rel="reponseDemande/' . $demande->demande_id . '/' . $demande->revendeur . '/1/1">' . __('Je me suis chargé de cette demande') . '</a></td>';
+ } else {
+ $res .= '<td>' . $core->demandes_status[$demande->status] . ' (<a href="#" class="ajax" rel="resetDemande/' . $demande->demande_id . '" title="' . __('Réinitialiser la demande') . '">x</a>)</td>';
+ }
+ }
+ // On ne peut éditer que si la facture est non traitée et qu'elle n'a pas commencé à être éditée par un autre administrateur
+ if (($demande->administrateur == 0 || $demande->administrateur == $core->user->utilisateur_id) && $demande->status == 0) {
+ $res .= '<td class="action"><a href="#" class="popup" rel="formDemande/' . $demande->demande_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+ } else {
+ $res .= '<td></td>';
+ }
+ // On n'affiche le bouton "Supprimer" que si la demande est non-traitée
+ if (($demande->administrateur == 0 || $demande->administrateur == $core->user->utilisateur_id) && $demande->status == 0) {
+ $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeDemande/' . $demande->demande_id . '" title="' . __('Êtes-vous certain de vouloir supprimer cette demande ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
+ } else {
+ $res .= '<td></td>';
+ }
+ $res .= '</tr>';
+ $i++;
+ }
+ if (!isset($settings['search']) || is_null($settings['search'])) {
+ $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+ $res .= '<tr' . $odd . '><td colspan="10">';
+ $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d');
+ $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('demandes'));
+ $res .= '</td></tr>';
+ }
+ $res .= '</table>';
+ return $res;
+ }
+
+ public static function formDemande($demande_id = 'new') {
+ global $core;
+ commonDroits::min(5);
+ $dao = new wsDAODemande($core->con);
+ $demande = $dao->selectById($demande_id);
+
+ if ($demande->administrateur != 0 && $demande->administrateur != $core->user->utilisateur_id) {
+ $action = __("Cette demande est actuellement en cours d'édition par un autre administrateur");
+ } elseif ($demande->status > 1) {
+ $action = __("Cette demande est actuellement en cours de traitement");
+ } else {
+ $action = '<a href="#" rel="lockDemande/' . $demande->demande_id . '" class="ajax">' . __("Cliquez-ici pour effectuer une action") . '</a>';
+ }
+
+
+ $res = '<tr><td>' . __('Numéro de demande') . '</td><td>' . form::hidden('demande_id', $demande->demande_id) . '' . $demande->demande_id . '</td></tr>';
+ $res .= '<tr><td>' . __('Date de la demande') . '</td><td>' . date(__('d/m/Y H:i'), $demande->date) . '</td></tr>';
+ $res .= '<tr><td>' . __('Emetteur de la demande') . '</td><td><a href="#" class="popup" rel="formClient/' . $demande->entreprise . '">' . $demande->utilisateur_nom . '</a></td></tr>';
+ $res .= '<tr><td>' . __('Nombre de pages') . '</td><td>' . $demande->pages . '</td></tr>';
+ $res .= '<tr><td>' . __('Nombre de liens') . '</td><td>' . $demande->liens . '</td></tr>';
+ $res .= '<tr><td>' . __('Nombre de langues') . '</td><td>' . $demande->langues . '</td></tr>';
+ $res .= '<tr><td>' . __('Détails') . '</td><td>' . $demande->details . '</td></tr>';
+ $res .= '<tr><td>' . __('Action') . '</td><td><div id="actionDemande">' . $action . '</div></td></tr>';
+ $res .= '<tr><td></td></tr>';
+
+ return $res;
+ }
+
+ public static function reponseDemande($args) {
+ global $core;
+
+ commonDroits::min(3);
+
+
+ $demande_id = $args[1];
+ $revendeur_id = $args[2];
+
+ $dao = new wsDAODemande($core->con);
+ $demande = $dao->selectById($demande_id);
+
+ $res = commonPage::barre();
+ $res .= commonPage::tMain();
+ $res .= commonPage::bh();
+ $res .= '<div id="accepteDemandes">';
+ $res .= '<h1>' . __('Prendre en charge une demande de devis') . '</h1>';
+ $res .= '<br /><br />';
+
+ if ($demande->revendeur != $revendeur_id || $demande->revendeur != $core->user->utilisateur_id || $demande->status == 0) {
+ $res.='<p class="center">' . __('Cette demande de devis ne vous est pas adressée.') . '</p>';
+ } else if ($demande->status == 2) {
+ $res.='<p class="center">' . __('Merci ! Nous avons bien pris en compte votre réponse.') . '<br /><br />';
+ $res.='<a href="' . $dao->getMailto($demande_id) . '">' . __("Ouvrir l'email de réponse") . '</a>';
+ $res.='</p>';
+ } else {
+ $res .= '<p>' . __('Si vous acceptez de traiter la demande suivante, veuillez cliquer sur le bouton "Accepter la demande" situé à droite de la description.');
+ $res .= ' ' . __('Vous avez également la possibilité de décliner la demande en cliquant sur le bouton "Décliner la demande"') . "</p>";
+ $res .= '<br /><br />';
+
+ $res .= '<table>';
+ $res .= '<tr><th class="left" colspan="2">' . __("Détails de la demande") . '</th><th class="left" style="width:40%">' . __('Votre action') . '</th></tr>';
+ $res .= '<tr><td>' . __('Numéro de demande') . '</td><td>' . $demande->demande_id . '</td>';
+ $res .= '<td>' . '<a href="#" class="ajax download btbook" rel="reponseDemande/' . $demande_id . '/' . $revendeur_id . '/1" ><div></div><span>' . __('Accepter la demande') . '</span></a>' . '</td></tr>';
+ $res .= '<tr><td>' . __('Date de la demande') . '</td><td>' . date(__('d/m/Y H:i'), $demande->date) . '</td></tr>';
+ $res .= '</tr>';
+ $res .= '<tr><td>' . __('Client') . ' / ' . __('Prospect') . '</td><td><a href="#" class="popup" rel="formClient/' . $demande->entreprise . '">' . $demande->utilisateur_nom . '</a></td></tr>';
+ $res .= '<tr><td>' . __('Nombre de pages') . '</td><td>' . $demande->pages . '</td>';
+ $res .= '<td>' . '<a href="#" class="ajax suppr btbook" rel="reponseDemande/' . $demande_id . '/' . $revendeur_id . '/0"><div></div><span>' . __('Décliner la demande') . '</span></a>' . '</td>';
+ $res .='</tr>';
+ $res .= '<tr><td>' . __('Nombre de liens') . '</td><td>' . $demande->liens . '</td></tr>';
+ $res .= '<tr><td>' . __('Nombre de langues') . '</td><td>' . $demande->langues . '</td></tr>';
+ $res .= '<tr><td>' . __('Détails') . '</td><td>' . $demande->details . '</td></tr>';
+ $res .= '</table>';
+ }
+
+ $res .= '</div>';
+ $res .= commonPage::bf();
+ $res .= commonPage::bMain();
+ return $res;
+ }
+
+}
+
?>
\ No newline at end of file