
<head>

    <meta charset="utf-8">
    <title>DIGITAL ACCOUNTS MANAGEMENT</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
    <meta name="author" content="KASHIF ALI">

    <!-- The styles -->
    <link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">

    <link href="css/charisma-app.css" rel="stylesheet">
    <link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
    <link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
    <link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
    <link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
    <link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
    <link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
    <link href='css/jquery.noty.css' rel='stylesheet'>
    <link href='css/noty_theme_default.css' rel='stylesheet'>
    <link href='css/elfinder.min.css' rel='stylesheet'>
    <link href='css/elfinder.theme.css' rel='stylesheet'>
    <link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
    <link href='css/uploadify.css' rel='stylesheet'>
    <link href='css/animate.min.css' rel='stylesheet'>


 <link rel="stylesheet" href="css/jquery-ui.css">
  <!-- <link rel="stylesheet" href="/resources/demos/style.css"> -->
  <script src="js/jquery-1.12.4.js"></script>
  <script src="js/jquery-ui.js"></script>
    <link rel="stylesheet" href="css/bootsrap_my.css" />


    <!-- jQuery -->
    <script src="bower_components/jquery/jquery.min.js"></script>

    <link rel="shortcut icon" href="img/favicon.ico">
<!-- ****************************************** -->

  <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> -->
  <link rel="stylesheet" href="css/font-awesome.min2.css">
  <link rel="stylesheet" href="dist/css/bootstrap-select.css">

<!-- ************************************************ -->
</head>



 <body  style="background-color: white; margin-top: 0%; ">
 <div  class="container"> 



<?php 
 // echo @$_GET['msg'];
 //  session_start();
	// if(isset($_SESSION['userId'])){
	// if(isset($_GET['accid'])){
		require 'connection.php';

		$from= $_GET['from'];
		$to= $_GET['to'];
	
		$debitT = 0;
		$creditT = 0;
    $qtyT = 0;
		?>
		 <div style="background-color: white; margin-top: 20px;" class="table-responsive"> 
              <button style="align-self: center; min-width: 50px; min-height: 30px;" class="btn btn-warning btn-sm" id="closebtn"><i class="glyphicon glyphicon-off"></i></button>
               <button style="min-width: 70px;"  class="btn btn-primary btn-sm" id="printbtn"><i class="glyphicon glyphicon-print"></i> Print</button> 
               <br><br>
               <h2 id="lablrpt">Medicine Profit Loss Summary</h2>
               <br>

<table  style="background-color: white;" class="table  table-stripped col-md-12">      
    <tr>
 
  
     <th  style=" padding: 10px 4px 0 5px; border: 1px solid; border-color: black; font-size: 12px; border-right: none; height: 3px; color: black; ">Product Name</th>
 
    <th style="  padding: 10px 4px 0 5px; border: 1px solid; border-color: black; border-left: none; font-size: 12px; border-right: none; height: 3px; color: black; text-align: right;">Purchase Rate</th>

    <th style="  padding: 10px 4px 0 5px; border: 1px solid; border-color: black; border-left:  none; font-size: 12px; border-right: none; height: 3px; color: black; text-align: right;">Sale Rate</th>

       <th style="  padding: 10px 4px 0 5px; border: 1px solid; border-color: black; border-left:  none; font-size: 12px; border-right: none; height: 3px; color: black; text-align: right;">Def</th>

  <th style="  padding: 10px 4px 0 5px; border: 1px solid; border-color: black; border-left:  none; font-size: 12px; border-right: none; height: 3px; color: black; text-align: right;">Stock Out</th>

    <th style="  padding: 10px 4px 0 5px; border: 1px solid; border-color: black; border-left:  none; font-size: 12px; border-right: none; height: 3px; color: black; text-align: right; border-right: 1px solid; border-right-color: black;">PLS</th>
</tr>
<?php
$crtotal = 0;
$credit = 0;
$stkout = 0;
$stkcost = 0;
$stkprvalue = 0;
$itemid = 0;
$itemname = 0;
$oppbal = 0;
$oppbaltotal = 0;
$closbal = 0;
$qty = 0;
$runingaccid ='';
$drtotal = 0;
$totlpls = 0;
$totalbal = 0;
	

