        <link rel="stylesheet" href="css/font.css" type="text/css" />
        <script>
        function ink_report_print(url) {
        onmouseover432 = window.open(url, 'onmouseover432', 'height=580,width=1100,scrollbars=yes,left=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no');
        }
        </script>

        <?php
        error_reporting(0);
        /*********************************Get Found Result And Pagination********************************************************/
        include("../../include/db.php");
        $type_1 = $_GET['type_1'];
        ?>

        <?php
        include("../../include/db.php"); 

        function get_shift_name_from_mach($shift_time) {
        $sql_query11 = "select * from shift_creation where id='$shift_time' ";
        $rs11 = mysql_query($sql_query11);
        while ($rsdata11 = mysql_fetch_object($rs11)) {
        $to_time = $rsdata11->to_time;
        $shift_name = $rsdata11->shift_name;
        $from_time = $rsdata11->from_time;
        }
        $tot_shift = array($from_time, $to_time, $shift_name);
        return $tot_shift;
        }

        function get_machine_name($machine_no) {
        $sql_query11 = "select * from machine_creation where id='$machine_no' ";
        $rs11 = mysql_query($sql_query11);
        while ($rsdata11 = mysql_fetch_object($rs11)) {
        $machine_no = $rsdata11->machine_no;
        }
        return $machine_no;
        }

        function get_operator_id($operator_id) {
        $sql_query11 = "select * from operator_creation where id='$operator_id' ";
        $rs11 = mysql_query($sql_query11);
        while ($rsdata11 = mysql_fetch_object($rs11)) {
        $operator_name = $rsdata11->operator_name;
        }
        return $operator_name;
        }
        ?>

        <?php
        $item_name4 = $_GET['item_name'];
        $from_date = $_GET['from_date'];
        $to_date = $_GET['to_date'];
        $cur_date = date("Y-m-d");

        if ($from_date != "") {
        $from_date1 = "DATE_FORMAT(ink_date,'%Y-%m-%d')>='$from_date'";
        } else {
        $from_date1 = "";
        }

        if ($to_date != "") {
        $to_date1 = "DATE_FORMAT(ink_date,'%Y-%m-%d')<='$to_date'";
        } else {
        $to_date1 = "";
        }

        if ($item_name4 != "") {
        $item_name41 = "prod_size='$item_name4'";
        } else {
        $item_name41 = "";
        }

        $all_value10 = $from_date1 . "@" . $to_date1 . "@" . $item_name41;
        $all_array10 = explode('@', $all_value10);
        foreach ($all_array10 as $value10) {
        if ($value10 != '') {
        $get_query105 .= $value10 . " AND ";
        }
        }
        ?>

        <style type="text/css">
        .style1 {
        font-size: 16px
        }
        </style>

        <table width="100%">
        <tr>
        <td width="1%" height="38">&nbsp;</td>
        <td width="7%" class="style15">&nbsp;</td>
        <td width="13%" align="center">&nbsp;</td>
        <td width="1%">&nbsp;</td>
        <td width="6%" class="style15">&nbsp;</td>
        <td width="14%" align="center" class="style15">&nbsp;</td>
        <td width="2%">&nbsp;</td>
        <td width="11%" class="style15">&nbsp;</td>
        <td width="24%" align="left">&nbsp;</td>
        <td width="8%" align="center">&nbsp;</td>
        <td width="2%"></td>
        <td width="7%" align="center"><a href="javascript:ink_report_print('report/inl_usage_consolidated_report/ink_usages_report_print.php?item_name=<?php echo $_GET['item_name'];?>&from_date=<?php echo $_GET['from_date']; ?>&to_date=<?php echo $_GET['to_date']; ?>');" style="text-decoration:none;"><img src="img/PrinterBlack.png" width="35" height="30" title="Print" value="Print"/></a></td>
        </tr>
        </table>

        <div class="container">
        <div class="row-fluid">
        <div class="span12">
        <div class="table-responsive">
        <div class="CSSTableGenerator">
        <table border="0" width="99%" align="center" cellpadding="0" cellspacing="0">
        <tr>
        <th align="left">S.No</th>
        <th align="left">Date</th>
        <th align="left">Particulars</th>
        <?php
        $machine_numbers = array();
        $sql_user = "SELECT * FROM machine_creation WHERE mach_type='printer' ORDER BY machine_no ASC";
        $rs_user = mysql_query($sql_user);
        while ($rsdata_user = mysql_fetch_object($rs_user)) {
        $machine_no = $rsdata_user->machine_no;
        $machine_numbers[] = $machine_no;
        ?>
        <th align="left"><?php echo $machine_no; ?></th>
        <?php } ?>
        <th align="right">Qty</th>
        </tr>

        <?php
        $i = 0;
        $machine_totals = array_fill(0, count($machine_numbers), 0); // Initialize the array for machine totals

        if ($from_date != '') {
        $sql = "SELECT * FROM ink_sublist WHERE $get_query105 ink_sub_id!='' ORDER BY prod_size ASC";
        } else {
        $sql = "SELECT * FROM ink_sublist WHERE DATE_FORMAT(ink_date,'%Y-%m-%d')='$cur_date' ORDER BY prod_size ASC";
        }
        $rs = mysql_query($sql);
        $rscount = mysql_num_rows($rs);
        if ($rscount != '') {
        $s_no = 0;
        while ($rsdata = mysql_fetch_array($rs)) {
        $ink_date = $rsdata['ink_date'];
        $prod_size = $rsdata['prod_size'];
        $total_qty = $rsdata['total_req'];
        $machine_no = $rsdata['machine_no'];
        $machine_names = get_machine_name($machine_no);
        $i = $i + 1;
        ?>
        <tr>
        <td align="left" style="border:1px solid #ddd;width:20px;"><?php echo $i; ?>&nbsp;&nbsp;</td>
        <td height="29" align="left" style="border:1px solid #ddd;width: 120px;">&nbsp;&nbsp;&nbsp;<?php echo date("d-m-Y", strtotime($ink_date)); ?></td>
        <td align="left" style="border:1px solid #ddd;width: 180px;"><?php echo $prod_size; ?>&nbsp;&nbsp;</td>
        <?php
        foreach ($machine_numbers as $index => $machine_no) {
        ?>
        <td align="left" style="border:1px solid #ddd;width: 180px;">
        <?php
        if ($machine_no == $machine_names) {
        echo number_format($total_qty, 2);
        $machine_totals[$index] += $total_qty; // Update the machine total
        } else {
        echo "&nbsp;";
        }
        ?>
        </td>
        <?php } ?>
        <td align="right" style="border:1px solid #ddd;width: 80px;"><?php echo number_format($total_qty, 2); ?>&nbsp;&nbsp;</td>
        </tr>
        <?php
        $sum_tot2 += $total_qty;
        }
        }
        ?>

        <tr>
        <th height="28" colspan="3" align="right" style="border:1px solid #ddd"><strong>Total&nbsp;&nbsp;</strong></th>
        <?php
        foreach ($machine_totals as $machine_total) {
        echo "<th align='right' style='border:1px solid #ddd'>" . number_format($machine_total, 2) . "&nbsp;&nbsp;</th>";
        }
        ?>
        <th width="55" align="right" style="border:1px solid #ddd"><strong><?php echo number_format($sum_tot2, 2); ?>&nbsp;&nbsp;</strong></th>
        </tr>
        </table>
        </div>
        </div>
        </div>
        </div>
        </div>
