<?php
// *************************************************************************
// * DEPRIXA PRO - Integrated Web Shipping System                         *
// * Copyright (c) JAOMWEB. All Rights Reserved                            *
// * Email: support@jaom.info                                              *
// * Website: http://www.jaom.info                                         *
// *************************************************************************
ini_set('display_errors', 0);
error_reporting(E_ALL);

session_start(); // Ensure session is started

if (!$user->cdp_is_Admin()) {
    header("Location: login.php");
    exit;
}

require_once("helpers/querys.php");
require_once 'helpers/vendor/autoload.php';

use Twilio\Rest\Client;

require_once("helpers/phpmailer/class.phpmailer.php");
require_once("helpers/phpmailer/class.smtp.php");

$userData = $user->cdp_getUserData();

$db = new Conexion;

// Fetch settings
$db->cdp_query("SELECT * FROM cdb_settings");
$settings = $db->cdp_registro();

$order_prefix = $settings->prefix;
$site_email = $settings->email_address;
$check_mail = $settings->mailer;
$names_info = $settings->smtp_names;
$mlogo = $settings->logo;
$msite_url = $settings->site_url;
$msnames = $settings->site_name;

$smtphost = $settings->smtp_host;
$smtpuser = $settings->smtp_user;
$smtppass = $settings->smtp_password;
$smtpport = $settings->smtp_port;
$smtpsecure = $settings->smtp_secure;

