]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6571 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Jan 2024 18:45:25 +0000 (19:45 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Jan 2024 18:45:25 +0000 (19:45 +0100)
app/Http/Controllers/Admin/Operations/InvoiceOperation.php [deleted file]
app/Models/FluidbookPublication.php
public/packages/fluidbook/toolbox/js/contextdownload.js
resources/views/columns/fluidbook_status.blade.php
resources/views/vendor/backpack/crud/buttons/invoice.blade.php

diff --git a/app/Http/Controllers/Admin/Operations/InvoiceOperation.php b/app/Http/Controllers/Admin/Operations/InvoiceOperation.php
deleted file mode 100644 (file)
index 8116fa3..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Admin\Operations;
-
-use Illuminate\Support\Facades\Route;
-
-trait InvoiceOperation
-{
-    protected function setupInvoiceRoutes($segment, $routeName, $controller)
-    {
-        Route::match(['get'], $segment . '/{id}/invoice', $controller . '@invoiceItem');
-    }
-
-    protected function setupInvoiceDefaults()
-    {
-        $this->crud->addButtonFromView('line', 'invoice', 'invoice', 'end');
-    }
-
-    protected function invoiceItem($id)
-    {
-
-    }
-}
index 0fee1c895af698754355e992fdaa2cbc1bff7a6f..026748001645dfcb18d3991d725065173cfca70c 100644 (file)
@@ -103,7 +103,6 @@ class FluidbookPublication extends ToolboxStatusModel
         EditOperation::class,
         ChangeownerOperation::class,
         ChangestatusOperation::class,
-        InvoiceOperation::class,
         // Services
         SocialImageOperation::class,
         ExportPdfOperation::class,
index fcd9d5e0e5600b515788786f1ceb7c5ffaecb457..8a22b888c02fc54fad5e1a1b2bd5f97f04b8b760 100644 (file)
@@ -8,11 +8,11 @@ $(function () {
             var items = {};
             var confirm = $($trigger).data('context-confirm');
             var disabledOption = $($trigger).data('context-disabled-action');
+            var callbackFunc = $($trigger).data('context-callback')
 
             var actions = {};
 
             $.each(rawActions, function (key, action) {
-                console.log(action);
                 if (action != sep) {
                     if (typeof action === 'string') {
                         action = {'label': action};
@@ -27,14 +27,14 @@ $(function () {
                     action.disabled = action.disabled || (key == disabledOption);
                     action.isHtmlName = true;
                 }
-                actions[key+""] = action;
+                actions[key + ""] = action;
             });
 
             $.each(actions, function (key, action) {
                 if (action !== sep) {
-                    items[key+""] = {name: action.label, isHtmlName: action.isHtmlName, disabled: action.disabled,};
+                    items[key + ""] = {name: action.label, isHtmlName: action.isHtmlName, disabled: action.disabled,};
                 } else {
-                    items[key+""] = action;
+                    items[key + ""] = action;
                 }
             });
 
@@ -44,6 +44,12 @@ $(function () {
 
             return {
                 callback: function (key, options) {
+                    if (callbackFunc !== undefined && callbackFunc !== null) {
+                        if (!window[callbackFunc]($($trigger), key)) {
+                            return false;
+                        }
+                    }
+
                     var ok = function () {
                         var target = actions[key].target;
                         var url = actions[key].url;
index dc03a9c7d0c9fb1f4663d9ad700f4c0992f87884..f0733e1c09f28697b9b61d47cbe674d728d18386 100644 (file)
@@ -7,19 +7,42 @@
 @can('fluidbook-publication:admin')
     @if($entry->allowsEdit())
         <span data-{{$entry->getOption('name')}}-{{$column['name']}}="{{$values}}">
-    <a href="#"
-       data-toggle="tooltip"
-       data-context-disabled-action="{{$values}}"
-       data-context-actions="{{json_encode($column['options'])}}"
-       data-context-route="{{$crud->route}}/$id/changestatus/$action"
-       data-context-id="{{$entry->getKey()}}"
-       title="{{__('Changer le status')}}"
-    >{{$v}}</a>
+        <a href="#"
+           data-toggle="tooltip"
+           data-context-disabled-action="{{$values}}"
+           data-context-actions="{{json_encode($column['options'])}}"
+           data-context-route="{{$crud->route}}/$id/changestatus/$action"
+           data-context-id="{{$entry->getKey()}}"
+           data-context-callback="statusCallback"
+           title="{{__('Changer le status')}}"
+        >{{$v}}</a>
     @else
+                {{$v}}
+            @endif
+</span>
+    @endcan
+
+    @cannot('fluidbook-publication:admin')
         {{$v}}
+    @endcannot
+
+
+
+    @if(!isset($crud->seenStatusChange))
+        @php
+            $crud->seenStatusChange=true;
+
+        @endphp
+        <style>
+
+        </style>
+        <script>
+            function statusCallback(element, value) {
+                if (value < 3) {
+                    return true;
+                }
+
+
+            }
+        </script>
     @endif
-</span>
-@endcan
-@cannot('fluidbook-publication:admin')
-    {{$v}}
-@endcannot
index b589a84a1bde9d6c874a8d1507ccc1c16e74bc9d..e7a144eefc7c37ed539412dc9bfa0a7c37f00694 100644 (file)
@@ -1,60 +1,72 @@
 {{-- __('!! Paramètres des fluidbooks') --}}
 @if($entry->status<3 && $entry->status>0 && $entry->canAdmin(backpack_user()))
+    @if(!isset($crud->seenInvoice))
+        @php
+            $crud->seenInvoice=true;
+           // $crud->ajaxOwnerList=\Cubist\Backpack\Magic\Fields\SelectFromArray::hashOptions($column['options']);
+        @endphp
+        <style>
+            .select2-dropdown {
+                z-index: 10000;
+            }
+        </style>
+        <script>
+            $(function () {
+                console.log(':))');
+                $(document).on('click', "a.invoice", function () {
+                    console.log(':)');
+                    var a = $(this);
+                    Swal.fire({
+                        title: '{{__('Facturer')}}',
+                        html: $(a).closest('span').find('.invoice_container').html(),
+                        confirmButtonColor: '#467fcf',
+                        confirmButtonText: '{{__('Valider')}}',
+                        showCancelButton: true,
+                        cancelButtonText: '{{__('Annuler')}}',
+                        cancelButtonColor: '#f1ecec',
+                        cancelButtonTextColor: '#000000',
+                        focusConfirm: false,
+                        didOpen: function () {
+                            let select = $(Swal.getHtmlContainer()).find('select');
+                            $(select).select2({
+                                theme: 'bootstrap',
+                                ajax: {
+                                    url: '{{backpack_url('select2')}}' + '/' + $(select).data('ajax'),
+                                    dataType: 'json'
+                                },
+                                escapeMarkup: function (m) {
+                                    return m;
+                                }
+                            });
+                        },
+                        didDestroy: function () {
+                            let select = $(Swal.getHtmlContainer()).find('select');
+                            $(select).select2('destroy');
+                        },
+                    }).then((result) => {
+                        if (result.isConfirmed) {
+                            let select = $(Swal.getHtmlContainer()).find('select');
+                            window.location = '{{backpack_url($entry->getOption('name'))}}/' + $(a).data('entry-id') + '/invoice/' + select.val();
+                        }
+                    });
+                    return false;
+                });
+            });
+
+        </script>
+    @endif
+
+    <div class="invoice_container" style="display: none;">
+        <select
+            style="width: 100%;"
+            name="projects_list"
+            data-ajax="{{$crud->ajaxOwnerList}}"
+        >
 
+        </select>
+    </div>
     <a class="btn btn-sm btn-link" class="invoice" href="#"
        data-toggle="tooltip"
        title="{{__('Facturer')}}"><i class="las la-money-check-alt"></i> {{__('Facturer')}}
     </a>
 @endif
-
-
-@if(!isset($crud->seenInvoice))
-    @php
-        $crud->seenInvoice=true;
-       // $crud->ajaxOwnerList=\Cubist\Backpack\Magic\Fields\SelectFromArray::hashOptions($column['options']);
-    @endphp
-    <style>
-        .select2-dropdown {
-            z-index: 10000;
-        }
-    </style>
-    <script>
-        $(document).on('click', ".invoice", function () {
-            var a = $(this);
-            Swal.fire({
-                title: '{{__('Facturer')}}',
-                html: $(a).closest('span').find('.invoice_container').html(),
-                confirmButtonColor: '#467fcf',
-                confirmButtonText: '{{__('Valider')}}',
-                showCancelButton: true,
-                cancelButtonText: '{{__('Annuler')}}',
-                cancelButtonColor: '#f1ecec',
-                cancelButtonTextColor: '#000000',
-                focusConfirm: false,
-                didOpen: function () {
-                    let select = $(Swal.getHtmlContainer()).find('select');
-                    $(select).select2({
-                        theme: 'bootstrap',
-                        ajax: {
-                            url: '{{backpack_url('select2')}}' + '/' + $(select).data('ajax'),
-                            dataType: 'json'
-                        },
-                        escapeMarkup: function (m) {
-                            return m;
-                        }
-                    });
-                },
-                didDestroy: function () {
-                    let select = $(Swal.getHtmlContainer()).find('select');
-                    $(select).select2('destroy');
-                },
-            }).then((result) => {
-                if (result.isConfirmed) {
-                    let select = $(Swal.getHtmlContainer()).find('select');
-                    window.location = '{{backpack_url($entry->getOption('name'))}}/' + $(a).data('entry-id') + '/invoice/' + select.val();
-                }
-            });
-            return false;
-        });
-    </script>
-@endif