<?php
  session_start();
  if(!isset($_SESSION['LOGIN_STATUS']))
  {
      header('location:../index.php');
  }
  require "../model/configuration.php";
  $rn=rand(100,115000).time();
$_SESSION['prms']=$rn;
$_SESSION['estimate']="Estimate";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php echo $_SESSION['title'];?></title>
<link rel='stylesheet' type='text/css' href='../css/fonts.googleapis.com/css_cd14c140.css' />
<!-- Bootstrap CSS -->
<link rel="stylesheet" type="text/css" href="../vendor/bootstrap/css/bootstrap.min.css" />
<!-- Theme CSS -->
<link rel="stylesheet" type="text/css" href="../css/vendor.css" />
<link rel="stylesheet" type="text/css" href="../css/theme.css" />
<link rel="stylesheet" type="text/css" href="../css/utility.css" />
<link rel="stylesheet" type="text/css" href="../css/custom.css" />
<link href="../vendor/Selectbox/bootstrap-select.min.css" rel="stylesheet" />
</head>

<body class="dashboard-page">
<script> var boxtest = localStorage.getItem('boxed'); if (boxtest === 'true') {document.body.className+=' boxed-layout';} </script> 
<!-- Start: Theme Preview Pane -->


<!-- Start: Header -->
<header class="navbar navbar-fixed-top">
  
   <?php include_once("../include/top_menu.php");?> 
</header>

<!-- Start: Main -->
<div id="main"> 
  
  <!-- Start: Sidebar -->
  <?php include_once("../include/left_menu.php");?>

  <!-- Start: Content -->
  <section id="content_wrapper">
    <div id="topbar">
      <div class="topbar-left">
        <ol class="breadcrumb">
          <li class="crumb-icon"><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
          <li class="crumb-link"><a href="#">Estimate</a></li>
          <li class="crumb-trail">Estimate Add</li>
        </ol>
      </div>
      
    </div>
    
    
    <div id="content">
      <div class="row">
      <form class="cmxform form-horizontal" action="" method="POST">
        <div class="col-md-12">
        <div class="col-md-6">
          <div class="panel">
            <div class="panel-heading"> <span class="panel-title"> <span class="glyphicon glyphicon-lock"></span> Estimate Add </span> </div>
            <div class="panel-body">
              
              
              
              
              <div class="form-group">
                  <label for="cp" class="col-lg-2 control-label">Customer Name</label>
                  <div class="col-lg-10">
                    <div class="col-lg-12">
                      <select class="selectpicker form-control" data-live-search="true" name="customer" id="customer" tabindex="6">
                      
<option value="">--Select--</option>
 <?php
		
        $cusquery=$db->execute("select * from clients where delet='0'");
		while($cusresult=$cusquery->fetch_assoc())
			{
				
		?>
        <option value="<?php echo $cusresult['client_id'];?>"><?php echo $cusresult['client_name'];?></option>
        <?php
			}
		?>
   
      </select>
                    </div>
                  </div>
                </div>
 
 
 <!--<div class="form-group">
                  <label for="datepicker" class="col-lg-2 control-label">Date</label>
                  <div class="col-lg-10">
                    <div class="input-group"> 
                      <input type="text" id="datepicker" name="dates" class="form-control datepicker mtn" placeholder="Date" required="" />
                      <div class="input-group-addon"><i class="fa fa-calendar"></i> </div>
                  </div>
                  </div>
                </div>--><!--<input type="hidden" id="datepicker" name="dates" class="form-control mtn" placeholder="Date" required="" value="<?php //echo date("d-m-Y");?>" />-->
 
 
 
 
 
 <div class="form-group">
                  <label for="cp" class="col-lg-2 control-label">Machines Name</label>
                  <div class="col-lg-10">
                    <div class="col-lg-12">
                      <select class="selectpicker form-control changesNo" data-live-search="true" name="machinename" id="machinename" onchange="getMechine(this.value);" tabindex="6">
                      
