<?php 
//	print_r($_POST);
	iniciarConexionADM();
    $accion = 1;
    $accion = $_POST['accion'];
    
    foreach (explode(",",$_POST['campos_ds_9']) as $key => $value) {                        
        $arr_fields[$value] = true;
    }    

    if(empty($_POST['no_form']) )  {
        $sql="SELECT ctg_tpt_noform FROM ctg_tipo_tramites WHERE ctg_tpt_id = '".$_POST['tpt_id']."' AND ctg_tpr_id='".$_POST['id']."'";
        // echo $sql;
        $result=$connectionADM->Execute($sql);
        if (!$result->EOF){
            $operador = $result->fields;
            $_POST['no_form']= $operador['ctg_tpt_noform'];
        }
    }   

//    echo "(".$_POST['readonly'].")(".isset($_POST['ingredientes']).")";
  //  echo "<pre>";print_r($_POST);echo "</pre>";

    if(isset($_POST['ingredientes'])){
        if ($_POST['readonly'] != 'disabled') { //2013-07-17
        
		    if ($_SESSION['usuario_cta'] != 2 || $_SESSION['panel'] == 10)  
	        	include("form_crear_producto_{$_POST['tipo_pro']}_op.php");
	        else
    	        include("form_adm_crear_producto_{$_POST['tipo_pro']}_op.php");
        }
    }

    // if ($_POST['bolet']!='0') // NO EDITABLE CUANDO HAY BOLETA
    //     $_POST['readonly']="enabled";

    //2012-12-13
    $cnf_newing = 0;
    $sql = "SELECT ctg_tpr_vus_newing FROM ctg_tipo_productos WHERE ctg_tpr_id = '{$_POST['id']}'";
     $result1=$connectionADM->Execute($sql);
     if (!$result1->EOF) {
          //$cnf_newing = $result1->fields['ctg_tpr_vus_newing'];
          $reg = $result1->fields;
          $cnf_newing = $reg['ctg_tpr_vus_newing'];                            
    }
    //echo $sql."<br>($cnf_newing)";
      
if($_POST['for_id']=='') $_POST['for_id']=1;
if($_POST['tab']=='') $_POST['tab']=0;

//if($_POST['tipo_pro']=='ef' && $_POST['pre_pfi']==1){ $_POST['pre_pfi'] = ' checked ';} 2017-10-05
$_POST['pre_pfi'] = ' checked '; //2017-10-05

switch ($_POST['tipo_pro']){
    case 'pc':
    
    	if ($pais == "VEN")
        $variedad=true;
        $ingrediente=true;
        $cantidad=true;
        $unidad=true;
        //$conct=true;
        //$uso=true;
        //$naturaleza=true;
        //$tipo_comp=true;
        //$modalidad=true;
        $justificado=true;
        $incluye=true;
        $height=500;

        if($_POST['readonly']!=''){$height=200;}

        break;
    case 'pa':
        $ingrediente=true;
        $tipopa=true;
        $cantidad=true;
        $unidad=true;
        $funcion=true;
        $height=400;

        break;
    case 'ef':
            // $variedadef=2;
            // $nom_sus=true;
            // $tipo=true;
            // $cantidadef=true;
            // $unidadef=true;
            // $incluyeef=true;
            // $height=400;           
    	
        if ($_POST['readonly']==''){
            $variedadef=2;
            $nom_sus=true;
            $tipo=true;
            $cantidadef=true;
            $unidadef=true;
            $incluyeef=true;
            $height=400;           
        } else {
            $variedadef=2;
            $nom_sus=false;
            $tipo=false;
            $cantidadef=false;
            $unidadef=false;
            $incluyeef=false;
        }
    break;
    case 'mm':
        $nom_sus=true;
        $tipo=true;
        $cantidadef=true;
        $unidadef=true;
        $incluyeef=true;
      	$height=400;
    break;

    case 'pn':
        $nom_sus=true;
        $tipo=true;
        $cantidadef=true;
        $unidadef=true;
        $incluyeef=true;
		$equivalentex=true;
		$canequivalentex=true;
		$uniequivalentex=true;
		$nomequivalentex=true;
    	$height=420;
	break;
    
    case 'pb':
        $variedadef=2;

        $ingrediente=true;
        $tipo=true;
        $cantidadef=true;
        $unidadef=true;
        $incluyeef=true;
        $rango=true;
	$height=420;
	break;

}

$unidad=false;
$unidadef=false;
$uniequivalentex = false;
//$mono = 0;
$variedadef=0;


    if ($_SESSION['usuario_cta'] == 2 && $_SESSION['panel'] != 10) {
    //if ($_SESSION['usuario_cta'] == 2) {  //2013-03-06
        $prefijo = "adm_{$_POST['tipo_pro']}FOR_";
        $tabla = "ctg_productos_{$_POST['tipo_pro']}_formulareg";
        $tabla2 = "ctg_productos_{$_POST['tipo_pro']}";
        $prefijo2 = "adm_{$_POST['tipo_pro']}_";
        $numreg = "numreg";
        $tpt_id = "";
        $conn = $connectionADM;
        
    } else {
        $prefijo = "vus_{$_POST['tipo_pro']}FOR_";
        $tabla = "vus_tramites_{$_POST['tipo_pro']}{$_SESSION['dtb_vus']}_formula";
        $tabla2 = "vus_tramites_{$_POST['tipo_pro']}{$_SESSION['dtb_vus']}";
        $prefijo2 = "vus_{$_POST['tipo_pro']}_";
        $numreg = "numsol";
        $tpt_id = " AND \"{$prefijo}tpt_id\"='{$_POST['tpt_id']}' ";
        $tpt_id2 = " AND \"{$prefijo2}tpt_id\"='{$_POST['tpt_id']}' ";
        $conn = $connection;
    }

if ($_SESSION['usuario_cta'] == 2 && $_SESSION['panel'] != 10) {
    $sql= "SELECT  adm_{$_POST['tipo_pro']}_gt_mono FROM ctg_productos_{$_POST['tipo_pro']} WHERE adm_{$_POST['tipo_pro']}_numreg='{$_POST['numsol']}'";
    $respuesta['sql'] = $sql;

    $result=$conn->Execute($sql);
    if (!$result->EOF){
        $ope= $result->fields;
        $mono =$ope["adm_".$_POST['tipo_pro']."_gt_mono"];
        // $_POST['adm_'.$_POST['tipo_pro'].'_admin']=$operado[$prefijo2."admin"];
    }
} else {

    $catalogo_prefijo = "vus_{$_POST['tipo_pro']}_";
    $sql= "SELECT vus_{$_POST['tipo_pro']}_admin, vus_{$_POST['tipo_pro']}_gt_mono FROM vus_tramites_{$_POST['tipo_pro']}{$_SESSION['dtb_vus']} WHERE \"{$catalogo_prefijo}numsol\"='{$_POST['numsol']}'";
    $respuesta['sql'] = $sql;
    // echo $sql;  
    $result=$connection->Execute($sql);
    if (!$result->EOF){
        $ope= $result->fields;
        $mono =$ope["vus_".$_POST['tipo_pro']."_gt_mono"];
        $_POST['vus_'.$_POST['tipo_pro'].'_admin']=$operado[$prefijo2."admin"];
    }
}

if ($mono == '2') {//2017-12-14
	$variedadef = 2;
} else {
	$variedadef = 1;
}


if (!isset($_POST['can'])) $_POST['can'] = 0; 
if (!isset($_POST['can2'])) $_POST['can2'] = '0000';

$_POST['vus_'.$_POST['tipo_pro'].'FOR_unit_desc']='';
$_POST['vus_'.$_POST['tipo_pro'].'FOR_each']='0';

$sq4= "SELECT * FROM $tabla WHERE 
\"{$prefijo}{$numreg}\"='{$_POST['numsol']}' $tpt_id  AND 
\"{$prefijo}tpr_id\"='{$_POST['id']}' ";

if($_POST['tipo_pro']=="ef") 
    $sq4 .= " and \"{$prefijo}id\"='".$_POST['for_id']."'";
$result=$conn->Execute($sq4);
if (!$result->EOF){
    $operado = $result->fields;
    $_POST['vus_efFOR_unit_desc']=$operado[$prefijo.'unit_desc'];
    $_POST['vus_efFOR_each']=$operado[$prefijo.'each'];

}
if($_POST['editar'] == '' && empty($_POST['desc'])){
    if ($_SESSION['usuario_cta'] == 2 && $_SESSION['panel'] != 10) {
        $sq4= "SELECT adm_{$_POST['tipo_pro']}_refe{$_POST['for_id']} FROM $tabla2 WHERE 
        \"{$prefijo2}{$numreg}\"='{$_POST['numsol']}' $tpt_id2  AND 
        \"{$prefijo2}tpr_id\"='{$_POST['id']}' ";
        $result=$conn->Execute($sq4);
        if (!$result->EOF){
            $operado = $result->fields;
            $_POST['vus_efFOR_reference']=xdecode($operado[$prefijo2.'refe'.$_POST['for_id']]);
        }
    
        if ($_POST['vus_efFOR_reference']==""){
            switch($_POST['adm_ef_admin']){
            case 1:
                $_POST['vus_efFOR_reference'] = $_POST['forma_desc'];
                break;
            case 2:
                $_POST['vus_efFOR_reference'] = $_POST['gt_env_id_desc'];
                break;
            case 3:
                $_POST['vus_efFOR_reference'] = 'millilitre';
                break;
            case 4:
                $_POST['vus_efFOR_reference'] = 'gram';
                break;
            case 5:
                $_POST['vus_efFOR_reference'] = $arr_label['vus_efFOR_each6'].' '.$_POST['vus_ef_admin_oth'];
                break;
            }    
        }        
    } else {
        $sq4= "SELECT vus_{$_POST['tipo_pro']}_refe{$_POST['for_id']} FROM $tabla2 WHERE 
        \"{$prefijo2}{$numreg}\"='{$_POST['numsol']}' $tpt_id2  AND 
        \"{$prefijo2}tpr_id\"='{$_POST['id']}' ";

        $result=$conn->Execute($sq4);
        if (!$result->EOF){
            $operado = $result->fields;
            $_POST['vus_efFOR_reference']=xdecode($operado[$prefijo2.'refe'.$_POST['for_id']]);
        }
    
        if ($_POST['vus_efFOR_reference']==''){
            switch($_POST['vus_ef_admin']){
            case 1:
                $_POST['vus_efFOR_reference'] = $_POST['forma_desc'];
                break;
            case 2:
                $_POST['vus_efFOR_reference'] = $_POST['gt_env_id_desc'];
                break;
            case 3:
                $_POST['vus_efFOR_reference'] = 'millilitre';
                break;
            case 4:
                $_POST['vus_efFOR_reference'] = 'gram';
                break;
            case 5:
                $_POST['vus_efFOR_reference'] = $arr_label['vus_efFOR_each6'].' '.$_POST['vus_ef_admin_oth'];
                break;
            }    
        }
    }

}

