<script type="text/javascript">
    var params=0;
    $(function(){
        $("#print").click(function(e){
            window.frames["preview"].focus();
            window.frames["preview"].print();
        });
            
            
        $("#show").click(function(e){
              var product = document.getElementById('product');
              var warehouse = document.getElementById('warehouse');
              var reason = document.getElementById('select_custom');
              var materialcategory = document.getElementById('materialcategory');
              var datefrom = document.getElementById('datepicker');
              var dateto = document.getElementById('datepicker2');
                $.ajax(
                {
                    type: "POST",
                    url: "<?php echo base_url(); ?>reports/inventory/setparamsinsessionforstockdiary",
                    //dataType: "json",
                    data: {PRODUCT:product.value,WAREHOUSE:warehouse.value, REASON:reason.value,MATERIALCATEGORY:materialcategory.value,DATEFROM:datefrom.value,DATETO:dateto.value},
                    success: function(data){
                        
                        document.getElementById("preview").src =  "<?php echo base_url(); ?>reports/inventory/printstockdiary";
                   
                },
                                        
                     error:function (xhr, ajaxOptions, thrownError){
                          alert(thrownError);
                     }
                 });

                 e.preventDefault();
                   //alert('here also ');
                return false;

                  });

    });
   
    
</script>
<!-- WAREHOUSE AUTOCOMPLETE -->

<style>

    #preview 
    {
        border: 1px solid #ddd;
        padding: 10px;
    }
    .form-control, select
    {
        padding: 3px 12px;
    }
</style>
<!-- Page Content -->
<div class="page-content">

    <!-- Page Header -->
    <div class="page-header position-relative">
        <div class="header-title">
            <h1>
             Stock Diary
            </h1>
        </div>
        <!--Header Buttons-->
        <div class="header-buttons">
            <a class="sidebar-toggler" href="#">
                <i class="fa fa-arrows-h"></i>
            </a>
            <a class="refresh" id="refresh-toggler" href="">
                <i class="glyphicon glyphicon-refresh"></i>
            </a>
            <a class="fullscreen" id="fullscreen-toggler" href="#">
                <i class="glyphicon glyphicon-fullscreen"></i>
            </a>
        </div>
        <!--Header Buttons End-->
    </div>
    <!-- /Page Header -->
    <!-- Page Body -->
    <div class="page-body" id="resources">
      <div class="well with-header">
          <div class="row">
                     <div class="form-group">
                           <div class="col-md-2">
                                 
                                    Item
                                    <input id="product" type="text" name="product" class="form-control"/>
                                
                               </div>
                                <div class="col-md-2">
                                    Warehouse
                                    <input id="warehouse" type="text" name="warehouse" class="form-control"/>
                               </div>
                                <div class="col-md-2">
                                 Reason
                                    <select id="select_custom" name="type" class="form-control">
                                        <option value="" selected=’selected’>Select Reason</option>
                                        <option value="1">(IN) Purchase</option>
                                        <option value="2">(IN) Refund</option>
                                        <option value="4">(IN) Movement</option>
                                        <option value="5">(IN) Production</option>
                                        <option value="-1">(OUT) Sale</option>
                                        <option value="-2">(OUT) Refund</option>
                                        <option value="-3">(OUT) Break</option>
                                        <option value="-4">(OUT) Movement</option>
                                         <option value="1000">Crossing</option>
                                         </select>
                                </div>
                                 <div class="col-md-2">
                                    Category
                                    <input id="materialcategory" type="text" name="materialcategory" class="form-control"/>
                                </div>
                                 <div class="col-md-2">
                                    Date
                                          <input name="datefrom" type="text" id="datepicker" class="form-control date-picker" data-date-format="yyyy-mm-dd"/>
                                 </div>
                                  <div class="col-md-2">
                                    Date To
                                    <input name="dateto" type="text" id="datepicker2" class="form-control date-picker" data-date-format="yyyy-mm-dd"/>
                                  </div>
                                  <div class="col-md-4">
                                     <br>
                                    <button class="btn btn-primary" id="show" name="add">Show</button>
                               
                                    <button class="btn btn-danger" id="print" name="print">Print</button>
                              </div>
                     </div>
                </div>
                <div class="row">
                        <iframe id="preview" name="preview" src="about:blank"  frameborder="5" width="100%" height="600" marginheight="0" marginwidth="0" scrolling="auto"></iframe>
                </div>
</div>
</div>
<!-- /Page Body -->
</div>
<!-- /Page Content -->

</div>
<!-- /Page Container -->
<!-- Main Container -->

</div>















