<?php
/**
 * HTML Change Password Form
 *
 * PHP version 7.3
 *
 * @package        SMS
 * @version        Release 1.0.0
 * @create_by      Mohammad aljaouni
 * @create_date    17-08-2020
 * @edited_by
 * @last_edit_date
 * @todo           Nothing
 */
ob_start();
session_start();
$chain = "AWdrh78y892Djk*^523*%$#ghgHGHia&%$*)AsfdsLJnLaad";
include("validateLogin.php");
include("includeInformation.php");
include("header.php");
$idUser = (int) $_SESSION['userId'];
if(!isset($idUser))
	exit;
?>
<link rel="stylesheet" type="text/css" href="../JScalendar/jquery-ui-timepicker-addon.css" />
<link rel="stylesheet" media="all" href="../JScalendar/jquery-ui.css" />
<?php if($_SESSION["language"]==1){
    ?>
    <script type="text/javascript" src="../JScalendar/jquery-ui.min.Ar.js"></script>
    <script type="text/javascript" src="../JScalendar/jquery-ui-timepicker-addon-Ar.js"></script>
    <?php
}else{
    ?>
    <script type="text/javascript" src="../JScalendar/jquery-ui.min.js"></script>
    <script type="text/javascript" src="../JScalendar/jquery-ui-timepicker-addon.js"></script>
    <?php
}
?>
<script>
function changeSearchAction() {
	
	if($('#searchFrom').val() == "") {
		alert("<?php echo $archivesSearchLBL["searchTimeEndStart"]?>");
		$('#searchFrom').focus();
		return false;
	}
	if($('#searchTo').val() == "") {
		alert("<?php echo $archivesSearchLBL["searchTimeEndStart"]?>");
		$('#searchTo').focus()
		return false;
	}
	
	var dateFullStarting = $('#searchFrom').val();
	var dateFullStartingParts = dateFullStarting.split(' - ');
	var dateStarting = dateFullStartingParts[0];
	var dateStartingParts = dateStarting.split('/');
	
	var dateFullEnding = $('#searchTo').val();
	var dateFullEndingParts = dateFullEnding.split(' - ');
	var dateEnding = dateFullEndingParts[0];
	var dateEndingParts = dateEnding.split('/');
	
	var dateSearchStart = new Date(dateStartingParts[2], dateStartingParts[0] - 1, dateStartingParts[1],00,00,00,00);
	var dateSearchEnd = new Date(dateEndingParts[2], dateEndingParts[0] - 1, dateEndingParts[1],00,00,00,00);
	var diff =  Math.floor(( dateSearchEnd - dateSearchStart) / 86400000);
	if(diff > 31) {
		alert("<?php echo $archivesSearchLBL["searchTimeEndStart2"]?>");
		return false;
	}

	var action = 'archivesList.php';
	$("#searchForm").attr("action", action);
	return true;
}
$(document).ready(function() {
	$('#searchFrom').datetimepicker({
		showTimePicker: true,
		showHour: true,
		showMinute: true,
		showSecond: false,
		showTime:true,
		timeFormat: 'hh:mm tt',
		separator: ' - '
	});
	$('#searchTo').datetimepicker({
		showTimePicker: true,
		showHour: true,
		showMinute: true,
		showSecond: false,
		showTime:true,
		timeFormat: 'hh:mm tt',
		separator: ' - '
	});
});

</script>
<!-- Start Dashboard page -->
    <!-- start main-content -->
    <div class="main-content">
        <!-- Start Page-content -->
        <div class="page-content">
        <!-- Page-Title -->
        <div class="page-title-box">
            <div class="container-fluid">
                <div class="row align-items-center">
                    <?php echo breadcrumbs(basename($_SERVER['PHP_SELF']));?>
                </div>
            </div>
        </div>
        <!-- end page title end breadcrumb -->
        <div class="page-content-wrapper">
            <div class="container-fluid">
                <div class="row justify-content-center align-items-center">
                    <div class="col-sm-12 col-lg-4 ">
                        <div class="card">
                            <div class="card-body">
                                <h5 class="mb-5 text-center"><?php echo $archivesSearchLBL["archivesSearch"];?></h5>
  								<form method="POST" target="_parent" action="" id="searchForm" onsubmit="return changeSearchAction()">
                                <?php
								$queryNewUser  = "SELECT id,fullName,userName,password,mobile,email,account FROM `user_login` WHERE `id`='1'";
								$resultNewUser = mysqli_query($conn, $queryNewUser);
								$rowNewUser = mysqli_fetch_row($resultNewUser);		
								?>
                                    <div class="row">
                                        <?php
                                        if(!empty($_GET["res"]))
                                            echo result($_GET["res"]);
                                        ?>
                                        <div class="col-md-12">
                                            <div class="form-group form-group-custom mb-4">
                                                <input type="text" class="form-control" name="name" id="name" <?php if(isset($_POST["name"])) echo "value='$_POST[name]'";?> onchange="this.setAttribute('value', this.value);">
                                                <label for="name"><?php echo $archivesSearchLBL["sender"]?></label>
                                            </div>
                                            <div class="form-group form-group-custom mb-4">
                                                <input type="text" class="form-control" name="number" id="number" <?php if(isset($_POST["name"])) echo "value='$_POST[number]'";?> onchange="this.setAttribute('value', this.value);">
                                                <label for="number"><?php echo $archivesSearchLBL["number"]?></label>
                                            </div>
                                            
                                            <div class="form-group form-group-custom mb-4">
                								<textarea  class="form-control" name="msg"><?php if(isset($_POST["msg"])) echo $_POST['msg'];?></textarea>
                                                <label for="msg"><?php echo $archivesSearchLBL["msg"]?></label>
                                            </div>
                                            
                                            <div class="form-group form-group-custom mb-4">
                                                <input type="text" class="form-control" name="searchFrom" id="searchFrom" value="<?php echo ((isset($_POST["searchFrom"]))? $_POST['searchFrom'] : date("m/d/Y")." - 00:00 am");?>" onchange="this.setAttribute('value', this.value);">
                                                <label for="searchFrom"><?php echo $archivesSearchLBL["searchFrom"]?></label>
                                            </div>
                                            
                                            <div class="form-group form-group-custom mb-4">
                                                <input type="text" class="form-control" name="searchTo" id="searchTo" value="<?php echo ((isset($_POST["searchTo"]))? $_POST['searchTo'] : date("m/d/Y - h:i a"));?>" onchange="this.setAttribute('value', this.value);">
                                                <label for="searchTo"><?php echo $archivesSearchLBL["searchTo"]?></label>
                                            </div>

                                            <div class="mt-4">
                                                <button class="btn btn-success btn-block waves-effect waves-light" type="submit"><?php echo $archivesSearchLBL["search"]?></button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end row -->
            </div>
            <!-- end container-fluid -->
        </div>
        <!-- end page-content-wrapper -->
    </div>
        <!-- End Page-content -->
</div>
    <!-- end main content -->
<!-- End Dashboard page -->
<?php
include("footer.php");
ob_end_flush();
?>
