<?php 
    @$msg = $_GET['msg'];
	require_once("vendor/autoload.php");
	require_once('./constantes.php');
	$pedidos = new \App\Models\Pedidos();
	$config = new \App\Models\Config();

	$getConfig   = $config->getConfig();
	$getAllLojas = $pedidos->getAllLojas();
	
	$data_hoje = date('Y-m-d');
	$faixa_final   = date('Y-m-d', strtotime($getConfig[0]["data_analise_ini"]." days", strtotime($data_hoje)));
	$faixa_inicial = date('Y-m-d', strtotime($getConfig[0]["data_analise_fim"]." days", strtotime($faixa_final)));
	$sug_dias      = $getConfig[0]["sug"];
?>
<style>
  .bd-placeholder-img {
	font-size: 1.125rem;
	text-anchor: middle;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
  }
  @media (min-width: 768px) {
	.bd-placeholder-img-lg {
	  font-size: 3.5rem;
	}
  }
  .list-group-horizontal{-ms-flex-direction: row;flex-direction: row;}
  .list-group-item{ padding: .4rem 0rem; }
  .list-group-item a{ padding: .75rem 1.25rem; } 
  .disabled {cursor: not-allowed;}

    .table-hover tbody tr:hover {
		background-color: rgb(210 210 210) !important;
	}
  
  		.table td, .table th {
			font-size: 11px !important;
		    height: auto !important;
		}
		.btn {
			padding: .1rem 1.8rem !important;
			font-size: 12px !important;
		}
		.form-control {
			font-size: 12px;
			border-color: #ebedf2;
			padding: 2px 5px;
			height: inherit!important;
		}
		
		#configfor3 input{
			border: 1px solid #f40;
		}
</style>
<!-- MOVE O CURSO DO MENU -->
<script> window.onload = function(e){ $('.nav-item').removeClass('active'); $('#analise').addClass('active'); } </script>
<!-- MOVE O CURSO DO MENU -->
<div class="page-inner">
<br>
<br>
	<div class="row">
		<div class="col-md-3">
			<label>Origem</label>
			<input type="hidden" name="cod" id="cod" value="1"/>
			<input type="hidden" name="qtd_min" id="qtd_min" value="1"/>
			<select name="origem" id="origem" class="form-control disabled" disabled >
				<option value="1">Matriz - Feira de Santana</option>
			</select>
		</div>
		<div class="col-md-3">
			<label>Destino</label>
			<select name="destino" id="destino" class="form-control <?php if($_SESSION['id_loja'] != 0){ ?>disabled<?php } ?>" <?php if($_SESSION['id_loja'] != 0){ ?>disabled<?php } ?>>
				<option value="">::- Selecione -::</option>
				<?php 
					foreach ($getAllLojas as $key => $lista) {
				?>
					<option value="<?= $lista['id'];?>" <?php if($_SESSION['id_loja'] == $lista['codigo_loja']){ ?>selected<?php } ?> ><?= $lista['nome'];?></option>
				<?php } ?>
				
			</select>							
		</div>
		<div class="col-md-2">
			<label>Faixa Inicial</label>
			<input type="date" name="date_ini" id="date_ini" class="form-control disabled" disabled value="<?= $faixa_inicial; ?>" required />
		</div>
		<div class="col-md-2">
			<label>Faixa Final</label>
			<input type="date" name="date_fim" id="date_fim" class="form-control disabled" disabled value="<?= $faixa_final; ?>" required />
		</div>
		<div class="col-md-2">
			<label>Sug Dias</label>
			<input type="number" name="dias" id="dias" class="form-control disabled" disabled required value="<?= $sug_dias; ?>" />
		</div>
	</div>
	<div class="row">
		<!--<div class="col-md-2">
			<label>Fornecedor</label>
		</div>-->
		<div class="col-md-2">
			<label>Grupo</label>
			<input type="text" name="grupo" id="grupo" class="form-control" />
			<input type="hidden" name="fornecedor" id="fornecedor" class="form-control" />
			<input type="hidden" name="tipo" id="tipo" class="form-control" />
			<input type="hidden" name="usuario" id="usuario" value="0" />			
		</div>
		<!--<div class="col-md-2">
			<label>Tipo</label>

		</div>-->
		<div class="col-md-3">
			<label>Deposito</label>
			<select name="deposito" id="deposito" class="form-control" required >
				<option value="" selected disabled="disabled">::- Selecione o Deposito - ::</option>
				<option value="1">DEPOSITO 1</option>
				<option value="2">DEPOSITO 2</option>
				<option value="3">DEPOSITO 3</option>
				<option value="4">DEPOSITO 4</option>
				<option value="5">DEPOSITO 5</option>
				<option value="6">DEPOSITO 6</option>
				<option value="7">DEPOSITO 7</option>
			</select>														
		</div>	
		
	</div>	
	<div class="row" style="padding-top: 10px; padding-bottom: 10px;">
		<div class="col-md-6">
			<button type="button" name="btn_abrirModal" id="btn_abrirModal" class="btn btn-info"  onclick="Seleciona_Traslados('', 'Traslados');" >Gerar<span id="span_abrirModal"></span></button>
			<button type="button" onclick="window.location.reload();" name="btt" id="btt" class="btn btn-danger"  >Parar Execurção</button>
		</div>
		<div class="col-md-6 pull-right">
			<button type="button" onclick="excluir();" name="btt2" id="btt2" class="btn btn-secondary btt disabled"  >Excluir</button>
			<button type="button" onclick="alterar();" name="btt3" id="btt3" class="btn btn-secondary btt disabled"  >Alterar</button>
		</div> 
	</div>		
	<div class="row">
		<div class="col-md-12">
			<?php include './inc/alerts.php';?>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="table-responsive">
				<div style="overflow-x:auto;" id="ts" >
					<table id="example" class="table table-bordered table-hover" style="background:#FFF; margin:0 !important;width: 100%;">
						<thead  class="thead-dark">
							<tr>
								<th style="text-align:center;"><input type='checkbox' id='checkAll' /></th>
								<th style="text-align:center;">COD</th>
								<th style="text-align:center;">REF</th>
								<th style="text-align:center;">DESCRIÇÂO</th>
								<th style="text-align:center;">VEN. PERIODO</th>
								<th style="text-align:center;">EST. MATRIZ</th>
								<th style="text-align:center;">EST. FILIAL</th>
								<th style="text-align:center;">SUGESTÂO</th>
							</tr>
						</thead>
						<tbody id="ResultX">
							<tr>
								<td colspan="8">Faça uma busca para começar</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<div class="row" style="padding-top: 10px;" >
		<div class="col-lg-12">
			<button type="button" name="concluir" id="concluir" class="btn btn-secondary disabled pull-left" disabled >Concluir</button>
			<button type="button" name="newana" id="newana" class="btn btn-secondary pull-right" onclick="tes();"  >Nova Analise em Branco</button>
			<button type="button" name="import" id="import" class="btn btn-dark pull-right" style="margin-right: 10px;" >Importar Analise</button>
			
		</div>
	</div>	
	
	
	
