<?php
function generatePIN($digits = 4){
    $i = 0; //counter
    $pin = ""; //our default pin is blank.
    while($i < $digits){
        //generate a random number between 0 and 9.
        $pin .= mt_rand(0, 9);
        $i++;
    }
    return $pin;
}

function dsName($ds_code)
{
	global $cn;
	$sqlCategory     = mysqli_query($cn,"select ds_name from `tbl_sh` where `ds_code`='".$ds_code."'");
	$sqlCategoryData = mysqli_fetch_array($sqlCategory);
	return $sqlCategoryData['ds_name'];
}

function shopName($shop_id)
{
	global $cn;
	$sqlCategory     = mysqli_query($cn,"select `shop_name` from `tbl_retailer` where `id`='".$shop_id."'");
	$sqlCategoryData = mysqli_fetch_array($sqlCategory);
	return $sqlCategoryData['shop_name'];
}

function shopState($shop_id)
{
	global $cn;
	$sqlCategory     = mysqli_query($cn,"select `state`,`district`,`sale_district`,`beat` from `tbl_retailer` where `id`='".$shop_id."'");
	$sqlCategoryData = mysqli_fetch_array($sqlCategory);
	return " [ <strong> State : </strong> " . $sqlCategoryData['state']." <strong> Disrtict : </strong>".$sqlCategoryData['district']." ( ".$sqlCategoryData['sale_district']." ) <strong>Beat : </strong>".$sqlCategoryData['beat']." ]";
}


function productName($product_id)
{
	global $cn;
	$sqlCategory     = mysqli_query($cn,"select `product_name` from `tbl_product` where `id`='".$product_id."'");
	$sqlCategoryData = mysqli_fetch_array($sqlCategory);
	return $sqlCategoryData['product_name'];
}
?>