first commit

This commit is contained in:
2025-03-05 20:44:45 -06:00
commit 06dbf8e2a7
74 changed files with 9681 additions and 0 deletions

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\inventoryStockLevels;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class inventoryStockLevelsIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.inventory-items.inventory-items-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\InventoryMovements;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class InventoryMovementsIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.inventory-movements.inventory-movements-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\InventoryStock;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class InventoryStockIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.inventory-stock.inventory-stock-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\Materials;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class MaterialsIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.materials.materials-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\ProductCatalogs;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class ProductCatalogsIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.product-catalogs.product-catalogs-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\ProductCategories;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class ProductCategoriesIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.product-categories.product-categories-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\ProductReceipts;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class ProductReceiptsIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.product-receipts.product-receipts-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\Products;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class ProductsIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.products.products-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\PurchaseOrders;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class PurchaseOrdersIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.purchase-orders.purchase-orders-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\WarehouseMovements;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class WarehouseMovementsIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.warehouse-movements.warehouse-movements-index');
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\WarehouseTransfers;
use Koneko\SatCatalogs\Models\RegimenFiscal;
use Koneko\SatCatalogs\Models\UsoCfdi;
use Koneko\VuexyAdmin\Models\User;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class WarehouseTransfersIndex extends Component
{
public $tipo_persona_options, $estado_options, $status_options;
public $status_list, $status_list_class;
public $userId,
$name,
$email,
$cargo,
$rfc,
$nombre_fiscal,
$c_regimen_fiscal,
$domicilio_fiscal,
$c_uso_cfdi,
$roles,
$password,
$status,
$is_prospect,
$is_customer,
$is_provider,
$is_user;
public $statuses;
public $rows_roles = [];
public $roles_options = [];
public $uso_cfdi_options = [];
public $regimen_fiscal_options = [];
public $roles_html_select;
public function mount()
{
$this->tipo_persona_options = [
User::TIPO_RFC_FISICA => User::$tipoRfcList[User::TIPO_RFC_FISICA],
User::TIPO_RFC_MORAL => User::$tipoRfcList[User::TIPO_RFC_MORAL],
User::TIPO_RFC_PUBLICO => User::$tipoRfcList[User::TIPO_RFC_PUBLICO],
];
$this->estado_options = DB::table('sat_estado')
->select('sat_estado.c_estado', 'sat_estado.nombre_del_estado')
->join('sat_codigo_postal', 'sat_estado.c_estado', '=', 'sat_codigo_postal.c_estado')
->join('users', 'users.domicilio_fiscal', '=', 'sat_codigo_postal.c_codigo_postal')
->distinct()
->orderBy('sat_estado.c_estado')
->pluck('sat_estado.nombre_del_estado', 'sat_estado.c_estado');
$this->status_options = $this->status_list = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
//$this->status = User::STATUS_ENABLED;
$this->status_list_class = User::$statusListClass;
$this->statuses = [
User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]],
User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]],
User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]],
];
$roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get();
$this->roles_html_select = "<select id=\"UserRole\" class=\"form-select text-capitalize\"><option value=\"\"> Selecciona un rol </option>";
foreach ($roles as $role) {
$this->rows_roles[$role->name] = "<span class=\"badge bg-label-" . $role->style . " mx-1\">" . $role->name . "</span>";
if (Auth::user()->hasRole('SuperAdmin') || $role->name != 'SuperAdmin') {
$this->roles_html_select .= "<option value=\"" . $role->name . "\" class=\"text-capitalize\">" . $role->name . "</option>";
$this->roles_options[$role->name] = $role->name;
}
}
$this->roles_html_select .= "</select>";
$this->status_options = [
User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED],
User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED],
];
$this->uso_cfdi_options = UsoCfdi::selectList();
$this->regimen_fiscal_options = RegimenFiscal::selectList();
}
public function render()
{
return view('vuexy-warehouse::livewire.warehouse-transfers.warehouse-transfers-index');
}
}

View File