// $qry = "SELECT sum(stockout) as stkout, sum(costout) as stkcost, sum(prvalue) as stkprvalue, stockledger.itemid  from stockledger inner join itemreg on stockledger.itemid=itemreg.itemid where stockledger.dated>='$from' and stockledger.dated<='$to' and itemreg.catid=3 group by stockledger.itemid";

        $qry = "SELECT sum(stockout) as stkout, sum(costout) as stkcost, sum(prvalue) as stkprvalue, stockledger.itemid, itemname  from stockledger inner join itemreg on stockledger.itemid=itemreg.itemid  where stockledger.dated>= '$from' and stockledger.dated<='$to' and catid=3 group by stockledger.itemid";
        $run_qry = mysqli_query($connect, $qry);
        while ($row=mysqli_fetch_array($run_qry)) {

            $itemid=$row['itemid'];
            // $itemname=$row['itemname'];
            $stkout=$row['stkout'];
            $stkcost=$row['stkcost'];
            $stkprvalue=$row['stkprvalue'];


$qry2 = "SELECT itemname from itemreg where itemid='$itemid'";
        $run_qry2 = mysqli_query($connect, $qry2);
      $row2=mysqli_fetch_array($run_qry2);

?>

<tr>
<td  style="border-bottom: 1px solid #304366; font-size: 12px; padding: 12px 4px 0 5px; color: black; width: auto; border-left: 1px solid; border-left-color: #304366;">

  <?php echo $row2['itemname']; ?>
        

    </td>
 
 <td  style="border: 1px solid #304366; border-left: none; border-right: none; font-size: 12px; padding: 12px 4px 0 5px; color: black; text-align: right;">
    <?php
    $prrate=$stkprvalue/$stkout;
  echo round($prrate); 
  ?>
     
 </td>

<td  style="border: 1px solid #304366;  border-left: none; border-right: none; font-size: 12px; padding: 12px 4px 0 5px; color: black; text-align: right;">
    <?php
    $slrate=$stkcost/$stkout;

      echo round($slrate);
       ?>
        
    </td> 


<td  style="border: 1px solid #304366;  border-left: none; border-right: none; font-size: 12px; padding: 12px 4px 0 5px; color: black; text-align: right;">
    <?php

  $def=$slrate-$prrate;
    echo round($def);
       ?>
        
    </td> 

    <td  style="border: 1px solid #304366;  border-left: none; border-right: none; font-size: 12px; padding: 12px 4px 0 5px; color: black; text-align: right;">
    <?php

      echo $stkout;
       ?>
        
    </td> 

<td style="font-size: 12px; padding: 12px 4px 0 5px; color: black; border-bottom: 1px solid #304366; text-align: right; border: 1px solid; border-left: none;  border-color: #304366;">
    <?php 
   $pls=$stkcost-$stkprvalue;
   $totlpls=$totlpls+$pls;
   echo $pls;
     ?>
        
    </td>
	
</tr>


		<?php

        	}
				?>


<tr>
<td  colspan="5">
    </td>

<td style="font-size: 14px; font-weight: bold; padding: 12px 4px 0 5px; color: black; text-align: right; "><?php echo $totlpls; ?></td>
 
 
</tr>

</table>

 </div>


</div>
<script src="plugins/common/common.min.js"></script>
    <script src="js/custom.min.js"></script>
    <script src="js/settings.js"></script>
    <script src="js/gleek.js"></script>
    <script src="js/styleSwitcher.js"></script>

    <!-- Chartjs -->
    <script src="./plugins/chart.js/Chart.bundle.min.js"></script>
    <!-- Circle progress -->
    <script src="./plugins/circle-progress/circle-progress.min.js"></script>
    <!-- Datamap -->
    <script src="./plugins/d3v3/index.js"></script>
    <script src="./plugins/topojson/topojson.min.js"></script>
    <script src="./plugins/datamaps/datamaps.world.min.js"></script>
    <!-- Morrisjs -->
    <script src="./plugins/raphael/raphael.min.js"></script>
    <script src="./plugins/morris/morris.min.js"></script>
    <!-- Pignose Calender -->
    <script src="./plugins/moment/moment.min.js"></script>
    <script src="./plugins/pg-calendar/js/pignose.calendar.min.js"></script>
    <!-- ChartistJS -->
    <script src="./plugins/chartist/js/chartist.min.js"></script>
    <script src="./plugins/chartist-plugin-tooltips/js/chartist-plugin-tooltip.min.js"></script>
    <script src="./js/dashboard/dashboard-1.js"></script>


<!-- Group Reg Table Script -->
    <script src="./plugins/tables/js/jquery.dataTables.min.js"></script>
    <script src="./plugins/tables/js/datatable/dataTables.bootstrap4.min.js"></script>
    <script src="./plugins/tables/js/datatable-init/datatable-basic.min.js"></script>

<script type="text/javascript">
    $(document).ready(function(e){
        
        $('#printbtn').click(function(){
            $('#printbtn').hide();
            $('#closebtn').hide();
            document.getElementById("lablrpt").style.marginTop ="-60px";

              window.print();
        })

        $('#closebtn').click(function(){
       
              window.close();
        })

    });
</script>
</body>
