<?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                         *
// *                                                                       *
// *************************************************************************



if (!$user->cdp_is_Admin())
	cdp_redirect_to("login.php");

$userData = $user->cdp_getUserData();

?>
<!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="keywords" content="Courier DEPRIXA-Integral Web System" />
	<meta name="author" content="Jaomweb">

	<title><?php echo $lang['tools-config61'] ?> | <?php echo $core->site_name ?></title>
	<?php include 'views/inc/head_scripts.php'; ?>
</head>

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


	<?php include 'views/inc/preloader.php'; ?>
	<!-- ============================================================== -->
	<!-- Main wrapper - style you can find in pages.scss -->
	<!-- ============================================================== -->
	<div id="main-wrapper">
		<!-- ============================================================== -->
		<!-- Topbar header - style you can find in pages.scss -->
		<!-- ============================================================== -->

		<!-- ============================================================== -->
		<!-- 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">

			<!-- ============================================================== -->
			<!-- Start Page Content -->
			<!-- ============================================================== -->
			<div class="email-app">
				<!-- ============================================================== -->
				<!-- Left Part menu -->
				<!-- ============================================================== -->

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

				<!-- ============================================================== -->
				<!-- Right Part contents-->
				<!-- ============================================================== -->
				<div class="right-part mail-list bg-white overflow-auto">

					<!-- Action part -->
					<div class="p-4 border-bottom">
						<div class="d-flex align-items-center">
							<div>
								<h4><?php echo $lang['tools-config61'] ?> | <?php echo $lang['tools-database9'] ?></h4>
								<span><i data-feather="chevrons-right" class="feather-sm fill-white me-2"></i> <b><?php echo $lang['tools-database10'] ?></b></span>
							</div>
						</div>
					</div>

					<!-- Button group part -->
					<div class="bg-light p-15">
						<div class="row justify-content-center">
							<div class="col-md-12">
								<div class="row">
									<div class="col-12">
										<?php

										if (isset($_GET['backupok']) && $_GET['backupok'] == "1") {
										?>
											<div class="alert customize-alert alert-dismissible alert-light-info text-info fade show" role="alert" id="success-alert">
												<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
												<div class="d-flex align-items-center font-medium">
													<p>
														<i class="bi-check2-all text-info me-2"></i>
														<?php echo $lang['leftorder216'] ?>

													</p>

												</div>
											</div>
										<?php
										}


										if (CDP_APP_MODE_DEMO === false) {

											if (isset($_GET['create']) && $_GET['create'] == "1") {

												doBackup();
											}
										}


										?>


										<!-- <div id="loader" style="display:none"></div> -->
										<div id="resultados_ajax"></div>
									</div>
								</div>
							</div>
						</div>
					</div>

					<div class="card-body">
						<div class="d-flex no-block align-items-center m-b-30">
							<h4 class="card-title"></h4>
							<div class="ml-auto">
								<div class="btn-group">
									<a href="backup.php?do=backup&amp;create=1"><button type="button" class="btn btn-dark">
											<?php echo $lang['tools-database1'] ?>
											<span class="icon-hdd"></span></button></a>
								</div>
							</div>
						</div>
						<div><br></div>

						<p class="bluetip"> <?php echo $lang['tools-database2'] ?><br />
							<?php echo $lang['tools-database3'] ?> [<strong><?php echo $lang['tools-database9'] ?></strong>] <?php echo $lang['tools-database4'] ?> <br />
							<?php echo $lang['tools-database5'] ?>
						</p>
						<hr>
						<div class="table-responsive">
							<?php
							$dir = 'backups/';
							if (is_dir($dir)) :
								$getDir = dir($dir);
								while (false !== ($file = $getDir->read())) :
									if ($file != "." && $file != ".." && $file != "user.php") :
										$sql =  ($file == $core->backup) ? " db-latest" : "";
										echo '<div class="db-backup' . $sql . '" id="item_' . $file . '"><i data-feather="database" style="color:#A3ACBA" class="feather-icon" pull-left icon-3x></i>';
										echo '<span>' . getSize(filesize('backups/' . $file)) . '</span>';

										echo '<a class="delete">
											  <small class="sdelet btn btn-light" data-toggle="tooltip" title="' . $lang['tools-database6'] . '" ' . $file . 'p"><i data-feather="trash" style="color:#f62d51" class="feather-icon"></i></small></a>';

										echo '<a href="download.php?file=' . $file . '">
											  <small class="sdown btn btn-light" data-toggle="tooltip" title="' . $lang['tools-database7'] . '"><i data-feather="download-cloud" style="color:#517FEC" class="feather-icon"></i></small></a>';

										echo '<a class="restore">
											  <small class="srestore btn btn-light" data-toggle="tooltip" title="' . $lang['tools-database8'] . '"' . $file . '"><i data-feather="refresh-ccw" style="color:#61DA0D" class="feather-icon"></i></small></a>';
										echo '<p>' . str_replace(".sql", "", $file) . '</p>';

										echo '</div>';
									endif;
								endwhile;
								$getDir->close();
							endif;
							?>
						</div>
					</div>

				</div>

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


	</div>
	<!-- ============================================================== -->
	<!-- End Page wrapper  -->
	<!-- ============================================================== -->


	<script src="dataJs/backup.js"></script>

</body>

</html>