<?php
 
function convert_number($number) 
{ 
    if (($number < 0) || ($number > 999999999)) 
    { 
    throw new Exception("Number is out of range");
    } 

    $Gn = floor($number / 1000000);  /* Millions (giga) */ 
    $number -= $Gn * 1000000; 
    $kn = floor($number / 1000);     /* Thousands (kilo) */ 
    $number -= $kn * 1000; 
    $Hn = floor($number / 100);      /* Hundreds (hecto) */ 
    $number -= $Hn * 100; 
    $Dn = floor($number / 10);       /* Tens (deca) */ 
    $n = $number % 10;               /* Ones */ 

    $res = ""; 

    if ($Gn) 
    { 
        $res .= convert_number($Gn) . " Million"; 
    } 

    if ($kn) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($kn) . " Thousand"; 
    } 

    if ($Hn) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($Hn) . " Hundred"; 
    } 

    $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", 
        "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", 
        "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", 
        "Nineteen"); 
    $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", 
        "Seventy", "Eigthy", "Ninety"); 

    if ($Dn || $n) 
    { 
        if (!empty($res)) 
        { 
            $res .= " and "; 
        } 

        if ($Dn < 2) 
        { 
            $res .= $ones[$Dn * 10 + $n]; 
        } 
        else 
        { 
            $res .= $tens[$Dn]; 

            if ($n) 
            { 
                $res .= "-" . $ones[$n]; 
            } 
        } 
    } 

    if (empty($res)) 
    { 
        $res = "zero"; 
    } 

    return $res; 
} 

	function getActualData( $data)
	{
		$cp = "";
		$sour_prefix = "";
		
		$cp = explode("|", $data);
		for($i = 0; $i < (count($cp) - 1); $i++)
		{
			$sour_prefix .= chr($cp[$i]);
		}
		
		return $sour_prefix;
	}
	
	
	function create_string_amount($amount)
	{
		$string = '';
		$substring = '';
		$j = 0;
		$length =  strlen($amount);
		
		if($length > 3 )
		{
			for($i = 3; $i < $length; $i = $i + 3)
			{
				$substring = substr($amount, (-1 * $i), 3);
		 		$string = ',' . $substring . $string;
				$j = $j + 3;
			}
		}
		
		$length = $length - $j;
		
		$string = substr($amount, 0, $length) . $string;
		
		return $string;
		
	}
	
	function create_offer_contant($id)
	{
		$display = "";
		   
		$display .=" <div style='border-style: groove;  margin: 20px 50px 20px 50px'>
    
        <table style='width:100%;'>
            <tr>
                <td align='right'>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
                <td align='right'>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
                <td align='right'>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
            </tr>
            <tr>
                <td align='right'>
                    GENERATOR BAND :</td>
                <td>
                    <input id='txt_gen_name$id' class='common_text' type='text' disabled='disabled' /> 
                              <input type='button' value='---' id='btn_generator' onclick='call_sub_page(\"generator_list_all\", 0, 1, $id)'  />
                        
                        </td>
                <td align='right'>
                    KVA</td>
                <td>
                    <input id='txt_kva$id' class='common_text'  type='text' /></td>
                <td align='right'>
                    MODEL </td>
                <td>
                    <input id='txt_model$id' class='common_text'  type='text' /></td>
            </tr>
            
             <tr>
                <td align='right'>
                    ENGINE :</td>
                <td><input id='txt_eng$id' class='common_text' type='text'   /></td>
                <td align='right'>
                    SKVA</td>
                <td>
                  <input id='txt_skva$id' class='common_text'  type='text' /> </td>
                <td align='right'>
                    CODE</td>
              <td><input id='txt_code$id' class='common_text' type='text' /></td>
            </tr>
            
             <tr>
                <td align='right'>
                    MODEL : </td>
                <td align='left'>
                    <input id='txt_eng_model$id' class='common_text' type='text' /></td>
                <td align='right'>
                     FUEL CONS /h:</td>
                <td align='left'>
                      <input id='txt_puel_h$id' class='common_text' style='width: 80px' type='text' /></td>
                <td align='right' >
                   ATS</td>
                    <!-- onchange='addd_in_data_table('ats',this.value)' -->   
                <td align='left'>
                <select id='cmb_ats$id'  class='common_commbo' name='D4' disabled='disabled'  >
                  <option value='0'>--N/A--</option>";
                  
										include('../../config/db_connect.php');
										$query = 'CALL usp_select_product_type(3)'; 
							  		
										$res = $mysql->query($query);
										
										while($b_row = mysqli_fetch_array($res))
										{
                  					  $display .="<option   value='$b_row[id]'>$b_row[type_name]</option>";
										}
									 
                                        
       $display .="</select>
                    </td>
            </tr>
             <tr>
                <td align='right'>
                    DIMENTION(cm):</td>
                <td align='left'>
                    <input id='txt_dimension$id' class='common_text' type='text' /></td>
                <td align='right'>ALTER:</td>
                <!-- onchange='addd_in_data_table('alter',this.value)' -->
                <td align='left'><select  class='common_commbo' id='cmb_alt$id' name='D2' disabled='disabled' >
                       <option value='0'>--Select--</option> ";
								 
										include('../../config/db_connect.php');
										$query = 'CALL usp_select_product_type(1)'; 
							  		
										$res = $mysql->query($query);
										
										while($b_row = mysqli_fetch_array($res))
										{
                  					  $display .="<option   value='$b_row[id]'>$b_row[type_name]</option>";
										}
										
            $display .="</select></td>
                <td align='right'>
                    CANOPY:</td>
                                    <!-- onchange='addd_in_data_table('canopy',this.value)' -->
                <td align='left'>
                    <select  class='common_commbo' id='cmb_canopy$id' name='D3'  disabled='disabled'  >
                        <option value='0'>--N/A--</option> ";
							 
										include('../../config/db_connect.php');
										$query = 'CALL usp_select_product_type(2)'; 
							  		
										$res = $mysql->query($query);
										
										while($b_row = mysqli_fetch_array($res))
										{
                  					  $display .="<option   value='$b_row[id]'>$b_row[type_name]</option>";
										}
										
       $display .="</select></td>
            </tr>
             <tr>
                <td align='right'>
                    TANK CAPACITY:</td>
                <td align='left'>
                    <input id='txt_tan_capacity$id' class='common_text' type='text' /></td>
                                <td align='right'>
                    MODULE:</td>
                <td align='left'>
                <select  class='common_commbo' id='cmb_module$id' name='D'  disabled='disabled'  >
                  <option value='0'>--Select--</option>";
										 
										include('../../config/db_connect.php');
										$query = 'CALL usp_select_product_module(0)'; 
							  		
										$res = $mysql->query($query);
										
										while($b_row = mysqli_fetch_array($res))
										{
                  					  $display .="<option   value='$b_row[id]'>$b_row[module_name]</option>";
										}
										
	 	
       $display .="</select></td>
                    

                <td>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
            </tr>
           
             <tr>
                <td align='right'>&nbsp;
                    </td>
                <td align='left'>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
                <td>&nbsp;
                    </td>
            </tr>
           
             <tr>
                <td align='right'>
                    <input id='Radio1$id' type='radio' checked='checked' name='nm_price' /></td>
                <td align='left'>
                    Local price (Ready Stock)</td>
                <td align='right'>
                    <input id='Radio2$id' type='radio' name='nm_price' /></td>
                <td align='left'>
                    Local price(Import)</td>
                <td align='right'>
                    <input id='Radio3$id' type='radio' name='nm_price' /></td>
                <td align='left'>
                    C&amp;F Price</td>
            </tr>
           
             <tr>
                <td align='right'>&nbsp;
                    </td>
                <td align='left'>&nbsp;
                    </td>
                <td align='right'>&nbsp;
                    </td>
                <td align='left'>&nbsp;
                    </td>
                <td align='right'>&nbsp;
                    </td>
                <td align='left'>&nbsp;
                    </td>
            </tr>
           
        </table>
    
</div>";

		
		
		
		
		
		
		
		
		return $display;
	}
	
	
	

?>
 