<?php
include("../../packages/require.php");
include("controller/controller_dashboard.php");
$curpage = "dashboard";
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title><?=$title['dashboard'];?></title>
    <?php include($global['root']."packages/head.php");?>
    <style type="text/css">
        .icon .fa {
            font-size: 70px;
            line-height: 0 !important;
            -webkit-font-smoothing: antialiased;
            position: relative;
            top: -8px;
        }
        .icon .fa::before {
            line-height: 1;
        }
        .box-top-rms h3 {margin: 0;padding: 15px 0;font-size: 40px;}

        .box-top-rms {
            min-height: 90px;
        }

        .box-top-rms .icon {
            top: 2px;
            display: none;
        }

        .box-top-rms h3 > span {
            background-color: #ffff;
            color: #444;
            padding: 2px 12px;
            font-size: 40px;
            border-radius: 10px;
            float: right;
            top: -3px;
            position: relative;
        }
        .table-hover th {
            text-transform: uppercase !important;
        }
        @media(max-width: 991px){
            .box-top-rms h3 > span {
                display: inline-block;
                float: none;
                top: 0;
                font-size: 30px;
                display: block;
                text-align: center;
                margin: 10px;
            }
            .box-top-rms h3 {
                display: block;
                white-space: normal;
                font-size: 30px;
                text-align: center;
            }
        }
    </style>
