<?php

	require_once("../admin/conn.php");

	function digit_eng_ban($main_string){
		$length=strlen($main_string);
		$bangla_str="";
		for($i=0;$i<$length;$i++){
			$single_char=substr($main_string, $i, 1);
			$bangla_char_query=mysql_query("select bangla from tbl_digit_eng_to_ban where english = '$single_char'");
			$bangla_char_query_result=mysql_fetch_row($bangla_char_query);
			$bangla_str=$bangla_str.$bangla_char_query_result[0];
		}
		echo $bangla_str;
	}
	
	function digit_to_word($digit){
       $bangla_in_word="";
	   
	   $digit=str_replace(",", "", $digit);
	   
	   $poisa=substr($digit, strpos($digit,".")+1, 2);
	   $digit=substr($digit, 0, strpos($digit,"."));
	   $length=strlen($digit);
	   
	   if($length>5 and $length<8){
        $lokkho=$digit / 100000;
        $lokkho=(integer)$lokkho;
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$lokkho'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." ";
        $bangla_in_word=$bangla_in_word."লক্ষ ";
        $digit=$digit % 100000;
       }
       
	   $length=strlen($digit);
       if($length>3 and $length<6){
        $hajar=$digit / 1000;
        $hajar=(integer)$hajar;
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$hajar'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." ";
        $bangla_in_word=$bangla_in_word."হাজার ";
        $digit=$digit % 1000;
       }
       
       $length=strlen($digit);
       if($length>2 and $length<4){
        $shoto=$digit / 100;
        $shoto=(integer)$shoto;
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$shoto'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." ";
        $bangla_in_word=$bangla_in_word."শত ";
        $digit=$digit % 100;
       }
       
       $length=strlen($digit);
       if($length<3){
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$digit'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." টাকা ";
       }
	   
	   if($poisa!="00"){
		$bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$poisa'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=" ".$bangla_in_word.$bangla_word_query_result[0]." পয়সা";
	   }
       echo $bangla_in_word;
	}
	
	function digit_to_word_wc($digit){
       $bangla_in_word="";
	   
	   $digit=str_replace(",", "", $digit);
	   
	   $poisa=substr($digit, strpos($digit,".")+1, 2);
	   $digit=substr($digit, 0, strpos($digit,"."));
	   $length=strlen($digit);
	   
	   if($length>5 and $length<8){
        $lokkho=$digit / 100000;
        $lokkho=(integer)$lokkho;
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$lokkho'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." ";
        $bangla_in_word=$bangla_in_word."লক্ষ ";
        $digit=$digit % 100000;
       }
       
	   $length=strlen($digit);
       if($length>3 and $length<6){
        $hajar=$digit / 1000;
        $hajar=(integer)$hajar;
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$hajar'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." ";
        $bangla_in_word=$bangla_in_word."হাজার ";
        $digit=$digit % 1000;
       }
       
       $length=strlen($digit);
       if($length>2 and $length<4){
        $shoto=$digit / 100;
        $shoto=(integer)$shoto;
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$shoto'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." ";
        $bangla_in_word=$bangla_in_word."শত ";
        $digit=$digit % 100;
       }
       
       $length=strlen($digit);
       if($length<3){
        $bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$digit'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=$bangla_in_word.$bangla_word_query_result[0]." "; //currency
       }
	   
	   if($poisa!="00"){
		$bangla_word_query=mysql_query("select word from tbl_digit_to_word where digit = '$poisa'");
        $bangla_word_query_result=mysql_fetch_row($bangla_word_query);
		$bangla_in_word=" ".$bangla_in_word.$bangla_word_query_result[0]." পয়সা";
	   }
       echo $bangla_in_word;
	}
	function no_to_month($month_no){
		switch($month_no){
			case 1:
				return "জানুয়ারী";
				break;
			case 2:
				return "ফেব্রুয়ারী";
				break;
			case 3:
				return "মার্চ";
				break;
			case 4:
				return "এপ্রিল";
				break;
			case 5:
				return "মে";
				break;
			case 6:
				return "জুন";
				break;
			case 7:
				return "জুলাই";
				break;
			case 8:
				return "আগস্ট";
				break;
			case 9:
				return "সেপ্টেম্বর";
				break;
			case 10:
				return "অক্টোবর";
				break;
			case 11:
				return "নভেম্বর";
				break;
			case 12:
				return "ডিসেম্বর";
				break;
				
		}
	}

	function digit_eng_ban_new($main_string){
		$length=strlen($main_string);
		$bangla_str="";
		for($i=0;$i<$length;$i++){
			$single_char=substr($main_string, $i, 1);
			$bangla_char_query=mysql_query("select bangla from tbl_digit_eng_to_ban where english = '$single_char'");
			$bangla_char_query_result=mysql_fetch_row($bangla_char_query);
			$bangla_str=$bangla_str.$bangla_char_query_result[0];
		}
		return $bangla_str;
	}
?>