<?php 
error_reporting(0);
session_start();

$id = $_GET['reg'];
$_SESSION['id'] = $id;
$invoiceid = $_SESSION['id'];
		
if(!isset($_SESSION['admin']) || ($_SESSION['admin'] == "") )
{
?>
<script language="javascript">window.location.href="index.php";</script>
<?php 
}
include "config.php";
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Generate Invoice Add</title>
<meta name="author" content="pixelcave">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="img/apple-touch-icon-57x57-precomposed.png">
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-precomposed.png">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/plugins.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/themes.css">

<link href="datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
  
<script type="text/javascript" src="datepicker/js/datepicker.js"></script>   
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>

<script type="application/javascript">
  function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
         return true;
      }
</script>

 <script type="text/javascript">
        function ShowHideDiv() {
            var ddlPassport = document.getElementById("ddlPassport");
            var dvPassport = document.getElementById("dvPassport");
            dvPassport.style.display = ddlPassport.value == "Y" ? "block" : "none";
        }
    </script>
    
    
  <script type="text/javascript" src="js/jsapi.js"></script>

      <script type="text/javascript">
        // Load the Google Transliteration API
        google.load("elements", "1", {
          packages: "transliteration"
        });

        function onLoad() {
          var options = {
            sourceLanguage: 'en',
            destinationLanguage: ['gu'],
            shortcutKey: 'ctrl+m',
            transliterationEnabled: true
          }

          // Create an instance on TransliterationControl with the required options.
          var control = new google.elements.transliteration.TransliterationControl(options);

          // Enable transliteration in the textfields with the given ids.
          var ids = ["language"];
          control.makeTransliteratable(ids);
 
    var ids = ["language2"];
          control.makeTransliteratable(ids);
          // Show the transliteration control which can be used to toggle between English and Hindi and also choose other destination language.
          control.showControl('translControl');
        }

        google.setOnLoadCallback(onLoad);
      </script>  
    
    
</head>
<body>
<div id="page-container">
  <?php include 'header.php' ?>
  <div id="inner-container">
    <?php include 'left_menu.php' ?>
    <div id="page-content">
      <ul id="nav-info" class="clearfix">
        <li><a href="#"><i class="icon-home"></i></a></li>
        <li class="active"><a href="generate_invoice_list.php"> Invoice List</a></li>
		<li class="active"><a href="#"> New Invoice Add</a></li>
      </ul>
      
       <?php 
	if ($_POST['add']) 
	{
	$customerid=$_POST['customerid'];
	if($customerid != '')
	{
	$data1 = mysql_query("select * from tbl_customer_mst where customerid='$customerid'");														
	$adata1 = mysql_fetch_array($data1);
	$customername=$adata1['customername']; 
	$company_name=$adata1['company_name']; 
	$person_name=$adata1['person_name']; 
	$address1=$adata1['address1'];
	$city=$adata1['city'];
	$state=$adata1['state'];
	$phone_no=$adata1['phone_no'];
	$mobile1=$adata1['mobile1'];
	$email_id=$adata1['email_id'];
	
	}
	else
	{
	$customername=$_REQUEST['customername']; 
	$company_name=$_REQUEST['company_name'];
	$address1=$_REQUEST['address'];
	$city=$_REQUEST['city'];
	$state=$_REQUEST['state'];
	$phone_no=$_REQUEST['phone_no'];
	$mobile1=$_REQUEST['mobile'];
	$email_id=$_REQUEST['email'];
	
		
	$sql=mysql_query("INSERT INTO tbl_customer_mst (reg_date,customername,company_name,person_name,address1,city,state,phone_no,mobile1,email_id,status)VALUES (now(),'$customername','$company_name','$person_name','$address1','$city','$state','$phone_no','$mobile1','$email_id','Enable')");
	
	$customerid= mysql_insert_id();
	$_SESSION['customerid']=$customerid;
	$customerid = $_SESSION['customerid'];
	}
	
	$invoice_no = $_REQUEST['invoice_no'];
	$date1=$_REQUEST['invoice_date'];
	$invoice_date=date("Y-m-d", strtotime($date1));  
	
	$birth_date1=$_REQUEST['birth_date'];
	$birth_date=date("Y-m-d", strtotime($birth_date1));  
	
	$ann_date1=$_REQUEST['ann_date'];
	$ann_date=date("Y-m-d", strtotime($ann_date1));  
	
	
	$adv_amount=$_REQUEST['adv_amount'];
	$discount=$_REQUEST['discount'];
	
	$sql=mysql_query("INSERT 
		INTO 
		tbl_generate_invoice_mst	(quotation_id,quotation_no,quotation_date,invoice_no,invoice_date,birth_date,ann_date,adv_amount,customername,company_name,invoice_cust_name,mobile,address,city,email,status) 
		VALUES  ('$id','$quotation_no','$quotation_date','$invoice_no','$invoice_date','$birth_date','$ann_date','$adv_amount','$customername','$company_name','$invoicecustname','$mobile1','$address1','$city','$email_id','Running')");
		
	
        $lastinvoice_id =  mysql_insert_id(); 
	   $_SESSION['lastinvoice_id'] = $lastinvoice_id; 
	   $lastinvoice_id = $_SESSION['lastinvoice_id']; 
	
 ?>
   <script language="javascript">window.location.href="generate_extra_invoice_detail_add.php";</script>
   <?php 
  }
   ?>
 <button id="addRow" class="btn btn-success" onClick="location.href = 'generate_invoice_list.php';">&nbsp;નવા બિલ ની યાદી જુવો</button>
     <?php /*?> <?php 
  $id = $_GET['reg'];
 if(isset($_REQUEST['up'])) 
  { 
  	$quotation_no = $_REQUEST['quotation_no'];
	$quotation_date = $_REQUEST['quotation_date'];
	$customername = $_REQUEST['customername'];
	
	$invoice_no=$_REQUEST['invoice_no'];
	$date1=$_REQUEST['invoice_date'];
	$invoice_date=date("Y-m-d", strtotime($date1));  
	
	$status=$_REQUEST['status'];
	
	
	
	$uupQry="UPDATE  tbl_generate_invoice_mst SET quotation_id='$quotation_id',quotation_no='$quotation_no',quotation_date='$quotation_date',invoice_no='$invoice_no',invoice_date='$invoice_date',customername='$customername',status='Running' WHERE invoice_id='$id'";
	$uuresult=mysql_query($uupQry);
	?>
      <script language="javascript">window.location.href="generate_invoice_add.php";</script>
      <?php 
  }
   ?><?php */?>
    
      <form id="form-validation"  method="post" name="form" class="form-horizontal form-box remove-margin">
        <div class="form-box-content">
        
        <div class="control-group">
            <label class="control-label" for="val_username">બિલ નંબર : &nbsp;&nbsp;</label>
            <div class="controls">
              <div class="input-prepend">
          <?php 
	$sure=mysql_query("select * from  tbl_generate_invoice_mst order by ABS(invoice_no) desc");
	$srow = mysql_fetch_array($sure);
	 $code = $srow['invoice_no'] + 1;
	 // $dr_dep_id = $srow['dr_dep_id'];
	  
 $newcode = '00'.$code;
?>
                <input type="text" required id="val_username" name="invoice_no" value="<?php echo $newcode; ?>" readonly> 
              </div>
              <div class="input-prepend"> 
              

				<div class="input-prepend date input-datepicker" data-date="04-30-2013" data-date-format="mm-dd-yyyy">
				<label class="control-label" for="val_username">બિલ તારીખ : &nbsp;&nbsp;</label>       
                  <input type="text" id="val_password" required class="w8em format-d-m-y" name="invoice_date" value="<?php echo date('d-m-Y'); ?>" >
                </div>
				
              <!--<input type="text"  id="val_username" name="quotation_date" value="<?php //echo $quotation_date1; ?>" readonly>-->
                
             </div>
             </div>
             </div>
             <div class="control-group">
             <label class="control-label" for="val_username">ગ્રાહકનું નામ : &nbsp;&nbsp;</label>
             <div class="controls">
             <div class="input-prepend">
             <select  data-placeholder="Select Customer Name..." class="chzn-select full" name="customerid" id="ddlPassport" onChange="ShowHideDiv()">
                  <option value="">ગ્રાહકનું નામ પસંદ કરો....</option>
                  <?php 
$ure22=mysql_query("select * from tbl_customer_mst order by customerid desc");
		
		      while($urow22=mysql_fetch_array($ure22)) {?>
              <option value="<?php echo $urow22[0]; ?>"> <?php echo $urow22['customername']; ?></option>
              <?php } ?>
              </select>
             </div>
</div>
</div> 

			 <div id="dvPassport">
			 <div class="control-group">
             <label class="control-label" for="val_username">ગ્રાહકનું નામ : &nbsp;&nbsp;</label>
             <div class="controls">
             <div class="input-prepend">
             <input type="text"  id="language" name="customername" value="<?php echo $customername; ?>" >
             </div>
             <div class="input-prepend"> 
             <label class="control-label" for="val_username">મોબાઇલ : &nbsp;&nbsp;</label>
                <input type="text"  id="language" name="mobile" value="<?php echo $row['mobile']; ?>" maxlength="10" >
              </div>
          
          
       
           
</div>
</div>
<div class="control-group">
<label class="control-label" for="val_password"> જન્મ તારીખ &nbsp;&nbsp;</label>
<div class="controls">
<div class="input-prepend date input-datepicker2" data-date="04-30-2013" data-date-format="mm-dd-yyyy">

 <input type="text" id="val_password" required class="w8em format-d-m-y" name="birth_date" value="<?php echo date('d-m-Y'); ?>" >
</div>

<div class="input-prepend date input-datepicker3" data-date="04-30-2013" data-date-format="mm-dd-yyyy">
				<label class="control-label" for="val_username">વર્ષગાંઠ તારીખ : &nbsp;&nbsp;</label>       
                  <input type="text" id="val_password" required class="w8em format-d-m-y" name="ann_date" value="<?php echo date('d-m-Y'); ?>" >
                </div>
		
 


</div>
</div>
		
<div class="control-group">
<label class="control-label" for="val_password">ગામ/નગર: &nbsp;&nbsp;</label>
<div class="controls">
<div class="input-prepend">
  <input type="text"  id="language2" name="city" value="<?php echo $city; ?>" >
</div>
              </div>

</div>




</div>

 
          <div class="form-actions">
           
            <input type="submit" name="add" value="બિલ બનાવો અને વિગત ઉમેરો" class="btn btn-success">
            
            <!--<button type="reset" class="btn btn-danger"><i class="icon-repeat"></i> Reset</button>-->
          </div>
        </div>
      </form>
    </div>
    <?php include 'footer.php' ?>
  </div>
</div>
<?php include 'profile_popup.php' ?>
<!--[if lte IE 8]><script src="js/helpers/excanvas.min.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/vendor/jquery-1.9.1.min.js"%3E%3C/script%3E'));</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script>$(function(){$("#form-validation").validate({errorClass:"help-block text-error",errorElement:"span",errorPlacement:function(t,e){e.parents(".controls").append(t)},highlight:function(t){$(t).closest(".control-group").removeClass("success error").addClass("error")},success:function(t){t.addClass("valid").closest(".control-group").removeClass("success error").addClass("success"),t.closest(".help-inline").remove(),t.closest(".help-block").remove()},rules:{val_username:{required:!0,minlength:2},val_password:{required:!0,minlength:5},val_confirm_password:{required:!0,minlength:5,equalTo:"#val_password"},val_email:{required:!0,email:!0},val_website:{required:!0,url:!0},val_date:{required:!0,date:!0},val_range:{required:!0,range:[1,100]},val_number:{required:!0,number:!0},val_digits:{required:!0,digits:!0},val_skill:{required:!0},val_credit_card:{required:!0,creditcard:!0},val_terms:{required:!0}},messages:{val_username:{required:"Please enter a username",minlength:"Your username must consist of at least 2 characters"},val_password:{required:"Please provide a password",minlength:"Your password must be at least 5 characters long"},val_confirm_password:{required:"Please provide a password",minlength:"Your password must be at least 5 characters long",equalTo:"Please enter the same password as above"},val_email:"Please enter a valid email address",val_website:"Please enter your website!",val_date:"Please select a date!",val_range:"Please enter a number between 1 and 100!",val_number:"Please enter a number!",val_digits:"Please enter digits!",val_credit_card:"Please enter a valid credit card!",val_skill:"Please select a skill!",val_terms:"You must agree to the terms!"}})});</script>
</body>
</html>


