386 lines
20 KiB
PHP
Executable File
386 lines
20 KiB
PHP
Executable File
<!--sidebar end-->
|
|
<!--main content start-->
|
|
<div class="app-content content">
|
|
<section class="content-wrapper">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h3 class="font-weight-bold">
|
|
<?php
|
|
if (!empty($user->id))
|
|
echo lang('edit').' '.lang('coordinator');
|
|
else
|
|
echo lang('add').' '.lang('coordinator');
|
|
?>
|
|
</h3>
|
|
|
|
<?php //echo $this->session->flashdata('feedback'); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr class="mt-0 mb-0" />
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<form role="form" action="coordinators/addNew" method="post" enctype="multipart/form-data" onsubmit="return validateForm()">
|
|
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />
|
|
<input type="hidden" value="<?php echo $cid; ?>"/>
|
|
<div class="row">
|
|
<div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1"><?php echo lang('name'); ?></label>
|
|
|
|
<input type="text" class="form-control" name="name" id="name" value='<?php
|
|
if (!empty($setval)) {
|
|
echo set_value('name');
|
|
}
|
|
if (!empty($user->name)) {
|
|
echo $user->name;
|
|
}
|
|
?>' placeholder="" required>
|
|
<div class="txt-red" id="name_Error" style="color:red;font-size: 12.5px !important;"></div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label class="required-field" for="exampleInputEmail1"><?php echo lang('email'); ?></label>
|
|
<div class="input-group">
|
|
<input type="email" class="form-control" name="email" id="email" value='<?php
|
|
if (!empty($setval)) {
|
|
echo set_value('email');
|
|
}
|
|
if (!empty($user->email)) {
|
|
echo $user->email;
|
|
}
|
|
?>' placeholder="" required data-error="Please enter a valid email.">
|
|
<div class="input-group-append" id="emailcheckTab" style="display: none;">
|
|
<span class="input-group-text" >
|
|
<span id="emailChecking" style="display: none"><i class="la la-hourglass-start" style="color: blue;"></i></span>
|
|
<span id="emailAvailable" style="display: none"><i class="la la-check" style="color: green;">Available</i></span>
|
|
<span id="emailNA" style="display: none"><i class="la la-close" style="color: red;">Not-Available</i></span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="help-block with-errors"></div>
|
|
<div class="txt-red" id="email_Error" style="color:red;font-size: 12.5px !important;"></div>
|
|
</div>
|
|
<!-- <div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1"><?php echo lang('password'); ?></label>
|
|
<input type="password" class="form-control" name="password" id="password"minlength="5" maxlength="10" placeholder="********"
|
|
<?php
|
|
if (empty($user->id))
|
|
echo 'required';
|
|
?>
|
|
>
|
|
</div> -->
|
|
<div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1"><?php echo lang('password'); ?></label>
|
|
<!-- <div class="input-group"> -->
|
|
<input type="password" class="form-control" name="password" id="password"minlength="5" maxlength="10" placeholder="********"
|
|
<?php
|
|
if (empty($user->id))
|
|
echo 'required';
|
|
?>
|
|
>
|
|
<div class="input-group-append" id="passcheckTab" style="display: none;">
|
|
<span class="input-group-text" >
|
|
<span id="passChecking" style="display: none"><i class="la la-hourglass-start" style="color: blue;"></i></span>
|
|
<span id="passErrMin" style="display: none"><i class="la la" style="color: red;">Password must contain atleast 5 characters</i></span>
|
|
<span id="passErrMax" style="display: none"><i class="la la" style="color: red;">Password must contain less than 10 characters</i></span>
|
|
</span>
|
|
</div>
|
|
<!-- </div> -->
|
|
<div class="help-block with-errors"></div>
|
|
</div>
|
|
|
|
</div>
|
|
<?php
|
|
$address = json_decode($user->address);
|
|
?>
|
|
<div class="row">
|
|
<div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1" class="required-field"><?php echo lang('House Number and Street Name'); ?></label>
|
|
<input type="text" class="form-control" name="address" id="address" value='<?php
|
|
if (!empty($setval)) {
|
|
echo set_value('address');
|
|
}
|
|
if (!empty($address)) {
|
|
echo $address->address;
|
|
}
|
|
?>' placeholder="" required data-error="Please enter your permanent address.">
|
|
<div class="help-block with-errors"></div>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1"><?php echo lang('State'); ?></label>
|
|
<input type="text" class="form-control" name="state" id="state" value="<?php echo $address->state; ?>" readonly required data-error="Please enter zipcode and check address.">
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1"><?php echo lang('Country'); ?></label>
|
|
<input type="text" class="form-control" name="county" id="county" value="<?php echo $address->county; ?>" readonly required data-error="Please enter zipcode and check address.">
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1"><?php echo lang('City'); ?></label>
|
|
<input type="text" class="form-control" name="city" id="city" value="<?php echo $address->City; ?>" readonly required data-error="Please enter zipcode and check address.">
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="exampleInputEmail1" class="required-field"><?php echo lang('Zip Code'); ?></label>
|
|
<input type="text" class="form-control" name="zipcode" id="zipcode" minlength="5" maxlength="5" onkeypress="return isNumberKey(event)" value='<?php
|
|
if (!empty($setval)) {
|
|
echo set_value('zipcode');
|
|
}
|
|
if (!empty($address->zipcode)) {
|
|
echo $address->zipcode;
|
|
}
|
|
?>' placeholder="" required data-error="Please enter your zip code.">
|
|
<!-- <div class="help-block with-errors"></div> -->
|
|
<section id="zipcode1Error" class="col-md-12 zipcode1Error"></section>
|
|
</div>
|
|
<div class="form-group col-md-1 mt-2">
|
|
<img src="<?php echo base_url(); ?>uploads/ajax-loader.gif" id="check_parmanent_address_loader" Style="display:none;">
|
|
<button type="button" class="btn btn-info" id="check_parmanent_address_btn" onclick="check_parmanent_address();"><?php echo lang('Check'); ?></button>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="form-group col-md-4">
|
|
<label for="exampleInputEmail1"><?php echo lang('phone'); ?></label>
|
|
<input type="text" class="form-control onlyNumber" name="phone" id="phone" onkeyup="formatPhoneNumber(this.value,this)" minlength="10" maxlength="10" onBlur="formatPhoneNumber(this.value,this)" value='<?php
|
|
if (!empty($setval)) {
|
|
echo set_value('phone');
|
|
}
|
|
if (!empty($user->phone)) {
|
|
echo $user->phone;
|
|
}
|
|
?>' placeholder="" required>
|
|
<div class="txt-red" id="phone_Error" style="color:red;font-size: 12.5px !important;"></div>
|
|
</div>
|
|
|
|
<input type="hidden" name="id" value='<?php
|
|
if (!empty($user->id)) {
|
|
echo $user->id;
|
|
}
|
|
?>'>
|
|
|
|
<div class="btn-group col-md-12">
|
|
<button type="submit" id="submitBtn" name="submit" class="btn btn-default"><?php echo lang('submit'); ?></button>
|
|
<a class="btn btn-info btn-min-width" title="<?php echo lang('Back'); ?>" href="<?php echo base_url(); ?>coordinators" style="margin-left: 10px;">
|
|
<i class="fa fa-undo" aria-hidden="true"></i> <?php echo lang('Back'); ?>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<?php
|
|
if(isset($_SESSION['feedback'])){
|
|
?>
|
|
<script>
|
|
$(function(){
|
|
Swal.fire({
|
|
position: 'center',
|
|
icon: 'error',
|
|
title: '<?php echo $_SESSION['feedback']; ?>',
|
|
showConfirmButton: false,
|
|
timer: 2000
|
|
})
|
|
})
|
|
</script>
|
|
<?php
|
|
}
|
|
?>
|
|
<script type="text/javascript">
|
|
$("#email").blur(function(){
|
|
//alert('1');
|
|
var email=this.value;
|
|
// alert(email);
|
|
$("#emailcheckTab").show();
|
|
$("#emailChecking").show();
|
|
$("#emailAvailable").hide();
|
|
$("#emailNA").hide();
|
|
$("#submitBtn").prop('disabled', true);
|
|
|
|
$.ajax({
|
|
url:'<?php echo base_url(); ?>coordinators/checkEmail?cid=<?php echo $cid?>',
|
|
type:'GET',
|
|
data:{email:email},
|
|
beforeSend: function(){
|
|
$("#emailcheckTab").show();
|
|
$("#emailChecking").show();
|
|
$("#emailAvailable").hide();
|
|
$("#emailNA").hide();
|
|
},
|
|
success:function(data){
|
|
// alert(data);
|
|
// console.log(data);
|
|
if(data){
|
|
$("#emailAvailable").show();
|
|
$("#emailNA").hide();
|
|
$("#submitBtn").prop('disabled', false);
|
|
}else{
|
|
$("#emailAvailable").hide();
|
|
$("#emailNA").show();
|
|
}
|
|
$("#emailcheckTab").show();
|
|
$("#emailChecking").hide();
|
|
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#password").blur(function(){
|
|
|
|
var password=this.value;
|
|
// alert(password);
|
|
if(password!='')
|
|
{
|
|
var pass=$.trim(password);
|
|
// $("#passcheckTab").show();
|
|
if(pass.length<5){
|
|
$("#passcheckTab").show();
|
|
$("#passErrMin").show();
|
|
|
|
}else if(pass.length>10){
|
|
$("#passcheckTab").show();
|
|
$("#passErrMax").show();
|
|
}else{
|
|
$("#passcheckTab").hide();
|
|
$("#passErrMin").hide();
|
|
$("#passErrMax").hide();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
});
|
|
function check_parmanent_address(){
|
|
|
|
var address=$('#address').val();
|
|
var zipcode=$('#zipcode').val();
|
|
if(address!="" && zipcode!=""){
|
|
$.ajax({
|
|
url:"coordinators/checkaddress",
|
|
type:"GET",
|
|
data:{address:address,zipcode:zipcode},
|
|
dataType: "json",
|
|
beforeSend: function() {
|
|
$("#check_parmanent_address_btn").hide();
|
|
$("#check_parmanent_address_loader").show();
|
|
},
|
|
success:function(data){
|
|
//console.log(data);
|
|
if(data.status_code=="200"){
|
|
$('#state').val(data.state);
|
|
$('#county').val(data.county);
|
|
$('#city').val(data.city);
|
|
$('#lang').val(data.lat);
|
|
$('#long').val(data.long);
|
|
$('#contact_info_submit').prop('disabled',false);
|
|
}else{
|
|
Swal.fire({
|
|
position: 'center',
|
|
icon: 'error',
|
|
title: 'address not found.',
|
|
showConfirmButton: false,
|
|
timer: 3500
|
|
});
|
|
//alert('address not found.');
|
|
$('#contact_info_submit').prop('disabled',true);
|
|
}
|
|
$("#check_parmanent_address_btn").show();
|
|
$("#check_parmanent_address_loader").hide();
|
|
}
|
|
});
|
|
}else{
|
|
Swal.fire({
|
|
position: 'center',
|
|
icon: 'error',
|
|
title: 'Enter street address and zipcode.',
|
|
showConfirmButton: false,
|
|
timer: 3500
|
|
});
|
|
//alert('Enter street address and zipcode.');
|
|
}
|
|
}
|
|
function isNumberKey(evt){
|
|
var charCode = (evt.which) ? evt.which : evt.keyCode
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
|
return false;
|
|
return true;
|
|
}
|
|
</script>
|
|
<script>
|
|
function formatPhoneNumber(phoneNumberString,_this) {
|
|
|
|
var cleaned = ('' + phoneNumberString).replace(/\D/g, '')
|
|
if(cleaned.length > 10){
|
|
cleaned = cleaned.substr(0, 10);
|
|
}
|
|
var match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/)
|
|
if (cleaned.length == 10 && match) {
|
|
var intlCode = (match[1] ? '+1 ' : '')
|
|
var fres = [intlCode, '(', match[2], ') ', match[3], '-', match[4]].join('')
|
|
_this.value = fres;
|
|
}else{
|
|
_this.value = cleaned
|
|
}
|
|
return null
|
|
}
|
|
</script>
|
|
<script>
|
|
function validateForm(){
|
|
var has_error =0;
|
|
$("#name_Error").html('');
|
|
$("#email_Error").html('');
|
|
$("#phone_Error").html('');
|
|
|
|
var name = $('#name').val();
|
|
var email = $('#email').val();
|
|
var phone = $('#phone').val();
|
|
|
|
var regex = /^[a-zA-Z ]*$/;
|
|
var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
|
|
|
|
if($.trim(name) == ''){
|
|
$("#name_Error").html('Please enter a valid name.');
|
|
$('#name').focus();
|
|
has_error++;
|
|
return false;
|
|
}
|
|
|
|
if ($.trim(name) !='' && (!regex.test($.trim(name)))){
|
|
$('#name_Error').html("Name field does not contain characters.");
|
|
$('#name').focus();
|
|
has_error++;
|
|
return false;
|
|
}
|
|
if ($.trim(email) !='' && (!ck_email.test($.trim(email)))){
|
|
$('#email_Error').html('Please enter correct email.');
|
|
$('#email').focus();
|
|
has_error++;
|
|
return false;
|
|
}
|
|
|
|
if(phone.length<13){
|
|
$('#phone_Error').html('Phone number must conatian 10 digits.');
|
|
$('#phone').focus();
|
|
has_error++;
|
|
return false;
|
|
}
|
|
|
|
if(has_error == 0){
|
|
$('#submitBtn').submit();
|
|
}
|
|
}
|
|
</script>
|
|
<!--main content end-->
|
|
<!--footer start-->
|