@ -0,0 +1,221 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\Warehouses;
use Koneko\VuexyAdmin\Livewire\Table\AbstractIndexComponent;
use Koneko\VuexyWarehouse\Models\Warehouse;
use Koneko\VuexyStoreManager\Services\StoreCatalogService;
class WarehouseIndex extends AbstractIndexComponent
{
public $store_id;
public $storeOptions = [];
/**
* Retorna la clase del modelo asociado.
*
* @return string
*/
protected function model(): string
{
return Warehouse::class;
}
/**
* Configura el encabezado (header) de la tabla (las columnas).
*
* @return array
*/
protected function columns(): array
{
return [
'action' => 'Acciones',
'store_code' => 'Código de Tienda',
'store_name' => 'Nombre de la Tienda',
'work_center_code' => 'Código del Centro de Trabajo',
'work_center_name' => 'Nombre del Centro de Trabajo',
'code' => 'Código de Almacén',
'name' => 'Nombre del Almacén',
'description' => 'Descripción',
'manager_name' => 'Encargado',
'pais' => 'País',
'estado' => 'Estado',
'localidad' => 'Localidad',
'municipio' => 'Municipio',
'codigo_postal' => 'Código Postal',
'colonia' => 'Colonia',
'direccion' => 'Dirección',
'tel' => 'Teléfono',
'tel2' => 'Teléfono Alternativo',
'priority' => 'Prioridad',
'status' => 'Estatus',
'created_at' => 'Fecha de Creación',
'updated_at' => 'Última Actualización',
];
}
/**
* Define los formatos de cada columna (se inyectará en $bt_datatable['format']).
*
* @return array
*/
protected function format(): array
{
return [
'action' => [
'formatter' => 'warehouseActionFormatter',
'onlyFormatter' => true,
],
'store_code' => [
'formatter' => [
'name' => 'dynamicBadgeFormatter',
'params' => ['color' => 'secondary']
],
'align' => 'center',
'visible' => false,
],
'work_center_code' => [
'formatter' => [
'name' => 'dynamicBadgeFormatter',
'params' => ['color' => 'secondary']
],
'align' => 'center',
'visible' => false,
],
'work_center_name' => [
'visible' => false,
],
'code' => [
'formatter' => [
'name' => 'dynamicBadgeFormatter',
'params' => ['color' => 'secondary'],
],
'align' => 'center',
'switchable' => false,
],
'name' => [
'switchable' => false,
],
'description' => [
'visible' => false,
],
'manager_name' => [
'formatter' => 'managerFormatter',
],
'tel' => [
'formatter' => 'telFormatter',
'align' => 'center',
],
'tel2' => [
'formatter' => 'telFormatter',
'align' => 'center',
'visible' => false,
],
'pais' => [
'align' => 'center',
'visible' => false,
],
'estado' => [
'formatter' => 'textNowrapFormatter',
'visible' => false,
],
'localidad' => [
'formatter' => 'textNowrapFormatter',
'visible' => false,
],
'municipio' => [
'formatter' => 'textNowrapFormatter',
'visible' => false,
],
'codigo_postal' => [
'align' => 'center',
'visible' => false,
],
'colonia' => [
'formatter' => 'textNowrapFormatter',
'visible' => false,
],
'direccion' => [
'formatter' => 'direccionFormatter',
'visible' => false,
],
'priority' => [
'formatter' => 'numberFormatter',
'align' => 'center',
],
'status' => [
'formatter' => [
'name' => 'dynamicBooleanFormatter',
'params' => ['tag' => 'activo']
],
'align' => 'center',
],
'created_at' => [
'formatter' => 'textNowrapFormatter',
'align' => 'center',
'visible' => false,
],
'updated_at' => [
'formatter' => 'textNowrapFormatter',
'align' => 'center',
'visible' => false,
],
];
}
/**
* Retorna la configuración base (común) para la tabla Bootstrap Table.
*
* @return array
*/
protected function bootstraptableConfig(): array
{
return [
'sortName' => 'code',
'exportFileName' => 'Almacenes',
'showFullscreen' => false,
'showPaginationSwitch' => false,
'showRefresh' => false,
'pagination' => false,
];
}
/**
* Retorna la ruta de la vista Blade.
*
* @return string
*/
protected function viewPath(): string
{
// La vista que ya tienes creada para WarehouseIndex
return 'vuexy-warehouse::livewire.warehouses.index';
}
/**
* Métodos que necesites sobreescribir o extender.
*/
public function mount(): void
{
parent::mount();
// Cargar opciones de tienda, por ejemplo:
$storeCatalogService = app(StoreCatalogService::class);
$this->storeOptions = $storeCatalogService->searchCatalog('stores', '', ['limit' => -1]);
}
/**
* Puedes agregar lógica de filtrado específica para warehouses,
* si lo requieres, sobrescribiendo el método applyFilters del padre.
*/
protected function applyFilters($criteria = [])
{
$query = parent::applyFilters($criteria);
// Ejemplo de aplicar filtro por store_id
if ($this->store_id) {
$query->where('store_id', $this->store_id);
}
return $query;
}
}

View File

