<?php use_helper('Javascript') ?>
<?php use_helper('Object') ?>
<?php use_helper('Date') ?>

<?php echo form_tag('encuesta/updateDatosCrediticiosCrediya', array ('name' => 'formDatosCrediticios','id' => 'formDatosCrediticios','onChange' => 'optionChange()', 'onSubmit' => 'return submitDatosCrediticios()')) ?>

<?php /* Constantes YML */ ?>
<?php $constantes = sfYaml::load(sfConfig::get('sf_root_dir').'/config/const.yml'); ?>
<?php $adquisicion = '' ?>
<?php $mejoras = '' ?>

<?php /* campos de control */ ?>
<?php echo input_hidden_tag('solicitud_solte_nat_id', $solicitud_solte_nat->getId()) ?>
<?php echo input_hidden_tag('solicitud_solicitud_id', $solicitud_solicitud->getId()) ?>
<?php //echo input_hidden_tag('solicitud_ref_personales_id', $solicitud_ref_personales->getId()) ?>
<?php //echo input_hidden_tag('solicitud_ref_personales_id2', $solicitud_ref_personales->getId()) ?>
<?php //echo input_hidden_tag('solicitud_ref_bancarias', $solicitud_ref_bancarias->getId()) ?>
<?php //echo input_hidden_tag('solicitud_ref_bancarias2',$solicitud_ref_bancarias->getId()) ?>
<?php echo input_hidden_tag('hoy', date('Y-m-d')) ?>

<?php /* controles */ ?>
<div id="ctl1">

</div>

<?php $producto_objeto_id = $producto_producto->getProductoObjetoId() ?>

<?php //if ($producto_objeto_id == $constantes["objeto_adquisicion"]) : ?>
  <?php //$adquisicion = 'on' ?>
<?php //else : ?>
  <?php //$mejoras = 'on' ?>
<?php //endif; ?>
<?php echo input_hidden_tag('adquisicion', $adquisicion ? $adquisicion : 0) ?>
<?php echo input_hidden_tag('mejoras', $mejoras ? $mejoras : 0) ?>
<?php echo input_hidden_tag('credito_vivienda', $credito_vivienda) ?>
<?php echo input_hidden_tag('credito_activo', $credito_activo) ?>
<?php echo input_hidden_tag('hoy', date('Y-m-d')) ?>


<div class="encuesta_grupo">
  <?php echo _('Datos Financieros') ?>
</div>

<div><font color="red"><h2><?php echo $sf_request->hasError('msg_gastos') ? "<div class='validate_error'>".$sf_request->getError('msg_gastos')."</div>" : '' ?></h2></font></div>

<div class="encuesta_sub_grupo">
  <?php echo _('Ingresos Mensuales') ?>
</div>

