From: Vincent Vanwaelscappel Date: Tue, 19 Sep 2023 13:26:31 +0000 (+0200) Subject: wait #6260 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=de2633c3ba61c51e93dbca48e2b5f66571e36f3d;p=fluidbook-toolbox.git wait #6260 @1 --- diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/YSLOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/YSLOperation.php index 9173b6d8b..e8337999e 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/YSLOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/YSLOperation.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers\Admin\Operations\FluidbookPublication; +use App\Http\Middleware\CheckIfAdmin; +use App\Http\Middleware\VerifyCsrfToken; use App\Models\FluidbookPublication; use App\Models\YSLSurvey; use Cubist\Excel\Excel; @@ -22,7 +24,7 @@ trait YSLOperation Route::post($segment . '/postyslreport', [ 'uses' => $controller . '@postyslreport', - ]); + ])->withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); } protected function setupYSLDefaults() @@ -32,14 +34,13 @@ trait YSLOperation return; } - if (!can('fluidbook-publication:write')) { - $this->crud->removeButtonFromStack('preview', 'line'); - $this->crud->removeButtonFromStack('edit', 'line'); - $this->crud->removeButtonFromStack('download', 'line'); - $this->crud->removeButtonFromStack('clone', 'line'); - $this->crud->removeButtonFromStack('upgrade', 'line'); - $this->crud->removeButtonFromStack('deletefb', 'line'); - } + $this->crud->removeButtonFromStack('preview', 'line'); + $this->crud->removeButtonFromStack('edit', 'line'); + $this->crud->removeButtonFromStack('download', 'line'); + $this->crud->removeButtonFromStack('clone', 'line'); + $this->crud->removeButtonFromStack('upgrade', 'line'); + $this->crud->removeButtonFromStack('deletefb', 'line'); + $this->crud->addButtonFromView('line', 'yslreport', 'fluidbook_publication.yslreport', 'end'); } @@ -48,7 +49,7 @@ trait YSLOperation */ protected function yslreport($id) { - if (!FluidbookPublication::hasPermission($id)) { + if (!FluidbookPublication::hasPermission($id, 'read')) { abort(401); } @@ -57,14 +58,10 @@ trait YSLOperation $fluidbook = FluidbookPublication::withoutGlobalScopes()->find($id); $head = ['Date', 'Page', 'Rating', 'Country', 'Function', 'Suggestions']; - // $sql = "SELECT * FROM ysl_survey WHERE fluidbook_id='" . $core->con->escape($bid) . "' ORDER BY date ASC"; - - //$r = $core->con->select($sql); $data = []; -// while ($r->fetch()) { -// $data[] = [date('Y-m-d H:i:s', $r->date), $r->page, $r->rating, $r->country, $r->function, $r->suggestions]; -// } - + foreach (YSLSurvey::withoutGlobalScopes()->where('fluidbook_id', $id)->orderBy('date', 'ASC')->get() as $r) { + $data[] = [date('Y-m-d H:i:s', $r->date), $r->page, $r->rating, $r->country, $r->function, $r->suggestions]; + } Excel::fromArray('Survey data #' . $id, $data, $head, $tmp, 100); return response()->download($tmp, 'report-' . $id . '-' . Text::str2URL($fluidbook->title) . '.xlsx', ['content-type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); @@ -72,30 +69,43 @@ trait YSLOperation protected function postyslreport() { - $i = new YSLSurvey(); - $i->fluidbook_id = $_POST['Fluidbook_ID']; - $i->page = $_POST['page']; - $i->rating = $_POST['rating']; - $i->suggestions = $_POST['suggestions']; - $i->country = $_POST['country']; - $i->function = $_POST['function']; - $i->title = $_POST['title']; - $i->date = time(); - $i->save(); - try { - $client = new Client(['timeout' => 10.0]); - $client->request('post', 'https://suivi.ysl-retailhandbook.com/importCSV.php', ['form_params' => [ - 'Fluidbook_ID' => $_POST['Fluidbook_ID'], - 'page' => $_POST['page'], - 'rating' => $_POST['rating'], - 'feedback' => $_POST['feedback'], - 'country' => $_POST['country'], - 'function' => $_POST['function'], - 'title' => $_POST['title'], - ]]); - } catch (Exception $e1) { - Log::error($e1->getMessage()); + $i = new YSLSurvey(); + $i->fluidbook_id = $_POST['Fluidbook_ID']; + $i->page = $_POST['page']; + $i->rating = $_POST['rating']; + $i->suggestions = $_POST['feedback']; + $i->country = $_POST['country']; + $i->function = $_POST['function']; + $i->title = $_POST['title']; + $i->date = time(); + $i->save(); + + try { + $client = new Client(['timeout' => 10.0]); + $client->request('post', 'https://suivi.ysl-retailhandbook.com/importCSV.php', ['form_params' => [ + 'Fluidbook_ID' => $_POST['Fluidbook_ID'], + 'page' => $_POST['page'], + 'rating' => $_POST['rating'], + 'feedback' => $_POST['feedback'], + 'country' => $_POST['country'], + 'function' => $_POST['function'], + 'title' => $_POST['title'], + ]]); + } catch (Exception $e1) { + Log::error($e1->getMessage()); + } + + $res = '1'; + } catch (\Exception $e) { + $res = '0'; } + + $headers = ['Access-Control-Allow-Origin' => '*', + 'Access-Control-Allow-Methods' => 'POST,GET,OPTIONS,PUT,DELETE', + 'Access-Control-Allow-Headers' => 'Content-Type,Accept,x-requested-with', + 'Content-type' => "text/plain"]; + + return response($res, 200, $headers); } } diff --git a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php index aa5895d60..352d58763 100644 --- a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php +++ b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php @@ -48,177 +48,187 @@ }); @endpush - - + + + -@can('files:read') - -@endcan + + @endcan -@canany(['quiz:read','quiztranslation:read','elearning_media:read']) -
  • {{__('e-Learning')}} - -
  • -@endcanany + @endcan + + + @endcanany +@endif @canany(['fluidbook-quote:read','signature:read','fluidbook-theme:read','fluidbook-iconset:read','fluibook-translate:write','fluidbook-publication:read'])
  • {{__('Fluidbook')}} + class="nav-icon la">{{__('Fluidbook')}}
  • @endcanany -@can('tools') -
  • {{__('Outils')}} - @include('tools.sidebar') -
  • -@endcan -@canany(['users:read','company:read','managerolesandpersmissions']) -
  • + @endcan + @canany(['users:read','company:read','managerolesandpersmissions']) +
  • {{__('Clients')}} - -
  • -@endcan + @endcan + + + @endcan -@canany(['team-leave:read','team-overtime:read','extranet:manage_emails']) -
  • {{__('Équipe')}} - -
  • -@endcan + {{__('Heures supp')}} + + @endcan + + + @endcan -@canany(['maintenance','toolbox-translate:admin']) -
  • {{__('Administration')}} - -
  • -@endcanany + {{__('Traduction')}} + + @endcan + @can('maintenance') + + + @endcan + + + @endcanany +@endif