if($_POST['editar'] != '' && !empty($_POST['desc']) ){
    if($_POST['tipo_pro']=="pc") {

		$sq4= "SELECT * FROM $tabla WHERE 
		\"{$prefijo}{$numreg}\"='{$_POST['numsol']}' $tpt_id  AND 
		\"{$prefijo}tpr_id\"='{$_POST['id']}' AND
		\"{$prefijo}sus_nom\"='".$_POST['desc']."' AND
		\"{$prefijo}justif\"='".$_POST['justif1']."' AND
		\"{$prefijo}var_id\"='".$_POST['var_tipo']."'";
    } else {

		$sq4= "SELECT * FROM $tabla WHERE 
		\"{$prefijo}{$numreg}\"='{$_POST['numsol']}' $tpt_id  AND 
		\"{$prefijo}tpr_id\"='{$_POST['id']}' AND
		\"{$prefijo}sus_nom\"='".$_POST['desc']."' AND
		\"{$prefijo}tipo\"='".$_POST['var_tipo']."' ";
		
		if($_POST['tipo_pro']=="ef") 
			$sq4 .= " and \"{$prefijo}id\"='".$_POST['for_id']."'";
        
    		
	}

    $_POST["vus_efFOR_ume_id"]="";
    $result=$conn->Execute($sq4);
    if (!$result->EOF){
        $operado = $result->fields;
        $_POST['sus_id']=$operado[$prefijo.'sus_id'];
        $_POST['sus_id_desc']=$operado[$prefijo.'sus_nom'];
        $_POST['tipo']=$operado[$prefijo.'tipo'];
        //echo "(".$operado[$prefijo.'can'].")";
        list($_POST['can'],$_POST['can2'])= explode(".",$operado[$prefijo.'can']);
		if (empty($_POST['can']))
    		$_POST['can'] = 0; 
    	if (empty($_POST['can2']))
    		$_POST['can2'] = '0000';
        //$_POST['can']=number_format($operado[$prefijo.'can'],4, $decimal, $thousands); 
        //$_POST['ume_ids']=$operado[$prefijo.'ume_id'];
        $_POST['conct']=$operado[$prefijo.'conct'];
	   	// if($operado[$prefijo.'pre_pfi']==1){$_POST['pre_pfi'] = ' checked ';}
		if($operado[$prefijo.'pre_pfi']==0){$_POST['pre_pfi'] = '';}
        $_POST['fun']=$operado[$prefijo.'fun'];
        $_POST["vus_".$_POST['tipo_pro']."FOR_ume_id"]= intval($operado['vus_'.$_POST['tipo_pro'].'FOR_ume_id']) == 0 ? "" : intval($operado['vus_'.$_POST['tipo_pro'].'FOR_ume_id']);
        $_POST['justif']=$operado[$prefijo.'justif'];
        $_POST['atc_id']=$operado[$prefijo.'atc_id'];
        $_POST['var_id']=$operado[$prefijo.'var_id'];
        $_POST['atc_id_desc']=$operado[$prefijo.'atc_id_des'];
        $_POST['este']=$operado[$prefijo.'este'];
        $_POST['rango']=$operado[$prefijo.'ran_id'];

        //$_POST['sue_can']=number_format($operado[$prefijo.'sue_can'],2, $decimal, $thousands);
        $_POST['sue_can']=$operado[$prefijo.'sue_can']; 
        $_POST['sue_ume_id']=$operado[$prefijo.'sue_ume_id'];
        $_POST['sue_id_desc']=$operado[$prefijo.'sue_nom'];
        $_POST['vus_efFOR_each']=$operado[$prefijo.'each'];
        $_POST['vus_efFOR_cominfo']=$operado[$prefijo.'cominfo'];
        $_POST['vus_efFOR_ume_id']=$operado[$prefijo.'ume_id'];
        $_POST['vus_efFOR_ume_oth']=$operado[$prefijo.'ume_oth'];
        $_POST['vus_efFOR_unit_desc']=$operado[$prefijo.'unit_desc'];
    }
    //$_POST['editar']=''; 2015-01-09
}
?>

<?php
$sql_ume_exist="SELECT ctg_ume_obs, ctg_ume_id, ctg_ume_desc FROM ctg_uni_medida WHERE ctg_tpr_id = \'{$_POST['id']}\' AND ctg_ume_id = \'codigo_actual\'";
$sql_ume_look ="SELECT ctg_ume_obs, ctg_ume_id, ctg_ume_desc FROM ctg_uni_medida WHERE ctg_tpr_id = \'{$_POST['id']}\'&codigo=ctg_ume_id&desc=ctg_ume_desc&orden=ctg_ume_id";


$sql_fun_exist="SELECT ctg_fun_obs, ctg_fun_id, ctg_fun_desc FROM ctg_funciones WHERE ctg_tpr_id = \'01\' AND ctg_fun_id = \'codigo_actual\'";
$sql_fun_look ="SELECT ctg_fun_obs, ctg_fun_id, ctg_fun_desc FROM ctg_funciones WHERE ctg_tpr_id = \'01\'&codigo=ctg_fun_id&desc=ctg_fun_desc&orden=ctg_fun_id";

if(!empty($_POST['fun'])){

        $sql = stripslashes($sql_fun_exist);
        $sql = str_replace("codigo_actual", $_POST['fun'], $sql);
        $result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['fun_desc']=clean_string(trim($operador['ctg_fun_desc']));
         }
}


/* SE OCULTA UNIDAD 2014-04-26
if(!empty($_POST['ume_ids'])){

        $sql = stripslashes($sql_ume_exist);
        $sql = str_replace("codigo_actual", $_POST['ume_ids'],$sql);
        //echo $sql;
   $result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['ume_ids_desc']=clean_string(trim($operador['ctg_ume_desc']));
         }
}
*/

if(!empty($_POST['sue_ume_id'])){
        $sql = stripslashes($sql_ume_exist);
        $sql = str_replace("codigo_actual", $_POST['sue_ume_id'],$sql);
       // echo $sql;
        $result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['sue_ume_id_desc']=clean_string(trim($operador['ctg_ume_desc']));
         }
}
?>
<?php

//UPPER(vus_ayu_form) = '".trim(strtoupper($params))."'";  

$sql_sus_id_exist="SELECT ctg_sus_sinonims, ctg_sus_id, ctg_sus_desc,ctg_sus_cas, ctg_sus_blq FROM ctg_substancias WHERE ctg_sus_id = \'codigo_actual\' AND ctg_tpr_id = \'{$_POST['id']}\'";
$sql_sus_id_look ="SELECT ctg_sus_sinonims, ctg_sus_id, ctg_sus_desc,ctg_sus_cas, ctg_sus_blq FROM ctg_substancias WHERE ctg_tpr_id = \'{$_POST['id']}\'&codigo=ctg_sus_id&desc=ctg_sus_desc&orden=ctg_sus_desc&buscar2=ctg_sus_sinonims";

//$sql_sue_nom_exist="SELECT ctg_sus_sinonims, ctg_sus_desc, ctg_sus_id FROM ctg_substancias WHERE (UPPER(ctg_sus_desc) = \'codigo_actual%\' OR UPPER(ctg_sus_sinonims) = \'codigo_actual%\') AND ctg_tpr_id = \'{$_POST['id']}\'";

$sql_sue_nom_exist="SELECT ctg_sus_sinonims, ctg_sus_desc, ctg_sus_id, ctg_sus_blq FROM ctg_substancias WHERE UPPER(ctg_sus_desc) = \'codigo_actual%\' AND ctg_tpr_id = \'{$_POST['id']}\'";

//$sql_sue_nom_exist="SELECT ctg_sus_sinonims, ctg_sus_desc, ctg_sus_id FROM ctg_substancias WHERE ctg_sus_desc ILIKE \'codigo_actual%\' AND ctg_tpr_id = \'{$_POST['id']}\'";

$sql_sue_id_exist="SELECT ctg_sus_sinonims, ctg_sus_id, ctg_sus_desc, ctg_sus_blq FROM ctg_substancias WHERE ctg_sus_id = \'codigo_actual\' AND ctg_tpr_id = \'{$_POST['id']}\'";
$sql_sue_id_look ="SELECT ctg_sus_sinonims, ctg_sus_id, ctg_sus_desc, ctg_sus_blq FROM ctg_substancias WHERE ctg_tpr_id = \'{$_POST['id']}\'&codigo=ctg_sus_id&desc=ctg_sus_desc&orden=ctg_sus_desc&buscar2=ctg_sus_sinonims";


//$sql_sue_nom_exist="SELECT ctg_sue_id, ctg_sue_desc FROM ctg_susbstancias_equivalencias WHERE ctg_sue_desc = \'codigo_actual\' AND ctg_tpr_id = \'{$_POST['id']}\'";
//$sql_sue_id_exist="SELECT ctg_sue_id, ctg_sue_desc FROM ctg_susbstancias_equivalencias WHERE ctg_sue_id = \'codigo_actual\' AND ctg_tpr_id = \'{$_POST['id']}\'";
//$sql_sue_id_look ="SELECT ctg_sue_id, ctg_sue_desc FROM ctg_susbstancias_equivalencias WHERE ctg_tpr_id = \'{$_POST['id']}\'&codigo=ctg_sue_id&desc=ctg_sue_desc&orden=ctg_sue_id";

if(!empty($_POST['sus_id_desc'])){
        $sql = stripslashes($sql_sus_nom_exist);
        $sql = str_replace("codigo_actual", strtoupper($_POST['sus_id_desc']),$sql);
		$result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['sus_id']=clean_string(trim($operador['ctg_sus_id']));
         }
}

