protected function download($id, $action)
{
- FluidbookCollectionDownload::dispatch(FluidbookCollection::find($id), $action, backpack_user())->onQueue('download');;
+ FluidbookCollectionDownload::dispatch(FluidbookCollection::find($id), $action, backpack_user())->onQueue('download');
Alert::add('success', __('La compilation a été placée en file d\'attente. Vous recevrez un email lorsqu\'elle sera terminée.'))->flash();
return redirect(backpack_url('fluidbook-collection'));
}
use App\Models\FluidbookQuote;
use App\Models\User;
use Illuminate\Support\Facades\Mail;
+use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Route;
+use Prologue\Alerts\Facades\Alert;
trait AssignOperation
{
protected function setupAssignRoutes($segment, $routeName, $controller)
{
- Route::match(['post'], $segment . '/{id}/assign', $controller . '@assign');
+ Route::match(['get'], $segment . '/{id}/assign/{reseller}', $controller . '@assign');
}
protected function setupAssignDefaults()
$this->crud->addButtonFromView('line', 'assign', 'fluidbook_quote.assign', 'end');
}
- protected function assign($id)
+ protected function assign($id, $reseller)
{
$quote = FluidbookQuote::where('id', $id)->first();
- $quote->reseller = request()->get('reseller');
+ $quote->reseller = $reseller;
$quote->status = 1;
$quote->admin = backpack_user()->id;
$quote->save();
$quoteMail->setQuote($quote);
Mail::send($quoteMail);
}
+ Alert::add('success', __('La demande de devis a été attribuée'))->flash();
+ return Redirect::to(session('_previous', ['url' => backpack_url('fluidbook-quote')])['url']);
}
}
$manifest = $path . '/' . $lang . '/imsmanifest.xml';
if ($lang === $default) {
rename($manifest, $manifestFile);
- } else {
+ } else if (file_exists($manifest)) {
unlink($manifest);
}
}
'packages/featherlight/featherlight.gallery.min.css',
'packages/fluidbook/toolbox/css/style.css',
+ 'https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.css',
+
// Here's what's inside the bundle:
// 'packages/@digitallyhappy/backstrap/css/style.min.css',
// 'packages/animate.css/animate.min.css',
'packages/featherlight/featherlight.min.js',
'packages/featherlight/featherlight.gallery.min.js',
'packages/fluidbook/toolbox/js/bundle.js',
+ 'packages/fluidbook/toolbox/js/contextdownload.js',
'https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.3.0/jquery.form.min.js',
+ "https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js",
+ "https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.ui.position.min.js",
// examples (everything inside the bundle, loaded from CDN)
// 'https://code.jquery.com/jquery-3.4.1.min.js',
--- /dev/null
+$(function () {
+ $.contextMenu({
+ selector: '[data-context-actions]', trigger: 'left', build: function ($trigger, e) {
+ var route = $($trigger).data('context-route');
+ var id = $($trigger).data('context-id');
+ var actions = $($trigger).data('context-actions');
+ var items = {};
+ var confirm = $($trigger).data('context-confirm');
+ $.each(actions, function (key, name) {
+ items[key] = {name: name};
+ });
+
+ function replaceVariables(template, action) {
+ return template.replace(/\$id/g, id).replace(/\$action/g, action);
+ }
+
+ return {
+ callback: function (key, options) {
+ var url = replaceVariables(route, key);
+ var ok = function () {
+ window.location = url;
+ return true;
+ }
+ if (confirm === null) {
+ return ok();
+ }
+ swal({
+ title: confirm.title,
+ text: replaceVariables(confirm.text, actions[key]),
+ icon: "info",
+ buttons: {
+ cancel: {
+ text: confirm.cancel,
+ value: null,
+ visible: true,
+ className: "bg-secondary",
+ closeModal: true,
+ },
+ delete: {
+ text: confirm.confirm,
+ value: true,
+ visible: true,
+ className: "bg-success",
+ }
+ },
+ }).then((value) => {
+ if (value) {
+ ok();
+ }
+ });
+
+ }, items: items
+ };
+ }
+ });
+});
<script src="https://cdnjs.cloudflare.com/ajax/libs/keypress/2.1.5/keypress.min.js"
integrity="sha512-JjqUcblrwIZTQBPL/azOhVHwq5uaeXkKzq7da3JZEP14Zg926vZZVhRhBBi+L2pWYquZ6r5P8OZYDYgOChtkOw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js"
- integrity="sha512-kvg/Lknti7OoAw0GqMBP8B+7cGHvp4M9O9V6nAYG91FZVDMW3Xkkq5qrdMhrXiawahqU7IZ5CNsY/wWy1PpGTQ=="
- crossorigin="anonymous" referrerpolicy="no-referrer"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.ui.position.min.js"
- integrity="sha512-878jmOO2JNhN+hi1+jVWRBv1yNB7sVFanp2gA1bG++XFKNj4camtC1IyNi/VQEhM2tIbne9tpXD4xaPC4i4Wtg=="
- crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
@endpush
-@once
- @php
- $showjs=false;
- if($crud->getValue('seenExportJS')===null){
- $showjs =true;
- $crud->setValue('seenExportJS',true);
- }
- @endphp
- @if($showjs)
- <style>
- a.exportelearningmedia {
- position: relative;
- }
-
- a.exportelearningmedia select {
- opacity: 0;
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- cursor: pointer;
- }
- </style>
- <script>
- jQuery(document).ready(function ($) {
- $('a.exportelearningmedia').on('click', function () {
- return false;
- });
- $('a.exportelearningmedia select').on('change', function () {
- var val = $(this).val();
- if (val <= 0 || val == null || val == 'null') {
- return;
- }
- var id = $(this).data('id');
- window.location = $(this).data('route') + "/" + id + "/download/" + val;
- });
- });
- </script>
- @endif
-@endonce
-
<a class="btn btn-sm btn-link exportelearningmedia" href="#"
data-toggle="tooltip"
- title="{{__('Exporter le media')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
- <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
- <option value="" selected style="display: none">--</option>
- <option value="download">{{__('Télécharger')}}</option>
- <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
- </select>
+ title="{{__('Exporter le media')}}"
+ data-context-actions="{{json_encode(['download'=>__('Télécharger'),'scormcloud'=>__('Tester sur Scorm Cloud')])}}"
+ data-context-route="{{$crud->route}}/$id/download/$action"
+ data-context-id="{{$entry->getKey()}}"
+>
+ <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
</a>
-@once
- @php
- $showjs=false;
- if($crud->getValue('seenExportJS')===null){
- $showjs =true;
- $crud->setValue('seenExportJS',true);
- }
- @endphp
- @if($showjs)
- <style>
- a.exportelearningpackage {
- position: relative;
- }
-
- a.exportelearningpackage select {
- opacity: 0;
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- cursor: pointer;
- }
- </style>
- <script>
- jQuery(document).ready(function ($) {
- $('a.exportelearningpackage').on('click', function () {
- return false;
- });
- $('a.exportelearningpackage select').on('change', function () {
- var val = $(this).val();
- if (val <= 0 || val == null || val == 'null') {
- return;
- }
- var id = $(this).data('id');
- window.location = $(this).data('route') + "/" + id + "/download/" + val;
- });
- });
- </script>
- @endif
-@endonce
-
<a class="btn btn-sm btn-link exportelearningpackage" href="#"
data-toggle="tooltip"
- title="{{__('Exporter le media')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
- <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
- <option value="" selected style="display: none">--</option>
- <option value="download">{{__('Télécharger')}}</option>
- <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
- </select>
+ title="{{__('Exporter le package')}}"
+ data-context-actions="{{json_encode(['download'=>__('Télécharger'),'scormcloud'=>__('Tester sur Scorm Cloud')])}}"
+ data-context-route="{{$crud->route}}/$id/download/$action"
+ data-context-id="{{$entry->getKey()}}"
+>
+ <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
</a>
-@once
@php
-$showjs=false;
-if($crud->getValue('seenExportJS')===null){
-$showjs =true;
-$crud->setValue('seenExportJS',true);
-}
-@endphp
-@if($showjs)
-<style>
- a.exportcollection {
- position: relative;
- }
-
- a.exportcollection select {
- opacity: 0;
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- cursor: pointer;
+ $actions=['download'=>__('Télécharger')];
+ if($entry->type==='scorm_multilang'){
+ $actions['scormcloud']=__('Tester sur Scorm Cloud');
}
-</style>
-<script>
- jQuery(document).ready(function ($) {
- $('a.exportcollection').on('click', function () {
- return false;
- });
- $('a.exportcollection select').on('change', function () {
- var val = $(this).val();
- if (val <= 0 || val == null || val == 'null') {
- return;
- }
- var id = $(this).data('id');
- window.location = $(this).data('route') + "/" + id + "/download/" + val;
- });
- });
-</script>
-@endif
-@endonce
-
+@endphp
<a class="btn btn-sm btn-link exportcollection" href="#"
data-toggle="tooltip"
- title="{{__('Exporter la collection')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
- <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
- <option value="" selected style="display: none">--</option>
- <option value="download">{{__('Télécharger')}}</option>
- @if($entry->type==='scorm_multilang')
- <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
- @endif
- </select>
+ title="{{__('Exporter la collection')}}"
+ data-context-actions="{{json_encode($actions)}}"
+ data-context-route="{{$crud->route}}/$id/download/$action"
+ data-context-id="{{$entry->getKey()}}"
+>
+ <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
</a>
-
-@once
- @php
- $showjs=false;
- if($crud->getValue('seenAssignJS')===null){
- $showjs =true;
- $crud->setValue('seenAssignJS',true);
- }
- @endphp
- @if($showjs)
- <style>
- a.assignto {
- position: relative;
- }
-
- select.assign {
- opacity: 0;
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- cursor: pointer;
- }
- </style>
- <script>
- jQuery(document).ready(function ($) {
- $('select.assign').on('change', function () {
- var val = $(this).val();
- if (val <= 0 || val == null || val == 'null') {
- return;
- }
- var option = $(this).find('option[value="' + val + '"]').text();
- var id = $(this).data('id');
- swal({
- title: "{!!__("Confier la demande de devis")!!}",
- text: "{!!__("Vous avez choisi l'option « :option »",['option'=>'"+ option +"'])!!}",
- icon: "info",
- buttons: {
- cancel: {
- text: "{!!__('Annuler')!!}",
- value: null,
- visible: true,
- className: "bg-secondary",
- closeModal: true,
- },
- delete: {
- text: "{!!__('Confirmer')!!}",
- value: true,
- visible: true,
- className: "bg-success",
- }
- },
- }).then((value) => {
- if (value) {
- $.ajax({
- url: '/fluidbook-quote/' + id + '/assign',
- type: 'POST',
- data: {reseller: val},
- success: function (result) {
- window.location = '';
- }
- });
- }
- });
-
- });
- });
- </script>
- @endif
-@endonce
-
@if($entry->status==0)
- <a class="btn btn-sm btn-link assignto" nohref data-toggle="tooltip"
- title="Assign to"><i class="la la-user-check"></i> {{__('Confier')}}
- <select class="assign" data-id="{{$entry->getKey()}}">
- <option value="null">-</option>
- <option value="{{backpack_user()->id}}">{{__('Je vais traiter la demander')}}</option>
-{{-- <option value="5256">{{__('Confier à :reseller',['reseller'=>'Mallaury'])}}</option>--}}
- <option value="94">{{__('Confier à :reseller',['reseller'=>'Kadreo'])}}</option>
- </select>
+ <a class="btn btn-sm btn-link assignto" href="#" data-toggle="tooltip"
+ data-context-actions="{{json_encode([backpack_user()->id=>__('Je vais traiter la demander'),'94'=>__('Confier à :reseller',['reseller'=>'Kadreo'])])}}"
+ data-context-route="{{$crud->route}}/$id/assign/$action"
+ data-context-id="{{$entry->getKey()}}"
+ data-context-confirm="{{json_encode(
+ [
+ 'title'=>__('Confier la demande de devis'),
+ 'text'=>__("Vous avez choisi l'option « :option »",['option'=>'$action']),
+ 'confirm'=>__('Confirmer'),
+ 'cancel'=>__('Annuler')
+ ]
+ )}}"
+ title="{{__('Confier la demande à')}}"><i class="la la-user-check"></i> {{__('Confier')}}
</a>
-
@endif
-@once
- @php
- $showjs=false;
- if($crud->getValue('seenExportJS')===null){
- $showjs =true;
- $crud->setValue('seenExportJS',true);
- }
- @endphp
- @if($showjs)
- <style>
- a.exportquiz {
- position: relative;
- }
-
- a.exportquiz select {
- opacity: 0;
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- cursor: pointer;
- }
- </style>
- <script>
- jQuery(document).ready(function ($) {
- $('a.exportquiz').on('click', function () {
- return false;
- });
- $('a.exportquiz select').on('change', function () {
- var val = $(this).val();
- if (val <= 0 || val == null || val == 'null') {
- return;
- }
- var id = $(this).data('id');
- window.location = $(this).data('route') + "/" + id + "/download/" + val;
- });
- });
- </script>
- @endif
-@endonce
-
<a class="btn btn-sm btn-link exportquiz" href="#"
data-toggle="tooltip"
- title="{{__('Exporter le quiz')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
- <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
- <option value="" selected style="display: none">--</option>
- <option value="download">{{__('Télécharger')}}</option>
- <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
- </select>
+ title="{{__('Exporter le quiz')}}"
+ data-context-actions="{{json_encode(['download'=>__('Télécharger'),'scormcloud'=>__('Tester sur Scorm Cloud')])}}"
+ data-context-route="{{$crud->route}}/$id/download/$action"
+ data-context-id="{{$entry->getKey()}}"
+>
+ <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
</a>