@ -0,0 +1,219 @@
<?php
namespace Koneko\VuexyWarehouse\Livewire\Warehouses;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
use Koneko\VuexyAdmin\Livewire\Form\AbstractFormOffCanvasComponent;
use Koneko\VuexyContacts\Services\ContactCatalogService;
use Koneko\VuexyStoreManager\Services\StoreCatalogService;
use Koneko\VuexyWarehouse\Models\Warehouse;
/**
* Class WarehouseOffcanvasForm
*
* Componente Livewire para gestionar almacenes.
* Extiende la clase AbstractFormOffCanvasComponent e implementa validaciones dinámicas,
* manejo de formularios, eventos y actualizaciones en tiempo real.
*
* @package Koneko\VuexyWarehouse\Livewire\Warehouses
*/
class WarehouseOffcanvasForm extends AbstractFormOffCanvasComponent
{
/**
* Propiedades del formulario relacionadas con el almacén.
*/
public $id, $store_id, $work_center_id, $code, $name, $description,
$manager_id, $tel, $tel2, $priority, $status, $confirmDeletion;
/**
* Listas de opciones para selects en el formulario.
*/
public $store_options = [],
$work_center_options = [],
$manager_options = [];
/**
* Eventos de escucha de Livewire.
*
* @var array
*/
protected $listeners = [
'editWarehouse' => 'loadFormModel',
'confirmDeletionWarehouse' => 'loadFormModelForDeletion',
];
/**
* Definición de tipos de datos que se deben castear.
*
* @var array
*/
protected $casts = [
'status' => 'boolean',
];
/**
* Define el modelo Eloquent asociado con el formulario.
*
* @return string
*/
protected function model(): string
{
return Warehouse::class;
}
/**
* Define los campos del formulario.
*
* @return array<string, mixed>
*/
protected function fields(): array
{
return (new Warehouse())->getFillable();
}
/**
* Valores por defecto para el formulario.
*
* @return array
*/
protected function defaults(): array
{
return [
'priority' => 0,
'status' => true,
];
}
/**
* Campo que se debe enfocar cuando se abra el formulario.
*
* @return string
*/
protected function focusOnOpen(): string
{
return 'code';
}
/**
* Define reglas de validación dinámicas basadas en el modo actual.
*
* @param string $mode El modo actual del formulario ('create', 'edit', 'delete').
* @return array
*/
protected function dynamicRules(string $mode): array
{
switch ($mode) {
case 'create':
case 'edit':
return [
'store_id' => ['required', 'integer', 'exists:stores,id'],
'work_center_id' => ['nullable', 'integer', 'exists:store_work_centers,id'],
'code' => ['required', 'string', 'max:16', Rule::unique('warehouses', 'code')->ignore($this->id)],
'name' => ['required', 'string', 'max:96'],
'description' => ['nullable', 'string', 'max:1024'],
'manager_id' => ['nullable', 'integer', 'exists:users,id'],
'tel' => ['nullable', 'regex:/^[0-9+\-\s]+$/', 'max:20'],
'tel2' => ['nullable', 'regex:/^[0-9+\-\s]+$/', 'max:20'],
'priority' => ['nullable', 'numeric', 'between:0,99'],
'status' => ['nullable', 'boolean'],
];
case 'delete':
return [
'confirmDeletion' => 'accepted', // Asegura que el usuario confirme la eliminación
];
default:
return [];
}
}
// ===================== VALIDACIONES =====================
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
*/
protected function attributes(): array
{
return [
'code' => 'código de almacén',
'name' => 'nombre del almacén',
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
protected function messages(): array
{
return [
'store_id.required' => 'El almacén debe estar asociado a un negocio.',
'code.required' => 'El código del almacén es obligatorio.',
'code.unique' => 'Este código ya está en uso por otro almacén.',
'name.required' => 'El nombre del almacén es obligatorio.',
];
}
/**
* Carga el formulario con datos del almacén y actualiza las opciones dinámicas.
*
* @param int $id
*/
public function loadFormModel($id): void
{
parent::loadFormModel($id);
$this->work_center_options = $this->store_id
? DB::table('store_work_centers')
->where('store_id', $this->store_id)
->pluck('name', 'id')
->toArray()
: [];
}
/**
* Carga el formulario para eliminar un almacén, actualizando las opciones necesarias.
*
* @param int $id
*/
public function loadFormModelForDeletion($id): void
{
parent::loadFormModelForDeletion($id);
$this->work_center_options = DB::table('store_work_centers')
->where('store_id', $this->store_id)
->pluck('name', 'id')
->toArray();
}
/**
* Define las opciones de los selectores desplegables.
*
* @return array
*/
protected function options(): array
{
$storeCatalogService = app(StoreCatalogService::class);
$contactCatalogService = app(ContactCatalogService::class);
return [
'store_options' => $storeCatalogService->searchCatalog('stores', '', ['limit' => -1]),
'manager_options' => $contactCatalogService->searchCatalog('users', '', ['limit' => -1]),
];
}
/**
* Ruta de la vista asociada con este formulario.
*
* @return string
*/
protected function viewPath(): string
{
return 'vuexy-warehouse::livewire.warehouses.form-offcanvas';
}
}