<%@include file="/jsp/common/taglibs.jsp"%>
<script type="text/javascript" language="javascript" src="${contextPath}/js/dda/contrato/promociones/formManager.js?v=${versionJS}"></script>
<script type="text/javascript" language="javascript" src="${contextPath}/js/dda/contrato/promociones/promocionesValidate.js?v=${versionJS}"></script>
<script src="${contextPath}/js/common/alerts/dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="${contextPath}/js/common/alerts/dist/sweetalert.css">

<style type="text/css">
.mymodal-xl {
    width: 90%;
   max-width:1200px;
  }
/*  table {
    border-collapse: collapse;
}*/

.myborder {
	border: 1px solid #dddddd;
}

</style>


<!-- _____________________________MODAL AGREGAR PROMOCIONES___________________________________________________________________________ -->

<div class="modal fade bs-example-modal-lg" id="modalPromociones">
	<div class="modal-dialog  modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h3 class="modal-title">Agregar Promocion</h3>
			</div>
			<div class="modal-body">
			
				<s:form id="formNuevaPromocion" class="form-horizontal col-md-50" action="#">	
				   <fieldset>		
					   <div class="form-group">							
							 <div  class="col-md-12" >
								
								<label for="selectEstudios" class="col-md-2 control-label">Estudio: </label>
								<div class="col-md-4">								    																																			
									<select id="selectEstudios" name="selectEstudios" class="form-control required" 
									        ng-model="estudioSeleccionado"
									        ng-options="estudio as estudio.desc_estudio for estudio in estudios track by estudio.id_estudio" required>
									        <option value="">Selecciona un Estudio</option>
									</select>									
								</div>
								
								<label for="paisSeleccionado" class="col-md-2 control-label">Pais: </label>
								<div class="col-md-4">	
								  <span  class="nullable">																				
									<!-- select id="paisSeleccionado" name="paisSeleccionado" class="form-control required" 
									        ng-model="paisSeleccionado.id_pais"
									        ng-options="pais as pais.descripcion for pais in paises track by pais.id_pais">
									        <option value="">- Todos -</option>
									</select -->	
									<select id="paisSeleccionado" name="paisSeleccionado" class="form-control required" 
									        ng-model="paisSeleccionado"
									        ng-options="pais as pais.descripcion for pais in paises">
									        <option value="">- Todos -</option>
									</select>
								  </span>																				
								</div>
							</div>
						</div>																		
												
						<div class="form-group">							
							 <div  class="col-md-12" >
								
								<label for="inputEmail3" class="col-md-2 control-label">Nombre Promocion: </label>
								<div class="col-md-4">								    																																			
									<input id="nombre_promocion" maxlength="50" type="text" class="form-control required" name="nombre_promocion" required>	
									<!-- span ng-show="{ 'has-error' : !formNuevaPromocion.$pristine && formNuevaPromocion.nombre_promocion.$invalid}" class="help-block">Introduce un Nombre.</span -->								
								</div>
								
								<label for="inputEmail3" class="col-md-2 control-label">Descuento: </label>
								<div class="col-md-4">																					
									<input id="descuento" class="form-control required" name="descuento"  type="number" maxlength="7" required >
									<!-- span ng-show="{ 'has-error' : !formNuevaPromocion.$pristine && formNuevaPromocion.descuento.$invalid }" class="help-block" >Introduce el descuento.</span -->																				
								</div>
							</div>
						</div>																	
																						
						<div class="form-group">							
							 <div  class="col-md-12" >
								
								<label for="inputEmail3" class="col-md-2 control-label">Fecha Inicio</label>
								<div class="col-md-4">								    																																			
									<v:datePicker id="fecha_inicio"  name="fechaInicio" clazz="form-control required datepicker">
									</v:datePicker>									
								</div>
								
								<label for="inputEmail3" class="col-md-2 control-label">Fecha Fin</label>
								<div class="col-md-4">								    																																			
									<v:datePicker id="fecha_fin" name="fecha_fin" clazz="form-control required datepicker">
									</v:datePicker>									
								</div>
							</div>
						</div>																						
								
						<div class="form-group">							
							 <div  class="col-md-12" >
								
								<label for="inputEmail3" class="col-md-2 control-label">Tipo de Descuento</label>
								<div class="col-md-4">
								    
									    <label for="inputEmail3" class="checkbox-inline control-label"> 
											<input type="radio" value="MONEDA" name="tipo_descuento" class="formatos"> por Cantidad ($)
										</label>							    								    																																				
										<label for="inputEmail3" class=" checkbox-inline control-label"> 
											<input type="radio" value="PORCENTAJE" name="tipo_descuento" class="formatos" ng-checked='true'> por Porcentaje (%)
										</label>
																		
								</div>
								
							</div>
						</div>
						
						<div class="form-group">							
							 <div  class="col-md-12" >
								<div class="col-md-7">								    																																			
									 <input style="background-color:#181818; color:#fff9f9; width:100px; margin-left:150px;" class="btn" id="btnRegresar" type="button" value="Regresar" data-dismiss="modal">									
								</div>
								<div class="col-md-4">																					
									 <input style="width:150px; margin-left:150px;" class="btn btn-primary" id="btnConsultarTitulos" type="button" value="Consulta Titulos" ng-click="listaTitulos()">																				
								</div>
							</div>
						</div>	
																																																															
						<br>
						<label id="errorFormatos" name="errorFormatos" class="lbErrores" style="display:none; color:red; font-size: large;">Se debe seleccionar un tipo descuento</label>
						<label id="errorEditForm"                      class="lbErrores" style="display:none; color:red; font-size: large;">Complete todos los campos</label>
					</fieldset>
				</s:form>
                <!-- tabla para mostrar Titulos -->
                <div>
                     <table id="tablaTitulosPromos" class="table" ng-repeat="contratoAtitulo in titulosToFilter() | filter:filterTitulos">
                            <thead>
                                 <tr class="encabezado" role="row" >
                                       <td style="width: 166px;">Contrato: {{ contratoAtitulo.numero_contrato }}</td>
                                       <td> </td>
                                       <td> </td>
                                 </tr>
                                 
                            </thead>
                            <body>
                                  <tr ng-repeat="titulo in titulos | filter:{numero_contrato: contratoAtitulo.numero_contrato}">
                                       <td><input style="margin-left: 70px;" type="checkbox" id="{{titulo.id_bv}}" value="{{titulo.id_bv}}" name="checksBoxPromo" class="formatos"></td>
                                       <td style="width: 166px;">{{titulo.id_bv}}</td>
                                       <td>{{titulo.nombre_estandar}}</td>
                                  </tr>
                            </body>
                     </table>
                </div>
			</div>
			<div class="modal-footer">
				<input id="btnGuardarPromocion" type="submit" class="btn btn-primary" ng-disabled="btnGuardarPromo" ng-click="guardarPromocion()" value="Guardar">
			</div>
		</div>
	</div>
</div>

	