<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<?php 
$data_view['load_css'] = $load_css;
$this->load->view('template/head.php', $data_view); ?>
<?php
$this->load->view('template/header_admin.php');
?>
<section>
	<div id="container">
		<h3 class="text-center titulo"><?= $titulo ?></h3>
	</div>
	<div class="row contenedor-form caja-forms">
		<?php  if (isset($candidato)): ?>
			<div class="col-lg-12 col-md-12">
				<div id="foto-candidato">
					<div class="profile-header-container">   
						<div class="profile-header-img">
							<?= img($candidato->TEX_FOTO, '', ['class' => 'img-responsive img-circle']) ?>
							<!-- badge -->
							<div class="rank-label-container">
								<span class="label label-default rank-label"><?= $candidato->TEX_NOMCAN . ' ' . $candidato->TEX_APECAN ?></span>
							</div>
						</div>
					</div> 
				</div>
			</div>
		<?php endif; ?>

		<?php
		$form_data         = ['name'       => 'crear_form',
		'id'         => 'crear-form',
		'class'      => 'create-form',
		'novalidate' => '',
	];
	$attributes_labels = ['class' => 'control-label'];
	?>
	<?php echo form_open_multipart(base_url('candidatos/create'), $form_data); ?>
	<?php if (isset($candidato)): ?>
		<?= form_hidden('edit', 1) ?>
		<?= form_hidden('ID_CANDID', $candidato->ID_CANDID) ?>
	<?php endif; ?>
	<div class="col-lg-4 col-md-4">
		<div class="form-group input-type"> 
			<?php echo form_label('Número de Orden Tarjetón', 'NUM_ORDEN', $attributes_labels); ?>
			<div class="input-group">
				<div class="input-group-addon">
					<i class="fa fa-navicon"></i>
				</div>
				<?=
				form_input(['name'     => 'NUM_ORDEN',
					'id'       => 'NUM_ORDEN', 'class'    => 'form-control', 'type'     => 'number',
					'required' => '', 'value'    => (isset($candidato->NUM_ORDEN)) ? $candidato->NUM_ORDEN : ''])
					?>  
					<div class="input-group-addon">
						<a href="#" id="btn-numeros-orden" data-toggle="modal" data-target="#modal-lista-numeros-orden" title="Listado de los numeros disponibles">Ver Asignados</a>
					</div> 
				</div>
			</div> 
			<div class="form-group input-type"> 
				<?php echo form_label('Nombre Candidato', 'TEX_NOMCAN', $attributes_labels); ?>
				<div class="input-group">
					<div class="input-group-addon">
						<i class="fa fa-user"></i>
					</div>
					<?=
					form_input(['name'     => 'TEX_NOMCAN',
						'id'       => 'TEX_NOMCAN', 'class'    => 'form-control uppercase', 'onkeyup'  => 'uppercase(this.id);',
						'required' => '', 'value'    => (isset($candidato->TEX_NOMCAN)) ? $candidato->TEX_NOMCAN : ''])
						?>   
					</div>
				</div>

				<?php if ($this->session->userdata['settings']->BOL_VALLIS): ?>
					<div class="form-group input-type" style="width: 100%;"> 
						<?php echo form_label('Seleccione la Lista', 'ID_LISTA', $attributes_labels); ?>
						<div class="input-group" style="width: 100%;">
							<div class="input-group-addon">
								<i class="fa fa-list"></i>
							</div>
							<select name="ID_LISTA"  id="ID_LISTA" class="form-control">
								<option value=" ">Seleccione</option>
								<?php foreach ($listas as $list): ?>
									<option style="font-weight: bold;" value="<?= $list->ID_LISTA ?>"
										<?= ($list->ID_LISTA === @$candidato->ID_LISTA) ? 'selected' : '' ?>>
										<?= $list->TEX_NOMLIS ?></option>
									<?php endforeach; ?>
								</select> 
							</div>
						</div>
					<?php endif; ?>
				</div>
				<div class="col-lg-4 col-md-4">

					<div class="form-group input-type" style="width: 100%;"> 
						<?php echo form_label('Seleccione la Instancia', 'ID_INSTAN', $attributes_labels); ?>
						<div class="input-group" style="width: 100%;">
							<div class="input-group-addon">
								<i class="fa fa-building"></i>
							</div>
							<select name="ID_INSTAN"  id="ID_INSTAN" class="form-control" required="">
								<option value=" ">Seleccione</option>
								<?php foreach ($instancia as $instan): ?>
									<option style="font-weight: bold;" value="<?= $instan->ID_INSTAN ?>"
										<?= ($instan->ID_INSTAN === @$candidato->ID_INSTAN) ? 'selected' : '' ?>>
										<?= $instan->TEX_NOMINS ?></option>
									<?php endforeach; ?>
								</select> 
							</div>
						</div>

						<div class="form-group input-type"> 
							<?php echo form_label('Apellidos Candidato', 'TEX_APECAN', $attributes_labels); ?>
							<div class="input-group">
								<div class="input-group-addon">
									<i class="fa fa-user"></i>
								</div>
								<?=
								form_input(['name'    => 'TEX_APECAN',
									'id'      => 'TEX_APECAN', 'class'   => 'form-control uppercase',
									'onkeyup' => 'uppercase(this.id);',
									'value'   => (isset($candidato->TEX_APECAN)) ? $candidato->TEX_APECAN : ''])
									?>   
								</div>
							</div>
							

							<div class="form-group input-type" style="width: 100%;"> 
								<?php echo form_label('Seleccione la Ciudad', 'COD_CIUDAD', $attributes_labels); ?>
								<div class="input-group" style="width: 100%;">
									<select name="COD_CIUDAD"  id="COD_CIUDAD" class="form-control">
										<option value=" ">Seleccione</option>
										<?php foreach ($ciudades as $ciudad): ?>
											<option style="font-weight: bold;"
											value="<?= $ciudad->COD_CIUDAD ?>"
											<?= ($ciudad->COD_CIUDAD === @$candidato->COD_CIUDAD) ? 'selected' : '' ?>>
											<?= $ciudad->TEX_NOMCIU ?></option>
										<?php endforeach; ?>
									</select> 
								</div>
							</div>

						</div>
						<div class="col-lg-4 col-md-4">
							<div class="form-group input-type"> 
								<?php echo form_label('Texto perfil candidato', 'TEX_PERCAN', $attributes_labels); ?>
								<div class="input-group">
									<div class="input-group-addon">
										<i class="fa fa-book"></i>
									</div>
									<?=
									form_input(['name'     => 'TEX_PERCAN',
										'id'       => 'TEX_PERCAN', 'class'    => 'form-control',
										'value'    => (isset($candidato->TEX_PERCAN)) ? $candidato->TEX_PERCAN : ''])
										?>   
									</div>
								</div>
								<div class="form-group input-type"> 
									<?php echo form_label('Fotografía', 'TEX_FOTO', $attributes_labels); ?>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-image"></i>
										</div>
										<input type="hidden" name="TEX_FOTO"id="TEX_FOTO">
										<?=
										form_upload([
											'name'                                          => 'upload_foto',
											'id'                                            => 'upload_foto', 'class'                                         => 'form-control',
											(isset($candidato->TEX_FOTO)) ? '' : 'required' => '', 'value'                                         => (isset($candidato->TEX_FOTO)) ? $candidato->TEX_FOTO : ''])
											?>   
										</div>
									</div>

									<div class="form-group input-type" style="width: 100%;"> 
										<?php echo form_label('Seleccione la '.$this->session->userdata('NOMBRE_SEGMENTO'), 'COD_AGENCIA', $attributes_labels); ?>
										<div class="input-group" style="width: 100%;">
											<div class="input-group-addon">
												<i class="fa fa-map-marker"></i>
											</div>
											<select name="COD_AGENCIA"  id="COD_AGENCIA" class="form-control" required="">
												<option value=" ">Seleccione</option>
												<?php foreach ($agencias as $agen): ?>
													<option style="font-weight: bold;" value="<?= $agen->COD_AGENCIA ?>"
														<?= ($agen->COD_AGENCIA === @$candidato->COD_AGENCIA) ? 'selected' : '' ?>>
														<?= $agen->TEX_NOMAGE ?></option>
													<?php endforeach; ?>
												</select> 
											</div>
										</div>

            <!--            <div class="form-group input-type"> 
            <?php //echo form_label('Ciudad', 'TEX_CIUDAD', $attributes_labels); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-map-marker"></i>
                                </div>
                                <input type="hidden" name="COD_CIUDAD"id="COD_CIUDAD" 
                                       value="<?php // (isset($candidato->COD_CIUDAD)) ? $candidato->COD_CIUDAD : ''            ?>">
            <?php
             //form_input(['name'     => 'TEX_CIUDAD',
             //'id'       => 'TEX_CIUDAD', 'class'    => 'form-control',
             //'required' => '', 'value'    => (isset($candidato->TEX_NOMCIU)) ? $candidato->TEX_NOMCIU : '', 'style'    => 'width:200px;'])
            ?>  
                            </div>
                         </div> -->
                      </div>
                      <div class="col-lg-12 col-md-12">
                      	<div class="form-group input-type"> 
                      		<?= form_label('Observaciones', 'TEX_OBSERVACION', $attributes_labels); ?>
                      		<div class="input-group">
                      			<div class="input-group-addon">
                      				<i class="fa fa-calendar"></i>
                      			</div>
                      			<?=
                      			form_textarea(['name'  => 'TEX_OBSERVACION',
                      				'id'    => 'TEX_OBSERVACION', 'class' => 'form-control', 'rows'  => 3,
                      				'value' => (isset($empresa->TEX_OBSERVACION)) ? $empresa->TEX_OBSERVACION : ''])
                      				?>   
                      			</div>
                      		</div> 
                      	</div>
                      	<div class="boton-submit">
                      		<div class="input-group">
                      			<a href="<?php echo base_url($route) ?>" class="btn btn-danger" style="margin-right: 10px;">Regresar</a>
                      			<input type="submit" value="Guardar" class="btn btn-default"> 
                      		</div>  
                      	</div>
                      </div>
                      <?php echo form_close(); ?>
                   </section>
                   <div class="modal fade" id="modal-lista-numeros-orden" tabindex="-1" role="dialog" style="top:10%" aria-labelledby="myModalLabel">
                   	<div class="modal-dialog modal-lg" role="document">
                   		<div class="modal-content">
                   			<div class="modal-body">
                   				<h3 class="text-center text-success">Listado de numeros asignados</h3>
                   				<div id="contenedor-numeros">

                   					<?php if(isset($por_listas)): ?>
                   						<?php if(isset($numeros_orden)): ?>
                   							<?php foreach ($numeros_orden as $key => $lista): ?>
                   								<div id="contenedor-lista" style="border: 1px solid #fc873a; margin:3px;padding: 4px;">
                   									<div class="titulo-lista"><?= $lista['nombre_lista']?></div>
                   									<?php foreach ($lista['numeros'] as $key => $numero): ?>
                   										<div class="numero"><?= $numero->NUM_ORDEN ?></div>
                   									<?php endforeach ?>
                   							</div>
                   								<?php endforeach ?>
                   						<?php endif; ?>
                   					<?php else: ?>
                   						<?php if(isset($numeros_orden)): ?>
                   							<?php foreach ($numeros_orden as $key => $numero_orden): ?>
                   								<div class="numero"><?= $numero_orden->NUM_ORDEN ?></div>
                   							<?php endforeach ?>
                   						<?php endif; ?>
                   					<?php endif; ?>
                   				</div>	
                   			</div>
                   			<div class="modal-footer">
                   				<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                   			</div>
                   		</div>
                   	</div>
                   </div>
                   <?php
                   $data_view['loajs'] = $load_js;
                   $this->load->view('template/footer.php', $data_view);
                   ?>