Skip to content

Commit

Permalink
add products reports
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Dec 25, 2023
1 parent ff94e8f commit 3065b40
Show file tree
Hide file tree
Showing 14 changed files with 433 additions and 51 deletions.
2 changes: 1 addition & 1 deletion resources/views/product-brands/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<x-tomato-translation label="{{__('Name')}}" placeholder="{{__('Name')}}" name="name" />
<x-splade-input label="{{__('Key')}}" placeholder="{{__('Key')}}" name="key" />
<div class="flex justify-between gap-4">
<x-splade-input class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-icon class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-color label="{{__('Color')}}" placeholder="{{__('Color')}}" name="color" />
</div>
</div>
Expand Down
20 changes: 20 additions & 0 deletions resources/views/product-categories/attach.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<x-tomato-admin-container :label="__('Attach Category')">
<x-splade-form :default="['ids'=> $ids]" class="grid grid-cols-1 gap-4" method="POST" action="{{route('admin.products.category.attach.store')}}">

<x-splade-select
name="category_id"
:label="__('Category')"
:placeholder="__('Category')"
remote-root="data"
remote-url="{{route('admin.categories.api') . '?for=product-categories'}}"
option-label="name.{{app()->getLocale()}}"
option-value="id"
choices
/>

<div class="flex justify-start gap-4">
<x-tomato-admin-submit spinner :label="__('Save')" />
<x-tomato-admin-button secondary @click.prevent="modal.close" :label="__('Cancel')" />
</div>
</x-splade-form>
</x-tomato-admin-container>
54 changes: 30 additions & 24 deletions resources/views/product-categories/form.blade.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
<x-tomato-admin-container :label="isset($item) ? __('Update Category') : __('Add Category')">
<x-splade-form method="POST" action="{{route('admin.products.category.store')}}" :default="isset($item) ? $item : ['activated' => true, 'name' => ['ar' => '', 'en'=> '']]">
<div class="py-4 grid grid-cols-1 gap-4">
<x-splade-file filepond preview name="image" label="{{__('Image')}}" />
<x-splade-form class="grid grid-cols-1 gap-4" method="POST" action="{{route('admin.products.category.store')}}" :default="isset($item) ? $item : ['activated' => true, 'name' => ['ar' => '', 'en'=> '']]">
<x-splade-file filepond preview name="image" label="{{__('Image')}}" />

<x-splade-select
name="parent_id"
:label="__('Parent')"
:placeholder="__('Parent')"
remote-root="data"
remote-url="{{route('admin.categories.api') . '?for=product-categories'}}"
option-label="name.{{app()->getLocale()}}"
option-value="id"
choices
/>
<x-splade-input label="{{__('Name [AR]')}}" placeholder="{{__('Name [AR]')}}" @input="form.slug = form.name?.ar.replaceAll(' ', '-').toLowerCase()" name="name.ar" />
<x-splade-input label="{{__('Name [EN]')}}" placeholder="{{__('Name [EN]')}}" @input="form.slug = form.name?.en.replaceAll(' ', '-').toLowerCase()" name="name.en" />
<x-splade-input label="{{__('Slug')}}" placeholder="{{__('Slug')}}" name="slug" />
<div class="flex justify-between gap-4">
<x-splade-input class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-color label="{{__('Color')}}" placeholder="{{__('Color')}}" name="color" />
</div>
<div class="flex justify-between gap-4">
<x-splade-checkbox class="w-full" label="{{__('Activated')}}" name="activated" />
<x-splade-checkbox class="w-full" label="{{__('Show In Menu')}}" name="menu" />
</div>
<x-splade-select
name="parent_id"
:label="__('Parent')"
:placeholder="__('Parent')"
remote-root="data"
remote-url="{{route('admin.categories.api') . '?for=product-categories'}}"
option-label="name.{{app()->getLocale()}}"
option-value="id"
choices
/>
<x-splade-input label="{{__('Name [AR]')}}" placeholder="{{__('Name [AR]')}}" @input="form.slug = form.name?.ar.replaceAll(' ', '-').toLowerCase()" name="name.ar" />
<x-splade-input label="{{__('Name [EN]')}}" placeholder="{{__('Name [EN]')}}" @input="form.slug = form.name?.en.replaceAll(' ', '-').toLowerCase()" name="name.en" />
<x-splade-input label="{{__('Slug')}}" placeholder="{{__('Slug')}}" name="slug" />
<div class="flex justify-between gap-4">
<x-tomato-admin-icon class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-color label="{{__('Color')}}" placeholder="{{__('Color')}}" name="color" />
</div>
<div class="flex justify-between gap-4">
<x-splade-checkbox class="w-full" label="{{__('Activated')}}" name="activated" />
<x-splade-checkbox class="w-full" label="{{__('Show In Menu')}}" name="menu" />
</div>

