<?php
include("includes/check_auth_user.php");
include("includes/dbconnect.php");
include('includes/function.php');
$zdb = $_SESSION["zdbyear_$dbname"];
mysqli_select_db($conn, $zdb);
$maindb = "transacn";
$bdb = "accmast";
if (isset($_REQUEST["party"])) {
    $name = $_REQUEST["party"];
    $article = $_REQUEST["article"];
    $size = $_REQUEST["size"];
    $getdata = mysqli_query($conn, "SELECT a.packing, SUM(a.pairs) AS pairs, SUM(a.cartons) AS cartons, a.color, a.`ordno`, a.`rate`,
                            DATE_FORMAT(a.`vouchdt`, '%d-%m-%Y') AS vouchdt, b.`name` FROM `$maindb` a, `$bdb` b
                            WHERE a.`article`='$article' AND a.`size`='$size' AND a.accode = b.accode
                            GROUP BY a.`article`, a.`size`, a.`ordno`  HAVING pairs > 0
                            ORDER BY a.`vouchdt`, a.`ordno`") or die(mysqli_error($conn)); ?>
        <?php echo "<font color='#428BCA' style='float:left;margin-left:10px;'><b>$article - $size</b></font>"; ?><table border="1" width="100%" class="table table-bordered">    <tr>        <th align='left'>Date</th>        <th align='left'>Order No.</th>        <th align='left'>Party Name</th>        <th align='left'>Colour</th>        <th align='right' style='text-align:right;'>Packing</th>        <th align='right' style='text-align:right;'>Cartons</th>        <th align='right' style='text-align:right;'>Pairs</th>        <th align='right' style='text-align:right;'>Rate</th>    </tr>    <?php while ($row = mysqli_fetch_object($getdata)) {
        echo "<tr>";
        echo "<td align='left'>";
        echo $row->vouchdt;
        echo "</td>";
        echo "<td align='left'>";
        echo $row->ordno;
        echo "</td>";
        echo "<td align='left'>";
        echo $row->name;
        echo "</td>";
        echo "<td align='left'>";
        echo $row->color;
        echo "</td>";
        echo "<td align='right' style='text-align:right;'>";
        echo $row->packing;
        echo "</td>";
        echo "<td align='right' style='text-align:right;'>";
        echo $row->cartons;
        echo "</td>";
        echo "<td align='right' style='text-align:right;'>";
        echo $row->pairs;
        echo "</td>";
        echo "<td align='right' style='text-align:right;'>";
        echo $row->rate;
        echo "</td>";
        echo "</tr>";
    } ?>    </table>                <?php
}?>