<?php
ob_start();
session_start();
?>
<?php
if(isset($_SESSION['user_liwwan_admin_2023930']) AND ($_SESSION['type'] == "manager_session_alliwan") ){
$pageTitle = 'ADD Project';
include 'init.php';
?>
<?php
if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['add_project'])) {
// upload varriables
$avatarName1 = $_FILES['img1']['name'];
$avatarTmp1 = $_FILES['img1']['tmp_name'];
$avatarName2 = $_FILES['img2']['name'];
$avatarTmp2 = $_FILES['img2']['tmp_name'];
$avatarName3 = $_FILES['img3']['name'];
$avatarTmp3 = $_FILES['img3']['tmp_name'];
$avatarName4 = $_FILES['img4']['name'];
$avatarTmp4 = $_FILES['img4']['tmp_name'];
$avatarName5 = $_FILES['img5']['name'];
$avatarTmp5 = $_FILES['img5']['tmp_name'];
$avatarName6 = $_FILES['img6']['name'];
$avatarTmp6 = $_FILES['img6']['tmp_name'];
$avatarName7 = $_FILES['img7']['name'];
$avatarTmp7 = $_FILES['img7']['tmp_name'];
$avatarName8 = $_FILES['img8']['name'];
$avatarTmp8 = $_FILES['img8']['tmp_name'];
$avatarName9 = $_FILES['img9']['name'];
$avatarTmp9 = $_FILES['img9']['tmp_name'];
$avatarName10 = $_FILES['img10']['name'];
$avatarTmp10 = $_FILES['img10']['tmp_name'];
$type = filter_var($_POST['type'], FILTER_SANITIZE_STRING);
$donedate = filter_var($_POST['donedate'], FILTER_SANITIZE_STRING);
$tittle = filter_var($_POST['tittle'], FILTER_SANITIZE_STRING);
$compname = filter_var($_POST['compname'], FILTER_SANITIZE_STRING);
$description = filter_var($_POST['description'], FILTER_SANITIZE_STRING);
$country = filter_var($_POST['country'], FILTER_SANITIZE_STRING);
$ar_tittle = filter_var($_POST['ar_tittle'], FILTER_SANITIZE_STRING);
$ar_compname = filter_var($_POST['ar_compname'], FILTER_SANITIZE_STRING);
$ar_description = filter_var($_POST['ar_description'], FILTER_SANITIZE_STRING);
$ar_country = filter_var($_POST['ar_country'], FILTER_SANITIZE_STRING);
$formErrors = array();
if (empty($type)){
$formErrors[] = ' project type 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)){
//avatar chang name img and upload
//$avatar = $img1 = $img2 = $img3 = $img4 = $img5 $img6 = rand(0, 1000000000) . '_' . $avatarName;
$img1 = rand(0, 1000000000) . '_' . $avatarName1;
$img2 = rand(0, 1000000000) . '_' . $avatarName2;
$img3 = rand(0, 1000000000) . '_' . $avatarName3;
$img4 = rand(0, 1000000000) . '_' . $avatarName4;
$img5 = rand(0, 1000000000) . '_' . $avatarName5;
$img6 = rand(0, 1000000000) . '_' . $avatarName6;
$img7 = rand(0, 1000000000) . '_' . $avatarName7;
$img8 = rand(0, 1000000000) . '_' . $avatarName8;
$img9 = rand(0, 1000000000) . '_' . $avatarName9;
$img10 = rand(0, 1000000000) . '_' . $avatarName10;
move_uploaded_file($avatarTmp1, "images/uploads/projects/" . $img1);
move_uploaded_file($avatarTmp2, "images/uploads/projects/" . $img2);
move_uploaded_file($avatarTmp3, "images/uploads/projects/" . $img3);
move_uploaded_file($avatarTmp4, "images/uploads/projects/" . $img4);
move_uploaded_file($avatarTmp5, "images/uploads/projects/" . $img5);
move_uploaded_file($avatarTmp6, "images/uploads/projects/" . $img6);
move_uploaded_file($avatarTmp7, "images/uploads/projects/" . $img7);
move_uploaded_file($avatarTmp8, "images/uploads/projects/" . $img8);
move_uploaded_file($avatarTmp9, "images/uploads/projects/" . $img9);
move_uploaded_file($avatarTmp10, "images/uploads/projects/" . $img10);
$code =rand(000000,100000);
$stmt = $conn->prepare("INSERT INTO
projects(type, donedate, tittle, compname, description, country,
ar_tittle, ar_compname, ar_description, ar_country,
code, img1, img2, img3, img4, img5, img6, img7, img8, img9, img10 )
VALUES (:ztype, :zddate, :ztit, :zcname, :zdesc, :zcutry,
:zar_tit, :zar_cname, :zar_desc, :zar_cutry,
:zcode, :zimg1, :zimg2, :zimg3, :zimg4, :zimg5, :zimg6, :zimg7, :zimg8, :zimg9, :zimg10 ) ");
$stmt->execute(array(
'ztype' => $type,
'zddate' => $donedate,
'ztit' => $tittle,
'zcname' => $compname,
'zdesc' => $description,
'zcutry' => $country,
'zar_tit' => $ar_tittle,
'zar_cname' => $ar_compname,
'zar_desc' => $ar_description,
'zar_cutry' => $ar_country,
'zimg1' => $img1,
'zimg2' => $img2,
'zimg3' => $img3,
'zimg4' => $img4,
'zimg5' => $img5,
'zimg6' => $img6,
'zimg7' => $img7,
'zimg8' => $img8,
'zimg9' => $img9,
'zimg10' => $img10,
'zcode' => $code
));
header('location:projects.php?added');
exit();
} else{
$msg=urlencode("البيانات المدخلة تحتوي على مشكلة" . "، أعد المحاولة");
header('location:add_project.php?Message='. $msg);
exit();
}
}
?>
<section class="add_my">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST" enctype="multipart/form-data" class="form">
<p class="text-center h3 text-secondary fw-bold text-center m-auto add_my_p"> إضافة مشروع جديد </p>
<!-- Progress bar -->
<div class="progressbar">
<div class="progress" id="progress"></div>
<div class="progress-step progress-step-active" data-title="Basic"></div>
<div class="progress-step" data-title="ENGLISH"></div>
<div class="progress-step" data-title="عربي"></div>
</div>
<div class="ermsg">
<?php if (isset($_GET['Message'])){?>
<div class="box-root padding-top--5 padding-bottom--2 flex-flex flex-justifyContent--center">
<p class="custom_msg"><?php echo $_GET['Message']; ?></p>
</div>
<?php }?>
</div>
<!-- Steps -->
<div class="form-step form-step-active">
<div class="row">
<div class="justtitle mt-5">
<p class="text-muted mt-1 shadow p-3 rounded-pill text-center m-auto fs-4 w-50"> Basic </p>
</div>
<div class="col-6">
<div class="type mt-4">
<label for="type" class="text-muted fw-bold"> Project Type (إختر نوع المشروع) <span class="text-danger fs-5">◈</span></label>
<select class="form-select" aria-label="Default select example" name="type" required="required">
<option selected disabled class="fw-bold text-primary"> Project Type </option>
<option value="1">ديكور داخلي (interior decoration)</option>
<option value="2">تصميم خارجي (Exterior design)</option>
<option value="3">مكاتب شركات (Corporate offices)</option>
<option value="4">لاندسكيب (landscape)</option>
<option value="5"> تصماميم الفيلات (villa designs)</option>
<option value="6"> تصميم & تنفيذ (Design & Execution)</option>
</select>
</div>
</div>
<div class="col-6">
<div class="input-group">
<label for="donedate" class="text-muted fw-bold"> Done DATE (تاريخ إنجاز المشروع) <span class="text-danger fs-5">◈</span></label>
<input type="date" name="donedate" id="donedate" required="required" />
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img1" class="text-muted fw-bold"> img1 <span class="text-danger fs-5">◈</span></label>
<input type="file" id="img1" name="img1" class="btn btn-primary w-100 text-start" required="required">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img2" class="text-muted fw-bold"> img2 <span class="text-danger fs-5">◈</span></label>
<input type="file" id="img2" name="img2" class="btn btn-primary w-100 text-start" required="required">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img3" class="text-muted fw-bold"> img3 </label>
<input type="file" id="img3" name="img3" class="btn btn-primary w-100 text-start">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img4" class="text-muted fw-bold"> img4 </label>
<input type="file" id="img4" name="img4" class="btn btn-primary w-100 text-start">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img5" class="text-muted fw-bold"> img5 </label>
<input type="file" id="img5" name="img5" class="btn btn-primary w-100 text-start">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img6" class="text-muted fw-bold"> img6 </label>
<input type="file" id="img6" name="img6" class="btn btn-primary w-100 text-start">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img7" class="text-muted fw-bold"> img7 </label>
<input type="file" id="img7" name="img7" class="btn btn-primary w-100 text-start">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img8" class="text-muted fw-bold"> img8 </label>
<input type="file" id="img8" name="img8" class="btn btn-primary w-100 text-start">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img9" class="text-muted fw-bold"> img9 </label>
<input type="file" id="img9" name="img9" class="btn btn-primary w-100 text-start">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="upload_img_benfs my-4">
<label for="img10" class="text-muted fw-bold"> img10 </label>
<input type="file" id="img10" name="img10" class="btn btn-primary w-100 text-start">
</div>
</div>
</div>
<hr>
<div class="mt-5">
<a href="#" class="btn btn-next w-25 m-auto">Next</a>
</div>
</div>
<div class="form-step">
<div class="justtitle mt-5">
<p class="text-muted mt-3 shadow p-3 rounded-pill text-center m-auto fs-4 w-50"><img src="../img/flags/en.png" alt="en"> ENGLISH <img src="../img/flags/usa.png" alt="en"></p>
</div>
<div class="row">
<!-- first column -->
<div class="col-lg-6 col-sm-12">
<div class="input-group">
<label for="tittle" class="text-muted fw-bold"> Project Tittle <span class="text-danger fs-5">◈</span></label>
<input type="text" name="tittle" id="tittle" required="required" />
</div>
<div class="input-group">
<label for="compname" class="text-muted fw-bold"> Company Name <span class="text-danger fs-5">◈</span></label>
<input type="text" name="compname" id="compname" required="required" />
</div>
</div>
<!-- second column -->
<div class="col-lg-6 col-sm-12">
<div class="input-group">
<label for="country" class="text-muted fw-bold"> Project Country <span class="text-danger fs-5">◈</span></label>
<input type="text" name="country" id="country" required="required" />
</div>
</div>
<div class="col-lg-12 col-sm-12">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="description" class="form-label mt-2 text-muted fw-bold" > Project Description <span class="text-danger fs-5">◈</span></label>
<textarea class="form-control" id="description" rows="3" name="description"></textarea>
</div>
</div>
</div>
</div>
<hr>
<div class="btns-group">
<a href="#" class="btn btn-prev w-25">Previous</a>
<a href="#" class="btn btn-next w-25">Next</a>
</div>
</div>
<div class="form-step">
<div class="justtitle mt-5">
<p class="text-muted mt-3 shadow p-3 rounded-pill text-center m-auto fs-4 w-50"><img src="../img/flags/sa.png" alt="en"> Arabic <img src="../img/flags/eg.png" alt="en"></p>
</div>
<div class="row">
<!-- first column -->
<div class="col-lg-6 col-sm-12">
<div class="input-group">
<label for="ar_tittle" class="text-muted fw-bold"> عنوان المشروع <span class="text-danger fs-5">◈</span></label>
<input type="text" name="ar_tittle" id="ar_tittle" required="required" />
</div>
<div class="input-group">
<label for="ar_compname" class="text-muted fw-bold"> إسم الشركة <span class="text-danger fs-5">◈</span></label>
<input type="text" name="ar_compname" id="ar_compname" required="required" />
</div>
</div>
<!-- second column -->
<div class="col-lg-6 col-sm-12">
<div class="input-group">
<label for="ar_country" class="text-muted fw-bold"> بلد المشروع <span class="text-danger fs-5">◈</span></label>
<input type="text" name="ar_country" id="ar_country" required="required" />
</div>
</div>
<div class="col-lg-12 col-sm-12">
<div class="tex-area mt-2">
<div class="mb-3">
<label for="ar_description" class="form-label mt-2 text-muted fw-bold" > شرح المشروع <span class="text-danger fs-5">◈</span></label>
<textarea class="form-control" id="ar_description" rows="3" name="ar_description"></textarea>
</div>
</div>
</div>
</div>
<hr class="mt-5">
<div class="btns-group">
<a href="#" class="btn btn-prev w-25">Previous</a>
<input type="submit" name="add_project" value="Submit" class="btn btn-primary opacity-100" />
</div>
</div>
</form>
</section>
<?php
ob_end_flush();
include 'assets/includes/template/footer.php';
?>
<?php
}else{
header('Location:index.php');
exit;
}
?>