if(!empty($_POST['sus_id'])){
        $sql = stripslashes($sql_sus_id_exist);
        $sql = str_replace("codigo_actual", $_POST['sus_id'],$sql);
		$result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                $operador = $result->fields;
                $_POST['sus_id_desc']=clean_string(trim($operador['ctg_sus_desc']));
         }
}
/*
if(!empty($_POST['sue_id_desc'])){

        $sql = stripslashes($sql_sue_nom_exist);
        $sql = str_replace("codigo_actual", strtoupper($_POST['sue_id_desc']),$sql);
        //echo $sql;
   $result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['sue_id']=clean_string(trim($operador['ctg_sus_id']));
         }
}

if(!empty($_POST['sue_id'])){

        $sql = stripslashes($sql_sue_id_exist);
        $sql = str_replace("codigo_actual", $_POST['sue_id'],$sql);
   $result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['sue_id_desc']=clean_string(trim($operador['ctg_sus_desc']));
         }
}
*/
?>
<?php
///aatc
$sql_atc_exist="SELECT ctg_cla_obs, ctg_cla_id, ctg_cla_desc FROM ctg_clasif_atc WHERE ctg_cla_id = \'codigo_actual\'";
$sql_atc_look ="SELECT ctg_cla_obs, ctg_cla_id, ctg_cla_desc FROM ctg_clasif_atc&codigo=ctg_cla_id&desc=ctg_cla_desc&orden=ctg_cla_id";


if(!empty($_POST['atc_id'])){

        $sql = stripslashes($sql_atc_exist);
        $sql = str_replace("codigo_actual", $_POST['atc_id'],$sql);
		$result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['atc_id_desc']=clean_string(trim($operador['ctg_cla_desc']));
         }
}

?>
<?php

$sql_somero_exist="SELECT ctg_som_obs, ctg_som_id, ctg_som_desc FROM ctg_someros WHERE ctg_tpr_id = \'{$_POST['id']}\' AND ctg_som_id = \'codigo_actual\'";
$sql_somero_look ="SELECT ctg_som_obs, ctg_som_id, ctg_som_desc FROM ctg_someros WHERE ctg_tpr_id = \'{$_POST['id']}\'&codigo=ctg_som_id&desc=ctg_som_desc&orden=ctg_som_id";

$sql_rango_exist ="SELECT ctg_ran_obs, ctg_ran_id, ctg_ran_desc FROM ctg_rangos  WHERE ctg_tpr_id = \'{$_POST['id']}\' AND ctg_ran_id = \'codigo_actual\'";
$sql_rango_look  ="SELECT ctg_ran_obs, ctg_ran_id, ctg_ran_desc FROM ctg_rangos  WHERE ctg_tpr_id = \'{$_POST['id']}\'&codigo=ctg_ran_id&desc=ctg_ran_desc&orden=ctg_ran_id";


if(!empty($_POST['este'])){

        $sql = stripslashes($sql_somero_exist);
        $sql = str_replace("codigo_actual", $_POST['este'],$sql);
        $result=$connectionADM->Execute($sql);
        if (!$result->EOF) {
                 $operador = $result->fields;
                 $_POST['este_desc']=clean_string(trim($operador['ctg_som_desc']));
         }
}
if(!empty($_POST['rango'])){

    $sql = stripslashes($sql_rango_exist);
    $sql = str_replace("codigo_actual", $_POST['rango'],$sql);
    $result=$connectionADM->Execute($sql);
    if (!$result->EOF) {
             $operador = $result->fields;
             $_POST['rango_desc']=clean_string(trim($operador['ctg_ran_desc']));
     }
}
?>

<?php include_once("includes/lenguaje.php");?>

<?php include_once("includes/modal.php");?>

<script>

$(document).keypress(function(e) {
	if(e.keyCode == 13) {		
		switch($(e.target).attr('id')){
			case 'sus_id_desc':
			case 'vus_efFOR_cominfo':			
				console.log($(e.target).attr('id'));		
				e.preventDefault();
				return false;			
				break;
		}				
	}
});  
</script>

      
<script type="text/javascript" src="includes/common.js"></script>
<script type="text/javascript">
function submit_abandona_muestras( form ){

    document.getElementById('form_standar').target = '';
    document.getElementById('form_standar').action = 'index.php';
    form.opcion.value='form_crear_standar';

return true;
}


function limpiar_datos(){
    if (document.getElementById('atc_id')) document.getElementById('atc_id').value="";
    if (document.getElementById('atc_id_desc')) document.getElementById('atc_id_desc').value="";
    if (document.getElementById('sus_id')) document.getElementById('sus_id').value="";
    if (document.getElementById('sus_id_desc')) document.getElementById('sus_id_desc').value="";
    if (document.getElementById('este')) document.getElementById('este').value="";
    if (document.getElementById('este_desc')) document.getElementById('este_desc').value="";
    if (document.getElementById('rango')) document.getElementById('rango').value="";
    if (document.getElementById('rango_desc')) document.getElementById('rango_desc').value="";
    if (document.getElementById('sue_can')) document.getElementById('sue_can').value="";
    if (document.getElementById('sue_id_desc')) document.getElementById('sue_id_desc').value="";
    if (document.getElementById('sue_ume_id')) document.getElementById('sue_ume_id').value="";
    if (document.getElementById('sue_id')) document.getElementById('sue_id').value="";
    if (document.getElementById('vus_efFOR_each')) document.getElementById('vus_efFOR_each').value="";
    if (document.getElementById('vus_efFOR_cominfo')) document.getElementById('vus_efFOR_cominfo').value="";
    
    if (document.getElementById('vus_efFOR_ume_oth')) document.getElementById('vus_efFOR_ume_oth').value="";
    if (document.getElementById('vus_efFOR_unit_desc')) document.getElementById('vus_efFOR_unit_desc').value="";
    
/*

<?php if($ingrediente || $nom_sus){ ?>
    document.getElementById('sus_id').value="";
    document.getElementById('sus_id_desc').value="";
<?php } ?>

<?php if($_POST['tipo']==1 && $_POST['tipo_pro']=='ef'){ ?>

//alert('test');
  //  document.getElementById('tipo').value="";
    document.getElementById('atc_id').value="";
	document.getElementById('atc_id_desc').value="";
    document.getElementById('sue_can').value="";
    document.getElementById('sue_id').value="";
    document.getElementById('sue_id_desc').value="";
    document.getElementById('sue_ume_id').value="";
    document.getElementById('este').value="";

<?php } ?>

    if(document.getElementById('sue_can')) document.getElementById('sue_can').value="";
    if(document.getElementById('sue_id_desc')) document.getElementById('sue_id_desc').value="";
    if(document.getElementById('sue_ume_id')) document.getElementById('sue_ume_id').value="";
    if(document.getElementById('sue_id')) document.getElementById('sue_id').value="";
*/
<?php if($cantidad || $cantidadef){ ?>
    document.getElementById('can').value="0";
    document.getElementById('can2').value="0000";
<?php } ?>

    if(document.getElementById('veum1')) document.getElementById('veum1').checked=false;
    if(document.getElementById('veum2')) document.getElementById('veum2').checked=false;
    if(document.getElementById('veum3')) document.getElementById('veum3').checked=false;
    if(document.getElementById('veum4')) document.getElementById('veum4').checked=false;

<?php if($unidadef || $unidad){ ?>
    //document.getElementById('ume_ids').value="";
<?php } ?>

<?php if($conct){ ?>
    document.getElementById('conct').value="";
<?php } ?>

<?php if($uso){ ?>
    document.getElementById('uso').value="";
<?php } ?>

<?php if($naturaleza){ ?>
    document.getElementById('natur').value="";
<?php } ?>

<?php if($tipo_comp){ ?>
    document.getElementById('tip_comp').value="";
<?php } ?>

<?php if($tipopa){ ?>
    document.getElementById('tipo').value="";
<?php } ?>

<?php if($funcion){ ?>
    document.getElementById('fun').value="";
<?php } ?>

<?php if($modalidad){ ?>
    document.getElementById('mod_comp').value="";
<?php } ?>

<?php if($justificado){ ?>
    document.getElementById('justif').value="";
<?php } ?>

}