</div>
<a href="#" data-toggle="modal" data-target="#modalStatus" class="btn btn-icon btn-round btn-info btn-sm" style="cursor: pointer; width: 3%; position: fixed;top: 13%;right: 10px;z-index: 99;padding: 0 !important;" ><i class="fa fa-question fa-2x" aria-hidden="true"></i></a>
 <!-- Modal -->
    <div class="modal fade" id="modalStatus" tabindex="-1" role="dialog" aria-labelledby="modalEdtdms" aria-hidden="true">
		 <div class="modal-dialog">
			  <div class="modal-content">
				  <div class="modal-header">
					<h5 class="modal-title" id="modalEdtdms">Observação da Página</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					  <span aria-hidden="true">&times;</span>
					</button>
				  </div>
				  <div class="modal-body">
					<p style="font-size: 12px;padding-top: 2px;"><b>Para alterar basta dá duplo click na sugestão que deseja.</b><br> <i class="fa fa-square" aria-hidden="true" style='color: #ed8080; width: 8px; height: 8px; display: inline-block;' ></i> Vermelho: Sujestão maior que a quantidade da loja matriz. <br> <i class="fa fa-square" aria-hidden="true" style='color: #f7c44f; width: 8px; height: 8px; display: inline-block;'></i> Amarelo: Sujestão igual a quantidade da loja matriz.</p>
				  </div>
			  </div>
		 </div>
    </div>
	
	<div class="modal fade" id="modalNew2" tabindex="-1" role="dialog" aria-labelledby="modalEdtdms" aria-hidden="true">
		 <div class="modal-dialog modal-lg">
			  <div class="modal-content">
				  <div class="modal-header">
					<h5 class="modal-title" id="modalEdtdms">Nova analise em Branco</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					  <span aria-hidden="true">&times;</span>
					</button>
				  </div>
				  <div class="modal-body">
				  		<form  method="post" id="configfor3" enctype="multipart/form-data" >
							<div class="row">
								<div class="col-md-3">
									<div class="form-group">
										<label>Código item</label>
								      	<input type="hidden" name="cod" value="7">
								      	<input type="hidden" name="POST_paramentro" value="analise_branco">
								      	<input type="hidden" name="DIAS_sug" id="DIAS_sug" value="">
								      	<input type="hidden" name="price" id="price" value="">
								      	<input type="text" class="form-control" name="item" id="item" onfocus="this.selectionStart"  
  autofocus="true"/> <!--onchange="" onkeyup="consulta_cod(this.value);"-->  
									</div>
								</div>
								<div class="col-md-3">
									<div class="form-group">
										<label>REF</label>
								      	<input type="text" class="form-control" name="ref2" id="ref2" disabled  />
									</div>
								</div>
								<div class="col-md-4">
									<div class="form-group">
										<label>DESCRIÇÃO</label>
								      	<input type="text" class="form-control" name="descri2" id="descri2" disabled />
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label>DIAS</label>
								      	<input type="number" class="form-control" name="dias2" id="dias2" disabled />
									</div>
								</div>
								
							</div>
							<div class="row">
								<div class="col-md-2">
									<div class="form-group">
										<label>VEN.PERÍODO</label>
								      	<input type="number" class="form-control" name="ven3" id="ven3" disabled />
									</div>
								</div>							
								<div class="col-md-2">
									<div class="form-group">
										<label>MEDIA</label>
										<input class="form-control" type="text" name="media3" id="media3" disabled />
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label>EST. MATRIZ</label>
										<input class="form-control" type="text" name="estmatriz3" id="estmatriz3" disabled />
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label>EST. FILIAL</label>
										<input class="form-control" type="text" name="estfilial3" id="estfilial3" disabled />
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label>SUGESTÃO</label>
										<input class="form-control" type="text" name="suj3" id="suj3" value="0" />
										<input type="hidden" name="depositov" id="depositov" value="0" />
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-md-12">
									<button class="btn btn-primary" type="button" onclick="consulta_cod('item');" name="BTN_PESQ" id="btn_modalEdt22" >Pesquisar <span id="span_modalEdt22"></span></button>
									<button class="btn btn-success" type="button" onclick="Analise_branca('configfor4','btn_modalEdt2','span_modalEdt2','main?view=config');return false;" name="BTN_SALVAR" id="btn_modalEdt2" >Salvar <span id="span_modalEdt2"></span></button>
									<button class="btn btn-info" type="button" onclick="Limpar_analise();" name="BTN_LIMPAR" >Limpar analise </button>
								</div>
							</div>
						</form>
				  
				  </div>
			  </div>
		 </div>
    </div>
	
	 <!-- Modal -->
    <div class="modal fade" id="modalimport" tabindex="-1" role="dialog" aria-labelledby="modalEdtdms" aria-hidden="true">
		 <div class="modal-dialog">
			  <div class="modal-content">
				  <div class="modal-header">
					<h5 class="modal-title" id="modalEdtdms">Importação de analise</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					  <span aria-hidden="true">&times;</span>
					</button>
				  </div>
				  <div class="modal-body">
				  
					<p style="font-size: 12px;padding-top: 2px;">OBS: Arquivo deve ser no formato Planilha XML</p>
					
					<form action="#" method="POST" id="form_abrirModal" enctype="multipart/form-data">
						<small>(Adicione um arquivo para importação clicando na caixa.)</small>
						<label id="thumbnail" title="Clique aqui para adicionar um arquivo.">
							<input type="file" name="file_arquivo" id="file_arquivo"  onchange="getFileExtension2(this.value);"  required>
						</label><br>
						<button type="button" name="BTNINPORT" id="BTNINPORT" onclick="importar_analise('form_abrirModal')" class="btn btn-info" style="margin-top: 10px;" ><i class="fa fa-upload"></i> IMPORTAR AGORA</button>
						<button id="BTNINPORT10" disabled style="display: none" ><i class="fa fa-refresh fa-spin fa-3x fa-fw"></i></button>
					</form>
					
				  
				  </div>
			  </div>
		 </div>
    </div>
	

<!-- inclusao do footer -->
<?php
	$jspage = "<script src='utils/js/acoes_analise_pedidos_teste.js'></script>";
	$jspage .= "<script src='utils/js/importacao_.js'></script>";
?>

