From: vincent@cubedesigners.com Date: Wed, 25 May 2011 13:59:22 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e376eef1ff2c7cdb167539716086c00947ddf05a;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 133f72d17..c9ccd20f0 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -1,8 +1,8 @@ con); // Creation de l'entreprise @@ -47,8 +45,7 @@ class wsAjax extends cubeAjax { $daoClient = new commonDAOClient($core->con); try { $daoClient->sauve($data); - } - catch(exception $e) { + } catch (exception $e) { $dao->supprime($entreprise->entreprise_id); } } @@ -59,8 +56,7 @@ class wsAjax extends cubeAjax { $x->addClosePopup(); } - public static function saveContact($args, &$x) - { + public static function saveContact($args, &$x) { global $core; $dao = new commonDAOClient($core->con); $client = $dao->sauve($_POST); @@ -70,7 +66,7 @@ class wsAjax extends cubeAjax { $x->addContent('listeContacts', wsUrl::listeContacts($client->entreprise)); $contacts = array(); $client_contacts = $dao->getContactsOfEntreprise($client->entreprise); - foreach($client_contacts as $c) { + foreach ($client_contacts as $c) { $contacts[] = '' . $c->prenom . ' ' . $c->nom . ''; } @@ -80,8 +76,7 @@ class wsAjax extends cubeAjax { $x->addPopupDimensions(); } - public static function supprimeClient($args, &$x) - { + public static function supprimeClient($args, &$x) { global $core; $dao = new commonDAOEntreprise($core->con); @@ -92,31 +87,26 @@ class wsAjax extends cubeAjax { $x->addContent('listeClients', wsUrl::listeClients()); } - public static function searchClients($args, &$x) - { + public static function searchClients($args, &$x) { $x->addContent('listeClients', wsUrl::listeClients()); } - public static function sortClient($args, &$x) - { + public static function sortClient($args, &$x) { commonAjax::sort('clients_ws', $args[1]); $x->addContent('listeClients', wsUrl::listeClients()); } - public static function pageClient($args, &$x) - { + public static function pageClient($args, &$x) { commonAjax::page('clients_ws', $args[1]); $x->addContent('listeClients', wsUrl::listeClients()); } - public static function parPageClient($args, &$x) - { + public static function parPageClient($args, &$x) { commonAjax::parPage('clients_ws', $_POST['par_page']); $x->addContent('listeClients', wsUrl::listeClients()); } - public static function filtreClients($args, &$x) - { + public static function filtreClients($args, &$x) { if (isset($args[1]) && $args[1] == 'efface') { commonAjax::filtre('clients_ws'); $x->addReload(); @@ -127,49 +117,41 @@ class wsAjax extends cubeAjax { } } - public static function supprimeBook($args, &$x) - { + public static function supprimeBook($args, &$x) { global $core; $dao = new wsDAOBook($core->con); $dao->supprime($args[1]); $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function searchPublications($args, &$x) - { + public static function searchPublications($args, &$x) { $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function pageBooks($args, &$x) - { + public static function pageBooks($args, &$x) { commonAjax::page('books', $args[1]); $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function parPageBooks($args, &$x) - { + public static function parPageBooks($args, &$x) { commonAjax::parPage('books', $_POST['par_page']); $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function sortBooks($args, &$x) - { + public static function sortBooks($args, &$x) { commonAjax::sort('books', $args[1]); $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function newBookForm($args, &$x) - { + public static function newBookForm($args, &$x) { commonAjax::form('newBook', __("Créer une nouvelle publication à partir d'une existante"), wsUrl::chooseExistingBook(), __('Créer une nouvelle publication'), 3); } - public static function formChangeBookProprietaire($args, &$x) - { + public static function formChangeBookProprietaire($args, &$x) { commonAjax::form('changeBookProprietaire/' . $args[1], __("Modifier le propriétaire de la publication"), wsUrl::changeBookProprietaire($args[1]), __('Enregistrer'), 3); } - public static function filtreBooks($args, &$x) - { + public static function filtreBooks($args, &$x) { if (isset($args[1]) && $args[1] == 'efface') { commonAjax::filtre('books'); $x->addReload(); @@ -180,8 +162,7 @@ class wsAjax extends cubeAjax { } } - public static function newBook($args, &$x) - { + public static function newBook($args, &$x) { global $core; $dao = new wsDAOBook($core->con); if ($_POST['book'] != '') { @@ -195,8 +176,7 @@ class wsAjax extends cubeAjax { $x->addTruePopup(SITE_PATH . 'editor/' . $book->book_id); } - public static function changeBookProprietaire($args, &$x) - { + public static function changeBookProprietaire($args, &$x) { global $core; if ($_POST['proprietaire'] == '') { $x->addError('book_proprietaire'); @@ -209,8 +189,7 @@ class wsAjax extends cubeAjax { $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function downbook($args, &$x) - { + public static function downbook($args, &$x) { global $core; $book_id = $args[1]; $version = $args[2]; @@ -228,10 +207,7 @@ class wsAjax extends cubeAjax { if (!wsDroits::admin()) { if ($book->status < 1) { - $popup = commonAjax::form('downbook/' . $book_id . '/' . $version, - __('Téléchargement du Fluidbook'), - wsUrl::valideDownload($book_id, $version), - __('Télécharger'), 2, '', '', true); + $popup = commonAjax::form('downbook/' . $book_id . '/' . $version, __('Téléchargement du Fluidbook'), wsUrl::valideDownload($book_id, $version), __('Télécharger'), 2, '', '', true); $x->addOpenPopup($popup); return; @@ -242,8 +218,7 @@ class wsAjax extends cubeAjax { $x->addRedirection($url); } - public static function statusBook($args, &$x) - { + public static function statusBook($args, &$x) { global $core; $book_id = $args[1]; @@ -259,13 +234,11 @@ class wsAjax extends cubeAjax { $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function formBookChooseProject($book_id) - { + public static function formBookChooseProject($book_id) { return commonAjax::form('bookChooseProject', __("Selection d'un projet"), wsUrl::chooseBookProject($book_id), __('Suivant'), 3, '', '', true); } - public static function bookChooseProject($args, &$x) - { + public static function bookChooseProject($args, &$x) { global $core; $book_id = $_POST['book_id']; @@ -296,13 +269,11 @@ class wsAjax extends cubeAjax { $x->addChangePopup(self::formBookChooseTache($book_id, $project)); } - public static function formBookChooseTache($book_id, $project) - { + public static function formBookChooseTache($book_id, $project) { return commonAjax::form('bookChooseTache', __("Selection d'une tâche"), wsUrl::chooseBookTache($book_id, $project), __('Enregistrer'), 3, '', '', true); } - public static function bookChooseTache($args, &$x) - { + public static function bookChooseTache($args, &$x) { global $core; $book_id = $_POST['book_id']; @@ -349,13 +320,11 @@ class wsAjax extends cubeAjax { $x->addContent('listeBooks', wsUrl::listeBooks()); } - public static function changeLang($args, &$x) - { + public static function changeLang($args, &$x) { $x->addContent('formLang', wsUrl::formLang($_POST['lang'])); } - public static function saveLang($args, &$x) - { + public static function saveLang($args, &$x) { global $core; $dao = new wsDAOLang($core->con); $data['lang_id'] = $_POST['lang']; @@ -367,8 +336,7 @@ class wsAjax extends cubeAjax { $x->addAlert(__('Paramètres de la langue et traductions enregistrées')); } - public static function demandeDevis($args, &$x) - { + public static function demandeDevis($args, &$x) { global $core; if (!self::valideDemandeDevis($x)) { return; @@ -452,7 +420,7 @@ class wsAjax extends cubeAjax { $mail->to = FROM_EMAIL; $mail->subject = '[' . EMAIL_SUBJECT . '] Demande de devis'; $body = 'Une demande de devis a été envoyée avec les informations suivantes :' . "\r\n\r\n"; - foreach($fields as $f => $d) { + foreach ($fields as $f => $d) { if ($_POST[$f] != '') { if ($f == 'pays') { $body .= ' * ' . $d . ' : ' . cubeCountry::getCountry($_POST[$f], 'fr') . "\r\n"; @@ -470,11 +438,10 @@ class wsAjax extends cubeAjax { $core->refreshWSUsersTree(); } - public static function valideDemandeDevis(&$x) - { + public static function valideDemandeDevis(&$x) { $d = unserialize(base64_decode($_GET['devis_form'])); $d = cubeArray::array_flatten($d); - foreach($d as $k => $v) { + foreach ($d as $k => $v) { $_POST[$k] = trim($v); } if (isset($_POST['pages'])) { @@ -486,7 +453,7 @@ class wsAjax extends cubeAjax { // Validation des champs de formulaires $ok = true; $non_vides = array('nombre_pages', 'nom', 'adresse', 'code_postal', 'ville', 'pays'); - foreach($non_vides as $nv) { + foreach ($non_vides as $nv) { if (!isset($_POST[$nv]) || $_POST[$nv] == '') { $x->addError($nv); $ok = false; @@ -508,31 +475,26 @@ class wsAjax extends cubeAjax { return $ok; } - public static function searchDemandes($args, &$x) - { + public static function searchDemandes($args, &$x) { $x->addContent('listeDemandes', wsUrl::listeDemandes()); } - public static function sortDemandes($args, &$x) - { + public static function sortDemandes($args, &$x) { commonAjax::sort('demandes', $args[1]); $x->addContent('listeDemandes', wsUrl::listeDemandes()); } - public static function pageDemandes($args, &$x) - { + public static function pageDemandes($args, &$x) { commonAjax::page('demandes', $args[1]); $x->addContent('listeDemandes', wsUrl::listeDemandes()); } - public static function parPageDemandes($args, &$x) - { + public static function parPageDemandes($args, &$x) { commonAjax::parPage('demandes', $_POST['par_page']); $x->addContent('listeDemandes', wsUrl::listeDemandes()); } - public static function supprimeDemande($args, &$x) - { + public static function supprimeDemande($args, &$x) { global $core; $demande_id = $args[1]; @@ -542,8 +504,7 @@ class wsAjax extends cubeAjax { $x->addContent('listeDemandes', wsUrl::listeDemandes()); } - public static function filtreDemandes($args, &$x) - { + public static function filtreDemandes($args, &$x) { if (isset($args[1]) && $args[1] == 'efface') { commonAjax::filtre('demandes'); $x->addReload(); @@ -554,16 +515,14 @@ class wsAjax extends cubeAjax { } } - public static function formDemande($args, &$x) - { + public static function formDemande($args, &$x) { if (!isset($args[2])) { $args[2] = null; } commonAjax::form('saveDemande', __("Edition d'une demande"), wsUrl::formDemande($args[1], $args[2])); } - public static function saveDemande($args, &$x) - { + public static function saveDemande($args, &$x) { global $core; $dao = new wsDAODemande($core->con); @@ -578,12 +537,11 @@ class wsAjax extends cubeAjax { $demande = $dao->setRevendeur($_POST['demande_id'], $_POST['revendeur']); } - $x->addContent('listeDemandes' , wsUrl::listeDemandes()); + $x->addContent('listeDemandes', wsUrl::listeDemandes()); $x->addClosePopup(); } - public static function sendDemandeToRevendeur($demande, $revendeur) - { + public static function sendDemandeToRevendeur($demande, $revendeur) { global $core; $dao = new commonDAOUtilisateur($core->con); @@ -600,7 +558,7 @@ class wsAjax extends cubeAjax { 'liens' => __('Liens'), 'langues' => __('Langues'), 'details' => __('Commentaires')); - foreach($fields as $p => $t) { + foreach ($fields as $p => $t) { if ($demande->$p != '') { $body .= ' * ' . $t . ' : ' . $demande->$p . "\r\n"; } @@ -614,7 +572,7 @@ class wsAjax extends cubeAjax { 'code_postal' => __('Code postal'), 'ville' => __('Ville'), 'pays' => 'Pays'); - foreach($fields as $p => $t) { + foreach ($fields as $p => $t) { if ($utilisateur->$p != '') { if ($p == 'pays') { $body .= ' * ' . $t . ' : ' . cubeCountry::getCountry($utilisateur->$p, $revendeur->lang) . "\r\n"; @@ -636,8 +594,7 @@ class wsAjax extends cubeAjax { fb($mail->send()); } - public static function reponseDemande($args, &$x) - { + public static function reponseDemande($args, &$x) { global $core; $demande_id = $args[1]; @@ -661,31 +618,92 @@ class wsAjax extends cubeAjax { if (!isset($args[4])) { $x->addRedirection(SITE_PATH); } else { - $x->addContent('listeDemandes' , wsUrl::listeDemandes()); + $x->addContent('listeDemandes', wsUrl::listeDemandes()); } } - public static function resetDemande($args, &$x) - { + public static function resetDemande($args, &$x) { global $core; $demande_id = $args[1]; $dao = new wsDAODemande($core->con); $dao->reinitDemande($demande_id); - $x->addContent('listeDemandes' , wsUrl::listeDemandes()); + $x->addContent('listeDemandes', wsUrl::listeDemandes()); } - public static function restoreLinksVersion($args, &$x) - { + public static function restoreLinksVersion($args, &$x) { global $core; $book_id = $args[1]; $date = $args[2]; $dao = new wsDAODocument($core->con); - $dao->restoreLinksVersion($book_id, $date,$core->user->utilisateur_id); + $dao->restoreLinksVersion($book_id, $date, $core->user->utilisateur_id); + } + + public static function importLinksAsExcel($args) { + global $core; + $book_id = $args[1]; + + $xls = new PHPExcel(); + $reader = new PHPExcel_Reader_Excel2007(); + $xls = $reader->load($_FILES['file']['tmp_name']); + + $s = $xls->setActiveSheetIndexByName('Links'); + $i = 0; + $links = array(); + foreach ($s->getRowIterator() as $row) { + $cellIterator = $row->getCellIterator(); + $cellIterator->setIterateOnlyExistingCells(false); + if ($i == 0) { + $cols = array(); + foreach ($cellIterator as $cell) { + $cols[] = $cell->getValue(); + } + } else { + $link = array(); + $j = 0; + foreach ($cellIterator as $cell) { + $link[$cols[$j]] = $cell->getValue(); + $j++; + } + $links[] = $link; + } + + $i++; + } + + $i = 0; + $rulers = array(); + $s = $xls->setActiveSheetIndexByName('Rulers'); + foreach ($s->getRowIterator() as $row) { + $cellIterator = $row->getCellIterator(); + $cellIterator->setIterateOnlyExistingCells(false); + if ($i == 0) { + $cols = array(); + foreach ($cellIterator as $cell) { + $cols[] = $cell->getValue(); + } + } else { + $link = array(); + $j = 0; + foreach ($cellIterator as $cell) { + $ruler[$cols[$j]] = $cell->getValue(); + $j++; + } + + $rulers[] = $ruler; + } + $i++; + } + + + + $dao = new wsDAODocument($core->con); + $dao->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), 'Import from excel', $core->user->utilisateur_id); } + } ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 23300e059..e376ad592 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -343,7 +343,7 @@ html{height:100%}' . "\n"; $res .= ''; $res .= '