$value_weight = $settings->value_weight;
$meter = $settings->meter;

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST["create_invoice"])) {
    try {
        $next_order = $core->cdp_order_track();
        $date = date('Y-m-d H:i:s', strtotime(cdp_sanitize($_POST["order_date"]) ?: date('Y-m-d')));

        $db->cdp_query("SELECT * FROM cdb_payment_methods WHERE id = :id");
        $db->bind(':id', (int)cdp_sanitize($_POST["order_payment_method"]));
        $payment_methods = $db->cdp_registro();

        $days = (int)$payment_methods->days;
        $due_date = cdp_sumardias(date("Y-m-d H:i:s"), $days);
        $status_invoice = ($days == 0) ? 1 : 2;

        $code_prefix = (isset($_POST["prefix_check"]) && $_POST["prefix_check"] == 1) 
            ? cdp_sanitize($_POST["code_prefix2"]) 
            : cdp_sanitize($_POST["code_prefix"]);

        // Insert order
        $db->cdp_query("INSERT INTO cdb_add_order (
            user_id, order_prefix, order_no, order_date, sender_id, sender_address_id, receiver_id, 
            receiver_address_id, tax_value, tax_insurance_value, total_insured_value, tax_custom_tariffis_value, 
            value_weight, declared_value, volumetric_percentage, total_weight, sub_total, tax_discount, 
            total_tax_insurance, total_tax_custom_tariffis, total_tax, total_declared_value, total_fixed_value, 
            total_tax_discount, total_reexp, total_order, order_datetime, agency, origin_off, order_package, 
            order_item_category, order_courier, order_service_options, order_deli_time, order_pay_mode, 
            order_payment_method, status_courier, driver_id, due_date, status_invoice
        ) VALUES (
            :user_id, :order_prefix, :order_no, :order_date, :sender_id, :sender_address_id, :receiver_id, 
            :receiver_address_id, :tax_value, :tax_insurance_value, :total_insured_value, :tax_custom_tariffis_value, 
            :value_weight, :declared_value, :volumetric_percentage, :total_weight, :sub_total, :tax_discount, 
            :total_tax_insurance, :total_tax_custom_tariffis, :total_tax, :total_declared_value, :total_fixed_value, 
            :total_tax_discount, :total_reexp, :total_order, :order_datetime, :agency, :origin_off, :order_package, 
            :order_item_category, :order_courier, :order_service_options, :order_deli_time, :order_pay_mode, 
            :order_payment_method, :status_courier, :driver_id, :due_date, :status_invoice
        )");

        $db->bind(':user_id', (int)$_SESSION['userid']);
        $db->bind(':order_prefix', $code_prefix);
        $db->bind(':order_no', cdp_sanitize($_POST["order_no"]));
        $db->bind(':order_datetime', $date);
        $db->bind(':sender_id', (int)cdp_sanitize($_POST["sender_id"]));
        $db->bind(':receiver_id', (int)cdp_sanitize($_POST["recipient_id"]));
        $db->bind(':sender_address_id', (int)cdp_sanitize($_POST["sender_address_id"]));
        $db->bind(':receiver_address_id', (int)cdp_sanitize($_POST["recipient_address_id"]));
        $db->bind(':tax_value', floatval($_POST["tax_value"]));
        $db->bind(':tax_insurance_value', floatval($_POST["insurance_value"]));
        $db->bind(':total_insured_value', floatval($_POST["insured_value"]));
        $db->bind(':tax_custom_tariffis_value', floatval($_POST["tariffs_value"]));
        $db->bind(':value_weight', floatval($_POST["price_lb"]));
        $db->bind(':declared_value', floatval($_POST["declared_value_tax"]));
        $db->bind(':total_declared_value', floatval($_POST["declared_value_input"]));
        $db->bind(':total_fixed_value', floatval($_POST["fixed_value_input"]));
        $db->bind(':volumetric_percentage', $meter);
        $db->bind(':sub_total', floatval($_POST["subtotal_input"]));
        $db->bind(':tax_discount', floatval($_POST["discount_value"]));
        $db->bind(':total_reexp', floatval($_POST["reexpedicion_value"]));
        $db->bind(':total_tax_discount', floatval($_POST["discount_input"]));
        $db->bind(':total_tax_insurance', floatval($_POST["insurance_input"]));
        $db->bind(':total_tax_custom_tariffis', floatval($_POST["total_impuesto_aduanero_input"]));
        $db->bind(':total_tax', floatval($_POST["impuesto_input"]));
        $db->bind(':total_order', floatval($_POST["total_envio_input"]));
        $db->bind(':total_weight', floatval($_POST["total_weight_input"]));
        $db->bind(':order_date', date("Y-m-d H:i:s"));
        $db->bind(':agency', (int)cdp_sanitize($_POST["agency"]));
        $db->bind(':origin_off', (int)cdp_sanitize($_POST["origin_off"]));
        $db->bind(':order_package', (int)cdp_sanitize($_POST["order_package"]));
        $db->bind(':order_item_category', (int)cdp_sanitize($_POST["order_item_category"]));
        $db->bind(':order_courier', (int)cdp_sanitize($_POST["order_courier"]));
        $db->bind(':order_service_options', (int)cdp_sanitize($_POST["order_service_options"]));
        $db->bind(':order_deli_time', (int)cdp_sanitize($_POST["order_deli_time"]));
        $db->bind(':order_pay_mode', (int)cdp_sanitize($_POST["order_pay_mode"]));
        $db->bind(':order_payment_method', (int)cdp_sanitize($_POST["order_payment_method"]));
        $db->bind(':status_courier', (int)cdp_sanitize($_POST["status_courier"]));
        $db->bind(':driver_id', (int)cdp_sanitize($_POST["driver_id"]));
        $db->bind(':due_date', $due_date);
        $db->bind(':status_invoice', $status_invoice);

        $db->cdp_execute();
        $order_id = $db->dbh->lastInsertId();

        // Insert order items
        for ($count = 0; $count < (int)$_POST["total_item"]; $count++) {
            $db->cdp_query("INSERT INTO cdb_add_order_item (
                order_id, order_item_description, order_item_quantity, order_item_weight, 
                order_item_length, order_item_width, order_item_height, order_item_fixed_value, 
                order_item_declared_value
            ) VALUES (
                :order_id, :order_item_description, :order_item_quantity, :order_item_weight, 
                :order_item_length, :order_item_width, :order_item_height, :order_item_fixed_value, 
                :order_item_declared_value
            )");

            $db->bind(':order_id', $order_id);
            $db->bind(':order_item_description', cdp_sanitize($_POST["order_item_description"][$count]));
            $db->bind(':order_item_quantity', (int)cdp_sanitize($_POST["order_item_quantity"][$count]));
            $db->bind(':order_item_weight', floatval($_POST["order_item_weight"][$count]));
            $db->bind(':order_item_length', floatval($_POST["order_item_length"][$count]));
            $db->bind(':order_item_width', floatval($_POST["order_item_width"][$count]));
            $db->bind(':order_item_height', floatval($_POST["order_item_height"][$count]));
            $db->bind(':order_item_fixed_value', floatval($_POST["order_item_fixed_value"][$count]));
            $db->bind(':order_item_declared_value', floatval($_POST["order_item_declared_value"][$count]));

            $db->cdp_execute();
        }

        // File uploads
        if (!empty($_FILES['filesMultiple']['name'][0])) {
            $target_dir = "order_files/";
            $allowed_types = ['jpg', 'png', 'pdf']; // Define allowed file types
            $deleted_file_ids = !empty($_POST['deleted_file_ids']) ? explode(",", $_POST['deleted_file_ids']) : [];

            foreach ($_FILES["filesMultiple"]['tmp_name'] as $key => $tmp_name) {
                if (!in_array($key, $deleted_file_ids) && $_FILES["filesMultiple"]["size"][$key] > 0) {
                    $image_name = time() . "_" . basename($_FILES["filesMultiple"]["name"][$key]);
                    $target_file = $target_dir . $image_name;
                    $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));

                    if (in_array($imageFileType, $allowed_types) && $_FILES["filesMultiple"]["size"][$key] <= 5000000) { // 5MB limit
                        move_uploaded_file($tmp_name, $target_file);
                        cdp_insertOrdersFiles($order_id, $target_file, $image_name, date("Y-m-d H:i:s"), '0', $imageFileType);
                    }
                }
            }
        }

        $order_track = $code_prefix . cdp_sanitize($_POST["order_no"]);

        // Insert tracking
        $db->cdp_query("INSERT INTO cdb_courier_track (
            order_track, comments, t_date, status_courier, office_id, user_id
        ) VALUES (
            :order_track, :comments, :t_date, :status_courier, :office, :user_id
        )");

        $db->bind(':order_track', $order_track);
        $db->bind(':t_date', date("Y-m-d H:i:s"));
        $db->bind(':status_courier', (int)cdp_sanitize($_POST['status_courier']));
        $db->bind(':comments', 'Shipping created');
        $db->bind(':office', (int)cdp_sanitize($_POST['origin_off']));
        $db->bind(':user_id', (int)$_SESSION['userid']);
        $db->cdp_execute();

        // Email notification
        $db->cdp_query("SELECT * FROM cdb_users WHERE id = :id");
        $db->bind(':id', (int)cdp_sanitize($_POST["sender_id"]));
        $sender_data = $db->cdp_registro();

        $fullshipment = $order_track;
        $app_url = $msite_url . 'track.php?order_track=' . $fullshipment;
        $subject = "A new shipment has been created, tracking number $fullshipment";

        $email_template = cdp_getEmailTemplates(16);
        $body = str_replace(
            ['[NAME]', '[TRACKING]', '[DELIVERY_TIME]', '[URL]', '[URL_LINK]', '[SITE_NAME]', '[URL_SHIP]'],
            [$sender_data->fname . ' ' . $sender_data->lname, $fullshipment, date("Y-m-d H:i:s a"), $msite_url, $mlogo, $msnames, $app_url],
            $email_template->body
        );
        $newbody = cdp_cleanOut($body);

        if ($check_mail == 'PHP') {
            $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=UTF-8\r\nFrom: $site_email\r\n";
            mail($sender_data->email, $subject, $newbody, $headers);
        } elseif ($check_mail == 'SMTP') {
            $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->SMTPAuth = true;
            $mail->Port = $smtpport;
            $mail->IsHTML(true);
            $mail->CharSet = "utf-8";
            $mail->Host = $smtphost;
            $mail->Username = $smtpuser;
            $mail->Password = $smtppass;
            $mail->From = $site_email;
            $mail->FromName = $names_info;
            $mail->AddAddress($sender_data->email);
            $mail->Subject = $subject;
            $mail->Body = "<html><body>$newbody</body></html>";
            $mail->SMTPOptions = ['ssl' => ['verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true]];
            $mail->Send();
        }

        // WhatsApp notifications
        if ($core->twilio_sid && $core->twilio_token && $core->twilio_number) {
            $twilio = new Client($core->twilio_sid, $core->twilio_token);
            $whatsapp_body = "A new shipment has been registered, *Tracking #$fullshipment* Follow up on your package at $app_url";

            if (isset($_POST['notify_whatsapp_sender']) && $_POST['notify_whatsapp_sender'] == 1) {
                $twilio->messages->create("whatsapp:" . $sender_data->phone, [
                    "from" => "whatsapp:" . $core->twilio_number,
                    "body" => $whatsapp_body
                ]);
            }

            if (isset($_POST['notify_whatsapp_receiver']) && $_POST['notify_whatsapp_receiver'] == 1) {
                $db->cdp_query("SELECT * FROM cdb_users WHERE id = :id");
                $db->bind(':id', (int)cdp_sanitize($_POST["recipient_id"]));
                $receiver_data = $db->cdp_registro();
                $twilio->messages->create("whatsapp:" . $receiver_data->phone, [
                    "from" => "whatsapp:" . $core->twilio_number,
                    "body" => $whatsapp_body
                ]);
            }
        }

        // Insert user history
        $db->cdp_query("INSERT INTO cdb_order_user_history (user_id, order_id, action, date_history) 
            VALUES (:user_id, :order_id, :action, :date_history)");
        $db->bind(':order_id', $order_id);
        $db->bind(':user_id', (int)$_SESSION['userid']);
        $db->bind(':action', 'create shipment');
        $db->bind(':date_history', date("Y-m-d H:i:s"));
        $db->cdp_execute();

        // Insert notification
        $db->cdp_query("INSERT INTO cdb_notifications (user_id, order_id, notification_description, shipping_type, notification_date) 
            VALUES (:user_id, :order_id, :notification_description, :shipping_type, :notification_date)");
        $db->bind(':user_id', (int)$_SESSION['userid']);
        $db->bind(':order_id', $order_id);
        $db->bind(':notification_description', 'There is a new shipment, please check it');
        $db->bind(':shipping_type', '1');
        $db->bind(':notification_date', date("Y-m-d H:i:s"));
        $db->cdp_execute();
        $notification_id = $db->dbh->lastInsertId();

        // Notify driver, admins, employees, and customer
        cdp_insertNotificationsUsers($notification_id, (int)$_POST["driver_id"]);
        foreach (cdp_getUsersAdminEmployees() as $key) {
            cdp_insertNotificationsUsers($notification_id, $key->id);
        }
        cdp_insertNotificationsUsers($notification_id, (int)$_POST['sender_id']);

        // Save addresses
        $db->cdp_query("SELECT * FROM cdb_users_multiple_addresses WHERE id_addresses = :id");
        $db->bind(':id', (int)cdp_sanitize($_POST["sender_address_id"]));
        $sender_address_data = $db->cdp_registro();

        $db->cdp_query("SELECT * FROM cdb_users_multiple_addresses WHERE id_addresses = :id");
        $db->bind(':id', (int)cdp_sanitize($_POST["recipient_address_id"]));
        $recipient_address_data = $db->cdp_registro();

        $db->cdp_query("INSERT INTO cdb_address_shipments (
            order_track, sender_address, sender_country, sender_city, sender_zip_code, 
            recipient_address, recipient_country, recipient_city, recipient_zip_code
        ) VALUES (
            :order_track, :sender_address, :sender_country, :sender_city, :sender_zip_code, 
            :recipient_address, :recipient_country, :recipient_city, :recipient_zip_code
        )");
        $db->bind(':order_track', $order_track);
        $db->bind(':sender_address', $sender_address_data->address);
        $db->bind(':sender_country', $sender_address_data->country);
        $db->bind(':sender_city', $sender_address_data->city);
        $db->bind(':sender_zip_code', $sender_address_data->zip_code);
        $db->bind(':recipient_address', $recipient_address_data->address);
        $db->bind(':recipient_country', $recipient_address_data->country);
        $db->bind(':recipient_city', $recipient_address_data->city);
        $db->bind(':recipient_zip_code', $recipient_address_data->zip_code);
        $db->cdp_execute();

        header("Location: courier_view.php?id=$order_id");
        exit;
    } catch (Exception $e) {
        die("Error processing request: " . $e->getMessage());
    }
}
?>

<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" type="image/png" sizes="16x16" href="assets/<?php echo htmlspecialchars($core->favicon); ?>">
    <title><?php echo htmlspecialchars($lang['add-courier']); ?> | <?php echo htmlspecialchars($core->site_name); ?></title>
    <link rel="stylesheet" type="text/css" href="assets/libs/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.css">
    <link rel="stylesheet" href="assets/css/input-css/intlTelInput.css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="assets/select2/dist/css/select2.min.css">
    <link href="assets/css/style.min.css" rel="stylesheet">
    <link rel="stylesheet" href="assets/jquery-ui.css">
    <script src="assets/js/jquery.js"></script>
    <script src="assets/js/jquery-ui.js"></script>
    <link rel="stylesheet" href="assets/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" href="assets/custom_dependencies/bootstrap.min.css">
    <style>
        .bg-primary { background-color: #7460ee !important; }
        .dropdown-divider { height: 0; margin: .5rem 0; overflow: hidden; border-top: 1px solid #f8f9fa; }
        .dropdown-item { display: block; width: 100%; padding: .65rem 1rem; clear: both; color: #212529; text-align: inherit; background-color: transparent; border: 0; }
        .checkbox-label { font-size: 18px; padding-left: 0; }
    </style>
    <script>
        $(function() {
            $("#main-wrapper").AdminSettings({
                Theme: false,
                Layout: 'vertical',
                LogoBg: 'skin6',
                NavbarBg: 'skin1',
                SidebarType: 'mini-sidebar',
                SidebarColor: 'skin6',
                SidebarPosition: true,
                HeaderPosition: true,
                BoxedLayout: false
            });
        });
    </script>
</head>

<body>
    <?php include 'views/inc/preloader.php'; ?>
    <div id="main-wrapper">
        <?php include 'views/inc/topbar.php'; ?>
        <?php include 'views/inc/left_sidebar.php'; ?>

        <?php 
        $office = $core->cdp_getOffices(); 
        $agencyrow = $core->cdp_getBranchoffices(); 
        $courierrow = $core->cdp_getCouriercom(); 
        $statusrow = $core->cdp_getStatus(); 
        $packrow = $core->cdp_getPack(); 
        $payrow = $core->cdp_getPayment(); 
        $paymethodrow = $core->cdp_getPaymentMethod(); 
        $itemrow = $core->cdp_getItem(); 
        $moderow = $core->cdp_getShipmode(); 
        $driverrow = $user->cdp_userAllDriver(); 
        $delitimerow = $core->cdp_getDelitime(); 
        $track = $core->cdp_order_track(); 
        $categories = $core->cdp_getCategories(); 
        $code_countries = $core->cdp_getCodeCountries(); 
        $trackDigitsx = $core->cdp_trackDigits(); 
        ?>

        <div class="page-wrapper">
            <div class="page-breadcrumb">
                <div class="row">
                    <div class="col-12 align-self-center">
                        <h4 class="page-title"><i class="ti-package" aria-hidden="true"></i> Add Create Shipments</h4>
                    </div>
                </div>
            </div>

            <form method="post" id="invoice_form" name="invoice_form" enctype="multipart/form-data">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-body">
                                    <div class="form-row">
                                        <div class="form-group col-md-6">
                                            <?php if (isset($_GET['prefix_error']) && $_GET['prefix_error'] == 1) { ?>
                                                <div class="alert alert-danger" id="success-alert">
                                                    <p><span class="icon-minus-sign"></span><i class="close icon-remove-circle"></i>
                                                        <span>Error!</span> There was an error processing the request<br>Select the country code
                                                    </p>
                                                </div>
                                            <?php } ?>
                                            <label for="code_prefix_input" class="control-label col-form-label">Shipment Prefix</label>
                                            <div class="input-group mb-3">
                                                <div class="input-group-prepend">
                                                    <div class="input-group-text">
                                                        <div class="form-check form-check-inline">
                                                            <input class="form-check-input" type="checkbox" name="prefix_check" id="prefix_check" value="1">
                                                            <label class="form-check-label" for="prefix_check">Country prefix</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <input type="text" class="form-control" name="code_prefix" id="code_prefix_input" value="<?php echo htmlspecialchars($order_prefix); ?>" readonly>
                                                <select class="custom-select input-sm hide" id="code_prefix_select" name="code_prefix2" required="">
                                                    <option value="0">--Select country code--</option>
                                                    <?php foreach ($code_countries as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->iso_3166_3); ?>">
                                                            <?php echo htmlspecialchars($row->iso_3166_3 . ' - ' . $row->name); ?>
                                                        </option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="order_no" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title24']); ?></label>
                                            <div class="input-group mb-3">
                                                <input type="number" class="form-control" name="order_no" id="order_no" value="<?php echo htmlspecialchars($track); ?>" onchange="cdp_validateTrackNumber(this.value, '<?php echo htmlspecialchars($trackDigitsx); ?>');" required>
                                                <input type="hidden" name="order_no_main" id="order_no_main" value="<?php echo htmlspecialchars($track); ?>">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-body">
                                    <div class="form-row">
                                        <div class="form-group col-md-6">
                                            <label for="agency" class="control-label col-form-label"><?php echo htmlspecialchars($lang['left201']); ?></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="agency" name="agency" required>
                                                    <?php foreach ($agencyrow as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->name_branch); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="origin_off" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title14']); ?></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" name="origin_off" id="origin_off" required>
                                                    <?php foreach ($office as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->name_off); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-body">
                                    <h4 class="card-title"><i class="mdi mdi-information-outline" style="color:#36bea6"></i><?php echo htmlspecialchars($lang['langs_010']); ?></h4>
                                    <hr>
                                    <div class="resultados_ajax_add_user_modal_sender"></div>
                                    <br>
                                    <?php if ($core->active_whatsapp == 1) { ?>
                                        <label class="custom-control custom-checkbox checkbox-label">
                                            <input type="checkbox" class="custom-control-input" name="notify_whatsapp_sender" id="notify_whatsapp_sender" value="1">
                                            <b>Notify by WhatsApp <i class="fa fa-whatsapp" style="font-size: 22px; color:#07bc4c;"></i></b>
                                            <span class="custom-control-indicator"></span>
                                        </label>
                                    <?php } ?>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <label class="control-label col-form-label"><?php echo htmlspecialchars($lang['sender_search_title']); ?></label>
                                            <div class="row">
                                                <div class="col-md-10">
                                                    <div class="input-group">
                                                        <select class="select2 form-control custom-select" id="sender_id" name="sender_id" required></select>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <div class="input-group-append input-sm">
                                                        <button type="button" class="btn btn-default" data-type_user="user_customer" data-toggle="modal" data-target="#myModalAddUser"><i class="fa fa-plus"></i></button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-12">
                                            <label for="sender_address_id" class="control-label col-form-label"><?php echo htmlspecialchars($lang['sender_search_address_title']); ?></label>
                                            <div class="row">
                                                <div class="col-md-10">
                                                    <div class="input-group">
                                                        <select class="select2 form-control" id="sender_address_id" name="sender_address_id" disabled></select>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <div class="input-group-append input-sm">
                                                        <button disabled id="add_address_sender" data-type_user="user_customer" data-toggle="modal" data-target="#myModalAddRecipientAddresses" type="button" class="btn btn-default"><i class="fa fa-plus"></i></button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-body">
                                    <h4 class="card-title"><i class="mdi mdi-information-outline" style="color:#36bea6"></i><?php echo htmlspecialchars($lang['left334']); ?></h4>
                                    <hr>
                                    <div class="resultados_ajax_add_user_modal_recipient"></div>
                                    <br>
                                    <?php if ($core->active_whatsapp == 1) { ?>
                                        <label class="custom-control custom-checkbox checkbox-label">
                                            <input type="checkbox" class="custom-control-input" name="notify_whatsapp_receiver" id="notify_whatsapp_receiver" value="1">
                                            <b>Notify by WhatsApp <i class="fa fa-whatsapp" style="font-size: 22px; color:#07bc4c;"></i></b>
                                            <span class="custom-control-indicator"></span>
                                        </label>
                                    <?php } ?>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <label for="recipient_id" class="control-label col-form-label"><?php echo htmlspecialchars($lang['recipient_search_title']); ?></label>
                                            <div class="row">
                                                <div class="col-md-10">
                                                    <div class="input-group">
                                                        <select class="select2 form-control custom-select" id="recipient_id" name="recipient_id" disabled></select>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <div class="input-group-append input-sm">
                                                        <button disabled id="add_recipient" type="button" data-type_user="user_recipient" data-toggle="modal" data-target="#myModalAddUser" class="btn btn-default"><i class="fa fa-plus"></i></button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-12">
                                            <label for="recipient_address_id" class="control-label col-form-label"><?php echo htmlspecialchars($lang['recipient_search_address_title']); ?></label>
                                            <div class="row">
                                                <div class="col-md-10">
                                                    <div class="input-group">
                                                        <select class="select2 form-control" id="recipient_address_id" name="recipient_address_id" disabled></select>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <div class="input-group-append input-sm">
                                                        <button disabled id="add_address_recipient" type="button" data-type_user="user_recipient" data-toggle="modal" data-target="#myModalAddRecipientAddresses" class="btn btn-default"><i class="fa fa-plus"></i></button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-body">
                                    <h4 class="card-title"><i class="mdi mdi-book-multiple" style="color:#36bea6"></i> <?php echo htmlspecialchars($lang['add-title13']); ?></h4>
                                    <br>
                                    <div class="row">
                                        <div class="form-group col-md-3">
                                            <label for="order_item_category" class="control-label col-form-label">Service Shipping</label>
                                            <div class="input-group">
                                                <select class="custom-select col-12" id="order_item_category" name="order_item_category" required>
                                                    <?php foreach ($categories as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->name_item); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="order_package" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title17']); ?></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="order_package" name="order_package" required>
                                                    <?php foreach ($packrow as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->name_pack); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="order_courier" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title18']); ?></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="order_courier" name="order_courier" required>
                                                    <?php foreach ($courierrow as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->name_com); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="order_service_options" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title22']); ?></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="order_service_options" name="order_service_options" required>
                                                    <?php foreach ($moderow as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->ship_mode); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group col-md-3">
                                            <label for="order_deli_time" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title20']); ?></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="order_deli_time" name="order_deli_time" required>
                                                    <?php foreach ($delitimerow as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->delitime); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="order_pay_mode" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title23']); ?> <i style="color:#ff0000" class="fas fa-donate"></i></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="order_pay_mode" name="order_pay_mode" required>
                                                    <?php foreach ($payrow as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->met_payment); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="order_payment_method" class="control-label col-form-label"><?php echo htmlspecialchars($lang['payment_methods']); ?></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="order_payment_method" name="order_payment_method" required>
                                                    <?php foreach ($paymethodrow as $row) : ?>
                                                        <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->label); ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="status_courier" class="control-label col-form-label"><?php echo htmlspecialchars($lang['add-title19']); ?> <i style="color:#ff0000" class="fas fa-shipping-fast"></i></label>
                                            <div class="input-group mb-3">
                                                <select class="custom-select col-12" id="status_courier" name="status_courier" required>
                                                    <?php foreach ($statusrow as $row) : ?>
                                                        <?php if (!in_array($row->mod_style, ['Delivered', 'Pending', 'Rejected', 'Pick up', 'Picked up', 'No Picked up', 'Consolidate'])) : ?>
                                                            <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->mod_style); ?></option>
                                                        <?php endif; ?>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-4">
                                            <div>
                                                <label class="control-label" id="selectItem">Attach files</label>
                                            </div>
                                            <input class="custom-file-input" id="filesMultiple" name="filesMultiple[]" multiple type="file" style="display: none;" onchange="cdp_validateZiseFiles(); cdp_preview_images();" />
                                            <button type="button" id="openMultiFile" class="btn btn-default pull-left mb-4"><i class='fa fa-paperclip' style="font-size:18px; cursor:pointer;"></i> Upload files </button>
                                        </div>
                                        <div class="col-md-12 row" id="image_preview"></div>
                                        <div class="col-md-4 mt-4">
                                            <div id="clean_files" class="hide">
                                                <button type="button" id="clean_file_button" class="btn btn-danger ml-3"><i class='fa fa-trash' style="font-size:18px; cursor:pointer;"></i> Cancel attachments </button>
                                            </div>
                                        </div>
                                        <div class="resultados_file col-md-4 pull-right mt-4"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-body">
                                    <h4 class="card-title"><i class="fas fa-boxes" style="color:#36bea6"></i> <?php echo htmlspecialchars($lang['left212']); ?></h4>
                                    <div id="resultados_ajax"></div>
                                    <div class="card-hover">
                                        <hr>
                                        <div class="row">
                                            <div class="col-md-5">
                                                <div class="form-group">
                                                    <label for="order_item_description1"><?php echo htmlspecialchars($lang['left213']); ?></label>
                                                    <div class="input-group">
                                                        <input type="text" name="order_item_description[]" id="order_item_description1" class="form-control input-sm order_item_description" data-toggle="tooltip" data-placement="bottom" title="<?php echo htmlspecialchars($lang['left225']); ?>" placeholder="<?php echo htmlspecialchars($lang['left224']); ?>" required>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-3">
                                                <div class="form-group">
                                                    <label for="order_item_quantity1"><?php echo htmlspecialchars($lang['left214']); ?></label>
                                                    <div class="input-group">
                                                        <input min="1" type="text" onkeypress="return cdp_soloNumeros(event)" name="order_item_quantity[]" id="order_item_quantity1" data-srno="1" class="form-control input-sm order_item_quantity" data-toggle="tooltip" data-placement="bottom" title="<?php echo htmlspecialchars($lang['left227']); ?>" value="1" required />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <label for="order_item_fixed_value1">Fixed charge</label>
                                                    <div class="input-group">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" name="order_item_fixed_value[]" id="order_item_fixed_value1" data-srno="1" class="form-control input-sm number_only order_item_fixed_value" data-toggle="tooltip" data-placement="bottom" title="Fixed charge" value="0" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <label for="order_item_declared_value1">Declared value</label>
                                                    <div class="input-group">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" name="order_item_declared_value[]" id="order_item_declared_value1" data-srno="1" class="form-control input-sm number_only order_item_declared_value" data-toggle="tooltip" data-placement="bottom" title="Declared value" value="0" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-3">
                                                <div class="form-group">
                                                    <label for="order_item_weight1"><?php echo htmlspecialchars($lang['left215']); ?></label>
                                                    <div class="input-group">
                                                        <div class="input-group-append input-sm">
                                                            <button type="button" class="btn btn-default" onclick="cdp_decrementInputNumber('order_item_weight', 1)"><i class="fa fa-minus"></i></button>
                                                        </div>
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" name="order_item_weight[]" id="order_item_weight1" data-srno="1" class="form-control input-sm order_item_weight" data-toggle="tooltip" data-placement="bottom" title="<?php echo htmlspecialchars($lang['add-title31']); ?>" value="0" />
                                                        <div class="input-group-append input-sm">
                                                            <button type="button" class="btn btn-default" onclick="cdp_incrementInputNumber('order_item_weight', 1)"><i class="fa fa-plus"></i></button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <label for="order_item_length1"><?php echo htmlspecialchars($lang['left216']); ?></label>
                                                    <div class="input-group">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" name="order_item_length[]" id="order_item_length1" data-srno="1" class="form-control input-sm text_only order_item_length" data-toggle="tooltip" data-placement="bottom" title="<?php echo htmlspecialchars($lang['add-title37']); ?>" value="0" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <label for="order_item_width1"><?php echo htmlspecialchars($lang['left217']); ?></label>
                                                    <div class="input-group">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" name="order_item_width[]" id="order_item_width1" data-srno="1" class="form-control input-sm text_only order_item_width" data-toggle="tooltip" data-placement="bottom" title="<?php echo htmlspecialchars($lang['add-title38']); ?>" value="0" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <label for="order_item_height1"><?php echo htmlspecialchars($lang['left218']); ?></label>
                                                    <div class="input-group">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" name="order_item_height[]" id="order_item_height1" data-srno="1" class="form-control input-sm number_only order_item_height" data-toggle="tooltip" data-placement="bottom" title="<?php echo htmlspecialchars($lang['add-title39']); ?>" value="0" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <hr>
                                    </div>
                                    <div id="data_items"></div>
                                    <div class="row">
                                        <div class="col-md-12 mb-3">
                                            <button type="button" name="add_row" id="add_row" class="btn btn-success mb-2"><span class="fa fa-plus"></span> <?php echo htmlspecialchars($lang['left231']); ?></button>
                                        </div>
                                    </div>
                                    <div class="table-responsive">
                                        <table id="invoice-item-table" class="table">
                                            <tfoot>
                                                <tr class="card-hover">
                                                    <td colspan="2"></td>
                                                    <td colspan="2" class="text-right"><b><?php echo htmlspecialchars($lang['left240']); ?></b></td>
                                                    <td colspan="2"></td>
                                                    <td class="text-center" id="subtotal">0.00</td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="1"><b>Price Lb:</b></td>
                                                    <td>
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" class="form-control form-control-sm" value="<?php echo htmlspecialchars($core->value_weight); ?>" name="price_lb" id="price_lb" style="width: 160px;">
                                                    </td>
                                                    <td colspan="2" class="text-right"><b>Discount %</b></td>
                                                    <td colspan="2" class="text-right">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" value="0" name="discount_value" id="discount_value" class="form-control form-control-sm">
                                                    </td>
                                                    <td class="text-center" id="discount">0.00</td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"></td>
                                                    <td class="text-right" colspan="2"><b>Insured Value</b></td>
                                                    <td colspan="2">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" class="form-control form-control-sm" value="100" name="insured_value" id="insured_value">
                                                    </td>
                                                    <td class="text-center" id="insured_label"></td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"><b><?php echo htmlspecialchars($lang['left232']); ?>:</b> <span id="total_libras">0.00</span></td>
                                                    <td colspan="2" class="text-right"><b>Shipping insurance %</b></td>
                                                    <td colspan="2" class="text-right">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" class="form-control form-control-sm" value="<?php echo htmlspecialchars($core->insurance); ?>" name="insurance_value" id="insurance_value">
                                                    </td>
                                                    <td class="text-center" id="insurance">0.00</td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"><b><?php echo htmlspecialchars($lang['left234']); ?>:</b> <span id="total_volumetrico">0.00</span></td>
                                                    <td colspan="2" class="text-right"><b>Customs tariffs %</b></td>
                                                    <td colspan="2" class="text-right">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" class="form-control form-control-sm" value="<?php echo htmlspecialchars($core->c_tariffs); ?>" name="tariffs_value" id="tariffs_value">
                                                    </td>
                                                    <td class="text-center" id="total_impuesto_aduanero">0.00</td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"><b><?php echo htmlspecialchars($lang['left236']); ?></b>: <span id="total_peso">0.00</span></td>
                                                    <td></td>
                                                    <td class="text-right"><b>Tax %</b></td>
                                                    <td colspan="2">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" class="form-control form-control-sm" value="<?php echo htmlspecialchars($core->tax); ?>" name="tax_value" id="tax_value">
                                                    </td>
                                                    <td class="text-center" id="impuesto">0.00</td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"><b>Total declared value:</b> <span id="total_declared">0.00</span></td>
                                                    <td class="text-right" colspan="2"><b>Declared tax %</b></td>
                                                    <td colspan="2">
                                                        <input type="text" value="<?php echo htmlspecialchars($core->declared_tax); ?>" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" class="form-control form-control-sm" name="declared_value_tax" id="declared_value_tax">
                                                    </td>
                                                    <td class="text-center" id="declared_value_label">0.00</td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"></td>
                                                    <td class="text-right" colspan="2"><b>Fixed Charge</b></td>
                                                    <td colspan="2"></td>
                                                    <td class="text-center" id="fixed_value_label">0.00</td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"></td>
                                                    <td class="text-right" colspan="2"><b>Re expedition</b></td>
                                                    <td colspan="2">
                                                        <input type="text" onkeypress="return cdp_soloNumeros(event)" onblur="cdp_cal_final_total();" class="form-control form-control-sm" value="0" name="reexpedicion_value" id="reexpedicion_value">
                                                    </td>
                                                    <td class="text-center" id="reexpedicion_label"></td>
                                                    <td></td>
                                                </tr>
                                                <tr class="card-hover">
                                                    <td colspan="2"></td>
                                                    <td colspan="2" class="text-right"><b><?php echo htmlspecialchars($lang['add-title44']); ?> <?php echo htmlspecialchars($core->currency); ?></b></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td class="text-center" id="total_envio">0.00</td>
                                                    <td></td>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    </div>
                                    <div class="row">
                                        <?php if ($userData->userlevel == 3) { ?>
                                            <div class="col-md-6">
                                                <label for="driver_name" class="control-label col-form-label"><?php echo htmlspecialchars($lang['left208']); ?></label>
                                                <div class="input-group mb-3">
                                                    <div class="input-group-prepend">
                                                        <span class="input-group-text" style="color:#ff0000"><i class="fas fa-car"></i></span>
                                                    </div>
                                                    <input type="hidden" name="driver_id" id="driver_id" value="<?php echo htmlspecialchars($_SESSION['userid']); ?>">
                                                    <select class="custom-select col-12" id="driver_name" name="driver_name">
                                                        <option value="<?php echo htmlspecialchars($_SESSION['userid']); ?>"><?php echo htmlspecialchars($_SESSION['name']); ?></option>
                                                    </select>
                                                </div>
                                            </div>
                                        <?php } else { ?>
                                            <div class="col-md-6">
                                                <label for="driver_id" class="control-label col-form-label"><?php echo htmlspecialchars($lang['left208']); ?></label>
                                                <div class="input-group mb-3">
                                                    <div class="input-group-prepend">
                                                        <span class="input-group-text" style="color:#ff0000"><i class="fas fa-car"></i></span>
                                                    </div>
                                                    <select class="custom-select col-12" id="driver_id" name="driver_id">
                                                        <option value="0">--<?php echo htmlspecialchars($lang['left209']); ?>--</option>
                                                        <?php foreach ($driverrow as $row) : ?>
                                                            <option value="<?php echo htmlspecialchars($row->id); ?>"><?php echo htmlspecialchars($row->fname . ' ' . $row->lname); ?></option>
                                                        <?php endforeach; ?>
                                                    </select>
                                                </div>
                                            </div>
                                        <?php } ?>
                                        <div class="col-md-6">
                                            <div class="form-actions">
                                                <div class="card-body">
                                                    <div class="text-right">
                                                        <input type="hidden" name="sumador_valor_declarado" id="sumador_valor_declarado" />
                                                        <input type="hidden" name="total_item_files" id="total_item_files" value="0" />
                                                        <input type="hidden" name="deleted_file_ids" id="deleted_file_ids"/>
                                                        <input type="hidden" name="total_item" id="total_item" value="1" />
                                                        <input type="hidden" name="discount_input" id="discount_input" />
                                                        <input type="hidden" name="subtotal_input" id="subtotal_input" />
                                                        <input type="hidden" name="impuesto_input" id="impuesto_input" />
                                                        <input type="hidden" name="declared_value_input" id="declared_value_input" />
                                                        <input type="hidden" name="fixed_value_input" id="fixed_value_input" />
                                                        <input type="hidden" name="insurance_input" id="insurance_input" />
                                                        <input type="hidden" name="total_impuesto_aduanero_input" id="total_impuesto_aduanero_input" />
                                                        <input type="hidden" name="total_weight_input" id="total_weight_input" />
                                                        <input type="hidden" name="total_envio_input" id="total_envio_input" />
                                                        <input type="hidden" name="order_date" value="<?php echo date('Y-m-d'); ?>" />
                                                        <input type="submit" name="create_invoice" id="create_invoice" class="btn btn-success" value="Create Invoice" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <input type="hidden" name="core_meter" id="core_meter" value="<?php echo htmlspecialchars($core->meter); ?>" />
                    <input type="hidden" name="core_min_cost_tax" id="core_min_cost_tax" value="<?php echo htmlspecialchars($core->min_cost_tax); ?>" />
                    <input type="hidden" name="core_min_cost_declared_tax" id="core_min_cost_declared_tax" value="<?php echo htmlspecialchars($core->min_cost_declared_tax); ?>" />
                </div>
            </form>

            <?php include('views/modals/modal_add_user_shipment.php'); ?>
            <?php include('views/modals/modal_add_addresses_user.php'); ?>
        </div>

        <footer class="footer text-center">
            © <?php echo date('Y') . ' ' . htmlspecialchars($core->site_name); ?> - <?php echo htmlspecialchars($lang['foot']); ?>
        </footer>
    </div>

    <script src="assets/libs/popper.js/dist/umd/popper.min.js"></script>
    <script src="assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="assets/js/app.min.js"></script>
    <script src="assets/js/app-style-switcher.js"></script>
    <script src="assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js"></script>
    <script src="assets/js/sparkline/sparkline.js"></script>
    <script src="assets/js/waves.js"></script>
    <script src="assets/js/sidebarmenu.js"></script>
    <script src="assets/js/custom.min.js"></script>
    <script src="assets/bootstrap-datetimepicker.min.js"></script>
    <script src="assets/select2/dist/js/select2.full.min.js"></script>
    <script src="assets/select2/dist/js/select2.min.js"></script>
    <script src="assets/js/input-js/intlTelInput.js"></script>
    <script src="assets/libs/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js"></script>
    <script src="dataJs/courier_add.js"></script>
</body>
</html>