File manager - Edit - /var/www/payraty/inventory_main/resources/views/admin/warehouses/edit.blade.php
Back
@extends('admin.layouts.master') @section('content') <div class="page-title-box"> <div class="row align-items-center"> <div class="col-sm-6"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#" class="ic-javascriptVoid">{{ __('custom.warehouse') }}</a></li> <li class="breadcrumb-item active">{{ __('custom.edit_warehouse') }}</li> </ol> </div> </div> </div> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-body"> <h4 class="header-title">{{ __('custom.edit_warehouse') }}</h4> <form class="form-validate" action="{{ route('admin.warehouses.update', $warehouse->id) }}" method="POST"> @csrf @method('PUT') <div class="row"> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="">{{__('custom.warehouse_name')}} <span class="error">*</span></label> <input type="text" name="name" class="form-control" value="{{ $warehouse->name }}" required> @error('name') <p class="error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="">Number of shelves<span class="error"></span></label> <input type="text" name="shelf" class="form-control" value="{{ $warehouse->shelf }}" readonly> @error('shelf') <p class="error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="">{{__('custom.email')}}</label> <input type="email" name="email" class="form-control" value="{{ $warehouse->email }}"> @error('email') <p class="error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="">{{__('custom.phone')}}</label> <input id="phone" type="text" name="phone" class="form-control w-100 phone" value="{{ $warehouse->phone ?? '+1' }}"> @error('phone') <p class="error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="">{{__('custom.company_name')}}</label> <input type="text" name="company_name" class="form-control" value="{{ $warehouse->company_name }}"> @error('company_name') <p class="error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="address_1">{{__('custom.address_1')}}</label> <input type="text" class="form-control" name="address_1" value="{{ $warehouse->address_1 }}"> @error('address_1') <p class=" error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="address_2">{{__('custom.address_2')}}</label> <input type="text" class="form-control" name="address_2" value="{{ $warehouse->address_2 }}"> @error('address_2') <p class=" error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label for="">{{__('custom.priority')}} <p class="p-0 m-0"> <small> {{__('custom.warehouse_priority_message')}} </small> </p> </label> <input type="number" name="priority" class="form-control" value="{{ $warehouse->priority }}"> @error('priority') <p class="error">{{ $message }}</p> @enderror </div> <div class="form-group col-sm-6 col-lg-6 col-xl-4"> <label class="text-white">{{__('custom.default')}}</label> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="is_default" @if($warehouse->is_default) checked @endif value="1" id="is_default"> <label class="custom-control-label" for="is_default">{{__('custom.is_default_warehouse')}}</label> </div> @error('is_default') <p class="error">{{ $message }}</p> @enderror </div> <div class="form-group"> <label class="d-block mb-3">{{ __('custom.status') }} <span class="error">*</span></label> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" id="status_yes" value="{{ \App\Models\Warehouse::STATUS_ACTIVE }}" name="status" class="custom-control-input" @if(\App\Models\Warehouse::STATUS_ACTIVE==$warehouse->status) checked @endif> <label class="custom-control-label" for="status_yes">{{__('custom.active')}}</label> </div> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" id="status_no" value="{{ \App\Models\Warehouse::STATUS_INACTIVE }}" name="status" class="custom-control-input" @if(\App\Models\Warehouse::STATUS_INACTIVE==$warehouse->status) checked @endif> <label class="custom-control-label" for="status_no">{{__('custom.inactive')}}</label> </div> @error('status') <p class="error">{{ $message }}</p> @enderror </div> </div> <div class="form-group"> <div> <button class="btn btn-primary waves-effect waves-lightml-2" type="submit"> <i class="fa fa-save"></i> <span>{{ __('custom.submit') }}</span> </button> <a class="btn btn-danger waves-effect" href="{{ route('admin.warehouses.index') }}"> <i class="fa fa-times"></i> <span>{{ __('custom.cancel') }}</span> </a> </div> </div> </form> <!-- Shelves Section --> <div class="card mt-4"> <div class="card-header d-flex justify-content-between align-items-center"> <h5 class="card-title mb-0">Existing Shelves</h5> <button type="button" class="btn btn-sm btn-success" id="addShelfBtn"> <i class="fa fa-plus"></i> Add New Shelf </button> </div> <div class="card-body"> @if($warehouse->shelves && count($warehouse->shelves) > 0) <div class="table-responsive"> <table class="table table-bordered table-striped"> <thead> <tr> <th>Shelf Number</th> <th>Name</th> <th>Actions</th> </tr> </thead> <tbody id="shelfTableBody"> @foreach($warehouse->shelves as $index => $shelf) <tr data-shelf-id="{{ $shelf['id'] ?? '' }}"> <td>{{ $index + 1 }}</td> <td>{{ $shelf['name'] ?? 'Shelf ' . ($index + 1) }}</td> <td> <button type="button" class="btn btn-sm btn-danger delete-shelf"> <i class="fa fa-trash"></i> </button> </td> </tr> @endforeach </tbody> </table> </div> @else <div class="alert alert-info" id="noShelvesAlert"> No Existing Shelves Found </div> @endif </div> </div> </div> </div> </div> </div> @endsection @push('style') @endpush @push('script') @endpush <script> document.addEventListener('DOMContentLoaded', function() { function findShelfTableBody() { return document.querySelector('#shelfTableBody') || document.querySelector('table tbody'); } function findNoShelvesAlert() { return document.querySelector('#noShelvesAlert'); } function updateShelfTable(data) { const shelfTableBody = findShelfTableBody(); const noShelvesAlert = findNoShelvesAlert(); const shelvesContainer = document.querySelector('.card-body'); // If table body doesn't exist, we might need to create the entire table if (!shelfTableBody) { const tableHtml = ` <div class="table-responsive"> <table class="table table-bordered table-striped"> <thead> <tr> <th>Shelf Number</th> <th>Name</th> <th>Actions</th> </tr> </thead> <tbody id="shelfTableBody"> <tr data-shelf-id="${data.shelf.id}"> <td>1</td> <td>${data.shelf.name}</td> <td> <button type="button" class="btn btn-sm btn-danger delete-shelf"> <i class="fa fa-trash"></i> </button> </td> </tr> </tbody> </table> </div> `; // Remove no shelves alert if it exists if (noShelvesAlert) { noShelvesAlert.remove(); } // Insert the new table shelvesContainer.innerHTML += tableHtml; } else { // If table already exists, add a new row const newRow = document.createElement('tr'); newRow.dataset.shelfId = data.shelf.id; newRow.innerHTML = ` <td>${shelfTableBody.children.length + 1}</td> <td>${data.shelf.name}</td> <td> <button type="button" class="btn btn-sm btn-danger delete-shelf"> <i class="fa fa-trash"></i> </button> </td> `; // Hide no shelves alert if it exists if (noShelvesAlert) { noShelvesAlert.style.display = 'none'; } // Append new row to table body shelfTableBody.appendChild(newRow); } } const addShelfBtn = document.getElementById('addShelfBtn'); if (addShelfBtn) { addShelfBtn.addEventListener('click', function() { fetch('/admin/warehouses/{{ $warehouse->id }}/add-shelf', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': '{{ csrf_token() }}', } }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { console.log('Shelf added:', data); // Update the table dynamically updateShelfTable(data); }) .catch(error => { console.error('Error:', error); alert('Error adding shelf: ' + error.message); }); }); } // Re-attach delete event listener to handle dynamically added delete buttons document.addEventListener('click', function(event) { const deleteBtn = event.target.closest('.delete-shelf'); if (deleteBtn) { const row = deleteBtn.closest('tr'); const shelfId = row.dataset.shelfId; if (confirm('Are you sure you want to delete this shelf?')) { fetch(`/admin/warehouses/{{ $warehouse->id }}/delete-shelf`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': '{{ csrf_token() }}', }, body: JSON.stringify({ shelf_id: shelfId }) }) .then(response => response.json()) .then(data => { // Remove the row row.remove(); // Reindex the remaining rows const shelfTableBody = findShelfTableBody(); if (shelfTableBody) { Array.from(shelfTableBody.children).forEach((row, index) => { row.querySelector('td:first-child').textContent = index + 1; }); } // If no shelves left, show no shelves alert const noShelvesAlert = document.querySelector('.card-body'); if (shelfTableBody && shelfTableBody.children.length === 0) { noShelvesAlert.innerHTML += ` <div class="alert alert-info" id="noShelvesAlert"> No Existing Shelves Found </div> `; } }) .catch(error => { console.error('Error:', error); alert('Error deleting shelf'); }); } } }); }); </script>
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings