<?php
session_start();
require('db.php');
include("auth.php");

?>
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon -->
    <link rel="shortcut icon" type="icon" href="DiGiXstyle/img/slogo.png"/>
    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <![endif]-->
    <title>DiGi-X Data Collection</title>
    <!--GOOGLE FONT -->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <!--BOOTSTRAP MAIN STYLES -->
    <link href="DiGiXstyle/css/bootstrap.min.css" rel="stylesheet" />
    <!--FONTAWESOME MAIN STYLE -->
    <link href="css/font-awesome.min.css" rel="stylesheet" />
    <!--CUSTOM STYLE -->
    <link href="DiGiXstyle/css/style.css" rel="stylesheet" />
    <link href="css/style.css" rel="stylesheet" />
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/custom.js"></script>
    <script src="js/custom1.js"></script>
    <script src="js/custom2.js"></script>


    <style>
        .new-test{
            margin: 14px 0;
        }
    </style>


<body>

<?php
                if ( $_GET['id'] ) {
                    $getId = $_GET['id'];
                    $_SESSION["testId"] = $getId;
                    
                    $sql = "SELECT * FROM dataregistration WHERE users_id = '$getId'";
                    $run = mysqli_query($con, $sql);
                    $helrow = mysqli_fetch_assoc($run);

                    $cname = $helrow['cname'];
                    $address = $helrow['address'];
                    $oth = $helrow['oth'];
                    $mobileno = $helrow['mobileno'];
                }
            ?>
<?php
    $testname = $_SESSION['username'];
    $result = "SELECT * FROM registration WHERE rmobileno = '$testname'";
    $query = mysqli_query($con, $result);
    $rows=mysqli_fetch_assoc($query);
    $member_id = $rows['id'];
    $upl_name = $rows['rname'];
    
?>

    <!--NAV SECTION -->
    <header id="header-nav" role="banner">
        <div id="navbar" class="navbar navbar-default">
            <div class="navbar-header">
                <a class="navbar-brand" href="http://digix.in/member/dataupload.php"> <img src="DiGiXstyle/img/logo.png" class="img-responsive"  width="100px" alt="">  </a>
                <font color="white">   Welcome : <?php echo $upl_name; ?></font>
             
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>  
            </div>
         
            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav flot-nav">
                <li><a href="dataupload.php"> <i class="fa fa-home" aria-hidden="true"></i>Home </a></li>
                    <li><a href="invoice.php?id=<?php echo $_SESSION["testId"]; ?>"> <i class=" fa fa-database"></i> Generate</a></li>
                    <li><a href="invoice-view.php"> <i class=" fa fa-eye"></i>View </a></li>
                    
                </ul>
            </div>
        </div>
        <?php
if (!isset($_POST['submit']))
    {
?>
  
    </header>
    <!--END NAV SECTION -->
    
    <!--Home SECTION -->
<br><br><br>
<div>    </div>
    
<div class="container">
    <div class="row">
        <div class="col-md-12">
    
           
    
       <div class="boxskill002149" align="center"> <font size="5" >   Generate Invoice  </font></div>
    
<form id="addem" name="addem" method="post" action="" autocomplete="off" onSubmit="return validate()" enctype="multipart/form-data">

    <!-- <div align="cen ter"  cellpadding="5"   > -->



<div class="container">





<div class="col-md-12">







<div class="col-md-4"> 
     
     
     
     
     <h3>To :</h3>
     <p><input type="text" value="<?php echo $cname; ?>" style="width:100%;" name="customer_name"></p>
     <p><input type="text" value="<?php echo $mobileno; ?>" style="width:100%;" name="customer_no"></p>
     <p><input type="text" value="<?php echo $address; ?>" style="width:100%;" name="customer_address"></p>
     
     <div>
<div align="left">Project Billing Status<font color="red"></font> </div>


<select id="subject" name="billstatus" placeholder="Class :" title="Name" class=" input"    class="put-r ight form-control input" class="form-control input " >
                      <option value="Unpaid bill">Unpaid bill</option>
                      
                      <option value="Semi Paid Bill">Semi Paid Bill</option>
                      <option value="Paid Bill ">Paid Bill </option>
                      <option value="Renewal Bill ">Renewal Bill</option>
                       
                      
                      
                    </select>

</div>
          
          
          
          
          
          </div>    

<div class="col-md-4">


<input type="hidden" id="id" name="member_id" value="<?php echo $member_id; ?>" placeholder="Name" title="Name" class="input"  >
 



<div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service1" placeholder="Service 1 " title="Name" class=" input"   >
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service1amount" placeholder="Amount " title="Name" class=" input" onkeyup="calculateTotal()"  >
        </div> 
</div> 



<div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service2" placeholder="Service 2 " title="Name" class=" input"   >
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service2amount" placeholder="Amount " title="Name" class=" input" onkeyup="calculateTotal()"  >
        </div> 
</div> 


<div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service3" placeholder="Service 3 " title="Name" class=" input"   >
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service3amount" placeholder="Amount " title="Name" class=" input"   >
        </div> 
</div> 



<div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service4" placeholder="Service 4 " title="Name" class=" input"   >
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service4amount" placeholder="Amount " title="Name" class=" input"   >
        </div> 
</div> 



<div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service5" placeholder="Service 5 " title="Name" class=" input"   >
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="service5amount" placeholder="Amount " title="Name" class=" input"   >
        </div> 
</div> 






</div>
    <div class="col-md-4">  
    
    




    <div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <p class="new-test">Total :</p>
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="total" name="total" placeholder="Amount " title="Name" class=" input" required  >
        </div> 
</div> 






<div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <p class="new-test">Paid :</p>
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="paid" placeholder="Amount " title="Name" class=" input"   >
        </div> 
</div> 








<div class="col-xs-12" style="padding:0;">
<!-- <div align="left">Mobile No<font color="red">*</font> </div> -->

        <div class="col-xs-9" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <p class="new-test">Due :</p>
        </div> 


        <div class="col-xs-3" style="padding:0;">
        <!-- <div align="left">Mobile No<font color="red">*</font> </div> -->
        <input type="text"  id="cname" name="due" placeholder="Amount " title="Name" class=" input"   >
        </div> 
</div> 


</div>







</div>






</div>









 <div class="col-md-12 text-center">
<br>
    
<input type="submit" value="Submit Form" name="submit" id="submit" class="btn btn-info btn-lg " style="cursor:pointer;">

<br>
<br>
<br>

</div>


                     
                     </form>
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                        </div> 
    
    
               
                
    </div>
    </div>
</div>

<?php
  }
  
  if (isset($_POST['submit']))
    {
  
  function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  $data=htmlspecialchars($data,ENT_QUOTES);
  return $data;
}

