<?php
ob_start();
session_start();

function check_session($sess_name, $REDIRECT_URL) {
  if (!strlen($_SESSION[$sess_name])) {
    header("Location:$REDIRECT_URL");
    exit;
  }
}

function admin_header($sitetitle = "") { //admin_full_header.
  ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title><?=ucfirst($_SESSION['ADMIN_DIR']); ?></title>
      <meta charset="utf-8">

        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
          <link href="styles.css" rel="stylesheet" type="text/css" />	 
          <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />	 
          <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />	
    
          <script type="text/javascript" src="<?= site_url; ?>/js/validation.js"></script>
          <script type="text/javascript" src="<?= site_url; ?>/js/showHint.js"></script>
          <script type="text/javascript" src="<?= site_url; ?>/js/common.js"></script>
          <script language="javascript" src="js/admin.js"></script>
          <!-- <script type="text/javascript" src="fckeditor/fckeditor.js"></script> -->
          <script src="./ckeditor/ckeditor.js"></script>	 
          <script src="./ckfinder/ckfinder.js"></script>	 
          <script type="text/javascript" src="js/bootstrap.min.js"></script>
        <link rel="preconnect" href="https://fonts.googleapis.com">
       <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
       <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
            <!-- fontawesome -->
            
            <script type="text/javascript" src="<?= site_url; ?>/cmadmin/js/main.js"></script>
              <script type="text/javascript" src="<?= site_url; ?>/cmadmin/js/font-awesome.js"></script>
            </head>
            <body>

              <div>
                <div class="content-100">
                  <div class="content-20">
                     <div class="nav-menu">
                      
                      <?php
                  if (isset($_SESSION['MyCpanel'])) {
                    ?>
   
                 
                        
                          <?php
                          if ($_SESSION['MyAdminUserType'] == "admin") {
                            ?>
    <div class="side-bar">
        <div class="icon-btn">
            <i class="fas fa-bars"></i>
        </div>
        <div class="close-btn">
            <i class="fas fa-times"></i>
        </div>
        <div class="menu">
             <div class="logo-content">
                          
                                <img alt="Control Panel" hspace=20 src="<?=theme_url;?>/images/logo.jpg">
                          
                             <p><a href="<?= site_url; ?>" title="<?=COMPANY_NAME;?>" class="bb-0" target="_blank"><i class="fas fa-globe"></i><?=COMPANY_NAME;?></a></p>
                       
                        </div> 
            <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/manage_categories.php">
                 <i class="fas fa-desktop"></i>
                    <span>Manage Categories</span>
                </a>
            </div>
            
            <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/manage_products.php">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Product</span>
                </a>
            </div> 
            <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/manage_banners.php">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Banners</span>
                </a>
            </div>
                <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/manage_blog.php">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Blog Article</span>
                </a>
                          </div>
                <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/manage_locations.php">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Locations</span>
                </a>
            </div>
            <div class="item">
                <a href="#" class="sub-btn">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Static Pages</span>
                    <i class="fas fa-tasks-alt"></i>
                </a>      
                <div class="sub-menu">
                               <?php
                              $spQry = mysqli_query($GLOBALS['dbconn'], "select pageID, pageTitle from static_pages");
                              while ($spRes = mysqli_fetch_array($spQry)) {
                                ?>
                               <a href="<?= SITE_ADMIN_URL; ?>/page-content.php?cid=<?= $spRes['pageID']; ?>" class="sub-item"><?= $spRes['pageTitle']; ?></a> 
                                <?php
                              }
                              ?>
                </div>
            </div> 
            <div class="item">
            <a href="<?=SITE_ADMIN_URL;?>/manage_success_stories.php" class="sub-item">Manage Success Story</a>
            </div>
              <div class="item">
                <a href="#" class="sub-btn">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Meta Tags</span>
                    <i class="fas fa-angle-right dropdown"></i>
                </a>
                <div class="sub-menu">
                     <a href="<?= SITE_ADMIN_URL; ?>/manage_standardmetatags.php">Standard Meta Tags</a>
                     <a href="<?= SITE_ADMIN_URL; ?>/manage_subdomainmetatag.php">Subdomain Standard Meta Tags</a>
                      <a href="<?=SITE_ADMIN_URL;?>/manage_location_content.php?category_id=0">Subdomain Home Content</a>
                </div>
            </div>
            <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/home-pointer.php">
                    <i class="fas fa-home"></i>
                    <span>Homepage Pointer</span>
                </a>
            </div>
            <div class="item">
                <a href="#" class="sub-btn">
                    <i class="fas fa-user"></i>
                    <span>Admin Section</span>
                    <i class="fas fa-angle-right dropdown"></i>
                </a>
                <div class="sub-menu">
                       <a href="<?= SITE_ADMIN_URL; ?>/myaccount.php">Manage Admin Details</a>
                       <a href="<?= SITE_ADMIN_URL; ?>/manage_user.php">Manage Sub Admin</a>
                              <a href="<?= SITE_ADMIN_URL; ?>/admin_change_pass.php">Change Username & Password</a>
                              <a href="<?= SITE_ADMIN_URL; ?>/index.php?id1=Logout">Logout</a>
                </div>
            </div>
        </div>
    </div>       
                              <?php
                            } else{
                              ?>
                              <div class="side-bar">
        <div class="icon-btn">
            <i class="fas fa-bars"></i>
        </div>
        <div class="close-btn">
            <i class="fas fa-times"></i>
        </div>
        <div class="menu">
             <div class="logo-content">
                          
                                <img alt="Control Panel" hspace=20 src="<?=theme_url;?>/images/logo.jpg">
                          
                             <p><a href="<?= site_url; ?>" title="<?=COMPANY_NAME;?>" class="bb-0" target="_blank"><i class="fas fa-globe"></i><?=COMPANY_NAME;?></a></p>
                       
                        </div> 
            <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/manage_products.php">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Product</span>
                </a>
            </div>
            <div class="item">
                <a href="<?= SITE_ADMIN_URL; ?>/manage_enquiry.php">
                  <i class="fas fa-desktop"></i>
                    <span>Manage Enquiry</span>
                </a>
            </div>
            <div class="item">
                <a href="#" class="sub-btn">
                    <i class="fas fa-user"></i>
                    <span>Admin Section</span>
                    <i class="fas fa-angle-right dropdown"></i>
                </a>
                <div class="sub-menu">
                  <a href="<?= SITE_ADMIN_URL; ?>/index.php?id1=Logout">Logout</a>
                </div>
            </div>
        </div>
    </div>
                              <?php
                            }
                            ?>
                     <?php
                  }
                  ?>
                        </div>
                    </div>
                  <div class="content-80">
                    
 
                  <div class="sec-content">
                      <div class="header-style">
                        
                        <div class="content-100 bg-grey">
                            <div class="content-33 content-xs-50">
                          <div class="menu-btn">
                             <p><i class="fas fa-list"></i> Menu</p>
                          </div>
                                
                          <div class="menu-btn-xs">
                             <p><i class="fas fa-list"></i> Menu</p>
                          </div>
                          </div>
<!--
                          <div class="content-33 content-xs-50">
                             <img alt="Control Panel" hspace=20 src="<?=site_url;?>/designer/images/logo.jpg">
                           </div> 
-->
                          <div class="content-33 content-xs-25 d-none-xs">
                             <p><a href="<?=SITE_ADMIN_URL; ?>" title="<?=COMPANY_NAME;?>" class="bb-0" target="_blank"><i class="fas fa-globe"></i><?=COMPANY_NAME;?></a></p>
                          </div> 
                          </div>
                   
                         </div>
                     <div class="content-padding">
                
                         <div class="clearfix"></div>
                         
                        <?php
                      }

                      function admin_footer() {//footer for control panel...
                        ?>
                      </div>
                  </div>
                    </div>                 
                </div>
              </div>
              <div id="footer">
                <table cellspacing=0 cellpadding=0 width="100%" border=0>
                  <tr bgcolor="#f1f1f1"><td height=50>&nbsp;Copyright &copy; <?= date("Y"); ?> &nbsp; <?=$_SESSION['companyName']; ?>&nbsp;All Rights Reserved. <br /></td></tr>
                </table>
              </div>
              <script type="text/javascript" src="<?= SITE_ADMIN_URL; ?>/js/jquery.js"></script>
              <script type="text/javascript">
                $(function () {
                  $textarea = $('textarea');
                  $.each($textarea, function (index, value) {
                    let id = $(this).attr('id');
                    let ckeditor = CKEDITOR.replace(id);
                    // let ckeditor = CKEDITOR.replace(id, {
                    // 	filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
                    //  			filebrowserUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                    //  			// extraPlugins : 'filebrowser'

                    // });
                    // CKFinder.setupCKEditor( ckeditor );
                  });
                })
              </script>
            </body></html>
            <?php
          }

          function pop_header($title) {
            ?>
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
              <head>
                <title><?= $title; ?></title>
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                <link href="<?= SITE_ADMIN_URL; ?>/admin.css" rel="stylesheet" type="text/css" />
                <script language="javascript" src="admin_js.js"></script>
              </head>
              <body>
                <p bgcolor="#f1f1f1" align="center"><br><a href="javascript:void(0);" OnClick="javascript:window.close();">Close Window</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" OnClick="javascript:window.print();">Print Details</a></p>
                <?php
              }

              function pop_footer() {
                ?>
                <br /><br />
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
        <td align="center" bgcolor="#f1f1f1"><strong>Copyright <?= date('Y'); ?> &copy; <?=$_SESSION['companyName']; ?></strong></td>
                  </tr>
                </table>
                <p bgcolor="#f1f1f1" align="center"><br><a href="javascript:void(0);" OnClick="javascript:window.close();">Close Window</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" OnClick="javascript:window.print();">Print Details</a></p>
              </body>
            </html>
            <?php
          }

          function admin_change_pass() {
            $res = getResult("admin_details", " where user_id='" . $_SESSION['MyAdminUserID'] . "' and user_type='" . $_SESSION['MyAdminUserType'] . "'");
            ?>
            <script type="text/javascript">
              function validate_form() {
                var frm = document.chgPwd;
                if (frm.username.value == 0) {
                  alert("Please enter username");
                  frm.username.focus();
                  return false;
                }
                if (frm.old_password.value == 0) {
                  alert("Please enter your current password");
                  frm.old_password.focus();
                  return false;
                }
                if (frm.password.value == 0) {
                  alert("Please enter your new password");
                  frm.password.focus();
                  return false;
                }
                if (frm.repassword.value == 0) {
                  alert("Please confirm your new password");
                  frm.repassword.focus();
                  return false;
                }
                if (frm.password.value != frm.repassword.value) {
                  alert("Password and Confirm Password mismatched");
                  frm.repassword.focus();
                  return false;
                }
              }
            </script>
 
            <form action="" method="post" name="chgPwd" id="chgPwd" onsubmit="return validate_form();">
                
                <div class="form-group">
                     <?php
                    if ($_SESSION['session_message'] != '') {
                      echo '<font color="#C05813"></font><br>';
                    }
                    ?>
                </div>
                <div class="form-group">
                    <label>Username:<span>*</span></label>
                    <input type="text" name="username" value="<?= $res['user_id']; ?>" class="form-control">
                </div>
                  <div class="form-group">
                    <label>Current Password:<span>*</span></label>
                    <input type="password" name="old_password" class="form-control" placeholder="Enter Current Password">
                </div>
                  <div class="form-group">
                    <label>New Password:<span>*</span></label>
                    <input type="password" name="password" placeholder="Enter New Password" class="form-control">
                </div>
                  <div class="form-group">
                    <label>Confirm Password:<span>*</span></label>
                    <input type="password" name="repassword" placeholder="Enter Confirm Password" class="form-control">
                </div>
                <div class="form-group">
                   <input type="button" name="imageField" Value="Submit" class="btn btn-success"/>
                    <input type="hidden" name="action" value="Update">
                </div>
            </form>
            <?php
          }

          function welcome() {
            $q = getResult("admin_details", " where user_id='" . $_SESSION['MyAdminUserID'] . "' and user_type='" . $_SESSION['MyAdminUserType'] . "'");
            ?>
            <div align="left"><font color="red"><strong>Last Login At ::</strong></font>  <?= showdatetime($q['last_login']); ?></div>
            <hr size="2" width="100%" color="#92B2D6">
              <br/><br/><br/>
              <table width="80%" align="center" cellpadding="5" cellspacing="0" border="0">
                <tr><td align="center"><marquee behavior="alternate"><font color="navy" size="3"><?= WEBSITE_NAME; ?><br/><br/>Administrator Work Area</font></marquee></td></tr>
              </table> 
              <?php
            }

            function addEditLinks($id) {
              $num = getCount("static_pages", " where pageID='$id'");
              if ($num > 0) {
                $res = getResult("static_pages", " where pageID='$id'");
                echo '<script type="text/javascript">document.getElementById("pgtitle _Container").innerHTML="' . $res['pageTitle'] . '";</script>';
                $var1 = '
		
		
		<form method="post" action="" name="faqfrm" enctype="multipart/form-data">
        <div class="form-group">
        <label> Content (<font color="red">*</font>) mandatory fields</label>
        <textarea name="pageDesc" id="pageDesc" rows=10 cols=100  class="form-control">' . $res['pageDesc'] . '</textarea>
        </div>
        
         <div class="form-group">
        <label> Content-Desc1 (<font color="red">*</font>) mandatory fields</label>
        <textarea name="pageDesc1" id="pageDesc1" rows=10 cols=100  class="form-control">' . $res['pageDesc1'] . '</textarea>
        </div>
        
         <div class="form-group">
        <label> Meta Title (<font color="red">*</font>) mandatory fields</label>
        <input type="text" name="mtitle" id="mtitle" rows=10 cols=100  class="form-control" value=" ' .$res['page_metatitle'].'">
        </div>
        
        <div class="form-group">
        <label> Meta Keyword (<font color="red">*</font>) mandatory fields</label>
       <input type="text" name="mkeyword" id="mtitle" rows=10 cols=100  class="form-control" value=" ' .$res['page_keyword'].'">
        </div>
        
        <div class="form-group">
        <label> Meta Desc (<font color="red">*</font>) mandatory fields</label>
       
        <textarea name="mdesc" rows=7 cols=50  class="form-control txtfieldadmin">' . $res['page_metadesc'] . '</textarea>
        </div>
        
        <div class="form-group">
        <label> Page Banner (<font color="red">*</font>) </label>
        <input type="file" name="banner" class="form-control"/>';
                if ($res['pageBanner'] != '') {
                  $banner = site_url . "/uploaded-files/page-banners/" . $res['pageBanner'];
                  if (file_exists($banner)) {
                    $dimens = GetImageSize($banner);
                    if ($dimens[0] > 130) {
                      $dimens[0] = $dimens[0] + 50;
                      $dimens[1] = $dimens[1] + 80;
                    } else {
                      $dimens[0] = 200;
                      $dimens[1] = 200;
                    }
                    $var1 .= "&nbsp;<a href=\"javascript:void(0);\" onClick=\"openwin('" . SITE_ADMIN_URL . "/popup_new.php?img=page-banners/" . $res['pageBanner'] . "', '$dimens[0]', '$dimens[1]')\" class=\"linkgray fontbold\"><b>View Image</b></a>&nbsp; <strong><a href=" . SITE_ADMIN_URL . "/page-content.php?cid=" . $id . "&id=remove_image&field=pageBanner\">Remove</a></strong>";
                  }
                }
                $var1 .= "&nbsp;<a href=\"javascript:void(0);\" onClick=\"openwin('" . SITE_ADMIN_URL . "/popup_new.php?img=page-banners/" . $res['pageBanner'] . "', '$dimens[0]', '$dimens[1]')\" class=\"linkgray fontbold\"><b>View Image</b></a>&nbsp; <strong><a href=" . SITE_ADMIN_URL . "/page-content.php?cid=" . $id . "&id=remove_image&field=pageBanner\">Remove</a></strong>";
                $var1 .= '</div>
         <div class="form-group">
        <label>Page Image <font color="red">*</font></label>
        <input type="file" name="image" class="form-control" />';
                if ($res['pageImage'] != '') {
                  $banner = site_url . "/uploaded-files/page-images/" . $res['pageImage'];
                  if (file_exists($banner)) {
                    $dimens = GetImageSize($banner);
                    if ($dimens[0] > 130) {
                      $dimens[0] = $dimens[0] + 50;
                      $dimens[1] = $dimens[1] + 80;
                    } else {
                      $dimens[0] = 200;
                      $dimens[1] = 200;
                    }
                    $var1 .= "&nbsp;<a href=\"javascript:void(0);\" onClick=\"openwin('" . SITE_ADMIN_URL . "/popup_new.php?img=page-images/" . $res['pageImage'] . "', '$dimens[0]', '$dimens[1]')\" class=\"linkgray fontbold\"><b>View Image</b></a>";
                  }
                }

                $var1 .= '</div>
            <div class="form-group">
            <input type="hidden" name="st_id" value="' . $id . '">
            <input type="submit" name="add_ct" value="Save" class="button">
            </div></form>';

                $var1 .= '
		<script type="text/javascript">
		 var oFCKeditor = new FCKeditor(\'pageDesc\');
		 oFCKeditor.BasePath = "fckeditor/";
		 oFCKeditor.ReplaceTextarea() ;
		</script>';

                $var1 .= '
		<script type="text/javascript">
		 var oFCKeditor = new FCKeditor(\'pageDesc1\');
		 oFCKeditor.BasePath = "fckeditor/";
		 oFCKeditor.ReplaceTextarea() ;
		</script>';
              } else {
                echo '<script type="text/javascript">document.getElementById("pgtitle _Container").innerHTML="????";</script>';
                $var1 = '<br><br><center>No Record Found</center>';
              }

              return $var1;
            }

            function validate_session() {
              $mem = explode("~", $_SESSION['SessionId']);
              $res = getResult("admin_details", " where adminId='$mem[0]'");
              $un1 = substr(md5($res['username']), 0, 10);
              $pn1 = substr(md5($res['pwd']), 0, 10);
              if ($un1 == $mem[1] && $pn1 == $mem[2]) {
                return "V";
              } else {
                return "I";
              }
            }

            function adminName() {
              $mem = explode("~", $_SESSION['SessionId']);
              $res = getResult("admin_details", " where user_id='" . $_SESSION['MyAdminUserID'] . "' and user_type='" . $_SESSION['MyAdminUserType'] . "'");
              if ($res['name'] != "") {
                echo $res['name'] . ",";
              } else {
                echo "Admin,";
              }
            }

            function required() {
              $mem = explode("~", $_SESSION['SessionId']);
              $res = getResult("admin_details", " where user_id='" . $_SESSION['MyAdminUserID'] . "' and user_type='" . $_SESSION['MyAdminUserType'] . "'");
              if (($res['name'] == "" || $res['email'] == "" || $res['website'] == "") && $_SESSION['SessionId'] != "") {
                return "<br /><center><font style='color:#ee0000;'>Some Required Fields are empty.Please enter this fields by <a href='<?=SITE_ADMIN_URL;?>/myaccount.php'>clicking here</a></font></center>";
              } else {
                return 0;
              }
            }

            function showdatetime($date) {
              $split_time = explode(" ", $date);
              $cdate = explode("-", $split_time[0]);
              $month = $cdate[1];
              $day = $cdate[2];
              $year = $cdate[0];

              $ctime = explode(":", $split_time[1]);
              $hours = $ctime[0];
              $minutes = $ctime[1];
              $seconds = $ctime[2];
              return date('d F, Y G:i:s', mktime($hours, $minutes, $seconds, $month, $day, $year));
            }

            function date_format_only($date) {
              $cdate = explode("-", $date);
              $month = $cdate[1];
              $day = $cdate[2];
              $year = $cdate[0];
              return date('d/m/Y', mktime(0, 0, 0, $month, $day, $year));
            }

            function showdate($date) {
              $cdate = explode("-", $date);
              $month = $cdate[1];
              $day = $cdate[2];
              $year = $cdate[0];

              if ($date != "" && $date != "0000-00-00") {
                return date('d-m-Y', mktime('', '', '', $month, $day, $year));
              } else {
                return "";
              }
            }

            function rss_write() {
              $pgnm = site_url . "/rss/news_feed.rss";
              $fp = fopen("$pgnm", "w");

              $newsCnt = getCount("news_tbl", " where status='Y'");
              if ($newsCnt > 0) {
                $rss_content = '<?xml version="1.0" encoding="iso-8859-1" ?> ' . "\n" . '<rss version="2.0">' . "\n" . '<channel>' . "\n" . '<title>Red Apple</title>' . "\n" . '' . "\n";
                $newsQry = db_query("select * from news_tbl where status='Y'");
                while ($newsRes = mysqli_fetch_array($newsQry)) {
                  $newsRes = ms_htmlentities_decode($newsRes);
                  $rss_content .= '<item>' . "\n";
                  $look = array('\'', '"', '&', '<', '>');
                  $replace = array('&quot;', '&quot;', '&amp;', '&lt;', '&gt;');
                  $newsHeading = str_replace($look, $replace, $newsRes['newsHeading']);
                  $newsDescription = str_replace($look, $replace, $newsRes['newsDescription']);
                  $rss_content .= '<title>' . $newsHeading . '</title>' . "\n";

                  $rss_content .= '<description>' . "\n\t\t" . $newsDescription . "\n" . '</description>' . "\n";
                  $rss_content .= '</item>' . "\n";
                }
                $rss_content .= '</channel>' . "\n";
                $rss_content .= '</rss>' . "\n";
              }
              fwrite($fp, $rss_content);
              fclose($fp);
            }

            function get_team_group_name($id) {
              $sql = mysqli_query($GLOBALS['dbconn'], "SELECT * FROM team_group_tbl where id= $id");
              $team_group = mysqli_fetch_array($sql);
              if (is_array($team_group)) {
                return $team_group['group_name'];
              } else {
                return "";
              }
            }

            function get_category_name($id) {
              $sql = mysqli_query($GLOBALS['dbconn'], "SELECT * FROM category_tbl where catID= $id");
              $team_group = mysqli_fetch_array($sql);
              if (is_array($team_group)) {
                return $team_group['catName'];
              } else {
                return "";
              }
            }

            function get_location_name($id) {
              $sql = mysqli_query($GLOBALS['dbconn'], "SELECT * FROM location_tbl where locationID= $id");
              $team_group = mysqli_fetch_array($sql);
              if (is_array($team_group)) {
                return $team_group['locationName'];
              } else {
                return "";
              }
            }

            function get_category_count() {
              return mysqli_num_rows(mysqli_query($GLOBALS['dbconn'], "SELECT * FROM category_tbl"));
            }

            function get_enquiry_count() {
              return mysqli_num_rows(mysqli_query($GLOBALS['dbconn'], "SELECT * FROM tbl_enquiry"));
            }

            function get_blog_count() {
              return mysqli_num_rows(mysqli_query($GLOBALS['dbconn'], "SELECT * FROM blog_tbl"));
            }

            function get_location_count() {
              return mysqli_num_rows(mysqli_query($GLOBALS['dbconn'], "SELECT * FROM location_tbl"));
            }
            ?>