From f05bbc84f615c3bd09ca284dfdd435d48edc4c26 Mon Sep 17 00:00:00 2001 From: Damien Burel <damien.burel@maarch.org> Date: Mon, 27 Feb 2017 16:13:13 +0100 Subject: [PATCH] FEAT #5233 Change route with basketId + left panel --- .../class/class_lists_Abstract.php | 2 +- apps/maarch_entreprise/js/app.module.js | 6 +-- modules/basket/Models/BasketsModel.php | 26 +++++++++ .../basket/Models/BasketsModelAbstract.php | 54 +++++++++++++++++++ modules/visa/Controllers/VisaController.php | 8 +++ modules/visa/Views/signatureBook.html | 10 ++-- modules/visa/css/module.css | 9 +++- modules/visa/js/aController.js | 17 ++++-- rest/index.php | 2 +- 9 files changed, 119 insertions(+), 15 deletions(-) create mode 100644 modules/basket/Models/BasketsModel.php create mode 100644 modules/basket/Models/BasketsModelAbstract.php diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index 6bf2d09927e..81a3f6ed1d9 100644 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -1467,7 +1467,7 @@ abstract class lists_Abstract extends Database } $aService = Basket_Baskets_Service::getServiceFromActionId(['id' => $this->params['defaultAction']]); if ($aService['actionPage'] == 'visa_mail' && V2_ENABLED == true) { - $return = 'onmouseover="this.style.cursor=\'pointer\';" onClick="location.href=\'#/signatureBook/' .$keyValue. '\'" '; + $return = 'onmouseover="this.style.cursor=\'pointer\';" onClick="location.href=\'#/' .$_SESSION['current_basket']['id']. '/signatureBook/' .$keyValue. '\'" '; } else { $return = 'onmouseover="this.style.cursor=\'pointer\';" onClick="validForm( \'page\', \''.$keyValue.'\', \''.$this->params['defaultAction'].'\');" '; } diff --git a/apps/maarch_entreprise/js/app.module.js b/apps/maarch_entreprise/js/app.module.js index c4ca8ffa2e6..86c1cd3f088 100644 --- a/apps/maarch_entreprise/js/app.module.js +++ b/apps/maarch_entreprise/js/app.module.js @@ -2,10 +2,10 @@ var mainApp = angular.module("AppModule", ["ngRoute", "ngTable"]); mainApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $routeProvider - .when("/signatureBook/:resId", { + .when("/:basketId/signatureBook/:resId", { templateUrl : "../../modules/visa/Views/signatureBook.html", - controller : "visaCtrl" - //controllerAs : "vm" + controller : "visaCtrl", + controllerAs : "vm" }); $locationProvider.hashPrefix(''); diff --git a/modules/basket/Models/BasketsModel.php b/modules/basket/Models/BasketsModel.php new file mode 100644 index 00000000000..ccf7181aee5 --- /dev/null +++ b/modules/basket/Models/BasketsModel.php @@ -0,0 +1,26 @@ +<?php + +/* +* Copyright 2015 Maarch +* +* This file is part of Maarch Framework. +* +* Maarch Framework is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Maarch Framework is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. +*/ + +require_once 'modules/basket/Models/BasketsModelAbstract.php'; + +class BasketsModel extends BasketsModelAbstract { + // Do your stuff in this class +} \ No newline at end of file diff --git a/modules/basket/Models/BasketsModelAbstract.php b/modules/basket/Models/BasketsModelAbstract.php new file mode 100644 index 00000000000..df7e1dd256c --- /dev/null +++ b/modules/basket/Models/BasketsModelAbstract.php @@ -0,0 +1,54 @@ +<?php + +/* +* Copyright 2015 Maarch +* +* This file is part of Maarch Framework. +* +* Maarch Framework is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Maarch Framework is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. +*/ + +require_once 'apps/maarch_entreprise/services/Table.php'; + +class BasketsModelAbstract extends Apps_Table_Service { + + public static function getResListById(array $aArgs = []) { + static::checkRequired($aArgs, ['basketId']); + static::checkString($aArgs, ['basketId']); + + + $aBasket = static::select([ + 'select' => ['basket_clause'], + 'table' => ['baskets'], + 'where' => ['basket_id = ?'], + 'data' => [$aArgs['basketId']] + ]); + + if (empty($aBasket[0]) || empty($aBasket[0]['basket_clause'])) { + return []; + } + + $where = str_replace('@user', "'" .$_SESSION['user']['UserId']. "'", $aBasket[0]['basket_clause']); + + $aResList = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['res_view_letterbox'], + 'where' => [$where], + 'order_by' => "creation_date DESC", + ]); + + return $aResList; + } + +} \ No newline at end of file diff --git a/modules/visa/Controllers/VisaController.php b/modules/visa/Controllers/VisaController.php index c3bfda9cebb..f9b5c57a2cf 100644 --- a/modules/visa/Controllers/VisaController.php +++ b/modules/visa/Controllers/VisaController.php @@ -10,6 +10,7 @@ require_once 'apps/maarch_entreprise/Models/ResModel.php'; require_once 'apps/maarch_entreprise/Models/HistoryModel.php'; require_once 'apps/maarch_entreprise/Models/ContactsModel.php'; require_once 'apps/maarch_entreprise/Models/UsersModel.php'; +require_once 'modules/basket/Models/BasketsModel.php'; class VisaController { @@ -17,6 +18,7 @@ class VisaController { public function getSignatureBook(RequestInterface $request, ResponseInterface $response, $aArgs) { $resId = $aArgs['resId']; + $basketId = $aArgs['basketId']; $incomingMail = \ResModel::get([ 'resId' => $resId, @@ -138,6 +140,10 @@ class VisaController { 'orderBy' => ['event_date DESC'] ]); + $resList = \BasketsModel::getResListById([ + 'basketId' => $basketId, + 'select' => ['res_id', 'alt_identifier', 'subject', 'creation_date', 'process_limit_date', 'priority'] + ]); $datas = []; $datas['actions'] = $actionsData; @@ -146,7 +152,9 @@ class VisaController { $datas['currentAction'] = $_SESSION['current_basket']['default_action']; //TODO Aller chercher l'id de la basket sans passer par la session $datas['linkNotes'] = 'index.php?display=true&module=notes&page=notes&identifier=' .$resId. '&origin=document&coll_id=letterbox_coll&load&size=medium'; $datas['histories'] = $history; + $datas['resList'] = $resList; return $response->withJson($datas); } + } \ No newline at end of file diff --git a/modules/visa/Views/signatureBook.html b/modules/visa/Views/signatureBook.html index 72b4a922a9d..abc21b8769c 100644 --- a/modules/visa/Views/signatureBook.html +++ b/modules/visa/Views/signatureBook.html @@ -1,6 +1,3 @@ -<div class="visaResList"> - -</div> <div class='visaContent'> <div class="titleSignatureBook" title="Viser le document n°231 : {{signatureBook.documents[0].title}}"> Viser le document n°231 : {{signatureBook.documents[0].title}} @@ -19,7 +16,7 @@ <i class="fa fa-line-chart fa-2x"></i> </div> <div class="others"> - <i style="cursor: pointer" ng-click="backToBasket()" class="fa fa-backward fa-lg"></i> + <i style="cursor: pointer" ng-click="backToBasket()" class="fa fa-times-circle fa-2x"></i> </div> <div class="actions"> <select id="signatureBookActions"> @@ -29,6 +26,11 @@ </div> </div> <div class="contentSignatureBook"> + <div class="resListContent"> + <div ng-repeat="res in signatureBook.resList" ng-click="changeLocation(res.res_id)"> + <span>{{res.alt_identifier}}</span> + </div> + </div> <div class="contentLeft"> <div class="contentShow" ng-if="signatureBook.headerTab == 1"> <div class="pjDoc" > diff --git a/modules/visa/css/module.css b/modules/visa/css/module.css index d27a1a3d0e6..8e3d9972146 100644 --- a/modules/visa/css/module.css +++ b/modules/visa/css/module.css @@ -231,13 +231,20 @@ text-align: right; } +.resListContent{ + display: table-cell; + width:10%; + text-align: center; + border-right: solid 1px; + vertical-align: top; +} .contentLeft{ border-right: solid 1px; vertical-align: top; } .contentLeft, .contentRight{ display: table-cell; - width:50%; + width:45%; text-align: center; } diff --git a/modules/visa/js/aController.js b/modules/visa/js/aController.js index 9894391e342..2c9067d9e5e 100644 --- a/modules/visa/js/aController.js +++ b/modules/visa/js/aController.js @@ -1,17 +1,17 @@ "use strict"; -mainApp.controller("visaCtrl", ["$scope", "$http", "$routeParams", "$interval", "NgTableParams", function($scope, $http, $routeParams, $interval, NgTableParams) { +mainApp.controller("visaCtrl", ["$scope", "$http", "$routeParams", "$interval", "NgTableParams", "$location", function($scope, $http, $routeParams, $interval, NgTableParams, $location) { - //var vm = this; + var vm = this; - function getDatas(res_id) { + function getDatas(basketId, resId) { $j('#inner_content').remove(); $j('#header').remove(); $j('#viewBasketsTitle').remove(); $http({ method : 'GET', - url : globalConfig.coreurl + 'rest/signatureBook/' + res_id, + url : globalConfig.coreurl + 'rest/' + basketId + '/signatureBook/' + resId, headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function successCallback(response) { @@ -80,6 +80,10 @@ mainApp.controller("visaCtrl", ["$scope", "$http", "$routeParams", "$interval", location.reload(); }; + $scope.changeLocation = function(resId) { + $location.path(vm.basketId + "/signatureBook/" + resId); + }; + $scope.validForm = function() { //$interval.cancel(intervalPromise); unlockDocument($routeParams.resId); @@ -101,7 +105,10 @@ mainApp.controller("visaCtrl", ["$scope", "$http", "$routeParams", "$interval", //Initialize View - getDatas($routeParams.resId); + vm.basketId = $routeParams.basketId; + vm.resId = $routeParams.resId; + + getDatas($routeParams.basketId, $routeParams.resId); lockDocument($routeParams.resId); $interval(function () { diff --git a/rest/index.php b/rest/index.php index 730db35551d..a722e4f11d4 100644 --- a/rest/index.php +++ b/rest/index.php @@ -102,6 +102,6 @@ $app->post('/status', \Core\Controllers\StatusController::class . ':create'); $app->put('/status', \Core\Controllers\StatusController::class . ':update'); $app->delete('/status/{id}', \Core\Controllers\StatusController::class . ':delete'); -$app->get('/signatureBook/{resId}', \Visa\Controllers\VisaController::class . ':getSignatureBook'); +$app->get('/{basketId}/signatureBook/{resId}', \Visa\Controllers\VisaController::class . ':getSignatureBook'); $app->run(); -- GitLab