<?php
date_default_timezone_set('Africa/Lagos');
?>

<?php
include '../admin/includes/database.php';
include '../admin/includes/functions.php';
$conn= new Functions();



if(!empty(isset($_POST['phone'])) && isset($_POST['phone'])){
   $phoneInput= $_POST['phone'];
   checkphone($conn, $phoneInput);
  
}
function checkphone($conn, $phoneInput){
    
    
$profilepic = $conn->base_url()."images/profile.json";

$date= date('jS F, Y');
$time= date('h:i A');
$letter = chr(rand(65,71));

  $sql = "SELECT main_url FROM general_settings";
  $conn->query($sql);
  $base_url = $conn->fetchColumn();
  
  $sql = "SELECT id FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $id = $conn->fetchColumn();
  
  $sql = "SELECT firstname FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $firstnames = $conn->fetchColumn();
  $firstname = ucwords ($firstnames);

  $sql = "SELECT surname FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $surnames = $conn->fetchColumn();
   $surname = ucwords ($surnames);
  
  $sql = "SELECT serial FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $serial = $conn->fetchColumn();
  
   $sql = "SELECT occupation FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $occupation = $conn->fetchColumn();
  $occupations = ucwords ($occupation);
  
   $sql = "SELECT church FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $church = $conn->fetchColumn();
   $churchName = ucwords ($church);

  $sql = "SELECT districtID FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $district_id = $conn->fetchColumn();
  
  

   //fetch class name
   $sql = "SELECT name FROM districts WHERE id =:id";
   $conn->query($sql);
   $conn->bind(":id", $district_id);
   $districtName = $conn->fetchColumn();
   
  
  $sql = "SELECT phone FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $phone = $conn->fetchColumn();
  
  
  $sql = "SELECT reg_date FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $reg_date = $conn->fetchColumn();
  
  $sql = "SELECT sex FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $sex = $conn->fetchColumn();
  
  
  $sql = "SELECT conyear FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $conyear = $conn->fetchColumn(); 
  
  $sql = "SELECT reg_date FROM members WHERE phone=:phone";
  $conn->query($sql);
  $conn->bind(":phone", $phoneInput);
  $reg_date = $conn->fetchColumn();


                                            $orgDate = "$reg_date";  
                                            $newDate = date("l, jS F, Y h:i A", strtotime($orgDate));  
                                            
                                            $date = date("$reg_date");
                                            $today = date("Y-m-d H:i:s");
                                            $diff = date_diff(date_create($date), date_create($today));
                                            $diffs = $diff->format('%yyr %mmo %dd %Hh %Im %Ss');
                                            
                                            $regdate =  date('jS F, Y');
                                            
                                            
                                            
  echo "<div class='row'>
  <div class='alert alert-success' style='width: 100%;display: flex;margin-left: 5px;margin-right: 5px;' role='alert'>
                       
                        <strong><i class='pg-icon'>tick_circle </i></strong>Congratulations! Result found for&nbsp;<b> $firstname $surname </b>&nbsp;from&nbsp;<b>$districtName District</b>
                    </div>
                <div class='col-lg-4'>
                        <div id='card-linear' class='card card-default'>
                            <!-- <div class='card-header'>
                                <div class='card-title'>
                                </div>
                                <div class='card-controls'>
                                    <ul>
                                        <li><a href='#' class='card-collapse' data-toggle='collapse'><i class='card-icon card-icon-collapse'></i></a>
                                        </li>
                                        <li><a href='#' id='' class='card-refresh' data-toggle='refresh'><i class='card-icon card-icon-refresh'></i></a>
                                        </li>
                                        <li><a href='#' class='card-close' data-toggle='close'><i class='card-icon card-icon-close'></i></a>
                                        </li>
                                    </ul>
                                </div>
                            </div> -->
                            <div class='card-body'>
                            <lottie-player src='$profilepic'  background='transparent'  speed='1' style='width: 65%;text-align: center;margin-left: auto;margin-right: auto;'  loop  autoplay></lottie-player>
                           

                                        <div class='m-t-30 text-center'>
                                        <h4>$firstname $surname</h4>
                                        </div>

                                        <div class='text-center' style='color: #288855;width: 150px;padding: 2px;margin: auto;font-weight: 600;margin-top: -10px;'>$serial
                                        </div>

                                       


                                        <div class='text-center' style='color: #288855;width: 225px;padding: 6px;border-radius: 15.5px;background-color: rgba(184,251,215,.2);margin: 47px auto;font-weight: 600;'><a href='javascript:void(0); ' data-toggle='modal' data-target='#generateprint' style='font-weight: 700;color:#288855'>
                                        Generate Registration Slip </a> </div>

                        


                            
                            </div>
                        </div>
                        <!-- <div id='card-linear-color' class='card card-default'>
                            <div class='card-header  '>
                                <div class='card-title'>Announcements
                                </div>
                                <div class='card-controls'>
                                    <ul>
                                        <li><a href='#' class='card-collapse' data-toggle='collapse'><i class='card-icon card-icon-collapse'></i></a>
                                        </li>
                                        <li><a href='#' id='newsreload' onclick='loadDoc()' class='card-refresh' data-source='add-member-new.php' data-toggle='refresh'><i class='card-icon card-icon-refresh'></i></a>
                                        </li>
                                        <li><a href='#' class='card-close' data-toggle='close'><i class='card-icon card-icon-close'></i></a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <div class='card-body' id='news'>
                                <?php include('notice.php'); ?>
                            </div>
                        </div> -->
                    </div>
                    <div class='col-xl-8 col-lg-8'>
                <div class='card card-borderless'>
                  <ul class='nav nav-tabs nav-tabs-simple d-none d-md-flex d-lg-flex d-xl-flex' role='tablist' data-init-reponsive-tabs='dropdownfx'>
                    <li class='nav-item'>
                      <a class='active' data-toggle='tab' role='tab' data-target='#tab2profile' href='#'>Quick Profile</a>
                    </li>
                  </ul><div class='nav-tab-dropdown cs-wrapper full-width d-lg-none d-xl-none d-md-none'></div>
                  <div class='tab-content'>
                    <div class='tab-pane active' id='tab2profile' style='margin-bottom: 116px;'>
                      <div class='row column-seperation'>
                        <div class='col-lg-6'>
                       
                        <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                                Joining Date
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>$newDate
                                            </p>
                                            </div>
                                        </div>
                        </div>
                            <!-- profile data -->
                        <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                                District
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>$districtName
                                            </p>
                                            </div>
                                        </div>
                        </div>
                            <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                                Last Conference
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>NCFI ($conyear)
                                            </p>
                                            </div>
                                        </div>
                        </div>
                        <!-- profile data -->
                            <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                                Sex
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>$sex
                                            </p>
                                            </div>
                                        </div>
                        </div>
                        <!-- profile data -->
                          <!-- profile data -->
                          
                        <!-- profile data -->

                        </div>
                        <div class='col-lg-6'>
                            
                            <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                               Total Time in System
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>$diffs
                                            </p>
                                            </div>
                                        </div>
                        </div>
                            <!-- profile data -->
                          <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                                Occupation
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>$occupations
                                            </p>
                                            </div>
                                        </div>
                        </div>
                            <!-- profile data -->
                        <!-- profile data -->
                           <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                                Phone Number
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>$phone
                                            </p>
                                            </div>
                                        </div>
                        </div>
                        <!-- profile data -->
                       
                            <!-- profile data -->
                        <div class='b-b b-grey m-t-30'>
                                        <div class='padding-10'>
                                            <div class='clearfix'>
                                            <p class='bold v-align-middle pull-left no-margin'>
                                                Church
                                            </p>
                                            <p class='text-right v-align-middle pull-right no-margin'>$churchName
                                            </p>
                                            </div>
                                        </div>
                        </div>
                        <!-- profile data -->
                            
                          
                        </div>

                        <div class='text-center' style='color: #288855;width: 124px;padding: 6px;border-radius: 15.5px;background-color: rgba(184,251,215,.2);margin: 50px auto;font-weight: 600;'><a target='_blank' href='$main_url/conference/edit-member/$id' style='font-weight: 700;color:#288855'>
                                        Edit <svg style='height: 16px;width: 16px;display: inline-block;' data-v-3072428e='' viewBox='0 0 16 16' width='1em' height='1em' focusable='false' role='img' aria-label='pencil' xmlns='http://www.w3.org/2000/svg' fill='currentColor' class='bi-pencil b-icon bi'><title data-v-3072428e=''>Update details</title><g data-v-3072428e=''><path d='M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z'></path></g></svg>
                                        </a> </div>
                      </div>
                    </div>

                    
                    
            </div>
        </div>
                        
                    </div>
                    


                </div><div class='modal fade slide-up disable-scroll' id='generateprint' tabindex='-1' role='dialog' aria-hidden='false'>
    <div class='modal-dialog '>
        <div class='modal-content-wrapper'>
            <div class='modal-content text-center' >
                <div class='modal-header clearfix' style='display: block'>
                    <button aria-label='' type='button' class='close' data-dismiss='modal' aria-hidden='true'><i class='pg-icon'>close</i>
                    </button>

                    


                    <h5 style='margin-bottom: -6px'><span class='semi-bold'>Registration Receipt</span></h5>
                    <p class='p-b-10'>Please confirm before printing</p>
                </div>
                <div class='modal-body'>
                   <div class='row d-flex' id='printThis'>
                       <div class='col-xl-12 d-flex printscreen' style='font-size: 12px;'><div class='col-lg-6 text-right'><span class='text-uppercase bold'>First name: </span></div>
                           <div class='col-lg-6 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$firstname</span></div></div>

                       <div class='col-xl-12 d-flex printspan' style='font-size: 16px; padding-right: 0'><div class='col-lg-3 text-right'><span class='text-uppercase'>First name:&nbsp; </span></div>
                           <div class='col-lg-9 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$firstname</span></div></div>

                       <div class='col-xl-12 d-flex printscreen' style='font-size: 12px;'><div class='col-lg-6 text-right'><span class='text-uppercase bold'>Last name: </span></div>
                           <div class='col-lg-6 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$surname</span></div></div>

                       <div class='col-xl-12 d-flex printspan' style='font-size: 12px; padding-right: 0'><div class='col-lg-3 text-right'><span class='text-uppercase'>Last name: &nbsp;</span></div>
                           <div class='col-lg-9 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$surname</span></div></div>

                           <div class='col-xl-12 d-flex printscreen' style='font-size: 12px;'><div class='col-lg-6 text-right'><span class='text-uppercase bold'>Gender: </span></div>
                               <div class='col-lg-6 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$sex</span></div></div>

                       <div class='col-xl-12 d-flex printspan' style='font-size: 12px;  padding-right: 0'><div class='col-lg-3 text-right'><span class='text-uppercase'>Gender: &nbsp;</span></div>
                           <div class='col-lg-9 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$sex</span></div></div>

                               <div class='col-xl-12 d-flex printscreen' style='font-size: 12px;'><div class='col-lg-6 text-right'><span class='text-uppercase bold'>District: </span></div>
                                   <div class='col-lg-6 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$districtName</span></div></div>

                       <div class='col-xl-12 d-flex printspan' style='font-size: 12px; padding-right: 0'><div class='col-lg-3 text-right'><span class='text-uppercase'>District: &nbsp;</span></div>
                           <div class='col-lg-9 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$districtName</span></div></div>

                                   <div class='col-xl-12 d-flex printscreen' style='font-size: 12px;'><div class='col-lg-6 text-right'><span class='text-uppercase bold'>Reg. Date: </span></div>
                                       <div class='col-lg-6 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$regdate</span></div></div>

                       <div class='col-xl-12 d-flex printspan' style='font-size: 12px; padding-right: 0'><div class='col-lg-3 text-right'><span class='text-uppercase'>Reg. Date: &nbsp;</span></div>
                           <div class='col-lg-9 text-left' style='padding-left: 0; text-wrap: none !important;'><span class='text-uppercase bold'>$regdate</span></div></div>

                                       <div class='col-xl-12 d-flex printscreen' style='font-size: 12px;'><div class='col-lg-6 text-right'><span class='text-uppercase bold'>Reg. Time: </span></div>
                        <div class='col-lg-6 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$time</span></div>
                                       </div>

                       <div class='col-xl-12 d-flex printspan' style='font-size: 12px; padding-right: 0'><div class='col-lg-3 text-right'><span class='text-uppercase'>Reg. Time: &nbsp;</span></div>
                           <div class='col-lg-9 text-left' style='padding-left: 0'><span class='text-uppercase bold'>$time</span></div>
                       </div>

                       <div class='col-xl-12 text-center m-t-10 biblescreen' style='font-size: 12px;'><span class='text-uppercase bold'>BIBLE STUDY GROUP</span></div>

                       <div class='col-xl-12 text-center m-t-10 bible' style='font-size: 12px;'><span class='text-uppercase bold'>BIBLE STUDY GROUP</span></div>

                       <div class='col-xl-12 text-center m-t-20 bibles'><span style='font-size: 62pt' class='text-uppercase bold'>$letter</span></div>



                       <div class='col-xl-12 text-center m-t-20 biblescreen' style='font-size: 12px;'><span class='text-uppercase bold'>Cathedral Fund Raising Account</span></div>

                       <div class='col-xl-12 text-center m-t-20 bank' style='font-size: 12px;'><span class='text-uppercase bold'>Cathedral Fund Raising Account</span></div>

                       <div class='col-xl-12 text-center biblescreen' style='font-size: 12px;'><span class='text-uppercase bold'>Zenith Bank | 1014674238</span></div>

                       <div class='col-xl-12 text-center bankd' style='font-size: 12px;'><span class='text-uppercase bold'>Zenith Bank | 1014674238</span></div>


                       <div style='margin-top: 20px' class='col-xl-12 text-center biblescreen'><span style='font-size: 10px' class=''>©Copyright NKC Media</span></div>

                       <div style='margin-top: 20px' class='col-xl-12 text-center copy'><span style='font-size: 12px' class='copy'>©Copyright NKC Media</span></div>



                   </div>


                        <div class='col-xl-12 m-t-50'>
                            <button aria-label='' type='submit' id='btnPrint' class='btn btn-primary btn-lg btn-animated from-left'>
                                <span>Print Receipt</span>
                                <span class='hidden-block'>
													<i class='pg-icon'>tick_circle</i>
												</span></button>
                        </div>

                </div>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
</div>";
                
                
  }
  ?>
  
  <!--        Printout Modal Start-->
<!-- Modal -->

<!-- /.modal-dialog -->
<!--        Printout Modal End-->




    <script>
        document.getElementById("btnPrint").onclick = function () {
            printElement(document.getElementById("printThis"));
        }

        function printElement(elem) {
            var domClone = elem.cloneNode(true);

            var $printSection = document.getElementById("printSection");

            if (!$printSection) {
                var $printSection = document.createElement("div");
                $printSection.id = "printSection";
                document.body.appendChild($printSection);
            }

            $printSection.innerHTML = "";
            $printSection.appendChild(domClone);
            window.print();
        }

    </script>


