<html>
    <head>
        <title><?php echo $menu_label ?></title>
        <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/custom/css/print_new.css">
    </head>
    <style type="text/css">
        @media print {
            .noPrint { display: none; }
        }
    </style>
    <body>
        <div class="easyui-layout" data-options="fit:true,border:false">
            <!-- Top view-->
            <div id="form-header" data-options="region:'north',border:false">
                <div id="form-header-wrapper">
                    <table cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td align="left" valign="middle">
                                <a href="#" class="easyui-linkbutton noPrint" data-options="plain:true,iconCls:'icon-print'" onClick="print_detail()" <?=in_array($detail->TransStatus,array(1,2,3,9))?'':'disabled';?>>Print</a>
                                <a href="#" class="easyui-linkbutton noPrint" data-options="plain:true,iconCls:'icon-excel'" onClick="modal_open('Import New Account', 'dlg_importfile');" >Export File</a>

                            </td>             
                        </tr>
                    </table>  
                </div>      
            </div>
            <br><br>
            <!-- Header -->
            <div id="print-container">
                <?php
                $CountList = count($list); // Count total item
                if ($CountList <= 18):
                    $MaxList = 18;
                    ?>
                    <!-- Start Item <=8 -->
                    <!-- HEADER -->
                    <table class="header">
                        <tr>
                            <td colspan="2" class="bdr-left bdr-right bdr-top bdr-bottom head-left" rowspan="2">
                                <span class="small_bold span_block" ><?php echo $detail->CompanyName; ?> - <?php echo $detail->BranchName; ?></span>
                                <span class="small_bold span_block"><?php echo $detail->BranchAddress; ?></span>
                            </td>
                            <td colspan="2" class="bdr-right bdr-top bdr-bottom head-right">
                                <h2>INVENTORIES ADJUSTMENT</h2>
                            </td>
                        </tr>
                        <tr>
                         
                        	<td class="bdr-right bdr-bottom head-right-bottom text-top">
                              <p><label class="lbl-a" >ADj. No</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo $detail->IAdjNumber;?></label></p>
                            </td>
                            <td class="bdr-right bdr-bottom head-right-bottom text-top">
                              <p><label class="lbl-aright" >ADj. Date</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo date("d-m-Y", strtotime($detail->IAdjDate)); ?></label></p>
                              <p><label class="lbl-aright" >Branch</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo $detail->BranchName;?></label></p>
                            </td>
                        </tr>
                    </table>
                    <!-- Detail Item -->
                    <table class="content">
                        <tr class="content-top">
                            <th class="bdr-right bdr-left bdr-top bdr-bottom th-code"><span class="normal_bold">Item Code</span></th>
                            <th class="bdr-right bdr-top bdr-bottom th-name"><span class="normal_bold">Item Description</span></th>

                            <?php
                            if ($detail->StatusCheck == 0) {
                                ?>
                                <th class="bdr-right bdr-top bdr-bottom th-qty"><span class="normal_bold">Current Qty</span></th>
                                <th class="bdr-right bdr-top bdr-bottom th-qty"><span class="normal_bold">New Qty</span></th>
                                <?php
                            } else {
                                ?>
                                <th class="bdr-right bdr-top bdr-bottom th-amount"><span class="normal_bold">Current Value</span></th>
                                <th class="bdr-right bdr-top bdr-bottom th-amount"><span class="normal_bold">New Value</span></th>
                                <?php
                            }
                            ?>
                            <th class="bdr-right bdr-top bdr-bottom th-code"><span class="normal_bold">Unit</span></th>
                        </tr>
                            <?php for ($x = 0; $x < $CountList; $x++): ?>
                            <tr class="content-middle">
                                <td class="bdr-left text-top" ><span class="small_bold"><?php echo $list[$x]['ItemCode']; ?></span></td>
                                <td class=" text-top" ><span class="small_bold"><?php echo $list[$x]['ItemDesc']; ?></span></td>
                                <?php
                                if ($detail->StatusCheck == 0) {
                                    ?>
                                    <td class=" text-right text-top"><span class="small_bold"><?php echo $list[$x]['ItemQty']; ?></span></td>
                                    <td class=" text-right text-top"><span class="small_bold"><?php echo $list[$x]['ItemNewQty']; ?></span></td>
                                    <?php
                                } else {
                                    ?>
                                    <td class=" text-right text-top"><span class="small_bold"><?php echo number_format($list[$x]['ItemValue'], "2", ",", "."); ?></span></td>
                                    <td class=" text-right text-top"><span class="small_bold"><?php echo number_format($list[$x]['ItemNewValue'], "2", ",", "."); ?></span></td>
                                    <?php
                                }
                                ?>
                                <td class=" bdr-right text-center text-top"><span class="small_bold"><?php echo $list[$x]['ItemUnit']; ?></span></td>
                            </tr>
                            <?php endfor; ?>
    <?php
    // Count Last Item
    if ($CountList < $MaxList):

        $ListDiff = $MaxList - $CountList; // Variabel Count Last Item

        for ($xi = 0; $xi < $ListDiff; $xi++):
            ?>
                                <tr class="content-middle no-item">
                                    <td class="bdr-left "><span class="small_bold">&nbsp;</span></td>
                                    <td class=" "><span class="small_bold">&nbsp;</span></td>
                                    <td class=" "><span class="small_bold">&nbsp;</span></td>
                                    <td class=" "><span class="small_bold">&nbsp;</span></td>
                                    <td class="bdr-right "><span class="small_bold">&nbsp;</span></td>
                                </tr>
        <?php endfor; ?>
    <?php endif; ?>
                        <!-- Description -->
                        <tr class="content-bottom">
                            <td colspan="5" class="bdr-left bdr-right bdr-top bdr-bottom content-bottom-desc">
                                <span class="normal_bold">Description :</span>
    <?php if ($detail->IAdjDesc != ""): ?>
                                    <span class="small_bold span_block">
        <?php echo preg_replace("/\r|\n/", "", substr($detail->IAdjDesc,0,225)); ?>
                                    </span>
                                <?php else: ?>
                                    <span class="normal_bold span_block">&nbsp;</span>
                                    <?php endif; ?>
                            </td>
                        </tr>             
                    </table>
                    <!-- Footer Form -->
                    <div class="footer">
                        <div class="footer-top">
                            <div class="footer-paraf-div">
                                <div class="footer-paraf-by normal_bold">Elektronik Prepared By</div>
                                <?php if($detail->nm_createby !=""):?>
                                <span class="text-underline text-center footer-paraf-name"><?php echo $detail->nm_createby;?></span>
                                    <?php else:?>
                                <span class="text-underline normal_bold span_block footer-paraf-name">____________</span>
                                <?php endif;?>
                            </div>       
                            <div class="footer-paraf-div">
                                <div class="footer-paraf-by normal_bold">Elektronik Approved</div>
                                <?php if($detail->nm_approve  !=""):?>
                                <span class="text-underline text-center footer-paraf-name"><?php echo $detail->nm_approve;?></span>
                                    <?php else:?>
                                <span class="text-underline normal_bold span_block footer-paraf-name">____________</span>
                                <?php endif;?>
                            </div>    
                            <?php if(($detail->TransStatus == 3) or ($detail->TransStatus == 9)){?>
                                <div class="footer-status"><h4 id="title-form" class="suspended">DOKUMEN TIDAK BERLAKU</h4></div>     
                            <?php }?>
                            <div class='clear-float'></div>
                        </div>

                        <div class="footer-bottom">
                            <div class="footer-bottom-company">
                                <div class="footer-bottom-page">Page : 1 Of 1</div>
                            </div>
                            <div class='clear-float'></div>
                        </div>
                    </div>
                    
                <?php else: ?>
                    <?php
                    $MaxList = 64;
                    if ($CountList <= $MaxList):
                        ?>
                        <!-- Item > 8 and item <=40-->
                        <!-- Start Item <=40 -->
                        <table class="header">
                                <tr>
                                    <td colspan="2" class="bdr-left bdr-right bdr-top bdr-bottom head-left" rowspan="2">
                                        <span class="small_bold span_block" ><?php echo $detail->CompanyName; ?> - <?php echo $detail->BranchName; ?></span>
                                        <span class="small_bold span_block"><?php echo $detail->BranchAddress; ?></span>
                                    </td>
                                    <td colspan="2" class="bdr-right bdr-top bdr-bottom head-right">
                                        <h2>INVENTORIES ADJUSTMENT</h2>
                                    </td>
                                </tr>
                                 <tr>
                                 
                                    <td class="bdr-right bdr-bottom head-right-bottom text-top">
                                      <p><label class="lbl-a" >ADj. No</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo $detail->IAdjNumber;?></label></p>
                                    </td>
                                    <td class="bdr-right bdr-bottom head-right-bottom text-top">
                                      <p><label class="lbl-aright" >ADj. Date</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo date("d-m-Y", strtotime($detail->IAdjDate)); ?></label></p>
                                      <p><label class="lbl-aright" >Branch</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo $detail->BranchName;?></label></p>
                                    </td>
                                </tr>
                            </table>
                        <!-- Detail Item -->
                        <table class="content">
                            <tr class="content-top">
                            <th class="bdr-right bdr-left bdr-top bdr-bottom th-code"><span class="normal_bold">Item Code</span></th>
                            <th class="bdr-right bdr-top bdr-bottom th-name"><span class="normal_bold">Item Description</span></th>

                            <?php
                            if ($detail->StatusCheck == 0) {
                                ?>
                                <th class="bdr-right bdr-top bdr-bottom th-qty"><span class="normal_bold">Current Qty</span></th>
                                <th class="bdr-right bdr-top bdr-bottom th-qty"><span class="normal_bold">New Qty</span></th>
                                <?php
                            } else {
                                ?>
                                <th class="bdr-right bdr-top bdr-bottom th-amount"><span class="normal_bold">Current Value</span></th>
                                <th class="bdr-right bdr-top bdr-bottom th-amount"><span class="normal_bold">New Value</span></th>
                                <?php
                            }
                            ?>
                            <th class="bdr-right bdr-top bdr-bottom th-code"><span class="normal_bold">Unit</span></th>
                            </tr>
                                <?php for ($x = 0; $x < $CountList; $x++): ?>
                                
                                <tr class="content-middle">
                                    <td class="bdr-left text-top" ><span class="small_bold"><?php echo $list[$x]['ItemCode']; ?></span></td>
                                    <td class=" text-top" ><span class="small_bold"><?php echo $list[$x]['ItemDesc']; ?></span></td>
                                    <?php
                                    if ($detail->StatusCheck == 0) {
                                        ?>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo $list[$x]['ItemQty']; ?></span></td>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo $list[$x]['ItemNewQty']; ?></span></td>
                                        <?php
                                    } else {
                                        ?>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo number_format($list[$x]['ItemValue'], "2", ",", "."); ?></span></td>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo number_format($list[$x]['ItemNewValue'], "2", ",", "."); ?></span></td>
                                        <?php
                                    }
                                    ?>
                                    <td class=" bdr-right text-center text-top"><span class="small_bold"><?php echo $list[$x]['ItemUnit']; ?></span></td>
                                </tr>
                                <?php endfor; ?>
                                <?php
                                // Count Last Item
                                if ($CountList < $MaxList):

                                    $ListDiff = $MaxList - $CountList; // Variabel Count Last Item

                                    for ($xi = 0; $xi < $ListDiff; $xi++):
                                        ?>
                                    <tr class="content-middle no-item">
                                        <td class="bdr-left "><span class="small_bold">&nbsp;</span></td>
                                        <td class=" "><span class="small_bold">&nbsp;</span></td>
                                        <td class=" "><span class="small_bold">&nbsp;</span></td>
                                        <td class=" "><span class="small_bold">&nbsp;</span></td>
                                        <td class="bdr-right "><span class="small_bold">&nbsp;</span></td>
                                    </tr>
            <?php endfor; ?>
        <?php endif; ?>
                            <!-- Description -->
                            <tr class="content-bottom">
                                <td colspan="5" class="bdr-left bdr-right bdr-top bdr-bottom content-bottom-desc">
                                    <span class="normal_bold">Description :</span>
                            <?php if ($detail->IAdjDesc != ""): ?>
                                        <span class="small_bold span_block">
                                <?php echo preg_replace("/\r|\n/", "", substr($detail->IAdjDesc,0,225)); ?>
                                        </span>
        <?php else: ?>
                                        <span class="normal_bold span_block">&nbsp;</span>
                                    <?php endif; ?>
                                </td>
                            </tr>             
                        </table>

                        <!-- Footer Form -->
                    <div class="footer">
                        <div class="footer-top">
                            <div class="footer-paraf-div">
                                <div class="footer-paraf-by normal_bold">Elektronik Prepared By</div>
                                <?php if($detail->nm_createby !=""):?>
                                <span class="text-underline text-center footer-paraf-name"><?php echo $detail->nm_createby;?></span>
                                    <?php else:?>
                                <span class="text-underline normal_bold span_block footer-paraf-name">____________</span>
                                <?php endif;?>
                            </div>       
                            <div class="footer-paraf-div">
                                <div class="footer-paraf-by normal_bold">Elektronik Approved</div>
                                <?php if($detail->nm_approve  !=""):?>
                                <span class="text-underline text-center footer-paraf-name"><?php echo $detail->nm_approve;?></span>
                                    <?php else:?>
                                <span class="text-underline normal_bold span_block footer-paraf-name">____________</span>
                                <?php endif;?>
                            </div>    
                            <?php if(($detail->TransStatus == 3) or ($detail->TransStatus == 9)){?>
                                <div class="footer-status"><h4 id="title-form" class="suspended">DOKUMEN TIDAK BERLAKU</h4></div>     
                            <?php }?>
                            <div class='clear-float'></div>
                        </div>

                        <div class="footer-bottom">
                            <div class="footer-bottom-company">
                                <div class="footer-bottom-page">Page : 1 Of 1</div>
                            </div>
                            <div class='clear-float'></div>
                        </div>
                    </div>

                <?php else: ?>
                                    <!-- Item > 8 and Item > 25 -->
                    <?php
                    $paper_count = ceil($CountList / $MaxList); // Page AMount
                    $ListTo = array(0, 0); // Array to get index Item

                    for ($i = 0; $i < $paper_count; $i++): // Loop Until Last Form

                        $ListTo[0] = $i * $MaxList; // Index Item From
                        $ListTo[1] = ($i * $MaxList) + 37; // Index Item To

                        if ($ListTo[1] == $CountList) { // If Index Item To == Item AMount
                            $ListTo[1] = $CountList - 37;
                        } elseif ($ListTo[1] > $CountList) { // If Index More Than Item AMount
                            $ListTo[1] = ($CountList - (($i - 1) * $MaxList)) - 1;
                        }
                        ?>

                            <!-- Header Form -->
                            <table class="header">
                                <tr>
                                    <td colspan="2" class="bdr-left bdr-right bdr-top bdr-bottom head-left" rowspan="2">
                                        <span class="small_bold span_block" ><?php echo $detail->CompanyName; ?> - <?php echo $detail->BranchName; ?></span>
                                        <span class="small_bold span_block"><?php echo $detail->BranchAddress; ?></span>
                                    </td>
                                    <td colspan="2" class="bdr-right bdr-top bdr-bottom head-right">
                                        <h2>INVENTORIES ADJUSTMENT</h2>
                                    </td>
                                </tr>
                                 <tr>
                         
                                    <td class="bdr-right bdr-bottom head-right-bottom text-top">
                                      <p><label class="lbl-a" >ADj. No</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo $detail->IAdjNumber;?></label></p>
                                    </td>
                                    <td class="bdr-right bdr-bottom head-right-bottom text-top">
                                      <p><label class="lbl-aright" >ADj. Date</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo date("d-m-Y", strtotime($detail->IAdjDate)); ?></label></p>
                                      <p><label class="lbl-aright" >Branch</label><label class="lbl-b" > :</label><label class="lbl-c" ><?php echo $detail->BranchName;?></label></p>
                                    </td>
                                </tr>
                            </table>
                            <!-- Detail Item -->
                            <table class="content">
                                <tr class="content-top">
                                    <th class="bdr-right bdr-left bdr-top bdr-bottom th-code"><span class="normal_bold">Item Code</span></th>
                                    <th class="bdr-right bdr-top bdr-bottom th-name"><span class="normal_bold">Item Description</span></th>

                                    <?php
                                    if ($detail->StatusCheck == 0) {
                                        ?>
                                        <th class="bdr-right bdr-top bdr-bottom th-qty"><span class="normal_bold">Current Qty</span></th>
                                        <th class="bdr-right bdr-top bdr-bottom th-qty"><span class="normal_bold">New Qty</span></th>
                                        <?php
                                    } else {
                                        ?>
                                        <th class="bdr-right bdr-top bdr-bottom th-amount"><span class="normal_bold">Current Value</span></th>
                                        <th class="bdr-right bdr-top bdr-bottom th-amount"><span class="normal_bold">New Value</span></th>
                                        <?php
                                    }
                                    ?>
                                    <th class="bdr-right bdr-top bdr-bottom th-code"><span class="normal_bold">Unit</span></th>
                                </tr>
            <?php for ($x = 0; $x < $CountList; $x++): ?>                                    
                                <tr class="content-middle">
                                    <td class="bdr-left text-top" ><span class="small_bold"><?php echo $list[$x]['ItemCode']; ?></span></td>
                                    <td class=" text-top" ><span class="small_bold"><?php echo $list[$x]['ItemDesc']; ?></span></td>
                                    <?php
                                    if ($detail->StatusCheck == 0) {
                                        ?>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo $list[$x]['ItemQty']; ?></span></td>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo $list[$x]['ItemNewQty']; ?></span></td>
                                        <?php
                                    } else {
                                        ?>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo number_format($list[$x]['ItemValue'], "2", ",", "."); ?></span></td>
                                        <td class=" text-right text-top"><span class="small_bold"><?php echo number_format($list[$x]['ItemNewValue'], "2", ",", "."); ?></span></td>
                                        <?php
                                    }
                                    ?>
                                    <td class=" bdr-right text-center text-top"><span class="small_bold"><?php echo $list[$x]['ItemUnit']; ?></span></td>
                                </tr>
                                    <?php endfor; ?>
            <?php
            // Count Last Item
            if ($CountList < $MaxList):

                $ListDiff = $MaxList - $CountList; // Variabel Count Last Item

                for ($xi = 0; $xi < $ListDiff; $xi++):
                    ?>
                                        <tr class="content-middle no-item">
                                            <td class="bdr-left "><span class="small_bold">&nbsp;</span></td>
                                            <td class=" "><span class="small_bold">&nbsp;</span></td>
                                            <td class=" "><span class="small_bold">&nbsp;</span></td>
                                            <td class=" "><span class="small_bold">&nbsp;</span></td>
                                            <td class="bdr-right "><span class="small_bold">&nbsp;</span></td>
                                        </tr>
                                    <?php endfor; ?>
                                <?php endif; ?>
                                <!-- Description -->
                                <tr class="content-bottom">
                                    <td colspan="5" class="bdr-left bdr-right bdr-top bdr-bottom content-bottom-desc">
                                        <span class="normal_bold">Description :</span>
                                <?php if ($detail->IAdjDesc != ""): ?>
                                            <span class="small_bold span_block">
                <?php echo preg_replace("/\r|\n/", "", substr($detail->IAdjDesc,0,225)); ?>
                                            </span>
            <?php else: ?>
                                            <span class="normal_bold span_block">&nbsp;</span>
            <?php endif; ?>
                                    </td>
                                </tr>             
                            </table>

                            <!-- Footer Form -->
                            <div class="margin-page">
                                <div class="footer-top">
                                    <div class="footer-paraf-div">
                                        <div class="footer-paraf-by normal_bold">Elektronik Prepared By</div>
                                        <?php if($detail->nm_createby !=""):?>
                                        <span class="text-underline text-center footer-paraf-name"><?php echo $detail->nm_createby;?></span>
                                            <?php else:?>
                                        <span class="text-underline normal_bold span_block footer-paraf-name">____________</span>
                                        <?php endif;?>
                                    </div>       
                                    <div class="footer-paraf-div">
                                        <div class="footer-paraf-by normal_bold">Elektronik Approved</div>
                                        <?php if($detail->nm_approve  !=""):?>
                                        <span class="text-underline text-center footer-paraf-name"><?php echo $detail->nm_approve;?></span>
                                            <?php else:?>
                                        <span class="text-underline normal_bold span_block footer-paraf-name">____________</span>
                                        <?php endif;?>
                                    </div>    
                                    <?php if(($detail->TransStatus == 3) or ($detail->TransStatus == 9)){?>
                                        <div class="footer-status"><h4 id="title-form" class="suspended">DOKUMEN TIDAK BERLAKU</h4></div>     
                                    <?php }?>
                                    <div class='clear-float'></div>
                                </div>

                                <div class="footer-bottom">
                                    <div class="footer-bottom-company">
                                        <div class="footer-bottom-page">Page : 1 Of 1</div>
                                    </div>
                                    <div class='clear-float'></div>
                                </div>
                            </div>
        <?php endfor; ?>
    <?php endif; ?>
                    <!-- End Item <=8 -->
<?php endif; ?>
            </div>
        </div>
    </body>
</html>

<script type="text/javascript">
    var data_append = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""];

    function print_detail() {
        //var opt_print   = $("input[type='radio'][name='opt_print']:checked").val();
        var data_print = $("#print-container").html();
        Popup(data_print);

    }

    function Popup(data)
    {
        var mywindow = window.open('', 'print-container', 'height=528,width=700');
//        var css = '<link rel="stylesheet" href="<?php echo base_url() ?>assets/custom/css/print.css" type="text/css" />';
        var css = css_print();
        mywindow.document.write('<html><head><title>Print Detail</title>');
        mywindow.document.write(css);
        mywindow.document.write('</head><body >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');

        mywindow.document.close(); // necessary for IE >= 10
        mywindow.focus(); // necessary for IE >= 10

        mywindow.print();
        mywindow.close();

        return true;
    }
</script>