<?php $__env->startSection('CSS'); ?>
<?php echo HTML::style('bootstrap-select/css/bootstrap-select.min.css'); ?>

<?php echo HTML::style('Intl-Tel-Input/17.0.3/css/intlTelInput.min.css'); ?>

<style type="text/css">
	.intl-tel-input, .iti {
		height: 34px !important;
		width: 100%;
		display: table-cell;
	}
	.intl-tel-input.allow-dropdown input {
		padding-right: 6px !important;
		padding-left: 52px !important;
		margin-left: 0;
	}
	.intl-tel-input.allow-dropdown ul.country-list {
		z-index: 9999 !important;
	}
	.seleccionado {
		color: #282323;
		font-weight: normal;
	}
	.deshabilitado {
		pointer-events: none;
		opacity: 0.5;
	}
	@media (max-width: 768px){
		.ext {
			width: 50px !important;
		}
	}
	@media  only screen and (orientation: landscape) and (max-width: 700px) {
		.ext {
			width: 70px !important;
		}
	}
</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('Contenido'); ?>
<?php
	$Cliente = Cliente::find( $Empleado->clientes_id );
	$Pais = $Cliente->pais;
	if( $Prospecto->pais != '' ){
		$Pais = $Prospecto->pais;
	}
	$telefono = $Prospecto->telefono;
	$ext_tel = '';
	$telefono_2 = $Prospecto->telefono2;
	$ext_tel2 = '';
	$tel_trabajo = $Prospecto->numero_de_telefono_del_trabajo;
	$ext_tel_trabajo = '';
	if( strpos($Prospecto->telefono, 'ext') ){
		$telefono = explode(" ", $Prospecto->telefono);
		$ext_tel = $telefono[2];
		$telefono = $telefono[0];
	}
	if( strpos($Prospecto->telefono2, 'ext') ){
		$telefono_2 = explode(" ", $Prospecto->telefono2);
		$ext_tel2 = $telefono_2[2];
		$telefono_2 = $telefono_2[0];
	}
	if( strpos($tel_trabajo, 'ext') ){
		$tel_trabajo = explode(" ", $tel_trabajo);
		$ext_tel_trabajo = $tel_trabajo[2];
		$tel_trabajo = $tel_trabajo[0];
	}
	$Vendido =SeguimientoProspecto::where('prospectos_id', '=', $Prospecto->id)->where('estado', '=', 'V')->count();