$customer_name=test_input($_POST['customer_name']);
$customer_no=test_input($_POST['customer_no']);
$customer_address=test_input($_POST['customer_address']);
$billstatus=test_input($_POST['billstatus']);

$service1=test_input($_POST['service1']);
$service2=test_input($_POST['service2']);
$service3=test_input($_POST['service3']);
$service4=test_input($_POST['service4']);
$service5=test_input($_POST['service5']);

$service1amount=test_input($_POST['service1amount']);
$service2amount=test_input($_POST['service2amount']);
$service3amount=test_input($_POST['service3amount']);
$service4amount=test_input($_POST['service4amount']);
$service5amount=test_input($_POST['service5amount']);

$total=test_input($_POST['total']);
$paid=test_input($_POST['paid']);
$due=test_input($_POST['due']);


date_default_timezone_set('Asia/Kolkata');
$created=date("l,j F, Y");

$uploader_id=$member_id;

$ins_sql = "INSERT INTO invoice (customer_name, customer_no, customer_address,billstatus, service1, service2, service3, service4, service5, service1amount, service2amount, service3amount, service4amount, service5amount, total, paid, due, uploader_id, uploader_name, created) VALUES ('$customer_name', '$customer_no', '$customer_address','$billstatus', '$service1', '$service2', '$service3', '$service4', '$service5', '$service1amount', '$service2amount', '$service3amount', '$service4amount', '$service5amount', '$total', '$paid', '$due', '$uploader_id', '$upl_name', '$created')";




    

    $api_key = '45899D6EF8D236';
    $from = 'DIGIXT';
    //$from = 'DRMIND';
    $message = "Congrats! ".$customer_name.", Your payment of Rs ".$paid." is successful and Due Amount is Rs ".$due." under Digi-X Technology";
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, "http://sambsms.com/app/smsapi/index.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "key=".$api_key."&campaign=0&routeid=7&type=text&contacts=".$customer_no."&senderid=".$from."&msg=".$message);
    $response = curl_exec($ch);
    curl_close($ch);
    
    













mysqli_query($con, $ins_sql);

?>
    <script>
        window.location = "suceesspage33.php";
    </script>
<?php
}
?>



    
    <!--END Home SECTION -->
    <!--FOOTER SECTION -->
    <footer id="footer">
        <div class="row">
            <div class="col-md-12  col-sm-12">
                &copy; 2017 www.DiGiX.in  |  All Rights Reserved
               
            </div>
        </div>
    </footer>
    
   
   
    <!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME  -->
    <!-- CORE JQUERY LIBRARY -->
    <script src="DiGiXstyle/js/jquery.js"></script>
    <!-- BOOTSTRAP SCRIPTS LIBRARY -->
    <script src="DiGiXstyle/js/bootstrap.min.js"></script>
   
    
    




</body>
</html>





