<!-- Main content -->
<?php
session_start();
include_once './connection_sql.php';
 
?>
  
 
<section class="content">
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">Problem</h3>
            <h4 style="float: right;height: 3px;"><b id="time"></b></h4>
        </div>
        <form role="form" name ="form1" class="form-horizontal" target="_blank" action="stkrepnew_print.php">
            <div class="box-body">
                <div class="form-group col-md-12">
                    <a onclick="location.reload();" class="btn btn-default">
                        <span class="fa fa-user-plus"></span> &nbsp; NEW
                    </a>   
                    
                   
                </div>
                <div class="form-group"></div>
                <input type="hidden" id="uniq" class="form-control">

                <div id="msg_box"  class="span12 text-center"  >  </div>

               <?php
                                 
//                                        $sql14 = "update s_trn set tru_qty = qty where (LEDINDI = 'ARN' or LEDINDI ='GRN' or LEDINDI = 'GINR' or LEDINDI ='IIN'  or LEDINDI='TRN');";
//                                        $result_4 = mysqli_query($GLOBALS['dbinv'], $sql14);
//                                        $row_4 = mysqli_fetch_array($result_4);
//                                                  
//                                        $sql15 = "update s_trn set tru_qty = qty * -1 where (LEDINDI = 'ISO' or LEDINDI = 'ARR' or LEDINDI ='INV' or LEDINDI = 'GINI' or LEDINDI ='IOU');";
//                                        $result_5 = mysqli_query($GLOBALS['dbinv'], $sql15);
//                                        $row_5 = mysqli_fetch_array($result_5);
                                   

                                        echo "<table class='CSSTableGenerator' style=\"overflow-y:scroll; color:red; height:100px;overflow:scroll;\">";
                                        echo "<tr><th colspan=4' style='color:blue'>Problem Items</th></tr>";

                                        echo "<tr><th width ='50' style='color:blue'>Item No</th>";
                                        echo "<th width ='200' style='color:blue'>Qty IN Hand</th>";
                                        echo "<th width ='80' style='color:blue'>True Qty</th>";
                                        echo "<th width ='80' style='color:blue'>Department</th></tr>";
     
                                        // $sql11 = "update s_trn set tru_qty = QTY where (LEDINDI = 'ARN' or LEDINDI ='GRN' or LEDINDI = 'GINR' or LEDINDI ='IIN' or LEDINDI = 'TRN')  "; 
                                        // $result_1 = $conn->query($sql11); 
                                        // $row_1 = $result_1->fetch();
                                         
                                                  
                                        // $sql12 = "update s_trn set tru_qty = QTY * -1 where  (LEDINDI = 'ISO' or LEDINDI = 'ARR' or LEDINDI ='INV' or LEDINDI = 'GINI' or LEDINDI ='IOU')  ";
                                        // $result_2 = $conn->query($sql12); 
                                        // $row_2 = $result_2->fetch();
                                        
                                                  
                                        $sql13 = "select stk_no,QTYINHAND,sum(tru_qty),department  from view_trn_submas    group by stk_no,department  having qtyinhand <> sum(tru_qty)	";
                                        foreach ($conn->query($sql13) as $row_3) {

                                            echo "<tr><td>" . $row_3['STK_NO'] . "</td>";
                                            echo "<td>" . $row_3['QTYINHAND'] . "</td>";
                                            echo "<td>" . $row_3['sum(tru_qty)'] . "</td>";
                                            echo "<td>" . $row_3['DEPARTMENT'] . "</td></tr>";
                                        }
                                        
                                        echo "<tr><th width ='100' style='color:blue' >Item No</th>";
                                        echo "<th width ='200' style='color:blue'>Qty In Hand</th>";
                                        echo "<th width ='80' style='color:blue'>True Qty</th>"; 
     

                                                  
                                        // $sql16 = "select stk_no,QTYINHAND,sum(tru_qty)  from view_trn_smas     group by stk_no  having qtyinhand <> sum(tru_qty)";
                                        // foreach ($conn->query($sql16) as $row_6) {

                                        //     echo "<tr><td>" . $row_6['STK_NO'] . "</td>";
                                        //     echo "<td>" . $row_6['QTYINHAND'] . "</td>";
                                        //     echo "<td>" . $row_6['sum(tru_qty)'] . "</td></tr>";
                                        // }
                                        
                                          echo "<tr><th colspan=4' style='color:blue'>Minus Items</th></tr>";

                                        echo "<tr><th width ='50' style='color:blue'>Item No</th>";
                                        echo "<th width ='200' style='color:blue'>Qty IN Hand</th>"; 
                                        echo "<th width ='80' style='color:blue'>Department</th></tr>";
                                        
                                        $sql17 = "select *  from s_mas  where QTYINHAND <0   ";
                                        foreach ($conn->query($sql17) as $row_7) {

                                            echo "<tr><td>" . $row_7['STK_NO'] . "</td>";
                                            echo "<td>" . $row_7['QTYINHAND'] . "</td></tr>";
                                        }
                                        
                                        //  $sql18 = "select *  from s_submas  where QTYINHAND <0   ";
                                        // foreach ($conn->query($sql18) as $row_8) {

                                        //     echo "<tr><td>" . $row_8['STK_NO'] . "</td>";
                                        //     echo "<td>" . $row_8['QTYINHAND'] . "</td>";
                                        //     echo "<td>" . $row_8['STO_CODE'] . "</td></tr>";
                                        // }
                                        
                                        echo "<tr><th colspan=4' style='color:blue'>Department Total Problem</th></tr>";

                                        echo "<tr><th width ='50' style='color:blue'>Item No</th></tr>";
                                        
                                        //  $sql19 = "select *  from s_mas  ";
                                        // foreach ($conn->query($sql19) as $row_9) {
                                            
                                        //     $sql10 = "select sum(QTYINHAND) as QTYINHAND  from s_submas where STK_NO = '" . $row_9["STK_NO"] . "' group by STK_NO "; 
                                        //     $result_10 = $conn->query($sql10); 
                                        //     $row_10 = $result_10->fetch();
                                       
                                        //     if($row_9['QTYINHAND']!=$row_10['QTYINHAND']){
                                        //         echo "<tr><td>" . $row_9['STK_NO'] . "</td></tr>";
                                        //     }

                                            
                                        // }
                                        
                                        
                               
                                    ?>
                   
                 <!--==================================================================================================================================== -->
                  
            </div> </div> 
        </form>
    </div> 
</section> 

<script>
    

</script>

 
  