function submit_datos_ingredientes( form ){

    console.log('<?=$accion?>' + ')(' + '<?=$arr_fields['for_i']?>' + ')(' + '<?=$arr_fields['for_u']?>' + ')(' + '<?=$_POST['editar']?>' + ')(' + '<?=$_POST['desc']?>');
   
    if ('<?=$accion?>' == 2 || '<?=$accion?>' == 9){

        if ('<?=$arr_fields['for_i']?>' == 1 || '<?=$arr_fields['for_u']?>' == 1){
                            
            if (document.getElementById('tipo').value == '1') {
                //alert('No puede agregar o modificar principio activo');//1054
                call_dialog_msginfo('<?=$arr_label['no_principio']?>');
                return false;
            }

            if ('<?=$_POST['editar']?>' != '' && '<?=$_POST['desc']?>' != ''){ //editar
                             
                    //continua
                                         
            } else {
            
                if ('<?=$arr_fields['for_i']?>' == 1){
                
                    //continua
                    
                } else {

                    //alert('No puede agregar o modificar substancias');//1053
                    call_dialog_msginfo('<?=$arr_label['no_substancias']?>');
                    return false;
                }                
            }
          
        } else {
            //alert('No puede agregar o modificar substancias');
            call_dialog_msginfo('<?=$arr_label['no_substancias']?>');
            return false;
        }
    }




var errorCount = 0;


var campo = document.getElementById('enfoco');


if (document.getElementById('var_id'))

if (document.getElementById('max_id').value == document.getElementById('var_id').value) {
    errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['maximo']?>';campo.value='var_id';}
}

var nombre = form.sus_id_desc.value;
nombre_sus= nombre.trim();

<?php if($ingrediente){ ?>
    if(form.sus_id_desc.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['ingrediente']?>';campo.value='sus_id_desc';}}
<?php }else if($nom_sus){ ?>
    if(nombre_sus==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['nom_sus']?>';campo.value='sus_id_desc';}}
<?php } ?>

//    if(form.vus_efFOR_reference.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['vus_efFOR_reference']?>';campo.value='vus_efFOR_reference';}}

<?php if($tipo || $tipopa){ ?>
    if(form.tipo.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['tipo']?>';campo.value='tipo';}}
<?php } ?>

<?php if($funcion){ ?>
    if(form.fun.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['funcion']?>';campo.value='fun';}}
<?php } ?>

<?php if($cantidad || $cantidadef){ ?>

	if (form.tipo)
    	if (form.tipo.value == 1)
            if(form.can.value=='' || form.can2.value=='' )
            {errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['cantidad']?>';campo.value='can';}}    
    
<?php } ?>

<?php if($conct){ ?>
    if(form.conct.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['conct']?>';campo.value='conct';}}
<?php } ?>

<?php if($uso){ ?>
    if(form.uso.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['uso']?>';campo.value='uso';}}
<?php } ?>

<?php if($naturaleza){ ?>
    if(form.natur.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['naturaleza']?>';campo.value='natur';}}
<?php } ?>


<?php if($tipo_comp){ ?>
    if(form.tip_comp.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['tipo_comp']?>';campo.value='tip_comp';}}
<?php } ?>

<?php if($modalidad){ ?>
    if(form.mod_comp.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['modalidad']?>';campo.value='mod_comp';}}
<?php } ?>

<?php if($justificado){ ?>
    if(form.justif.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['justificacion']?>';campo.value='justif';}}
<?php } ?>

<?php //if($_POST['tipo']==1 && $_POST['tipo_pro']=='ef'){ ?>

    //alert(form.vus_efFOR_each.value)  ;

	if (document.getElementById('veea1')) { //opcion 2
	    if(form.vus_efFOR_each.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['vus_efFOR_each']?>';campo.value='vus_efFOR_each';}}
	
	}
	//alert(form.vus_efFOR_ume_id.value);
	
  if (form.tipo)
    	if (form.tipo.value == 1) {

		    if(form.vus_efFOR_ume_id.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['vus_efFOR_ume_id']?>';campo.value='';}
		
    	} else {
		
    		if (form.vus_efFOR_ume_id.value == '4') { //unit op 4
				    if(form.vus_efFOR_ume_oth.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['vus_efFOR_ume_oth']?>';campo.value='vus_efFOR_ume_oth';}}
				}
    	}
	}

<?php if($_POST['tipo_pro']=='ef'){ ?>

    if(form.tipo.value=='1') {
        if(form.atc_id.value==''){errorCount++;if(errorCount==1){etiqueta='<?php echo $arr_label['cod_atc']?>';campo.value='atc_id';}}
    }

<?php } ?>
    if (errorCount) {
    call_dialog_msg(etiqueta);
    return false;
    }
$('#dialog-confirmar-ingredientes').dialog('open');
document.getElementById('dialog-confirmar-ingredientes-conteiner').innerHTML = "<table border=0 height=80% width=100%><td align=center valign=middle class=\"msginfo\" >"+  '<?php echo $arr_label['seguro_grabar']?>' + "</td></table>"; 
return false;
}

function result_op(resultado,error,info){
	var msg = '';
		switch (resultado){
			case '1':msg = '<?php echo $arr_label['datos_guardados']?>'; limpiar_datos(); break;
			case '2':msg = '<?php echo $arr_label['datos_borrados']?>'; limpiar_datos(); break;
			default :
						msg = '<?php echo $arr_label['datos_guardados']?>'; limpiar_datos(); break;
		}

	if (error != ""){ msg = '<?php echo $arr_label['error_sql']?>'; }

	call_dialog_msginfo(msg);
}




function editar_ingre(desc,tipo,justif,tab){
    var form = document.forms.form_standar;
    document.getElementById('form_standar').target = '';
    document.getElementById('form_standar').action = 'index.php';

    form.editar.value=desc;
    form.desc.value=desc;
    form.var_tipo.value=tipo;
    form.justif1.value=justif;
    
    // alert(tipo);
    //alert(form.desc.value + ' ' + form.var_tipo.value);
    form.submit();
}

function borrar_ingre(desc,tipo,justif,tab){
    var form = document.forms.form_standar;    
    document.getElementById('form_standar').target = '';
    document.getElementById('form_standar').action = 'index.php';
    form.editar.value=desc;
    form.desc.value=desc;
    form.var_tipo.value=tipo;
    form.justif1.value=justif;

    //alert(form.desc.value + ' ' + form.var_tipo.value);    
    
	$('#dialog-borrar-ingre').dialog('open');
	document.getElementById('dialog-borrar-ingre-conteiner').innerHTML = "<table border=0 height=80% width=100%><td align=center valign=middle class=\"msginfo\" >"+  '<?php echo $arr_label['seguro_borrar']?>' + "</td></table>";

	return false;
	
	    
    //form.submit();
}





function submit_borra_ingredientes(form){


    var form = document.forms.form_standar;

	var desc = document.getElementById('sus_id_desc').value;
    var tipo = document.getElementById('tipo').value;
    
    //1017
    if (desc == "" || tipo == "") {
        var etiqueta='<?php echo $arr_label['selec']?>';	
        call_dialog_msginfo(etiqueta);
	    return false;
	}	
	
	document.getElementById('str').value=desc;
	document.getElementById('long').value=tipo;

	//alert(document.getElementById('str').value + ')(' + document.getElementById('long').value);


	$('#dialog-borrar-ingre').dialog('open');
	document.getElementById('dialog-borrar-ingre-conteiner').innerHTML = "<table border=0 height=80% width=100%><td align=center valign=middle class=\"msginfo\" >"+  '<?php echo $arr_label['seguro_borrar']?>' + "</td></table>";

	return false;

}



function limpiar_sus_id(){
    document.getElementById('sus_id').value="";
}

function limpiar_sue_id(){
    document.getElementById('sue_id').value="";
}
 
function submit_tab(quien){

    var form = document.forms.form_standar;

    document.getElementById('form_standar').target = '';
    document.getElementById('form_standar').action = 'index.php'; 
    form.for_id.value=quien;
    form.tab.value=form.for_id.value-1;

	form.desc.value = '';
	
	form.var_tipo.value = '';

    if (document.getElementById('atc_id')) document.getElementById('atc_id').value="";
    if (document.getElementById('atc_id_desc')) document.getElementById('atc_id_desc').value="";

    if (document.getElementById('sus_id')) document.getElementById('sus_id').value="";
    if (document.getElementById('sus_id_desc')) document.getElementById('sus_id_desc').value="";

    if (document.getElementById('este')) document.getElementById('este').value="";
    if (document.getElementById('este_desc')) document.getElementById('este_desc').value="";

    if (document.getElementById('rango')) document.getElementById('rango').value="";
    if (document.getElementById('rango_desc')) document.getElementById('rango_desc').value="";

    if(document.getElementById('sue_can')) document.getElementById('sue_can').value="";
    if(document.getElementById('sue_id_desc')) document.getElementById('sue_id_desc').value="";
    if(document.getElementById('sue_ume_id')) document.getElementById('sue_ume_id').value="";
    if(document.getElementById('sue_id')) document.getElementById('sue_id').value="";
    
    
    if(document.getElementById('tipo')) document.getElementById('tipo').value="";
    
    if(document.getElementById('can')) document.getElementById('can').value="0";
    if(document.getElementById('can2')) document.getElementById('can2').value="0000";
    
    if(document.getElementById('veum1')) document.getElementById('veum1').checked=false;
    if(document.getElementById('veum2')) document.getElementById('veum2').checked=false;
    if(document.getElementById('veum3')) document.getElementById('veum3').checked=false;
    if(document.getElementById('veum4')) document.getElementById('veum4').checked=false;

    
    

if (document.getElementById('vus_efFOR_each')) document.getElementById('vus_efFOR_each').value="";
if (document.getElementById('vus_efFOR_cominfo')) document.getElementById('vus_efFOR_cominfo').value="";
//if (document.getElementById('vus_efFOR_reference')) document.getElementById('vus_efFOR_reference').value="";

if (document.getElementById('vus_efFOR_ume_oth')) document.getElementById('vus_efFOR_ume_oth').value="";
  if (document.getElementById('vus_efFOR_unit_desc')) document.getElementById('vus_efFOR_unit_desc').value="";
  
    form.submit();

}

function submit_categoria( ){
		document.getElementById('sus_id_desc').value = '';
		/* 2013-06-01
		document.getElementById('form_standar').target = '';
		document.getElementById('form_standar').action = 'index.php';
		document.forms.form_standar.submit();
		*/
}

function submit_frame(){

		document.getElementById('form_standar').target = 'tabla_ingredintes';
		document.getElementById('form_standar').action = 'includes/form_ingredientes_frame.php';
		document.forms.form_standar.submit();
}
</script>



<?php /*
<script src="includes/maskInputMoney_files/jquery_002.js" type="text/javascript"></script>
<script src="includes/maskInputMoney_files/jquery.ui.js" type="text/javascript"></script>
<script src="includes/maskInputMoney_files/jquery.js" type="text/javascript"></script>
<script src="includes/maskInputMoney_files/jquery.js" type="text/javascript"></script>
<script language="JavaScript1.2">
$(function(){

<?php /* 2014-04-26 if($cantidad && $_POST['readonly']=='' || $cantidadef && $_POST['readonly']==''){ */ /*?>   
    $("#can").maskMoney({symbol:"",decimal:"<?php echo $decimal?>",thousands:"<?php echo $thousands?>",precision:3})     
<?php /* } 

	if(document.getElementById('sue_can'))
  $("#sue_can").maskMoney({symbol:"",decimal:"<?php echo $decimal?>",thousands:"<?php echo $thousands?>"})
  
  */ /*?>
})


</script>*/ 

?> 

<form method="POST" action="index.php" id=form_standar name=form_standar>
<input type=hidden id="opcion" name="opcion" value="<?php echo $_POST['opcion']?>">
<input type=hidden id="id" name="id" value="<?php echo $_POST['id']?>">
<input type=hidden id="tpt_id"  name="tpt_id"  value="<?php echo $_POST['tpt_id']?>">
<input type=hidden id="tpt_desc"  name="tpt_desc"  value="<?php echo $_POST['tpt_desc']?>">
<input type=hidden id="modeofform" name="modeofform" value="<?php echo $_POST['modeofform']?>">
<input type=hidden id="numsol" name="numsol" value="<?php echo $_POST['numsol']?>">
<input type=hidden id="noform" name="noform" value="<?php echo $_POST['noform']?>">
<input type=hidden id="tipo_pro" name="tipo_pro" value="<?php echo $_POST['tipo_pro']?>">
<input type=hidden id="fec_cre" name="fec_cre" value="<?php echo $_POST['fec_cre'] ?>">
<input type=hidden id="nom_arch" name="nom_arch" value="<?php echo $_POST['nom_arch']?>">
<input type=hidden id="dis" name="dis" value="<?php echo $_POST["dis"]?>">
<input type=hidden id="op" name="op" value="<?php echo $_POST['op']?>">
<input type=hidden id="accion" name="accion" value="<?php echo $_POST['accion']?>">
<input type=hidden id="variedad_num" name="variedad_num" value="<?php echo $_POST['variedad_num']?>">
<input type=hidden id="str" name="str" value="<?php echo $_POST['str']?>">
<input type=hidden id="long" name="long" value="<?php echo $_POST['long']?>">
<input type=hidden id="salir" name="salir" value="<?php echo $_POST['salir']?>">
<input type=hidden id="for_id" name="for_id" value="<?php echo $_POST['for_id']?>">
<input type=hidden id="tab" name="tab" value="<?php echo $_POST['tab']?>">
<input type=hidden id="editar" name="editar" value="<?php echo $_POST['editar']?>">
<input type=hidden id="tipox" name="tipox" value="<?php echo $_POST['tipox']?>">
<input type=hidden id="faltant" name="faltant" value="<?php echo $_POST['faltant']?>">
<input type=hidden id="bolet" name="bolet" value="<?php echo $_POST['bolet']?>">
<input type=hidden id="justif1" name="justif1" value="<?php echo $_POST['justif1']?>">
<input type=hidden id="enfoco" name="enfoco" value="<?php echo $_POST['enfoco']?>">
<input type=hidden id="readonly" name="readonly" value="<?php echo $_POST['readonly']?>">
<input type="hidden"  id="campos_ds_9" name="campos_ds_9" value="<?=$_POST['campos_ds_9']?>">
<?php include_once("includes/form_vus_botones.php");?>

<table border=0 align=center width=95% cellpadding=1 cellspacing=0 style="margin-top:0px" >
<td>
   <script type="text/javascript" src="includes/jquery/ui/ui.tabs.js"></script>
    <script type="text/javascript">
       $(function() {    
            $('#tabs').tabs({ selected: <?php echo $_POST['tab']?> });
       });
    </script>
    <div id="tabs">
        <ul>
        <li><a href="#tabs-1" onClick="submit_tab('1')"><?php echo $arr_label['formula']?></a></li>
        
<?php if($variedadef=='2'){ ?>
        <li><a href="#tabs-2" onClick="submit_tab('2')"><?php echo $arr_label['formula2']?></a></li>
        <li><a href="#tabs-3" onClick="submit_tab('3')"><?php echo $arr_label['formula3']?></a></li>
        <li><a href="#tabs-4" onClick="submit_tab('4')"><?php echo $arr_label['formula4']?></a></li>
        <li><a href="#tabs-5" onClick="submit_tab('5')"><?php echo $arr_label['formula5']?></a></li>
<?php }?>
        </ul>
        <div>
<table border="0" align=center width=95% cellpadding=1 cellspacing=0>

<?php if($_POST['nom_arch'] != "form_crear_producto_pc_10.php") { ?>

<?php if($_POST['var_id']==''){ $_POST['var_id']=1; } ?>

<?php if($variedad){ ?>
    <tr>
        <td class=form_standar_cap><?php echo $arr_label['var']?></td>
        <td colspan=2> 
       
        <select class="text-input" id=var_id name=var_id  onchange="submit_frame()">
<?php

    if ($_SESSION['usuario_cta'] == 2 && $_SESSION['panel'] != 10) {		
	//if ($_SESSION['usuario_cta'] == 2) {  //2013-03-06
		$prefijo = "adm_{$_POST['tipo_pro']}VAR_";
		$tabla = "ctg_productos_{$_POST['tipo_pro']}_VAR";
		$numreg = "numreg";
		$tpt_id = "";
		$conn = $connectionADM;
	} else {
		$prefijo = "vus_{$_POST['tipo_pro']}VAR_";
		$tabla = "vus_tramites_{$_POST['tipo_pro']}{$_SESSION['dtb_vus']}_VAR";
		$numreg = "numsol";
		$tpt_id = " AND \"{$prefijo}tpt_id\"='{$_POST['tpt_id']}' ";
		$conn = $connection;
	}

    if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){      
        $i=1;  
        $test = "";
        while($i<$_POST['variedad_num']+1 && $i < 1000){
            $sql= "SELECT * FROM \"{$tabla}\" WHERE \"{$prefijo}{$numreg}\"='{$_POST['numsol']}' $tpt_id AND \"{$prefijo}tpr_id\"='{$_POST['id']}' AND \"{$prefijo}var_id\"='$i' ";        
            $test .= $sql."<br>";
            $result=$conn->Execute($sql);
            if (!$result->EOF){
                $operador = $result->fields;
                echo "<option value=\"$i\">$i - ".$operador[$prefijo.'desc']."</option>";  
            }
            $i++;  
        }
       
        $_POST['max_id'] = $i;
        echo "<option value=\"$i\">$i - ".$arr_label['todas']."</option>";  
            
    }else{
        $sql="SELECT * FROM \"{$tabla}\" WHERE \"{$prefijo}{$numreg}\"='{$_POST['numsol']}' $tpt_id AND \"{$prefijo}tpr_id\"='{$_POST['id']}'";
        $i=1;        
       // echo "($sql)";        
        $result=$conn->Execute($sql);
        if (!$result->EOF){
            while ( !$result->EOF ) {
                $operador = $result->fields;
                echo "<option value=\"$i\">$i - ".$operador[$prefijo.'desc']."</option>"; 
                $result->MoveNext (); 
                $i++;
            }
        }
    }
?>	        
	        </select>	    
<?php    //echo $test; //"(".$_POST['variedad_num'].")<br>"; ?>	        
        </td>
        <td colspan=5></td>
    </tr>        
<?php } ?>

<?php } ?>

<?php 



if (isset($_SESSION['ADMusuario_id']) || campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])) { ?>
		<tr>	
			<td class=form_standar_cap valign=top><?php //echo $arr_label['vus_efFOR_each']?></td>
			<td>
<!--
				<select id=vus_efFOR_each name=vus_efFOR_each <?php echo campo_req($accion,"3",$_POST['readonly'],$arr_fields["vus_efFOR_each"])?> onchange="document.getElementById('vus_ef_formaLabel').style.display = 'none'; if (this.value == '1') document.getElementById('vus_ef_formaLabel').style.display = 'inline';">
				<option value=''><?php echo $arr_label['seleccionar']?></option>
			    <option value='1' <?=$_POST['vus_efFOR_each'] == 1 ? "selected" : ""?>><?php echo $arr_label['vus_ef_dosageforms']?></option>
			    <option value='2' <?=$_POST['vus_efFOR_each'] == 2 ? "selected" : ""?>><?php echo $arr_label['vus_ef_milliliters']?></option>
			    <option value='3' <?=$_POST['vus_efFOR_each'] == 3 ? "selected" : ""?>><?php echo $arr_label['vus_ef_grams']?></option>
			    <option value='4' <?=$_POST['vus_efFOR_each'] == 4 ? "selected" : ""?>><?php echo $arr_label['vus_ef_other']?></option>
				</select>		
-->	
<?php

	$veea1 = "";
	$veea2 = "";
	$veea0 = "";
	
	Switch ($_POST["vus_efFOR_each"]){
		case 1:
			$veea1 = " checked ";
			$veea0 = 1;
			break;
		case 2:
			$veea2 = " checked ";
			$veea0 = 2;
			break;
	}

?>

<script>

	function clearFormula(a){

		    $.ajax ({
		        type: "POST",
		        url: "/includes/form_ingredientes_op.php",
		        dataType: "json",
		        data: {op:'clearformula', tipo_pro: '<?=$_POST['tipo_pro']?>', numsol:'<?=$_POST['numsol']?>', tpt_id:'<?=$_POST['tpt_id']?>', id:'<?=$_POST['id']?>', for_id:'<?=$_POST['for_id']?>',each:$('#veea0').val(),unit_desc:$('#vus_efFOR_unit_desc').val()},
		      	success: function (data) { 
		        	console.log(data);
		        	
					//ChangeUnitDesc(a);		        	
					
		        	if (data.affected == 0){
						alert('<?=$arr_label['NoUpdateRecords']?>');
					} else {
						var UpdatedRecords = '<?=$arr_label['UpdateRecords']?>';
						UpdatedRecords = UpdatedRecords.replace('#*#',data.affected);
						alert(UpdatedRecords);						
						document.forms.form_standar.submit();
					}
		        }
		    })
			
	}

	function ChangeUnitDesc(a){
		
		console.log($('#vus_efFOR_unit_desc').val());
		$('#vus_efFOR_unit_desc').val('');
		
		switch(parseInt(a)){
			case 1:
				$('#vus_efFOR_unit_desc').val('<?=$arr_label['vus_efFOR_each2'] . " " . $_POST['gt_env_id_desc'] ?>');
				break;
			case 2:
				//alert(a + ' ' + '<?=$arr_label['vus_efFOR_each3']?>');
				$('#vus_efFOR_unit_desc').val('<?=$arr_label['vus_efFOR_each3']?>');
				//alert($('#vus_efFOR_unit_desc').val());
				break;
		}
	}
	
	function submit_unit_desc(a){

		if ($('#veea0').val() == '') {
			$('#veea0').val(a);
			ChangeUnitDesc(a);
		} else {

			if ($('#veea0').val() != a) {		
			    
			    $.ajax ({
			        type: "POST",
			        url: 'includes/form_ingredientes_op.php',
			        dataType: 'json',
			        data: {op:'checkformula', tipo_pro: '<?=$_POST['tipo_pro']?>', numsol:'<?=$_POST['numsol']?>', tpt_id:'<?=$_POST['tpt_id']?>', id:'<?=$_POST['id']?>', for_id:'<?=$_POST['for_id']?>'},
			      	success: function (data) { 
			        	console.log(data.sql);
			        	if (data.count > 0){		
							if (confirm('<?=$arr_label['QuantitiesToCero']?>')) {
								$('#veea0').val(a);
								ChangeUnitDesc(a);
								clearFormula(a); 
				
							} else {
			
								if (a == 1) {
									$('#veea2').attr('checked','on');
								} else {
									$('#veea1').attr('checked','on');
								}
								
								return false;
							}		
						} else {
							ChangeUnitDesc(a);
						} 
			        }
			    })
		    } else {
				ChangeUnitDesc(a);
			}
		}
	}

	
function GuardarCom(numsol,tpotra,tpopro,forid){

        var tip = "<?=$_POST['for_id']?>";
        var tpr = "<?=$_POST['id']?>";
        var tpt = "<?=$_POST['tpt_id']?>";
        var cod = "<?=$_POST['numsol']?>";
        var sig = "<?=$_POST['tipo_pro']?>";

        $.post("includes/form_ingredientes_op.php", { ajax: "1", tipo:tip, ctg_tpr_id:tpr, ctg_tpt_id:tpt, codigo:cod, obs:document.getElementById("vus_efFOR_reference").value, session_vus:'<?=$_SESSION['dtb_vus']?>',siglas:sig},

       function(data) 
        {           
            data = JSON.parse(json);  
            //alert(data);              
            console.log(data);
       },'json');
}

</script>

<body onload=ChangeUnitDesc('<?=$_POST["vus_efFOR_each"]?>');>

<input type=hidden id="vus_ef_admin" name="vus_ef_admin" value="<?php echo $_POST['vus_ef_admin']?>">
<input type=hidden id="forma_desc" name="forma_desc" value="<?php echo $_POST['forma_desc']?>">
<input type=hidden id="vus_ef_admin_oth" name="vus_ef_admin_oth" value="<?php echo $_POST['vus_ef_admin_oth']?>">
<input type=hidden id="gt_env_id_desc" name="gt_env_id_desc" value="<?php echo $_POST['gt_env_id_desc']?>">


                <table>
                    <tr>
                        <td class=form_standar_cap><?php echo $arr_label['each']?></td>

                        <td>
                            <input <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> size=50 maxlength=100 id="vus_efFOR_reference" name="vus_efFOR_reference" title="<?php echo $arr_label['vus_efFOR_reference']?>" value="<?php echo $_POST['vus_efFOR_reference']?>" onblur="GuardarCom();">
                        <td class=form_standar_cap><?php echo $arr_label['contain']?></td>
<!--
                        <td>
                            <ul id="icons" class="ui-widget ui-helper-clearfix">
                                <li class="ui-state-default ui-corner-all" >                                                                
                                    <span class="ui-icon ui-icon-disk"  title="<?=$arr_label['graba'].' '.$arr_label['comentarios']?>"></span>
                                </li>
                            </ul>-->
                    </tr>
                </table>

				<span  class=form_standar_cap id="vus_ef_formaLabel" align=center style="display:none"><?=$_POST['vus_efFOR_each'] == 1 ? $_POST['forma_desc'] : ""?>  (<?=$_POST['forma_desc']?>)</span>		
	        
		        
            <input type=hidden id=vus_efFOR_unit_desc name=vus_efFOR_unit_desc value="*<?=$_POST['vus_efFOR_unit_desc']?>" style="border:1px solid blue " display="none">
		        
			</td>
			
		</tr>	
<?php } // fin de if (isset($_SESSION['ADMusuario_id']) 997



if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])) { ?>

<?php if($cantidadef){ ?>
  <?php if($tipo){ ?>
    <tr>
        <td class=form_standar_cap><?php echo $arr_label['tipo']?></td>
        <td>  
          <select id=tipo name=tipo  <?php echo campo_req($accion,"3",$_POST['readonly'],$arr_fields[''])?> onchange="submit_categoria()" >
            <option value=''><?php echo $arr_label['seleccionar']?></option>
            <option value='1'><?php echo $arr_label['activo']?></option>
            <option value='2'><?php echo $arr_label['excipiente']?></option>
            <!--
            <option value='4'><?php echo $arr_label['recubrimiento']?></option>
            <option value='5'><?php echo $arr_label['saborizante']?></option>
            <option value='6'><?php echo $arr_label['colorante']?></option>
            <option value='7'><?php echo $arr_label['tinta']?></option>
            <option value='8'><?php echo $arr_label['cascarilla']?></option>
            <option value='3'><?php echo $arr_label['otro']?></option>
          -->
          </select>
        </td>        
    </tr>



    <tr>
    <?php if($ingrediente){ ?>
		<td class=form_standar_cap><?php echo $arr_label['ingrediente']?></td>
	<?php }else if($nom_sus){ ?>
        <td class=form_standar_cap><?php echo $arr_label['nom_sus']?></td>
    <?php } ?>
   
        <td colspan=5>
	        <input type=hidden id="max_id" name="max_id" value="<?php echo $_POST['max_id']?>">
	        <input type=hidden id="sus_id" name="sus_id" value="<?php echo $_POST['sus_id']?>">
	        <table border=0 cellpadding=1 cellspacing=0>
	        <tr>
            <?php /*if($cnf_newing!='1'){ ?>
            <tr>
            <td>
            <input <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> size=60 maxlength=100 id="sus_id_desc" name="sus_id_desc" onFocus="limpiar_sus_id()" onKeyPress="toupper(this);return acceptStandar(event)" onBlur="toupper(this);check_exist(this.value,this.id,'','<?php echo $sql_sus_nom_exist?>')" value="<?php echo $_POST['sus_id_desc']?>">
            </td>
            <?php } else { 

          <td>        
              <input id="sus_id_desc" name="sus_id_desc" list="ingredientes_list"  autocomplete="off" size=80 maxlength=100 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  onFocus="limpiar_sus_id()" onKeyPress="toupper(this);return acceptStandar(event)" onblur="valida_ingrediente_list(this,1)" value="<?php echo $_POST['sus_id_desc']?>">
          </td>

            */ ?>
	        
            <?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
            echo "<td><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
            //echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['nom_sus']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"if ($('#tipo').val() != '') check_look('','sus_id','".$sql_sus_id_look."'); else alert('".$arr_label['MustSelectType']."');\"></span></li>";
            echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['nom_sus']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"if ($('#tipo').val() != '') check_look('','sus_id','".$sql_sus_id_look."'); else alert('".$arr_label['MustSelectType']."');\"></span></li>";
            echo "</ul></td>";
             } ?>

	        <td>        
	            <input id="sus_id_desc" name="sus_id_desc" onFocus="if ($('#tipo').val() != '') limpiar_sus_id(); else { $('#sus_id_desc').val(''); alert('<?=$arr_label['MustSelectType']?>?'); }"  value="<?php echo $_POST['sus_id_desc']?>" size=75 maxlength=100 autocomplete="on" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>>
	        </td>
	        
<script>
/*$('#sus_id_desc').keypress(function(e) {
	if ($('#tipo').val() != '') { 
		toupper(this);return acceptStandar(event);
	} else {  
		if ($('#sus_id_desc').val() != '') { 
			alert('<?=$arr_label['MustSelectType']?>'); 
		} 
		return false;
	}
}*/

$('#sus_id_desc').blur(function(e) {
	    if($('#tipo').val() == 1 && $('#sus_id_desc').val() != '') {
			
			$.ajax ({
		        type: "POST",
		        url: 'includes/form_ingredientes_op.php',
		        dataType: 'json',
		        data: {op:'searchFormula', dato: $('#sus_id_desc').val()},
		      	success: function (data) { 
		        	console.log(data);
		        	
		        	if (data.dato != ''){
		        		$('#sus_id_desc').val(data.dato);
						alert('<?=$arr_label['TerminoPreferido']?>');
					} else {
						$('#sus_id_desc').val('');
					}
		        }
		    })
    	} else {

			if($('#tipo').val() == '' && $('#sus_id_desc').val() != '')
				alert('<?=$arr_label['MustSelectType']?>*');
		}
    //}
});	
</script>	        
<?php //} ?>
    
            <?php if($_POST['tipo_pro']=='ef'){ ?>
	            <td class=form_standar_cap colspan=2><?php echo $arr_label['pre_pfi']?></td>
                <td><input  type="checkbox" <?php echo campo_req($accion,"3",$_POST['readonly'],$arr_fields[''])?>  id="pre_pfi" name="pre_pfi" value="1" <?php echo $_POST['pre_pfi']?>></td>
            <?php } ?>
            </table>

        </td>
    </tr>    


		<tr>	
			<td class=form_standar_cap><?php echo $arr_label['vus_efFOR_cominfo']?></td>
			<td>			
			<input <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> size=100 maxlength=100  id="vus_efFOR_cominfo" name="vus_efFOR_cominfo" onKeyPress="return acceptStandar(event);" value="<?php echo $_POST['vus_efFOR_cominfo']?>" >
       		</td>
		</tr>	


    <?php if($tipopa || $funcion){ ?>
	<tr>
	  <?php if($tipopa){ ?>
		<td class=form_standar_cap><?php echo $arr_label['tipo']?></td>
        <td>
            <select id=tipo name=tipo  <?php echo campo_req($accion,"3",$_POST['readonly'],$arr_fields[''])?> >
	        <option value=''><?php echo $arr_label['seleccionar']?></option>
			<option value='1'><?php echo $arr_label['aditivo']?></option>
			<option value='2'><?php echo $arr_label['ingrediente']?></option>
            </select>
        </td>
	  <?php } ?>  

	<?php if($funcion){ ?>
    <tr>
		<td class=form_standar_cap><?php echo $arr_label['funcion']?></td>
		<td>
            <table cellpadding=1 cellspacing=0>
            <tr>
            <td>
            <input id="fun" name="fun" onKeyPress="return acceptAlfaNumeric(event);" onBlur="check_exist(this.value,this.id,'conct','<?php echo $sql_fun_exist?>')" value="<?php echo $_POST['fun']?>" size=10 maxlength=10 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> >
            </td>    
            <td>
                <?php   
                echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
                echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['funcion']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','fun','".$sql_fun_look."','conct')\"></span></li>";
                echo "</ul>";
                ?>
            </td>
            <td>
                <input id="fun_desc" name="fun_desc" value="<?php echo $_POST['fun_desc']?>" size=50 maxlength=50 type=text class="text-view" disabled="disabled" >
            </td>
            </tr>
            </table>
        </td>
	</tr>

	<?php } ?>
	
<?php } ?>






 <?php if($cantidad){ ?>   


    <tr>
		<td class=form_standar_cap><?php echo $arr_label['cantidad']?></td>
		<td>
		
			<input size=6 maxlength=10 autocomplete="off" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>   onKeyPress="return acceptNumeric(event);"  id="can" name="can" value="<?php echo $_POST['can']?>" style="text-align:right">
			.
			<input size=5 maxlength=10 autocomplete="off" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>   onKeyPress="return acceptNumeric(event);"  id="can2" name="can2" value="<?php echo $_POST['can2']?>">
			
		</td>
		
<?php } ?>

<?php /* if($unidad){ ?> SE OCULTA UNIDA 2014-04-26
		
        <td class=form_standar_cap width=15% ><?php echo $arr_label['unidad']?></td>
        <td width="50%">

        <table cellpadding=1 cellspacing=0>
        <tr>
		<td>
        
            <input size=10 maxlength=10 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> id="ume_ids" name="ume_ids"  onKeyPress="return acceptAlfa(event);" onBlur="Lower(this);check_exist(this.value,this.id,'conct','<?php echo $sql_ume_exist?>')" value="<?php echo $_POST['ume_ids']?>">
        
        </td>
        <td>

<?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['unidad']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','ume_ids','".$sql_ume_look."','conct')\"></span></li>";
echo "</ul></td>";

 } ?>

	   <td><input size=25 maxlength=25 type=text class="text-view" disabled="disabled" id='ume_ids_desc' name='ume_id
       s_desc' value="<?php echo $_POST['ume_ids_desc']?>"></td>
        </tr>
        </table>
<?php } */ ?>



	

    </tr>
<!--
<?php if($uso){ ?>
    <tr>
		<td class=form_standar_cap><?php echo $arr_label['uso']?></td>
		<td><input size=10 maxlength=10  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="uso" name="uso" onKeyPress="return acceptAlfaNumeric(event);" value="<?php echo $_POST['uso']?>"></td>
<?php } ?>
<?php if($naturaleza){ ?>
		<td class=form_standar_cap><?php echo $arr_label['naturaleza']?></td>
		<td><input size=10 maxlength=10  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="natur" name="natur" onKeyPress="return acceptAlfaNumeric(event);" value="<?php echo $_POST['natur']?>"></td>
<?php } ?>

    </tr>    

<?php if($tipo_comp){ ?>    
        <tr>
		<td class=form_standar_cap><?php echo $arr_label['tipo_comp']?></td>
		<td><input size=25 maxlength=25  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="tip_comp" name="tip_comp" onKeyPress="return acceptStandar(event)" value="<?php echo $_POST['tip_comp']?>"></td>
<?php } ?>
<?php if($modalidad){ ?>
		<td class=form_standar_cap width=10%><?php echo $arr_label['modalidad']?></td>
		<td><input size=25 maxlength=25  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="mod_comp" name="mod_comp" onKeyPress="return acceptStandar(event)" value="<?php echo $_POST['mod_comp']?>"></td>
<?php } ?>
-->
<?php if($justificado){ ?>
    <tr>
		<td class=form_standar_cap><?php echo $arr_label['justificacion']?></td>
		<td colspan=3><input size=100 maxlength=100 autocomplete="off" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="justif" name="justif" onKeyPress="return acceptStandar(event)" value="<?php echo $_POST['justif']?>"></td>
    </tr>  
<?php } ?>

<?php } ?>  
    <tr>
		<td class=form_standar_cap><?php echo $arr_label['cantidad']?></td>
		<td>
		
			<!-- <input id="can" name="can" size=10 maxlength=10 autocomplete="off" onKeyPress="return acceptNumeric(event);" value="<?php echo $_POST['can']?>" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>>
			-->
			

			<input size=7 maxlength=5 autocomplete="off" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>   onKeyPress="return acceptNumeric(event);"  id="can" name="can" value="<?php echo $_POST['can']?>" style="text-align:right">
			.
			<input size=5 maxlength=4 autocomplete="off" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>   onKeyPress="return acceptNumeric(event);"  id="can2" name="can2" value="<?php echo $_POST['can2']?>">
						
			
			
		</td>
    </tr>
		
<?php } ?>



<script>
	function submit_admin(a){
		console.log(a);
		$('#vus_efFOR_ume_oth').hide();
		switch(parseInt(a)){
			case 4:
		$('#vus_efFOR_ume_oth').show();
				break;
		}
	}
</script>



<?php
if ($cantidadef) {

	$veum1 = "";
	$veum2 = "";
	$veum3 = "";
	$veum4 = "";

	Switch ($_POST["vus_efFOR_ume_id"]){
		case 1:
		$veum1 = " checked ";
			break;
		case 2:
		$veum2 = " checked ";
			break;
		case 3:
		$veum3 = " checked ";
			break;
		case 4:
		$veum4 = " checked ";
			break;
	}
?>
	<tr>
		<td class=form_standar_cap><?php echo $arr_label['vus_efFOR_ume_id']?></td>
		<td colspan=4>
					
		<table>
		<tr><td><input type=radio name='vus_efFOR_ume_id' id='veum1' value='1' onclick="return submit_admin(this.value)" <?=$veum1?> ></td>
		<td class=checkbox_cap><label for='veum1' class=checkbox_cap><?=$arr_label['vus_efFOR_ume_id1']?></label></td></tr>
		<tr><td><input type=radio name='vus_efFOR_ume_id' id='veum2' value='2' onclick="return submit_admin(this.value)" <?=$veum2?> ></td>
		<td class=checkbox_cap><label for='veum2' class=checkbox_cap><?=$arr_label['vus_efFOR_ume_id2']?></label></td></tr>
		<tr><td><input type=radio name='vus_efFOR_ume_id' id='veum3' value='3' onclick="return submit_admin(this.value)" <?=$veum3?> ></td>
		<td class=checkbox_cap><label for='veum3' class=checkbox_cap><?=$arr_label['vus_efFOR_ume_id3']?></label></td></tr>
		<tr><td><input type=radio name='vus_efFOR_ume_id' id='veum4' value='4' onclick="return submit_admin(this.value)" <?=$veum4?> ></td>
		<td class=checkbox_cap><label for='veum4' class=checkbox_cap><?=$arr_label['vus_efFOR_ume_id4']?></label>
		<input size=40 maxlength=150  id="vus_efFOR_ume_oth" name="vus_efFOR_ume_oth" onKeyPress="return acceptStandar(event);" value="<?php echo $_POST['vus_efFOR_ume_oth']?>">

		</td></tr>
		</table>

    	</td>	
	</tr>

<script>
submit_admin('<?=$_POST["vus_efFOR_ume_id"]?>');
</script>

<?php
} 

/* if($unidadef){ ?> SE OCULTA UNIDA 2014-04-26
		
        <td class=form_standar_cap width=10% ><?php echo $arr_label['unidad']?></td>
        <td width="15%"><table cellpadding=1 cellspacing=0>
		<td><input size=10 maxlength=10 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> id="ume_ids" name="ume_ids"  onKeyPress="return acceptAlfaNumeric(event);" onBlur="Lower(this);check_exist(this.value,this.id,'ume','<?php echo $sql_ume_exist?>')" value="<?php echo $_POST['ume_ids']?>"></td><td>

<?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['unidad']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','ume_ids','".$sql_ume_look."')\"></span></li>";
echo "</ul></td>";

 } ?>
	<td colspan="2"><input size=25 maxlength=25 type=text class="text-view" disabled="disabled" id='ume_ids_desc' name='ume_ids_desc' value="<?php echo $_POST['ume_ids_desc']?>"></td>


</td></table>

<?php } */ ?>  


  
<?php if($pais != "LAO" ){  ?>
  
  <?php /* if($_POST['tipo_pro']=='ef' && $_POST['tipo']==1){  $height=500; */?>
  <?php if($_POST['tipo_pro']=='ef' ){  $height=500; ?>

    <tr>
        <td class=form_standar_cap rowspan="1"><?php echo $arr_label['cod_atc']?></td>
        <td colspan=3>
            
            <table cellpadding=1 cellspacing=0>
            <tr>
            <td colspan=2>
                <table cellpadding=1 cellspacing=0 border=0>
                <tr>
                <td>
                <input size=10 maxlength=10 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> id="atc_id" name="atc_id" onKeyPress="return acceptAlfaNumeric(event);" onBlur="toupper(this);check_exist(this.value,this.id,'ume','<?php echo $sql_atc_exist?>')" value="<?php echo $_POST['atc_id']?>">
                </td>
                
                
                <?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
                echo "<td><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
                echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['cod_atc']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','atc_id','".$sql_atc_look."')\"></span></li>";
                echo "</ul></td>";
                } ?>
                <td colspan="2">
                <input size=55 maxlength=55 type=text class="text-view" title="<?php echo $_POST['atc_id_desc']?>" readonly id="atc_id_desc" name="atc_id_desc" value="<?php echo $_POST['atc_id_desc']?>">
                </td>
                </tr>
                </table>
           </td>
           </tr>
           </table>
       </td>
    </tr>  
<?php } ?>
          
<?php if($pais == "VEN"){  ?>
            
    <tr>     
        <td class=form_standar_cap><?php echo $arr_label['estereo']?></td>
        <td colspan="3">
            
            <table cellpadding=1 cellspacing=0> 
            <tr>
            <td colspan=2>
                <input size=10 maxlength=10  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="este" name="este" onKeyPress="return acceptAlfaNumeric(event);" onBlur="toupper(this);check_exist(this.value,this.id,'sue_can','<?php echo $sql_somero_exist?>')" value="<?php echo $_POST['este']?>">
            </td>

            <?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
            echo "<td width=10><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
            echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['estereo']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','este','".$sql_somero_look."','sue_can')\"></span></li>";
            echo "</ul></td>";
            } ?>
            
                <td colspan="2">
                <input size=55 maxlength=55 type=text class="text-view" title="<?php echo $_POST['este_desc']?>" readonly id="este_desc" name="este_desc" value="<?php echo $_POST['este_desc']?>">

            </tr>            
            </table>
            
        </td>
    </tr>

    <?php if($rango) { ?>
	<tr>

    <td class=form_standar_cap><?php echo $arr_label['rango']?></td>
        <td colspan="3">
            
            <table cellpadding=1 cellspacing=0> 
            <tr>
            <td colspan=2>
                <input size=10 maxlength=10  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="rango" name="rango" onKeyPress="return acceptAlfaNumeric(event);" onBlur="toupper(this);check_exist(this.value,this.id,'sue_can','<?php echo $sql_rango_exist?>')" value="<?php echo $_POST['rango']?>">
            </td>

            <?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
            echo "<td width=10><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
            echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['rango']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','rango','".$sql_rango_look."','sue_can')\"></span></li>";
            echo "</ul></td>";
            } ?>            
                <td colspan="2">
                <input size=55 maxlength=55 type=text class="text-view" title="<?php echo $_POST['rango_desc']?>" readonly id="rango_desc" name="rango_desc" value="<?php echo $_POST['rango_desc']?>">

            </tr>            
            </table>
            
        </td>

    </tr>
<?php } //fin rango ?>

<?php } ?>



<!--
	<tr>
		<td class=form_standar_cap><?php echo $arr_label['can_equivalencia']?></td>
  	    <td><input size=50 maxlength=50 autocomplete="off" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="sue_can" name="sue_can" value="<?php echo $_POST['sue_can']?>"></td>
  	  
  	  <?php /* 2014-04-26
		<td class=form_standar_cap width=10% ><?php echo $arr_label['unidad_equivalencia']?></td>
  	<td width="15%"><table cellpadding=1 cellspacing=0>
		  <td><input size=10 maxlength=10 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> id="sue_ume_id" name="sue_ume_id"  onKeyPress="return acceptAlfaNumeric(event);" onBlur="Lower(this);check_exist(this.value,this.id,'ume','<?php echo $sql_ume_exist?>')" value="<?php echo $_POST['sue_ume_id']?>"></td><td>
	
    <?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
    echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
    echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['unidad']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','sue_ume_id','".$sql_ume_look."')\"></span></li>";
    echo "</ul></td>";

     } ?>
			<td colspan="2"><input size=25 maxlength=25 type=text class="text-view" disabled="disabled" id="sue_ume_id_desc" name="sue_ume_id_desc" value="<?php echo $_POST['sue_ume_id_desc']?>"></td>
  	</td></table>
  	*/?>
	</tr>    
	
	<tr>    
		<td class=form_standar_cap><?php echo $arr_label['nom_equivalente']?></td>
        <input type=hidden id="sue_id" name="sue_id" value="<?php echo $_POST['sue_id']?>">     
        <td colspan=5>  
            <table cellpadding=1 cellspacing=0>
            <tr>
            <td> 
            -->
<!--    
  <input size=60 maxlength=100 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="sue_id_desc" name="sue_id_desc" onFocus="limpiar_sue_id()" onKeyPress="toupper(this);return acceptStandar(event)" onBlur="toupper(this);check_exist(this.value,this.id,'','<?php echo $sql_sue_nom_exist?>')" value="<?php echo $_POST['sue_id_desc']?>">

            <input size=60 maxlength=100 list="ingredientes_list" autocomplete="off" <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="sue_id_desc" name="sue_id_desc" onFocus="limpiar_sue_id()" onKeyPress="toupper(this);return acceptStandar(event)" onblur="valida_ingrediente_list(this)"  value="<?php echo $_POST['sue_id_desc']?>">
            
-->            </td>
        
            <?php /* if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
            echo "<td><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
            echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['nom_equivalente']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','sue_id','".$sql_sue_id_look."')\"></span></li>";
            echo "</ul></td>";
             } */?>
            </table>
        </td>
    </tr>
 
 <?php } //fin de EF ?>


<?php if($equivalentex){ ?>  
	<tr>
	 <?php if($canequivalentex){ ?>  
        <td class=form_standar_cap><?php echo $arr_label['can_equivalencia']?></td>
  	    <td><input size=80 maxlength=150  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="sue_can" name="sue_can" value="<?php echo $_POST['sue_can']?>"></td>
	<?php } ?>
	
	 <?php if($uniequivalentex){ ?>  
		<td class=form_standar_cap><?php echo $arr_label['unidad_equivalencia']?></td>
  	    <td>
  	        <table cellpadding=1 cellspacing=0>
	        <td><input size=10 maxlength=10 <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?> id="sue_ume_id" name="sue_ume_id"  onKeyPress="return acceptAlfaNumeric(event);" onBlur="Lower(this);check_exist(this.value,this.id,'ume','<?php echo $sql_ume_exist?>')" value="<?php echo $_POST['sue_ume_id']?>"></td>
	        <td>	
            <?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
            echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
            echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['unidad']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','sue_ume_id','".$sql_ume_look."')\"></span></li>";
            echo "</ul></td>";
             } ?>
			<td colspan="2"><input size=25 maxlength=25 type=text class="text-view" disabled="disabled" id="sue_ume_id_desc" name="sue_ume_id_desc" value="<?php echo $_POST['sue_ume_id_desc']?>"></td>
      	    </table>
    	</td>    
	<?php } ?>
	</tr>    
	
	<tr>
<?php if($nomequivalentex){ ?>  
		<td class=form_standar_cap><?php echo $arr_label['nom_equivalente']?></td>
        <input type=hidden id="sue_id" name="sue_id" value="<?php echo $_POST['sue_id']?>">
       
        <td colspan=5>
    
<?php
if($cnf_newing!='1'){ ?>
            <table cellpadding=1 cellspacing=0>
            <td><input size=100 maxlength=100  <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="sue_id_desc" name="sue_id_desc" onFocus="limpiar_sue_id()" onKeyPress="toupper(this);return acceptStandar(event)" onBlur="toupper(this);check_exist(this.value,this.id,'','<?php echo $sql_sue_nom_exist?>')" value="<?php echo $_POST['sue_id_desc']?>"></td>
<?php }else{ ?>
            <table cellpadding=1 cellspacing=0><td><input size=100 maxlength=100   <?php echo campo_req($accion,"1",$_POST['readonly'],$arr_fields[''])?>  id="sue_id_desc" name="sue_id_desc" onFocus="limpiar_sue_id()" onKeyPress="toupper(this);return acceptStandar(event)" onBlur="toupper(this);" value="<?php echo $_POST['sue_id_desc']?>"></td>
<?php }  ?>

    <?php if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])){  
        echo "<td><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
        echo "<li class=\"ui-state-default ui-corner-all\" title=\"".$arr_label['buscar']." ".$arr_label['nom_equivalente']."\"><span class=\"ui-icon ui-icon-search\" style='' onClick=\"check_look('','sue_id','".$sql_sue_id_look."')\"></span></li>";
        echo "</ul></td>";
     } 
?>

            </table>
        </td>
<?php } ?>
    </tr>
 
<?php } //fin equivalentes?>