</head>
<body class="<?=$global['body-css'];?>">
    <div class="wrapper">

        <?php include($global['root']."section/header.php");?>

        <?php include($global['root']."section/sidebar.php");?>

        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    Dashboard
                    <small>Control panel</small>
                </h1>
                <ol class="breadcrumb">
                    <li><a href="<?=$path['dashboard'];?>"><i class="fa fa-dashboard"></i> Home</a></li>
                    <li class="active">Dashboard</li>
                </ol>
            </section>

            <!-- Main content -->
            <section class="content">

                <!-- Small boxes (Stat box) -->
                <div class="row">
                    <div class="col-sm-12">
                        <?php if($acsd_stat == 1){ ?>
                        <div class="row">
                            <div class="col-xs-12">
                                <!-- small box -->
                                <div class="small-box bg-teal box-top-rms" style="background-color: #679bd0 !important;">
                                    <div class="inner" style="text-transform: uppercase;">
                                        <h3>Total Purchase Order <span><?=$total_all;?></span></h3>
                                    </div>
                                    <div class="icon">
                                        <i class="fa fa-bar-chart"></i>
                                    </div>
                                </div>
                            </div>
                            <!-- ./col -->
                            <div class="col-lg-4 col-sm-6 col-xs-6">
                                <!-- small box -->
                                <div class="small-box bg-teal">
                                    <div class="inner" style="text-transform: uppercase;">
                                        <h3><?=$total_open;?></h3>
                                        <p>Open</p>
                                    </div>
                                    <div class="icon">
                                        <i class="ion ion-bag"></i>
                                    </div>
                                    <?php if($acsg_po == 1){ ?>
                                    <a href="<?=$path['po'].'open/';?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
                                    <?php } else { ?>
                                    <a href="javascript:void(0);" class="small-box-footer">-</a>
                                    <?php } ?>
                                </div>
                            </div>
                            <!-- ./col -->
                            <div class="col-lg-4 col-sm-6 col-xs-6">
                                <!-- small box -->
                                <div class="small-box bg-yellow">
                                    <div class="inner" style="text-transform: uppercase;">
                                        <h3><?=$total_prepared;?></h3>
                                        <p>Prepared</p>
                                    </div>
                                    <div class="icon">
                                        <i class="ion ion-checkmark"></i>
                                    </div>
                                    <?php if($acsg_po == 1){ ?>
                                    <a href="<?=$path['po'].'prepared/';?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
                                    <?php } else { ?>
                                    <a href="javascript:void(0);" class="small-box-footer">-</a>
                                    <?php } ?>
                                </div>
                            </div>
                            <!-- ./col -->
                            <div class="col-lg-4 col-sm-6 col-xs-6">
                                <!-- small box -->
                                <div class="small-box bg-maroon">
                                    <div class="inner" style="text-transform: uppercase;">
                                        <h3><?=$total_progress;?></h3>
                                        <p>In Progress</p>
                                    </div>
                                    <div class="icon">
                                        <i class="fa fa-hourglass-half"></i>
                                    </div>
                                    <?php if($acsg_po == 1){ ?>
                                    <a href="<?=$path['po'].'progress/';?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
                                    <?php } else { ?>
                                    <a href="javascript:void(0);" class="small-box-footer">-</a>
                                    <?php } ?>
                                </div>
                            </div>
                            <!-- ./col -->
                            <div class="col-lg-4 col-sm-6 col-xs-6">
                                <!-- small box -->
                                <div class="small-box bg-green">
                                    <div class="inner" style="text-transform: uppercase;">
                                        <h3><?=$total_complete;?></h3>
                                        <p>Completed</p>
                                    </div>
                                    <div class="icon">
                                        <i class="ion ion-checkmark"></i>
                                    </div>
                                    <?php if($acsg_po == 1){ ?>
                                    <a href="<?=$path['po'].'complete/';?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
                                    <?php } else { ?>
                                    <a href="javascript:void(0);" class="small-box-footer">-</a>
                                    <?php } ?>
                                </div>
                            </div>
                            <!-- ./col -->
                            <div class="col-lg-4 col-sm-6 col-xs-6">
                                <!-- small box -->
                                <div class="small-box bg-red">
                                    <div class="inner" style="text-transform: uppercase;">
                                        <h3><?=$total_cancel;?></h3>
                                        <p>Cancelled</p>
                                    </div>
                                    <div class="icon">
                                        <i class="ion ion-close"></i>
                                    </div>
                                    <?php if($acsg_po == 1){ ?>
                                    <a href="<?=$path['po'].'cancel/';?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
                                    <?php } else { ?>
                                    <a href="javascript:void(0);" class="small-box-footer">-</a>
                                    <?php } ?>
                                </div>
                            </div>
                            <!-- ./col -->
                            <div class="col-lg-4 col-sm-6 col-xs-6">
                                <!-- small box -->
                                <div class="small-box bg-primary">
                                    <div class="inner" style="text-transform: uppercase;">
                                        <h3><?=$total_paid;?></h3>
                                        <p>Paid</p>
                                    </div>
                                    <div class="icon">
                                        <i class="ion ion-thumbsup"></i>
                                    </div>
                                    <?php if($acsg_po == 1){ ?>
                                    <a href="<?=$path['po'];?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
                                    <?php } else { ?>
                                    <a href="javascript:void(0);" class="small-box-footer">-</a>
                                    <?php } ?>
                                </div>
                            </div>
                            <!-- ./col -->
                        </div>
                        <?php } ?>
                        <!-- /.row -->
                        <!-- TABLE: LATEST SHIPMENT -->
                        <?php if($acsd_new_po == 1){ ?>
                        <?php if(is_array($datas)){ ?>
                        <div class="box box-info box-recent-invent">
                            <div class="box-header with-border">
                                <h3 class="box-title">Newest Purchase Order</h3>
                            </div>
                            <!-- /.box-header -->
                            <div class="box-body">
                                <div class="table-responsive table-click">
                                    <table class="table table-hover no-margin">
                                        <thead>
                                            <tr>
                                                <th class="text-center">No.</th>
                                                <th class="text-center">PO ID</th>
                                                <th class="text-center">Purchase Order No</th>
                                                <th class="text-center">Client Name</th>
                                                <th class="text-center">Sub Client</th>
                                                <th class="text-center">Region</th>
                                                <th class="text-center">PIC</th>
                                                <th class="text-center">Document Date</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $i=1;foreach($datas as $data) { ?>
                                            <tr onclick='OpenDetail("<?=$path['po-detail'].$data['po_id'].'/';?>");'>
                                                <td class='text-center'><?=$i;?></td>
                                                <td class='text-center'><?=$data['po_id'];?></td>
                                                <td class='text-center'><?=$data['po_order_num'];?></td>
                                                <td class='text-center'><?=correctDisplay($data['client_name']);?></td>
                                                <td class='text-center'><?=correctDisplay($data['po_subclient']);?></td>
                                                <td class='text-center'><?=correctDisplay($data['region_title']);?></td>
                                                <td class='text-center'><?=correctDisplay($data['admin_name']);?></td>
                                                <td class='text-center'><?=date("d-m-Y", strtotime($data['po_date']));?></td>
                                            </tr>
                                            <?php $i++;} ?>
                                        </tbody>
                                    </table>
                                </div>
                                <!-- /.table-responsive -->
                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer clearfix">
                                <a href="<?=$path['po'];?>" class="btn btn-sm btn-default btn-flat pull-right">View All Purchase Order</a>
                            </div>
                            <!-- /.box-footer -->
                        </div>
                        <!-- /.box -->
                        <?php } ?>
                        <?php } ?>
                    </div>
                </div>
            </section>
            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->

        <?php include($global['root']."section/footer.php");?>

    </div>
    <!-- ./wrapper -->

    <?php include($global['root']."packages/footer.php");?>
    <script type="text/javascript">
        $(document).ready(function() {
            <?php if($message != "") { ?>
            //use session here for alert success/failed
            var alertText = "<?=$message;?>";
                <?php if($alert != "success"){ ?>
                errorAlert(alertText);// error alert
                <?php } else { ?>
                successAlert(alertText);// success alert
                <?php } ?>
            <?php } ?>
        });
    </script>
    <script src="<?=$global['absolute-url'];?>module/dashboard/js/index.js?<?=mt_rand(10,1000);?>"></script>
</body>
</html>