?>
<div class="row">
	<div class="col-md-12">
		<h2><i class="fa fa-users"></i> Gestión de prospectos </h2>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
		<div class="block-web">
			<div class="header"> <h3 class="content-header"> Editar prospecto </h3> </div>
			<div class="porlets-content">
				<?php echo Form::open(array('route' => array('SysWebGClientesProspectosEditar', $Prospecto->id), 'method' => 'post', 'class' => 'form-horizontal row-border', 'id' => 'frmEditar', 'files' => true, 'target' => 'upload_iframe')); ?>

					<div class="form-group">
						<label class="col-sm-3 control-label"> Nombre del cliente [Empresa] </label>
						<div class="col-sm-9">
							<?php echo Form::text('nombre', $Prospecto->nombre,  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errnombre"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Nombre del contacto (*) </label>
						<div class="col-sm-9">
							<?php echo Form::text('contacto', $Prospecto->contacto,  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errcontacto"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Número de teléfono (*) </label>
						<div class="col-sm-9">
							<div class="input-group">
								<span class="input-group-addon"><i class="fa fa-phone"></i></span>
								<?php echo Form::text('telefono-in', $telefono,  array('class' => 'form-control inTelIn', 'placeholder' => '', 'data-name' => 'telefono')); ?>

								<span class="input-group-addon"> Extensión </span>
								<input type="text" class="form-control ext" style="width: 150px;" value="<?php echo $ext_tel; ?>" name="txtExtension-Tel">
							</div>
							<span class="text-danger" id="errtelefono"> </span>
							<input type="hidden" name="telefono">
							<input type="hidden" name="telefono-pais">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Número de teléfono secundario </label>
						<div class="col-sm-9">
							<div class="input-group">
								<span class="input-group-addon"><i class="fa fa-phone"></i></span>
								<?php echo Form::text('telefono2-in', $telefono_2,  array('class' => 'form-control inTelIn', 'placeholder' => '', 'data-name' => 'telefono2')); ?>

								<span class="input-group-addon"> Extensión </span>
								<input type="text" class="form-control ext" style="width: 150px;" value="<?php echo $ext_tel2; ?>" name="txtExtension-Tel2">
							</div>
							<span class="text-danger" id="errtelefono2"> </span>
							<input type="hidden" name="telefono2">
							<input type="hidden" name="telefono2-pais">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Número de celular </label>
						<div class="col-sm-9">
							<div class="input-group">
								<span class="input-group-addon" style="padding: 0px 15px;"><i class="fa fa-mobile"></i></span>
								<?php echo Form::text('celular-in', $Prospecto->celular,  array('class' => 'form-control inTelIn', 'placeholder' => '', 'data-name' => 'celular')); ?>

							</div>
							<span class="text-danger" id="errcelular"> </span>
							<input type="hidden" name="celular">
							<input type="hidden" name="celular-pais">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Número de WhatsApp </label>
						<div class="col-sm-9">
							<div class="input-group">
								<span class="input-group-addon"><i class="fa fa-whatsapp"></i></span>
								<?php echo Form::text('whatsapp-in', $Prospecto->numero_de_whatsapp,  array('class' => 'form-control inTelIn', 'placeholder' => '', 'data-name' => 'whatsapp')); ?>

							</div>
							<span class="text-danger" id="errwhatsapp"> </span>
							<input type="hidden" name="whatsapp">
							<input type="hidden" name="whatsapp-pais">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Número de teléfono del trabajo </label>
						<div class="col-sm-9">
							<div class="input-group">
								<span class="input-group-addon"><i class="fa fa-building"></i></span>
								<?php echo Form::text('numero_de_telefono_del_trabajo-in', $tel_trabajo,  array('class' => 'form-control inTelIn', 'placeholder' => '', 'data-name' => 'numero_de_telefono_del_trabajo')); ?>

								<span class="input-group-addon"> Extensión </span>
								<input type="text" class="form-control ext" style="width: 150px;" value="<?php echo $ext_tel_trabajo; ?>" name="txtExtension-Trabajo">
							</div>
							<span class="text-danger" id="errnumero_de_telefono_del_trabajo"> </span>
							<input type="hidden" name="numero_de_telefono_del_trabajo">
							<input type="hidden" name="numero_de_telefono_del_trabajo-pais">
						</div>
					</div>
					<div class="form-group <?php if( $Prospecto->rebotado == 1 ): ?> has-error <?php endif; ?> ">
						<label class="col-sm-3 control-label">
							Correo electrónico
							<?php if( $Prospecto->rebotado == 1 ): ?> <span class="text-danger tooltips" data-toggle="tooltip" data-original-title="No hemos podido verificar que el correo electrónico sea válido, por favor confirma con el cliente que esté escrito correctamente">
								<i class="fa fa-exclamation-triangle"></i>
							</span> <?php endif; ?>
						</label>
						<div class="col-sm-9">
							<?php echo Form::text('correo_electronico', $Prospecto->correo_electronico,  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errcorreo_electronico"> </span>
						</div>
					</div>
					<div class="form-group">
						<label  class="col-sm-3 control-label"> Pais </label>
						<div class="col-sm-9">
							<select class="form-control crs-country seleccionado" id="pais" name="country" data-region-id="estado" data-default-option="Seleccione un país" data-whitelist="US,MX,CU,DM,DO,PR,BZ,GT,SV,HN,NI,CR,PA,VE,EC,CO,PE,BO,CL,PY,UY,AR,ES,GQ" data-value="shortcode" style="font-size: 13px; padding: 7.5px 11px !important;" data-default-value="<?php echo $Pais; ?>">
							</select>
							<span id="errcountry" class="text-danger"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Estado/Provincia/Depertamento </label>
						<div class="col-sm-9">
							<select class="form-control <?php if($Prospecto->estado != ''): ?> seleccionado <?php endif; ?> " id="estado" name="estado" data-blank-option="Seleccione su estado" data-default-option="Seleccione su estado/provincia/departamento" style="font-size: 13px; padding: 7.5px 11px !important;" <?php if($Prospecto->estado != ''): ?> data-default-value="<?php echo $Prospecto->estado; ?>" <?php endif; ?> >
							</select>
							<span id="errestado" class="text-danger"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Cuidad </label>
						<div class="col-sm-9">
							<?php echo Form::text('ciudad', $Prospecto->ciudad,  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errciudad"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Codigo postal </label>
						<div class="col-sm-9">
							<?php echo Form::text('postal', $Prospecto->codigo_postal,  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errpostal"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Dirección </label>
						<div class="col-sm-9">
							<?php echo Form::text('direccion', $Prospecto->direccion,  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errdireccion"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Referencia de dirección </label>
						<div class="col-sm-9">
							<?php echo Form::text('direccionDir', $Prospecto->referencia_dir,  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errdireccionDir"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Comentario </label>
						<div class="col-sm-9">
							<?php echo Form::textarea('comentario', $Prospecto->comentario, array('class' => 'form-control', 'rows' => '6', 'placeholder' => '')); ?>

							<span class="text-danger" id="errcomentario"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Producto/Servicio (*) </label>
						<div class="col-sm-9">
							<?php echo Form::select('productos_servicios_id', $slProductos, null, array('class' => ($Vendido > 0)?'form-control selectpicker deshabilitado':'form-control selectpicker', 'id' => 'productos_servicios_id', 'data-live-search' => 'true', 'multiple' => '', 'data-selected-text-format' => 'count')); ?>

							<span class="text-danger" id="errproductos_servicios_id"> </span>
						</div>
					</div>
					<div class="form-group" style="margin-bottom: 15px;">
						<label class="col-sm-3 control-label"></label>
						<div class="col-sm-9" id='categoria-productos'></div>
					</div>
					<?php if($Vendido == 0): ?>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Producto/Servicios relacionados </label>
						<div class="col-sm-9">
							<div id="dvPSRelacionados" style="/*padding-top: 10px;*/">
							</div>
							<input type="hidden" name="idsPSRS" value="">
						</div>
					</div>
					<?php endif; ?>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Referencia (*) </label>
						<div class="col-sm-9">
							<?php echo Form::select('referencias_id', $slReferencias, $Prospecto->referencias_id, array('class' => 'form-control selectpicker', 'id' => 'referencias_id', 'data-live-search' => 'true')); ?>

							<span class="text-danger" id="errreferencias_id"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Asignar a... (*) </label>
						<div class="col-sm-9">
							<?php echo Form::select('asignado_a', $slEmpleados, $Prospecto->asignado_a, array('class' => 'form-control selectpicker', 'id' => 'asignado_a', 'data-live-search' => 'true')); ?>

							<span class="text-danger" id="errasignado_a"> </span>
						</div>
					</div>
					<fieldset style="border-bottom: 1px solid #e5e5e5; margin-bottom: 15px;" class="redes">
						<legend > <label class="col-sm-3 control-label"></label><label class="col-sm-9"> Redes Sociales (opcional)</label> </legend>
						<div class="form-group">
								<label class="col-sm-3 control-label"> Facebook </label>
								<?php $Redes = json_decode($Prospecto->otros, true)?>
								<div class="col-sm-9">
									<?php echo Form::text('facebook', $Redes['facebook'],  array('class' => 'form-control', 'placeholder' => 'https://www.facebook.com/')); ?>

									<span class="text-danger" id="errfacebook"> </span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"> Linkedin </label>
								<div class="col-sm-9">
									<?php echo Form::text('linkedin', $Redes['linkedin'],  array('class' => 'form-control', 'placeholder' => 'https://www.linkedin.com/')); ?>

									<span class="text-danger" id="errlinkedin"> </span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"> Instagram </label>
								<div class="col-sm-9">
									<?php echo Form::text('instagram', $Redes['instagram'],  array('class' => 'form-control', 'placeholder' => 'https://www.instagram.com/')); ?>

									<span class="text-danger" id="errinstagram"> </span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"> Twitter </label>
								<div class="col-sm-9">
									<?php echo Form::text('twitter', $Redes['twitter'],  array('class' => 'form-control', 'placeholder' => 'https://www.twitter.com/')); ?>

									<span class="text-danger" id="errtwitter"> </span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"> Piterest </label>
								<div class="col-sm-9">
									<?php echo Form::text('pinterest', $Redes['pinterest'],  array('class' => 'form-control', 'placeholder' => 'https://www.pinterest.com/')); ?>

									<span class="text-danger" id="errpinterest"> </span>
								</div>
							</div>
					</fieldset>
					<div class="bottom">
						<?php echo Form::button('Editar', array('class' => 'btn btn-warning', 'id' => 'btnEditar', 'type' => 'submit')); ?>

						<?php echo HTML::linkRoute('SysWebGClientesProspectos', 'Cancelar', array(), array('class' => 'btn btn-default lR')); ?>

					</div>
				<?php echo Form::close(); ?>

		</div>
		
	</div>
</div><!--/row end-->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JS'); ?>
<?php echo HTML::script('bootstrap-select/js/bootstrap-select.min.js'); ?>

<?php echo HTML::script('bootstrap-select/js/i18n/defaults-es_CL.min.js'); ?>

<?php echo HTML::script('Intl-Tel-Input/17.0.3/js/intlTelInput-jquery.min.js'); ?>

<?php echo HTML::script('Alphanum/jquery.alphanum.min.js'); ?>

<?php echo HTML::script('jquery-browser-plugin/jquery.browser.min.js'); ?>

<script type="text/javascript">
	<?php
		DB::statement('SET SESSION group_concat_max_len = 10000000000000000000;');
		$sql = "SELECT
			IF(
				((SELECT COUNT(id) FROM productos_servicios WHERE clientes_id = @idC) > 0),
				(SELECT
					CONCAT('[',
						GROUP_CONCAT('
							{
								\"idPS\": \"',ps.id,'\",
								\"nombrePS\": \"',REPLACE(ps.nombre, '\"', \"'\"),'\",
								\"relacionados\": ',(
									IF(
										((SELECT COUNT(id) FROM ps_relacionados WHERE principal = ps.id) > 0),
										(SELECT
											CONCAT('[',
												GROUP_CONCAT('{
													\"idPS\": \"',r.id,'\",
													\"nombrePS\": \"',REPLACE(r.nombre, '\"', \"'\"),'\"
												}')
											,']')
										FROM
											ps_relacionados AS psr
										INNER JOIN
											productos_servicios AS r
											ON r.id = psr.relacionado
										WHERE
											psr.principal = ps.id
										),
										'[]'
									)
								)
							,'}')
					,']') AS productos
				FROM
					productos_servicios AS ps
				WHERE
					ps.clientes_id = @idC
				),
				'[]'
			) AS productos
		;";
		$sql = str_replace('@idC', $Cliente->id, $sql);
		$jSonProductosR = DB::select(DB::raw($sql));
	?>
	var jSonProductosR = <?php echo $jSonProductosR[0]->productos; ?>;
</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JSOr'); ?>
<?php if( Agent::isDesktop() ): ?>
$(".sidebar-toggle-box").trigger("click");
<?php endif; ?>
$(".inTelIn").intlTelInput({
	utilsScript: "<?php echo asset('Intl-Tel-Input/17.0.3/js/utils.min.js'); ?>"
});
$(".inTelIn").intlTelInput("setCountry", "<?php echo $Pais; ?>");
$('[name="txtExtension-Trabajo"], [name="txtExtension-Tel"], [name="txtExtension-Tel2"]').alphanum({
	allow: "0123456789",
	disallow: "abcdefghijklmnñopqrstuvwxyz",
	allowSpace: false,
	allowNumeric: true,
	allowUpper: false,
	allowCaseless: false,
	allowOtherCharSets: false,
	forceLower: true,
	maxLength: 5,
});
$(".inTelIn").alphanum({
	allow: "0123456789-+ ",
	disallow: "abcdefghijklmnñopqrstuvwxyz",
	allowSpace: false,
	allowNumeric: true,
	allowUpper: false,
	allowCaseless: false,
	allowOtherCharSets: false,
	forceLower: true,
});
$("[name='correo_electronico']").blur(function(e){
	$(this).val($(this).val().replace(/\s/g, ""));
});
$("#productos_servicios_id").selectpicker();
$("#productos_servicios_id").selectpicker("val", <?php echo $idProdcutos; ?>);
$("#productos_servicios_id").on("changed.bs.select", function(e, clickedIndex){
	if( clickedIndex != 0 ){
		$("#categoria-productos").html("");
		$("#dvPSRelacionados").html("");
		if($(this).val() != null){
			<?php if($Vendido == 0): ?>
			//ELIMINO LOS PRODUCTOS RELACIONADOS QUE SE HAN ELIMINADO
			if( $('[name="idsPSRS"]').val() != "" ){
				var idsPS = $("#productos_servicios_id").val();
				var idsPSRS = $('[name="idsPSRS"]').val().split(",");
				$.each(idsPSRS, function(indice, idPSRS){
					if( (idsPS.indexOf(idPSRS) == -1) ){
						idsPSRS.splice(indice, 1);
					}
				});
				//console.log();
				idsPSRSSt = idsPSRS.join();
				$('[name="idsPSRS"]').val(idsPSRSSt);
			}
			//-------------------------------------------------------
			<?php endif; ?>
			$.each( $(this).val(), function(key, value){
				if( value != "" ){
					$("#categoria-productos").closest(".form-group").removeAttr("style");
					$("#categoria-productos").append(' \
						<span class="label label-info" style="margin-bottom: 15px;"> \
							'+$("#productos_servicios_id > [value='"+value+"']").html()+' \
							<i class="fa fa-times etiq eliminar-producto'+value+'" data-id="'+value+'" style="cursor: pointer; padding-left: 5px; <?php if($Vendido > 0): ?> display: none; <?php endif; ?> " ></i> \
						</span> &nbsp; \
					');
					<?php if($Vendido == 0): ?>
					$(".eliminar-producto"+value).click(function(){
						$(this).parent().remove();
						var ids = [];
						$(".etiq").each(function(){
							ids.push($(this).attr("data-id"));
						});
						$("#productos_servicios_id").selectpicker("val", ids);
						$("#frmEditar").find('[name="idsP"]').val(ids);
						$("#productos_servicios_id").trigger("changed.bs.select");
					});
					//PROCESAMIENTO DE IDENTIFICACIÓN DE PRODUCTOS RELACIONADOS -----------------------------------------------------------------------------------------------------
					var idsPS = $("#productos_servicios_id").val();
					var idPS = value;
					$.each(jSonProductosR, function(indice, producto){
						if( parseInt(idPS) == parseInt(producto.idPS) ){
							var procesarR = true;
							if( $('[name="idsPSRS"]').val() != "" ){
								var idsPSRS = $('[name="idsPSRS"]').val().split(",");
									if( !(idsPSRS.indexOf(idPS) == -1) ){
										procesarR = false;
								}
							}
							if( procesarR ){
								if( producto.relacionados.length > 0 ){
									$.each(producto.relacionados, function(indice, productoR){
										if( (idsPS.indexOf( productoR.idPS ) == -1) ){
											$("#dvPSRelacionados").append(' \
												<span class="label label-success" style="margin-bottom: 15px;"> \
													'+productoR.nombrePS+' \
													<i class="fa fa-plus agregarPS'+productoR.idPS+'" data-id="'+productoR.idPS+'" style="cursor: pointer; padding-left: 5px" ></i> \
												</span> &nbsp; \
											');
										}
									});
								}
							}
						}
					});
					//---------------------------------------------------------------------------------------------------------------------------------------------------------------
					//PROGRAMACIÓN DE BOTÓN DE AGREGAR EN LISTA DE PRODUCTOS -------------
					$("#dvPSRelacionados").find(".fa-plus").each(function(e){
						var agregarPS = $(this);
						agregarPS.click(function(e){
							var idPS = $(this).attr("data-id");
							//AGREGO EL PRODUCTO A LOS IDS SELECCIONADOS -----------------
							var idsPSRS = new Array();
							if( $('[name="idsPSRS"]').val() != "" ){
								idsPSRS = $('[name="idsPSRS"]').val().split(",");
							}
							idsPSRS.push( idPS );
							idsPSRSSt = idsPSRS.join();
							$('[name="idsPSRS"]').val(idsPSRSSt);
							//AGREGO LOS IDS SELECCIONADOS AL LISTADO DE NO RELACIONADOS -
							var idsPS = $("#productos_servicios_id").val();
							if( (idsPS.indexOf( idPS ) == -1) ){
								idsPS.push( idPS );
								$("#productos_servicios_id").selectpicker("val", idsPS);
								$("#productos_servicios_id").trigger("changed.bs.select");
							}
							//------------------------------------------------------------
						});
					});
					//--------------------------------------------------------------------
					<?php endif; ?>
				}
			});
			var productos = $(this).val().filter(Boolean);
			if($("#frmEditar").find('[name="idsP"]').length == 0){
				$("#frmEditar").append('<input type="hidden" name="idsP" value="'+productos+'">');
			}
			else{
				$("#frmEditar").find('[name="idsP"]').val(productos);
			}
		}
	}
});
$("#productos_servicios_id").trigger("changed.bs.select");
$("#pais").change(function(){
	if( $(this).val() != "" ){
		$(this).addClass("seleccionado");
		$(".inTelIn").intlTelInput("setCountry", $(this).val());
	}
	else{
		$(this).removeClass("seleccionado");
		$("#estado").removeClass("seleccionado");
	}
});
$("#estado").change(function(){
	if( $(this).val() != "" ){
		$(this).addClass("seleccionado");
	}
	else{
		$(this).removeClass("seleccionado");
	}
});
if( $.browser.mozilla ){
	$("#frmEditar").find("input").each(function(){
		$(this).prop("autocomplete", "off");
	});
}
else{
	$("#frmEditar").find("input").each(function(){
		$(this).prop("autocomplete", "disabled");
	});
}
$("#frmEditar").submit(function(e){
	e.preventDefault();
	$.isLoading({ text: "Cargando..." }); NProgress.start();
	$("#btnEditar").html('<i class="fa fa-spinner fa-spin"></i> Cargando').prop("disabled", true);
	$(".inTelIn").each(function(){
		var name = $(this).attr("data-name");
		var pais = $(this).intlTelInput('getSelectedCountryData').iso2;
		var numero = $(this).intlTelInput("getNumber");
		if($(this).closest(".input-group").find(".ext").length > 0){
			if($(this).closest(".input-group").find(".ext").val() != ""){
				numero = numero+" ext. "+$(this).closest(".input-group").find(".ext").val();
			}
		}
		$('input[name="'+name+'"]').val(numero);
		$('input[name="'+name+'-pais"]').val(pais);
	});
	var productos = $("#productos_servicios_id").val().filter(Boolean);
	($("#estado").val() == '')?$("#estado").val('<?php echo $Prospecto->estado; ?>'):$("#estado").val();
	if($("#frmEditar").find('[name="idsP"]').length == 0){
		$("#frmEditar").append('<input type="hidden" name="idsP" value="'+productos+'">');
	}
	else{
		$("#frmEditar").find('[name="idsP"]').val(productos);
	}
	var frmEditar = new FormData(document.getElementById("frmEditar"));
	$.ajax({
		type: "POST",
		url: "<?php echo URL::route('SysWebGClientesProspectosEditar', array($Prospecto->id)); ?>",
		data: frmEditar,
		cache: false,
		contentType: false,
		processData: false,
		dataType: "json",
		success: function(data){
			$.isLoading("hide"); NProgress.done();
			$("#btnEditar").html("Guardar").prop("disabled", false);
			if(data.success){
				new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				if( $.GET("sc-cer") != undefined ){
					setTimeout( function(){ window.close(); }, 3000 );
				}
				else{
					setTimeout( function(){ window.location.href = "<?php echo URL::route('SysWebGClientesProspectos'); ?>"; }, 3000 );
				}
			}
			else{
				if(data.mensaje != ''){ new PNotify({ title: "Error", text: data.mensaje, type: "error" }); }
				$.each(data.errMensajes, function(key, value){ if(value != ''){ $("#err"+key).html(value); } else{ $("#err"+key).html(""); } });
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			new PNotify({ title: "Error", text: textStatus + " " + errorThrown, type: "error" });
		}
	});
});
if( $.GET("sc-cer") != undefined ){
	$(".lR").click(function(e){
		e.preventDefault();
		window.close();
	});
}
if( $.GET("sc-per") != undefined ){
	$(".lR").click(function(e){
		e.preventDefault();
		window.close();
	});
}
<?php if( $Empleado->cargos_id == 1 || $Empleado->cargos_id == 2 ): ?>
if( $("#referencias_id option:selected").text() == "Cliente existente" || $( "#referencias_id option:selected" ).text() == "Formulario SC" ){
	$("#referencias_id").addClass("deshabilitado");
	$("#referencias_id").selectpicker("refresh");
}
<?php endif; ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>