diff --git a/ci4/app/Controllers/Facturacion/Albaran.php b/ci4/app/Controllers/Facturacion/Albaran.php deleted file mode 100755 index cc91f085..00000000 --- a/ci4/app/Controllers/Facturacion/Albaran.php +++ /dev/null @@ -1,30 +0,0 @@ -request->isAJAX()) { + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $model_linea = model('App\Models\Pedidos\AlbaranLineaModel'); + $model_linea->where('albaran_id', $id)->delete(); + + $this->model->where('id', $id)->delete(); + + $data = [ + 'error' => 0, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function addLinea($albaran_id){ + + if ($this->request->isAJAX()) { + + $model_linea = model('App\Models\Pedidos\AlbaranLineaModel'); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + // si es un post, es el iva + if($this->request->getPost()){ + $reqData = $this->request->getPost(); + $albaran_id = $reqData['albaran_id'] ?? 0; + + $albaran = $this->model->find($albaran_id); + if($albaran == false){ + $data = [ + 'error' => 'Albaran no encontrado', + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + $presupuesto_model = model('App\Models\Presupuestos\PresupuestoModel'); + $presupuesto = $presupuesto_model->find($albaran->presupuesto_id); + if($presupuesto == false){ + $data = [ + 'error' => 'Presupuesto no encontrado', + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + $iva_reducido = $presupuesto->iva_reducido; + $lineas = $model_linea->where('albaran_id', $albaran_id)->findAll(); + $total = 0; + foreach($lineas as $linea){ + $total += $linea->total; + } + $iva = $iva_reducido? $total * 4.0 / 100: $total * 21.0 / 100; + $data_linea= [ + 'albaran_id' => $albaran_id, + 'titulo' => $iva_reducido?lang('Pedidos.iva4'):lang('Pedidos.iva21'), + 'cantidad' => 1, + 'precio_unidad' => round($iva,2), + 'total' => round($iva,2), + 'user_created_id' => auth()->user()->id, + 'user_updated_id' => auth()->user()->id + ]; + $id_linea = $model_linea->insert($data_linea); + $linea = $model_linea->find($id_linea); + $data = [ + 'error' => 0, + 'data' => $linea, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else{ + $linea = [ + 'albaran_id' => $albaran_id, + 'user_created_id' => auth()->user()->id, + 'user_updated_id' => auth()->user()->id + ]; + $id_linea = $model_linea->insert($linea); + $data = $model_linea->find($id_linea); + + $data = [ + 'error' => 0, + 'data' => $data, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function add() + { + if ($this->request->isAJAX()) { + + $user = auth()->user()->id; + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $reqData = $this->request->getPost(); + $pedido_id = $reqData['pedido_id'] ?? 0; + $presupuestos_id = $reqData['presupuestos_id'] ?? 0; + + $return_data = $this->model->generarAlbaranes($pedido_id, $presupuestos_id, $user); + $data = [ + 'data' => $return_data, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function update($id = null){ + + if ($this->request->isAJAX()) { + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + if ($id == null) : + $data = [ + 'error' => 2, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + endif; + $id = filter_var($id, FILTER_SANITIZE_URL); + $albaranEntity = $this->model->find($id); + + if ($albaranEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]); + $data = [ + 'error' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + endif; + + if ($this->request->getPost()) : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + $sanitizedData['user_updated_id'] = auth()->user()->id; + + $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('Pedidos.albaran'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $albaranEntity->fill($sanitizedData); + + endif; + if ($noException && $successfulResult) : + $id = $albaranEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; + + $data = [ + 'error' => 0, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $data = [ + 'error' => 1, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + public function updateLinea($id = null){ + + if ($this->request->isAJAX()) { + + $model_linea = model('App\Models\Pedidos\AlbaranLineaModel'); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + if ($id == null) : + $data = [ + 'error' => 2, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + endif; + $id = filter_var($id, FILTER_SANITIZE_URL); + $albaranEntity = $model_linea->find($id); + + if ($albaranEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]); + $data = [ + 'error' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + endif; + + if ($this->request->getPost()) : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + $sanitizedData['user_updated_id'] = auth()->user()->id; + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + if ($this->canValidate()) : + try { + $successfulResult = $model_linea->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]); + $this->session->setFlashdata('formErrors', $model_linea->errors()); + + endif; + + $albaranEntity->fill($sanitizedData); + + endif; + if ($noException && $successfulResult) : + $id = $albaranEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; + + $data = [ + 'error' => 0, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $data = [ + 'error' => 1, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function borrarLinea(){ + if ($this->request->isAJAX()) { + + $model_linea = model('App\Models\Pedidos\AlbaranLineaModel'); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $reqData = $this->request->getPost(); + $id = $reqData['id'] ?? 0; + $id = filter_var($id, FILTER_SANITIZE_URL); + $albaranLineaEntity = $model_linea->find($id); + + if ($albaranLineaEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]); + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]); + $data = [ + 'error' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + endif; + + $successfulResult = $model_linea->skipValidation(true)->update($id, ['deleted_at' => date('Y-m-d H:i:s')]); + + if ($successfulResult) : + $data = [ + 'error' => 0, + $csrfTokenName => $newTokenHash + ]; + else: + $data = [ + 'error' => 1, + $csrfTokenName => $newTokenHash + ]; + endif; + return $this->respond($data); + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function getAlbaranes($pedido_id = null){ + if ($this->request->isAJAX()) { + + $model_linea = model('App\Models\Pedidos\AlbaranLineaModel'); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $returnData = []; + $albaranes = $this->model->asArray()->where('pedido_id', $pedido_id)->findAll(); + + foreach($albaranes as $albaran){ + $albaran['fecha_albaran'] = $albaran['updated_at']; + array_push($returnData, + [ + 'albaran' => $albaran, + 'lineas' => $model_linea->asArray()->where('albaran_id', $albaran['id'])->findAll()] + ); + } + + $data = [ + 'data' => $returnData, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } +} + \ No newline at end of file diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index af9c7953..93e41170 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -2,54 +2,301 @@ namespace App\Controllers\Pedidos; use App\Controllers\BaseController; +use App\Entities\Pedidos\PedidoEntity; +use App\Models\Collection; +use App\Models\Pedidos\PedidoModel; -class Pedido extends BaseController +class Pedido extends \App\Controllers\BaseResourceController { - function __construct() - { - + protected $modelName = PedidoModel::class; + protected $format = 'json'; + + protected static $singularObjectNameCc = 'pedido'; + protected static $singularObjectName = 'Pedido'; + protected static $pluralObjectName = 'Pedidos'; + protected static $controllerSlug = 'pedido'; + + protected static $viewPath = 'themes/vuexy/form/pedidos/'; + + protected $indexRoute = 'pedidoList'; + + + public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) + { + $this->viewData['pageTitle'] = lang('Pedidos.moduleTitle'); + // Se indica que este controlador trabaja con soft_delete + + $this->viewData = ['usingServerSideDataTable' => true]; + + // Breadcrumbs + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_pedidos"), 'route' => "javascript:void(0);", 'active' => false], + ]; + + parent::initController($request, $response, $logger); + } public function index() { - echo 'Pedidos'; + + $this->viewData['usingClientSideDataTable'] = true; + + $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaextra.tarifaextra')]); + parent::index(); + } public function activos() { - echo 'Pedidos Activos'; + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]), + 'presupuestoEntity' => new PedidoEntity(), + 'usingServerSideDataTable' => true, + 'pageTitle' => lang('Pedidos.Pedidos'), + 'estadoPedidos' => 'activo', + ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true] + ]; + + return view(static::$viewPath . 'viewPedidosList', $viewData); } public function finalizados() { - echo 'Pedidos Finalizados'; + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]), + 'presupuestoEntity' => new PedidoEntity(), + 'usingServerSideDataTable' => true, + 'pageTitle' => lang('Pedidos.Pedidos'), + 'estadoPedidos' => 'finalizado', + ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true] + ]; + + return view(static::$viewPath . 'viewPedidosList', $viewData); } public function cancelados() { - echo 'Pedidos Cancelados'; + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]), + 'presupuestoEntity' => new PedidoEntity(), + 'usingServerSideDataTable' => true, + 'pageTitle' => lang('Pedidos.Pedidos'), + 'estadoPedidos' => 'cancelado', + ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true] + ]; + + return view(static::$viewPath . 'viewPedidosList', $viewData); } - public function manuales() + public function todos() { - echo 'Pedidos Manuales'; + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]), + 'presupuestoEntity' => new PedidoEntity(), + 'usingServerSideDataTable' => true, + 'pageTitle' => lang('Pedidos.Pedidos'), + 'estadoPedidos' => 'todos', + ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true] + ]; + + return view(static::$viewPath . 'viewPedidosList', $viewData); + } -// public function delete_files() -// { -// -// } -// -// public function pedidos_maquetacion() -// { -// -// } -// -// public function pedidos_prestashop() -// { -// -// } + public function cambiarEstado(){ + if($this->request->isAJAX()){ + $id = $this->request->getPost('id'); + $estado = $this->request->getPost('estado'); + + $this->model->where('id', $id)->set(['estado' => $estado])->update(); + return $this->respond(['status' => 'success', 'message' => lang('Basic.global.success')]); + }else{ + return $this->failUnauthorized('Invalid request', 403); + } + } + + + public function update($id = null){ + + if ($this->request->isAJAX()) { + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + if ($id == null) : + $data = [ + 'error' => 2, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + endif; + $id = filter_var($id, FILTER_SANITIZE_URL); + $pedidoEntity = $this->model->find($id); + + if ($pedidoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.pedido')), $id]); + $data = [ + 'error' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + endif; + + if ($this->request->getPost()) : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + $sanitizedData['user_updated_id'] = auth()->user()->id; + + $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('Pedidos.albaran'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $pedidoEntity->fill($sanitizedData); + + endif; + if ($noException && $successfulResult) : + $id = $pedidoEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; + + $data = [ + 'error' => 0, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $data = [ + 'error' => 1, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function edit($id=null){ + + if ($id == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($id, FILTER_SANITIZE_URL); + $pedidoEntity = $this->model->find($id); + + if ($pedidoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.pedido')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $this->obtenerDatosFormulario($pedidoEntity); + + $this->viewData['pedidoEntity'] = $pedidoEntity; + + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3'); + + return $this->displayForm(__METHOD__, $id); + } + + 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'] ?? 0; + $order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + $estado = $reqData['estado'] ?? 'todos'; + if($estado == 'todos') $estado = ''; + + $model_linea = model('\App\Models\Pedidos\PedidoLineaModel'); + $resourceData = $model_linea->getResource($search, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $model_linea->getResource("", $estado)->countAllResults(), + $model_linea->getResource($search, $estado)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function getlineas(){ + 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; + } + + $id = $reqData['pedido_id'] ?? 0; + $resourceData = $this->model->obtenerLineasPedido($id); + + return $this->respond(Collection::datatable( + $resourceData, + count($resourceData), + count($resourceData) + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + private function obtenerDatosFormulario(&$pedidoEntity){ + + $datos = $this->model->obtenerDatosForm($pedidoEntity->id); + + $pedidoEntity->estadoText = lang('Pedidos.' . $pedidoEntity->estado); + + if(count($datos) > 0){ + $pedidoEntity->cliente = $datos[0]->cliente; + $pedidoEntity->cliente_id = $datos[0]->cliente_id; + $pedidoEntity->comercial = $datos[0]->comercial; + } + + $pedidoEntity->fecha_entrega_real_text = $pedidoEntity->fecha_entrega_real ? date('d/m/Y', strtotime($pedidoEntity->fecha_entrega_real)) : ''; + $pedidoEntity->fecha_impresion_text = $pedidoEntity->fecha_impresion ? date('d/m/Y', strtotime($pedidoEntity->fecha_impresion)) : ''; + $pedidoEntity->fecha_encuadernado_text = $pedidoEntity->fecha_encuadernado ? date('d/m/Y', strtotime($pedidoEntity->fecha_encuadernado)) : ''; + $pedidoEntity->fecha_entrega_externo_text = $pedidoEntity->fecha_entrega_externo ? date('d/m/Y', strtotime($pedidoEntity->fecha_entrega_externo)) : ''; + } } \ No newline at end of file diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 3bf94ddf..67784cd8 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -20,6 +20,7 @@ use Exception; use function PHPUnit\Framework\containsOnly; + class Presupuestocliente extends \App\Controllers\BaseResourceController { protected $modelName = "PresupuestoModel"; @@ -787,6 +788,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($confirmar) { $model_presupuesto->confirmarPresupuesto($id); + $this->crearPedido($id); } return $this->respond([ @@ -889,6 +891,44 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController * Funciones auxiliares * **********************/ + public function crearPedido($presupuesto_id) + { + $model_pedido = model('App\Models\Pedidos\PedidoModel'); + $model_pedido_linea = model('App\Models\Pedidos\PedidoLineaModel'); + $model_cliente = model('App\Models\Clientes\ClienteModel'); + + $model_presupuesto = new PresupuestoModel(); + $datos_presupuesto = $model_presupuesto->find($presupuesto_id); + + $id_linea = 0; + + $data_pedido = [ + 'total_precio' => $datos_presupuesto->total_aceptado, + 'total_tirada' => $datos_presupuesto->tirada, + 'estado' => $model_cliente->creditoDisponible($datos_presupuesto->cliente_id) ? "produccion" : "validacion", + 'user_created_id' => auth()->user()->id, + 'user_updated_id' => auth()->user()->id, + ]; + + $pedido_id = $model_pedido->insert($data_pedido); + if($pedido_id){ + $data_pedido_linea = [ + "pedido_id" => $pedido_id, + "presupuesto_id" => $presupuesto_id, + "ubicacion_id" => 1, // safetak por defecto + "user_created_id" => auth()->user()->id, + "user_updated_id" => auth()->user()->id, + ]; + $id_linea = $model_pedido_linea->insert($data_pedido_linea); + } + + if($id_linea != 0 && $pedido_id != 0){ + return true; + } + return false; + } + + protected function borrarRelacionesPresupuesto($id) { // Se borran las lineas de presupuesto diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index cccbe256..3b6973fc 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -20,18 +20,11 @@ class Test extends BaseController public function index() { - helper('rbac'); - - //$user = auth()->user(); - - //generate_php_permissions_constant(); - - echo generate_php_permissions_matrix_constant(); - - //$user->syncGroups('admin'); - - //var_dump($user->can('token.menu')); - + $model = new PresupuestoModel(); + $data = $model->generarLineaPedido(123); + echo '
'; + var_dump($data); + echo ''; } diff --git a/ci4/app/Entities/Pedidos/AlbaranEntity.php b/ci4/app/Entities/Pedidos/AlbaranEntity.php new file mode 100644 index 00000000..bdff8334 --- /dev/null +++ b/ci4/app/Entities/Pedidos/AlbaranEntity.php @@ -0,0 +1,46 @@ + null, + 'pedido_id' => null, + 'presupuesto_id' => null, + 'presupuesto_direccion_id' => null, + 'cliente_id' => null, + 'serie_id' => null, + 'numero_albaran' => null, + 'mostrar_precios' => null, + 'total' => null, + 'direccion_albaran' => null, + 'att_albaran' => null, + 'user_created_id' => null, + 'user_updated_id' => null, + 'created_at' => null, + 'updated_at' => null, + 'deleted_at' => null, + ]; + + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + + protected $casts = [ + 'id' => 'integer', + 'pedido_id' => '?integer', + 'presupuesto_id' => '?integer', + 'presupuesto_direccion_id' => '?integer', + 'cliente_id' => '?integer', + 'serie_id' => '?integer', + 'numero_albaran' => '?string', + 'mostrar_precios' => '?boolean', + 'total' => 'float', + 'direccion_albaran' => '?string', + 'att_albaran' => '?string', + 'user_created_id' => 'integer', + 'user_updated_id' => 'integer', + ]; + + // Agrega tus métodos personalizados aquí +} diff --git a/ci4/app/Entities/Pedidos/AlbaranLineaEntity.php b/ci4/app/Entities/Pedidos/AlbaranLineaEntity.php new file mode 100644 index 00000000..c2137df8 --- /dev/null +++ b/ci4/app/Entities/Pedidos/AlbaranLineaEntity.php @@ -0,0 +1,40 @@ + null, + 'albaran_id' => null, + 'titulo' => null, + 'isbn' => null, + 'ref_cliente' => null, + 'cantidad' => null, + 'cajas' => null, + 'ejemplares_por_caja' => null, + 'precio_unidad' => null, + 'total' => null, + 'user_created_id' => null, + 'user_updated_id' => null, + 'created_at' => null, + 'updated_at' => null, + 'deleted_at' => null, + ]; + + protected $casts = [ + 'id' => 'integer', + 'albaran_id' => '?integer', + 'titulo' => 'string', + 'isbn' => '?string', + 'ref_cliente' => '?string', + 'cantidad' => '?integer', + 'cajas' => '?integer', + 'ejemplares_por_caja' => '?integer', + 'precio_unidad' => 'float', + 'total' => 'float', + 'user_created_id' => 'integer', + 'user_updated_id' => 'integer', + ]; +} \ No newline at end of file diff --git a/ci4/app/Entities/Pedidos/PedidoEntity.php b/ci4/app/Entities/Pedidos/PedidoEntity.php new file mode 100644 index 00000000..a847c03b --- /dev/null +++ b/ci4/app/Entities/Pedidos/PedidoEntity.php @@ -0,0 +1,30 @@ + null, + "total_precio" => null, + "total_tirada" => null, + "estado" => null, + "user_created_id" => null, + "user_updated_id" => null, + "user_validated_id" => null, + "fecha_entrega_real" => null, + "fecha_impresion" => null, + "fecha_encuadernado" => null, + "fecha_entrega_externo" => null, + "created_at" => null, + "updated_at" => null, + "validated_at" => null, + ]; + + + protected $casts = [ + "total_precio" => "float", + "total_tirada" => "float", + ]; +} diff --git a/ci4/app/Entities/Pedidos/PedidoLineaEntity.php b/ci4/app/Entities/Pedidos/PedidoLineaEntity.php new file mode 100644 index 00000000..38efab3f --- /dev/null +++ b/ci4/app/Entities/Pedidos/PedidoLineaEntity.php @@ -0,0 +1,25 @@ + null, + "pedido_id" => null, + "presupuesto_id" => null, + "ubicacion_id" => null, + "user_created_id" => null, + "user_updated_id" => null, + "created_at" => null, + "updated_at" => null, + ]; + + + protected $casts = [ + "pedido_id" => "int", + "presupuesto_id" => "int", + "ubicacion_id" => "int", + ]; +} diff --git a/ci4/app/Language/en/App.php b/ci4/app/Language/en/App.php index f3648c44..8a54743e 100755 --- a/ci4/app/Language/en/App.php +++ b/ci4/app/Language/en/App.php @@ -731,7 +731,7 @@ return [ "menu_pedidos_activos" => "Actives", "menu_pedidos_finalizados" => "Finished", "menu_pedidos_cancelados" => "Cancelled", - "menu_pedidos_manuales" => "Manual", + "menu_pedidos_todos" => "All", "menu_presupuestos" => "Budgets", "menu_presupuesto" => "Books", diff --git a/ci4/app/Language/en/Pedidos.php b/ci4/app/Language/en/Pedidos.php new file mode 100644 index 00000000..0e58640a --- /dev/null +++ b/ci4/app/Language/en/Pedidos.php @@ -0,0 +1,82 @@ + 'Number', + 'fecha' => 'Date', + 'fecha_entrega' => 'Delivery Date', + 'cliente' => 'Client', + 'comercial' => 'Commercial', + 'titulo' => 'Title', + 'ubicacion' => 'Location', + 'inc_rei' => 'Inc/Rei', // This seems to be a specific term, left as is + 'num_paginas' => 'Number of Pages', + 'tiradas' => 'Print Runs', + 'total_presupuesto' => 'Total Budget', + 'estado' => 'Status', + + 'validacion' => 'Validation', + 'produccion' => 'Production', + 'finalizado' => 'Finished', + 'enviado' => 'Sent', + 'cancelado' => 'Cancelled', + + 'datosPedido' => 'Order Details', + + 'totales' => 'Totales', + 'total_precio' => 'Total price', + "total_tirada" => 'Total print', + + 'fechas' => "Dates", + 'fecha_entrega_real' => 'Actual Delivery Date', + 'fecha_impresion' => 'Printing Date', + 'fecha_encuadernado' => 'Binding Date', + 'fecha_entrega_externo' => 'External Delivery Date', + + 'lineas' => 'Lines', + 'unidades' => "Units", + 'concepto' => "Concept", + 'total' => "Total", + 'presupuesto' => 'Budget', + + 'moduleTitle' => 'Orders', + 'pedido' => 'Order', + 'pedidos' => 'Orders', + 'pedidosList' => 'Orders List', + + 'cancelar' => 'Cancel', + 'finalizar' => 'Finish', + + 'unaCara' => '1 side', + 'dosCaras' => '2 sides', + + 'lineasTemplates' =>[ + 'libro' => "[BUDGET %s] Printing of %s copies of %s pages.\nTitle: %s. Author: %s. ISBN: %s.Size: %smm.\n", + 'libro_linea_interior' => "%s black pages on %s paper of %s grams", + 'libro_linea_cubierta' => "\nCover printed on %s on %s paper of %s grams", + 'libro_linea_sobrecubierta' => "\nDust jacket on %s paper of %s grams", + 'libro_solapas' => " with flaps of %smm.", + 'libro_encuadernacion' => "\nType of binding: %s" + ], + + 'albaranes' => 'Delivery Notes', + 'albaran' => 'Delivery Note', + 'generarAlbaranes' => 'Generate delivery notes', + 'borrarAlbaranes' => 'Delete delivery notes', + 'att' => "Att", + 'direccion' => 'Address', + 'borrarAlbaran' => 'Delete delivery note', + 'imprimirAlbaran' => 'Print', + 'nuevaLinea' => 'New line', + 'addIva' => "Add VAT", + 'mostrarPrecios' => 'Show prices', + 'iva4' => "4,00 % VAT", + 'iva21' => "21,00 % VAT", + + 'facturas' => 'Invoices', + + 'validation' => [ + + ], +]; \ No newline at end of file diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 3806b8cb..15882bbe 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -739,7 +739,7 @@ return [ "menu_pedidos_activos" => "Activos", "menu_pedidos_finalizados" => "Finalizados", "menu_pedidos_cancelados" => "Cancelados", - "menu_pedidos_manuales" => "Manuales", + "menu_pedidos_todos" => "Todos", "menu_presupuestos" => "Presupuestos", "menu_presupuesto" => "Libros", diff --git a/ci4/app/Language/es/Pedidos.php b/ci4/app/Language/es/Pedidos.php new file mode 100644 index 00000000..5e790760 --- /dev/null +++ b/ci4/app/Language/es/Pedidos.php @@ -0,0 +1,84 @@ + 'Número', + 'fecha' => 'Fecha', + 'fecha_entrega' => 'Fecha