Hi, I have a Master/Detail application, and I created an PHP Method called update_master (like scriptcase samples).
sc_lookup(dataset,“SELECT SUM(cantidad*precio_unitario) FROM tmp_facturas_detalles WHERE id_factura = ‘{id_factura}’”);
sc_lookup(datos_iva,“SELECT valor FROM tb_configuracion WHERE nombre = ‘iva’”);
if(empty({dataset}))
{
sc_error_message(‘El accesorio especificado no tiene precio de venta asignado’);
}
else
{
$base_imponible = {dataset[0][0]};
$imponible = number_format($base_imponible, 2,’,’,’.’);
$porcentaje = rtrim({datos_iva[0][0]});
$porcentaje_modificado = “1.”.$porcentaje;
$montoTotal = $base_imponible * $porcentaje_modificado;
$montoTotal2 = number_format($montoTotal,2,’,’,’.’);
$montoIva = $montoTotal - $base_imponible;
$montoIva2 = number_format($montoIva,2,’,’,’.’);
$iva_sql = number_format($montoIva,2,’.’,’’);
$total_sql = number_format($montoTotal,2,’.’,’’);
sc_master_value(‘base_imponible’,$imponible);
sc_master_value(‘iva_monto’,$montoIva2);
sc_master_value(‘monto_total’,$montoTotal2);
sc_exec_sql(“UPDATE tmp_facturas SET base_imponible = “.$base_imponible.”, iva_monto = “.$iva_sql.”, iva_porcentaje = '”.$porcentaje."’, monto_total = “.$total_sql.” WHERE id = ‘".{id_factura}."’");
}
The problem is when I call the method in onAfterInsert Event (or whatever else), the code as written before works fine, but sc_master_value doesnt work and the values in the master form are not updated.
BUT if I call a non-declared variable the values in master form are updated, I mean, by example, If before sc_exec_sql() (or anywhere in the method) I write echo $anything, Master Form values are updated but (of course) I receive an error in the application and stops its execution.
Do I explain my problem well? if not please tell me in order to try to explain better, I do not speak english.
Thanks a lot (y)