<?php
require_once($global['root-model']."Crud.php");
$obj_crud = new Crud();

require_once($global['root-model']."PO.php");
$obj_po = new PO();

require_once($global['root-model']."Access.php");
$obj_access = new Access();

if(!isset($_GET['action'])){

    $acsd_stat = $obj_access->check_access($obj_cruds,$_SESSION['admin_id'],'view_dashboard_stat');
    $acsd_new_po = $obj_access->check_access($obj_cruds,$_SESSION['admin_id'],'view_newest_po');
    $acsp_admin_region = $obj_access->check_access($obj_cruds,$_SESSION['admin_id'],'show_admin_region');

    if($acsp_admin_region == 1){
        $acg_region = $_SESSION['admin_region'];
    } else {
        $acg_region = "";
    }

    if($acsg_show_pic == 1){
        $acg_pic = $_SESSION['admin_id'];
    } else {
        $acg_pic = "";
    }

    $total_open = $obj_po->total_data_dashboard($obj_crud,'open',$acg_region,$acg_pic);
    $total_progress = $obj_po->total_data_dashboard($obj_crud,'progress',$acg_region,$acg_pic);
    $total_prepared = $obj_po->total_data_dashboard($obj_crud,'prepared',$acg_region,$acg_pic);
    $total_complete = $obj_po->total_data_dashboard($obj_crud,'complete',$acg_region,$acg_pic);
    $total_cancel = $obj_po->total_data_dashboard($obj_crud,'cancel',$acg_region,$acg_pic);
    $total_paid = $obj_po->total_data_dashboard_paid($obj_crud,$acg_region,$acg_pic);
    $total_all = $obj_po->total_data_dashboard_all($obj_crud,$acg_region,$acg_pic);

    $datas = $obj_po->get_data_dashboard($obj_crud,$acg_region,$acg_pic);

    if(isset($_SESSION['message_front'])){
        $message = $_SESSION['message_front'];
        unset($_SESSION['message_front']);
    } else {
        $message = "";
    }

    if(isset($_SESSION['alert_front'])){
        $alert = $_SESSION['alert_front'];
        unset($_SESSION['alert_front']);
    } else {
        $alert = "";
    }

    if(isset($_SESSION['status'])){
        $message = $_SESSION['status'];
        unset($_SESSION['status']);
    } else {
        $message = "";
    }

    if(isset($_SESSION['alert'])){
        $alert = $_SESSION['alert'];
        unset($_SESSION['alert']);
    } else {
        $alert = "";
    }

}
?>