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

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

if (!isset($_SESSION)) {
}

if (!isset($_SESSION["user_id"])) {
	header("location:../index.php");
}
$mySupp = $db->prepare('SELECT * from supplycomp where supp_id = ? ');
$mySupp->bindParam(1, ($_GET['id']));
$mySupp->execute();
if ($mySupp->rowCount() > 0) {
	$result = $mySupp->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 /><br />
		<h3 style="text-align:center ;font-weight:bold;font-size:25px;"> شاشة تحديث بيانات الشركات </h3>
		<br /><br />
		<div class="row">
			<div class="col-xs-1 col-md-1"></div>
			<div class="col-xs-10 col-md-10">
				<form method="post" class="form-horizontal" style="float:center;font-weight: bold; font-size: 20px; color: #000;">
					<input type="hidden" id="supp_id" name="supp_id" value="<?php echo $result['supp_id']; ?>" />
					<div class="row" style="padding:4px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="supp_name" class="control-label" style="float:left;">اسم الشركة </label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">

							<input type="text" class="form-control" style="float:right;" id="supp_name" name="supp_name" value="<?php echo $result['supp_name']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="company_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="company_owner" name="company_owner" value="<?php echo $result['company_owner']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="boss" class="control-label" style="float:left;">المدير</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" name="boss_jawal" onchange="ten('boss_jawal')" placeholder="رقم جوال " value="<?php echo $result['boss_jawal']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="sales_master" class="control-label " style="float:left;">مدير الحسابات</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="sales_master" name="sales_master" value="<?php echo $result['sales_master']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="master_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="master_jawal" name="master_jawal" onchange="ten('master_jawal')" placeholder="رقم جوال " value="<?php echo $result['master_jawal']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="sales" class="control-label" style="float:left;">المحاسب</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="sales" name="sales" value="<?php echo $result['sales']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="sales_jawal" class="control-label" style="float:left;">جوال المحاسب</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="number" class="form-control" style="float:right;" id="sales_jawal" name="sales_jawal" onchange="ten('sales_jawal')" placeholder="رقم جوال " value="<?php echo $result['sales_jawal']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-12 col-md-2" style="float:right;">
							<label for="cash_master" class="control-label" style="float:left;">مدير التحصيل</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="cash_master" name="cash_master" value="<?php echo $result['cash_master']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="cash_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="cash_jawal" name="cash_jawal" onchange="ten('cash_jawal')" placeholder="رقم جوال " value="<?php echo $result['cash_jawal']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="casher" class="control-label" style="float:left;">المحصل</label>
						</div>
						<div class="col-xs-12 col-md-4" style="float:right;">
							<input type="text" class="form-control" style="float:right;" id="casher" name="casher" value="<?php echo $result['casher']; ?>" />
						</div>
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="ca_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="ca_jawal" name="ca_jawal" onchange="ten('ca_jawal')" placeholder="رقم جوال " value="<?php echo $result['ca_jawal']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="fax" class="control-label" style="float:left;">رقم الفاكس</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')" value="<?php echo $result['phone']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-6 col-md-2" style="float:right;">
							<label for="address" class="control-label" style="float:left;">العنوان</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" name="start_date" readonly value="<?php echo $result['start_date']; ?>" />
						</div>
					</div>
					<div class="row" style="padding:2px;">
						<div class="col-xs-3 col-md-2" style="float:right;">
							<label for="comm" class="control-label" style="float:left;">ملاحظات</label>
						</div>
						<div class="col-xs-9 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="row" style="padding:4px;">
						<div class="col-md-2" style="float:right;">
							<button class="btn btn-danger" style="font-weight:bold;font-size:16px;float:left" name="close" id="close">خروج</button>
						</div>
						<div class="col-xs-3 col-md-2" style="float:right;">
							<button style="float:right ;font-weight:bold;font-size:14px;" id="update_supp" name="update_supp" class="btn btn-primary">تحديث بيانات الشركة</button>
						</div>
					</div>

					<div id="msg"></div>

			</div>
			</form>

		</div>
	</div>
	<script>
		$(document).ready(function() {
			$('#close').click(function() {
				close();
			});

			$("#update_supp").click(function(event) {
				event.preventDefault();
				$.ajax({
					url: "../actions/supp19Update.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 signup_button ajax code ?act='update'
		});

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

</html>