<?php } // este el fin del if(campo_req($accion,"2",$_POST['readonly'],$arr_fields[''])) { line 1238 ?>


</table>
    
    
<?php
    if($_POST['var_id']=='') $_POST['var_id']=1;

    if ($_SESSION['usuario_cta'] == 2 && $_SESSION['panel'] != 10) {
	//if ($_SESSION['usuario_cta'] == 2) {  //2013-03-06
		$prefijo = "adm_{$_POST['tipo_pro']}FOR_";
		$tabla = "ctg_productos_{$_POST['tipo_pro']}_formulareg";
		$numreg = "numreg";
		$tpt_id = "";
		$conn = $connectionADM;
	} else {
		$prefijo = "vus_{$_POST['tipo_pro']}FOR_";
		$tabla = "vus_tramites_{$_POST['tipo_pro']}{$_SESSION['dtb_vus']}_formula";
		$numreg = "numsol";
		$tpt_id = " AND \"{$prefijo}tpt_id\"='{$_POST['tpt_id']}' ";
		$conn = $connection;
	}
	
	$sql= "SELECT * FROM $tabla WHERE \"{$prefijo}{$numreg}\"='{$_POST['numsol']}' $tpt_id  AND \"{$prefijo}tpr_id\"='{$_POST['id']}' ";
	if ($_POST['tipo_pro'] == "ef")
		   $sql .= " AND \"{$prefijo}id\"='".$_POST['for_id']."'";
		  
