mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en resumen
This commit is contained in:
@ -11,6 +11,7 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"tarifa_encuadernado_id" => null,
|
||||
"precio_unidad" => null,
|
||||
"precio_total" => null,
|
||||
"margen" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
@ -19,5 +20,6 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"tarifa_encuadernado_id" => "int",
|
||||
"precio_unidad" => "float",
|
||||
"precio_total" => "float",
|
||||
"margen" => "float",
|
||||
];
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
4 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad", "margen"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -66,17 +66,22 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa['tarifa_id'], $tiempo, $tirada);
|
||||
if (count($tarifa_value)>0) {
|
||||
|
||||
$result_data[0] = floatval(1.0* $tarifa_value[0]->precio_hora* $tiempo / $tirada);
|
||||
$result_data[1] = floatval(1.0* $tarifa_value[0]->precio_hora* $tiempo) ;
|
||||
$precio_total = floatval(1.0* $tarifa_value[0]->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0);
|
||||
if (!$POD){
|
||||
$result_data[1] += floatval($tarifa_value[0]->tarifa_importe_fijo);
|
||||
$precio_total += floatval($tarifa_value[0]->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $precio_total * ($tarifa_value[0]->margen/100.0) ; // margen
|
||||
|
||||
array_push($tarifas,
|
||||
(object)[
|
||||
'tarifa_id'=> $tarifa['tarifa_id'],
|
||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
||||
]);
|
||||
@ -89,6 +94,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'total'=> 0,
|
||||
'margen' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -102,6 +108,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'margen'=> $result_data[2],
|
||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
||||
]);
|
||||
@ -114,6 +121,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'total'=> 0,
|
||||
'margen' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -162,6 +170,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'margen'=> $result_data[2],
|
||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
||||
];
|
||||
@ -174,6 +183,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'total'=> 0,
|
||||
'marge'=> 0,
|
||||
];
|
||||
return $ret_array;
|
||||
}
|
||||
@ -189,16 +199,21 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada, $proveedor_id);
|
||||
if (count($tarifa_value)>0) {
|
||||
|
||||
$result_data[0] = floatval(1.0* $tarifa_value[0]->precio_hora* $tiempo / $tirada);
|
||||
$result_data[1] = floatval(1.0* $tarifa_value[0]->precio_hora* $tiempo) ;
|
||||
$precio_total = floatval(1.0* $tarifa_value[0]->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0);
|
||||
if (!$POD){
|
||||
$result_data[1] += floatval($tarifa_value[0]->tarifa_importe_fijo);
|
||||
$precio_total += floatval($tarifa_value[0]->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $precio_total * ($tarifa_value[0]->margen/100.0) ; // margen
|
||||
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_encuadernacion_id,
|
||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
||||
];
|
||||
@ -211,6 +226,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'total'=> 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
return $ret_array;
|
||||
}
|
||||
@ -226,12 +242,13 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
|
||||
|
||||
$total = $precio_unidad * $paginas;
|
||||
$margen = $total * (floatval($tarifa->margen)/100.0);
|
||||
|
||||
if (!$is_POD){
|
||||
$total += floatval($tarifa->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
return [$precio_unidad, $total];
|
||||
return [$precio_unidad, $total, $margen];
|
||||
}
|
||||
|
||||
|
||||
@ -285,6 +302,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
->set('proveedor_id', $proveedor, false)
|
||||
->set('precio_unidad', $tarifa->precio_unidad)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
->update();
|
||||
|
||||
|
||||
@ -297,6 +315,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
->set('proveedor_id', $proveedor, false)
|
||||
->set('precio_unidad', $tarifa->precio_unidad)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
->insert();
|
||||
}
|
||||
}
|
||||
@ -315,7 +334,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_encuadernado_id AS tarifa_encuadernado_id, t1.precio_unidad AS precio_unidad,
|
||||
t1.precio_total AS precio_total, t2.nombre AS nombre, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor"
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
|
||||
@ -154,6 +154,7 @@
|
||||
<th><?= lang('Proveedores.proveedor') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -624,6 +625,10 @@
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
columnDefs: [{
|
||||
target: 5,
|
||||
visible: false
|
||||
}]
|
||||
|
||||
});
|
||||
|
||||
@ -651,7 +656,8 @@
|
||||
'</option>' +
|
||||
'</select>',
|
||||
'<span id="precio_unidad_encuadernado_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
|
||||
'<input id="precio_total_encuadernado_' + element.tarifa_encuadernado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||
'<input class="update-totales" id="precio_total_encuadernado_' + element.tarifa_encuadernado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||
'<span class="update-totales" id="margen_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_encuadernado_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
|
||||
@ -725,6 +731,7 @@
|
||||
|
||||
$('#precio_unidad_encuadernado_' + datos.tarifa_encuadernacion_id).text(parseFloat(data.values[0].precio_unidad).toFixed(2))
|
||||
$('#precio_total_encuadernado_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].total).toFixed(2))
|
||||
$('#margen_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].margen).toFixed(2))
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
return true;
|
||||
},
|
||||
@ -798,7 +805,8 @@
|
||||
'</option>' +
|
||||
'</select>',
|
||||
'<span id="precio_unidad_encuadernado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
|
||||
'<input id="precio_total_encuadernado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
|
||||
'<input class="update-totales" id="precio_total_encuadernado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
|
||||
'<span class="update-totales" id="margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
|
||||
@ -890,6 +898,9 @@
|
||||
case 4:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 5:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
@ -939,7 +950,7 @@
|
||||
element.tarifa_manipulado_id,
|
||||
element.nombre,
|
||||
'<span id="precio_unidad_manipulado_' + element.tarifa_manipulado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
|
||||
'<input id="precio_total_manipulado_' + element.tarifa_manipulado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||
'<input class="update-totales" id="precio_total_manipulado_' + element.tarifa_manipulado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_manipulado_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
|
||||
|
||||
@ -2698,12 +2698,12 @@ var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
/*columnDefs: [
|
||||
columnDefs: [
|
||||
{
|
||||
target: 12,
|
||||
visible: false
|
||||
}
|
||||
]*/
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -30,9 +30,9 @@
|
||||
<dd id="margenImpresion" class="col-2 py-1 text-end">NaN €</dd>
|
||||
|
||||
<dt class="col-6 fw-normal text-end">Coste servicios</dt>
|
||||
<dd class="col-6 text-end">NaN €</dd>
|
||||
<dd id="totalServicios" class="col-6 text-end">NaN €</dd>
|
||||
<dt class="col-6 fw-normal text-end">Margen servicios</dt>
|
||||
<dd class="col-6 text-end">NaN €</dd>
|
||||
<dd id="margenServicios" class="col-6 text-end">NaN €</dd>
|
||||
|
||||
<dt class="col-6 fw-normal text-end">Costes</dt>
|
||||
<dd class="col-6 text-end">NaN €</dd>
|
||||
@ -83,8 +83,20 @@ $(".update-totales").on("change", updateTotales)
|
||||
function updateTotales(){
|
||||
totalPapel = 0
|
||||
margenPapel = 0
|
||||
|
||||
totalImpresion = 0
|
||||
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
|
||||
|
||||
totalServicios = 0
|
||||
margenServicios = 0
|
||||
|
||||
tableLineasPresupuesto.rows({filter: 'applied'}).every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
|
||||
/*totalServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 4).node().lastChild.value)
|
||||
margenServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 5).node().lastChild.innerText)
|
||||
*/
|
||||
});
|
||||
|
||||
/*$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
|
||||
if($('#' + this.id + '_checkPapel').prop('checked')){
|
||||
totalPapel += parseFloat($('#' + this.id + '_totalPapelPedido').val())
|
||||
margenPapel += parseFloat($('#' + this.id + '_margenPapelPedido').val())
|
||||
@ -92,12 +104,37 @@ function updateTotales(){
|
||||
if($('#' + this.id + '_checkClicks').prop('checked')){
|
||||
totalImpresion += parseFloat($('#' + this.id + '_totalClicks').val())
|
||||
}
|
||||
})
|
||||
})*/
|
||||
|
||||
$('#totalCostePapel').text(totalPapel.toFixed(2) + '€')
|
||||
$('#margenPapel').text(margenPapel.toFixed(2) + '€')
|
||||
|
||||
$('#totalCosteImpresion').text(totalImpresion.toFixed(2) + '€')
|
||||
$('#margenImpresion').text((totalImpresion*$('#margenImpresionValue').val()/100.0).toFixed(2) + '€')
|
||||
|
||||
tableServiciosEnc.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
|
||||
totalServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 4).node().lastChild.value)
|
||||
margenServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 5).node().lastChild.innerText)
|
||||
|
||||
});
|
||||
|
||||
/*$('#tableOfServiciosEncuadernacion tbody tr').each(function(){
|
||||
console.log(this)
|
||||
var currentRow = $(this).closest("tr");
|
||||
var data = $('#myTable').DataTable().row(currentRow).data();
|
||||
console.log(data)
|
||||
//margenServicios += parseFloat(this.text())
|
||||
})*/
|
||||
/*$('#tableOfServiciosEncuadernacion tbody tr td:nth-child(4)').each(function(){
|
||||
totalServicios += parseFloat(this.text())
|
||||
})*/
|
||||
totalServicios -= margenServicios;
|
||||
$('#totalServicios').text(totalServicios.toFixed(2) + '€')
|
||||
$('#margenServicios').text(margenServicios.toFixed(2) + '€')
|
||||
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user