<?php
require_once __DIR__ . '/../magic/auth.php';

$auth = bdr_require_privilege(23, '../logout.php');
$user = $auth['user_id'];
$father = $auth['user_id'];
$branch = $auth['branch'];
$conn = $auth['conn'];
$db = $auth['conn'];

$dd			= $_REQUEST["id"];

$myIns = $db->prepare('SELECT * from insurance where insurance_id = ? ');
$myIns->bindParam(1, $dd);
$myIns->execute();
if ($myIns->rowCount() > 0) {
	$result = $myIns->fetch(PDO::FETCH_ASSOC);
}
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="robots" content="index,follow">
	<meta name="author" content="سامح دياب">
	<link rel="icon" href="../images/perfect.ico">
	<title>شركات التأمين</title>
	<link rel="stylesheet" href="../css/bootstrap.css" />
	<link rel="stylesheet" href="../hj2/humanity.calendars.picker.css">
	<link rel="stylesheet" href="../css/myCar.css" />
	<script src="../js/jquery.js"></script>
	<script src="../js/bootstrap.js"></script>
	<script src="../hj2/jquery.plugin.js"></script>
	<script src="../hj2/jquery.calendars.js"></script>
	<script src="../hj2/jquery.calendars.plus.js"></script>
	<script src="../hj2/jquery.calendars.picker.js"></script>
	<script src="../hj2/jquery.calendars.ummalqura.js"></script>
</head>

<body style="background-color:#f0f0f0;">
	<div class="container-fluid">
		<br />
		<h3 style="text-align:center">شاشة تحديث بيانات شركة التأمين</h3>
		<h3 style="text-align:center; font-weight:bold;"><?php echo $result['ins_name']; ?></h3>
		<br /><br />
		<div class="row">
			<div class="col-md-1"></div>
			<div class="col-md-10">
				<form id="new23" method="post" class="form-horizontal" style="float:center;font-weight: bold; font-size: 20px; color: #000;">
					<input type="hidden" id="insurance_id" name="insurance_id" value="<?php echo $result['insurance_id']; ?>" />
					<div class="row" style="padding:4px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="ins_name" class="control-label" style="float:right;">اسم الشركة</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="ins_name" name="ins_name" value="<?php echo $result['ins_name']; ?>" />
							<!-- <div id="ins_val"></div> -->
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="ins_owner" class="control-label" style="float:left;">اسم المالك</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" style="float:right;" class="form-control" id="ins_owner" name="ins_owner" value="<?php echo $result['ins_owner']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:4px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="boss" class="control-label" style="float:right;">المدير</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="boss" name="boss" value="<?php echo $result['boss']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="boss_jawal" class="control-label" style="float:left;">جوال المدير</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="number" style="float:right;" class="form-control" id="boss_jawal" placeholder="رقم جوال " name="boss_jawal" onchange="ten('boss_jawal')" value="<?php echo $result['boss_jawal']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:4px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="repman" class="control-label " style="float:right;">مدير الحسابات</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="repman" name="repman" value="<?php echo $result['repman']; ?>" />
						</div>
						<div class="col-xs-12 col-md-3" style="float:right;">
							<input type="number" style="float:right;" class="form-control" id="repjawal" name="repjawal" placeholder="رقم جوال " onchange="ten('repjawal')" value="<?php echo $result['repjawal']; ?>" />
						</div>
						<div class="col-xs-12 col-md-3" style="float:right;">
							<input type="number" style="float:right;" class="form-control" id="repjawal2" name="repjawal2" placeholder="رقم جوال " onchange="ten('repjawal2')" value="<?php echo $result['repjawal2']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:4px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="crash_man" class="control-label" style="float:right;">مسؤل حوادث</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="crash_man" name="crash_man" value="<?php echo $result['crash_man']; ?>" />
						</div>
						<div class="col-xs-12 col-md-3" style="float:right;">
							<input type="number" class="form-control" style="float:right;" id="crash_jawal" name="crash_jawal" placeholder="رقم جوال " onchange="ten('crash_jawal')" value="<?php echo $result['crash_jawal']; ?>" />
						</div>
						<div class="col-xs-12 col-md-3" style="float:right;">
							<input type="number" class="form-control" style="float:right;" id="crash_jawal2" name="crash_jawal2" placeholder="رقم جوال " onchange="ten('crash_jawal2')" value="<?php echo $result['crash_jawal2']; ?>" />
						</div>

					</div>
					<div class="row" style="padding:4px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="fax" class="control-label" style="float:right;">رقم الفاكس</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="number" class="form-control" style="float:right;" id="fax" name="fax" onchange="ten('fax')" value="<?php echo $result['fax']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="phone" class="control-label" style="float:left;">التليفون</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="number" style="float:right;" class="form-control" id="phone" name="phone" onchange="ten('phone')" placeholder="رقم جوال " value="<?php echo $result['phone']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:4px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="address" class="control-label" style="float:right;">العنوان</label>
						</div>
						<div class="col-xs-12 col-md-5" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="address" name="address" value="<?php echo $result['address']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="start_date" class="control-label" style="float:left;">تاريخ البداية</label>
						</div>
						<script>
							$(function() {
								var calendar = $.calendars.instance();
								$('#start_date').calendarsPicker({
									calendar: calendar
								});
							});
						</script>
						<div class="col-md-3 input-append" style="float:right;">
							<input type="text" style="float:right;" class="form-control" id="start_date" readonly name="start_date" value="<?php echo $result['start_date']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:4px;">
						<div class="col-md-2" style="float:right;">
							<label for="comm" class="control-label" style="float:right;">ملاحظات</label>
						</div>
						<div class="col-md-10" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="comm" name="comm" value="<?php echo $result['comm']; ?>" />
						</div>
					</div>
					<p><br /></p>
					<div class="form-group">
						<div class="col-md-12">
							<input style="float:right ;font-weight:bold;" type="submit" class="btn btn-danger" name="close" id="close" value=" خروج " />
							<input style="float:right ;font-weight:bold;" type="button" id="update_ins" name="update_ins" class="btn btn-success" value="تحديث بيانات الشركة">
						</div>
					</div>
				</form>
				<div id="msg"></div>
			</div>
		</div>
	</div>
	<script>
		$(document).ready(function() {
			$('#close').click(function() {
				close();
			});
			$("#update_ins").click(function(event) {
				event.preventDefault();
				$.ajax({
					url: "../actions/ins23update.php",
					method: "POST",
					data: $("form").serialize(),
					success: function(data) {
						$("#msg").html(data);
						$("#msg").delay(3000).slideUp(function() {
							$("#msg").html('');
						});
					},
					error: function(result) {
						alert(result.statusText);
					}
				})
			}); //end of update_ins ajax code
		});

		function ten(dd) {
			var a = $("#" + dd).val();
			if (a.length != 10) {
				$("#" + dd).css("background-color", "#FF6B46");
			} else {
				$("#" + dd).css("background-color", "");
			}
		};
	</script>
</body>
</html>