<?php
// *************************************************************************
// *                                                                       *
// * DEPRIXA BASIC -  Freight Forwarding & Shipping Software Solutions     *
// * Copyright (c) JAOMWEB. All Rights Reserved                            *
// *                                                                       *
// *************************************************************************
// *                                                                       *
// * Email: support@jaom.info                                              *
// * Website: https://deprixa.link/documentation/                          *
// *                                                                       *
// *************************************************************************
// *                                                                       *
// * This software is furnished under a license and may be used and copied *
// * only  in  accordance  with  the  terms  of such  license and with the *
// * inclusion of the above copyright notice.                              *
// * If you Purchased from Codecanyon, Please read the full License from   *
// * here- http://codecanyon.net/licenses/standard                         *
// *                                                                       *
// *************************************************************************


$userData = $user->cdp_getUserData();
$statusrow = $core->cdp_getStatus();


?>
<!DOCTYPE html>
<html dir="ltr" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="Courier DEPRIXA-Integral Web System" />
    <meta name="author" content="Jaomweb">
    <title><?php echo $lang['shiplist'] ?> | <?php echo $core->site_name ?></title>

    <!-- Favicon icon -->
    <link rel="stylesheet" href="dist/css/input-css/intlTelInput.css">
    <link rel="stylesheet" type="text/css" href="assets/libs/select2/dist/css/select2.min.css">
    <link rel="stylesheet" href="assets/libs/apexcharts/dist/apexcharts.css">

    <?php include 'views/inc/head_scripts.php'; ?>


</head>

