<?php 
 echo @$_GET['msg'];
  // session_start();
  // if(isset($_SESSION['userId'])){ 
if(isset($_POST['dated'])){
extract($_POST);


 require 'connection.php';
$qry = "SELECT vno,qty,srate, crate,itemid FROM feedinout where dated='$dated' order by vno asc";
             $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
    while($row = mysqli_fetch_array($run)){
$vno=$row['vno'];
$itmid=$row['itemid'];


  $qry1 = "SELECT supid,custid FROM feedinout where vno='$vno'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
$supid=$row1['supid'];
$accid=$row1['custid'];

  $qry1 = "SELECT itemname FROM itemreg where itemid='$itmid'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
$itmname=$row1['itemname'];



$qry1 = "SELECT accname FROM accreg where accid='$supid'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
$supliername=$row1['accname'];

$qry1 = "SELECT accname FROM accreg where accid='$accid'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
$custname=$row1['accname'];

?>
                
         <tr>
        <td class="center"><?php echo $row['vno']; ?></td>
        <td class="center"><i style="color: green; font-weight: bold;"><?php echo $supliername; ?></i>
        	<br><i style="color: brown; font-weight: bold;"><?php echo $custname; ?></i></td>
        <td style="color: #3D0C02; font-weight: bold;" class="center" class="center"><?php echo $itmname.' / '.$row['qty'];?></td>
        <td style="color: green; font-weight: bold;" class="center"><?php echo $row['srate']; ?></td>
        <td style="color: brown; font-weight: bold;" class="center"><?php echo $row['crate']; ?></td>

  
    </tr>


   <?php } 



}

if(isset($_POST['suprate'])){
extract($_POST);


 require 'connection.php';


  $qry1 = "SELECT max(trid) as trid FROM setrate where accid='$supid' and itemid='$suprate'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
$trid=$row1['trid'];


  $qry1 = "SELECT prate FROM setrate where trid='$trid'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
echo $row1['prate'];
}


if(isset($_POST['custrate'])){
extract($_POST);


 require 'connection.php';


  $qry1 = "SELECT max(trid) as trid FROM setrate where accid='$custid' and itemid='$custrate'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
$trid=$row1['trid'];


  $qry1 = "SELECT srate FROM setrate where trid='$trid'";
  $run1 = mysqli_query($connect, $qry1) or die(mysqli_error($connect));
  $row1 = mysqli_fetch_array($run1);
echo $row1['srate'];
}


// }

?>
