<?php
session_start();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];
if(($adminemailid !="")&&($companyname!="")){
require_once('../Control/address.php');
$objaddress=new addressctrl();
require_once('../Control/sales.php');
$objsales=new salesctrl();
require_once('../Control/contact.php');
$objcontact=new contactctrl();

if(isset($_POST['cont_title'])){
    $contnametitle=$_POST['cont_title'];
    $contfirstname=$_POST['cont_first_name'];
    $contlastname=$_POST['cont_last_name'];
    $contjobtitle=$_POST['cont_job_title'];
    $cont_organization=$_POST['cont_organization'];
    
    $contaddresscountry=$_POST['cont_country'];
    $contaddressstate=$_POST['cont_state'];
    $contaddresscity=$_POST['cont_city'];
    $contaddressline=$_POST['cont_address'];
    $contaddresspincode=$_POST['cont_pincode'];
    $contstatus=$_POST['cont_status'];
    $conttag=$_POST['cont_tag'];
    $contleadsource=$_POST['cont_lead'];
    $contbackground=$_POST['cont_background'];
    $contowner=$_POST['cont_owner'];
    $contmakeprivate=$_POST['cont_make_private'];
    $contbirthdate=$_POST['cont_birthday'];
    
    $orgname=$_POST['cont_organization1'];
    $orgdesc=$_POST['cont_org_desc'];
    $orgphone=$_POST['cont_org_phone'];
    $orgurl=$_POST['cont_org_url'];
    $orgcountry=$_POST['cont_org_country'];
    $orgstate=$_POST['cont_org_state'];
    $orgcity=$_POST['cont_org_city'];
    $orgadd=$_POST['cont_org_address'];
    $orgpincode=$_POST['cont_org_pincode'];

    $contphone=$_POST['cont_phone_number'];
    $contphonetype=$_POST['cont_phone_type'];
    $contemail=$_POST['cont_email_name'];
    $contemailtype=$_POST['cont_email_type'];
    $conturl=$_POST['cont_url_name'];
    $conturltype=$_POST['cont_url_type'];
    $ccont=$objsales->salesselectall($companyname, $adminemailid, "sales_contact", "all");
    $cont_count=$ccont->rowCount();
    $contfirstname1=str_replace(' ', '', $contfirstname);
    $contlastname1=str_replace(' ', '', $contlastname);
    $contid=$companyname[0].$companyname[1]."_".$contfirstname1[0]."_".$contlastname1[0]."_".$cont_count;
    $contcreatedby=$adminemailid;
    $contcreatedtype="admin";
    $corg=$objsales->salesselectall($companyname, $adminemailid, "sales_organization", "all");
    $cont_org=$corg->rowCount();
    $orgid=str_replace(' ', '', $orgname)."_".$cont_org."_".$companyname[0];
    if(($contmakeprivate=="on")||($contmakeprivate=="yes")){
        $contmakeprivate="yes";
    }else{
        $contmakeprivate="no";
    }
    date_default_timezone_set("Asia/Kolkata");
    $contdatetime=date("Y-m-d H:i:s");
    $objcontact->salesinsertcontact($companyname, $adminemailid, $contid, $contnametitle, $contfirstname, $contlastname, $contjobtitle, $contaddressline, $contaddresscity, $contaddressstate, $contaddresscountry, $contaddresspincode, $contstatus, $conttag, $contleadsource, $contbackground, $contowner, $contmakeprivate, $contbirthdate, $contdatetime, $contcreatedby, $contcreatedtype, $orgid,  $orgname, $orgdesc, $orgphone, $orgurl, $orgadd, $orgcity, $orgstate, $orgcountry, $orgpincode, $contphone, $contphonetype, $contemail, $contemailtype, $conturl, $conturltype);
}
?>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../../Bootstrap/css/bootstrap.min.css">
        <script src="../../Bootstrap/jquery.min.js"></script>
        <script src="../../Bootstrap/js/bootstrap.min.js"></script>
        <script src="../../Bootstrap/bootstrapAlert.js"></script>
        <link rel="stylesheet" href="Css/addcontact.css">    
        
      
<!-- FormValidation CSS file -->
<link rel="stylesheet" href="../../Formvalidation/formValidation.min.css">
<!-- FormValidation plugin and the class supports validating Bootstrap form -->
<script src="../../Formvalidation/formValidation.min.js"></script>
<script src="../../Formvalidation/framework.min.js"></script>


                
        <!-- Edit Select Picker -->
        <script src="../../Editablepicker/jquery-editable-select.min.js"></script>
        <link href="../../Editablepicker/jquery-editable-select.min.css" rel="stylesheet">
        
        <!-- Select Picker -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
        
        <!-- Latest compiled and minified JavaScript -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
        
        <!-- (Optional) Latest compiled and minified JavaScript translation files -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/i18n/defaults-*.min.js"></script>


  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

    

<script>
$(function(){
    var newdate = new Date();

    newdate.setDate(newdate.getYear() - 10); // minus the date
    
    var date1=newdate.getFullYear() + "-" +(newdate.getMonth()+1) + "-" +newdate.getDate();
    //alert(date1);

    $('#cont_birthday').datepicker({
        dateFormat: 'yy-mm-dd',
        changeMonth: true,
        changeYear: true,
        setDate: date1,
        numberOfMonths: 1,
        showButtonPanel: true,
        closeText: 'Clear',
        onClose: function (dateText, obj) {
            if ($(window.event.srcElement).hasClass('ui-datepicker-close'))
                $("#cont_birthday").val('');
        }
}); 
});

 
 </script>

        
        <script>
            $(document).on("click", "#backtopage", function(){
               window.location.assign("contact_information.php"); 
            });
        </script>
        <style>
            
@media screen and (min-width: 780px) {
    form {
        padding:0% 15%;
    }
}
        </style>
    </head>
    
    <body style="padding-top:20px;">
        

<span  class="view">
<div style="margin:50px 10px 10px 10px;border-style: solid;">
<div class="navbar-inverse">

<span style="color:white;padding-top: 5%;"><i style="align:center;font-size:2em;">Add Contact</i><span id="backtopage" style="cursor:pointer;"><img src="../../Images/backicon.jpg" class="img-circle pull-right" style="align:right;" width="35px" height="35px"></span><br></span>
</div>
<div class="form">

<br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactForm" method="post">

    <div class="form-group">
        
            <div id="messages"></div>
      
    </div>
            <div class="card">
                <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab" style="color:black;">Contact Info</a></li>
                <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab" style="color:black;">Organization Info</a></li>
                <span class="pull-right">
                    <!--<span style="color:grey;cursor:pointer;">Cancel</span>&nbsp;&nbsp;&nbsp;-->
                    <input type="submit" class="btn btn-primary "  disabled="disabled" name="Save">
                </span>
                </ul>
                
                        <script>
                            $(document).on("change", "#cont_organization", function(){
                               var value1=$("#cont_organization").val();
                               $("#cont_organization1").val(value1);
                            });
                        </script>
                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="home">
  
<?php
$res_title=$objsales->salesselectall($companyname, $adminemailid, "sales_contact_title", "no");
//print_r($res_sales);
?>                        
                    <br>
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Title</div>
                        <select name="cont_title" id="cont_title" class="form-control" title="title">
                            <option ></option>
                                    <?php 
                                    foreach($res_title as $row_title){
                                    $c_name=$row_title['contacttitle_name'];
                                    echo "<option value='".$c_name."'>".$c_name."</option>";
                                    }
                                    ?>
                        </select>
                        </div>
                        </div>
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">First Name</div>
                        <input name="cont_first_name" id="cont_first_name" type="text" class="form-control" placeholder="First Name">
                        </div>
                        </div>
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Last Name</div>
                        <input name="cont_last_name" id="cont_last_name" type="text" class="form-control" placeholder="Last Name">
                        </div> 
                        </div>
                    
                    <!--<div class="hidden-md hidden-lg">
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">TiTle</div>
                        <select name="cont_title" id="cont_title" class="form-control" title="title">
                            <option ></option>
                            <option value="Mr">Mr</option>
                            <option value="Mrs">Mrs</option>
                            <option value="Ms">Ms</option>
                        </select>
                        </div>
                        </div>
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">First Name</div>
                        <input name="cont_first_name" id="cont_first_name" type="text" class="form-control" placeholder="First Name">
                        </div>
                        </div>
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Last Name</div>
                        <input name="cont_last_name" id="cont_last_name" type="text" class="form-control" placeholder="Last Name">
                        </div>
                        </div>
                    </div>-->
                   
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Job Title</div>
                        <input name="cont_job_title" id="cont_job_title" type="text" class="form-control" placeholder="Job Title">
                        </div> 
                        </div>
                   

                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Organization</div>
                        <input name="cont_organization" id="cont_organization" type="text" class="form-control" placeholder="Organization">
                        <span class="input-group-addon"><span id="org_check">2</span></span>
                        </div> 
                        </div>
                        
                        <div class="field_wrapper_phone_1">
                            
                        </div>
                        <div class="row">
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">Phone</div>
                        <input class="form-control"  name="cont_phone_number[]" id="cont_phone_number" type="text" placeholder="Phone Number">
                        </div>
                        </div>
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">Phone Type</div>
                        <select class="form-control" name="cont_phone_type[]" id="cont_phone_type">
                            <option></option>
                            <option>Work</option>
                            <option>Mobile</option>
                            <option>Home</option>
                            <option>Direct</option>
                            <option>Fax</option>
                            <option>Skype</option>
                            <option>Other</option>
                        </select>
                        <span class="input-group-addon" style="background-color:green;color:white;cursor:pointer;" id="add_button_phone_1" style="background-color:green">+</span>
                        </div> 
                        </div>
                    </div>
                        <script type="text/javascript">
                            $(document).ready(function(){
                                var maxField = 10; //Input fields increment limitation
                                var addButton_1 = $('#add_button_phone_1'); //Add button selector
                                var wrapper_1 = $('.field_wrapper_phone_1'); //Input field wrapper
                                var inputphone1 = '<div><div class="row"><div class="form-group col-md-6"><div class="input-group"><div class="input-group-addon">Phone</div>';
                                inputphone1 +='<input name="cont_phone_number[]" id="cont_phone_number" type="text" class="form-control" placeholder="Phone Number">';    
                                inputphone1 += '</div></div><div class="form-group col-md-6"><div class="input-group"><div class="input-group-addon">Phone Type</div>';
                                inputphone1 +='<select class="form-control" name="cont_phone_type[]" id="cont_phone_type"><option></option><option>Work</option><option>Mobile</option><option>Home</option><option>Direct</option><option>Fax</option><option>Skype</option><option>Other</option></select>';
                                inputphone1 +='<div class="input-group-addon" style="background-color:red;color:white;cursor:pointer;" id="remove_button_phone_1">-</div>';
                                inputphone1 +='</div></div><hr></div>'; //New input field html 
                                var xphone1 = 1; //Initial field counter is 1
                                $(addButton_1).click(function(){ //Once add button is clicked
                                    if(xphone1 < maxField){ //Check maximum number of input fields
                                        xphone1++; //Increment field counter
                                        $(wrapper_1).append(inputphone1); // Add field html
                                    }
                                });
                                $(wrapper_1).on('click', '#remove_button_phone_1', function(e){ //Once remove button is clicked
                                    e.preventDefault();
                                    $(this).parent('div').parent('div').parent('div').remove(); //Remove field html
                                    xphone1--; //Decrement field counter
                                });
                            });
                        </script>
                        
                        <div class="field_wrapper_email_1">
                            
                        </div>
                        <div class="row">
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">Email</div>
                        <input class="form-control"  name="cont_email_name[]" id="cont_email_name" type="text" placeholder="Email">
                        </div>
                        </div>
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">Email Type</div>
                        <select class="form-control" name="cont_email_type[]" id="cont_email_type">
                            <option></option>
                            <option>Work</option>
                            <option>Home</option>
                            <option>Other</option>
                        </select>
                        <span class="input-group-addon" style="background-color:green;color:white;cursor:pointer;" id="add_button_email_1" style="background-color:green">+</span>
                        </div> 
                        </div>
                    </div>
                        <script type="text/javascript">
                            $(document).ready(function(){
                                var maxField = 10; //Input fields increment limitation
                                var addButton_eml_1 = $('#add_button_email_1'); //Add button selector
                                var wrapper_eml_1 = $('.field_wrapper_email_1'); //Input field wrapper
                                var inputeml1 = '<div><div class="row"><div class="form-group col-md-6"><div class="input-group"><div class="input-group-addon">Email</div>';
                                inputeml1 +='<input name="cont_email_name[]" id="cont_email_name" type="text" class="form-control" placeholder="Email">';       
                                inputeml1 += '</div></div><div class="form-group col-md-6"><div class="input-group"><div class="input-group-addon">Email Type</div>';
                                inputeml1 +='<select class="form-control" name="cont_email_type[]" id="cont_email_type"><option></option><option>Work</option><option>Home</option><option>Other</option></select>';
                                inputeml1 +='<div class="input-group-addon" style="background-color:red;color:white;cursor:pointer;" id="remove_button_email_1">-</div>';
                                inputeml1 +='</div></div><hr></div>'; //New input field html 
                                var xeml1 = 1; //Initial field counter is 1
                                $(addButton_eml_1).click(function(){ //Once add button is clicked
                                    if(xeml1 < maxField){ //Check maximum number of input fields
                                        xeml1++; //Increment field counter
                                        $(wrapper_eml_1).append(inputeml1); // Add field html
                                    }
                                });
                                $(wrapper_eml_1).on('click', '#remove_button_email_1', function(e){ //Once remove button is clicked
                                    e.preventDefault();
                                    $(this).parent('div').parent('div').parent('div').remove(); //Remove field html
                                    xeml1--; //Decrement field counter
                                });
                            });
                        </script>
                                       
                        <div class="field_wrapper_url_1">
                            
                        </div>
                        <div class="row">
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">URL</div>
                        <input class="form-control"  name="cont_url_name[]" id="cont_url_name" type="text" placeholder="Url">
                        </div>
                        </div>
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">Url Type</div>
                        <select class="form-control" name="cont_url_type[]" id="cont_url_type">
                            <option></option>
                            <option>Website</option><option>Blog</option>
                            <option>Twitter</option>
                            <option>LinkedIn</option>
                            <option>Xing</option>
                            <option>Facebook</option>
                            <option>Google+</option>
                            <option>Other</option>
                        </select>
                        <span class="input-group-addon" style="background-color:green;color:white;cursor:pointer;" id="add_button_url_1" style="background-color:green">+</span>
                        </div> 
                        </div>
                    </div>
                        <script type="text/javascript">
                            $(document).ready(function(){
                                var maxField = 10; //Input fields increment limitation
                                var addButton_url_1 = $('#add_button_url_1'); //Add button selector
                                var wrapper__url_1 = $('.field_wrapper_url_1'); //Input field wrapper
                                var inputurl1 = '<div><div class="row"><div class="form-group col-md-6"><div class="input-group"><div class="input-group-addon">URL</div>';
                                inputurl1 +='<input name="cont_url_name[]" id="cont_url_name" type="text" class="form-control" placeholder="Url">'; 
                                inputurl1 += '</div></div><div class="form-group col-md-6"><div class="input-group"><div class="input-group-addon">Url Type</div>';
                                inputurl1 +='<select class="form-control" name="cont_url_type[]" id="cont_url_type"><option></option><option>Website</option><option>Blog</option><option>Twitter</option><option>LinkedIn</option><option>Xing</option><option>Facebook</option><option>Google+</option><option>Other</option></select>';
                                inputurl1 +='<div class="input-group-addon" style="background-color:red;color:white;cursor:pointer;" id="remove_button_url_1">-</div>';
                                inputurl1 +='</div></div><hr></div>'; //New input field html 
                                var xurl1 = 1; //Initial field counter is 1
                                $(addButton_url_1).click(function(){ //Once add button is clicked
                                    if(xurl1 < maxField){ //Check maximum number of input fields
                                        xurl1++; //Increment field counter
                                        $(wrapper__url_1).append(inputurl1); // Add field html
                                    }
                                });
                                $(wrapper__url_1).on('click', '#remove_button_url_1', function(e){ //Once remove button is clicked
                                    e.preventDefault();
                                    $(this).parent('div').parent('div').parent('div').remove(); //Remove field html
                                    xurl1--; //Decrement field counter
                                });
                            });
                        </script>
                   
<?php
$res_country=$objaddress->allcountry();
?>
<div class="row">
                        <div class="form-group col-md-6">
                            <div class="input-group">
                                <div class="input-group-addon">Country</div>
                                <select class=" form-control cont_country" data-live-search="true" data-size="5" id="cont_country" title="select the Country"  name="cont_country" required width="70%">
                                    <option value="" >country</option>
                                    <?php 
                                    foreach($res_country as $row_country){
                                    $c_name=$row_country['name'];
                                    $c_id=$row_country['id'];
                                    echo "<option value='".$c_id."'>".$c_name."</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                   
<script>
    $(document).ready(function(){
       $('#cont_country').selectpicker(); 
       $('#cont_state').selectpicker(); 
       $('#cont_city').selectpicker(); 
    });
</script>
<script>
    $(document).ready(function(){
        $("#cont_country").change(function(){
            var value1=$(this).val();
            //alert(value1);
            $.post("../Control/address.php", {stateallfromcountry: value1}, function(result){
                //alert(result);
        $("#cont_state").html(result);
        $("#cont_state").selectpicker("refresh");
    });
        });
    });
</script>
<script>
    $(document).ready(function(){
        $("#cont_state").change(function(){
            var value1=$(this).val();
            //alert(value1);
            $.post("../Control/address.php", {cityallfromstate: value1}, function(result){
                //alert(result);
        $("#cont_city").html(result);
        $("#cont_city").selectpicker("refresh");
    });
        });
    });
</script>
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">State</div>
                        <select class="form-control cont_state" name="cont_state" id="cont_state" data-live-search="true" data-size="5">
                            <option></option>
                        </select>
                        </div> 
                        </div>
</div>

<div class="row"><div class=" col-md-6">
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">City</div>
                        <select class="form-control cont_city" name="cont_city" id="cont_city" data-live-search="true" data-size="5">
                            <option></option>
                        </select>
                        </div> 
                        </div>
                        
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Pincode</div>
                        <input type="text" name="cont_pincode" id="cont_pincode" class="form-control" placeholder="Pincode"></textarea>
                        </div> 
                        </div>
                  </div> 
                        <div class="form-group col-md-6">
                        <div class="input-group">
                        <div class="input-group-addon">Address</div>
                        <textarea name="cont_address" id="cont_address" class="form-control" placeholder="Address"></textarea>
                        </div> 
                        </div>
</div>                        
                        
              
<?php
$res_sales=$objsales->salesselectall($companyname, $adminemailid, "sales_status", "no");
//print_r($res_sales);
?>                   
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Status</div>
                        <select class="form-control" name="cont_status" id="cont_status">
                            <option></option>
                            <?php 
                            foreach($res_sales as $row_sales){
                            $s_name=$row_sales['status_name'];
                            $s_id=$row_sales['id'];
                            echo "<option value='".$s_id."'>".$s_name."</option>";
                            }
                            ?>
                        </select>
                        </div> 
                        </div>
              
<?php
$res_sales=$objsales->salesselectall($companyname, $adminemailid, "sales_tag", "no");
//print_r($res_sales);
?>                   
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Tag</div>
                        <select class="form-control" name="cont_tag" id="cont_tag">
                            <option></option>
                            <?php 
                            foreach($res_sales as $row_sales){
                            $t_name=$row_sales['tag_name'];
                            $t_id=$row_sales['id'];
                            echo "<option value='".$t_id."'>".$t_name."</option>";
                            }
                            ?>
                        </select>
                        </div> 
                        </div>
              
<?php
$res_sales=$objsales->salesselectall($companyname, $adminemailid, "sales_lead_source", "no");
//print_r($res_sales);
?>                   
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Lead Source</div>
                        <select class="form-control" name="cont_lead" id="cont_lead">
                            <option></option>
                            <?php 
                            foreach($res_sales as $row_sales){
                            $l_name=$row_sales['lead_name'];
                            $l_id=$row_sales['id'];
                            echo "<option value='".$l_id."'>".$l_name."</option>";
                            }
                            ?>
                        </select>
                        </div> 
                        </div>
                        
                        
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Background</div>
                        <textarea name="cont_background" id="cont_background" class="form-control" placeholder="Background"></textarea>
                        </div> 
                        </div>
              
<?php
$res_sales=$objsales->salesselectall($companyname, $adminemailid, "signupdetails", "no");
//print_r($res_sales);
    ?>                  
                        <div class="row">
                            <div class="col-md-8">
                                <div class="form-group">
                                <div class="input-group">
                                <div class="input-group-addon">Owner</div>
                                <select class="form-control" name="cont_owner" id="cont_owner">
                                    <option value="<?php echo $adminemailid;?>" selected>Me</option>
                                    <?php 
                                    foreach($res_sales as $row_sales){
                                    $s_employeename=$row_sales['employeename'];
                                    $s_emailid=$row_sales['emailid'];
                                    if($adminemailid!=$s_emailid){
                                    echo "<option value='".$s_emailid."'>".$s_employeename."(".$s_emailid.")</option>";
                                    }
                                    }
                                    ?>
                                </select>
                                </div> 
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-check">
                                    <label class="form-check-label">
                                      <input type="checkbox" class="form-check-input" id="cont_make_private1" name="cont_make_private1">
                                      Make Private
                                    </label>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" class="form-check-input"  id="cont_make_private" name="cont_make_private">
                            <script>
                                $(document).ready(function(){
                                   $("#cont_make_private1").change(function(){
                                       //alert("zx");
                                        if (this.checked)
                                        {
                                           // alert("on");
                                            $("#cont_make_private").val("yes");
                                        }else{
                                            //alert("off");
                                            $("#cont_make_private").val("no");
                                        }
                                   });
                                });
                            </script>
                    
                        
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Birthday</div>
                        <input type="text" class="form-control" name="cont_birthday" id="cont_birthday" readonly>
                        </div> 
                        </div>
                    
                        
                   
                    </div>
                    <div role="tabpanel" class="tab-pane" id="profile">
                        
                        <br>
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Organization</div>
                        <input name="cont_organization1" id="cont_organization1" type="text" class="form-control" placeholder="Organization" readonly>
                        </div> 
                        </div>

                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Description</div>
                        <textarea name="cont_org_desc" id="cont_org_desc" class="form-control" placeholder="Organization Description"></textarea>
                        </div> 
                        </div>

                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Org-phone</div>
                        <input name="cont_org_phone" id="cont_org_phone" type="text" class="form-control" placeholder="Organization Phone">
                        </div> 
                        </div>

                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Org-url</div>
                        <input name="cont_org_url" id="cont_org_url" type="text" class="form-control" placeholder="Organization Url">
                        </div> 
                        </div>
                   
<?php
$res_country1=$objaddress->allcountry();
?>                        
                        <div class="form-group">
                            <div class="input-group">
                                <div class="input-group-addon">Country</div>
                                <select class=" form-control cont_org_country" data-live-search="true" data-size="5" id="cont_org_country" title="select the Country"  name="cont_org_country" required width="70%">
                                    <option value="" >country</option>
                                    <?php 
                                    foreach($res_country1 as $row_country){
                                    $c_name=$row_country['name'];
                                    $c_id=$row_country['id'];
                                    echo "<option value='".$c_id."'>".$c_name."</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                   
             
<script>
    $(document).ready(function(){
       $('#cont_org_country').selectpicker(); 
       $('#cont_state').selectpicker(); 
       $('#cont_city').selectpicker(); 
    });
</script>
<script>
    $(document).ready(function(){
        $("#cont_org_country").change(function(){
            var value1=$(this).val();
            //alert(value1);
            $.post("../Control/address.php", {stateallfromcountry: value1}, function(result){
                //alert(result);
        $("#cont_org_state").html(result);
        $("#cont_org_state").selectpicker("refresh");
    });
        });
    });
</script>
<script>
    $(document).ready(function(){
        $("#cont_org_state").change(function(){
            var value1=$(this).val();
            //alert(value1);
            $.post("../Control/address.php", {cityallfromstate: value1}, function(result){
                //alert(result);
        $("#cont_org_city").html(result);
        $("#cont_org_city").selectpicker("refresh");
    });
        });
    });
</script>
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Org-State</div>
                        <select class="form-control cont_org_state" name="cont_org_state" id="cont_org_state" data-live-search="true" data-size="5">
                            <option></option>
                        </select>
                        </div> 
                        </div>
                   
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Org-City</div>
                        <select class="form-control cont_org_city" name="cont_org_city" id="cont_org_city" data-live-search="true" data-size="5">
                            <option></option>
                        </select>
                        </div> 
                        </div>
                   
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Org-Address</div>
                        <textarea name="cont_org_address" id="cont_org_address" class="form-control" placeholder="Address"></textarea>
                        </div> 
                        </div>
                   
                        <div class="form-group">
                        <div class="input-group">
                        <div class="input-group-addon">Org-Pincode</div>
                        <input type="text" name="cont_org_pincode" id="cont_org_pincode" class="form-control" placeholder="Pincode"></textarea>
                        </div> 
                        </div>
                        
                    </div>
                </div>
            </div>
       
    </div>


</form>


<script>
    
$(document).ready(function() {
    $('#contactForm').formValidation({
        //message: 'Invalid',
            framework: 'bootstrap',
            icon: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
        fields: {
            cont_owner: {
                validators: {
                    notEmpty: {
                        message: 'Employee Name is required and cannot be empty'
                    }
                }
            },
            
            cont_background: {
                validators: {
                    notEmpty: {
                        message: 'Background is required and cannot be empty'
                    },
                    regexp: {
                        regexp: /^[0-9a-zA-Z\s]+$/,
                        message: 'Background can only consist of alphabetical and space'
                    },
                    stringLength: {
                        min: 5,
                        max: 200,
                        message: 'The Address must be more than 5 and less than 200 characters long'
                    }
                }
            },
            
            cont_lead: {
                validators: {
                    notEmpty: {
                        message: 'Lead Source is required and cannot be empty'
                    }
                }
            },
            
            cont_tag: {
                validators: {
                    notEmpty: {
                        message: 'Tag is required and cannot be empty'
                    }
                }
            },
            
            cont_status: {
                validators: {
                    notEmpty: {
                        message: 'Status is required and cannot be empty'
                    }
                }
            },
            
            cont_pincode: {
                validators: {
                    notEmpty: {
                        message: 'Pincode is required and cannot be empty'
                    },
                      regexp: {
                        regexp: /^[0-9]+$/,
                        message: 'Pincode can only consist of Number'
                    },
                    stringLength: {
                        min: 5,
                        max: 10,
                        message: 'The Pincode must be more than 5 and less than 10 Number'
                    }
                }
            },
            
            cont_address: {
                validators: {
                    notEmpty: {
                        message: 'Customer name is required and cannot be empty'
                    },
                      regexp: {
                        regexp: /^[\[\]\\_={}$&+,:;=?@#|'<>.^*()%!-0123456789a-zA-Z\s]+$/,
                        message: 'The Address can only consist of alphanumeric and space'
                    },
                    stringLength: {
                        min: 6,
                        max: 100,
                        message: 'The Address must be more than 6 and less than 100 characters long'
                    }
                }
            },
            
            cont_city: {
                validators: {
                    notEmpty: {
                        message: 'City is required and cannot be empty'
                    }
                }
            },
            
            cont_state: {
                validators: {
                    notEmpty: {
                        message: 'State is required and cannot be empty'
                    }
                }
            },
            
            cont_country: {
                validators: {
                    notEmpty: {
                        message: 'Country is required and cannot be empty'
                    }
                }
            },
            /*
            'cont_url_type[]': {
                validators: {
                    notEmpty: {
                        message: 'Type of Travel is required and cannot be empty'
                    }
                }
            },
            
            'cont_email_type[]': {
                validators: {
                    notEmpty: {
                        message: 'Type of Travel is required and cannot be empty'
                    }
                }
            },
            
            'cont_phone_type[]': {
                validators: {
                    notEmpty: {
                        message: 'Type of Travel is required and cannot be empty'
                    }
                }
            },*/
            
            cont_organization: {
                validators: {
                    notEmpty: {
                        message: 'Organization is required and cannot be empty'
                    },
                  regexp: {
                        regexp: /^[\[\]\\_={}$&+,:;=?@#|'<>.^*()%!-0123456789a-zA-Z\s]+$/,
                        message: 'Organization can only consist of alphabetical and space'
                    },
                    stringLength: {
                        min: 5,
                        max: 200,
                        message: 'The Address must be more than 5 and less than 200 characters long'
                    }
                }
            },
            
            cont_job_title: {
                validators: {
                    notEmpty: {
                        message: 'Job Title is required and cannot be empty'
                    },
                  regexp: {
                        regexp: /^[\[\]\\_={}$&+,:;=?@#|'<>.^*()%!-0123456789a-zA-Z\s]+$/,
                        message: 'Job Title can only consist of alphabetical and space'
                    },
                    stringLength: {
                        min: 5,
                        max: 200,
                        message: 'The Address must be more than 5 and less than 200 characters long'
                    }
                }
            },
            
            cont_last_name: {
                validators: {
                    notEmpty: {
                        message: 'Last Name is required and cannot be empty'
                    },
                  regexp: {
                        regexp: /^[a-zA-Z\s]+$/,
                        message: 'Last Name can only consist of alphabetical and space'
                    },
                    stringLength: {
                        min: 1,
                        max: 100,
                        message: 'The Address must be more than 1 and less than 100 characters long'
                    }
                }
            },
            
            cont_first_name: {
                validators: {
                    notEmpty: {
                        message: 'First Name is required and cannot be empty'
                    },
                  regexp: {
                        regexp: /^[a-zA-Z\s]+$/,
                        message: 'First Name can only consist of alphabetical and space'
                    },
                    stringLength: {
                        min: 3,
                        max: 100,
                        message: 'The Address must be more than 5 and less than 100 characters long'
                    }
                }
            },
            
            cont_organization1: {
                validators: {
                  regexp: {
                        regexp: /^[0-9a-zA-Z\s]+$/,
                        message: 'First Name can only consist of alphabetical and space'
                    }
                },
                    stringLength: {
                        max: 150,
                        message: 'The Address must be less than 150 characters long'
                    }
            },
            
            cont_org_desc: {
                validators: {
                  regexp: {
                        regexp: /^[\[\]\\_={}$&+,:;=?@#|'<>.^*()%!-0123456789a-zA-Z\s]+$/,
                        message: 'First Name can only consist of alphabetical and space'
                    },
                    stringLength: {
                        max: 500,
                        message: 'The Address must be less than 500 characters long'
                    }
                }
            },
            
            cont_org_phone: {
                validators: {
                  regexp: {
                        regexp: /^[0-9]+$/,
                        message: 'First Name can only consist of alphabetical and space'
                    },
                    stringLength: {
                        max: 20,
                        message: 'The Address must be less than 20 characters long'
                    }
                }
            },
            
            cont_org_url: {
                validators: {
                  regexp: {
                        regexp: /^[\[\]\\_={}$&+,:;=?@#|'<>.^*()%!-0123456789a-zA-Z\s]+$/,
                        message: 'Url can only consist of alphanumeric and space'
                    },
                    stringLength: {
                        max: 200,
                        message: 'The url must be less than 200 characters long'
                    }
                }
            },
            
            cont_org_address: {
                validators: {p: {
                        regexp: /^[\[\]\\_={}$&+,:;=?@#|'<>.^*()%!-0123456789a-zA-Z\s]+$/,
                        message: 'Address can only consist of alphanumeric and space'
                    },
                    stringLength: {
                        max: 200,
                        message: 'The Address must be less than 200 characters long'
                    }
                }
            },
            
            cont_org_pincode: {
                validators: {
                  regexp: {
                        regexp: /^[0-9]+$/,
                        message: 'pincode can only consist of Number'
                    },
                    stringLength: {
                        max: 10,
                        message: 'The pincode must be less than 10 characters long'
                    }
                }
            }
   
        }  
    })
        .on('success.field.fv', function(e, data) {
            if (data.fv.getInvalidFields().length > 0) {    // There is invalid field
                data.fv.disableSubmitButtons(true);
            }
        });
});
               
</script>

</div>
</div>
</span>
        
    </body>
    
</html>

<?php
}else{
echo "<script> location.replace('http://fieldcloud.in/Login.php') </script>";
}?>