<?php include('../../config.php');
session_start();

if (
    !isset($_SESSION['USER']) || empty($_SESSION['USER']) ||
    !($res = mysqli_query($conn, "SELECT password FROM user WHERE uid = " . (int)$_SESSION['USER']['uid'] . " LIMIT 1")) ||
    !($row = mysqli_fetch_assoc($res)) ||
    $row['password'] != $_SESSION['USER']['password']
) {
    header('Location: ../../logout.php');
    exit;
} else {
    $uid      = $_SESSION['USER']['uid'];
    $coid     = $_SESSION['USER']['us_coid'];
    $bid      = $_SESSION['USER']['us_bid'];
    $brid     = $_SESSION['USER']['us_brid'];
    $u_langg  = $_SESSION['USER']['us_language'];
    $us_ugid  = $_SESSION['USER']['us_ugid'];
    $us_em_id = $_SESSION['USER']['us_em_id'];
    $currency = $_SESSION['USER']['currency'];
    $bid_per  = $_SESSION['USER']['bid_per'];
    $brid_per = $_SESSION['USER']['brid_per'];
    $company_balance = $_SESSION['USER']['balance'];
    $expiry_date = $_SESSION['USER']['expiry_date'];    
    $co_f_year_start=$_SESSION['USER']['co_f_year_start'];
    $printer_t = $_SESSION['USER']['printer_set'];
    $administrator = $_SESSION['USER']['default_set'];
    
    $decimaltk = $_SESSION['USER']['decimaltk'];
    $decimalitem = $_SESSION['USER']['decimalitem'];
    $welldiv='Powered by : www.welldiv.com';
    
     $mail_assress     = $_SESSION['USER']['branch_email'];

     $smtp_pass = 'hvgbhrqdhdzkrjvj';
    
    $multi_bid = count(explode(",",$bid_per));
    $multi_brid = count(explode(",",$brid_per));
    
 if ($administrator == 'primary'){
    $bidq = mysqli_query($conn,"SELECT bid FROM business WHERE coid='$coid'")or die(mysqli_error($conn));
    $bid_check = mysqli_num_rows($bidq);
    
    $bridq = mysqli_query($conn,"SELECT brid FROM branch WHERE coid='$coid'")or die(mysqli_error($conn));
    $brid_check = mysqli_num_rows($bridq);
 } else {
    $bid_check  = 1;
    $brid_check = 1; 
 }
    // Permission setup start 
    function per($aap){
     if((strpos($_SESSION['USER']['co_permission'], $aap)!==false && strpos($_SESSION['USER']['business_permission'], $aap)!==false && strpos($_SESSION['USER']['branch_permission'], $aap)!==false && strpos($_SESSION['USER']['group_permission'], $aap)!==false) || $GLOBALS['uid']==1){
         return 1;} else { return 0;}
    }
    // Permission setup End 
    
    // language setup start 
    
    function language($lang_id) {
      $colang = mysqli_query($GLOBALS['conn'],"SELECT  `lang_coid`, `lang_type`, `bangla`, `english`, `arabic`, `hindi`, `china`,`malaysia`   FROM language WHERE lang_id='$lang_id'");
      $lang = mysqli_fetch_assoc($colang);
    
      if ($GLOBALS['u_langg']==1) {
        return '<lang class="lanbn">'.$lang['bangla'].'</lang>';
      } elseif ($GLOBALS['u_langg']==2) {
        return '<lang class="lanen">'.$lang['english'].'</lang>';
      } elseif ($GLOBALS['u_langg']==3) {
        return '<lang class="lanear">'.$lang['arabic'].'</lang>';
      } elseif ($GLOBALS['u_langg']==4) {
        return '<lang class="lanehi">'.$lang['hindi'].'</lang>';
      }elseif ($GLOBALS['u_langg']==5) {
        return '<lang class="lanech">'.$lang['china'].'</lang>';
      }elseif ($GLOBALS['u_langg']==6) {
        return '<lang class="lanema">'.$lang['malaysia'].'</lang>';
      }
    }
      // language setup start
  
    date_default_timezone_set('Asia/Dhaka'); 
    $datetime = date('Y-m-d H:i:s', time());
    $date = date('Y-m-d');
    $time = date('H:i:s');
    $decimel = 0;
    $item_decimel = 0;
    // o zreo for round working like if balance 99.9 then balance 100

}

?>