$z=0;      
   
?>

	<!--
    <input type=text id="desc" name="desc" value="<?=$_POST['desc']?>">
    <input type=text id="var_tipo" name="var_tipo" value="<?=$_POST['var_tipo']?>">
    -->

    <input type=hidden id="desc" name="desc">
    <input type=hidden id="var_tipo" name="var_tipo">


    <iframe id="tabla_ingredintes" name="tabla_ingredintes" width="100%" height="400" scrolling=auto frameborder=0 src="#" ></iframe>
                  
    </div>
           
            
    </div>

</td>
</table>




















<?php
$opciones = "";

if($_POST['dis_emp_v']==''){  
    /*$arr_datos = array();
    $i=0;
    $sql = "SELECT ctg_sus_sinonims, ctg_sus_desc, ctg_sus_id FROM ctg_substancias WHERE ctg_tpr_id = '{$_POST['id']}' ORDER BY ctg_sus_desc";
    //echo "$sql<br>";
    $result=$connectionADM->Execute($sql);
    if (!$result->EOF) {
        while (!$result->EOF) {
            $operador = $result->fields;
            
            //$operador['ctg_sus_sinonims'] = eregi_replace("[\n|\r|\n\r]", " ", $operador['ctg_sus_sinonims']);

            $operador['ctg_sus_sinonims'] = str_replace(array("\n","\r","\n","\r"), " ", $operador['ctg_sus_sinonims']);

            
        	$opciones .= "<option value='{$operador['ctg_sus_desc']} ({$operador['ctg_sus_sinonims']})'>";
            $arr_datos[] = array("id"=>$operador['ctg_sus_id'],"desc"=>$operador['ctg_sus_desc'],"clave"=>$operador['ctg_sus_desc']." (".$operador['ctg_sus_sinonims'].")");
            $i++;
            $result->MoveNext ();
        }
        $json = json_encode ($arr_datos);
    }*/
?>	
	

<datalist id="ingredientes_list">
<?=$opciones?>
</datalist>

<script>
/*
$("#sus_id_desc,#sue_id_desc").bind('input', function () {
    window.checkModelData(this);
});

window.checkModelData = function(obj) {
    if (obj.value != '') {
        var myjson = <?php echo $json;?>;
        for(i=0;i < <?=$i?>;i++){  
            if (myjson[i].clave == obj.value) {
                console.log('(' + myjson[i].clave + ')(' + obj.value + ')');
                obj.value = myjson[i].desc;
                break;
            }
        }            
    }
}



function valida_ingrediente_list(obj,tip) { //2014-06-21    
    toupper(obj);
    check_exist(obj.value,obj.id,'tipo','<?php echo $sql_sus_nom_exist?>');    
}
*/
</script>

<?php } ?>




<script type="text/javascript">

if(document.getElementById('tipo')){
         document.getElementById('tipo').value = '<?php echo $_POST['tipo']?>';
}

if(document.getElementById('var_id')){
         document.getElementById('var_id').value = '<?php echo $_POST['var_id']?>';
}

        enfoco = document.getElementById('enfoco').value;
        
        if (document.getElementById(enfoco))
            document.getElementById(enfoco).focus();        
    
        document.getElementById('enfoco').value = "";
</script>

<script type="text/javascript">
submit_frame();
</script>