<table class="encuesta" border="0">
  <tbody>
    <tr>
      <th class="encuesta"><?php echo _('Sueldo (Bs.):') ?><font color="red"><strong>*</strong></font></th>
      <th class="encuesta"><?php echo _('Honorarios Profesionales (Bs.):') ?><font color="red"><strong>*</strong></font></th>
      <th class="encuesta"><?php echo _('Comisiones y Bonos (Bs.):') ?><font color="red"><strong>*</strong></font></th>
      <th class="encuesta"><?php echo _('Intereses y Rentas (Bs.):') ?><font color="red"><strong>*</strong></font></th>
    </tr>
    <tr>      
      <td class="encuesta">
        <?php echo $sf_request->hasError('ingreso_mensual') ? "<div class='validate_error'>".$sf_request->getError('ingreso_mensual')."</div><br />" : '' ?>
        <?php if ($ingreso_mensual = $solicitud_solte_nat->getIngresoMensual()) : ?>
          <?php $ingreso_mensual = str_replace('.',',',$ingreso_mensual) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $ingreso_mensual) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $ingreso_mensual .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $ingreso_mensual = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('ingreso_mensual', $ingreso_mensual, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
      <td class="encuesta">
        <?php echo $sf_request->hasError('honorarios_prof') ? "<div class='validate_error'>".$sf_request->getError('honorarios_prof')."</div><br />" : '' ?>
        <?php if ($honorarios_prof = $solicitud_solte_nat->getHonorariosProf()) : ?>
          <?php $honorarios_prof = str_replace('.',',',$honorarios_prof) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $honorarios_prof) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $honorarios_prof .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $honorarios_prof = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('honorarios_prof', $honorarios_prof, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
     
      <td class="encuesta">
        <?php echo $sf_request->hasError('comisiones_bonos') ? "<div class='validate_error'>".$sf_request->getError('comisiones_bonos')."</div><br />" : '' ?>
        <?php if ($comisiones_bonos = $solicitud_solte_nat->getComisionesBonos()) : ?>
          <?php $comisiones_bonos = str_replace('.',',',$comisiones_bonos) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $comisiones_bonos) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $comisiones_bonos .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $comisiones_bonos = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('comisiones_bonos', $comisiones_bonos, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
      
       <td class="encuesta">
        <?php echo $sf_request->hasError('intereses_rentas') ? "<div class='validate_error'>".$sf_request->getError('intereses_rentas')."</div><br />" : '' ?>
        <?php if ($intereses_rentas = $solicitud_solte_nat->getInteresesRentas()) : ?>
          <?php $intereses_rentas = str_replace('.',',',$intereses_rentas) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $intereses_rentas) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $intereses_rentas .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $intereses_rentas = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('intereses_rentas', $intereses_rentas, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
      
    </tr>

   
  </tbody>
</table>

<div class="encuesta_sub_grupo">
  <?php echo _('Gastos Mensuales') ?>
</div>

<table class="encuesta" border="0">
  <tbody>
    <tr>
      <th class="encuesta"><?php echo _('Gastos Familiares (Bs.):') ?><font color="red"><strong>*</strong></font></th>
      <th class="encuesta"><?php echo _('Préstamos (Bs.):') ?><font color="red"><strong>*</strong></font></th>
      <th class="encuesta"><?php echo _('Tarjetas de Crédito (Bs.):') ?><font color="red"><strong>*</strong></font></th>
      <th class="encuesta"><?php echo _('Cuota de Hipoteca (Bs.):') ?><font color="red"><strong>*</strong></font></th>
    </tr>
    <tr>      
      <td class="encuesta">
        <?php echo $sf_request->hasError('monto_otros') ? "<div class='validate_error'>".$sf_request->getError('monto_otros')."</div><br />" : '' ?>
        <?php if ($monto_otros = $solicitud_solicitud->getMontoOtros()) : ?>
          <?php $monto_otros = str_replace('.',',',$monto_otros) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $monto_otros) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $monto_otros .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $monto_otros = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('monto_otros', $monto_otros, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
      <td class="encuesta">
        <?php echo $sf_request->hasError('monto_deudas') ? "<div class='validate_error'>".$sf_request->getError('monto_deudas')."</div><br />" : '' ?>
        <?php if ($monto_deudas = $solicitud_solicitud->getMontoDeudas()) : ?>
          <?php $monto_deudas = str_replace('.',',',$monto_deudas) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $monto_deudas) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $monto_deudas .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $monto_deudas = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('monto_deudas', $monto_deudas, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
     
      <td class="encuesta">
        <?php echo $sf_request->hasError('monto_credito_mas_alto') ? "<div class='validate_error'>".$sf_request->getError('monto_credito_mas_alto')."</div><br />" : '' ?>
        <?php if ($monto_credito_mas_alto = $solicitud_solicitud->getMontoCreditoMasAlto()) : ?>
          <?php $monto_credito_mas_alto = str_replace('.',',',$monto_credito_mas_alto) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $monto_credito_mas_alto) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $monto_credito_mas_alto .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $monto_credito_mas_alto = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('monto_credita_mas_alto', $monto_credito_mas_alto, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
      
       <td class="encuesta">
        <?php echo $sf_request->hasError('monto_alquiler') ? "<div class='validate_error'>".$sf_request->getError('monto_alquiler')."</div><br />" : '' ?>
        <?php if ($monto_alquiler = $solicitud_solicitud->getMontoAlquiler()) : ?>
          <?php $monto_alquiler = str_replace('.',',',$monto_alquiler) ?>
          <?php /* Si el monto tiene un solo decimal se le agrega un cero al final */ ?>
          <?php $parametros = explode(",", $monto_alquiler) ?>
          <?php if ($parametros[1]) : ?>
            <?php if (strlen($parametros[1]) == 1) : ?>
              <?php $monto_alquiler .= '0' ?>
            <?php endif; ?>
          <?php endif; ?>
        <?php else : ?>
          <?php $monto_alquiler = '0'; ?>
        <?php endif; ?>
        <?php echo input_tag('monto_alquiler', $monto_alquiler, array('class' => 'encuesta_input_txt', 'maxlength' => $constantes["input_max_monto"])) ?>&nbsp;&nbsp;
        <?php echo 'Ejemplo: 1000 ó 1000,00' ?>
      </td>
      
    </tr>

   
  </tbody>
</table>

<div class="encuesta_grupo">
  <?php echo _('Referencias Personales (Debe Incluir las dos Referencias Personales)') ?>
</div>
<table class="encuesta" border="0">
  <tbody>
    <tr>
      <th class="encuesta"><?php echo _('Apellidos y Nombres:') ?><font color="red"><strong>*</strong></font></th>
      <th class="encuesta"><?php echo _('Telefono Principal:') ?><font color="red"><strong>*</strong></font></th>
        <th class="encuesta"><?php echo _('Telefono Secundario:') ?><font color="red"><strong>*</strong></font></th>

    </tr>
    <tr>      
     <td class="encuesta">
        <?php echo $sf_request->hasError('nombres_apellidos') ? "<div class='validate_error'>".$sf_request->getError('nombres_apellidos')."</div><br />" : '' ?>      
     <?php echo input_tag('nombres_apellidos',$nombres_apellidos,  array('class' => 'encuesta_input_txt2', 'maxlength' => $constantes["input_max_ptoreferencia"])) ?>
         <?php //echo input_hidden_tag($nombres_apellidos); ?>
        
     </td>
     
     <td class="encuesta">
        <?php echo $sf_request->hasError('telefono_1') ? "<div class='validate_error'>".$sf_request->getError('telefono_1')."</div><br />" : '' ?>
         <?php echo input_tag('telefono_1','',  array('class' => 'encuesta_input_txt', 'maxlength' => 11)) ?>
     </td>
     
     <td class="encuesta">
        <?php echo $sf_request->hasError('telefono_2') ? "<div class='validate_error'>".$sf_request->getError('telefono_2')."</div><br />" : '' ?>
        <?php echo input_tag('telefono_2','',  array('class' => 'encuesta_input_txt', 'maxlength' => 11)) ?>
     </td>
    <tr>
      <td class="encuesta">
        <?php echo $sf_request->hasError('nombres_apellidos2') ? "<div class='validate_error'>".$sf_request->getError('nombres_apellidos2')."</div><br />" : '' ?>      
     <?php echo input_tag('nombres_apellidos2',$nombres_apellidos2, array('class' => 'encuesta_input_txt2', 'maxlength' => $constantes["input_max_ptoreferencia"])) ?>
         <?php //echo input_hidden_tag('ref_per2', $solicitud_ref_personales2->getId()) ?>
     </td>
     
     <td class="encuesta">
        <?php echo $sf_request->hasError('telefono_1a') ? "<div class='validate_error'>".$sf_request->getError('telefono_1a')."</div><br />" : '' ?>
         <?php echo input_tag('telefono_1a','', array('class' => 'encuesta_input_txt', 'maxlength' => 11)) ?>
     </td>
     
     <td class="encuesta">
        <?php echo $sf_request->hasError('telefono_2a') ? "<div class='validate_error'>".$sf_request->getError('telefono_2a')."</div><br />" : '' ?>
        <?php echo input_tag('telefono_2a','', array('class' => 'encuesta_input_txt', 'maxlength' => 11)) ?>
     </td>
    
    </tr>  
    </tr>

   
  </tbody>
</table>

<div class="encuesta_grupo">
  <?php echo _('Referencias Bancarias (Debe Incluir al Menos una Referencia Bancaria)') ?>
</div>
<table class="encuesta" border="0">
  <tbody>
    <tr>
        <th class="encuesta" ><?php echo _('Operador Financiero:') ?><font color="red"><strong>*</strong></font></th>
        <th class="encuesta" ><?php echo _('Número de Cuenta:') ?><font color="red"><strong>*</strong></font></th>
        <th class="encuesta"><?php echo _('Tipo de Cuenta:') ?><font color="red"><strong>*</strong></font></th>

    </tr>
    <tr>      
        <td class="encuesta">
        <?php echo $sf_request->hasError('gen_operador_financiero_id') ? "<div class='validate_error'>".$sf_request->getError('gen_operador_financiero_id')."</div><br />" : '' ?>
        <?php echo object_select_tag('gen_operador_financiero_id', 'getGenOperadorFinancieroId', array('related_class' => 'GenOperadorFinanciero', 'class' => 'encuesta_input_select', 'peer_method' => 'operadoresOrdenados', 'include_blank' => 'true')) ?>
        <?php //echo input_hidden_tag('ref_ban1', $solicitud_ref_bancarias->getId()) ?>
      </td>    
      <td class="encuesta" >
 <?php echo $sf_request->hasError('nro_cuenta') ? "<div class='validate_error'>".$sf_request->getError('nro_cuenta')."</div><br />" : '' ?>
        <?php echo input_tag('nro_cuenta','', array('class' => 'encuesta_input_txt2', 'maxlength' => $constantes["input_max_num_cuenta"])) ?>         
     </td>
     
      <td class="encuesta">
	<?php echo $sf_request->hasError('tipo_cuenta') ? "<div class='validate_error' id='tipo_cuenta'>".$sf_request->getError('tipo_cuenta')."</div><br>" : '' ?>			

				<?php $tipo_cuenta = array(
                                                 ''  => '',
						 'Ahorro'  => 'AHORRO' ,
						 'Corriente'  => 'CORRIENTE'//,
						//'V' => 'V',
						//'G' => 'G',
						//'E' => 'E'

                                        ); 
                                ?>

        <?php echo select_tag('tipo_cuenta', options_for_select($tipo_cuenta, $sf_params->get('tipo_cuenta')), array('class' => 'full'));
        ?>

        <?php echo $sf_request->hasError('tipo_cuenta') ? "<div class='validate_error' id='tipo_cuenta'>".$sf_request->getError('tipo_cuenta')."</div><br>" : '' ?>
        <?php //echo object_select_tag($usuario, 'getGenTipoEmpresaId', array ('related_class' => 'GenTipoEmpresa', 'class' => 'encuesta_input_select', 'include_blank' => 'true')) ?>
      </td>
    
      
    </tr>
        <tr>      
        <td class="encuesta">
        <?php echo $sf_request->hasError('gen_operador_financiero_id2') ? "<div class='validate_error'>".$sf_request->getError('gen_operador_financiero_id2')."</div><br />" : '' ?>
        <?php echo object_select_tag('gen_operador_financiero_id2', 'getGenOperadorFinancieroId2', array('related_class' => 'GenOperadorFinanciero', 'class' => 'encuesta_input_select', 'peer_method' => 'operadoresOrdenados', 'include_blank' => 'true')) ?>
              <?php //echo input_hidden_tag('ref_ban2', $solicitud_ref_bancarias2->getId()) ?>
      </td>    
      <td class="encuesta" >
      <?php echo $sf_request->hasError('nro_cuenta2') ? "<div class='validate_error'>".$sf_request->getError('nro_cuenta')."</div><br />" : '' ?>
        <?php echo input_tag('nro_cuenta2','', array('class' => 'encuesta_input_txt2', 'maxlength' => $constantes["input_max_num_cuenta"])) ?>         
     </td>
     
      <td class="encuesta">
	<?php echo $sf_request->hasError('tipo_cuenta2') ? "<div class='validate_error' id='tipo_cuenta2'>".$sf_request->getError('tipo_cuenta2')."</div><br>" : '' ?>			

				<?php $tipo_cuenta2 = array(
                                                   ''  => '',
						 'Ahorro'  => 'AHORRO' ,
						 'Corriente'  => 'CORRIENTE'//,
						//'V' => 'V',
						//'G' => 'G',
						//'E' => 'E'

                                        ); 
                                ?>

        <?php echo select_tag('tipo_cuenta2', options_for_select($tipo_cuenta2, $sf_params->get('tipo_cuenta2')), array('class' => 'full'));
        ?>

        <?php echo $sf_request->hasError('tipo_cuenta2') ? "<div class='validate_error' id='tipo_cuenta2'>".$sf_request->getError('tipo_cuenta2')."</div><br>" : '' ?>
        <?php //echo object_select_tag($usuario, 'getGenTipoEmpresaId', array ('related_class' => 'GenTipoEmpresa', 'class' => 'encuesta_input_select', 'include_blank' => 'true')) ?>
      </td>
    
      
    </tr>

   
  </tbody>
</table>



<?php /* controles */ ?>
<div id="ctl2" class="controles">
  <table class="controls">
    <tbody>
      <tr>
        <td class="controls"><?php echo submit_tag(_('Guardar Cambios')) ?></td>
        <td class="controls"><?php echo link_to(image_tag('cancelar.png'), 'encuesta/editProductoCrediya') ?></td>
      </tr>
    </tbody>
  </table>
</div>

<div class="validate_error">
      <?php echo _('Los campos marcados con asterisco son obligatorios') ?>
</div>

</form>
