<?php
defined('BASEPATH') OR exit('No direct script access allowed');

?>

<div class="content-wrapper">
	<section class="content-header">
		<?php echo $pagetitle; ?>
		<?php echo $breadcrumb; ?>
	</section>
	<section class="content">
		<div class="row">
			<div class="filterable">
				 <div class="col-md-12">
					<div class="box">
						<div class="box-body">
								<?php echo form_open(current_url(), array('class' => 'form-horizontal', 'id' => 'form-ordenar')); ?>
                            	<div class="form-group">
	                                <div class="col-sm-2">
	                                <label for="expe_id_dependencia">Colonia a visualizar</label>
	                                    <?php  
	                                        $attribute = 'class="selectpicker show-tick form-control" title="Seleccione la colonia" disabled'; 
	                                        echo form_dropdown('colonia_busq', $dptodistritocolonia, '',$attribute); ?>
	                                </div>
	                                <div class="col-sm-2 pull-right">
	                                
	                                    <h3 class="box-title">
                                
			                                <?php echo anchor(
			                                    'cuest/reg01/create', 
			                                    '<i class="fa fa-plus"></i> '. 'Crear registro', 
			                                    array('class' => 'btn btn-block btn-primary btn-flat')
			                                );?>

			                            </h3>
	                                </div>
                            	</div>
                            	<hr>
                            	<?php if (isset($message)): ?>
                            		<pre>
                            			<?php echo $message ?>
                            		</pre>
                            	<?php endif ?>
                            	<div style="background-color: #e8f2fb; width: 85%" class="form-group">
                            		<label class="checkbox-inline"><h5><b>
							    	  Ordenar por:</b></h5>
							    	</label>
                            		<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_dpto'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_dpto" id="dpto" value="dpto">				<?php echo lang(	'control_dpto'	    		);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_distrito'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_distrito" value="distrito">					<?php echo lang(	'control_distrito'	    	);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_colonia'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_colonia" value="colonia">					<?php echo lang(	'control_colonia'	    	);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_manzana'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_manzana" value="manzana">					<?php echo lang(	'control_manzana'	    	);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_lote_a'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_lote_a" value="lote_a">						<?php echo lang(	'control_lote_a'			);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_lote_b'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_lote_b" value="lote_b">						<?php echo lang(	'control_lote_b'			);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_cuest'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_cuest" value="cuest">						<?php echo lang(	'control_cuest'				);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_situacion_lote'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_situacion_lote" value="situacion_lote">		<?php echo lang(	'control_situacion_lote'	);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_condicion_lote'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_condicion_lote" value="condicion_lote">		<?php echo lang(	'control_condicion_lote'	);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_ocupante_actual'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_ocupante_actual" value="ocupante_actual">	<?php echo lang(	'control_ocupante_actual'	);?>
							    	</label>
							    	<label class="checkbox-inline">
							    	  <input type="checkbox" <?php if (isset($_SESSION['ordenar']['ck_nombre_proceso'])) {echo 'checked';} ?> onclick="ordenar()" name="ck_nombre_proceso" value="nombre_proceso">		<?php echo lang(	'control_nombre_proceso'	);?>
							    	</label>
							    	<label class="checkbox-inline"><h5><b>
							    	  Orden:</b></h5>
							    	</label>
							    	<label class="radio-inline">
							    		<input type="radio" <?php if (isset($_SESSION['orden'])) {if ($_SESSION['orden'] == 'ASC') {echo 'checked';}else{echo '';}} ?> onclick="ordenar()" name="ordinalidad" value="ASC">Ascendente
							    	</label>
									<label class="radio-inline">
										<input type="radio" <?php if (isset($_SESSION['orden'])) {if ($_SESSION['orden'] == 'DESC') {echo 'checked';}else{echo '';}} ?> onclick="ordenar()" name="ordinalidad" value="DESC">Descendente
									</label>
							    </div>
							    <hr>
                            	<?php echo form_close();?>

                            <table id="tabla_operador" class="table table-striped table-hover">
								<thead>
									<tr>
										<th><?php echo lang(	'control_dpto'	    			);?></th>
                                        <th><?php echo lang(	'control_distrito' 				);?></th>
                                        <th><?php echo lang(	'control_colonia'				);?></th>
                                        <th><?php echo lang(	'control_colonia_desc'			);?></th>
                                        <th><?php echo lang(	'control_manzana'				);?></th>
                                        <th><?php echo lang(	'control_lote_a'				);?></th>
                                        <th><?php echo lang(	'control_lote_b'				);?></th>
										<th><?php echo lang(	'control_cuest'					);?></th>
                                        <th><?php echo lang(	'control_situacion_lote'		);?></th>
                                        <th><?php echo lang(	'control_condicion_lote'		);?></th>
                                        <th><?php echo lang(	'control_ocupante_actual'		);?></th>
                                        <th><?php echo lang(	'control_cultivo'				);?></th>
                                        <th><?php echo lang(	'control_produccion_ganadera'	);?></th>
                                        <th><?php echo lang(	'control_asistencia_crediticia'	);?></th>
                                        <th><?php echo lang(	'control_asistencia_tecnica'	);?></th>
                                        <th><?php echo lang(	'control_organizacion'			);?></th>
                                        <th><?php echo lang(	'control_nombre_proceso'		);?></th>
                                        <th></th>
                                        <th></th>
                                        <th></th>
                                        <th></th>
									</tr>
									<tr>
									<?php echo form_open('monitoreo/panel_control/panel_control/busqueda_control_operador', array('class' => 'form-horizontal', 'id' => 'form-buscar')); ?>
										<th><input id="dpto" name="dpto" type="text" class="form-control" 
										placeholder="<?php echo lang('control_dpto');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['dpto'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['dpto'];
													 }else{
														echo '';
													 } ?>"
										enable autofocus></th>

										<th><input id="distrito" name="distrito" type="text" class="form-control" 
										placeholder="<?php echo lang('control_distrito');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['distrito'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['distrito'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="colonia" name="colonia" type="text" class="form-control" 
										placeholder="<?php echo lang('control_colonia');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['colonia'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['colonia'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="colonia_desc" name="colonia_desc" type="text" class="form-control" 
										placeholder="<?php echo lang('control_colonia_desc');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['colonia_desc'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['colonia_desc'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="manzana" name="manzana" type="text" class="form-control" 
										placeholder="<?php echo lang('control_manzana');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['manzana'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['manzana'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="lote_a" name="lote_a" type="text" class="form-control" 
										placeholder="<?php echo lang('control_lote_a');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['lote_a'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['lote_a'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="lote_b" name="lote_b" type="text" class="form-control" 
										placeholder="<?php echo lang('control_lote_b');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['lote_b'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['lote_b'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="cuest" name="cuest" type="text" class="form-control" 
										placeholder="<?php echo lang('control_cuest');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['cuest'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['cuest'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="situacion_lote" name="situacion_lote" type="text" class="form-control" 
										placeholder="<?php echo lang('control_situacion_lote');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['situacion_lote'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['situacion_lote'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="condicion_lote" name="condicion_lote" type="text" class="form-control" 
										placeholder="<?php echo lang('control_condicion_lote');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['condicion_lote'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['condicion_lote'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="ocupante_actual" name="ocupante_actual" type="text" class="form-control" 
										placeholder="<?php echo lang('control_ocupante_actual');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['ocupante_actual'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['ocupante_actual'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="cultivo" name="cultivo" type="text" class="form-control" 
										placeholder="<?php echo lang('control_cultivo');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['cultivo'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['cultivo'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="produccion_ganadera" name="produccion_ganadera" type="text" class="form-control" 
										placeholder="<?php echo lang('control_produccion_ganadera');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['produccion_ganadera'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['produccion_ganadera'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="asistencia_crediticia" name="asistencia_crediticia" type="text" class="form-control" 
										placeholder="<?php echo lang('control_asistencia_crediticia');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['asistencia_crediticia'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['asistencia_crediticia'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="asistencia_tecnica" name="asistencia_tecnica" type="text" class="form-control" 
										placeholder="<?php echo lang('control_asistencia_tecnica');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['asistencia_tecnica'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['asistencia_tecnica'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="organizacion" name="organizacion" type="text" class="form-control" 
										placeholder="<?php echo lang('control_organizacion');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['organizacion'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['organizacion'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="nombre_proceso" name="nombre_proceso" type="text" class="form-control" 
										placeholder="<?php echo lang('control_nombre_proceso');?>" 
										value="<?php if (isset($_SESSION['arraywhere_control_operador']['nombre_proceso'])) 
													 {	
														echo $_SESSION['arraywhere_control_operador']['nombre_proceso'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th colspan="2">
											<button type="submit" class="btn btn-info">
      											<span class="glyphicon glyphicon-search"></span> Buscar
    										</button>
    									</th>
    									<th></th>
                                        <th></th>
                                    <?php echo form_close();?>
									</tr>
								</thead>
								<tbody class="muestra_geocolonias">
									<?php foreach ($control_operador as $values):?>
										<tr>
										<?php 	if ($values->proceso == 'A02') {
													$bgcolor = '#F2F5A9';
												}elseif ($values->proceso == 'A03') {
													$bgcolor = '#A9BCF5';
												}elseif ($values->proceso == 'A04') {
													$bgcolor = '#81F781';
												}elseif ($values->proceso == 'A07') {
													$bgcolor = '#FA5858';
												}else{
													$bgcolor = 'white';
												}
										?>
											<td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->dpto, 					ENT_QUOTES, 'UTF-8'); ?></td>
		
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->distrito, 				ENT_QUOTES, 'UTF-8'); ?></td>
		
											<td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->colonia, 					ENT_QUOTES, 'UTF-8'); ?></td>	
											
											<td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->col_desc,					ENT_QUOTES, 'UTF-8'); ?></td>	
					
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->manzana, 					ENT_QUOTES, 'UTF-8'); ?></td>	
			
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->lote_a, 					ENT_QUOTES, 'UTF-8'); ?></td>																	
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->lote_b, 					ENT_QUOTES, 'UTF-8'); ?></td>	
			
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->cuest, 					ENT_QUOTES, 'UTF-8'); ?></td>	
	
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->situacion_lote, 			ENT_QUOTES, 'UTF-8'); ?></td>	
	
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->condicion_lote, 			ENT_QUOTES, 'UTF-8'); ?></td>	
                                            
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->ocupante_actual, 			ENT_QUOTES, 'UTF-8'); ?></td>	
	
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->cultivo, 					ENT_QUOTES, 'UTF-8'); ?></td>	
	
                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->produccion_ganadera, 		ENT_QUOTES, 'UTF-8'); ?></td>

                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->asistencia_crediticia, 	ENT_QUOTES, 'UTF-8'); ?></td>

                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->asistencia_tecnica, 		ENT_QUOTES, 'UTF-8'); ?></td>

                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->organizacion, 			ENT_QUOTES, 'UTF-8'); ?></td>

                                            <td bgcolor="<?php echo $bgcolor ?>"><?php echo htmlspecialchars($values->nombre_proceso, 			ENT_QUOTES, 'UTF-8'); ?></td>

											<!--<td bgcolor="<?php echo $bgcolor ?>">
												<?php echo anchor('cuest/reg01/vista_ident_geo/'.$values->id_registro_lote, '<i class="glyphicon glyphicon-eye-open btn btn-xs bg-blue color-palette"></i>'); ?>
											</td>-->
											<td bgcolor="<?php echo $bgcolor ?>">
												<?php echo anchor('cuest/reg01/vista_ident_geo/'.$values->id_registro_lote, '<i class="fa fa-pencil btn btn-sm bg-orange color-palette"></i>', array('title' => 'Editar Cuestionario')); ?>
											</td>
											<td bgcolor="<?php echo $bgcolor ?>">
												<?php echo anchor('monitoreo/panel_control/panel_control/terminar_operador/'.$values->id_registro_lote, '<i >TERMINAR</i>',array('class' => 'btn btn-primary btn-sm', 'title' => 'Terminar Cuestionario')); ?>
												
											</td>
											<td bgcolor="<?php echo $bgcolor ?>">
												<?php echo anchor('monitoreo/panel_control/panel_control/liberar_operador_indiv/'.$values->id_registro_lote, '<i>LIBERAR</i>', array('class' => 'btn btn-success btn-sm', 'title' => 'Liberar Cuestionario')); ?>
												
											</td>
										</tr>

									<?php endforeach;?>
								</tbody>
							</table>
							<hr>
								<div class="form-group">
									<div class="col-sm-2">
										<?php echo $pagination; ?>
									</div>
									<div class="col-sm-4 pull-right">
										<?php echo form_open(base_url().'monitoreo/panel_control/panel_control/liberar_operador', array('class' => 'form-horizontal', 'id' => 'form-liberar')); ?>
											<label for="dptodistritocolonia">Elegir manzana a liberar</label>
											<div>
												<div class="col-sm-10">
			                            			<?php $attribute = 'class="selectpicker show-tick form-control" title="Seleccione la manzana" name="dptodistritocoloniamz" id="dptodistritocoloniamz"';
				                                    echo form_dropdown('dptodistritocoloniamz', $dptodistritocoloniamz, '', $attribute);   ?>
			                                	</div>
			                                	<?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-primary btn-flat', 'content' => 'LIBERAR', 'id' => 'boton_liberar'));
												 ?>
											</div>
		                            <?php echo form_close();?>
									</div>
									<div class="col-sm-4 pull-right">
										<?php echo form_open(base_url().'monitoreo/panel_control/panel_control/generar_excel_poblacion', array('class' => 'form-horizontal', 'id' => 'form-generar_excel')); ?>
											<label for="dptodistritocolonia">Generar excel de Población</label>
											<div>
			                            		<div class="col-sm-8">
				                            		<?php $attribute = 'class="selectpicker show-tick form-control" title="Seleccione la colonia" name="dptodistritocolonia" enabled id="dptodistritocolonia"';
					                                echo form_dropdown('dptodistritocolonia', $dptodistritocolonia, '', $attribute);   ?>
					                            </div>
					                            <?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-success fa fa-file-excel-o', 'content' => 'GENERAR EXCEL', 'id' => 'boton_excel'));
													 ?>
											</div>
			                            <?php echo form_close();?>
									</div>
								</div>
							</div>
						</div>
						<div class="box-body col-sm-2">
							<pre>
								<?php foreach ($estadistica_registros as $value):?>
								<b><h4><b>Registros asignados:</b> <?php echo $value->registros_asignados; ?></h4></b>
								<b><h4><b>Registros procesados:</b> <?php echo $value->procesados; ?></h4></b>
								<b><h4><b>Registros terminados:</b> <?php echo $value->terminados; ?></h4></b>
								<b><h4><b>Registros liberados:</b> <?php echo $value->liberados; ?></h4></b>
								<?php endforeach; ?>
							</pre>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</div>