<div class="flex justify-start gap-4">
<x-tomato-admin-submit spinner :label="__('Save')" />
@if($item)
<x-tomato-admin-button danger :href="route('admin.products.category.delete', $item->id)"
confirm="{{trans('tomato-admin::global.crud.delete-confirm')}}"
confirm-text="{{trans('tomato-admin::global.crud.delete-confirm-text')}}"
confirm-button="{{trans('tomato-admin::global.crud.delete-confirm-button')}}"
cancel-button="{{trans('tomato-admin::global.crud.delete-confirm-cancel-button')}}"
method="delete" label="{{__('Delete')}}" />
@endif
<x-tomato-admin-button secondary @click.prevent="modal.close" :label="__('Cancel')" />
</div>
</x-splade-form>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/product-options/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x-tomato-translation label="{{__('Name')}}" placeholder="{{__('Name')}}" name="name" />
<x-splade-input label="{{__('Key')}}" placeholder="{{__('Key')}}" name="key" />
<div class="flex justify-between gap-4">
<x-splade-input class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-icon class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-color label="{{__('Color')}}" placeholder="{{__('Color')}}" name="color" />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/product-tags/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<x-splade-input label="{{__('Name [EN]')}}" placeholder="{{__('Name [EN]')}}" @input="form.slug = form.name?.en.replaceAll(' ', '-').toLowerCase()" name="name.en" />
<x-splade-input label="{{__('Slug')}}" placeholder="{{__('Slug')}}" name="slug" />
<div class="flex justify-between gap-4">
<x-splade-input class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-icon class="w-full" label="{{__('Icon')}}" placeholder="{{__('Icon')}}" name="icon" />
<x-tomato-admin-color label="{{__('Color')}}" placeholder="{{__('Color')}}" name="color" />
</div>
<div class="flex justify-between gap-4">
Expand Down
34 changes: 34 additions & 0 deletions resources/views/products/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,40 @@
<div class="pb-12">
<div class="mx-auto">
<x-splade-table :for="$table" striped custom-body custom-body-view="tomato-products::products.list">
<x-slot:header>
<div class="grid grid-cols-1 lg:grid-cols-4 gap-4 mb-3">
@foreach($categories as $category)
<div class="relative border border-gray-200 dark:bg-gray-800 dark:border-gray-700 p-4 rounded-lg bg-white @if(isset(request()->get('filter')['category_id']) && request()->get('filter')['category_id'] == $category->id) ring-2 ring-primary-500 @endif">
<x-splade-link :href="route('admin.products.category.edit', $category->id)" modal class="absolute top-3 rtl:right-3 ltr:left-3 text-warning-500">
<i class="bx bx-edit"></i>
</x-splade-link>

<div @click.prevent="table.updateQuery('filter[category_id]', @js($category->id))" class="flex flex-col items-center justify-center cursor-pointer">
@if($category->getMedia('image')->first())
<div class="bg-cover w-16 h-16 bg-center rounded-full border-gray-200 dark:border-gray-700" style="background-image: url('{{$category->getMedia('image')->first()?->getUrl()}}')">

