mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido mensaje en comentarios logistica para tirada flexible
This commit is contained in:
@ -195,7 +195,8 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cambiarEstado(){
|
public function cambiarEstado()
|
||||||
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
$id = $this->request->getPost('id');
|
$id = $this->request->getPost('id');
|
||||||
@ -209,7 +210,8 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function update($id = null){
|
public function update($id = null)
|
||||||
|
{
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
@ -291,13 +293,13 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
];
|
];
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id=null){
|
public function edit($id = null)
|
||||||
|
{
|
||||||
|
|
||||||
if ($id == null):
|
if ($id == null):
|
||||||
return $this->redirect2listView();
|
return $this->redirect2listView();
|
||||||
@ -342,7 +344,8 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
return $this->displayForm(__METHOD__, $id);
|
return $this->displayForm(__METHOD__, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function datatable(){
|
public function datatable()
|
||||||
|
{
|
||||||
|
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
@ -360,7 +363,8 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||||
$estado = $reqData['estado'] ?? 'todos';
|
$estado = $reqData['estado'] ?? 'todos';
|
||||||
$cliente_id = $reqData['cliente_id'] ?? -1;
|
$cliente_id = $reqData['cliente_id'] ?? -1;
|
||||||
if($estado == 'todos') $estado = '';
|
if ($estado == 'todos')
|
||||||
|
$estado = '';
|
||||||
|
|
||||||
$showTotal = $reqData['showTotal'] ?? false;
|
$showTotal = $reqData['showTotal'] ?? false;
|
||||||
|
|
||||||
@ -459,7 +463,8 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
return $result->toJson(returnAsObject: true);
|
return $result->toJson(returnAsObject: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function obtenerTotalPedidosCliente($cliente_id){
|
public function obtenerTotalPedidosCliente($cliente_id)
|
||||||
|
{
|
||||||
|
|
||||||
$error = false;
|
$error = false;
|
||||||
$result = [
|
$result = [
|
||||||
@ -474,8 +479,7 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
->groupBy('presupuestos.cliente_id')->get()->getResultObject();
|
->groupBy('presupuestos.cliente_id')->get()->getResultObject();
|
||||||
if (count($data) > 0) {
|
if (count($data) > 0) {
|
||||||
$result['total_impresion'] = round(floatval($data[0]->total), 2);
|
$result['total_impresion'] = round(floatval($data[0]->total), 2);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
$result['total'] = $result['total_impresion'] + $result['total_maquetacion'];
|
$result['total'] = $result['total_impresion'] + $result['total_maquetacion'];
|
||||||
@ -483,17 +487,18 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function obtenerPedidosForFacturas(){
|
public function obtenerPedidosForFacturas()
|
||||||
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$reqData = $this->request->getPost();
|
$reqData = $this->request->getPost();
|
||||||
$start = $reqData['start'] ?? 0;
|
$start = $reqData['start'] ?? 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getlineas(){
|
public function getlineas()
|
||||||
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
$reqData = $this->request->getPost();
|
$reqData = $this->request->getPost();
|
||||||
@ -517,7 +522,8 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function addFactura(){
|
public function addFactura()
|
||||||
|
{
|
||||||
|
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
@ -584,7 +590,8 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function obtenerDatosFormulario(&$pedidoEntity){
|
private function obtenerDatosFormulario(&$pedidoEntity)
|
||||||
|
{
|
||||||
|
|
||||||
$datos = $this->model->obtenerDatosForm($pedidoEntity->id);
|
$datos = $this->model->obtenerDatosForm($pedidoEntity->id);
|
||||||
|
|
||||||
@ -618,6 +625,7 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
{
|
{
|
||||||
$serviceProduction = service('production');
|
$serviceProduction = service('production');
|
||||||
$pedido = $this->model->find($pedido_id);
|
$pedido = $this->model->find($pedido_id);
|
||||||
|
$cliente = $pedido->presupuesto()->cliente_id;
|
||||||
$serviceProduction->setPedido($pedido);
|
$serviceProduction->setPedido($pedido);
|
||||||
if ($pedido->orden_trabajo()) {
|
if ($pedido->orden_trabajo()) {
|
||||||
return $this->response->setJSON(["status" => false, "data" => $pedido->orden_trabajo(), "message" => "Ya existe una orden de trabajo para este pedido"]);
|
return $this->response->setJSON(["status" => false, "data" => $pedido->orden_trabajo(), "message" => "Ya existe una orden de trabajo para este pedido"]);
|
||||||
@ -625,9 +633,23 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
} else {
|
} else {
|
||||||
$r = $serviceProduction->createOrdenTrabajo();
|
$r = $serviceProduction->createOrdenTrabajo();
|
||||||
$this->model->set(['estado' => 'produccion'])->where('id', $pedido_id)->update();
|
$this->model->set(['estado' => 'produccion'])->where('id', $pedido_id)->update();
|
||||||
|
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||||
|
$cliente = $clienteModel->find($cliente);
|
||||||
|
if ($cliente) {
|
||||||
|
if ($cliente->tirada_flexible == 1) {
|
||||||
|
$ejemplares_tirada_flexible = intval($pedido->total_tirada * 0.05);
|
||||||
|
$comentario = lang('OrdenTrabajo.tiradaFlexible', [
|
||||||
|
'unidades' => $ejemplares_tirada_flexible
|
||||||
|
]) . "\n" . trim($cliente->comentarios_tirada_flexible);
|
||||||
|
|
||||||
|
$serviceProduction->init($r->id)->updateOrdenTrabajoData([
|
||||||
|
'name' => 'comment_logistica',
|
||||||
|
'comment_logistica' => $comentario
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $this->response->setJSON(["status" => true, "data" => $r, "message" => "Orden trabajo creada correctamente"]);
|
return $this->response->setJSON(["status" => true, "data" => $r, "message" => "Orden trabajo creada correctamente"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
6
ci4/app/Language/es/OrdenTrabajo.php
Normal file
6
ci4/app/Language/es/OrdenTrabajo.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
return [
|
||||||
|
'tiradaFlexible' => 'El cliente tiene opción de tirada flexible: ±{unidades, number, integer} unidades.',
|
||||||
|
];
|
||||||
@ -253,7 +253,8 @@ class PresupuestoService extends BaseService
|
|||||||
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
|
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
|
||||||
// Precio papel pedido
|
// Precio papel pedido
|
||||||
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
|
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
|
||||||
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);;
|
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);
|
||||||
|
;
|
||||||
|
|
||||||
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
|
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
|
||||||
$linea['fields']['maquina'] = $maquina->maquina;
|
$linea['fields']['maquina'] = $maquina->maquina;
|
||||||
@ -1913,6 +1914,23 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
$r = $serviceProduction->createOrdenTrabajo($isImported);
|
$r = $serviceProduction->createOrdenTrabajo($isImported);
|
||||||
$modelPedido->set(['estado' => 'produccion'])->where('id', $pedido_id)->update();
|
$modelPedido->set(['estado' => 'produccion'])->where('id', $pedido_id)->update();
|
||||||
|
|
||||||
|
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||||
|
$cliente = $clienteModel->find($datos_presupuesto->cliente_id);
|
||||||
|
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||||
|
|
||||||
|
if ($cliente) {
|
||||||
|
if ($cliente->tirada_flexible == 1) {
|
||||||
|
$ejemplares_tirada_flexible = intval($datos_presupuesto->tirada * 0.05);
|
||||||
|
$comentario = lang('OrdenTrabajo.tiradaFlexible', [
|
||||||
|
'unidades' => $ejemplares_tirada_flexible
|
||||||
|
]) . "\n" . trim($cliente->comentarios_tirada_flexible);
|
||||||
|
$serviceProduction->init($r->id)->updateOrdenTrabajoData([
|
||||||
|
'name' => 'comment_logistica',
|
||||||
|
'comment_logistica' => $comentario
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -1157,6 +1157,16 @@ class ProductionService extends BaseService
|
|||||||
$this->updateProgress();
|
$this->updateProgress();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function updateOrdenTrabajoData($data)
|
||||||
|
{
|
||||||
|
$result = $this->otModel->where('id', $this->ot->id)
|
||||||
|
->set($data['name'], $data[$data['name']])
|
||||||
|
->update();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function emptyOrdenTrabajoDate(int $orden_trabajo_id, string $dateName)
|
public function emptyOrdenTrabajoDate(int $orden_trabajo_id, string $dateName)
|
||||||
{
|
{
|
||||||
$status = $this->otDate->where('orden_trabajo_id', $orden_trabajo_id)
|
$status = $this->otDate->where('orden_trabajo_id', $orden_trabajo_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user