<option value="">--Select--</option>
 <?php
		
        $query=$db->execute("select * from machines_table where delet='0'");
		while($result=$query->fetch_assoc())
			{
				
		?>
        <option value="<?php echo $result['id'];?>"><?php echo $result['Machine_Name'];?></option>
        <?php
			}
		?>
   
      </select>
                    </div>
                  </div>
                </div>
 
 
 
 
 
 
 
 
  <div class="form-group">
                  <label for="cp" class="col-lg-2 control-label">Product</label>
                  <div class="col-lg-10">
                  
                    <div class="col-lg-12">
                                        
                    
                      <select class="form-control selectpicker changesNo" data-live-search="true" name="product" id="product" onchange="getCate(this.value);" tabindex="6">
                            <option value="">--Select--</option>
                                <?php
                                    $query=$db->execute("select * from products where delet='0'");
	                               	while($result=$query->fetch_assoc())
		                              	{
                                ?>
                            <option value="<?php echo $result['productcode'];?>|<?php echo $result['productname'];?>"><?php echo $result['productcode'];?>|<?php echo $result['productname'];?></option>
                                <?php
                                        }
                                ?>
                      </select>
                      
                    </div>
                    </div>
                </div>
 
 
 

              
              
              
              
              
    
    
  
    
    
    
    
    
    
    
    <div class="form-group">
                  <label for="cp" class="col-lg-2 control-label">Printing Size</label>
                  <div class="col-lg-10">
                    <div class="col-lg-12">
                      <select class="selectpicker form-control changesNo" data-live-search="true" name="printsize" id="printsize" onchange="getPrintsize(this.value);" tabindex="6">
                      
<option value="">--Select--</option>

		<?php
        $query=$db->execute("select * from printing_size where delet='0'");
		while($result=$query->fetch_assoc())
			{
		?>
        		<option value="<?php echo $result['print_size'];?>"><?php echo $result['print_size'];?></option>
        <?php
			}
		?>
   
      </select>
    
                    </div>
                  </div>
                </div>
    
    
    
    
    
    <div class="form-group">
<label for="cp" class="col-lg-2 control-label">Number of Pages</label>
                  <div class="col-lg-10">
                    <div class="col-lg-12">
                      <input id="numberofpages" name="numberofpages" type="text" class="form-control changesNo" onkeyup="getPagecount(this.value);" placeholder="Number of Pages" required="" autocomplete="off" />
                    </div>
                  </div>
</div>







<div class="form-group">
	<label for="cp" class="col-lg-2 control-label">Back Printing</label>
    <div class="col-lg-10">
    <div class="col-lg-12">
<select class="form-control changesNo" name="bckprint" id="bckprint" onchange="getbackprint(this.value);"><!--onchange="getFields(this.value);"-->
<option value="">--Select--</option>
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>  
    </div>

    </div>
</div>



<div id="bckprnt">



</div>


















    
    
 <div class="form-group">
	<label for="cp" class="col-lg-2 control-label">Copies</label>
    <div class="col-lg-10">
         <div class="col-lg-12">
                      <input id="pacopy" name="pacopy" type="text" class="form-control changesNo" placeholder="Copies" onkeyup="getplatecount(this.value);" required="" autocomplete="off" />
         </div>
    </div>
</div>   
    
    
    
    <div class="form-group">
<label for="cp" class="col-lg-2 control-label">Ink Color</label>
                  <div class="col-lg-10">
                    <div class="col-lg-12">
                      <input id="paperinkColor" name="paperinkColor" type="text" class="form-control"  placeholder="Ink Color" required="" autocomplete="off" />
                      
                    </div>
                  </div>
</div>
    
    
    
    
                
                
                
                
                
                <div id="fields">
                  
                </div>
                
   
   

   
   
   
   
   
   
   
   
   
   
                
                
               <div class="form-group">
<label for="cp" class="col-lg-2 control-label">Type of Work</label>
                  <div class="col-lg-10">
                    <div class="col-lg-12">
                      <input id="typeofwrk" name="typeofwrk" type="text" class="form-control" placeholder="Type of Work" required="" autocomplete="off" />
                    </div>
                  </div>
</div> 
                
                
                
                
                
         <div class="form-group">
<label for="cp" class="col-lg-2 control-label">Description</label>
                  <div class="col-lg-10">
                    <div class="col-lg-12">
                      <input id="wrkdescription" name="wrkdescription" type="text" class="form-control" placeholder="Customer Description of work" required="" autocomplete="off" />
                    </div>
                  </div>
</div>       
                
                
                
                
                
                
                
                
                
                
              
                
              
            </div>
          </div>
          </div>
          
          
          
          
          
          
 <div class="col-md-6">         
          

          
          
  <div class="panel">
            <div class="panel-heading"> <span class="panel-title"> <span class="glyphicon glyphicon-lock"></span> Estimate Add </span> </div>
            <div class="panel-body">        
          
         
          
          
     <div class="col-md-12">       
          
          
          
          
          
          
          
          
          <div class="col-lg-6">

<div class="form-group">
<label for="cp" class="col-lg-6 control-label">Number of Books</label>
                  <div class="col-lg-6">
                    <div class="col-lg-12">
                      <input id="numberofbooks" name="numberofbooks" type="text" class="form-control" placeholder="Number of Books" value="0" required="" autocomplete="off" />
                    </div>
                  </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-6 control-label">Number of sets per books</label>
    <div class="col-lg-6">
         <div class="col-lg-12">
                      <input id="numberofsetsperbooks" name="numberofsetsperbooks" type="text" class="form-control" placeholder="Number of sets per books" value="0" required="" autocomplete="off" />
         </div>
    </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-6 control-label">Starting No</label>
    <div class="col-lg-6">
         <div class="col-lg-12">
                      <input id="startingno" name="startingno" type="text" class="form-control" placeholder="Starting No" value="0" required="" autocomplete="off" />
         </div>
    </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-6 control-label">Type of Binding Board</label>
    <div class="col-lg-6">
         <div class="col-lg-12">
                      <input id="typeofbndboard" name="typeofbndboard" type="text" class="form-control" placeholder="Type of Binding Board" required="" autocomplete="off" />
         </div>
    </div>
</div>

<div class="form-group">
<label for="cp" class="col-lg-6 control-label">Plate</label>
                  <div class="col-lg-6">
                    <div class="col-lg-12">
                      <input id="plate" name="plate" type="text" class="form-control" placeholder="Plate" required="" autocomplete="off" />
                    </div>
                  </div>
</div>


<div class="form-group">
<label for="cp" class="col-lg-6 control-label">CTP</label>
                  <div class="col-lg-6">
                    <div class="col-lg-12">
                      <input id="ctp" name="ctp" type="text" class="form-control" placeholder="CTP" required="" readonly="readonly" autocomplete="off" />
                    </div>
                  </div>
</div>

</div>
          
          
          
  <div class="col-lg-6">



<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Lamination</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="lamination" id="lamination" value="Yes" />Yes </label>
         <label class="radio-inline mr10"><input type="radio" name="lamination" id="lamination" value="No" checked="checked" />No </label>
    </div>
</div>







<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Folding</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="folding" id="folding" value="Yes" />Yes </label>
         <label class="radio-inline mr10"><input type="radio" name="folding" id="folding" value="No" checked="checked" />No </label>
    </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Creasing</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="creasing" id="creasing" value="Yes" />Yes </label>
         <label class="radio-inline mr10"><input type="radio" name="creasing" id="creasing" value="No" checked="checked" />No </label>
    </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Binding</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="binding" id="binding" value="Normal" checked="checked" />Normal </label>
         <label class="radio-inline mr10"><input type="radio" name="binding" id="binding" value="Calico" />Calico </label>
    </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Stapling</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="stapling" id="stapling" value="Center" />Center </label>
         <label class="radio-inline mr10"><input type="radio" name="stapling" id="stapling" value="Side" checked="checked" />Side </label>
    </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Stitching</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="stitching" id="stitching" value="Yes" />Yes </label>
         <label class="radio-inline mr10"><input type="radio" name="stitching" id="stitching" value="No" checked="checked" />No </label>
    </div>
</div>

<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Pasting</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="pasting" id="pasting" value="Yes" />Yes </label>
         <label class="radio-inline mr10"><input type="radio" name="pasting" id="pasting" value="No" checked="checked" />No </label>
    </div>
