<div class="row">
	<form autocomplete='off' class='form-horizontal' name=''  method='post' action='<?php echo base_url('clientes/guardarcredito');?>' onsubmit="creditos.guardar(event,'<?php echo (isset($saldo))?'update':'save';?>')">
		<div class="panel blank-panel">
			<div class="panel-body">
				<div class="form-group">
					<label class="col-md-2 control-label">Cliente:</label>
					<div class="col-md-10">
						<select id="creditos-nuevo-cliente-select" name="id_cliente" class="form-control" data-placeholder="Elija un cliente" required>
							<option value="0"></option>
							<?php if(count($clientes)):foreach($clientes as $cliente):?>
								<option value="<?php echo $cliente->id;?>" <?php echo (isset($cliente->limite))?'selected':'';?>><?php echo $cliente->nombre; echo ($cliente->razon)?" - ".$cliente->razon:'';?></option>
							<?php endforeach;endif;?>
						</select>
						<span id="credito-no-cliente-error" class="help-block m-b-none" style="color:#ED5565; display:none;">Seleccione un cliente</span>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-md-3 control-label">Monto maximo:</label>
					<div class="col-md-4">
						<div class="input-group">
							<span class="input-group-addon"><i class="fa fa-money"></i></span>
							<input type="number" step="any" class="form-control" name="limite_credito_cliente" value="<?php echo (isset($cliente->limite))?$cliente->limite:'';?>" min="<?php echo (isset($saldo))?$saldo:'0';?>" required>
						</div>
					</div>
				</div>
				<div class="form-group" style="margin:0; text-align:center;">
					<button type="button" class="btn btn-danger btn-rounded" onclick="Custombox.close();">Cancelar</button>
					<button type="submit" class="btn btn-primary btn-rounded">Crear credito</button>
				</div>
			</div>
		</div>
	</form>
</div>
<script>		
	$("#creditos-nuevo-cliente-select").chosen({
		no_results_text: "No se encontro ningun resultado",
		allow_single_deselect: true
	}).change(function(){
		if($(this).val() != '0'){
			$("#credito-no-cliente-error").css('display','none');	
		}else{
			
		}		
	});
</script>