From ebb3139eb05afbcf762fb25449bd8528713b0c4b Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 30 Oct 2018 17:31:20 +0000 Subject: [PATCH] wip #2262 @1.5 --- inc/ws/Controlleur/class.ws.ajax.php | 303 ++++++++++++-------- inc/ws/Controlleur/class.ws.maintenance.php | 56 ++++ inc/ws/Controlleur/class.ws.url.php | 1 + 3 files changed, 245 insertions(+), 115 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index bb9ba2e7f..bdbce2343 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -1,8 +1,10 @@ con); // Creation de l'entreprise @@ -60,7 +64,8 @@ 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); @@ -80,7 +85,8 @@ 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); @@ -91,31 +97,37 @@ 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 sortCollections($args, &$x) { + public static function sortCollections($args, &$x) + { commonAjax::sort('collections', $args[1]); $x->addContent('listeCollections', wsUrl::listeCollections()); } - 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(); @@ -126,49 +138,59 @@ 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 newCollectionForm($args, &$x) { + public static function newCollectionForm($args, &$x) + { commonAjax::form('saveCollection', __("Créer une nouvelle collection"), wsUrl::formCollection(), __('Créer une nouvelle collection'), 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 formChangeCollectionProprietaire($args, &$x) { + public static function formChangeCollectionProprietaire($args, &$x) + { commonAjax::form('changeCollectionProprietaire/' . $args[1], __("Modifier le propriétaire de la collection"), wsUrl::changeCollectionProprietaire($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(); @@ -179,7 +201,8 @@ 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'] != '') { @@ -193,7 +216,8 @@ class wsAjax extends cubeAjax { $x->addTruePopup(SITE_PATH . 'editor/' . $book->book_id); } - public static function saveCollection($args, &$x) { + public static function saveCollection($args, &$x) + { global $core; $dao = new wsDAOCollection($core->con); $dao->sauve($_POST, $core->user->utilisateur_id); @@ -202,7 +226,8 @@ class wsAjax extends cubeAjax { $x->addContent('listeCollections', wsUrl::listeCollections()); } - public static function saveCollectionComposition($args, &$x) { + public static function saveCollectionComposition($args, &$x) + { global $core; $dao = new wsDAOCollection($core->con); @@ -274,15 +299,18 @@ class wsAjax extends cubeAjax { $x->addReload(); } - public static function changeBookProprietaire($args, &$x) { + public static function changeBookProprietaire($args, &$x) + { return self::_changeProprietaire('book', $args[1], $_POST['proprietaire'], $x); } - public static function changeCollectionProprietaire($args, &$x) { + public static function changeCollectionProprietaire($args, &$x) + { return self::_changeProprietaire('collection', $args[1], $_POST['proprietaire'], $x); } - public static function _changeProprietaire($type, $id, $proprietaire, &$x) { + public static function _changeProprietaire($type, $id, $proprietaire, &$x) + { global $core; if ($proprietaire == '') { $x->addError('book_proprietaire'); @@ -306,7 +334,8 @@ class wsAjax extends cubeAjax { } } - public static function downbook($args, &$x) { + public static function downbook($args, &$x) + { global $core; $book_id = $args[1]; $version = $args[2]; @@ -335,7 +364,8 @@ class wsAjax extends cubeAjax { $exporter->export($book_id, $x, 'download', $version); } - public static function statusBook($args, &$x) { + public static function statusBook($args, &$x) + { global $core; $book_id = $args[1]; @@ -351,11 +381,13 @@ 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']; @@ -386,11 +418,13 @@ 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']; @@ -437,11 +471,13 @@ 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']; @@ -453,21 +489,22 @@ 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; - $defaults = array('adresse' => '', - 'code_postal' => '', - 'ville' => '', - 'pays' => 'INT', - 'site' => '', - 'telephone' => '', - 'produits' => '', - 'nombre_pages' => '', - 'nombre_liens' => '', - 'nombre_langues' => '', - 'coupon' => ''); + 'code_postal' => '', + 'ville' => '', + 'pays' => 'INT', + 'site' => '', + 'telephone' => '', + 'produits' => '', + 'nombre_pages' => '', + 'nombre_liens' => '', + 'nombre_langues' => '', + 'coupon' => '', + 'fax' => ''); $_POST = array_merge($defaults, $_POST); @@ -535,25 +572,30 @@ class wsAjax extends cubeAjax { $daoDemande = new wsDAODemande($core->con); $daoDemande->sauve($datas); - $fields = array('prenom' => 'Prenom', - 'nom' => 'Nom', - 'email' => 'E-mail', - 'telephone' => 'Telephone', - 'rs' => 'Société', - 'site' => 'Site web', - 'adresse' => 'Adresse', - 'code_postal' => 'Code postal', - 'ville' => 'Ville', - 'pays' => 'Pays', - 'produits' => 'Type', - 'coupon' => 'Coupon', - 'lang' => 'Langue du visiteur', - 'nombre_liens' => 'Liens', - 'nombre_pages' => 'Pages', - 'nombre_langues' => 'Langues', - 'contact_type' => 'Type de client', - 'detail' => 'Commentaires', + $fields = array( + 'spam' => 'Demande SPAM', + 'prenom' => 'Prenom', + 'nom' => 'Nom', + 'email' => 'E-mail', + 'telephone' => 'Telephone', + 'rs' => 'Société', + 'site' => 'Site web', + 'adresse' => 'Adresse', + 'code_postal' => 'Code postal', + 'ville' => 'Ville', + 'pays' => 'Pays', + 'produits' => 'Type', + 'coupon' => 'Coupon', + 'lang' => 'Langue du visiteur', + 'nombre_liens' => 'Liens', + 'nombre_pages' => 'Pages', + 'nombre_langues' => 'Langues', + 'contact_type' => 'Type de client', + 'detail' => 'Commentaires', ); + + $_POST['spam'] = (strlen($_POST['fax']) > 0) ? 'Oui' : 'Non'; + $mail = new cubeMail(); $mail->charset = 'UTF-8'; $mail->from = $_POST['prenom'] . ' ' . $_POST['nom'] . '<' . $_POST['email'] . '>'; @@ -585,7 +627,8 @@ class wsAjax extends cubeAjax { $core->refreshWSUsersTree(); } - public static function valideDemandeDevis(&$x) { + public static function valideDemandeDevis(&$x) + { $d64 = base64_decode(str_replace(' ', '+', $_GET['devis_form'])); $d = json_decode($d64); @@ -624,31 +667,37 @@ 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 parPageCollections($args, &$x) { + public static function parPageCollections($args, &$x) + { commonAjax::parPage('collections', $_POST['par_page']); $x->addContent('listeCollections', wsUrl::listeCollections()); } - public static function supprimeDemande($args, &$x) { + public static function supprimeDemande($args, &$x) + { global $core; $demande_id = $args[1]; @@ -658,7 +707,8 @@ 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(); @@ -669,14 +719,16 @@ 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 lockDemande($args, &$x) { + public static function lockDemande($args, &$x) + { global $core; $dao = new wsDAODemande($core->con); $daoUtilisateur = new commonDAOUtilisateur($core->con); @@ -731,7 +783,8 @@ class wsAjax extends cubeAjax { $x->addContent('actionDemande', $res); } - public static function saveDemande($args, &$x) { + public static function saveDemande($args, &$x) + { global $core; $dao = new wsDAODemande($core->con); @@ -750,7 +803,8 @@ class wsAjax extends cubeAjax { $x->addClosePopup(); } - public static function sendDemandeToRevendeur($demande, $revendeur) { + public static function sendDemandeToRevendeur($demande, $revendeur) + { global $core; $dao = new commonDAOUtilisateur($core->con); @@ -776,7 +830,8 @@ class wsAjax extends cubeAjax { $mail->send(); } - public static function reponseDemande($args, &$x) { + public static function reponseDemande($args, &$x) + { global $core; $demande_id = $args[1]; @@ -808,7 +863,8 @@ class wsAjax extends cubeAjax { } } - public static function resetDemande($args, &$x) { + public static function resetDemande($args, &$x) + { global $core; $demande_id = $args[1]; @@ -818,7 +874,8 @@ class wsAjax extends cubeAjax { $x->addContent('listeDemandes', wsUrl::listeDemandes()); } - public static function restoreLinksVersion($args, &$x) { + public static function restoreLinksVersion($args, &$x) + { global $core; set_time_limit(0); @@ -841,7 +898,8 @@ class wsAjax extends cubeAjax { $dao->restoreLinksVersion($book_id, $time, $core->user->utilisateur_id); } - public static function importLinksAsExcel($args) { + public static function importLinksAsExcel($args) + { set_time_limit(0); global $core; @@ -856,7 +914,8 @@ class wsAjax extends cubeAjax { } } - protected static function _importLinksAsExcel($book_id) { + protected static function _importLinksAsExcel($book_id) + { global $core; $xls = new PHPExcel(); $reader = new PHPExcel_Reader_Excel2007(); @@ -868,7 +927,8 @@ class wsAjax extends cubeAjax { $dao->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), 'Import from excel', $core->user->utilisateur_id); } - protected function _importLinksAsAutobookmarkText($book_id) { + protected function _importLinksAsAutobookmarkText($book_id) + { global $core; wsLinks::getLinksFromAutobookmarkText(file_get_contents($_FILES['file']['tmp_name']), $links, $rulers); @@ -877,7 +937,8 @@ class wsAjax extends cubeAjax { $dao->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), 'Import from fwstk text export', $core->user->utilisateur_id); } - public static function offsetLinks($args, &$x) { + public static function offsetLinks($args, &$x) + { global $core; $book_id = $args[1]; $offset = $_POST['offset']; @@ -929,7 +990,8 @@ class wsAjax extends cubeAjax { $x->addReload(); } - public static function exportbook($args, &$x) { + public static function exportbook($args, &$x) + { if (isset($_POST['action'])) { $x->addChangePopup(commonAjax::form('exportbookExe', __("Exporter une publication"), self::formExportBook($_POST['book_id']), '', 2, '', '', true)); return; @@ -937,7 +999,8 @@ class wsAjax extends cubeAjax { commonAjax::form('exportbookExe', __("Exporter une publication"), self::formExportBook($args[1]), '', 2); } - public static function exportbookExe($args, &$x) { + public static function exportbookExe($args, &$x) + { $dest = array('dir' => null, 'file' => null); if (isset($_POST['destination']) && is_array($_POST['destination'])) { @@ -950,30 +1013,31 @@ class wsAjax extends cubeAjax { $x->addClosePopup(); } - public static function formExportBook($book_id) { + public static function formExportBook($book_id) + { global $core; $choices = array(__('Télécharger') => 'download', - __("Installer sur le serveur d'hébergement") => 'install_hosting', - __("Installer sur l'espace de références") => 'install_references', - __('Installer sur un serveur distant') => 'install_ftp', - __('Envoyer vers un projet Phonegap Android') => 'phonegap_android', - __('Envoyer vers un projet Phonegap iOS') => 'phonegap_ios' + __("Installer sur le serveur d'hébergement") => 'install_hosting', + __("Installer sur l'espace de références") => 'install_references', + __('Installer sur un serveur distant') => 'install_ftp', + __('Envoyer vers un projet Phonegap Android') => 'phonegap_android', + __('Envoyer vers un projet Phonegap iOS') => 'phonegap_ios' ); $formatInstall = array('online' => false, - 'v1' => false, - 'html' => false, - 'v2' => false, - 'win-exe' => 'zip', - 'win-ins' => 'exe', - 'win-html' => 'zip', - 'mac-exe' => 'zip', - 'win-cd' => 'zip', - 'phonegap' => 'zip', - 'mac-exe-html' => 'zip', - 'win-exe-html' => 'zip', - 'win-inst-html' => 'zip', - 'win-cd-html' => 'zip'); + 'v1' => false, + 'html' => false, + 'v2' => false, + 'win-exe' => 'zip', + 'win-ins' => 'exe', + 'win-html' => 'zip', + 'mac-exe' => 'zip', + 'win-cd' => 'zip', + 'phonegap' => 'zip', + 'mac-exe-html' => 'zip', + 'win-exe-html' => 'zip', + 'win-inst-html' => 'zip', + 'win-cd-html' => 'zip'); $defaultVersion = isset($_POST['version']) ? $_POST['version'] : 'online'; $version = '' . __('Version') . '' . form::combo('version', wsUrl::getFluidbookVersions(true), $defaultVersion) . ''; @@ -1056,7 +1120,8 @@ class wsAjax extends cubeAjax { return $res; } - public static function exportCollection($args, &$x) { + public static function exportCollection($args, &$x) + { $id = $args[1]; $os = $args[2]; @@ -1064,7 +1129,8 @@ class wsAjax extends cubeAjax { $exporter->exportCollection($id, $os); } - public static function publishCollection($args, &$x) { + public static function publishCollection($args, &$x) + { global $core; $collection = $_POST['collection']; @@ -1094,7 +1160,8 @@ class wsAjax extends cubeAjax { $apns->close(); } - public function fluidbookAssets($args, &$x) { + public function fluidbookAssets($args, &$x) + { $id = $args[1]; if (!$id) { $c = __('Entrez le numéro du fluidbook source pour sélectionner les fichiers à transférer'); @@ -1122,7 +1189,8 @@ class wsAjax extends cubeAjax { $x->addContent('f', $c); } - public function copywsassets($args, &$x) { + public function copywsassets($args, &$x) + { if (!isset($_POST['files']) || !count($_POST['files'])) { $x->addAlert(__('Aucun fichier sélectionné')); return; @@ -1143,7 +1211,8 @@ class wsAjax extends cubeAjax { $x->addAlert(__('Copie effectuée')); } - public static function collectionVersionCreate($args, &$x) { + public static function collectionVersionCreate($args, &$x) + { global $core; $id = $args[1]; @@ -1178,7 +1247,8 @@ class wsAjax extends cubeAjax { $x->addReload(); } - public static function _maxVersion($vv) { + public static function _maxVersion($vv) + { $e = explode(',', $vv); $res = array(); foreach ($e as $v) { @@ -1189,7 +1259,8 @@ class wsAjax extends cubeAjax { return array_pop($res); } - public static function collectionVersionPublish($args, &$x) { + public static function collectionVersionPublish($args, &$x) + { global $core; $id = $args[1]; @@ -1207,12 +1278,14 @@ class wsAjax extends cubeAjax { $x->addReload(); } - protected static function cleanCachesCollection($id) { + protected static function cleanCachesCollection($id) + { $ff = WS_COLLECTIONS . '/ws/' . $id . '.*'; `rm $ff`; } - public static function collectionVersionDelete($args, &$x) { + public static function collectionVersionDelete($args, &$x) + { global $core; $id = $args[1]; diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 7518a1ca4..8cd26209d 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1245,6 +1245,62 @@ class wsMaintenance } } + public static function kadreoDevis8524147851() + { + global $core; + + $xls = new PHPExcel(); + + $cols = ['demande_id' => '#', 'date' => 'Date', 'prenom' => 'Prénom', 'nom' => 'Nom', 'rs' => 'Entreprise', 'email' => 'E-mail', + 'telephone' => 'Téléphone', 'pays' => 'Pays', 'code_postal' => 'Code postal', 'details' => 'Détails']; + + + $r = $core->con->select('SELECT * FROM demandes LEFT JOIN utilisateurs_entreprise ON demandes.utilisateur=utilisateurs_entreprise.utilisateur_id WHERE revendeur=94 AND status=2 ORDER BY date DESC'); + $s = $xls->getActiveSheet(); + $s->setTitle('Demandes'); + + $i = 0; + foreach ($cols as $c => $col) { + $s->getColumnDimensionByColumn($i)->setAutoSize(true); + $s->setCellValueByColumnAndRow($i, 1, $col); + $i++; + } + + $j = 2; + while ($r->fetch()) { + $i = 0; + foreach ($cols as $c => $col) { + $v = $r->{$c}; + if ($c == 'telephone') { + $v = $v . ' '; + } + if ($c == 'date') { + $v = date('Y-m-d H:i:s', $v); + } + + + $s->setCellValueByColumnAndRow($i, $j, $v); + $style = $s->getCellByColumnAndRow($i, $j)->getStyle(); + $style->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT) + ->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP) + ->setWrapText(true); + $i++; + } + $j++; + } + + + $xls->setActiveSheetIndex(0); + + ob_end_clean(); + files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')); + cubeHTTP::forceDownload('Kadreo_demandes_Fluidbook-com.xlsx', false); + + $writer = new PHPExcel_Writer_Excel2007($xls); + $writer->save('php://output'); + exit; + } + public static function syncKadreoMailchimp() { global $core; diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 8e56ff7be..46f9adfa3 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -814,6 +814,7 @@ class wsUrl $writer = new PHPExcel_Writer_Excel2007($xls); $writer->save('php://output'); + exit; } public static function exportLangAsSheet($s, $lang_id, $ref_id = 'en') -- 2.39.5