<body>


    <div id="main-wrapper">
        <!-- ============================================================== -->
        <!-- Preloader - style you can find in spinners.css -->
        <!-- ============================================================== -->

        <?php include 'views/inc/preloader.php'; ?>

        <!-- ============================================================== -->
        <!-- Preloader - style you can find in spinners.css -->
        <!-- ============================================================== -->

        <?php include 'views/inc/topbar.php'; ?>

        <!-- End Topbar header -->


        <!-- Left Sidebar - style you can find in sidebar.scss  -->

        <?php include 'views/inc/left_sidebar.php'; ?>


        <!-- End Left Sidebar - style you can find in sidebar.scss  -->

        <!-- Page wrapper  -->

        <div class="page-wrapper">

            <div class="page-breadcrumb">
                <div class="row">
                    <div class="col-5 align-self-center">
                        <h4 class="page-title"> <?php echo $lang['shiplist']; ?> | <i class="fas fa-cubes"></i> <?php echo $lang['filter24']; ?></h4>

                    </div>
                </div>
            </div>


            <div class="container-fluid">

                <!-- -------------------------------------------------------------- -->
                <!-- Overview, Visits, Sales, Order -->
                <!-- -------------------------------------------------------------- -->
                <?php if ($userData->userlevel == 9) { ?>
                    <div class="row">
                        <!-- column -->
                        <div class="col-sm-12 col-lg-6 d-flex align-items-stretch">
                            <!-- ---------------------
                                start Last Month Summary
                            ---------------- -->
                            <div class="card w-100">
                                <div class="card-body">
                                    <div class="d-flex align-items-center mb-4">
                                        <div>
                                            <h4 class="card-title"><?php echo $lang['dashnew06'] ?></h4>
                                            <h5 class="card-subtitle"><?php echo $lang['leftorder123'] ?></h5>
                                        </div>

                                    </div>

                                    <div class="row">
                                        <!-- col shipments-->
                                        <div class="col-lg-6 col-md-6 border-end">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-info display-6">
                                                            <i data-feather="box" class="feather-xl"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['leftorder124'] ?></span>
                                                    <h3 class="font-medium m-b-0">
                                                        <?php
                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT COUNT(*) as total FROM cdb_add_order WHERE month(order_date)='$month' AND year(order_date)='$year'and  is_pickup=0 AND status_courier!=21");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo $count->total;
                                                        ?>
                                                    </h3>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- end col shipment -->

                                        <!-- col pick up -->
                                        <div class="col-lg-6 col-md-6">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-warning display-6">
                                                            <i data-feather="box" class="feather-xl"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['leftorder125'] ?></span>
                                                    <h3 class="font-medium m-b-0">
                                                        <?php

                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT COUNT(*) as total FROM cdb_add_order WHERE month(order_date)='$month' AND year(order_date)='$year'and  is_consolidate=1");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo $count->total;
                                                        ?>

                                                    </h3>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- end col pick up -->
                                    </div>

                                    <div><br></div>

                                    <div class="row">

                                        <!-- col consolidate -->
                                        <div class="col-lg-6 col-md-6 border-end">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-success display-6">
                                                            <i data-feather="box" class="feather-xl"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['leftorder126'] ?></span>
                                                    <h3 class="font-medium m-b-0">
                                                        <?php
                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT COUNT(*) as total FROM cdb_add_order WHERE month(order_date)='$month' AND year(order_date)='$year'and is_pickup=0  and  status_courier=8");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo $count->total;
                                                        ?>
                                                    </h3>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- End col consolidate -->

                                        <!-- col pre alerts-->
                                        <div class="col-lg-6 col-md-6">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-primary display-6">

                                                            <i class="ri-wallet-2-fill text-info display-6"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['count11'] ?></span>
                                                    <h4 class="font-medium m-b-0"><?php echo $core->currency; ?>
                                                        <?php
                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT IFNULL(SUM(total_order), 0) as total FROM cdb_add_order WHERE status_courier!=21 and is_consolidate!=1 and is_pickup=0 and month(order_date)='$month' AND year(order_date)='$year'");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo number_format($count->total, 2, '.', '.');
                                                        ?>
                                                    </h4>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- End col pre alerts -->

                                    </div>

                                </div>

                            </div>
                            <!-- ---------------------
                                end Last Month Summary
                            ---------------- -->
                        </div>

                        <!-- column -->
                        <div class="col-sm-12 col-lg-6 ">

                            <!-- Bsic Line Chart -->
                            <div class="col-lg-12">
                                <!-- ---------------------
                                        start Bsic Line Chart
                                    ---------------- -->
                                <div class="card">
                                    <div class="border-bottom title-part-padding">
                                        <h4 class="card-title mb-0"><?php echo $lang['count11'] ?></h4>
                                    </div>
                                    <div class="card-body analytics-info">
                                        <div id="basic-line" style="height:220px;"></div>
                                    </div>
                                </div>
                                <!-- ---------------------
                                        end Bsic Line Chart
                                    ---------------- -->
                            </div>

                        </div>
                    </div>

                <?php } else if ($userData->userlevel == 2) { ?>

                    <div class="row">
                        <!-- column -->
                        <div class="col-sm-12 col-lg-6 d-flex align-items-stretch">
                            <!-- ---------------------
                                start Last Month Summary
                            ---------------- -->
                            <div class="card w-100">
                                <div class="card-body">
                                    <div class="d-flex align-items-center mb-4">
                                        <div>
                                            <h4 class="card-title"><?php echo $lang['dashnew06'] ?></h4>
                                            <h5 class="card-subtitle"><?php echo $lang['leftorder123'] ?></h5>
                                        </div>

                                    </div>

                                    <div class="row">
                                        <!-- col shipments-->
                                        <div class="col-lg-6 col-md-6 border-end">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-info display-6">
                                                            <i data-feather="box" class="feather-xl"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['leftorder124'] ?></span>
                                                    <h3 class="font-medium m-b-0">
                                                        <?php
                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT COUNT(*) as total FROM cdb_add_order WHERE month(order_date)='$month' AND year(order_date)='$year'and  is_pickup=0");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo $count->total;
                                                        ?>
                                                    </h3>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- end col shipment -->

                                        <!-- col pick up -->
                                        <div class="col-lg-6 col-md-6">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-warning display-6">
                                                            <i data-feather="box" class="feather-xl"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['leftorder125'] ?></span>
                                                    <h3 class="font-medium m-b-0">
                                                        <?php

                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT COUNT(*) as total FROM cdb_add_order WHERE month(order_date)='$month' AND year(order_date)='$year'and  is_consolidate=1");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo $count->total;
                                                        ?>

                                                    </h3>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- end col pick up -->
                                    </div>

                                    <div><br></div>

                                    <div class="row">

                                        <!-- col consolidate -->
                                        <div class="col-lg-6 col-md-6 border-end">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-success display-6">
                                                            <i data-feather="box" class="feather-xl"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['leftorder126'] ?></span>
                                                    <h3 class="font-medium m-b-0">
                                                        <?php
                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT COUNT(*) as total FROM cdb_add_order WHERE month(order_date)='$month' AND year(order_date)='$year'and is_pickup=0  and  status_courier=8");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo $count->total;
                                                        ?>
                                                    </h3>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- End col consolidate -->

                                        <!-- col pre alerts-->
                                        <div class="col-lg-6 col-md-6">
                                            <div class="d-flex align-items-center">
                                                <div class="me-2">
                                                    <a href="#">
                                                        <span class="text-primary display-6">

                                                            <i class="ri-wallet-2-fill text-info display-6"></i>
                                                        </span>
                                                    </a>
                                                </div>
                                                <div><span><?php echo $lang['count11'] ?></span>
                                                    <h4 class="font-medium m-b-0"><?php echo $core->currency; ?>
                                                        <?php
                                                        $month = date('m');
                                                        $year = date('Y');

                                                        $db->cdp_query("SELECT IFNULL(SUM(total_order), 0) as total FROM cdb_add_order WHERE status_courier!=21 and is_consolidate!=1 and is_pickup=0 and month(order_date)='$month' AND year(order_date)='$year'");

                                                        $db->cdp_execute();

                                                        $count = $db->cdp_registro();

                                                        echo number_format($count->total, 2, '.', '.');
                                                        ?>
                                                    </h4>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- End col pre alerts -->

                                    </div>

                                </div>

                            </div>
                            <!-- ---------------------
                                end Last Month Summary
                            ---------------- -->
                        </div>

                        <!-- column -->
                        <div class="col-sm-12 col-lg-6 ">

                            <!-- Bsic Line Chart -->
                            <div class="col-lg-12">
                                <!-- ---------------------
                                        start Bsic Line Chart
                                    ---------------- -->
                                <div class="card">
                                    <div class="border-bottom title-part-padding">
                                        <h4 class="card-title mb-0"><?php echo $lang['count11'] ?></h4>
                                    </div>
                                    <div class="card-body analytics-info">
                                        <div id="basic-line" style="height:220px;"></div>
                                    </div>
                                </div>
                                <!-- ---------------------
                                        end Bsic Line Chart
                                    ---------------- -->
                            </div>

                        </div>
                    </div>

                <?php } ?>

                <div class="row">
                    <!-- Column -->

                    <div class="col-lg-12 col-xl-12 col-md-12">

                        <div class="card">
                            <div class="card-body">
                                <!-- Action part -->
                                <!-- Button group part -->
                                <div class="bg-light p-15">
                                    <div class="row justify-content-center">
                                        <div class="col-md-12">
                                            <div class="col-12">
                                                <!-- <div id="loader" style="display:none"></div> -->
                                                <div id="resultados_ajax"></div>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- Action part -->
                                <div class="row mb-5">
                                    <div class="col-md-3 col-sm-12">
                                        <!-- <div class="form-group"> -->

                                        <div class="btn-group mb-2 hide" id="div-actions-checked">
                                            <div class="row">
                                                <div class="col-lg-4">
                                                    <span class="mt-2 mr-4"><strong id="countChecked">
                                                            <h5 class="card-title">Selected: 0</h5>
                                                        </strong></span>
                                                </div>

                                                <div class="col-lg-8">
                                                    <button type="button" class="btn btn-light-info text-info"><?php echo $lang['leftorder127'] ?></button>
                                                    <button type="button" class="btn btn-light-info text-info dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                        <span class="sr-only">Toggle Dropdown</span>
                                                    </button>
                                                    <ul class="dropdown-menu">


                                                        <a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#modalCheckboxStatus"><i style="color:#20c997" class="mdi mdi-sync"></i>&nbsp;<?php echo $lang['filter35'] ?></a>

                                                        <a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#modalDriverCheckbox"><i style="color:#ff0000" class="fas fa-car"></i>&nbsp;<?php echo $lang['left208'] ?></a>

                                                        <a class="dropdown-item" onclick="cdp_printMultipleLabel();" target="_blank"> <i style="color:#343a40" class="mdi mdi-printer"></i>&nbsp;<?php echo $lang['toollabel'] ?> </a>


                                                    </ul>
                                                </div>
                                            </div>

                                        </div>
                                        <!-- </div> -->

                                    </div>

                                    <?php
                                    if ($user->cdp_is_Admin()) { ?>

                                        <div class=" col-sm-12 col-md-2 offset-7">

                                            <div class="form-group">
                                                <a href="courier_add.php"><button type="button" class="btn waves-effect waves-light btn-light-success text-success "><i class="mdi mdi-package-variant-closed" aria-hidden="true"></i> <?php echo $lang['createnewship'] ?></button></a>
                                            </div>
                                        </div>

                                    <?php } ?>

                                </div>

                                <div class="row mb-3 ml-2">

                                    <div class=" col-sm-12 col-md-4">
                                        <div class="input-group mb-3">
                                            <input type="text" name="search" id="search" class="form-control" placeholder="<?php echo $lang['leftorder260'] ?>" onkeyup="cdp_load(1);">
                                            <button class="btn btn-light-info text-info font-medium" type="button"><i class="fa fa-search"></i></button>
                                        </div>
                                    </div><!-- /.col -->

                                    <div class="col-sm-12 col-md-3">
                                        <div class="input-group">
                                            <select onchange="cdp_load(1);" class="select2 form-select" id="status_courier" name="status_courier" style="width: 100%;">
                                                <option value="0">--<?php echo $lang['left210'] ?>--</option>
                                                <?php foreach ($statusrow as $row) : ?>
                                                    <option value="<?php echo $row->id; ?>"><?php echo $row->mod_style; ?></option>

                                                <?php endforeach; ?>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-sm-12 col-md-2">
                                        <div class="input-group">
                                            <select onchange="cdp_load(1);" class="select2 form-select" id="filterby" name="filterby" style="width: 100%;">
                                                <option value="0"><?php echo $lang['leftorder128'] ?></option>
                                                <option value="2"><?php echo $lang['leftorder129'] ?></option>
                                                <option value="3"><?php echo $lang['leftorder130'] ?></option>
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <div class="outer_div"></div>


                            </div>
                        </div>
                    </div>
                    <!-- Column -->
                </div>
            </div>
            <!-- -------------------------------------------------------------- -->
            <!-- End Container fluid  -->
            <!-- -------------------------------------------------------------- -->

            <?php
            include('views/modals/modal_update_status_checked.php');
            ?>
            <?php include('views/modals/modal_send_email.php'); ?>

            <?php include('views/modals/modal_update_driver.php'); ?>
            <?php include('views/modals/modal_update_driver_checked.php'); ?>
            <?php include('views/modals/modal_verify_payment_packages.php'); ?>

            <?php include('views/modals/modal_cancel_pickup.php'); ?>


            <?php include('views/modals/modal_charges_list.php'); ?>
            <?php include('views/modals/modal_charges_add.php'); ?>
            <?php include('views/modals/modal_charges_edit.php'); ?>



            <?php include 'views/inc/footer.php'; ?>

        </div>
    </div>

    <!-- End Wrapper -->
    <script src="assets/libs/select2/dist/js/select2.full.min.js"></script>
    <script src="assets/libs/select2/dist/js/select2.min.js"></script>

    <script src="assets/libs/echarts/dist/echarts-en.min.js"></script>

    <!--datajs JavaScript -->
    <script src="dataJs/dashboard_shipments.js"></script>
    <script src="dataJs/courier.js"></script>


</body>

</html>