<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php $this->load->view('template/head.php'); ?>
<?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
		$form_data         = [
			'name'       => 'crear_form',
			'id'         => 'crear-form',
			'class'      => 'crear-form',
			'novalidate' => '',
		];
		$attributes_labels = ['class' => 'control-label'];
		?>
		<?php echo form_open_multipart(base_url('configuracion/create'), $form_data); ?>
		<?php if (isset($configuracion)): ?>
			<?= form_hidden('edit', 1) ?>
			<?= form_hidden('ID_GENERAL', $configuracion->ID_GENERAL) ?>
		<?php endif; ?>
		<div class="col-lg-4 col-md-4">
			<div class="form-group input-type" style="width: 100%;">
				<?php echo form_label('Tipo de Ingreso', 'NUM_VALING', $attributes_labels); ?>
				<div class="input-group" style="width: 100%;">
					<div class="input-group-addon">
						<i class="fa fa-sign-in"></i>
					</div>
					<select name="NUM_VALING"  id="NUM_VALING" class="form-control" onchange="ingresoPin(this.id, this.value)" required="required">
						<option value=" ">Seleccione</option>
						<option value="W" <?= (@$configuracion->NUM_VALING === 'W') ? 'selected' : '' ?>>Identificación y Clave</option>
						<option value="I" <?= (@$configuracion->NUM_VALING === 'I') ? 'selected' : '' ?>>Solo Identificación</option>
						<option value="P" <?= (@$configuracion->NUM_VALING === 'P') ? 'selected' : '' ?>>Código PIN</option>
					</select>
				</div>
			</div>


			<div class="form-group input-type" style="width: 100%;">
				<?php echo form_label('Tipo de Segmentación', 'TEX_SEGMEN', $attributes_labels); ?>
				<div class="input-group" style="width: 100%;">
					<div class="input-group-addon">
						<i class="fa fa-sign-in"></i>
					</div>
					<select name="TEX_SEGMEN"  id="TEX_SEGMEN" class="form-control" required="required">
						<option value=" ">Seleccione</option>
						<option value="N" <?= (@$configuracion->TEX_SEGMEN === 'N') ? 'selected' : '' ?>>Ninguna</option>
						<option value="A" <?= (@$configuracion->TEX_SEGMEN === 'A') ? 'selected' : '' ?>>Por Agencia</option>
						<option value="C" <?= (@$configuracion->TEX_SEGMEN === 'C') ? 'selected' : '' ?>>Por Ciudad</option>
					</select>
				</div>
			</div>

			<div class="form-group input-type"> 
				<label for="BOL_VALLIS" class="control-label input-group">Tipo de Votación</label>
				<div id="grupo-BOL_VALLIS" class="btn-group" data-toggle="buttons">
					<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALLIS) ? 'active' : '' ?>" data-toggle="button">
						<?= form_radio('BOL_VALLIS', '1', (@$configuracion->BOL_VALLIS) ? true : '') ?>Con Listas
					</label>
					<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALLIS) ? '' : 'active' ?>" data-toggle="button">
						<?= form_radio('BOL_VALLIS', '0', (@$configuracion->BOL_VALLIS) ? '' : true) ?>Sin Listas
					</label>
				</div>
			</div>

			<div class="form-group input-type grupo-num-candit" <?= (@$configuracion->BOL_VALLIS) ? 'style="display:none;"' : '' ?>>
				<?php echo form_label('Número de candidatos por fila (Entre 3 y 8)', 'NUM_CANFIL', $attributes_labels); ?>
				<div class="input-group">
					<div class="input-group-addon">
						<i class="fa fa-cog"></i>
					</div>
					<?=
					form_input([
						'name'              => 'NUM_CANFIL',
						'id'                => 'NUM_CANFIL', 'class'             => 'form-control',
						'number'            => 'number',
						'min'     => 0,
						'data-parsley-type' => 'integer',
						'data-parsley-min'  => '3',
						'data-parsley-max'  => '8',
						'required'          => '',
						'value'             => (isset($configuracion->NUM_CANFIL)) ? $configuracion->NUM_CANFIL : ''])
						?>
					</div>
				</div>

				<div class="form-group input-type grupo-num-listas"  <?= (@$configuracion->BOL_VALLIS) ? '' : 'style="display:none;"' ?>>
					<?php echo form_label('Número de listas por fila', 'NUM_LISFIL', $attributes_labels); ?>
					<div class="input-group">
						<div class="input-group-addon">
							<i class="fa fa-cog"></i>
						</div>
						<?=
						form_input([
							'name'     => 'NUM_LISFIL',
							'id'       => 'NUM_LISFIL',
							'class'    => 'form-control',
							'number'   => 'number',
							'min'     => 0,
							'required' => '',
							'value'    => (isset($configuracion->NUM_LISFIL)) ? $configuracion->NUM_LISFIL : ''])
							?>
						</div>
					</div>


					<div class="form-group input-type grupo-num-intentos"  <?= (@$configuracion->NUM_INLOGIN) ? '' : 'style="display:none;"' ?> <?= ($configuracion->NUM_VALING == 'W')?'':'style="display:none;"' ?>>
						<?php echo form_label('Número de intentos de login permitidos', 'NUM_INLOGIN', $attributes_labels); ?>
						<div class="input-group">
							<div class="input-group-addon">
								<i class="fa fa-user"></i>
							</div>
							<?=
							form_input([
								'name'     => 'NUM_INLOGIN',
								'id'       => 'NUM_INLOGIN',
								'class'    => 'form-control',
								'number'   => 'number',
                        'min'     => 0,
								'required' => '',
								'' => ($configuracion->NUM_VALING === 'W') ? '' : 'disabled',
								'value'    => (isset($configuracion->NUM_INLOGIN)) ? $configuracion->NUM_INLOGIN : ''])	
								?>
							</div>
						</div>


						<div class="form-group input-type">
							<?php echo form_label('Tiempo para el proceso de votación (En minutos, 0 es infinito)', 'NUM_TEMPO', $attributes_labels); ?>
							<div class="input-group">
								<div class="input-group-addon">
									<i class="fa fa-download"></i>
								</div>
								<?=
								form_input([
									'name'  => 'NUM_TEMPO',
									'id'    => 'NUM_TEMPO',
									'class' => 'form-control',
									'value' => (isset($configuracion->NUM_TEMPO)) ? $configuracion->NUM_TEMPO : '0',
								])
								?>
							</div>
						</div>

						<div class="form-group input-type">
							<?php echo form_label('Nombre segmentación flexible', 'TEX_NOMSEG', $attributes_labels); ?>
							<div class="input-group">
								<div class="input-group-addon">
									<i class="fa fa-home"></i>
								</div>
								<?=
								form_input([
									'name'  => 'TEX_NOMSEG',
									'id'    => 'TEX_NOMSEG',
									'class' => 'form-control',
									'value' => (isset($configuracion->TEX_NOMSEG)) ? $configuracion->TEX_NOMSEG : '0',
								])
								?>
							</div>
						</div>

						<div class="form-group input-type"> 
							<label for="BOL_ACTIINFORVOT" class="control-label input-group">Activar para ocultar informes de escrutiño
							</label>
							<div class="btn-group" data-toggle="buttons">
								<label class="switch btn btn-primary <?= (@$configuracion->BOL_ACTIINFORVOT) ? 'active' : '' ?>" data-toggle="button">
									<?= form_radio('BOL_ACTIINFORVOT', '1', (@$configuracion->BOL_ACTIINFORVOT) ? true : '') ?>Si
								</label>
								<label class="switch btn btn-primary <?= (@$configuracion->BOL_ACTIINFORVOT) ? '' : 'active' ?>" data-toggle="button">
									<?= form_radio('BOL_ACTIINFORVOT', '0', (@$configuracion->BOL_ACTIINFORVOT) ? '' : true) ?>No
								</label>
							</div>
						</div>

						<div class="form-group input-type"> 
							<label for="BOL_ACTIVAIMPREVOT" class="control-label input-group">Activar impresión en el proceso de votación
							</label>
							<div class="btn-group" data-toggle="buttons">
								<label class="switch btn btn-primary <?= (@$configuracion->BOL_ACTIVAIMPREVOT) ? 'active' : '' ?>" data-toggle="button">
									<?= form_radio('BOL_ACTIVAIMPREVOT', '1', (@$configuracion->BOL_ACTIVAIMPREVOT) ? true : '') ?>Si
								</label>
								<label class="switch btn btn-primary <?= (@$configuracion->BOL_ACTIVAIMPREVOT) ? '' : 'active' ?>" data-toggle="button">
									<?= form_radio('BOL_ACTIVAIMPREVOT', '0', (@$configuracion->BOL_ACTIVAIMPREVOT) ? '' : true) ?>No
								</label>
							</div>
						</div>

					</div>



					<div class="col-lg-4 col-md-4 grupo-mail" <?= (@$configuracion->BOL_VALMAI) ? 'style="display:block"' : 'style=display:none' ?>>
						<div class="form-group input-type">
							<?php echo form_label('Nombre o IP SMTP', 'TEX_SMTP', $attributes_labels); ?>
							<div class="input-group">
								<div class="input-group-addon">
									<i class="fa fa-home"></i>
								</div>
								<?=
								form_input([
									'name'                                          => 'TEX_SMTP',
									'id'                                            => 'TEX_SMTP', 'class'                                         => 'form-control',
									'value'                                         => (isset($configuracion->TEX_SMTP)) ? $configuracion->TEX_SMTP : '',
									(@$configuracion->BOL_VALMAI) ? '' : 'disabled' => (@$configuracion->BOL_VALMAI) ? '' : 'disabled'])
									?>
								</div>
							</div>
							<div class="form-group input-type">
								<?= form_label('Número de puerto', 'TEX_PORT', $attributes_labels); ?>
								<div class="input-group">
									<div class="input-group-addon">
										<i class="fa fa-home"></i>
									</div>
									<?=
									form_input([
										'name'                                          => 'TEX_PORT', 'onkeyup'                                       => 'uppercase(this.id);',
										'id'                                            => 'TEX_PORT', 'class'                                         => 'form-control uppercase',
										'value'                                         => (isset($configuracion->TEX_PORT)) ? $configuracion->TEX_PORT : '',
										(@$configuracion->BOL_VALMAI) ? '' : 'disabled' => (@$configuracion->BOL_VALMAI) ? '' : 'disabled'])
										?>
									</div>
								</div>
								<div class="form-group input-type">
									<?php echo form_label('Nombre correo utilizado como remitente', 'TEX_MAINOM', $attributes_labels); ?>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-inbox"></i>
										</div>
										<?=
										form_input([
											'name'                                          => 'TEX_MAINOM',
											'id'                                            => 'TEX_MAINOM',
											'data-parsley-type'                             => 'email',
											'class'                                         => 'form-control',
											'value'                                         => (isset($configuracion->TEX_MAINOM)) ? $configuracion->TEX_MAINOM : '',
											(@$configuracion->BOL_VALMAI) ? '' : 'disabled' => (@$configuracion->BOL_VALMAI) ? '' : 'disabled'
										])
										?>
									</div>
								</div>
								<div class="form-group input-type">
									<?php echo form_label('Clave MAIL', 'TEX_MAICLA', $attributes_labels); ?>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-key"></i>
										</div>
										<?=
										form_password(['name'                                          => 'TEX_MAICLA',
											'id'                                            => 'TEX_MAICLA', 'class'                                         => 'form-control',
											'value'                                         => '',
											(@$configuracion->BOL_VALMAI) ? '' : 'disabled' => (@$configuracion->BOL_VALMAI) ? '' : 'disabled'
										]);
										?>
									</div>
								</div>
								<div class="form-group input-type">
									<?php echo form_label('Confirmación Clave MAIL', 'RE_TEX_MAICLA', $attributes_labels); ?>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-key"></i>
										</div>
										<?=
										form_password(['name'                                          => 'RE_TEX_MAICLA',
											'id'                                            => 'RE_TEX_MAICLA', 'class'                                         => 'form-control',
											'value'                                         => '',
											(@$configuracion->BOL_VALMAI) ? '' : 'disabled' => (@$configuracion->BOL_VALMAI) ? '' : 'disabled'
										]);
										?>
									</div>
								</div>
							</div>
							<div class="col-lg-4 col-md-4">
								<?php $disabled_pin       = (@$configuracion->NUM_VALING === 'P') ? '' : 'disabled' ?>
								<div class="form-group input-type form-group-genera-pin" style="display: <?= (@$configuracion->NUM_VALING === 'P') ? 'block' : 'none' ?>"> 
									<label for="BOL_VALPIN" class="control-label input-group">Generar PIN</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALPIN) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_VALPIN', '1', (@$configuracion->BOL_VALPIN) ? true : '', "$disabled_pin class='grupo-pin'") ?>Si
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALPIN) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_VALPIN', '0', (@$configuracion->BOL_VALPIN) ? '' : true, "$disabled_pin class='grupo-pin'") ?>No
										</label>
									</div>
								</div>
								<div class="form-group input-type form-group-envia-pin" style="display: <?= (@$configuracion->NUM_VALING === 'P') ? 'block' : 'none' ?>"> 
									<label for="BOL_VALSMS" class="control-label input-group">Enviar PIN por SMS</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALSMS) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_VALSMS', '1', (@$configuracion->BOL_VALSMS) ? true : '', "$disabled_pin class='grupo-pin'") ?>Si
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALSMS) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_VALSMS', '0', (@$configuracion->BOL_VALSMS) ? '' : true, "$disabled_pin class='grupo-pin'") ?>No
										</label>
									</div>
								</div>
								<div class="form-group input-type"> 
									<label for="BOL_VALMAI" class="control-label input-group">Enviar Confirmación de voto por EMAIL</label>
									<div id="grupo-BOL_VALMAI" class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALMAI) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_VALMAI', '1', (@$configuracion->BOL_VALMAI) ? true : '', 'class="BOL_VALMAI_GP"') ?>Si
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_VALMAI) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_VALMAI', '0', (@$configuracion->BOL_VALMAI) ? '' : true, 'class="BOL_VALMAI_GP"') ?>No
										</label>
									</div>
								</div>
							<!-- 	<div class="form-group input-type"> 
									<label for="BOL_VOTBLA" class="control-label input-group">Activar voto en blanco</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?php // (@$configuracion->BOL_VOTBLA) ? 'active' : '' ?>" data-toggle="button">
											<?php // form_radio('BOL_VOTBLA', '1', (@$configuracion->BOL_VOTBLA) ? true : '') ?>Si
										</label>
										<label class="switch btn btn-primary <?php //(@$configuracion->BOL_VOTBLA) ? '' : 'active' ?>" data-toggle="button">
											<?php // form_radio('BOL_VOTBLA', '0', (@$configuracion->BOL_VOTBLA) ? '' : true) ?>No
										</label>
									</div>
								</div> -->
								<div class="form-group input-type"> 
									<label for="BOL_REGIST" class="control-label input-group">El proceso de votación es con registro previo</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_REGIST) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_REGIST', '1', (@$configuracion->BOL_REGIST) ? true : '') ?>Si
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_REGIST) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_REGIST', '0', (@$configuracion->BOL_REGIST) ? '' : true) ?>No
										</label>
									</div>
								</div>


								<div class="form-group input-type"> 
									<label for="BOL_ACTRECCON" class="control-label input-group">Activar opción recordar contraseña en el inicio de sesión
									</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_ACTRECCON) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_ACTRECCON', '1', (@$configuracion->BOL_ACTRECCON) ? true : '') ?>Si
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_ACTRECCON) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_ACTRECCON', '0', (@$configuracion->BOL_ACTRECCON) ? '' : true) ?>No
										</label>
									</div>
								</div>

								<div class="form-group input-type"> 
									<label for="BOL_BUSTAR" class="control-label input-group">Activar buscador de candidatos/listas
									</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_BUSTAR) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_BUSTAR', '1', (@$configuracion->BOL_BUSTAR) ? true : '') ?>Si
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_BUSTAR) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_BUSTAR', '0', (@$configuracion->BOL_BUSTAR) ? '' : true) ?>No
										</label>
									</div>
								</div>

								<div class="form-group input-type"> 
									<label for="BOL_GENMASESP" class="control-label input-group">Activar generación masiva escarapelas
									</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_GENMASESP) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_GENMASESP', '1', (@$configuracion->BOL_GENMASESP) ? true : '') ?>Si
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_GENMASESP) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_GENMASESP', '0', (@$configuracion->BOL_GENMASESP) ? '' : true) ?>No
										</label>
									</div>
								</div>

								<div class="form-group input-type"> 
									<label for="BOL_TIPPW" class="control-label input-group">Tipo de contraseña a generar (por el sistema)
									</label>
									<div class="btn-group" data-toggle="buttons">
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_TIPPW) ? 'active' : '' ?>" data-toggle="button">
											<?= form_radio('BOL_TIPPW', '1', (@$configuracion->BOL_TIPPW) ? true : '') ?>Alfanumérica
										</label>
										<label class="switch btn btn-primary <?= (@$configuracion->BOL_TIPPW) ? '' : 'active' ?>" data-toggle="button">
											<?= form_radio('BOL_TIPPW', '0', (@$configuracion->BOL_TIPPW) ? '' : true) ?>Numérica
										</label>
									</div>
								</div>

								<div class="form-group input-type">
									<?php echo form_label('Tamaño de la contraseña (generada por el sistema)', 'NUM_LONGPW', $attributes_labels); ?>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-cog"></i>
										</div>
										<?=
										form_input([
											'name'     => 'NUM_LONGPW',
											'id'       => 'NUM_LONGPW',
											'class'    => 'form-control',
											'number'   => 'number',
'min'     => 0,
											'value'    => (isset($configuracion->NUM_LONGPW)) ? $configuracion->NUM_LONGPW : ''])
											?>
										</div>
									</div>




								</div>
								<div class="col-lg-12 col-md-12">
									<div class="form-group input-type">
										<?php echo form_label('Observaciones', 'TEX_OBSERVACION', $attributes_labels); ?>
										<div class="input-group">
											<div class="input-group-addon">
												<i class="fa fa-terminal"></i>
											</div>
											<?=
											form_textarea(['name'  => 'TEX_OBSERVACION',
												'id'    => 'TEX_OBSERVACION', 'class' => 'form-control', 'rows'  => 4,
												'value' => (isset($configuracion->TEX_OBSERVACION)) ? $configuracion->TEX_OBSERVACION : '',
											]);
											?>
										</div>
									</div>
								</div>
								<div class="col-lg-12 col-md-12">
									<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" id="btn-save-config"> 
										</div>  
									</div>
								</div>
							</div>

							<?php echo form_close(); ?>
						</section>
						<?php
						$data_view['loajs'] = $load_js;
						$this->load->view('template/footer.php', $data_view);
						?>