<div class="row">
	<form class="form-horizontal" name='formSave' id='formSave' method='post' action='<?php echo base_url('administracion/guardar_configuraciones');?>' onsubmit="configuraciones.guardarConfigs(event)" autocomplete="off">
		<div class="col-lg-12">
			<div class="ibox">
				<div class="ibox-content">
					<div class="row m-t-xs">
						<div class="col-md-7">
							<div class="form-group">
								<label class="col-sm-3 control-label">Nombre:</label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="NombreEmpresa" value="<?php echo $configs['NombreEmpresa'];?>" required>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">Raz&oacute;n social:</label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="RazonSocialEmpresa" value="<?php echo $configs['RazonSocialEmpresa'];?>">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">Direcci&oacute;n:</label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="DireccionEmpresa" value="<?php echo $configs['DireccionEmpresa'];?>">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">Tel&eacute;fono:</label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="TelefonoEmpresa" value="<?php echo $configs['TelefonoEmpresa'];?>">
								</div>
							</div>
						</div>
						<div class="col-md-5" id="conf-gral-logo-wrapper">
							<img id="c-g-informacion-logo" class="img-responsive" src="<?php echo ($configs['LogoEmpresa'] == '')?base_url('assets/img/xypnos.png'):base_url($configs['LogoEmpresa']);?>">
							<div id="conf-gral-logo-change-mask" class="p-v-sm">
								<i class="fa fa-picture-o fa-5x"></i>
								<h1>Cambiar logo</h1>
							</div>
							<input type="file" id="conf-gral-logo-file" name="conf-gral-logo-file">
							<input type='hidden' name='logo_empresa' id='logo_empresa' value='<?php echo $configs['LogoEmpresa'];?>'/>
							<input type='hidden' name='' id='' value=''/>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<!--Info tributaria-->
					<div class="row">
						<div class="col-md-12">
							<div class="form-group">
								<label class="col-sm-1 control-label">Contribuyente:</label>
								<div class="col-sm-3">
									<select class="form-control" name="ClasificacionEmpresa" required>
										<option value="" disabled="disabled" <?php echo($configs['ClasificacionEmpresa'] == "")?'selected':'';?>>Seleccione una...</option>
										<option value="0" <?php echo($configs['ClasificacionEmpresa'] == "0")?'selected':'';?>>No contribuyente</option>
										<option value="1" <?php echo($configs['ClasificacionEmpresa'] == "1")?'selected':'';?>>Otros contribuyente</option>
										<option value="2" <?php echo($configs['ClasificacionEmpresa'] == "2")?'selected':'';?>>Mediano contribuyente</option>
										<option value="3" <?php echo($configs['ClasificacionEmpresa'] == "3")?'selected':'';?>>Gran contribuyente</option>
									</select>
								</div>
								<label class="col-sm-1 control-label">N.I.T.:</label>
								<div class="col-sm-3">
									<input type="text" class="form-control" name="NITEmpresa" value="<?php echo $configs['NITEmpresa'];?>" data-inputmask='"mask": "9999-999999-999-9"' data-mask>
								</div>
								<label class="col-sm-1 control-label">N.R.C.:</label>
								<div class="col-sm-3">
									<input type="text" class="form-control" name="NRCEmpresa" value="<?php echo $configs['NRCEmpresa'];?>">
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group">
								<label class="col-sm-1 control-label">Giro:</label>
								<div class="col-sm-11">
									<input type="text" class="form-control" name="GiroEmpresa" value="<?php echo $configs['GiroEmpresa'];?>">
								</div>
							</div>
						</div>
					</div>
					
					<div class="row">
						<div class="col-md-12">
							<div class="form-group" style="text-align:center;">
								<button type="submit" class="btn btn-primary" id="guardar-configs">Guardar configuraciones</button>
								<button type="button" class="btn btn-danger" id="cancelConfigSave">Cancelar</button>
							</div>
						</div>
					</div>
					
				</div>
			</div>
		</div>
	</form>
</div>
<script>
	$(document).ready(function() {		
		$("[data-mask]").inputmask();		
	});
	
	$("#cancelConfigSave").on("click",function(){
		location.reload(); 
	});

	var $inputImage = $("#conf-gral-logo-file");
	$("#conf-gral-logo-change-mask").on("click",function(){
		$inputImage .click();
	});
	if (window.FileReader) {
		$inputImage.change(function() {
			$inputImage.attr("disabled", true);
			
			var fileReader = new FileReader(),
					files = this.files,
					file;

			if (!files.length) {
				return;
			}

			file = files[0];

			if (/^image\/\w+$/.test(file.type)){
				fileReader.readAsDataURL(file);
				fileReader.onload=function(e){
					$("#c-g-informacion-logo").attr("src",fileReader.result);
					$inputImage.attr("disabled", false);
				};
			} else {
				swal("Error", "Por favor seleccione una imagen", "error")
			}
		});
	} else {
		$inputImage.addClass("hide");
	}
</script>