<?php
include_once("../include/main.inc.php");
check_session('MyCpanel','index.php');
$title = "Admin Login Panel";
admin_header();

$cat_count = get_category_count();
$enquiry_count = get_enquiry_count();
$enquirypermonths_count = get_enquiry_per_monthscount();
$location_count = get_location_count();
$blog_count = get_blog_count();
?>

      <div class="row dash-stats">
        <div class="col-lg-4 col-sm-6">
          <a  style="text-decoration: none;"href="<?= SITE_ADMIN_URL;?>/manage_categories.php">
            <div class="tb-iconbox tb-style4 tb-color1">
              <div class="tb-icon tb-flex">
                <i class="fa fa-users"></i>
              </div>
              <div class="tb-iconbox-text">
                <h3 class="tb-iconbox-heading"><?= $cat_count ?></h3>
                <div class="tb-iconbox-sub-heading">Total Categories</div>
              </div>
            </div>
          </a>
        </div>
        <div class="col-lg-4 col-sm-6">
          <a  style="text-decoration: none;"href="<?= SITE_ADMIN_URL;?>/manage_locations.php">
          <div class="tb-iconbox tb-style4 tb-color1">
            <div class="tb-icon tb-flex">
              <i class="fa fa-question-circle"></i>
            </div>
            <div class="tb-iconbox-text">
              <h3 class="tb-iconbox-heading"><?= $location_count ?></h3>
              <div class="tb-iconbox-sub-heading">Total Locations</div>
            </div>
          </div></a>
        </div>
        <div class="col-lg-4 col-sm-6">
          <a  style="text-decoration: none;"href="#">
          <div class="tb-iconbox tb-style4 tb-color1">
            <div class="tb-icon tb-flex">
              <i class="fa fa-newspaper-o"></i>
            </div>
            <div class="tb-iconbox-text">
              <h3 class="tb-iconbox-heading"><?= ($location_count*$cat_count) ?></h3>
              <div class="tb-iconbox-sub-heading">Total Locationwise Keywords</div>
            </div>
          </div></a>
        </div>
      </div>

      <div class="row dash-stats">
        <div class="col-lg-4 col-sm-6">
          <a  style="text-decoration: none;"href="<?= SITE_ADMIN_URL;?>/manage_enquiry.php">
          <div class="tb-iconbox tb-style4 tb-color1">
            <div class="tb-icon tb-flex">
              <i class="fa fa-map-marker"></i>
            </div>
            <div class="tb-iconbox-text">
              <h3 class="tb-iconbox-heading"><?= $enquiry_count ?></h3>
              <div class="tb-iconbox-sub-heading">Total Enquiries</div>
            </div>
          </div></a>
        </div>

        <div class="col-lg-4 col-sm-6">
          <a  style="text-decoration: none;"href="<?= SITE_ADMIN_URL;?>/manage_enquiry.php">
          <div class="tb-iconbox tb-style4 tb-color1">
            <div class="tb-icon tb-flex">
              <i class="fa fa-map-marker"></i>
            </div>
            <div class="tb-iconbox-text">
              <h3 class="tb-iconbox-heading"><?= $enquirypermonths_count ?></h3>
              <div class="tb-iconbox-sub-heading">Current Months Enquiries</div>
            </div>
          </div></a>
        </div>

        <div class="col-lg-4 col-sm-6">
          <a  style="text-decoration: none;"href="<?= SITE_ADMIN_URL;?>/manage_blog.php">
          <div class="tb-iconbox tb-style4 tb-color1">
            <div class="tb-icon tb-flex">
              <i class="fa fa-map-marker"></i>
            </div>
            <div class="tb-iconbox-text">
              <h3 class="tb-iconbox-heading"><?= $blog_count ?></h3>
              <div class="tb-iconbox-sub-heading">Total Blogs</div>
            </div>
          </div></a>
        </div>
      </div>
      <?php 
      $today = date('Y-m-d');
      $query = mysqli_query($dbconn,"SELECT * FROM tbl_enquiry order by en_id desc limit 5");
      if(mysqli_num_rows($query) > 0){$i=1;?>
        <div class="col-lg-12">
          <div class="text-center">
            <span class="heading">Todays Enquiry</span> <span class="pull-right"><a href="<?= SITE_ADMIN_URL;?>/manage_enquiry.php">View All</a></span>
          </div>
          <div class="table-responsive">

            <table class="table table-striped">

              <thead>
                <tr>
                  <th>S.No.</th>
                  <th>Enquiry Details</th>
                  <th>Sender Details</th>
                  <th>Actions</th>
                </tr>  
              </thead>
              <tbody>
                <?php while($enquiry = mysqli_fetch_array($query)){
                if($enquiry['en_zcode'] != '') {  
                    $mobileNumbers = '+' . $enquiry['en_zcode'] . ' - ' . $enquiry['en_mobile'];
                } else { 
                    $mobileNumbers = $enquiry['en_mobile'];
                }
                ?>
                  <tr>
                    <td><?= $i++ ?></td>
                    <td>
                      Name: <b><?=$enquiry['en_name'];?></b> <br /> 
                      <?php if ($enquiry['en_email'] != '') { ?>
                      Email: <b><?=$enquiry['en_email'];?></b>  <br />
                      <?php
               } else { ?>
            <?php
               } ?>
                      Mobile: <b><?=$mobileNumbers;?></b>  <br />
                      <?php if ($enquiry['en_country_name'] != '') { ?>
                      Country: <b><?=$enquiry['en_country_name'];?></b> 
                      <?php
               } else { ?>
            <?php
               } ?>
                    </td>
                    <td>
                      Sender Ip Address: <b><?=$enquiry['en_ip'];?></b>  <br />   
                      Message: <b><?=$enquiry['en_comment'];?></b>  <br /> 
                      URl: <b><?=$enquiry['en_url'];?></b>  
                    </td>
                    <td>

                    <?php if ($enquiry['en_country'] != '') { ?> 
    Location: <b><?= $enquiry['en_country']; ?></b> <br />
<?php } ?>


<?php if ($enquiry['en_quantity'] != '') { ?>
    Quantity: <b><?= $enquiry['en_quantity']; ?></b> <br />
<?php } ?>
                      <?php if ($enquiry['en_mobile'] != ''){?>
                          <a href="tel:<?= $enquiry['en_mobile'] ?>" title="Call Now"><i class="fa fa-phone call-to-action"></i></a>&nbsp;
<!--                          <a href="https://wa.me/91<?= $enquiry['en_mobile'] ?>" title="Whatsapp"><i class="fa fa-whatsapp call-to-action"></i></a>-->
                      <?php } ?>
                       <?php if ($enquiry['en_email'] != ''){?>
                          <a href="mailto:<?= $enquiry['en_email'] ?>" title="Mail Now"><i class="fa fa-envelope-o call-to-action"></i></a>&nbsp;
                      <?php } ?>
                    </td>
                </tr> 
                <?php }?>
              </tbody>
            </table>
          </div>
        </div>
      <?php }
      ?>
      



<?php
admin_footer();

?>