</div>
<div class="form-group">
	<label for="cp" class="col-lg-5 control-label">Print on Last Copy</label>
    <div class="col-lg-7">
         <label class="radio-inline mr10"><input type="radio" name="prntlastcopy" id="prntlastcopy" value="Yes" />Yes </label>
         <label class="radio-inline mr10"><input type="radio" name="prntlastcopy" id="prntlastcopy" value="No" checked="checked" />No </label>
    </div>
</div>
</div>        
          
 </div>         
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
                
          
          
           <div id="category"></div> 
           
           
           <div class="form-group">
                <div class="col-lg-6">
                  <input class="submit btn bg-purple pull-right" id="FormSubmit" name="catagry_add" type="submit" value="Add" />
                  </div>
                </div>
                
                
                
          
          
  </div>
  
  </div>        
          
          
          
          
          
          
          
          
         
          </div>
          </div>
          
  </form>        
          
          
          
          
          
          
          <div class="col-md-12" style="background-color: white;">
          <div class="panel">
            <div class="panel-heading"> <span class="panel-title"> <span class="glyphicon glyphicon-pencil"></span> Estimate </span> </div>
            <div class="panel-body pbn">
              <table class="table table-striped table-bordered table-hover" id="responds">
                <thead>
                  <tr>
                    <th>#</th>
                    <th>Machine</th>
                    <th>Paper</th>
                    <th>Printing Size</th>
                    <th>Number of Pages</th>
                    <th>Copies</th>
                    <th>CTP</th>
                    <th class="text-center hidden-xs">Actions</th>
                  </tr>
                </thead>
                <tbody>
                  
                </tbody>
              </table>
            </div>
          </div>
          
          <form action="save_estimate.php" class="form-horizontal" method="post">
            <div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'>
            <div class="col-lg-3">
                <input type="hidden" name="sion" id="sion" value="<?php echo $_SESSION['prms'];?>" />
                <div class="form-group">
<label for="cp" class="col-lg-3 control-label">Advance</label>
                  <div class="col-lg-9">
                    <div class="input-group"><span class="input-group-addon"><i class="fa fa-hand-o-right"></i></span>
                      <input id="advamt" name="advamt" type="text" class="form-control" placeholder="Advance Amount" required="" autocomplete="off" />
                    </div>
                  </div>
</div> 
</div>

<div class="col-lg-3">
<div class="form-group">
<label for="cp" class="col-lg-3 control-label">Additional CTP</label>
                  <div class="col-lg-9">
                    <div class="input-group"><span class="input-group-addon"><i class="fa fa-hand-o-right"></i></span>
                      <input id="additionalctp" name="additionalctp" type="text" class="form-control" placeholder="Additional CTP" required="" autocomplete="off" />
                    </div>
                  </div>
</div>
</div>


<div class="col-lg-3">
<div class="form-group">
<label for="cp" class="col-lg-4 control-label">Impression Charge</label>
                  <div class="col-lg-8">
                    <div class="input-group"><span class="input-group-addon"><i class="fa fa-hand-o-right"></i></span>
                      <input id="additionalimpressioncharge" name="additionalimpressioncharge" type="text" class="form-control" placeholder="Additional Impression Charge" required="" autocomplete="off" />
                    </div>
                  </div>
</div>
</div>

<div class="col-lg-3">
<div class="form-group">
<label for="cp" class="col-lg-4 control-label">DTP Charge</label>
                  <div class="col-lg-8">
                    <div class="input-group"><span class="input-group-addon"><i class="fa fa-hand-o-right"></i></span>
                      <input id="additionaldtpcharge" name="additionaldtpcharge" type="text" class="form-control" placeholder="Additional DTP Charge" required="" autocomplete="off" />
                    </div>
                  </div>
</div>
</div>



























		
                <input type="submit" id="Formsave" value="Save" name="save_estimate" class="btn btn-success center-block"/>
            </div>
          </form>
          
          
          
          
          
          
          
          </div>
          </div>
          
 
    
      <?php //include_once("dashboard_content.php");?>
    

    
    </div>
    
  </section>
  
  <!-- Start: Right Sidebar -->
  
</div>
<!-- End #Main --> 


