diff --git a/ci4/app/Controllers/Clientes/Clientecontactos.php b/ci4/app/Controllers/Clientes/Clientecontactos.php new file mode 100644 index 00000000..3eedbe45 --- /dev/null +++ b/ci4/app/Controllers/Clientes/Clientecontactos.php @@ -0,0 +1,294 @@ +viewData['pageTitle'] = lang('ClienteContactos.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteContactos.contactoDeCliente')]), + 'clienteContactoEntity' => new ClienteContactoEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewContactoDeClienteList', $viewData); + } + + + public function add() { + + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]).'.'; + $message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['clienteContactoEntity'] = isset($sanitizedData) ? new ClienteContactoEntity($sanitizedData) : new ClienteContactoEntity(); + $this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null); + + $this->viewData['formAction'] = route_to('createContactoDeCliente'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $clienteContactoEntity = $this->model->find($id); + + if ($clienteContactoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ClienteContactos.contactoDeCliente')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $clienteContactoEntity->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $clienteContactoEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]).'.'; + $message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['clienteContactoEntity'] = $clienteContactoEntity; + $this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null); + + $this->viewData['formAction'] = route_to('updateContactoDeCliente', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + + public function datatable() { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = ClienteContactoModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + foreach ($resourceData as $item) : +if (isset($item->apellidos) && strlen($item->apellidos) > 100) : + $item->apellidos = character_limiter($item->apellidos, 100); +endif; + endforeach; + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + protected function getClienteListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])]; + if (!empty($selId)) : + $clienteModel = model('App\Models\Clientes\ClienteModel'); + + $selOption = $clienteModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } + +} diff --git a/ci4/app/Controllers/Clientes/Clientedistribuidores.php b/ci4/app/Controllers/Clientes/Clientedistribuidores.php new file mode 100644 index 00000000..09af41c8 --- /dev/null +++ b/ci4/app/Controllers/Clientes/Clientedistribuidores.php @@ -0,0 +1,332 @@ +viewData['pageTitle'] = lang('ClienteDistribuidores.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteDistribuidores.distribuidorDeCliente')]), + 'clienteDistribuidorEntity' => new ClienteDistribuidorEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewDistribuidorDeClienteList', $viewData); + } + + + public function add() { + + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]).'.'; + $message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['clienteDistribuidorEntity'] = isset($sanitizedData) ? new ClienteDistribuidorEntity($sanitizedData) : new ClienteDistribuidorEntity(); + $this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null); + $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null); + + $this->viewData['formAction'] = route_to('createDistribuidorDeCliente'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $clienteDistribuidorEntity = $this->model->find($id); + + if ($clienteDistribuidorEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $clienteDistribuidorEntity->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $clienteDistribuidorEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]).'.'; + $message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['clienteDistribuidorEntity'] = $clienteDistribuidorEntity; + $this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null); + $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null); + + $this->viewData['formAction'] = route_to('updateDistribuidorDeCliente', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + + public function datatable() { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = ClienteDistribuidorModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + foreach ($resourceData as $item) : +if (isset($item->direccion) && strlen($item->direccion) > 100) : + $item->direccion = character_limiter($item->direccion, 100); +endif;if (isset($item->horarios_entrega) && strlen($item->horarios_entrega) > 100) : + $item->horarios_entrega = character_limiter($item->horarios_entrega, 100); +endif; + endforeach; + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + protected function getComunidadAutonomaListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])]; + if (!empty($selId)) : + $comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); + + $selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } + + + protected function getPaisListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; + if (!empty($selId)) : + $paisModel = model('App\Models\Configuracion\PaisModel'); + + $selOption = $paisModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } + + + protected function getProvinciaListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; + if (!empty($selId)) : + $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); + + $selOption = $provinciaModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } + +} diff --git a/ci4/app/Entities/Clientes/ClienteContactoEntity.php b/ci4/app/Entities/Clientes/ClienteContactoEntity.php new file mode 100644 index 00000000..2c8cb886 --- /dev/null +++ b/ci4/app/Entities/Clientes/ClienteContactoEntity.php @@ -0,0 +1,24 @@ + null, + "cliente_id" => null, + "cargo" => null, + "nombre" => null, + "apellidos" => null, + "telefono" => null, + "email" => null, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "cliente_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Clientes/ClienteDistribuidorEntity.php b/ci4/app/Entities/Clientes/ClienteDistribuidorEntity.php new file mode 100644 index 00000000..0afe9546 --- /dev/null +++ b/ci4/app/Entities/Clientes/ClienteDistribuidorEntity.php @@ -0,0 +1,34 @@ + null, + "nombre" => null, + "cif" => null, + "direccion" => null, + "ciudad" => null, + "cp" => null, + "email" => null, + "pais_id" => null, + "provincia_id" => null, + "comunidad_autonoma_id" => null, + "telefono" => null, + "horarios_entrega" => null, + "persona_contacto" => null, + "precio" => null, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "pais_id" => "int", + "provincia_id" => "int", + "comunidad_autonoma_id" => "?int", + "precio" => "?float", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Language/en/ClienteContactos.php b/ci4/app/Language/en/ClienteContactos.php new file mode 100644 index 00000000..d8ccfb0d --- /dev/null +++ b/ci4/app/Language/en/ClienteContactos.php @@ -0,0 +1,54 @@ + 'Apellidos', + 'cargo' => 'Cargo', + 'cliente' => 'Cliente ID', + 'cliente-contactos' => 'Contactos de cliente', + 'clienteId' => 'Cliente ID', + 'contactoDeCliente' => 'Contacto de cliente', + 'contactoDeClienteList' => 'Contacto de cliente List', + 'contactosDeCliente' => 'Contactos de cliente', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'email' => 'Email', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Cliente Contactos', + 'nombre' => 'Nombre', + 'telefono' => 'Telefono', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'apellidos' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'cargo' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'telefono' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'email' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'valid_email' => 'The {field} field must contain a valid email address.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/en/ClienteDistribuidores.php b/ci4/app/Language/en/ClienteDistribuidores.php new file mode 100644 index 00000000..e03128a4 --- /dev/null +++ b/ci4/app/Language/en/ClienteDistribuidores.php @@ -0,0 +1,86 @@ + 'Cif', + 'ciudad' => 'Ciudad', + 'cliente-distribuidores' => 'Distribuidores de cliente', + 'comunidadAutonoma' => 'Comunidad Autonoma', + 'cp' => 'Cp', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'direccion' => 'Direccion', + 'distribuidorDeCliente' => 'Distribuidor de cliente', + 'distribuidorDeClienteList' => 'Distribuidor de cliente List', + 'distribuidoresDeCliente' => 'Distribuidores de cliente', + 'email' => 'Email', + 'horariosEntrega' => 'Horarios Entrega', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Distribuidores de cliente', + 'nombre' => 'Nombre', + 'pais' => 'Pais', + 'personaContacto' => 'Persona Contacto', + 'precio' => 'Precio', + 'provincia' => 'Provincia', + 'telefono' => 'Telefono', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'cif' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'ciudad' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'cp' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'direccion' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'horarios_entrega' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'persona_contacto' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'precio' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + + ], + + 'telefono' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'email' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'valid_email' => 'The {field} field must contain a valid email address.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/ClienteContactos.php b/ci4/app/Language/es/ClienteContactos.php new file mode 100644 index 00000000..d8ccfb0d --- /dev/null +++ b/ci4/app/Language/es/ClienteContactos.php @@ -0,0 +1,54 @@ + 'Apellidos', + 'cargo' => 'Cargo', + 'cliente' => 'Cliente ID', + 'cliente-contactos' => 'Contactos de cliente', + 'clienteId' => 'Cliente ID', + 'contactoDeCliente' => 'Contacto de cliente', + 'contactoDeClienteList' => 'Contacto de cliente List', + 'contactosDeCliente' => 'Contactos de cliente', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'email' => 'Email', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Cliente Contactos', + 'nombre' => 'Nombre', + 'telefono' => 'Telefono', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'apellidos' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'cargo' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'telefono' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'email' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'valid_email' => 'The {field} field must contain a valid email address.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/ClienteDistribuidores.php b/ci4/app/Language/es/ClienteDistribuidores.php new file mode 100644 index 00000000..e03128a4 --- /dev/null +++ b/ci4/app/Language/es/ClienteDistribuidores.php @@ -0,0 +1,86 @@ + 'Cif', + 'ciudad' => 'Ciudad', + 'cliente-distribuidores' => 'Distribuidores de cliente', + 'comunidadAutonoma' => 'Comunidad Autonoma', + 'cp' => 'Cp', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'direccion' => 'Direccion', + 'distribuidorDeCliente' => 'Distribuidor de cliente', + 'distribuidorDeClienteList' => 'Distribuidor de cliente List', + 'distribuidoresDeCliente' => 'Distribuidores de cliente', + 'email' => 'Email', + 'horariosEntrega' => 'Horarios Entrega', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Distribuidores de cliente', + 'nombre' => 'Nombre', + 'pais' => 'Pais', + 'personaContacto' => 'Persona Contacto', + 'precio' => 'Precio', + 'provincia' => 'Provincia', + 'telefono' => 'Telefono', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'cif' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'ciudad' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'cp' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'direccion' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'horarios_entrega' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'persona_contacto' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'precio' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + + ], + + 'telefono' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'email' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'valid_email' => 'The {field} field must contain a valid email address.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Models/Clientes/ClienteContactoModel.php b/ci4/app/Models/Clientes/ClienteContactoModel.php new file mode 100644 index 00000000..cafe07cc --- /dev/null +++ b/ci4/app/Models/Clientes/ClienteContactoModel.php @@ -0,0 +1,138 @@ + "t1.id", + 2 => "t1.cliente_id", + 3 => "t1.cargo", + 4 => "t1.nombre", + 5 => "t1.apellidos", + 6 => "t1.telefono", + 7 => "t1.email", + 8 => "t2.nombre", + ]; + + protected $allowedFields = ["cliente_id", "cargo", "nombre", "apellidos", "telefono", "email"]; + protected $returnType = "App\Entities\Clientes\ClienteContactoEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "apellidos" => [ + "label" => "ClienteContactos.apellidos", + "rules" => "trim|max_length[500]", + ], + "cargo" => [ + "label" => "ClienteContactos.cargo", + "rules" => "trim|max_length[100]", + ], + "email" => [ + "label" => "ClienteContactos.email", + "rules" => "trim|max_length[150]|valid_email|permit_empty", + ], + "nombre" => [ + "label" => "ClienteContactos.nombre", + "rules" => "trim|max_length[100]", + ], + "telefono" => [ + "label" => "ClienteContactos.telefono", + "rules" => "trim|max_length[20]", + ], + ]; + + protected $validationMessages = [ + "apellidos" => [ + "max_length" => "ClienteContactos.validation.apellidos.max_length", + ], + "cargo" => [ + "max_length" => "ClienteContactos.validation.cargo.max_length", + ], + "email" => [ + "max_length" => "ClienteContactos.validation.email.max_length", + "valid_email" => "ClienteContactos.validation.email.valid_email", + ], + "nombre" => [ + "max_length" => "ClienteContactos.validation.nombre.max_length", + ], + "telefono" => [ + "max_length" => "ClienteContactos.validation.telefono.max_length", + ], + ]; + + public function findAllWithClientes(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS cliente_id FROM " . + $this->table . + " t1 LEFT JOIN clientes t2 ON t1.cliente_id = t2.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . $limit; + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . $offset; + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.cargo AS cargo, t1.nombre AS nombre, t1.apellidos AS apellidos, t1.telefono AS telefono, t1.email AS email, t2.nombre AS cliente_id" + ); + $builder->join("clientes t2", "t1.cliente_id = t2.id", "left"); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.cargo", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.apellidos", $search) + ->orLike("t1.telefono", $search) + ->orLike("t1.email", $search) + ->orLike("t2.id", $search) + ->orLike("t1.id", $search) + ->orLike("t1.cliente_id", $search) + ->orLike("t1.cargo", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.apellidos", $search) + ->orLike("t1.telefono", $search) + ->orLike("t1.email", $search) + ->orLike("t2.nombre", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Clientes/ClienteDistribuidorModel.php b/ci4/app/Models/Clientes/ClienteDistribuidorModel.php new file mode 100644 index 00000000..a5bce68f --- /dev/null +++ b/ci4/app/Models/Clientes/ClienteDistribuidorModel.php @@ -0,0 +1,214 @@ + "t1.id", + 2 => "t1.nombre", + 3 => "t1.cif", + 4 => "t1.direccion", + 5 => "t1.ciudad", + 6 => "t1.cp", + 7 => "t1.email", + 8 => "t1.pais_id", + 9 => "t1.provincia_id", + 10 => "t1.comunidad_autonoma_id", + 11 => "t1.telefono", + 12 => "t1.horarios_entrega", + 13 => "t1.persona_contacto", + 14 => "t1.precio", + 15 => "t2.nombre", + 16 => "t3.nombre", + 17 => "t4.nombre", + ]; + + protected $allowedFields = [ + "nombre", + "cif", + "direccion", + "ciudad", + "cp", + "email", + "pais_id", + "provincia_id", + "comunidad_autonoma_id", + "telefono", + "horarios_entrega", + "persona_contacto", + "precio", + ]; + protected $returnType = "App\Entities\Clientes\ClienteDistribuidorEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "cif" => [ + "label" => "ClienteDistribuidores.cif", + "rules" => "trim|max_length[50]", + ], + "ciudad" => [ + "label" => "ClienteDistribuidores.ciudad", + "rules" => "trim|max_length[100]", + ], + "cp" => [ + "label" => "ClienteDistribuidores.cp", + "rules" => "trim|max_length[10]", + ], + "direccion" => [ + "label" => "ClienteDistribuidores.direccion", + "rules" => "trim|max_length[300]", + ], + "email" => [ + "label" => "ClienteDistribuidores.email", + "rules" => "trim|max_length[150]|valid_email|permit_empty", + ], + "horarios_entrega" => [ + "label" => "ClienteDistribuidores.horariosEntrega", + "rules" => "trim|max_length[300]", + ], + "nombre" => [ + "label" => "ClienteDistribuidores.nombre", + "rules" => "trim|required|max_length[255]", + ], + "persona_contacto" => [ + "label" => "ClienteDistribuidores.personaContacto", + "rules" => "trim|max_length[100]", + ], + "precio" => [ + "label" => "ClienteDistribuidores.precio", + "rules" => "decimal|permit_empty", + ], + "telefono" => [ + "label" => "ClienteDistribuidores.telefono", + "rules" => "trim|max_length[60]", + ], + ]; + + protected $validationMessages = [ + "cif" => [ + "max_length" => "ClienteDistribuidores.validation.cif.max_length", + ], + "ciudad" => [ + "max_length" => "ClienteDistribuidores.validation.ciudad.max_length", + ], + "cp" => [ + "max_length" => "ClienteDistribuidores.validation.cp.max_length", + ], + "direccion" => [ + "max_length" => "ClienteDistribuidores.validation.direccion.max_length", + ], + "email" => [ + "max_length" => "ClienteDistribuidores.validation.email.max_length", + "valid_email" => "ClienteDistribuidores.validation.email.valid_email", + ], + "horarios_entrega" => [ + "max_length" => "ClienteDistribuidores.validation.horarios_entrega.max_length", + ], + "nombre" => [ + "max_length" => "ClienteDistribuidores.validation.nombre.max_length", + "required" => "ClienteDistribuidores.validation.nombre.required", + ], + "persona_contacto" => [ + "max_length" => "ClienteDistribuidores.validation.persona_contacto.max_length", + ], + "precio" => [ + "decimal" => "ClienteDistribuidores.validation.precio.decimal", + ], + "telefono" => [ + "max_length" => "ClienteDistribuidores.validation.telefono.max_length", + ], + ]; + public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS pais, t3.nombre AS provincia, t4.nombre AS comunidad_autonoma FROM " . + $this->table . + " t1 LEFT JOIN lg_paises t2 ON t1.pais_id = t2.id LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id LEFT JOIN lg_comunidades_autonomas t4 ON t1.comunidad_autonoma_id = t4.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . intval($limit); + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . intval($offset); + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.nombre AS nombre, t1.cif AS cif, t1.direccion AS direccion, t1.ciudad AS ciudad, t1.cp AS cp, t1.email AS email, t1.telefono AS telefono, t1.horarios_entrega AS horarios_entrega, t1.persona_contacto AS persona_contacto, t1.precio AS precio, t2.nombre AS pais, t3.nombre AS provincia, t4.nombre AS comunidad_autonoma" + ); + $builder->join("lg_paises t2", "t1.pais_id = t2.id", "left"); + $builder->join("lg_provincias t3", "t1.provincia_id = t3.id", "left"); + $builder->join("lg_comunidades_autonomas t4", "t1.comunidad_autonoma_id = t4.id", "left"); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.cif", $search) + ->orLike("t1.direccion", $search) + ->orLike("t1.ciudad", $search) + ->orLike("t1.cp", $search) + ->orLike("t1.email", $search) + ->orLike("t1.telefono", $search) + ->orLike("t1.horarios_entrega", $search) + ->orLike("t1.persona_contacto", $search) + ->orLike("t1.precio", $search) + ->orLike("t2.id", $search) + ->orLike("t3.id", $search) + ->orLike("t4.id", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.cif", $search) + ->orLike("t1.direccion", $search) + ->orLike("t1.ciudad", $search) + ->orLike("t1.cp", $search) + ->orLike("t1.email", $search) + ->orLike("t1.pais_id", $search) + ->orLike("t1.provincia_id", $search) + ->orLike("t1.comunidad_autonoma_id", $search) + ->orLike("t1.telefono", $search) + ->orLike("t1.horarios_entrega", $search) + ->orLike("t1.persona_contacto", $search) + ->orLike("t1.precio", $search) + ->orLike("t2.nombre", $search) + ->orLike("t3.nombre", $search) + ->orLike("t4.nombre", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/_contactoDeClienteFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/_contactoDeClienteFormItems.php new file mode 100644 index 00000000..5cff9964 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/_contactoDeClienteFormItems.php @@ -0,0 +1,58 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/viewContactoDeClienteForm.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/viewContactoDeClienteForm.php new file mode 100644 index 00000000..29d2aaf8 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/viewContactoDeClienteForm.php @@ -0,0 +1,65 @@ +include("Themes/_commonPartialsBs/select2bs5") ?> +include("Themes/_commonPartialsBs/sweetalert") ?> +extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> + + +section("additionalInlineJs") ?> + + + $('#clienteId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/viewContactoDeClienteList.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/viewContactoDeClienteList.php new file mode 100644 index 00000000..1a0a3487 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/contactos/viewContactoDeClienteList.php @@ -0,0 +1,171 @@ +include('Themes/_commonPartialsBs/select2bs5') ?> +include('Themes/_commonPartialsBs/datatables') ?> +include('Themes/_commonPartialsBs/sweetalert') ?> +extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfContactosdecliente').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfContactosdecliente').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + "dom": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + stateSave: true, + order: [[1, 'asc']], + language: { + url: "/assets/dt/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [0,lastColNr] + } + ], + columns : [ + { 'data': actionBtns }, + { 'data': 'id' }, + { 'data': 'cliente_id' }, + { 'data': 'cargo' }, + { 'data': 'nombre' }, + { 'data': 'apellidos' }, + { 'data': 'telefono' }, + { 'data': 'email' }, + { 'data': actionBtns } + ] + }); + + + + +$(document).on('click', '.btn-edit', function(e) { + window.location.href = `/${$(this).attr('data-id')}/edit`; + }); + +$(document).on('click', '.btn-delete', function(e) { + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + const dataId = $(this).data('id'); + const row = $(this).closest('tr'); + if (result.value) { + $.ajax({ + url: `/${dataId}`, + method: 'DELETE', + }).done((data, textStatus, jqXHR) => { + Toast.fire({ + icon: 'success', + title: data.msg ?? jqXHR.statusText, + }); + + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + }).fail((jqXHR, textStatus, errorThrown) => { + Toast.fire({ + icon: 'error', + title: jqXHR.responseJSON.messages.error, + }); + }) + } + }); + }); + + + + +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/_distribuidorDeClienteFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/_distribuidorDeClienteFormItems.php new file mode 100644 index 00000000..68658cb6 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/_distribuidorDeClienteFormItems.php @@ -0,0 +1,125 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/viewDistribuidorDeClienteForm.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/viewDistribuidorDeClienteForm.php new file mode 100644 index 00000000..56e72680 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/viewDistribuidorDeClienteForm.php @@ -0,0 +1,125 @@ +include("Themes/_commonPartialsBs/select2bs5") ?> +include("Themes/_commonPartialsBs/sweetalert") ?> +extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> + + +section("additionalInlineJs") ?> + + + $('#comunidadAutonomaId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + $('#provinciaId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + $('#paisId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/viewDistribuidorDeClienteList.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/viewDistribuidorDeClienteList.php new file mode 100644 index 00000000..b6899989 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/distribuidores/viewDistribuidorDeClienteList.php @@ -0,0 +1,185 @@ +include('Themes/_commonPartialsBs/select2bs5') ?> +include('Themes/_commonPartialsBs/datatables') ?> +include('Themes/_commonPartialsBs/sweetalert') ?> +extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfDistribuidoresdecliente').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfDistribuidoresdecliente').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + "dom": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + stateSave: true, + order: [[1, 'asc']], + language: { + url: "/assets/dt/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [0,lastColNr] + } + ], + columns : [ + { 'data': actionBtns }, + { 'data': 'id' }, + { 'data': 'nombre' }, + { 'data': 'cif' }, + { 'data': 'direccion' }, + { 'data': 'ciudad' }, + { 'data': 'cp' }, + { 'data': 'email' }, + { 'data': 'pais' }, + { 'data': 'provincia' }, + { 'data': 'comunidad_autonoma' }, + { 'data': 'telefono' }, + { 'data': 'horarios_entrega' }, + { 'data': 'persona_contacto' }, + { 'data': 'precio' }, + { 'data': actionBtns } + ] + }); + + + + +$(document).on('click', '.btn-edit', function(e) { + window.location.href = `/${$(this).attr('data-id')}/edit`; + }); + +$(document).on('click', '.btn-delete', function(e) { + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + const dataId = $(this).data('id'); + const row = $(this).closest('tr'); + if (result.value) { + $.ajax({ + url: `/${dataId}`, + method: 'DELETE', + }).done((data, textStatus, jqXHR) => { + Toast.fire({ + icon: 'success', + title: data.msg ?? jqXHR.statusText, + }); + + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + }).fail((jqXHR, textStatus, errorThrown) => { + Toast.fire({ + icon: 'error', + title: jqXHR.responseJSON.messages.error, + }); + }) + } + }); + }); + + + + +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> +