</div>
@elseif($category->icon)
<div class="w-16 h-16 flex flex-col items-center justify-center">
<i class="{{$category->icon}} bx-lg" style="color: {{$category->color}}"></i>
</div>
@else
<div class="w-16 h-16 flex flex-col items-center justify-center">
<i class="bx bxs-category bx-lg text-primary-500"></i>
</div>
@endif

<h1 class="font-bold text-2xl">{{$category->name}}</h1>
<h1 class="text-gray-400 text-sm">{{\TomatoPHP\TomatoProducts\Models\Product::where('category_id', $category->id)->count()}} {{__('Product')}}</h1>
</div>
</div>
@endforeach
<x-splade-link modal :href="route('admin.products.category.create')" class="border border-gray-200 dark:border-gray-700 px-4 py-8 rounded-lg bg-primary-500 text-white flex flex-col items-center justify-center">
<i class="bx bx-plus-circle bx-lg"></i>
<h1 class="font-bold text-xl">{{__('Create Category')}}</h1>
</x-splade-link>
</div>
</x-slot:header>
<x-slot:actions>
<x-tomato-admin-table-action secondary icon="bx bx-package" href="{{route('admin.products.options.index')}}" label="{{__('Product Options')}}" />
<x-tomato-admin-table-action secondary icon="bx bx-category" href="{{route('admin.products.category.index')}}" label="{{__('Product Categories')}}" />
Expand Down
15 changes: 15 additions & 0 deletions resources/views/products/inventory-attach.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<x-tomato-admin-container label="{{__('Attach Products To Inventory Reqeuest')}}">
<x-splade-form :default="['ids'=> $ids]" class="flex flex-col gap-4" action="{{route('admin.inventories.create')}}" method="get">
<h1>{{__('The Following Products will be attached to new inventory request')}}</h1>
<div>
@foreach($products as $product)
<div>{{$product->name}} [SKU: {{$product->sku}}]</div>
<br>
@endforeach
</div>
<div class="flex justify-start gap-2 pt-3">
<x-tomato-admin-submit label="{{__('Confirm')}}" :spinner="true" />
<x-tomato-admin-button secondary @click.prevent="modal.close" label="{{__('Cancel')}}"/>
</div>
</x-splade-form>
</x-tomato-admin-container>
64 changes: 41 additions & 23 deletions resources/views/products/list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ class="rounded dark:bg-gray-500 border-gray-300 dark:border-gray-600 text-indigo
:label="__('Product Reviews')"
icon="bx bx-star"
/>
@if(class_exists(\TomatoPHP\TomatoInventory\Facades\TomatoInventory::class))
<li class="whitespace-nowrap py-2 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-gray-900 px-4">
<a target="_blank" href="{{route('admin.inventories.print.products')}}?product_id={{$item->id}}"
class="relative flex justify-center gap-2 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 text-gray-600 dark:text-gray-200 hover:text-black text-gray-600 dark:text-gray-200 hover:text-primary-500">
<div class="flex flex-col items-center justify-center">
<i class="bx bxs-chart text-sm"></i>
</div>
<div class="text-sm"> {{__('Print Product Inventory Report')}} </div>
</a>
</li>
@endif
@if(class_exists(\TomatoPHP\TomatoOrders\Facades\TomatoOrdering::class))
<li class="whitespace-nowrap py-2 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-gray-900 px-4">
<a target="_blank" href="{{route('admin.products.print.orders')}}?product_id={{$item->id}}"
class="relative flex justify-center gap-2 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 text-gray-600 dark:text-gray-200 hover:text-black text-gray-600 dark:text-gray-200 hover:text-primary-500">
<div class="flex flex-col items-center justify-center">
<i class="bx bxs-rocket text-sm"></i>
</div>
<div class="text-sm"> {{__('Print Product Orders Report')}} </div>
</a>
</li>
@endif
<x-tomato-admin-dropdown-item
:href="route('admin.products.destroy', $item->id)"
confirm="{{trans('tomato-admin::global.crud.delete-confirm')}}"
Expand Down Expand Up @@ -213,26 +235,17 @@ class="rounded dark:bg-gray-500 border-gray-300 dark:border-gray-600 text-indigo
</div>
</div>
<div class="flex flex-col gap-4 px-4 my-4">
<div class="grid grid-cols-8 gap-4">
<x-tomato-admin-tooltip :class="!auth('web')->user()->can('admin.products.update') ? 'col-span-8' : 'col-span-5'" text="{{__('Product Main Category')}}">
<x-splade-select
:disabled="!auth('web')->user()->can('admin.products.update')"
name="category_id"
:options="\TomatoPHP\TomatoCategory\Models\Category::where('for', 'product-categories')->get()"
option-label="name"
option-value="id"
choices
:placeholder="__('Categories')"
/>
</x-tomato-admin-tooltip>
@if(auth('web')->user()->can('admin.products.update'))
<div class="col-span-3">
<x-splade-link modal :href="route('admin.products.category.create')" class="flex flex-col items-center justify-center rounded-lg border border-gray-300 dark:border-gray-700 shadow-sm dark:text-white py-2 px-4 h-full w-full text-center text-sm">
{{ __('Add Category') }}
</x-splade-link>
</div>
@endif
</div>
<x-tomato-admin-tooltip :class="!auth('web')->user()->can('admin.products.update') ? 'col-span-8' : 'col-span-5'" text="{{__('Product Main Category')}}">
<x-splade-select
:disabled="!auth('web')->user()->can('admin.products.update')"
name="category_id"
:options="\TomatoPHP\TomatoCategory\Models\Category::where('for', 'product-categories')->get()"
option-label="name"
option-value="id"
choices
:placeholder="__('Categories')"
/>
</x-tomato-admin-tooltip>
</div>
@if(auth('web')->user()->can('admin.products.update'))
<button class="py-3 px-4 border-t border-gray-200 dark:border-gray-700 font-bold w-full text-center bg-primary-500 dark:bg-gray-700 text-white text-sm rounded-b-lg" type="submit">
Expand All @@ -249,9 +262,14 @@ class="rounded dark:bg-gray-500 border-gray-300 dark:border-gray-600 text-indigo
@if(isset($emptyState) && !!$emptyState)
{{ $emptyState }}
@else
<p class="text-gray-700 px-6 py-12 font-medium text-sm text-center">
{{ __('There are no items to show.') }}
</p>
<div class="py-12">
<div class="flex flex-col justify-center items-center my-2 text-danger-500">
<x-heroicon-s-x-circle class="w-16 h-16" />
</div>
<p class="text-gray-700 dark:text-gray-200 px-6 font-medium text-sm text-center">
{{ __('There are no items to show.') }}
</p>
</div>
@endif
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions resources/views/products/order-attach.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<x-tomato-admin-container label="{{__('Attach Products To New Order')}}">
<x-splade-form :default="['ids'=> $ids]" class="flex flex-col gap-4" action="{{route('admin.orders.create')}}" method="get">
<h1>{{__('The Following Products will be attached to new order')}}</h1>
<div>
@foreach($products as $product)
<div>{{$product->name}} [SKU: {{$product->sku}}]</div>
<br>
@endforeach
</div>
<div class="flex justify-start gap-2 pt-3">
<x-tomato-admin-submit label="{{__('Confirm')}}" :spinner="true" />
<x-tomato-admin-button secondary @click.prevent="modal.close" label="{{__('Cancel')}}"/>
</div>
</x-splade-form>
</x-tomato-admin-container>
Loading

0 comments on commit 3065b40

Please sign in to comment.