<!-- jQuery --> 
<script type="text/javascript" src="../vendor/jquery/jquery-1.11.1.min.js"></script> 
<script type="text/javascript" src="../vendor/jquery/jquery_ui/jquery-ui.min.js"></script> <!-- Bootstrap --> 
<script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script> 

<!-- Page Plugins --> 
<script src="../vendor/Selectbox/bootstrap-select.min.js"></script>
<script type="text/javascript" src="../vendor/plugins/validate/jquery.validate.js"></script>  
<script type="text/javascript" src="../vendor/plugins/morris/morris.js"></script> 
<script type="text/javascript" src="../vendor/plugins/datatables/js/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="../vendor/plugins/datatables/js/datatables.js"></script> 
<script type="text/javascript" src="../vendor/plugins/multiselect/bootstrap-multiselect.js"></script> 
<script type="text/javascript" src="../vendor/plugins/jvectormap/jquery-jvectormap.min.js"></script> 
<script type="text/javascript" src="../vendor/plugins/jvectormap/assets/jquery-jvectormap-us-lcc-en.js"></script> 
<script type="text/javascript" src="../vendor/plugins/clndr/clndr.js"></script> 
<script type="text/javascript" src="../vendor/plugins/clndr/moment.js"></script> 
<script type="text/javascript" src="../vendor/plugins/datepicker/bootstrap-datepicker.js"></script> 
<script type="text/javascript" src="../vendor/plugins/jquerymask/jquery.maskedinput.min.js"></script> 
<!-- Flot Plugins --> 
<script type="text/javascript" src="../vendor/plugins/jqueryflot/jquery.flot.min.js"></script> 

<!-- Theme Javascript --> 
<script type="text/javascript" src="../js/utility/spin.min.js"></script> 
<script type="text/javascript" src="../js/utility/underscore-min.js"></script> 
<script type="text/javascript" src="../js/main.js"></script> 
<script type="text/javascript" src="../js/ajax.js"></script> 
<script type="text/javascript" src="../js/custom.js"></script> 
<script type="text/javascript" src="../js/auto.js"></script>
<script>
function getCate(val)
{
   $.ajax({
     type: 'post',
     url: 'get_category.php',
     data: {
       get_option:val
     },
     success: function (response) {
       document.getElementById("category").innerHTML=response; 
     }
   });
}

function getplatecount(val)
{
   $.ajax({
     type: 'post',
     url: 'getplate_count.php',
     data: {
       get_option:val
     },
     success: function (response) {
       document.getElementById("ctp").value=response; 
     }
   });
}


function getPagecount(val)
{
   $.ajax({
     type: 'post',
     url: 'get_Pagecount.php',
     data: {
       get_option:val
     },
     success: function (response) {
       //document.getElementById("ctp").value=response; 
	   getplatecount(val);
     }
   });
}

function getMechine(val)
{
   $.ajax({
     type: 'post',
     url: 'get_machine.php',
     data: {
       get_option:val
     },
     success: function (response) {
       //document.getElementById("ctp").value=response; 
	   //getplatecount(val);
     }
   });
}
















function getPrintsize(val)
{
   $.ajax({
     type: 'post',
     url: 'get_fields.php',
     data: {
       get_option:val
     },
     success: function (response) {
       document.getElementById("fields").innerHTML=response; 
	   getplatecount(val);
     }
   });
}

function getbackprint(val)
{
   $.ajax({
     type: 'post',
     url: 'get_backprint_dtls.php',
     data: {
       get_option:val
     },
     success: function (response) {
       document.getElementById("bckprnt").innerHTML=response; 
	   getplatecount(val);
     }
   });
}

function getplate(val)
{
   $.ajax({
     type: 'post',
     url: 'get_plate.php',
     data: {
       get_option:val
     },
     success: function (response) {
		 getplatecount(val);
       document.getElementById("plate_dtls").innerHTML=response; 
     }
   });
}



</script>

