first commit

This commit is contained in:
2025-03-05 20:43:35 -06:00
commit aa938a3cab
47 changed files with 4388 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
namespace Koneko\VuexyStoreManager\Http\Controllers;
use App\Http\Controllers\Controller;
class CompanyController extends Controller
{
/**
* Display the specified resource.
*/
public function index()
{
return view('vuexy-store-manager::company.index');
}
/**
* Show the form for editing the specified resource.
*/
public function edit()
{
return view('vuexy-store-manager::company.edit');
}
}

View File

@ -0,0 +1,158 @@
<?php
namespace Koneko\VuexyStoreManager\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Koneko\VuexyStoreManager\Models\Store;
use Koneko\VuexyAdmin\Queries\GenericQueryBuilder;
class StoreController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
if ($request->ajax()) {
$bootstrapTableIndexConfig = [
'table' => 'stores',
'columns' => [
'stores.id',
'stores.code',
'stores.name',
'stores.description',
'stores.c_codigo_postal AS codigo_postal',
'sat_pais.descripcion AS pais',
DB::raw("CONCAT_WS(' ', users.name, users.last_name) AS manager_name"),
'users.email AS manager_email',
'sat_estado.nombre_del_estado AS estado',
'sat_localidad.descripcion AS localidad',
'sat_municipio.descripcion AS municipio',
'sat_colonia.nombre_del_asentamiento AS colonia',
DB::raw("CONCAT_WS(' ', COALESCE(stores.direccion, ''), COALESCE(stores.num_ext, ''), IF(stores.num_int IS NOT NULL, CONCAT('Int ', stores.num_int), '')) AS direccion"),
'stores.lat',
'stores.lng',
'stores.email',
'stores.tel',
'stores.tel2',
'stores.rfc',
'stores.nombre_fiscal',
'sat_regimen_fiscal.descripcion AS regimen_fiscal',
'stores.domicilio_fiscal',
'stores.show_on_website',
'stores.enable_ecommerce',
'stores.status',
'stores.created_at',
'stores.updated_at',
],
'joins' => [
[
'table' => 'sat_pais',
'first' => 'stores.c_pais',
'second' => 'sat_pais.c_pais',
'type' => 'leftJoin',
],
[
'table' => 'sat_estado',
'first' => 'stores.c_estado',
'second' => 'sat_estado.c_estado',
'type' => 'leftJoin',
'and' => [
'stores.c_pais = sat_estado.c_pais',
],
],
[
'table' => 'sat_localidad',
'first' => 'stores.c_localidad',
'second' => 'sat_localidad.c_localidad',
'type' => 'leftJoin',
'and' => [
'stores.c_estado = sat_localidad.c_estado',
],
],
[
'table' => 'sat_municipio',
'first' => 'stores.c_municipio',
'second' => 'sat_municipio.c_municipio',
'type' => 'leftJoin',
'and' => [
'stores.c_estado = sat_municipio.c_estado',
],
],
[
'table' => 'sat_colonia',
'first' => 'stores.c_colonia',
'second' => 'sat_colonia.c_colonia',
'type' => 'leftJoin',
'and' => [
'stores.c_codigo_postal = sat_colonia.c_codigo_postal',
],
],
[
'table' => 'sat_regimen_fiscal',
'first' => 'stores.c_regimen_fiscal',
'second' => 'sat_regimen_fiscal.c_regimen_fiscal',
'type' => 'leftJoin',
],
[
'table' => 'users',
'first' => 'stores.manager_id',
'second' => 'users.id',
'type' => 'leftJoin',
],
],
'filters' => [
'search' => ['stores.name', 'stores.code', 'users.name', 'users.email'], // Búsqueda por nombre, código o manager
],
'sort_column' => 'stores.name', // Ordenamiento por defecto
'default_sort_order' => 'asc', // Orden ascendente por defecto
];
return (new GenericQueryBuilder($request, $bootstrapTableIndexConfig))->getJson();
}
return view('vuexy-store-manager::store.index');
}
/**
* Show the crud for creating a new resource.
*/
public function create()
{
return view('vuexy-store-manager::store.crud')
->with('mode', 'create')
->with('store', null);
}
/**
* Display the specified resource.
*/
public function show(Store $store)
{
return view('vuexy-store-manager::store.crud', compact('store'));
}
/**
* Show the crud for editing the specified resource.
*/
public function edit(Store $store)
{
//$store = Store::findOrFail($id);
return view('vuexy-store-manager::store.crud', compact('store'))->with('mode', 'edit');
}
/**
* Show the crud for editing the specified resource.
*/
public function delete(Store $store)
{
return view('vuexy-store-manager::store.crud', compact('store'))->with('mode', 'delete');
}
}

