<!DOCTYPE html>
<html lang="en">


<!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->
<head>
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Rizwan </title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="<?php echo base_url();?>assets/images/favicon.png">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/bootstrap-select/dist/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css">
    <!-- Pick date -->
   <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.date.css">
     <link href="<?php echo base_url();?>assets/vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">
    <!-- Custom Stylesheet -->
     

</head>

<body>

 <style type="text/css">
     @media print
{
  .button
  {
    display: none;
  }
}

 </style>

<div class="row">
    <div class="col-md-10">

        <div class="card mt-4">
            
            <div class="card-header">
                <!-- <img src="<?php echo base_url();?>assets/logo.png" style="width:105px;"/><br/> -->
                <span class="float-right">
                <!-- <strong>ST-0001-04</strong> <br/> -->
                <strong>Date: </strong><?php $currentDate = date('d-m-Y');
                echo $currentDate; ?><br/>
                <strong>P.O #: </strong><?php 
                    echo so_number_dc($view_all_dc[0]['so_id']);
                                    ?></span>
                </div>
            <div class="card-body">
             <div id='purchase_order_success' class='alert alert-success solid' style='display:none;'></div>
                
             <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th class="center">Supplier's Name </th>
                                <th class="center">Rizwan Associates</th>
                                <th class="center">Buyer's Name</th>
                                <th class="center"> <?php
                                $party_id = get_party_address($view_all_dc[0]['so_id']); 
                               echo  party_name($party_id);
                                ?>
                              </th>
                               <?php
                                $party_id = get_party_address($view_all_dc[0]['so_id']); 
                             
                                ?>
                              
                            </tr>

                            <tr>
                                <td>Address</td>
                                <td>A-1/f Mongophir Road S.I.T.E Karachi</td>
                                <td>Address</td>
                               <td><?php echo addres_party($party_id); ?></td> 
                            </tr>
                            <tr>
                            <td>Sales Tax number</td>
                            <td>11-00-3900-214-91</td>
                            <td>Sales Tax Number</td>
                            <td><?php echo partystrn($party_id); ?></td>
                            </tr>

                            <tr>
                            <td>NTN #</td>
                            <td>11-00-3900-214-91</td>
                            <td>NTN</td>
                            <td><?php echo partyntn($party_id); ?></td>
                            </tr>
                        </thead>
                        <tbody>
                            
                            
                        </tbody>
                    </table>
                </div>
             <p><strong>Invoice #:</strong><?php echo $view_all_dc[0]['bill_no']; ?></p>
             <div class="table-responsive">
                    <table class="table table-striped table-bordered dataTable no-footer">
                        <thead>
                            <tr>
                                <th class="center">Quantity</th>
                                <th class="center">Description</th>
                                <th class="center">Unit Price</th>
                                <th class="center">Value Excluding Sales Tax</th>
                                <th class="center">Sale Tax</th>
                                <th class="center">Value Including Taxes</th>
                                
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                            if(!empty($view_all_dc)) { 
                                $sum = 0;
                                $value_ex = 0;
                                ?>
                                <?php echo form_open(base_url(''),array('class'=>"form-horizontal add_bill", 'id'=>"add_bill")); ?>
                                   <div id='purchase_order_success' class='alert alert-success solid' style='display:none;'></div> 
                                <input type="hidden" name="so_id" value="<?php echo $view_all_dc[0]['so_id']; ?>">
                               
                                <input type="hidden" name="created" id="created" value="<?php echo date('Y-m-d H:i:s'); ?>" class="form-control required">
                                               
                                <?php form_close();?>
                                    <?php foreach ($view_all_dc as $view_all_dcs) {
                                        
                                      $toalQty = qty_dc_record($view_all_dcs['dc_id']);
                                      $value_ex += $toalQty;
                                      $get_ref = get_so_from_dcrecord($view_all_dcs['dc_id']); 
                                      $product = sale_order_pro($get_ref); 
                                      $rates = get_fg_rates($product);
                                      $gstRate = 0.18;
                                      $totalValueWithGST = $rates * $value_ex *$gstRate;
                                      $totalValue = $rates*$value_ex+$totalValueWithGST;    
                                    }
                                    ?>
                                       
                                <tr>
                                    <td class="center">
                                    <?php
                                    echo $value_ex;
                                    ?></td>
                                <td class="center"><?php
                                       $get_product = get_product_id($view_all_dcs['so_id']);
                                      
                                       $get_partty = so_party_id($view_all_dcs['so_id']);
                                      $get_fg_refcode = fg_rates_product_desc($get_product,$get_partty);
                                    echo @code_description($get_fg_refcode);
                                     
                                     ?>
                                </td>
                                <td class="center"><?php 
                                     $product = sale_order_pro($view_all_dcs['so_id']); 
                                     $rates = get_fg_rates($product);
                                    echo $rates;
                                ?></td>
                                <td class="center"><?php 
                                    $total_with_sale_tax = $rates*$value_ex;
                                    echo number_format($total_with_sale_tax);
                                ?></td>
                                <td class="center">
                                <?php
                                 $gstRate = 0.18;
                                 $totalValueWithGST = $rates * $value_ex *$gstRate;
                                 //$totalValueWithGST = $totalValue + ($totalValue * $gstRate);
                                 echo number_format($totalValueWithGST);
                                  ?></td>
                                <td class="right"><?php 
                                $totalValue = $rates*$value_ex+$totalValueWithGST;
                                echo number_format($totalValue);
                                ?></td>
                            </tr>
                            <?php
                            $sum+= $totalValue;
                        } ?>
                            
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    
                    <div class="col-lg-8 col-sm-5 ml-auto">
                        <table class="table table-clear">
                        <br/>
                    <br/>
                    <br/>
                    <br/>
                    <br/>
                    <br/>
                    <br/>
                    <br/>
                            <tbody>
                                <tr style="text-align: center;">
                                    <td class="left"><strong>Total Amount:</strong></td>
                                    <td class="right"><strong>Pkr/= <?php echo number_format($sum,2); ?></strong></td>
                                </tr>
                                <tr>
                                    <?php $amountInWords = $sum; ?>
                                <td><strong>Amount in Words:</strong></td>
                              
                               
                                    <td class="right"><?php
                                     echo number_to_words($amountInWords);
                                    ?></td>
                                   
                                </tr>
                            </tbody>
                           
                            
                        </table>
                        
                    </div>
                    
                </div>
                <table class="">
                <?php foreach ($view_all_dc as $view_all_dcs) { ?>
                            <tr>
                            <td>DC #:<?php echo $view_all_dcs['dc_id']; ?></td>
                            </tr>
                            
                            <?php } ?>
                            
                        <tr>
                        
                                <td class="right"><strong>Signature:</strong></td>
                                <td class="right"><strong>_________________________</strong></td>
                                </tr>
                        </table>
            </div>
            </div>
            <div class="col-lg-12 text-right">
                <button type="submit" id="dis_submit" class="btn btn-primary button" onclick="myFunction()">Save & Print<i class="icon-arrow-right14 position-right"></i></button>
                                 
             </div>
    </div>
</div>
       <?php  $this->load->view('footer'); ?>  
</body>
<script type="text/javascript">


function myFunction()
    {
            var mywindow = window.open('', 'PRINT', 'height=400,width=600');
        window.print();
    }

var add_order = $('#add_bill');   
    add_order.on('submit',function(e){
  $("#dis_submit").attr('disabled', true);
        e.preventDefault();
          //if (confirm('Are you sure you want to Save.?')) {
        var add_add_order = add_order.serialize();
          $.ajax({
                type:'POST',
                url:'<?php echo base_url('sales_order/update_sales_tax_bill'); ?>',
                data:add_add_order,
                dataType:'json',
                success:function(data){
                
                    console.log('first'+data.status);
                    if(data.status === 'true'){
                        console.log('second'+data.status);
                        $('#purchase_order_success').show().html('Bill Added Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('sales_order/create_sales_tax/'); ?>"} , 2000);
                    }else{
                        console.log('third'+data);          
                    }
                },
                error:function(data){console.log(data.responseText);}
            });
        //}
    });


        function proceed(id)
        {
            var ids = id;
             
              $.ajax({
                type:'POST',
               
                url:'<?php echo base_url('Purchase_order/email_to_vendor/'); ?>'+ids,
                data:ids,
                dataType:'json',
                success:function(data){
                   
                    alert('ok');
                },
                error:function(data){console.log(data.responseText);}
            });
        }


     </script>
<!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->
</html> 