<script type="text/javascript">
$(document).ready(function() {
    
    "use strict";

     // Init Theme Core 	  
     Core.init();

     // Enable Ajax Loading 	  
     Ajax.init();    
     
    $('.datepicker').datepicker()

	//##### send add record Ajax request to response.php #########
	$("#FormSubmit").click(function (e) {
			e.preventDefault();
             if($("#customer").val()==='')
			{
				alert("Please Select Customer!");
				return false;
			}
			//else if($("#datepicker").val()==='')
//			{
//				alert("Please enter Date!");
//				return false;
//			}
			else if($("#machinename").val()==='')
			{
				alert("Please Select Machine!");
				return false;
			}
			//else if($("#categor").val()==='')
//			{
//				alert("Please Select Category!");
//				return false;
//			}
            else if($("#product").val()==='')
			{
				alert("Please Select Product!");
				return false;
			}
						
			$("#FormSubmit").hide(); //hide submit button
			$("#LoadingImage").show(); //show loading image
			
				//+ '&length=' + $("#length").val() + '&prwidth=' + $("#prwidth").val()
			//+ '&product=' + $("#product").val()
			
			var myData = '&customer=' + $("#customer").val() + '&machinename=' + $("#machinename").val() + '&product=' + $("#product").val() + '&printsize=' + $("#printsize").val()+'&numberofpages=' + $("#numberofpages").val() + '&bckprint=' + $("#bckprint").val()+ '&samematter=' + $("#samematter").val()+ '&pacopy=' + $("#pacopy").val()+ '&paperinkColor=' + $("#paperinkColor").val() + '&numberofbooks=' + $("#numberofbooks").val()+'&numberofsetsperbooks=' + $("#numberofsetsperbooks").val()+ '&startingno=' + $("#startingno").val()+ '&typeofbndboard=' + $("#typeofbndboard").val()+ '&plate=' + $("#plate").val()+'&ctp=' + $("#ctp").val()+'&typeofwrk=' + $("#typeofwrk").val()+ '&wrkdescription=' + $("#wrkdescription").val()+ '&lamination=' + $("input:radio[name=lamination]:checked").val()+ '&folding=' + $("input:radio[name=folding]:checked").val()+ '&creasing=' + $("input:radio[name=creasing]:checked").val()+ '&binding=' + $("input:radio[name=binding]:checked").val()+ '&stapling=' + $("input:radio[name=stapling]:checked").val()+ '&stitching=' + $("input:radio[name=stitching]:checked").val()+ '&pasting=' + $("input:radio[name=pasting]:checked").val()+ '&prntlastcopy=' + $("input:radio[name=prntlastcopy]:checked").val()+ '&sion=' + $("#sion").val(); //build a post data structure
			jQuery.ajax({
			type: "POST", // HTTP method POST or GET
			url: "../controler/estimate_add_temp.php", //Where to make Ajax calls
			dataType:"text", // Data type, HTML, json etc.
			data:myData, //Form variables
			success:function(response){
				$("#responds").append(response);
				//$("#salesdate").val(''); //empty text field on successful
				$("#FormSubmit").show(); //show submit button
				$("#LoadingImage").hide(); //hide loading image

			},
			error:function (xhr, ajaxOptions, thrownError){
				$("#FormSubmit").show(); //show submit button
				$("#LoadingImage").hide(); //hide loading image
				alert(thrownError);
			}
			});
	});

	//##### Send delete Ajax request to response.php #########
	$("body").on("click", "#responds .del_button", function(e) {
		 e.preventDefault();
		 var clickedID = this.id.split('-'); //Split ID string (Split works as PHP explode)
		 var DbNumberID = clickedID[1]; //and get number from array
		 var myData = 'recordToDelete='+ DbNumberID; //build a post data structure
if(confirm("Are you sure you want to delete this?")){		 
		$('#item_'+DbNumberID).addClass( "sel" ); //change background of this element by adding class
		$(this).hide(); //hide currently clicked delete button

			jQuery.ajax({
			type: "POST", // HTTP method POST or GET
			url: "../controler/dell_estimate_temp.php", //Where to make Ajax calls
			dataType:"text", // Data type, HTML, json etc.
			data:myData, //Form variables
			success:function(response){
				//on success, hide  element user wants to delete.
				$('#item_'+DbNumberID).fadeOut();
			},
			error:function (xhr, ajaxOptions, thrownError){
				//On error, we alert user
				alert(thrownError);
			}
			});
}
	});

});
</script>  
</body>
</html>