<?php
ob_start();
session_start();
?>
<?php
if(isset($_SESSION['user_liwwan_admin_2023930']) AND ($_SESSION['type'] == "manager_session_alliwan") ){
$pageTitle = 'Edit template';
include 'init.php';
?>
<?php
if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['do_edit_tem'])) { ?>
<?php
$ctemid = $_POST['temid'];
$temcode = $_POST['cuscode'];
$tem_tittle = filter_var($_POST['tem_tittle'], FILTER_SANITIZE_STRING);
$tem_cusname = filter_var($_POST['tem_cusname'], FILTER_SANITIZE_STRING);
$tem_desc = filter_var($_POST['tem_desc'], FILTER_SANITIZE_STRING);
if(isset($_POST['pr1_code']) && (strlen($_POST['pr1_code']) > 2) ){
$cusp1 = filter_var($_POST['pr1_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp1 = 0;}
if(isset($_POST['pr2_code']) && (strlen($_POST['pr2_code']) > 2) ){
$cusp2 = filter_var($_POST['pr2_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp2 = 0;}
if(isset($_POST['pr3_code']) && (strlen($_POST['pr3_code']) > 2) ){
$cusp3 = filter_var($_POST['pr3_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp3 = 0;}
if(isset($_POST['pr4_code']) && (strlen($_POST['pr4_code']) > 2) ){
$cusp4 = filter_var($_POST['pr4_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp4 = 0;}
if(isset($_POST['pr5_code']) && (strlen($_POST['pr5_code']) > 2) ){
$cusp5 = filter_var($_POST['pr5_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp5 = 0;}
if(isset($_POST['pr6_code']) && (strlen($_POST['pr6_code']) > 2) ){
$cusp6 = filter_var($_POST['pr6_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp6 = 0;}
if(isset($_POST['pr7_code']) && (strlen($_POST['pr7_code']) > 2) ){
$cusp7 = filter_var($_POST['pr7_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp7 = 0;}
if(isset($_POST['pr8_code']) && (strlen($_POST['pr8_code']) > 2) ){
$cusp8 = filter_var($_POST['pr8_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp8 = 0;}
if(isset($_POST['pr9_code']) && (strlen($_POST['pr9_code']) > 2) ){
$cusp9 = filter_var($_POST['pr9_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp9 = 0;}
if(isset($_POST['pr10_code']) && (strlen($_POST['pr10_code']) > 2) ){
$cusp10 = filter_var($_POST['pr10_code'], FILTER_SANITIZE_NUMBER_INT);
}else{$cusp10 = 0;}
$formErrors = array();
if (empty($tem_tittle)){
$formErrors[] = ' project tittle Cant Be <strong>Empty</strong> ';
}
//loop into errors array and echo it
foreach($formErrors as $error){
echo '<div class= "alert alert-danger text-center">' . $error . '</div>' ;
}
if (empty($formErrors)){
$stmt = $conn->prepare("UPDATE
custompage
SET
cus_name = ?,
cus_tittle = ?,
cus_desc = ?,
cus_p1 = ?,
cus_p2 = ?,
cus_p3 = ?,
cus_p4 = ?,
cus_p5 = ?,
cus_p6 = ?,
cus_p7 = ?,
cus_p8 = ?,
cus_p9 = ?,
cus_p10 = ?
WHERE
cusid = $ctemid
AND
cus_tem_code = $temcode ");
$stmt->execute(array($tem_tittle,$tem_cusname,$tem_desc,$cusp1,$cusp2,$cusp3,$cusp4,$cusp5,$cusp6,$cusp7,$cusp8,$cusp9,$cusp10));
header('location:custommer_templates.php');
exit();
}
}
?>
<?php
if (isset($_POST['edit_tem'])){
$cusid = $_POST["cus_code"];
// select All Data Depend on this ID
$stmt2 = $conn->prepare("SELECT * FROM custompage WHERE cus_tem_code = $cusid");
// execute Query
$stmt2->execute();
// fetch the data
$info = $stmt2->fetch();
?>
<section class="add_my">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST" class="form mt-5">
<p class="text-center h3 fw-bold text-center m-auto add_my_p"> تعديل نموذج عميل </p>
<div class="row">
<div class="input-group">
<div class="col-lg-6 col-sm-12">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="tem_tittle" class="text-muted fw-bold text-center"><span class="text-danger fs-5">◈</span> عنوان النموذج </label>
<input type="text" class="w-100 text-muted fw-bold py-2 text-center" name="tem_tittle" value="<?php echo $info['cus_tittle'] ?>" required="required" id="tem_tittle"/>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="tem_cusname" class="text-muted fw-bold text-center"><span class="text-danger fs-5">◈</span> إسم العميل </label>
<input type="text" class="w-100 text-muted fw-bold py-2 text-center" name="tem_cusname" value="<?php echo $info['cus_name'] ?>" required="required" id="tem_cusname"/>
</div>
</div>
</div>
</div>
<div class="col-lg-12 col-sm-12">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="tem_desc" class="form-label mt-2 text-muted fw-bold text-center" ><span class="text-danger fs-5">◈</span> شرح النموذج </label>
<textarea class="form-control text-muted fw-bold text-center" id="tem_desc" rows="4" name="tem_desc" value="<?php echo $info['cus_desc'] ?>" required="required"><?php echo $info['cus_desc'] ?></textarea>
</div>
</div>
</div>
<hr class="mt-5">
<div class="input-group">
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr1_code" class="text-muted fw-bold text-center"> كود مشروع1 </label>
<input type="text" value="<?php echo $info['cus_p1'] ?>" class="w-100 text-muted fw-bold py-2" name="pr1_code" id="pr1_code"/>
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr2_code" class="text-muted fw-bold text-center"> كود مشروع2 </label>
<input type="text" value="<?php echo $info['cus_p2'] ?>" class="w-100 text-muted fw-bold py-2" name="pr2_code" id="pr2_code"/>
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr3_code" class="text-muted fw-bold text-center"> كود مشروع3 </label>
<input type="text" value="<?php echo $info['cus_p3'] ?>" class="w-100 text-muted fw-bold py-2" name="pr3_code" id="pr3_code"/>
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr4_code" class="text-muted fw-bold text-center"> كود مشروع4 </label>
<input type="text" value="<?php echo $info['cus_p4'] ?>" class="w-100 text-muted fw-bold py-2" name="pr4_code" id="pr4_code"/>
</div>
</div>
</div><div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr5_code" class="text-muted fw-bold text-center"> كود مشروع5 </label>
<input type="text" value="<?php echo $info['cus_p5'] ?>" class="w-100 text-muted fw-bold py-2" name="pr5_code" id="pr5_code"/>
</div>
</div>
</div><div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr6_code" class="text-muted fw-bold text-center"> كود مشروع6 </label>
<input type="text" value="<?php echo $info['cus_p6'] ?>" class="w-100 text-muted fw-bold py-2" name="pr6_code" id="pr6_code"/>
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr7_code" class="text-muted fw-bold text-center"> كود مشروع7 </label>
<input type="text" value="<?php echo $info['cus_p7'] ?>" class="w-100 text-muted fw-bold py-2" name="pr7_code" id="pr7_code"/>
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr8_code" class="text-muted fw-bold text-center"> كود مشروع8 </label>
<input type="text" value="<?php echo $info['cus_p8'] ?>" class="w-100 text-muted fw-bold py-2" name="pr8_code" id="pr8_code"/>
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr9_code" class="text-muted fw-bold text-center"> كود مشروع9 </label>
<input type="text" value="<?php echo $info['cus_p9'] ?>" class="w-100 text-muted fw-bold py-2" name="pr9_code" id="pr9_code"/>
</div>
</div>
</div>
<input type="hidden" name="temid" value="<?php echo $info['cusid']; ?>">
<input type="hidden" name="cuscode" value="<?php echo $info['cus_tem_code']; ?>">
<div class="col-lg-3 col-sm-6">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="pr10_code" class="text-muted fw-bold text-center"> كود مشروع10 </label>
<input type="text" value="<?php echo $info['cus_p10'] ?>" class="w-100 text-muted fw-bold py-2" name="pr10_code" id="pr10_code"/>
</div>
</div>
</div>
</div>
<hr>
<div class="col-8"></div>
<div class="col-4">
<button class="btn btn-primary px-4" name="do_edit_tem" type="submit"> تأكيد </button>
</div>
</div>
</form>
</section>
<?php }?>
<?php
ob_end_flush();
include 'assets/includes/template/footer.php';
?>
<?php
}else{
header('Location:index.php');
exit;
}
?>