mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'add/envio_ferros' into 'main'
Add/envio ferros See merge request jjimenez/safekat!745
This commit is contained in:
@ -807,6 +807,7 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
|||||||
$routes->get('print/label/test', 'LogisticaController::print_test_label');
|
$routes->get('print/label/test', 'LogisticaController::print_test_label');
|
||||||
$routes->get('panel', 'LogisticaController::panel', ['as' => 'LogisticaPanel']);
|
$routes->get('panel', 'LogisticaController::panel', ['as' => 'LogisticaPanel']);
|
||||||
$routes->get('envios', 'LogisticaController::gestionEnvios', ['as' => 'gestionEnvios']);
|
$routes->get('envios', 'LogisticaController::gestionEnvios', ['as' => 'gestionEnvios']);
|
||||||
|
$routes->get('enviosFerros', 'LogisticaController::gestionEnviosFerros', ['as' => 'gestionEnviosFerros']);
|
||||||
$routes->get('datatableEnvios', 'LogisticaController::datatable_envios');
|
$routes->get('datatableEnvios', 'LogisticaController::datatable_envios');
|
||||||
$routes->get('datatableLineasEnvios/(:num)', 'LogisticaController::datatable_enviosEdit/$1');
|
$routes->get('datatableLineasEnvios/(:num)', 'LogisticaController::datatable_enviosEdit/$1');
|
||||||
$routes->get('envio/(:num)', 'LogisticaController::editEnvio/$1');
|
$routes->get('envio/(:num)', 'LogisticaController::editEnvio/$1');
|
||||||
@ -821,6 +822,7 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
|||||||
$routes->post('updateProveedorEnvio', 'LogisticaController::updateProveedorEnvio');
|
$routes->post('updateProveedorEnvio', 'LogisticaController::updateProveedorEnvio');
|
||||||
$routes->post('finalizarEnvio', 'LogisticaController::finalizarEnvio');
|
$routes->post('finalizarEnvio', 'LogisticaController::finalizarEnvio');
|
||||||
$routes->post('generateEnvio', 'LogisticaController::generarEnvio');
|
$routes->post('generateEnvio', 'LogisticaController::generarEnvio');
|
||||||
|
$routes->post('generateEnvioFerro', 'LogisticaController::generarEnvioFerro');
|
||||||
$routes->get('selectForNewEnvio', 'LogisticaController::findForNewEnvio');
|
$routes->get('selectForNewEnvio', 'LogisticaController::findForNewEnvio');
|
||||||
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
||||||
$routes->post('imprimirEtiquetas', 'LogisticaController::imprimirEtiquetas');
|
$routes->post('imprimirEtiquetas', 'LogisticaController::imprimirEtiquetas');
|
||||||
|
|||||||
@ -62,6 +62,22 @@ class LogisticaController extends BaseController
|
|||||||
'currentModule' => static::$controllerSlug,
|
'currentModule' => static::$controllerSlug,
|
||||||
'boxTitle' => lang('Logistica.gestionEnvios'),
|
'boxTitle' => lang('Logistica.gestionEnvios'),
|
||||||
'usingServerSideDataTable' => true,
|
'usingServerSideDataTable' => true,
|
||||||
|
'tipo_envio' => 'estandar',
|
||||||
|
];
|
||||||
|
|
||||||
|
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||||
|
|
||||||
|
return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function gestionEnviosFerros()
|
||||||
|
{
|
||||||
|
$viewData = [
|
||||||
|
'currentModule' => static::$controllerSlug,
|
||||||
|
'boxTitle' => lang('Logistica.envioFerros'),
|
||||||
|
'usingServerSideDataTable' => true,
|
||||||
|
'tipo_envio' => 'ferro_prototipo',
|
||||||
];
|
];
|
||||||
|
|
||||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||||
@ -85,7 +101,14 @@ class LogisticaController extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$query = LogisticaService::findForNewEnvio();
|
|
||||||
|
$tipo_envio = $this->request->getGet('tipo_envio') ?? 'estandar';
|
||||||
|
|
||||||
|
if($tipo_envio == 'ferro_prototipo'){
|
||||||
|
$query = LogisticaService::findForNewEnvioFerro();
|
||||||
|
} else {
|
||||||
|
$query = LogisticaService::findForNewEnvio();
|
||||||
|
}
|
||||||
if ($this->request->getGet("q")) {
|
if ($this->request->getGet("q")) {
|
||||||
$query->groupStart()
|
$query->groupStart()
|
||||||
->orLike("id", $this->request->getGet("q"))
|
->orLike("id", $this->request->getGet("q"))
|
||||||
@ -105,12 +128,12 @@ class LogisticaController extends BaseController
|
|||||||
public function selectDireccionForEnvio(){
|
public function selectDireccionForEnvio(){
|
||||||
|
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$pedido_id = $this->request->getGet('pedido_id');
|
$ot = $this->request->getGet('ot_id');
|
||||||
if($pedido_id == null || $pedido_id == 0){
|
if($ot == null || $ot == 0){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$searchVal = $this->request->getGet("q") ?? "";
|
$searchVal = $this->request->getGet("q") ?? "";
|
||||||
$result = LogisticaService::findDireccionesNewEnvio($pedido_id, $searchVal);
|
$result = LogisticaService::findDireccionesNewEnvio($ot, $searchVal);
|
||||||
|
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
} else {
|
} else {
|
||||||
@ -124,9 +147,22 @@ class LogisticaController extends BaseController
|
|||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
$pedido_id = $this->request->getPost('pedido_id');
|
$ot_id = $this->request->getPost('ot_id');
|
||||||
$direccion = $this->request->getPost('direccion');
|
$direccion = $this->request->getPost('direccion') ?? "";
|
||||||
$result = LogisticaService::generateEnvio($pedido_id, $direccion);
|
$result = LogisticaService::generateEnvio($ot_id, $direccion);
|
||||||
|
return $this->response->setJSON($result);
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function generarEnvioFerro()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
|
$ot_id = $this->request->getPost('ot_id');
|
||||||
|
$result = LogisticaService::generateEnvioFerro($ot_id);
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
@ -233,9 +269,10 @@ class LogisticaController extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
$otsFilter = $this->request->getGetPost('otsFilter');
|
$otsFilter = $this->request->getGetPost('otsFilter');
|
||||||
|
$tipo_envio = $this->request->getGetPost('tipo_envio') ?? 'estandar';
|
||||||
|
|
||||||
$model = model('App\Models\Logistica\EnvioModel');
|
$model = model('App\Models\Logistica\EnvioModel');
|
||||||
$q = $model->getDatatableQuery();
|
$q = $model->getDatatableQuery($tipo_envio);
|
||||||
|
|
||||||
if (!empty($otsFilter)) {
|
if (!empty($otsFilter)) {
|
||||||
$q->groupStart();
|
$q->groupStart();
|
||||||
@ -370,7 +407,7 @@ class LogisticaController extends BaseController
|
|||||||
)->edit(
|
)->edit(
|
||||||
"unidadesEnvio",
|
"unidadesEnvio",
|
||||||
function ($row, $meta) {
|
function ($row, $meta) {
|
||||||
if($row->finalizado == 1){
|
if($row->finalizado == 1 || $row->tipo_envio == 'ferro_prototipo'){
|
||||||
return $row->unidadesEnvio;
|
return $row->unidadesEnvio;
|
||||||
}
|
}
|
||||||
return '<input type="number" class="form-control input-lineas input-unidades text-center"
|
return '<input type="number" class="form-control input-lineas input-unidades text-center"
|
||||||
|
|||||||
@ -54,6 +54,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
|
|||||||
$proveedor = $reqData['proveedor'] ?? "";
|
$proveedor = $reqData['proveedor'] ?? "";
|
||||||
$proveedor_id = $reqData['proveedor_id'] ?? "";
|
$proveedor_id = $reqData['proveedor_id'] ?? "";
|
||||||
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
|
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
|
||||||
|
$is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0;
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
"presupuesto_id" => $presupuesto_id,
|
"presupuesto_id" => $presupuesto_id,
|
||||||
@ -73,6 +74,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
|
|||||||
"proveedor" => $proveedor,
|
"proveedor" => $proveedor,
|
||||||
"proveedor_id" => $proveedor_id,
|
"proveedor_id" => $proveedor_id,
|
||||||
"entregaPieCalle" => $entregaPieCalle,
|
"entregaPieCalle" => $entregaPieCalle,
|
||||||
|
"is_ferro_prototipo" => $is_ferro_prototipo
|
||||||
];
|
];
|
||||||
$response = $this->model->insert($data);
|
$response = $this->model->insert($data);
|
||||||
|
|
||||||
|
|||||||
@ -7,30 +7,24 @@ use CodeIgniter\Database\Migration;
|
|||||||
use CodeIgniter\Database\RawSql;
|
use CodeIgniter\Database\RawSql;
|
||||||
use CodeIgniter\I18n\Time;
|
use CodeIgniter\I18n\Time;
|
||||||
|
|
||||||
class AddClickColumnOrdenTrabajoTarea extends Migration
|
class AddFerroProtoPresupuestoDirecciones extends Migration
|
||||||
{
|
{
|
||||||
|
|
||||||
protected array $COLUMNS = [
|
protected array $COLUMNS = [
|
||||||
"click_init" => [
|
"is_ferro_prototipo" => [
|
||||||
"type" => "INT",
|
"type" => "TINYINT",
|
||||||
"unsigned" => true,
|
"unsigned" => true,
|
||||||
"default" => 0,
|
"default" => 0,
|
||||||
"comment" => "Click iniciales de una tarea de impresion"
|
"comment" => "Indica si es una direccion para el prototipo o ferro",
|
||||||
],
|
|
||||||
"click_end" => [
|
|
||||||
"type" => "INT",
|
|
||||||
"unsigned" => true,
|
|
||||||
"default" => 0,
|
|
||||||
"comment" => "Click finales de una tarea de impresion"
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->forge->addColumn('orden_trabajo_tareas', $this->COLUMNS);
|
$this->forge->addColumn('presupuesto_direcciones', $this->COLUMNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->forge->dropColumn('orden_trabajo_tareas', array_keys($this->COLUMNS));
|
$this->forge->dropColumn('presupuesto_direcciones', array_keys($this->COLUMNS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
|
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
|
||||||
|
use CodeIgniter\Database\Migration;
|
||||||
|
use CodeIgniter\Database\RawSql;
|
||||||
|
use CodeIgniter\I18n\Time;
|
||||||
|
|
||||||
|
class AddTipoEnvioEnvios extends Migration
|
||||||
|
{
|
||||||
|
|
||||||
|
protected array $COLUMNS = [
|
||||||
|
"tipo_envio" => [
|
||||||
|
"type" => "enum",
|
||||||
|
"constraint" => ['estandar', 'ferro_prototipo'],
|
||||||
|
"default" => 'estandar',
|
||||||
|
"comment" => "Indica el tipo de envio",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->forge->addColumn('envios', $this->COLUMNS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$this->forge->dropColumn('envios', array_keys($this->COLUMNS));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -31,5 +31,6 @@ class EnvioEntity extends Entity
|
|||||||
'created_at' => 'datetime',
|
'created_at' => 'datetime',
|
||||||
'updated_at' => 'datetime',
|
'updated_at' => 'datetime',
|
||||||
'cajas' => 'int',
|
'cajas' => 'int',
|
||||||
|
'tipo_envio' => 'string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"proveedor_id" => null,
|
"proveedor_id" => null,
|
||||||
"margen" => null,
|
"margen" => null,
|
||||||
"entregaPieCalle" => null,
|
"entregaPieCalle" => null,
|
||||||
|
"is_ferro_prototipo" => null,
|
||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
"presupuesto_id" => "int",
|
"presupuesto_id" => "int",
|
||||||
@ -38,6 +39,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"margen" => "float",
|
"margen" => "float",
|
||||||
"proveedor_id" => "int",
|
"proveedor_id" => "int",
|
||||||
"entregaPieCalle" => "int",
|
"entregaPieCalle" => "int",
|
||||||
|
"is_ferro_prototipo" => "int",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class EnvioLineaModel extends Model
|
|||||||
->select(
|
->select(
|
||||||
"t1.id, t1.pedido_id as pedido, t3.id as presupuesto,
|
"t1.id, t1.pedido_id as pedido, t3.id as presupuesto,
|
||||||
t3.titulo as titulo, t1.unidades_envio as unidadesEnvio, t1.unidades_envio as unidadesEnvioRaw,
|
t3.titulo as titulo, t1.unidades_envio as unidadesEnvio, t1.unidades_envio as unidadesEnvioRaw,
|
||||||
t1.unidades_total as unidadesTotal,
|
t1.unidades_total as unidadesTotal, t2.tipo_envio as tipo_envio,
|
||||||
IFNULL((
|
IFNULL((
|
||||||
SELECT SUM(t_sub.unidades_envio)
|
SELECT SUM(t_sub.unidades_envio)
|
||||||
FROM envios_lineas t_sub
|
FROM envios_lineas t_sub
|
||||||
|
|||||||
@ -32,13 +32,14 @@ class EnvioModel extends Model
|
|||||||
'created_at',
|
'created_at',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
'cajas',
|
'cajas',
|
||||||
|
'tipo_envio',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $useTimestamps = true;
|
protected $useTimestamps = true;
|
||||||
protected $createdField = 'created_at';
|
protected $createdField = 'created_at';
|
||||||
protected $updatedField = 'updated_at';
|
protected $updatedField = 'updated_at';
|
||||||
|
|
||||||
public function getDatatableQuery(): BaseBuilder
|
public function getDatatableQuery($tipo_envio = "estandar"): BaseBuilder
|
||||||
{
|
{
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
@ -51,6 +52,24 @@ class EnvioModel extends Model
|
|||||||
$builder->join("lg_paises t3", "t3.id = t1.pais_id", "left");
|
$builder->join("lg_paises t3", "t3.id = t1.pais_id", "left");
|
||||||
$builder->join("pedidos t4", "t4.id = t2.pedido_id", "left");
|
$builder->join("pedidos t4", "t4.id = t2.pedido_id", "left");
|
||||||
$builder->join('ordenes_trabajo t5', 't5.pedido_id = t4.id');
|
$builder->join('ordenes_trabajo t5', 't5.pedido_id = t4.id');
|
||||||
|
$builder->where("t1.tipo_envio", $tipo_envio);
|
||||||
|
|
||||||
|
$builder->groupBy("t1.id");
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatatableQueryFerroPrototipo(): BaseBuilder
|
||||||
|
{
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t1.id, GROUP_CONCAT(DISTINCT t5.id) AS ots,
|
||||||
|
t1.att, t1.direccion, t1.ciudad, t3.nombre as pais, t1.cp, t1.email, t1.telefono, t1.finalizado"
|
||||||
|
);
|
||||||
|
$builder->join("lg_paises t3", "t3.id = t1.pais_id", "left");
|
||||||
|
$builder->join("pedidos t4", "t4.id = t2.pedido_id", "left");
|
||||||
|
$builder->join('ordenes_trabajo t5', 't5.pedido_id = t4.id');
|
||||||
|
$builder->whereIn("t1.tipo_envio", ["estandar"]);
|
||||||
|
|
||||||
$builder->groupBy("t1.id");
|
$builder->groupBy("t1.id");
|
||||||
return $builder;
|
return $builder;
|
||||||
|
|||||||
@ -45,6 +45,7 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel
|
|||||||
"proveedor_id",
|
"proveedor_id",
|
||||||
"proveedor",
|
"proveedor",
|
||||||
"entregaPieCalle",
|
"entregaPieCalle",
|
||||||
|
"is_ferro_prototipo"
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity";
|
protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity";
|
||||||
@ -69,7 +70,8 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel
|
|||||||
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t2.nombre AS pais,
|
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t2.nombre AS pais,
|
||||||
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono,
|
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono,
|
||||||
t1.peso AS peso, t1.cantidad AS cantidad, t1.precio AS precio, t1.margen AS margen,
|
t1.peso AS peso, t1.cantidad AS cantidad, t1.precio AS precio, t1.margen AS margen,
|
||||||
t1.proveedor_id AS proveedor_id, t1.proveedor AS proveedor, t1.entregaPieCalle AS entregaPieCalle"
|
t1.proveedor_id AS proveedor_id, t1.proveedor AS proveedor, t1.entregaPieCalle AS entregaPieCalle,
|
||||||
|
t1.is_ferro_prototipo AS is_ferro_prototipo"
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||||
|
|||||||
@ -94,6 +94,7 @@ class LogisticaService
|
|||||||
WHERE el.pedido_id = p.id
|
WHERE el.pedido_id = p.id
|
||||||
AND el.presupuesto_id = pr.id
|
AND el.presupuesto_id = pr.id
|
||||||
AND e.finalizado = 1
|
AND e.finalizado = 1
|
||||||
|
AND e.tipo_envio = 'estandar'
|
||||||
) AS unidades_enviadas,
|
) AS unidades_enviadas,
|
||||||
pd.cantidad AS cantidad
|
pd.cantidad AS cantidad
|
||||||
")
|
")
|
||||||
@ -115,7 +116,47 @@ class LogisticaService
|
|||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function findDireccionesNewEnvio($pedido_id, $searchVal = "")
|
public static function findForNewEnvioFerro()
|
||||||
|
{
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
|
||||||
|
// 3. Subconsulta principal
|
||||||
|
$subBuilder = $db->table('pedidos_linea pl')
|
||||||
|
->select("
|
||||||
|
ot.id AS id,
|
||||||
|
CONCAT('[', ot.id, '] - ', pr.titulo) AS name,
|
||||||
|
p.id as pedido_id,
|
||||||
|
pr.id as presupuesto_id
|
||||||
|
")
|
||||||
|
->join('pedidos p', 'p.id = pl.pedido_id')
|
||||||
|
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||||
|
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||||
|
->join('ordenes_trabajo ot', 'ot.pedido_id = p.id')
|
||||||
|
->join('orden_trabajo_dates ot_dates', 'ot_dates.orden_trabajo_id = ot.id')
|
||||||
|
->whereIn('p.estado', ['finalizado', 'produccion'])
|
||||||
|
->where('ot_dates.pendiente_ferro_at IS NOT NULL')
|
||||||
|
->where('pd.is_ferro_prototipo', 1)
|
||||||
|
->groupBy('pl.id');
|
||||||
|
|
||||||
|
// 4. Envolver y filtrar por unidades pendientes
|
||||||
|
$builder = $db->table("({$subBuilder->getCompiledSelect(false)}) AS sub");
|
||||||
|
$builder->select('id, name');
|
||||||
|
$builder->orderBy('name', 'ASC');
|
||||||
|
|
||||||
|
$builder->where("
|
||||||
|
NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM envios e
|
||||||
|
INNER JOIN envios_lineas le ON le.envio_id = e.id
|
||||||
|
WHERE e.tipo_envio = 'ferro_prototipo'
|
||||||
|
AND (le.pedido_id = sub.pedido_id OR le.presupuesto_id = sub.presupuesto_id)
|
||||||
|
)
|
||||||
|
", null, false);
|
||||||
|
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function findDireccionesNewEnvio($ot_id, $searchVal = "")
|
||||||
{
|
{
|
||||||
|
|
||||||
$direcciones = [];
|
$direcciones = [];
|
||||||
@ -126,7 +167,9 @@ class LogisticaService
|
|||||||
->join('presupuestos pr', 'pr.id=presupuesto_direcciones.presupuesto_id')
|
->join('presupuestos pr', 'pr.id=presupuesto_direcciones.presupuesto_id')
|
||||||
->join('pedidos_linea pl', 'pl.presupuesto_id = pr.id')
|
->join('pedidos_linea pl', 'pl.presupuesto_id = pr.id')
|
||||||
->join('pedidos p', 'pl.pedido_id=p.id')
|
->join('pedidos p', 'pl.pedido_id=p.id')
|
||||||
->where('p.id', $pedido_id);
|
->join('ordenes_trabajo ot', 'ot.pedido_id = p.id')
|
||||||
|
->where('ot.id', $ot_id)
|
||||||
|
->where("presupuesto_direcciones.is_ferro_prototipo", 0);
|
||||||
if ($searchVal != "") {
|
if ($searchVal != "") {
|
||||||
$dirs = $dirs->groupStart()
|
$dirs = $dirs->groupStart()
|
||||||
->Like("id", $searchVal)
|
->Like("id", $searchVal)
|
||||||
@ -138,10 +181,13 @@ class LogisticaService
|
|||||||
$unidades_en_direccion = $modelEnvioLineasModel->select('SUM(envios_lineas.unidades_envio) as unidades_enviadas,
|
$unidades_en_direccion = $modelEnvioLineasModel->select('SUM(envios_lineas.unidades_envio) as unidades_enviadas,
|
||||||
envios_lineas.unidades_total')
|
envios_lineas.unidades_total')
|
||||||
->join('envios', 'envios.id = envios_lineas.envio_id')
|
->join('envios', 'envios.id = envios_lineas.envio_id')
|
||||||
->where('pedido_id', $pedido_id)
|
->join('pedidos_linea', 'pedidos_linea.pedido_id = envios_lineas.pedido_id')
|
||||||
|
->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id')
|
||||||
|
->join('ordenes_trabajo', 'ordenes_trabajo.pedido_id = pedidos.id')
|
||||||
|
->where('ordenes_trabajo.id', $ot_id)
|
||||||
->where('envios.direccion', $direccion->direccion)
|
->where('envios.direccion', $direccion->direccion)
|
||||||
->where('envios.finalizado', 1)
|
->where('envios.finalizado', 1)
|
||||||
->groupBy('pedido_id')->get()->getResult();
|
->groupBy('ordenes_trabajo.pedido_id')->get()->getResult();
|
||||||
if (count($unidades_en_direccion) == 0 || $unidades_en_direccion[0]->unidades_enviadas < $unidades_en_direccion[0]->unidades_total) {
|
if (count($unidades_en_direccion) == 0 || $unidades_en_direccion[0]->unidades_enviadas < $unidades_en_direccion[0]->unidades_total) {
|
||||||
array_push(
|
array_push(
|
||||||
$direcciones,
|
$direcciones,
|
||||||
@ -196,6 +242,7 @@ class LogisticaService
|
|||||||
->join('pedidos p', 'p.id = pl.pedido_id')
|
->join('pedidos p', 'p.id = pl.pedido_id')
|
||||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||||
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||||
|
->where('pd.is_ferro_prototipo', 0)
|
||||||
->where('p.id', $pedido_id)
|
->where('p.id', $pedido_id)
|
||||||
->whereIn('p.estado', ['finalizado', 'produccion'])
|
->whereIn('p.estado', ['finalizado', 'produccion'])
|
||||||
->where("TRIM(LOWER(pd.direccion)) = '$direccionNormalizada'", null, false)
|
->where("TRIM(LOWER(pd.direccion)) = '$direccionNormalizada'", null, false)
|
||||||
@ -242,7 +289,7 @@ class LogisticaService
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function generateEnvio($pedido_id, $direccion = null)
|
public static function generateEnvio($ot_id, $direccion = null)
|
||||||
{
|
{
|
||||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||||
$direccionNormalizada = strtolower(trim($direccion));
|
$direccionNormalizada = strtolower(trim($direccion));
|
||||||
@ -259,6 +306,7 @@ class LogisticaService
|
|||||||
presupuesto_direcciones.pais_id,
|
presupuesto_direcciones.pais_id,
|
||||||
presupuesto_direcciones.cantidad as cantidad_total,
|
presupuesto_direcciones.cantidad as cantidad_total,
|
||||||
presupuestos.cliente_id as cliente_id,
|
presupuestos.cliente_id as cliente_id,
|
||||||
|
ordenes_trabajo.pedido_id as pedido_id,
|
||||||
|
|
||||||
(
|
(
|
||||||
presupuesto_direcciones.cantidad - IFNULL((
|
presupuesto_direcciones.cantidad - IFNULL((
|
||||||
@ -275,7 +323,9 @@ class LogisticaService
|
|||||||
->join('pedidos_linea', 'pedidos_linea.presupuesto_id = presupuesto_direcciones.presupuesto_id')
|
->join('pedidos_linea', 'pedidos_linea.presupuesto_id = presupuesto_direcciones.presupuesto_id')
|
||||||
->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id')
|
->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id')
|
||||||
->join('presupuestos', 'pedidos_linea.presupuesto_id = presupuestos.id')
|
->join('presupuestos', 'pedidos_linea.presupuesto_id = presupuestos.id')
|
||||||
->where('pedidos.id', $pedido_id)
|
->join('ordenes_trabajo', 'ordenes_trabajo.pedido_id = pedidos.id')
|
||||||
|
->where('ordenes_trabajo.id', $ot_id)
|
||||||
|
->where('presupuesto_direcciones.is_ferro_prototipo', 0)
|
||||||
->like('presupuesto_direcciones.direccion', $direccion)
|
->like('presupuesto_direcciones.direccion', $direccion)
|
||||||
->groupBy('presupuesto_direcciones.id')
|
->groupBy('presupuesto_direcciones.id')
|
||||||
->first();
|
->first();
|
||||||
@ -311,7 +361,7 @@ class LogisticaService
|
|||||||
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||||
$EnvioLineasModel->save([
|
$EnvioLineasModel->save([
|
||||||
'envio_id' => $idEnvio,
|
'envio_id' => $idEnvio,
|
||||||
'pedido_id' => $pedido_id,
|
'pedido_id' => $datosEnvio->pedido_id,
|
||||||
'unidades_envio' => $datosEnvio->cantidad,
|
'unidades_envio' => $datosEnvio->cantidad,
|
||||||
'unidades_total' => $datosEnvio->cantidad_total,
|
'unidades_total' => $datosEnvio->cantidad_total,
|
||||||
'cajas' => 1,
|
'cajas' => 1,
|
||||||
@ -332,6 +382,96 @@ class LogisticaService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function generateEnvioFerro($ot_id)
|
||||||
|
{
|
||||||
|
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||||
|
|
||||||
|
$datosEnvio = $presupuestoDireccionesModel
|
||||||
|
->select("
|
||||||
|
presupuestos.id as presupuesto_id,
|
||||||
|
presupuesto_direcciones.att,
|
||||||
|
presupuesto_direcciones.direccion,
|
||||||
|
presupuesto_direcciones.provincia as ciudad,
|
||||||
|
presupuesto_direcciones.cp,
|
||||||
|
presupuesto_direcciones.telefono,
|
||||||
|
presupuesto_direcciones.email,
|
||||||
|
presupuesto_direcciones.pais_id,
|
||||||
|
presupuesto_direcciones.cantidad as cantidad_total,
|
||||||
|
presupuestos.cliente_id as cliente_id,
|
||||||
|
ordenes_trabajo.pedido_id as pedido_id,
|
||||||
|
")
|
||||||
|
->join('pedidos_linea', 'pedidos_linea.presupuesto_id = presupuesto_direcciones.presupuesto_id')
|
||||||
|
->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id')
|
||||||
|
->join('presupuestos', 'pedidos_linea.presupuesto_id = presupuestos.id')
|
||||||
|
->join('ordenes_trabajo', 'ordenes_trabajo.pedido_id = pedidos.id')
|
||||||
|
->where('ordenes_trabajo.id', $ot_id)
|
||||||
|
->where('presupuesto_direcciones.is_ferro_prototipo', 1)
|
||||||
|
->where("
|
||||||
|
NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM envios e
|
||||||
|
INNER JOIN envios_lineas el ON el.envio_id = e.id
|
||||||
|
WHERE e.tipo_envio = 'ferro_prototipo'
|
||||||
|
AND (el.pedido_id = pedidos.id OR el.presupuesto_id = presupuestos.id)
|
||||||
|
)
|
||||||
|
", null, false) // <= Esta es la parte nueva, importante
|
||||||
|
->groupBy('presupuesto_direcciones.id')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
// Validación si no hay datos o no quedan unidades
|
||||||
|
if (empty($datosEnvio)) {
|
||||||
|
return [
|
||||||
|
'status' => false,
|
||||||
|
'message' => lang('Logistica.errors.noAddresses')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crear envío
|
||||||
|
$EnvioModel = model('App\Models\Logistica\EnvioModel');
|
||||||
|
$EnvioModel->set([
|
||||||
|
'cliente_id' => $datosEnvio->cliente_id,
|
||||||
|
'att' => $datosEnvio->att,
|
||||||
|
'direccion' => $datosEnvio->direccion,
|
||||||
|
'ciudad' => $datosEnvio->ciudad,
|
||||||
|
'cp' => $datosEnvio->cp,
|
||||||
|
'telefono' => $datosEnvio->telefono,
|
||||||
|
'email' => $datosEnvio->email,
|
||||||
|
'pais_id' => $datosEnvio->pais_id,
|
||||||
|
'cantidad' => 1,
|
||||||
|
'cajas' => 1,
|
||||||
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
|
'updated_at' => date('Y-m-d H:i:s'),
|
||||||
|
'tipo_envio' => 'ferro_prototipo',
|
||||||
|
]);
|
||||||
|
$EnvioModel->insert();
|
||||||
|
$idEnvio = $EnvioModel->insertID();
|
||||||
|
|
||||||
|
// Crear línea de envío
|
||||||
|
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||||
|
$EnvioLineasModel->save([
|
||||||
|
'envio_id' => $idEnvio,
|
||||||
|
'pedido_id' => $datosEnvio->pedido_id,
|
||||||
|
'unidades_envio' => 1,
|
||||||
|
'unidades_total' => 1,
|
||||||
|
'cajas' => 1,
|
||||||
|
'unidades_cajas' => 1,
|
||||||
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
|
'updated_at' => date('Y-m-d H:i:s'),
|
||||||
|
'created_by' => auth()->user()->id,
|
||||||
|
'updated_by' => auth()->user()->id,
|
||||||
|
'presupuesto_id' => (int) $datosEnvio->presupuesto_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'status' => true,
|
||||||
|
'data' => [
|
||||||
|
'id_envio' => $idEnvio,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function finalizarEnvio($envio_id, $finalizar_ot = false)
|
public static function finalizarEnvio($envio_id, $finalizar_ot = false)
|
||||||
{
|
{
|
||||||
// hay que comprobar que para todas las lineas de envio de este envio
|
// hay que comprobar que para todas las lineas de envio de este envio
|
||||||
@ -383,24 +523,36 @@ class LogisticaService
|
|||||||
$cantidad_enviada = $cantidad_enviada[0]->unidades_enviadas;
|
$cantidad_enviada = $cantidad_enviada[0]->unidades_enviadas;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cantidad_enviada + $linea->unidades_envio == $pedido->total_tirada) {
|
if ($envio->tipo_envio == 'ferro_prototipo') {
|
||||||
$otModel = model('App\Models\OrdenTrabajo\OrdenTrabajoModel');
|
$otModel = model('App\Models\OrdenTrabajo\OrdenTrabajoModel');
|
||||||
$ot = $otModel->where('pedido_id', $linea->pedido_id)
|
$ot = $otModel->where('pedido_id', $linea->pedido_id)
|
||||||
->first();
|
->first();
|
||||||
$ps = (new ProductionService())->init($ot->id);
|
$ps = (new ProductionService())->init($ot->id);
|
||||||
$ps->updateOrdenTrabajoDate([
|
$ps->updateOrdenTrabajoDate([
|
||||||
"name" => "envio_at",
|
"name" => "ferro_en_cliente_at",
|
||||||
"envio_at" => date('Y-m-d H:i:s')
|
"ferro_en_cliente_at" => date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
if ($finalizar_ot) {
|
} else {
|
||||||
$ps->updateOrdenTrabajo(
|
if ($cantidad_enviada + $linea->unidades_envio == $pedido->total_tirada) {
|
||||||
[
|
$otModel = model('App\Models\OrdenTrabajo\OrdenTrabajoModel');
|
||||||
"estado" => 'F'
|
$ot = $otModel->where('pedido_id', $linea->pedido_id)
|
||||||
]
|
->first();
|
||||||
);
|
$ps = (new ProductionService())->init($ot->id);
|
||||||
array_push($ots, $ot->id);
|
$ps->updateOrdenTrabajoDate([
|
||||||
|
"name" => "envio_at",
|
||||||
|
"envio_at" => date('Y-m-d H:i:s')
|
||||||
|
]);
|
||||||
|
if ($finalizar_ot) {
|
||||||
|
$ps->updateOrdenTrabajo(
|
||||||
|
[
|
||||||
|
"estado" => 'F'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
array_push($ots, $ot->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$EnvioModel->update($envio_id, ['finalizado' => 1]);
|
$EnvioModel->update($envio_id, ['finalizado' => 1]);
|
||||||
@ -424,19 +576,19 @@ class LogisticaService
|
|||||||
$data = [
|
$data = [
|
||||||
"printer" => $printer->name,
|
"printer" => $printer->name,
|
||||||
"header" => [
|
"header" => [
|
||||||
"_FORMAT" => "E:PEDIDO.ZPL",
|
"_FORMAT" => "E:PEDIDO.ZPL",
|
||||||
"_QUANTITY" => 1,
|
"_QUANTITY" => 1,
|
||||||
"_PRINBTERNAME" => $printer->name,
|
"_PRINBTERNAME" => $printer->name,
|
||||||
"_JOBNAME" => "LBL101"
|
"_JOBNAME" => "LBL101"
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($lineas as $linea) {
|
foreach ($lineas as $linea) {
|
||||||
$data["labels"][] = [
|
$data["labels"][] = [
|
||||||
"cliente" => $envio->cliente,
|
"cliente" => $envio->cliente,
|
||||||
"titulo" => "[" . $linea->pedido_id . "] - " . $linea->titulo,
|
"titulo" => "[" . $linea->pedido_id . "] - " . $linea->titulo,
|
||||||
"cantidad" => $linea->unidades_envio,
|
"cantidad" => $linea->unidades_envio,
|
||||||
"tirada" => $linea->unidades_total,
|
"tirada" => $linea->unidades_total,
|
||||||
"cajas" => $cajas,
|
"cajas" => $cajas,
|
||||||
"ean" => null,
|
"ean" => null,
|
||||||
"nombre" => $envio->att,
|
"nombre" => $envio->att,
|
||||||
@ -449,15 +601,15 @@ class LogisticaService
|
|||||||
|
|
||||||
$servicioImpresora = new ImpresoraEtiquetaService();
|
$servicioImpresora = new ImpresoraEtiquetaService();
|
||||||
$xml = $servicioImpresora->createEtiqueta($data);
|
$xml = $servicioImpresora->createEtiqueta($data);
|
||||||
if($xml == null){
|
if ($xml == null) {
|
||||||
return [
|
return [
|
||||||
'status' => false,
|
'status' => false,
|
||||||
'message' => lang('Logistica.errors.noEtiquetas'),
|
'message' => lang('Logistica.errors.noEtiquetas'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$sk_environment = getenv('SK_ENVIRONMENT');
|
$sk_environment = getenv('SK_ENVIRONMENT');
|
||||||
if($sk_environment == 'production'){
|
if ($sk_environment == 'production') {
|
||||||
|
|
||||||
$status = $servicioImpresora->sendToImpresoraEtiqueta("ETIQUETA", $xml, $printer);
|
$status = $servicioImpresora->sendToImpresoraEtiqueta("ETIQUETA", $xml, $printer);
|
||||||
if ($status) {
|
if ($status) {
|
||||||
return [
|
return [
|
||||||
@ -472,7 +624,7 @@ class LogisticaService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
return [
|
return [
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'message' => lang('Logistica.success.imprimirEtiquetas'),
|
'message' => lang('Logistica.success.imprimirEtiquetas'),
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h4><?= $boxTitle ?>
|
<h4><?= $boxTitle ?>
|
||||||
|
<?= ($envioEntity->tipo_envio == 'ferro_prototipo') ? '<span class="badge text-bg-warning fw-lg">FERRO</span>':'' ?>
|
||||||
<?= ($envioEntity->finalizado == 0) ? '' : '<span class="badge text-bg-success fw-lg">FINALIZADO</span>' ?>
|
<?= ($envioEntity->finalizado == 0) ? '' : '<span class="badge text-bg-success fw-lg">FINALIZADO</span>' ?>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -18,7 +19,6 @@
|
|||||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||||
|
|
||||||
<input type="hidden" id="id" name="id" value="<?= $envioEntity->id ?>">
|
<input type="hidden" id="id" name="id" value="<?= $envioEntity->id ?>">
|
||||||
<input type="hidden" id="nextCaja" name="next_caja" value="<?= $envioEntity->nextCaja ?>">
|
|
||||||
|
|
||||||
<div class="accordion accordion-bordered">
|
<div class="accordion accordion-bordered">
|
||||||
<div class="card accordion-item active mb-5">
|
<div class="card accordion-item active mb-5">
|
||||||
@ -114,7 +114,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($envioEntity->finalizado == 0): ?>
|
<?php if ($envioEntity->finalizado == 0 && $envioEntity->tipo_envio=='estandar'): ?>
|
||||||
<div class="accordion accordion-bordered">
|
<div class="accordion accordion-bordered">
|
||||||
<div class="card accordion-item active mb-5">
|
<div class="card accordion-item active mb-5">
|
||||||
<h4 class="accordion-header px-4 py-3">
|
<h4 class="accordion-header px-4 py-3">
|
||||||
@ -172,7 +172,7 @@
|
|||||||
<i class="ti ti-select"></i>
|
<i class="ti ti-select"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($envioEntity->finalizado == 0): ?>
|
<?php if ($envioEntity->finalizado == 0 && $envioEntity->tipo_envio=='estandar'): ?>
|
||||||
<div class="col-sm-2 px-3">
|
<div class="col-sm-2 px-3">
|
||||||
<button id="btnEliminarLineas" name="btnEliminarLineas" tabindex="1"
|
<button id="btnEliminarLineas" name="btnEliminarLineas" tabindex="1"
|
||||||
class="btn btn-danger w-100">
|
class="btn btn-danger w-100">
|
||||||
@ -336,6 +336,7 @@
|
|||||||
<ti class="ti ti-check"></ti>
|
<ti class="ti ti-check"></ti>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if ($envioEntity->tipo_envio=='estandar'): ?>
|
||||||
<div class="col-sm-3 px-3">
|
<div class="col-sm-3 px-3">
|
||||||
<button id="finalizarEnvioYOTs" name="finalizar_envio_ots" tabindex="1"
|
<button id="finalizarEnvioYOTs" name="finalizar_envio_ots" tabindex="1"
|
||||||
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
||||||
@ -343,6 +344,7 @@
|
|||||||
<ti class="ti ti-checks"></ti>
|
<ti class="ti ti-checks"></ti>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,97 +0,0 @@
|
|||||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
|
||||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
|
||||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
|
||||||
|
|
||||||
<?= $this->section('content'); ?>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h4><?= $boxTitle ?></h4>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
|
|
||||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
|
||||||
|
|
||||||
<div class="card accordion-item active mb-5">
|
|
||||||
<h4 class="accordion-header px-4 py-3">
|
|
||||||
<?= lang("Logistica.nuevoEnvio") ?>
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<div id="accordionNuevoEnvioTip" class="accordion-collapse collapse show">
|
|
||||||
<div class="accordion-body px-4 py-3">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="mb-1 col-sm-4">
|
|
||||||
<label for="buscadorPedidos" class="form-label">
|
|
||||||
<?= lang("Logistica.buscadorPedidosTitle") ?>
|
|
||||||
</label>
|
|
||||||
<input id="buscadorPedidos" name="buscador_pedidos" tabindex="1" maxlength="50"
|
|
||||||
class="form-control" value="">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="card accordion-item active">
|
|
||||||
<h4 class="accordion-header px-4 py-3">
|
|
||||||
<?= lang("Logistica.listadoEnvios") ?>
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<div id="accordionListadoEnviosTip" class="accordion-collapse collapse show">
|
|
||||||
<div class="accordion-body px-4 py-3">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<table id="tableOfEnvios" class="table table-striped table-hover w-100">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th><?= lang('Logistica.idEnvio') ?? 'ID Envío' ?></th>
|
|
||||||
<th><?= lang('Logistica.numeroOts') ?? 'Nº OTs' ?></th>
|
|
||||||
<th><?= lang('Logistica.numeroLineas') ?? 'Nº Líneas' ?></th>
|
|
||||||
<th><?= lang('Logistica.att') ?? 'Att' ?></th>
|
|
||||||
<th><?= lang('Logistica.direccion') ?? 'Dirección' ?></th>
|
|
||||||
<th><?= lang('Logistica.ciudad') ?? 'Ciudad' ?></th>
|
|
||||||
<th><?= lang('Logistica.pais') ?? 'País' ?></th>
|
|
||||||
<th><?= lang('Logistica.cp') ?? 'CP' ?></th>
|
|
||||||
<th><?= lang('Logistica.email') ?? 'Email' ?></th>
|
|
||||||
<th><?= lang('Logistica.telefono') ?? 'Teléfono' ?></th>
|
|
||||||
<th><?= lang('Logistica.finalizado') ?? 'Finalizado' ?></th>
|
|
||||||
<th><?= lang('Logistica.acciones') ?? 'Acciones' ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-3">
|
|
||||||
<button type="button" class="btn btn-secondary" id="btnImprimirEtiquetas"
|
|
||||||
onclick="window.location.href='<?= route_to('LogisticaPanel') ?>'">
|
|
||||||
<?= lang('Logistica.backToPanel') ?>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section('css') ?>
|
|
||||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
|
|
||||||
<?= $this->section('additionalExternalJs') ?>
|
|
||||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
|
||||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/logistica/envio.js") ?>"></script>
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
@ -12,6 +12,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
|
<input type="hidden" id="tipo_envio" value="<?= $tipo_envio ?>" />
|
||||||
|
|
||||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||||
|
|
||||||
<div class="card accordion-item active mb-5">
|
<div class="card accordion-item active mb-5">
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
<img src="<?= site_url("assets/img/logistica/envios.jpg") ?>" alt="Envíos">
|
<img src="<?= site_url("assets/img/logistica/envios.jpg") ?>" alt="Envíos">
|
||||||
<div><span><?= lang("Logistica.gestionEnvios"); ?></span></div>
|
<div><span><?= lang("Logistica.gestionEnvios"); ?></span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item" onclick="location.href='<?= route_to('gestionEnviosFerros') ?>'">
|
||||||
<img src="<?= site_url("assets/img/logistica/envios_ferros.png") ?>" alt="Envío de Ferros/Prototipos">
|
<img src="<?= site_url("assets/img/logistica/envios_ferros.png") ?>" alt="Envío de Ferros/Prototipos">
|
||||||
<div><span><?= lang("Logistica.envioFerros"); ?></span></div>
|
<div><span><?= lang("Logistica.envioFerros"); ?></span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
|
||||||
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
|
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
|
||||||
<th class="lp-header">Pallets?</th>
|
<th class="lp-header">Pallets?</th>
|
||||||
|
<th class="lp-header">Ferro o Prototipo?</th>
|
||||||
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
|
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -60,6 +61,7 @@
|
|||||||
<button id="insertar_direccion" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
<button id="insertar_direccion" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div> <!-- //.accordion-body -->
|
</div> <!-- //.accordion-body -->
|
||||||
</div> <!-- //.accordion-collapse -->
|
</div> <!-- //.accordion-collapse -->
|
||||||
</div> <!-- //.accordion-item -->
|
</div> <!-- //.accordion-item -->
|
||||||
|
|||||||
@ -8,6 +8,15 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div id='error-tarifa'></div>
|
<div id='error-tarifa'></div>
|
||||||
|
|
||||||
|
<div class="mb-3" id="direccionFerroProto">
|
||||||
|
<label for="dirFerroProto" class="form-label">
|
||||||
|
Dirección Ferro o Prototipo
|
||||||
|
</label>
|
||||||
|
<input type="checkbox" id="dirFerroProto" class="form-check-input">
|
||||||
|
|
||||||
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_clientedAdd" class="form-label">
|
<label for="add_clientedAdd" class="form-label">
|
||||||
<?= lang('PresupuestosDirecciones.clientedAdd') ?>*
|
<?= lang('PresupuestosDirecciones.clientedAdd') ?>*
|
||||||
|
|||||||
@ -4,11 +4,14 @@ import ClassSelect from '../../components/select2.js';
|
|||||||
$(() => {
|
$(() => {
|
||||||
|
|
||||||
let otsFilter = '';
|
let otsFilter = '';
|
||||||
|
const tipo_envio = $('#tipo_envio').val();
|
||||||
|
|
||||||
const selectPedidos = new ClassSelect($('#buscadorPedidos'), '/logistica/selectForNewEnvio', "");
|
const selectPedidos = new ClassSelect($('#buscadorPedidos'), '/logistica/selectForNewEnvio', "", true, {
|
||||||
|
tipo_envio: () => $('#tipo_envio').val()
|
||||||
|
});
|
||||||
selectPedidos.init();
|
selectPedidos.init();
|
||||||
const selectDirecciones = new ClassSelect($('#selectDirecciones'), '/logistica/selectDireccionForEnvio', "", true, {
|
const selectDirecciones = new ClassSelect($('#selectDirecciones'), '/logistica/selectDireccionForEnvio', "", true, {
|
||||||
pedido_id: () => selectPedidos.getVal()
|
ot_id: () => selectPedidos.getVal()
|
||||||
});
|
});
|
||||||
selectDirecciones.init();
|
selectDirecciones.init();
|
||||||
|
|
||||||
@ -19,7 +22,10 @@ $(() => {
|
|||||||
})
|
})
|
||||||
selectPedidos.item.on('change', () => {
|
selectPedidos.item.on('change', () => {
|
||||||
selectDirecciones.empty();
|
selectDirecciones.empty();
|
||||||
$('.select-direcciones').removeClass('d-none');
|
if(tipo_envio == 'ferro_prototipo')
|
||||||
|
$('.add-envio').removeClass('d-none');
|
||||||
|
else
|
||||||
|
$('.select-direcciones').removeClass('d-none');
|
||||||
})
|
})
|
||||||
selectDirecciones.item.on('select2:open', () => {
|
selectDirecciones.item.on('select2:open', () => {
|
||||||
$('.add-envio').addClass('d-none');
|
$('.add-envio').addClass('d-none');
|
||||||
@ -31,12 +37,24 @@ $(() => {
|
|||||||
|
|
||||||
|
|
||||||
$('#btnAddEnvio').on('click', () => {
|
$('#btnAddEnvio').on('click', () => {
|
||||||
const pedido_id = selectPedidos.getVal();
|
let url = '';
|
||||||
const direccionSeleccionada = selectDirecciones.getText();
|
let data = {};
|
||||||
$.post('/logistica/generateEnvio', {
|
if(tipo_envio == 'ferro_prototipo'){
|
||||||
pedido_id: pedido_id,
|
url = '/logistica/generateEnvioFerro';
|
||||||
direccion: direccionSeleccionada
|
data = {
|
||||||
}, function (response) {
|
ot_id: selectPedidos.getVal()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
url = '/logistica/generateEnvio';
|
||||||
|
data = {
|
||||||
|
ot_id: selectPedidos.getVal(),
|
||||||
|
direccion: selectDirecciones.getText()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
$.post(
|
||||||
|
url,
|
||||||
|
data, function (response) {
|
||||||
if (response.status) {
|
if (response.status) {
|
||||||
window.open(`${window.location.origin}/logistica/envio/${response.data.id_envio}`);
|
window.open(`${window.location.origin}/logistica/envio/${response.data.id_envio}`);
|
||||||
selectDirecciones.empty();
|
selectDirecciones.empty();
|
||||||
@ -51,7 +69,7 @@ $(() => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const tableEnvios = $('#tableOfEnvios').DataTable({
|
const tableEnvios = $('#tableOfEnvios').DataTable({
|
||||||
processing: true,
|
processing: true,
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
@ -66,6 +84,7 @@ $(() => {
|
|||||||
"url": "/logistica/datatableEnvios",
|
"url": "/logistica/datatableEnvios",
|
||||||
"data": function (d) {
|
"data": function (d) {
|
||||||
d.otsFilter = otsFilter;
|
d.otsFilter = otsFilter;
|
||||||
|
d.tipo_envio = $('#tipo_envio').val();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"columns": [
|
"columns": [
|
||||||
|
|||||||
@ -235,9 +235,35 @@ class DatosLibro {
|
|||||||
|
|
||||||
if (this.ferro.prop('checked')) {
|
if (this.ferro.prop('checked')) {
|
||||||
$(document).trigger('add-servicio-lineas', 'ferro');
|
$(document).trigger('add-servicio-lineas', 'ferro');
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas: false,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: true,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(document).trigger('remove-servicio-lineas', 'ferro');
|
$(document).trigger('remove-servicio-lineas', 'ferro');
|
||||||
|
if(!this.prototipo.prop('checked')){
|
||||||
|
const table = $('#tableOfDireccionesEnvio').DataTable();
|
||||||
|
const rows = table.rows().data();
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
const rowData = rows[i];
|
||||||
|
if (rowData.is_ferro_prototipo == 1) {
|
||||||
|
table.rows(i).remove();
|
||||||
|
table.draw();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas: false,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: true,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,9 +287,35 @@ class DatosLibro {
|
|||||||
|
|
||||||
if (this.prototipo.prop('checked')) {
|
if (this.prototipo.prop('checked')) {
|
||||||
$(document).trigger('add-servicio-lineas', 'prototipo');
|
$(document).trigger('add-servicio-lineas', 'prototipo');
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas: false,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: true,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(document).trigger('remove-servicio-lineas', 'prototipo');
|
$(document).trigger('remove-servicio-lineas', 'prototipo');
|
||||||
|
if(!this.ferro.prop('checked')){
|
||||||
|
const table = $('#tableOfDireccionesEnvio').DataTable();
|
||||||
|
const rows = table.rows().data();
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
const rowData = rows[i];
|
||||||
|
if (rowData.is_ferro_prototipo == 1) {
|
||||||
|
table.rows(i).remove();
|
||||||
|
table.draw();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas: false,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: true,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,7 @@ class Envios {
|
|||||||
},
|
},
|
||||||
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
|
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
|
||||||
{ 'data': 'entregaPieCalle' },
|
{ 'data': 'entregaPieCalle' },
|
||||||
|
{ 'data': 'is_ferro_prototipo' },
|
||||||
{
|
{
|
||||||
data: function (row, type, set, meta) {
|
data: function (row, type, set, meta) {
|
||||||
return `
|
return `
|
||||||
@ -87,7 +88,7 @@ class Envios {
|
|||||||
orderable: false,
|
orderable: false,
|
||||||
searchable: false,
|
searchable: false,
|
||||||
// all columns
|
// all columns
|
||||||
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
|
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||||
//targets: [$('#tableOfDireccionesEnvio').find("tr:first th").length - 1]
|
//targets: [$('#tableOfDireccionesEnvio').find("tr:first th").length - 1]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -97,7 +98,7 @@ class Envios {
|
|||||||
|
|
||||||
drawCallback: function (settings) {
|
drawCallback: function (settings) {
|
||||||
|
|
||||||
const boolCols = [15];
|
const boolCols = [15, 16];
|
||||||
for (let coln of boolCols) {
|
for (let coln of boolCols) {
|
||||||
self.table.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
|
self.table.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
|
||||||
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
||||||
@ -164,6 +165,19 @@ class Envios {
|
|||||||
$('#add_telefono').val(data.telefono)
|
$('#add_telefono').val(data.telefono)
|
||||||
$('#add_cantidad').val(data.cantidad)
|
$('#add_cantidad').val(data.cantidad)
|
||||||
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false)
|
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false)
|
||||||
|
$('#dirFerroProto').prop('checked', data.is_ferro_prototipo == 1 ? true : false)
|
||||||
|
|
||||||
|
if (data.is_ferro_prototipo == 1) {
|
||||||
|
$('#add_cantidad').val(1);
|
||||||
|
$('#add_cantidad').attr('disabled', true);
|
||||||
|
$('#dirFerroProto').prop('disabled', true);
|
||||||
|
$('#direccionFerroProto').removeClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#add_cantidad').attr('disabled', false);
|
||||||
|
$('#dirFerroProto').prop('disabled', false);
|
||||||
|
$('#direccionFerroProto').addClass('d-none');
|
||||||
|
}
|
||||||
|
|
||||||
self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
|
self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
|
||||||
self.direccionesClienteForm.init();
|
self.direccionesClienteForm.init();
|
||||||
@ -220,6 +234,7 @@ class Envios {
|
|||||||
let newAddDialog = $("#addressForm");
|
let newAddDialog = $("#addressForm");
|
||||||
this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
|
this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
|
||||||
this.direccionesClienteForm.init();
|
this.direccionesClienteForm.init();
|
||||||
|
|
||||||
let maximaCantidad = parseInt($('#tirada').val());
|
let maximaCantidad = parseInt($('#tirada').val());
|
||||||
$("#add_cantidad").attr("max", maximaCantidad);;
|
$("#add_cantidad").attr("max", maximaCantidad);;
|
||||||
$("#add_cantidad").val(maximaCantidad);
|
$("#add_cantidad").val(maximaCantidad);
|
||||||
@ -228,16 +243,39 @@ class Envios {
|
|||||||
})
|
})
|
||||||
|
|
||||||
let cantidad_total = 0;
|
let cantidad_total = 0;
|
||||||
|
let hasFerroPrototipo = false;
|
||||||
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
let data = this.data();
|
let data = this.data();
|
||||||
cantidad_total += parseInt(data.cantidad);
|
if (data.is_ferro_prototipo == 0)
|
||||||
|
cantidad_total += parseInt(data.cantidad);
|
||||||
|
else
|
||||||
|
hasFerroPrototipo = true;
|
||||||
});
|
});
|
||||||
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val()) - cantidad_total);
|
const restante = parseInt($('#tirada').val()) - cantidad_total;
|
||||||
$('#add_cantidad').val(parseInt($('#tirada').val()) - cantidad_total);
|
$('#add_cantidad').attr('max-value', restante);
|
||||||
|
$('#add_cantidad').val(restante > 0 ? restante : 0);
|
||||||
|
|
||||||
|
if (hasFerroPrototipo) {
|
||||||
|
$('#dirFerroProto').prop('checked', false);
|
||||||
|
$('#direccionFerroProto').addClass('d-none');
|
||||||
|
$('#add_cantidad').attr('disabled', false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (restante == 0) {
|
||||||
|
$('#direccionFerroProto').removeClass('d-none');
|
||||||
|
$('#dirFerroProto').prop('checked', true);
|
||||||
|
$('#dirFerroProto').prop('disabled', true);
|
||||||
|
$('#add_cantidad').attr('disabled', true);
|
||||||
|
$('#add_cantidad').val(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
newAddDialog.modal('show');
|
newAddDialog.modal('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
get_peso_libro() {
|
get_peso_libro() {
|
||||||
|
|
||||||
var peso_total_libro = 0.0
|
var peso_total_libro = 0.0
|
||||||
@ -277,11 +315,12 @@ class Envios {
|
|||||||
margen: data.margen,
|
margen: data.margen,
|
||||||
proveedor: data.proveedor,
|
proveedor: data.proveedor,
|
||||||
proveedor_id: data.proveedor_id,
|
proveedor_id: data.proveedor_id,
|
||||||
entregaPieCalle: data.entregaPieCalle
|
entregaPieCalle: data.entregaPieCalle,
|
||||||
|
is_ferro_prototipo: data.is_ferro_prototipo,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,11 +418,14 @@ class Envios {
|
|||||||
'precio': datos_tarifa.precio.toFixed(2),
|
'precio': datos_tarifa.precio.toFixed(2),
|
||||||
'margen': datos_tarifa.margen,
|
'margen': datos_tarifa.margen,
|
||||||
'entregaPieCalle': rowData.entregaPieCalle,
|
'entregaPieCalle': rowData.entregaPieCalle,
|
||||||
|
'is_ferro_prototipo': rowData.is_ferro_prototipo,
|
||||||
'actionBtns_direcciones': self.actionBtns_direcciones,
|
'actionBtns_direcciones': self.actionBtns_direcciones,
|
||||||
})
|
})
|
||||||
.draw();
|
.draw();
|
||||||
|
|
||||||
|
|
||||||
|
self.check_unidades_enviadas(null,null);
|
||||||
|
|
||||||
$(document).trigger('update-presupuesto', {
|
$(document).trigger('update-presupuesto', {
|
||||||
update_lineas: false,
|
update_lineas: false,
|
||||||
update_servicios: false,
|
update_servicios: false,
|
||||||
@ -566,6 +608,7 @@ class Envios {
|
|||||||
'precio': tarifa_final.precio,
|
'precio': tarifa_final.precio,
|
||||||
'margen': tarifa_final.margen,
|
'margen': tarifa_final.margen,
|
||||||
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0,
|
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0,
|
||||||
|
'is_ferro_prototipo': $('#dirFerroProto').is(":checked") ? 1 : 0,
|
||||||
'actionBtns_direcciones': `
|
'actionBtns_direcciones': `
|
||||||
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span>
|
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span>
|
||||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
|
||||||
@ -673,8 +716,12 @@ class Envios {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cantidad_total = 0
|
let cantidad_total = 0
|
||||||
|
let hasFerroPrototipo = false
|
||||||
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
cantidad_total += parseInt(this.data().cantidad)
|
if (this.data().is_ferro_prototipo == 0)
|
||||||
|
cantidad_total += parseInt(this.data().cantidad);
|
||||||
|
else
|
||||||
|
hasFerroPrototipo = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const tirada = parseInt($('#tirada').val());
|
const tirada = parseInt($('#tirada').val());
|
||||||
@ -695,7 +742,11 @@ class Envios {
|
|||||||
this.insertarEnvio.removeClass('d-none');
|
this.insertarEnvio.removeClass('d-none');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.insertarEnvio.addClass('d-none');
|
|
||||||
|
if (($('#ferro').is(':checked') || $('#prototipo').is(':checked')) && !hasFerroPrototipo)
|
||||||
|
this.insertarEnvio.removeClass('d-none');
|
||||||
|
else
|
||||||
|
this.insertarEnvio.addClass('d-none');
|
||||||
$('#alert-envios').html(htmlString);
|
$('#alert-envios').html(htmlString);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user