<?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">
						<div>
							<?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>
                            	<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>
                            <?php echo form_close();?>
							<hr>
							<?php if (isset($message)): ?>
                            	<pre>
                            		<?php echo $message ?>
                            	</pre>
                            <?php endif ?>
                            <div style="overflow-x: scroll;">
                            	<table id="tabla_supervisor" 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>
									</tr>
									<tr>
									<?php echo form_open('monitoreo/panel_control/panel_control/busqueda_control_supervisor', 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_supervisor']['dpto'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['distrito'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['colonia'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['colonia_desc'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['manzana'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['lote_a'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['lote_b'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['cuest'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['situacion_lote'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['condicion_lote'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['ocupante_actual'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['cultivo'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['produccion_ganadera'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['asistencia_crediticia'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['asistencia_tecnica'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['organizacion'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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_supervisor']['nombre_proceso'])) 
													 {	
														echo $_SESSION['arraywhere_control_supervisor']['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 if ($control_supervisor != NULL) {?>
									<?php foreach ($control_supervisor 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 == 'A05') {
													$bgcolor = '#7ac5cd';
												}elseif ($values->proceso == 'A06') {
													$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, 'VER'); ?>
											</td>
											<td bgcolor="<?php echo $bgcolor ?>">
												<?php 
												if ($values->proceso == 'A05' || $values->proceso == 'A06') {
													echo anchor('monitoreo/panel_control/panel_control/confirmar_supervisor/'.$values->id_registro_lote.'/'.$values->mapear, 'CONFIRMAR'); 
												}
												?>
											</td>
											<td bgcolor="<?php echo $bgcolor ?>">
												<?php 
												if ($values->proceso == 'A05' || $values->proceso == 'A06') {
													echo anchor('monitoreo/panel_control/panel_control/rechazar_supervisor/'.$values->id_registro_lote, 'RECHAZAR');
												}
												?>
											</td>
											<td bgcolor="<?php echo $bgcolor ?>">
												<?php 
												if ($values->proceso == 'A05') {
													echo anchor('monitoreo/panel_control/panel_control/liberar_supervisor_indiv/'.$values->id_registro_lote, 'LIBERAR');
												}
												?>
											</td>
										</tr>

									<?php endforeach;?>
									<?php }; ?>
									</tbody>
								</table>
							</div>
							<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_supervisor', array('class' => 'form-horizontal', 'id' => 'form-liberar')); ?>
										<label for="dptodistritocolonia">Elegir colonia a liberar</label>
										<div>
											<div class="col-sm-10">
			                        			<?php $attribute = 'class="selectpicker show-tick form-control" title="Seleccione la colonia" name="dptodistritocolonia" id="dptodistritocolonia"';
				                                echo form_dropdown('dptodistritocolonia', $dptodistritocolonia, '', $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_responsable 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 verif.:	</b> <?php echo $value->liberados_verificador; 	?></h4></b>
								
							</pre>
						</div>
						<div class="box-body col-sm-2">
							<pre>
								<b><h4><b>Registros rechazados:			</b> <?php echo $value->rechazados; 			?></h4></b>
								<b><h4><b>Registros confirmados:		</b> <?php echo $value->confirmados; 			?></h4></b>
								<b><h4><b>Registros liberados sup.:		</b> <?php echo $value->liberados_responsable; 	?></h4></b>
								<?php endforeach; ?>
							</pre>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</div>