View File

@ -0,0 +1,142 @@
<?php
namespace Koneko\VuexyStoreManager\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Koneko\VuexyAdmin\Helpers\CatalogHelper;
use Koneko\VuexyAdmin\Queries\GenericQueryBuilder;
use Koneko\SatCatalogs\Http\Controllers\SatCatalogController;
use Koneko\VuexyStoreManager\Models\StoreWorkCenter;
class WorkCenterController extends SatCatalogController
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
if ($request->ajax()) {
$bootstrapTableIndexConfig = [
'table' => 'store_work_centers',
'columns' => [
'store_work_centers.id',
'stores.code AS stores_code',
'stores.name AS stores_name',
'store_work_centers.code',
'store_work_centers.name',
'store_work_centers.description',
'store_work_centers.manager_id',
DB::raw("CONCAT_WS(' ', users.name, users.last_name) AS manager_name"),
'users.email AS manager_email',
'store_work_centers.tel',
'store_work_centers.tel2',
'stores.c_codigo_postal AS codigo_postal',
'sat_pais.descripcion AS pais',
'sat_estado.nombre_del_estado AS estado',
'sat_localidad.descripcion AS localidad',
'sat_municipio.descripcion AS municipio',
'sat_colonia.nombre_del_asentamiento AS colonia',
DB::raw("CONCAT_WS(' ', COALESCE(stores.direccion, ''), COALESCE(stores.num_ext, ''), IF(stores.num_int IS NOT NULL, CONCAT('Int ', stores.num_int), '')) AS direccion"),
'store_work_centers.lat',
'store_work_centers.lng',
'store_work_centers.status',
'store_work_centers.created_at',
'store_work_centers.updated_at',
],
'joins' => [
[
'table' => 'stores',
'first' => 'store_work_centers.store_id',
'second' => 'stores.id',
'type' => 'join', // INNER JOIN
],
[
'table' => 'sat_pais',
'first' => 'stores.c_pais',
'second' => 'sat_pais.c_pais',
'type' => 'leftJoin', // LEFT OUTER JOIN
],
[
'table' => 'sat_estado',
'first' => 'stores.c_estado',
'second' => 'sat_estado.c_estado',
'and' => [
'stores.c_pais = sat_estado.c_pais',
],
'type' => 'leftJoin',
],
[
'table' => 'sat_localidad',
'first' => 'stores.c_localidad',
'second' => 'sat_localidad.c_localidad',
'and' => [
'stores.c_estado = sat_localidad.c_estado',
],
'type' => 'leftJoin',
],
[
'table' => 'sat_municipio',
'first' => 'stores.c_municipio',
'second' => 'sat_municipio.c_municipio',
'and' => [
'stores.c_estado = sat_municipio.c_estado',
],
'type' => 'leftJoin',
],
[
'table' => 'sat_colonia',
'first' => 'stores.c_colonia',
'second' => 'sat_colonia.c_colonia',
'and' => [
'stores.c_codigo_postal = sat_colonia.c_codigo_postal',
],
'type' => 'leftJoin',
],
[
'table' => 'users',
'first' => 'store_work_centers.manager_id',
'second' => 'users.id',
'type' => 'leftJoin',
],
],
'filters' => [
'search' => [
'store_work_centers.code',
'store_work_centers.name',
'stores.code',
'stores.name',
],
],
'sort_column' => 'store_work_centers.name', // Columna por defecto para ordenamiento
'default_sort_order' => 'asc', // Orden por defecto
];
return (new GenericQueryBuilder($request, $bootstrapTableIndexConfig))->getJson();
}
return view('vuexy-store-manager::work-center.index');
}
public function ajax(\Illuminate\Http\Request $request)
{
$options = [
'id' => $request->input('id', null),
'searchTerm' => $request->input('searchTerm', null),
'limit' => $request->input('limit', 20),
'keyField' => 'id',
'valueField' => 'custom_name', // Usamos un alias que agregaremos con DB::raw()
'responseType' => $request->input('responseType', 'select2'),
'filters' => [
'store_id' => $request->input('store_id', null),
]
];
// Aquí añadimos la expresión de concatenación con un alias
$query = StoreWorkCenter::query()
->select('store_work_centers.*', DB::raw("CONCAT_WS(' - ', code, name) AS custom_name"));
return CatalogHelper::ajaxFlexibleResponse($query, $options);
}
}