hola dampudia, trato de usar tu código pero no funciona , en que parte del editviewdefs.php se tiene que ubicar el código que sugieres.
- el archivo se ubica en “custom/modules/Opportunities/metadata/editviewdefs.php”.
- el JS esta en ‘custom/modules/Opportunities/js/calculos.js’ (el directorio js no existía lo he creado.)
te muestro el código de editviewdefs.php , me parece que no funciona por que no lo he puesto en el lugar correcto. al final esta el JS espero me puedas ayudar , gracias de antemano.
<?php
$viewdefs ['Opportunities'] =
array (
'EditView' =>
array (
'templateMeta' =>
array (
'maxColumns' => '2',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
),
'javascript' => '{$PROBABILITY_SCRIPT}',
'useTabs' => true,
'tabDefs' =>
array (
'DEFAULT' =>
array (
'newTab' => true,
'panelDefault' => 'expanded',
),
'LBL_PANEL_ASSIGNMENT' =>
array (
'newTab' => true,
'panelDefault' => 'expanded',
),
'LBL_EDITVIEW_PANEL1' =>
array (
'newTab' => false,
'panelDefault' => 'expanded',
),
'LBL_EDITVIEW_PANEL2' =>
array (
'newTab' => false,
'panelDefault' => 'expanded',
),
'LBL_EDITVIEW_PANEL3' =>
array (
'newTab' => true,
'panelDefault' => 'expanded',
),
),
'syncDetailEditViews' => true,
),
'panels' =>
array (
'default' =>
array (
0 =>
array (
0 =>
array (
'name' => 'name',
),
1 => 'account_name',
),
1 =>
array (
0 =>
array (
'name' => 'ccanal_c',
'studio' => 'visible',
'label' => 'LBL_CCANAL',
),
1 => '',
),
2 =>
array (
0 =>
array (
'name' => 'currency_id',
'label' => 'LBL_CURRENCY',
),
1 =>
array (
'name' => 'date_closed',
),
),
3 =>
array (
0 => 'opportunity_type',
1 =>
array (
'name' => 'tipo_servicio_c',
'studio' => 'visible',
'label' => 'LBL_TIPO_SERVICIO',
),
),
4 =>
array (
0 =>
array (
'name' => 'estado_c',
'studio' => 'visible',
'label' => 'LBL_ESTADO',
),
1 =>
array (
'name' => 'lista_pre_c',
'studio' => 'visible',
'label' => 'LBL_LISTA_PRE',
),
),
5 =>
array (
0 =>
array (
'name' => 'cmotivo_anulacion_c',
'studio' => 'visible',
'label' => 'LBL_CMOTIVO_ANULACION',
),
1 => '',
),
),
'LBL_PANEL_ASSIGNMENT' =>
array (
0 =>
array (
0 =>
array (
'name' => 'op_producto_rel_c',
'studio' => 'visible',
'label' => 'LBL_OP_PRODUCTO_REL',
),
1 =>
array (
'name' => 'op_tipo_doc_vta_c',
'studio' => 'visible',
'label' => 'LBL_OP_TIPO_DOC_VTA',
),
),
1 =>
array (
0 =>
array (
'name' => 'op_farmacia_c',
'studio' => 'visible',
'label' => 'LBL_OP_FARMACIA',
),
1 =>
array (
'name' => 'ruc_c',
'label' => 'LBL_RUC',
),
),
2 =>
array (
0 =>
array (
'name' => 'cpais_c',
'studio' => 'visible',
'label' => 'LBL_CPAIS',
),
1 =>
array (
'name' => 'razonsocial_c',
'label' => 'LBL_RAZONSOCIAL',
),
),
3 =>
array (
0 =>
array (
'name' => 'cdepartamento_c',
'studio' => 'visible',
'label' => 'LBL_CDEPARTAMENTO',
),
1 =>
array (
'name' => 'op_forma_pago_c',
'studio' => 'visible',
'label' => 'LBL_OP_FORMA_PAGO',
),
),
4 =>
array (
0 =>
array (
'name' => 'cprovincia_c',
'studio' => 'visible',
'label' => 'LBL_CPROVINCIA',
),
1 =>
array (
'name' => 'op_modalidad_pago_c',
'studio' => 'visible',
'label' => 'LBL_OP_MODALIDAD_PAGO',
),
),
5 =>
array (
0 =>
array (
'name' => 'cdistrito_c',
'studio' => 'visible',
'label' => 'LBL_CDISTRITO',
),
1 => '',
),
6 =>
array (
0 =>
array (
'name' => 'precio_unitario_c',
'label' => 'LBL_PRECIO_UNITARIO',
),
1 =>
array (
'name' => 'nro_tarjeta_c',
'label' => 'LBL_NRO_TARJETA',
),
),
7 =>
array (
0 =>
array (
'name' => 'precio_caja_c',
'label' => 'LBL_PRECIO_CAJA',
),
1 =>
array (
'name' => 'nro_verificacion_c',
'label' => 'LBL_NRO_VERIFICACION',
),
),
8 =>
array (
0 =>
array (
'name' => 'cantidad_c',
'label' => 'LBL_CANTIDAD',
),
1 =>
array (
'name' => 'f_expiracion_c',
'label' => 'LBL_F_EXPIRACION',
),
),
9 =>
array (
0 =>
array (
'name' => 'amount',
),
1 =>
array (
'name' => 'dias_credito_c',
'label' => 'LBL_DIAS_CREDITO',
),
),
10 =>
array (
0 => '',
1 =>
array (
'name' => 'banco_c',
'label' => 'LBL_BANCO',
),
),
11 =>
array (
0 => '',
1 =>
array (
'name' => 'nro_operacion_c',
'label' => 'LBL_NRO_OPERACION',
),
),
// aqui el codigo sujerido ------------------------------------------------------------------------
'includes' =>
array (
0 =>
array (
'file' => 'custom/modules/Opportunities/js/calculos.js',
),
),
'javascript' => '
{literal}
<script type="text/javascript">
jQuery(function(){
calculos();
});
</script>
{/literal}',
),
// hasta aqui el codigo ------------------------------------------------------------------------------------------
'lbl_editview_panel1' =>
array (
0 =>
array (
0 =>
array (
'name' => 'fecha_compra_far_c',
'label' => 'LBL_FECHA_COMPRA_FAR',
),
1 =>
array (
'name' => 'numero_boletas_c',
'label' => 'LBL_NUMERO_BOLETAS',
),
),
1 =>
array (
0 => 'description',
),
),
'lbl_editview_panel2' =>
array (
0 =>
array (
0 =>
array (
'name' => 'jjwg_maps_address_c',
'label' => 'LBL_JJWG_MAPS_ADDRESS',
),
),
),
'lbl_editview_panel3' =>
array (
0 =>
array (
0 =>
array (
'name' => 'modo_entrega_c',
'studio' => 'visible',
'label' => 'LBL_MODO_ENTREGA',
),
1 =>
array (
'name' => 'considera_hora_c',
'studio' => 'visible',
'label' => 'LBL_CONSIDERA_HORA',
),
),
1 =>
array (
0 =>
array (
'name' => 'fecha_entrega_c',
'label' => 'LBL_FECHA_ENTREGA',
),
1 =>
array (
'name' => 'detalles_entrega_c',
'studio' => 'visible',
'label' => 'LBL_DETALLES_ENTREGA',
),
),
2 =>
array (
0 =>
array (
'name' => 'ccourier_c',
'studio' => 'visible',
'label' => 'LBL_CCOURIER',
),
1 => '',
),
3 =>
array (
0 =>
array (
'name' => 'detalle_entrega_c',
'studio' => 'visible',
'label' => 'LBL_DETALLE_ENTREGA',
),
),
),
),
),
);
?>
aqui el Javascript:
function calculos() {
$("#cantidad_c").attr('onBlur','sumar();');
}
function sumar(){
var variable1=document.getElementById("amount").value;
var variable2=document.getElementById("cantidad_c").value;
if(Number(variable2)!=0){
var total = Number(variable1) / Number(variable2);
}else{
var total = 0;
}
document.getElementById("precio_caja_c").value=total;
}