mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into refactor/sk-21
This commit is contained in:
@ -72,9 +72,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -84,36 +84,36 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else :
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else :
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
@ -133,20 +133,20 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$papelGenerico = $this->model->find($id);
|
||||
|
||||
if ($papelGenerico == false) :
|
||||
if ($papelGenerico == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelGenerico.papelGenerico')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -159,24 +159,24 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
if ($this->request->getPost('show_in_client_special') == null) {
|
||||
$sanitizedData['show_in_client_special'] = false;
|
||||
}
|
||||
|
||||
if($sanitizedData['show_in_client_special']){
|
||||
|
||||
if ($sanitizedData['show_in_client_special']) {
|
||||
$sanitizedData['show_in_client'] = true;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
@ -186,17 +186,17 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $papelGenerico->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.';
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else :
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else :
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
@ -210,7 +210,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelGenerico.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
$this->viewData['usingServerSideDataTable'] = true;
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
@ -297,15 +297,14 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
public function getPapelCliente()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
|
||||
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
|
||||
$POD = null;
|
||||
if($tirada != null){
|
||||
if ($tirada != null) {
|
||||
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
if(intval($tirada) <= intval($POD_value)){
|
||||
if (intval($tirada) <= intval($POD_value)) {
|
||||
$POD = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$POD = false;
|
||||
}
|
||||
}
|
||||
@ -313,17 +312,38 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
$selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null;
|
||||
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
|
||||
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
|
||||
|
||||
$sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0;
|
||||
|
||||
$ancho = floatval($this->request->getGet('ancho') ?? 0);
|
||||
$alto = floatval($this->request->getGet('alto') ?? 0);
|
||||
$solapas = floatval($this->request->getGet('solapas') ?? 0);
|
||||
$lomo = floatval($this->request->getGet('lomo') ?? 0);
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
|
||||
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
|
||||
$forSelect2 = intval($this->request->getGet('forSelect2') ?? 0);
|
||||
|
||||
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
|
||||
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
|
||||
if ($forSelect2) {
|
||||
$menu = array_map(function ($item) {
|
||||
if (isset($item->id)) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'name' => $item->nombre
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'id' => $item->gramaje,
|
||||
'name' => $item->gramaje
|
||||
];
|
||||
}
|
||||
}, $menu);
|
||||
|
||||
return $this->respond($menu);
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
@ -340,23 +360,23 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function selectPapelEspecial()
|
||||
{
|
||||
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
|
||||
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
|
||||
$POD = null;
|
||||
if($tirada != null){
|
||||
if ($tirada != null) {
|
||||
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
if(intval($tirada) <= intval($POD_value)){
|
||||
if (intval($tirada) <= intval($POD_value)) {
|
||||
$POD = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$POD = false;
|
||||
}
|
||||
}
|
||||
$tipo = goSanitize($this->request->getGet('tipo'))[0];
|
||||
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
|
||||
|
||||
$sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0;
|
||||
|
||||
$ancho = floatval($this->request->getGet('ancho') ?? 0);
|
||||
$alto = floatval($this->request->getGet('alto') ?? 0);
|
||||
$solapas = floatval($this->request->getGet('solapas') ?? 0);
|
||||
@ -364,9 +384,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
$tapa_dura = $this->request->getGet('tapa_dura') ?? 0;
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$items = $this->model->getPapelCliente($tipo, $cubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
$items = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
$items = array_map(function ($item) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
|
||||
@ -97,6 +97,7 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $tirada, $proveedor, $POD);
|
||||
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||
$values[0]->faja = $tarifa['faja'] ?? 0;
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,6 +495,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
} else {
|
||||
$data['datosLibro']['acabadoSobrecubierta']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre;
|
||||
}
|
||||
$data['datosLibro']['acabadoFaja']['id'] = $presupuesto->acabado_faja_id;
|
||||
if ($presupuesto->acabado_faja_id == 0) {
|
||||
$data['datosLibro']['acabadoFaja']['text'] = "Ninguno";
|
||||
} else {
|
||||
$data['datosLibro']['acabadoFaja']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre;
|
||||
}
|
||||
$data['datosLibro']['prototipo'] = $presupuesto->prototipo;
|
||||
$data['datosLibro']['ferro'] = $presupuesto->ferro;
|
||||
$data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital;
|
||||
@ -1110,7 +1116,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$tirada);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_papel_generico.nombre", $this->request->getGet("q"))
|
||||
->orLike("t1.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
@ -1174,7 +1180,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$tirada);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_papel_impresion.gramaje", $this->request->getGet("q"))
|
||||
->orLike("t2.gramaje", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
@ -540,6 +540,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $sobrecubierta,
|
||||
'datos_guardas' => $datos_guardas,
|
||||
'faja' => $faja,
|
||||
|
||||
'servicios' => $reqData['servicios'] ?? [],
|
||||
);
|
||||
@ -694,7 +695,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
|
||||
$excluirRotativa = intval($excluirRotativa);
|
||||
|
||||
$tipo = $reqData['tipo'] ??'cosido';
|
||||
$tipo = $reqData['tipo'] ?? 'cosido';
|
||||
$tipoCubierta = 'blanda'; // solapas sólo tapa blanda y sobre cubierta
|
||||
|
||||
$isColor = intval($reqData['isColor']) ?? 0;
|
||||
@ -1054,6 +1055,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $sobrecubierta,
|
||||
'datos_guardas' => $datos_guardas,
|
||||
'faja' => $faja,
|
||||
|
||||
'servicios' => $reqData['servicios'] ?? [],
|
||||
);
|
||||
@ -1241,6 +1243,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$resultado_presupuesto['info']['merma'] = $this->calcular_merma($selected_tirada, $POD);
|
||||
|
||||
$datos_presupuesto['faja'] = $faja;
|
||||
|
||||
$id = $model_presupuesto->insertarPresupuestoCliente(
|
||||
$id,
|
||||
$selected_tirada,
|
||||
@ -1267,6 +1271,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['cubierta']);
|
||||
if (count($resultado_presupuesto['values']['sobrecubierta']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['sobrecubierta']);
|
||||
if (count($resultado_presupuesto['values']['faja']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['faja']);
|
||||
if (count($resultado_presupuesto['values']['guardas']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['guardas']);
|
||||
|
||||
@ -1293,6 +1299,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (is_array($faja) && intval($faja['acabado']) > 0) {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$servicio = $model->getPrecioTarifa(intval($faja['acabado']), intval($selected_tirada), -1, $POD);
|
||||
|
||||
if (count($servicio) > 0) {
|
||||
if ($servicio[0]->total > 0) {
|
||||
$this->guardarServicio($id, $servicio[0], 'acabado', false, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($resultado_presupuesto['values']['serviciosDefecto']['encuadernacion'] as $servicio) {
|
||||
$this->guardarServicio($id, $servicio, 'encuadernacion');
|
||||
@ -1475,6 +1492,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data['sobrecubierta']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre;
|
||||
}
|
||||
|
||||
if (array_key_exists('faja', $datos_papel)) {
|
||||
$data['faja']['papel'] = $datos_papel['faja'];
|
||||
$data['faja']['alto'] = $presupuesto->alto_faja_color;
|
||||
$data['faja']['solapas'] = 1;
|
||||
$data['faja']['solapas_ancho'] = $presupuesto->solapas_ancho_faja_color;
|
||||
$data['faja']['acabado']['id'] = $presupuesto->acabado_sobrecubierta_id;
|
||||
if ($presupuesto->acabado_faja_id == 0) {
|
||||
$data['faja']['acabado']['text'] = "Ninguno";
|
||||
} else {
|
||||
$data['faja']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre;
|
||||
}
|
||||
} else {
|
||||
$data['faja'] = [];
|
||||
}
|
||||
|
||||
$data['guardas'] = array_key_exists('guardas', $datos_papel) ? $datos_papel['guardas'] : [];
|
||||
|
||||
$modelLinea = new PresupuestoLineaModel();
|
||||
@ -1586,11 +1618,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if (!is_null($new_name)) {
|
||||
$path = WRITEPATH . 'uploads/presupuestos/' . $new_name;
|
||||
move_uploaded_file($tmp_name, $path);
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> main
|
||||
}
|
||||
}
|
||||
$ftp->uploadFilePresupuesto($presupuesto_id);
|
||||
@ -1684,7 +1711,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
protected function guardarServicio($presupuestoId, $servicio, $tipo, $cubierta = false, $sobrecubierta = false)
|
||||
protected function guardarServicio($presupuestoId, $servicio, $tipo, $cubierta = false, $sobrecubierta = false, $faja = false)
|
||||
{
|
||||
|
||||
if ($tipo == 'encuadernacion') {
|
||||
@ -1695,8 +1722,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'tarifa_encuadernado_id' => $servicio->tarifa_id,
|
||||
'proveedor_id' => $servicio->proveedor_id,
|
||||
'tiempo' => $servicio->tiempo,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'precio_total' => round($servicio->total, 2),
|
||||
'precio_unidad' => round($servicio->precio_unidad, 2),
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
|
||||
@ -1712,7 +1739,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_extra_id' => $servicio->tarifa_id,
|
||||
'precio' => $servicio->precio,
|
||||
'precio' => round($servicio->precio, 2),
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
@ -1728,6 +1755,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'proveedor_id' => $servicio->proveedor_id,
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $sobrecubierta,
|
||||
'faja' => $faja,
|
||||
];
|
||||
$model->insert($data);
|
||||
} else if ($tipo == 'manipulado') {
|
||||
@ -1736,8 +1764,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_manipulado_id' => $servicio->tarifa_id,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'precio_total' => round($servicio->total, 2),
|
||||
'precio_unidad' => round($servicio->precio_unidad, 2),
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
@ -1764,7 +1792,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$margen = 0;
|
||||
|
||||
|
||||
$peso_envio = round(floatval(floatval($peso) * floatval($unidades) / 1000.0)); // peso libro * unidades y se pasa a kilogramos
|
||||
$peso_envio = round(floatval(floatval($peso) * floatval($unidades) / 1000.0), 3); // peso libro * unidades y se pasa a kilogramos
|
||||
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($pais_id, $cp, $peso_envio, $entregaPieCalle ? 'palets' : 'cajas');
|
||||
for ($i = 0; $i < count($tarifas_envio); $i++) {
|
||||
if ($peso_envio > $tarifas_envio[$i]->peso_max || floatval($tarifas_envio[$i]->precio_max) == 0) {
|
||||
@ -1840,6 +1868,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
// Sobrecubierta
|
||||
$sobreCubierta = $datos_entrada["sobrecubierta"] ?? null;
|
||||
|
||||
// Faja
|
||||
$faja = $datos_entrada["faja"] ?? null;
|
||||
|
||||
// Guardas
|
||||
$datos_guardas = $datos_entrada['datos_guardas'] ?? [];
|
||||
|
||||
@ -1930,7 +1961,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$peso_interior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
$costeInterior += round(floatval($linea['total_impresion']), 2);
|
||||
$peso_interior += floatval($linea['peso']);
|
||||
$lomo += floatval($linea['mano']);
|
||||
$info['lomo_interior'] += floatval($linea['mano']);
|
||||
@ -1990,7 +2021,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
$costeInterior += round(floatval($linea['total_impresion']), 2);
|
||||
$peso_interior += floatval($linea['peso']);
|
||||
$lomo += floatval($linea['mano']);
|
||||
if ($extra_info) {
|
||||
@ -2042,7 +2073,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$coste_cubierta = 0.0;
|
||||
$peso_cubierta = 0.0;
|
||||
if (count($cubierta) > 0) {
|
||||
$coste_cubierta += floatval($cubierta['total_impresion']);
|
||||
$coste_cubierta += round(floatval($cubierta['total_impresion']), 2);
|
||||
$peso_cubierta += floatval($cubierta['peso']);
|
||||
$lomo += floatval($cubierta['mano']);
|
||||
if ($extra_info) {
|
||||
@ -2099,7 +2130,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
$coste_servicios += floatval($acabadoCubierta[0]->total);
|
||||
$coste_servicios += round(floatval($acabadoCubierta[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($acabadoCubierta[0]->total), 2);
|
||||
$base = round(floatval($acabadoCubierta[0]->total / (1 + $acabadoCubierta[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($acabadoCubierta[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2126,7 +2163,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$linea_sobrecubierta = PresupuestoClienteService::obtenerSobrecubierta($input_data);
|
||||
|
||||
if (count($linea_sobrecubierta) > 0) {
|
||||
$coste_sobrecubierta += floatval($linea_sobrecubierta['total_impresion']);
|
||||
$coste_sobrecubierta += round(floatval($linea_sobrecubierta['total_impresion']), 2);
|
||||
$peso_sobrecubierta += floatval($linea_sobrecubierta['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
@ -2184,7 +2221,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($acabadoSobrecubierta[0]->total);
|
||||
$coste_servicios += round(floatval($acabadoSobrecubierta[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($acabadoSobrecubierta[0]->total), 2);
|
||||
$base = round(floatval($acabadoSobrecubierta[0]->total / (1 + $acabadoSobrecubierta[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($acabadoSobrecubierta[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2220,7 +2263,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$guardas = PresupuestoClienteService::obtenerGuardas($input_data);
|
||||
|
||||
if (count($guardas) > 0) {
|
||||
$coste_guardas += floatval($guardas['total_impresion']);
|
||||
$coste_guardas += round(floatval($guardas['total_impresion']), 2);
|
||||
$peso_guardas += floatval($guardas['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
@ -2251,6 +2294,98 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$coste_faja = 0.0;
|
||||
$peso_faja = 0.0;
|
||||
$linea_faja = [];
|
||||
$acabadoFaja = [];
|
||||
if (!is_null($faja) && $faja && $faja != false) {
|
||||
|
||||
$input_data['papel_generico']['id'] = $faja['papel'] ?? 0;
|
||||
$input_data['gramaje'] = $faja['gramaje'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = 4;
|
||||
$input_data['datosPedido']->alto = floatval($faja['alto'] ?? 0);
|
||||
$input_data['paginas_color'] = 4;
|
||||
$input_data['datosPedido']->solapas_ancho = intval($faja['solapas'] ?? 0);
|
||||
$input_data['datosPedido']->solapas = 1;
|
||||
$input_data['datosPedido']->lomo = $this->calcular_lomo([$cubierta], $input_data['datosPedido']->lomo);
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'faja';
|
||||
|
||||
$linea_faja = PresupuestoClienteService::obtenerSobrecubierta($input_data);
|
||||
|
||||
if (count($linea_faja) > 0) {
|
||||
$linea_faja['tipo_linea'] = 'lp_faja';
|
||||
$coste_faja += round(floatval($linea_faja['total_impresion']), 2);
|
||||
$peso_faja += floatval($linea_faja['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
$this->calcular_coste_linea(
|
||||
$linea_faja,
|
||||
$totalPapel,
|
||||
$margenPapel,
|
||||
$sumForFactor,
|
||||
$totalImpresion,
|
||||
$margenImpresion
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($coste_faja <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener la faja',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
// Acabado faja
|
||||
if (intval($faja['acabado']) != 0) {
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$acabadoFaja = $model->getPrecioTarifa(intval($faja['acabado']), $datosPedido->tirada, -1, $POD);
|
||||
|
||||
if (count($acabadoFaja) > 0) {
|
||||
|
||||
if ($acabadoFaja[0]->total <= 0) {
|
||||
|
||||
$input_data['tarifas_acabado_faja'] = intval($faja['acabado']);
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener acabados de faja',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += round(floatval($acabadoFaja[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($acabadoFaja[0]->total), 2);
|
||||
$base = round(floatval($acabadoFaja[0]->total / (1 + $acabadoFaja[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($acabadoFaja[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($extra_info) {
|
||||
$totalPapel -= $margenPapel;
|
||||
$totalImpresion -= $margenImpresion;
|
||||
@ -2293,10 +2428,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
$costeServiciosDefecto += round(floatval($servicio->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($servicio->total);
|
||||
$margenServicios += floatval($servicio->total) * floatval($servicio->margen) / 100.0;
|
||||
$totalServicios += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada), 2)*$datosPedido->tirada;
|
||||
$margenServicios += round(floatval($servicio->total -$base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2328,10 +2465,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
$costeServiciosDefecto += round(floatval($servicio->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($servicio->total);
|
||||
$margenServicios += floatval($servicio->total) * floatval($servicio->margen) / 100.0;
|
||||
$totalServicios += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada), 2)*$datosPedido->tirada;
|
||||
$margenServicios += round(floatval($servicio->total -$base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2388,11 +2527,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value
|
||||
];
|
||||
|
||||
<<<<<<< HEAD
|
||||
// se comprueba si $datos guardas es un array
|
||||
=======
|
||||
// se comprueba si $datos guardas es un array
|
||||
>>>>>>> main
|
||||
if (is_array($datos_guardas)) {
|
||||
if (count($datos_guardas) > 0) {
|
||||
array_push($servicios, $servicio_plegado_guardas); // Plegado de guardas
|
||||
@ -2411,18 +2546,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($servicios, $servicio_prototipo);
|
||||
if ($datos_entrada['servicios']['ferro']) // extra
|
||||
array_push($servicios, $servicio_ferro);
|
||||
if ($input_data['datosPedido']->solapas_ancho > 0)
|
||||
if ($solapasCubierta > 0)
|
||||
array_push($servicios, $servicio_solapas_cubierta);
|
||||
if (!is_null($sobreCubierta) && $sobreCubierta) // Si hay sobrecubierta, siempre con solapas
|
||||
array_push($servicios, $servicio_solapas_sobrecubierta);
|
||||
<<<<<<< HEAD
|
||||
/* TO-DO
|
||||
=======
|
||||
/* TO-DO
|
||||
>>>>>>> main
|
||||
if (!is_null($faja) && $faja) // Si hay faja, siempre con solapas
|
||||
if (!is_null($faja) && $faja && $faja != false) // Si hay faja, siempre con solapas
|
||||
array_push($servicios, $servicio_solapas_faja);
|
||||
*/
|
||||
|
||||
|
||||
foreach ($servicios as $servicio) {
|
||||
|
||||
@ -2452,10 +2582,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
} else if ($servicio->nombre == "ferro" || $servicio->nombre == "prototipo") {
|
||||
// Extra
|
||||
@ -2482,13 +2614,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->precio);
|
||||
$coste_servicios += round(floatval($resultado[0]->precio), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->precio);
|
||||
$margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->precio), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
else if ($servicio->nombre == 'solapas_cubierta' || $servicio->nombre == 'solapas_sobrecubierta' || $servicio->nombre == 'solapas_faja'){
|
||||
} else if ($servicio->nombre == 'solapas_cubierta' || $servicio->nombre == 'solapas_sobrecubierta' || $servicio->nombre == 'solapas_faja') {
|
||||
// Servicios manipulado
|
||||
$resultado = PresupuestoCLienteService::getServiciosManipulado([
|
||||
'tarifa_id' => intval($servicio->id),
|
||||
@ -2515,10 +2648,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2551,10 +2686,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2586,22 +2723,68 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
// TO-DO Faja
|
||||
if (is_array($faja) && ($faja['solapas'] > 0 && intval($linea_faja['dimension_desarrollo']['ancho']) > 630)) {
|
||||
|
||||
array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4));
|
||||
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2));
|
||||
// Servicios manipulado
|
||||
$resultado = PresupuestoCLienteService::getServiciosManipulado([
|
||||
'tarifa_id' => intval($servicio_solapas_grandes_faja->id),
|
||||
'tirada' => $datosPedido->tirada,
|
||||
'POD' => $POD,
|
||||
]);
|
||||
|
||||
if ($resultado[0]->total <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener servicio de manupulado ' . ((string) $servicio->nombre),
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
} else {
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
$total_por_tirada = $costeInterior +
|
||||
$coste_cubierta +
|
||||
$coste_sobrecubierta +
|
||||
$coste_guardas +
|
||||
$coste_faja +
|
||||
$costeServiciosDefecto + $coste_servicios;
|
||||
array_push(
|
||||
$precio_u,
|
||||
round(($total_por_tirada) / $tirada[$t], 4)
|
||||
);
|
||||
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas + $peso_faja, 2));
|
||||
|
||||
if ($extra_info) {
|
||||
$totalServicios -= $margenServicios;
|
||||
if (($margenServicios + $totalServicios) > 0) {
|
||||
$porcentajeMargenServicios = $margenServicios / ($margenServicios + $totalServicios) * 100;
|
||||
$porcentajeMargenServicios = $margenServicios / ($totalServicios) * 100;
|
||||
} else {
|
||||
$porcentajeMargenServicios = 0;
|
||||
}
|
||||
@ -2638,6 +2821,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$return_data['values']['cubierta'] = $cubierta;
|
||||
$return_data['values']['sobrecubierta'] = $linea_sobrecubierta;
|
||||
$return_data['values']['guardas'] = $guardas;
|
||||
$return_data['values']['faja'] = $linea_faja;
|
||||
$return_data['values']['serviciosDefecto']['encuadernacion'] = $servDefectoEnc;
|
||||
$return_data['values']['serviciosDefecto']['manipulado'] = $servDefectoMan;
|
||||
$return_data['values']['servicios_automaticos'] = $serviciosAutomaticos;
|
||||
@ -2676,25 +2860,25 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
if (count($linea) == 0)
|
||||
return;
|
||||
$totalPapel += $linea['precio_pedido'];
|
||||
$margenPapel += $linea['margen_papel_pedido'];
|
||||
$sumForFactor += $linea['precio_pedido'];
|
||||
$sumForFactor -= $linea['precio_pedido'];
|
||||
$totalPapel += round($linea['precio_pedido'], 2);
|
||||
$margenPapel += round($linea['margen_papel_pedido'], 2);
|
||||
$sumForFactor += round($linea['precio_pedido'], 2);
|
||||
$sumForFactor -= round($linea['precio_pedido'], 2);
|
||||
|
||||
$totalImpresion += $linea['precio_impresion_horas'];
|
||||
$totalImpresion += $linea['precio_click_pedido'];
|
||||
$sumForFactor += $linea['precio_click_pedido'];
|
||||
$totalImpresion += round($linea['precio_impresion_horas'], 2);
|
||||
$totalImpresion += round($linea['precio_click_pedido'], 2);
|
||||
$sumForFactor += round($linea['precio_click_pedido'], 2);
|
||||
|
||||
if ($linea['tipo_maquina'] == 'inkjet') {
|
||||
$totalImpresion += $linea['precio_tinta'];
|
||||
$totalImpresion += round($linea['precio_tinta'], 2);
|
||||
if (array_key_exists('total_corte', $linea)) {
|
||||
$totalImpresion += $linea['total_corte'];
|
||||
$sumForFactor += $linea['total_corte'];
|
||||
$totalImpresion += round($linea['total_corte'], 2);
|
||||
$sumForFactor += round($linea['total_corte'], 2);
|
||||
}
|
||||
}
|
||||
$margenImpresion += $linea['margen_impresion_horas'];
|
||||
$margenImpresion += $linea['margen_click_pedido'];
|
||||
$sumForFactor -= $linea['margen_click_pedido'];
|
||||
$margenImpresion += round($linea['margen_impresion_horas'], 2);
|
||||
$margenImpresion += round($linea['margen_click_pedido'], 2);
|
||||
$sumForFactor -= round($linea['margen_click_pedido'], 2);
|
||||
}
|
||||
|
||||
protected function calcular_lomo($lineas, $lomo_inicial)
|
||||
@ -2980,6 +3164,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$return_data['sobrecubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['sobrecubierta']['gramaje'] = $linea->gramaje;
|
||||
$return_data['sobrecubierta']['paginas'] = $linea->paginas;
|
||||
} else if ($linea->tipo == 'lp_faja') {
|
||||
$return_data['faja']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id)['nombre'];
|
||||
$return_data['faja']['papel_id'] = $linea->papel_id;
|
||||
$return_data['faja']['gramaje'] = $linea->gramaje;
|
||||
$return_data['faja']['paginas'] = $linea->paginas;
|
||||
} else if ($linea->tipo == 'lp_guardas') {
|
||||
$return_data['guardas']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['guardas']['gramaje'] = $linea->gramaje;
|
||||
|
||||
@ -115,7 +115,20 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$values = $model->getPrecioTarifa($tarifa, $tirada, $POD);
|
||||
$tarifa_id = 0;
|
||||
if(is_array($tarifa)){
|
||||
//check if $tarifa['tarifa_manipulado_id'] exists
|
||||
if(array_key_exists('tarifa_manipulado_id', $tarifa)){
|
||||
$tarifa_id = $tarifa['tarifa_manipulado_id'];
|
||||
}
|
||||
else if(array_key_exists('tarifa_id', $tarifa)){
|
||||
$tarifa_id = $tarifa['tarifa_id'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
$tarifa_id = $tarifa;
|
||||
}
|
||||
$values = $model->getPrecioTarifa($tarifa_id, $tirada, $POD);
|
||||
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||
array_push($result, $values[0]);
|
||||
|
||||
@ -86,6 +86,21 @@ class Presupuestopreimpresiones extends \App\Controllers\BaseResourceController
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServiciosPreimpresion($datos_tarifas)
|
||||
{
|
||||
$result = [];
|
||||
$model = model('App\Models\Presupuestos\Presupuestopreimpresiones');
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$values = $model->getPrecioTarifa($tarifa);
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -86,6 +86,20 @@ class Presupuestoserviciosextra extends \App\Controllers\BaseResourceController
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServiciosExtra($datos_tarifas)
|
||||
{
|
||||
$result = [];
|
||||
$model = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$values = $model->getPrecioTarifa($tarifa);
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -88,10 +88,17 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$json_data_acabados = $reqData['json_acabados'] ?? null;
|
||||
$json_data_encuadernacion = $reqData['json_encuadernaciones'] ?? null;
|
||||
$json_data_manipulado = $reqData['json_manipulado'] ?? null;
|
||||
$json_data_preimpresion = $reqData['json_preimpresion'] ?? null;
|
||||
$json_data_extra = $reqData['json_extra'] ?? null;
|
||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||
|
||||
$faja_alto = $reqData['faja_alto'] ?? 0;
|
||||
$solapas_faja = $reqData['solapas_faja'] ?? 0;
|
||||
|
||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
|
||||
$values = [];
|
||||
|
||||
if ($json_data) {
|
||||
@ -120,14 +127,29 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
$datosPedido->isCosido = false;
|
||||
}
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta' || $linea['row_id'] == 'lp_cubierta') {
|
||||
$datosPedido->solapas =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta'] : $reqData['solapas_sobrecubierta'];
|
||||
$datosPedido->solapas_ancho =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta_ancho'] : $reqData['solapas_sobrecubierta_ancho'];
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta' || $linea['row_id'] == 'lp_cubierta' || $linea['row_id'] == 'lp_faja') {
|
||||
$datosPedido->solapas = $reqData['solapas_cubierta'];
|
||||
if ($linea['row_id'] == 'lp_faja') {
|
||||
$datosPedido->solapas = 1;
|
||||
$datosPedido->alto = $faja_alto;
|
||||
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta') {
|
||||
$datosPedido->solapas = $reqData['solapas_sobrecubierta'];
|
||||
}
|
||||
$datosPedido->solapas_ancho = $reqData['solapas_cubierta_ancho'];
|
||||
if ($linea['row_id'] == 'lp_faja') {
|
||||
$datosPedido->solapas_ancho = $solapas_faja;
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta') {
|
||||
$datosPedido->solapas_ancho = $reqData['solapas_sobrecubierta_ancho'];
|
||||
}
|
||||
$datosPedido->lomo = $reqData['lomo'];
|
||||
|
||||
$type = $linea['row_id'] == 'lp_cubierta' ? 'cubierta' : 'sobrecubierta';
|
||||
$type = 'lp_cubierta';
|
||||
if ($linea['row_id'] == 'lp_sobrecubierta') {
|
||||
$type = 'lp_sobrecubierta';
|
||||
} else if ($linea['row_id'] == 'lp_faja') {
|
||||
$type = 'lp_faja';
|
||||
}
|
||||
|
||||
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
@ -174,6 +196,9 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
case 'lp_sobrecubierta':
|
||||
$uso = 'sobrecubierta';
|
||||
break;
|
||||
case 'lp_faja':
|
||||
$uso = 'faja';
|
||||
break;
|
||||
case 'lp_guardas':
|
||||
$uso = 'guardas';
|
||||
break;
|
||||
@ -185,7 +210,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
break;
|
||||
}
|
||||
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'guardas') {
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja' || $uso == 'guardas') {
|
||||
$isColor = true;
|
||||
$isHq = true;
|
||||
$tipo = 'colorhq';
|
||||
@ -288,10 +313,10 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$result = $acabados->getServiciosAcabados($json_data_acabados, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,10 +331,10 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$result = $encuadernacion->getServiciosEncuadernacion($json_data_encuadernacion, $reqData['tirada'], $reqData['paginas'], $reqData['ancho'], $reqData['alto'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,10 +348,44 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$result = $manipulados->getServiciosManipulado($json_data_manipulado, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($json_data_preimpresion){
|
||||
$json_data_preimpresion = json_decode($json_data_preimpresion, true);
|
||||
if (count($json_data_preimpresion) > 0) {
|
||||
$preimpresion = new Presupuestopreimpresiones();
|
||||
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||
$result = $preimpresion->getServiciosPreimpresion($json_data_preimpresion);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($json_data_extra){
|
||||
$json_data_extra = json_decode($json_data_extra, true);
|
||||
if (count($json_data_extra) > 0) {
|
||||
$extra = new Presupuestoserviciosextra();
|
||||
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||
$result = $extra->getServiciosExtra($json_data_extra, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,8 +398,8 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$peso_libro = floatval($reqData['peso_libro']);
|
||||
// el primer envio con la tirada base
|
||||
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$envios = $model->getTarifaEnvio(1, 18000, $tirada_base * $peso_libro/1000.0, "cajas");
|
||||
$resultado = $this->calcular_envio($envios, $tirada_base * $peso_libro/1000.0);
|
||||
$envios = $model->getTarifaEnvio(1, 18000, $tirada_base * $peso_libro / 1000.0, "cajas");
|
||||
$resultado = $this->calcular_envio($envios, $tirada_base * $peso_libro / 1000.0);
|
||||
$coste_envio += $resultado->coste;
|
||||
$margen_envio += $resultado->margen;
|
||||
|
||||
@ -348,7 +407,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$json_envios = json_decode($json_envios, true);
|
||||
if (count($json_envios) > 0) {
|
||||
//la primera linea es el envio base
|
||||
for($i = 1; $i < count($json_envios); $i++) {
|
||||
for ($i = 1; $i < count($json_envios); $i++) {
|
||||
|
||||
$porcentaje = ($json_envios[$i]['cantidad']) / $tirada_base * 100.0;
|
||||
$cantidad = floor($reqData['tirada'] * $porcentaje / 100.0);
|
||||
@ -401,7 +460,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$m = (($envio->precio_max - $envio->precio_min) / ($envio->peso_max - $envio->peso_min));
|
||||
$b = $envio->precio_max - $m * $envio->peso_max;
|
||||
$coste_envio = number_format($m * $peso_envio + $b, 2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$margen_envio += $coste_envio * $envio->margen / 100.0;
|
||||
|
||||
@ -26,13 +26,13 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$model = model("\App\Models\Clientes\ClientePreciosModel");
|
||||
/*$model = model("\App\Models\Clientes\ClientePreciosModel");
|
||||
$model->debug_all_clientes_to_defecto();
|
||||
echo '<pre>';
|
||||
echo 'OK';
|
||||
echo '</pre>';
|
||||
echo '</pre>';*/
|
||||
|
||||
//xdebug_info();
|
||||
xdebug_info();
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user