<?php
include '../connection.php';
if(!isset($_SESSION)) session_start();

$sqlRetriveData = "SELECT * FROM manager_ar";
$executeRetrive = mysqli_query($connection,$sqlRetriveData);
$rowData = mysqli_fetch_row($executeRetrive);

$name = isset($_POST["name"]) ? $_POST["name"] : "";
$email = isset($_POST["email"]) ? $_POST["email"] : "";
$phone = isset($_POST["phone"]) ? $_POST["phone"] : "";
$subject = isset($_POST["subject"]) ? $_POST["subject"] : "";
$content = isset($_POST["content"]) ? $_POST["content"] : "";

$errors = array();
$flag = true;
$errorList = "";
if(isset($_POST["send"]))
{
   if(empty($name) || empty($email) || empty($phone) || empty($subject) || empty($content))
   {
    $errors["empty"] = "يجب تعبئة جميع الحقول";
    $flag = false;
   }
   elseif(!preg_match("/^[-_[:alnum:]]+(\.[-_[:alnum:]]+)*@[[:alnum:]]+(\.[[:alnum:]]+)*(\.[[:alpha:]]{2,})$/",$email))
   {
      $errors["correctEmail"] = "يجب كتابة البريد الإلكتروني بالصيغة الصحيحة";
      $flag = false;
   }
   elseif(!preg_match('/^[[:digit:]]+$/',$phone))
   {
       $errors["phoneNumber"] = "يجب ان يحتوي الهاتف على ارقام فقط"."<br>";
       $flag=false;
   }
   elseif(strlen($phone)<9 || strlen($phone)>15)
   {
       $errors["sizePhone"] = "يجب ان يكون الهاتف من 9-15 رقم"."<br>";
       $flag=false;
   }
   if($flag === true)
   {
        $sqlInsert = "INSERT INTO contactus( name, email, phone, subject, content) VALUES ('{$name}','{$email}','{$phone}','{$subject}','{$content}')";
        $executeSql = mysqli_query($connection,$sqlInsert);
        $_SESSION["sendSuccess"] = 1;
   }
   else
   {
    foreach($errors as $error)
    {
      $errorList .= $error."<br>";
    }
    $_SESSION["errorSend"] = 1;
   }
}
?>
<!doctype html>
<html lang="ar">
  <head>
    <title>اتصل بنا</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="../assets/img/logo.png" type="image/x-icon">

    <!-- assets / css -->
    <?php include '../cssFile.php'; ?>
<style>
h4
{
    padding-bottom:1rem;
}
.btn-outline-maincolor
{
    border-color:#002539;
    background:#fff;
    color:#002539;
}
.btn-outline-maincolor:hover
{
    border-color:#002539;
    background:#002539;
    color:#fff;
   
}
.border-layout 
{
    border:2px solid #002539;
    border-radius:10px;
    padding:20px;
    padding-bottom:10px;
}
.label-form
{
    margin-top: -42px;
    background: #002539;
    width: 50%;
    border: 2px solid #002539;
    border-radius: 5px;
    padding: 3px 3px 7px 3px;
    color: #fff;
}
.form-style 
{
    overflow:hidden;
    margin-bottom:10px;
}
.form
{
 position:relative;
}
.form input 
{
    width:100%;
    height:100%;
    color:#595f6e;
    padding-top:23px;
    border:none;
    outline: none;
}
.form label
{
    position:absolute;
    bottom:-10px;
    left:0%;
    width:100%;
    height:100%;
    pointer-events:none;
    border-bottom:2px solid black;
}
.form label::after 
{
    content:"";
    position:absolute;
    left:0;
    bottom:-2px;
    height:100%;
    width:100%;
    border-bottom:3px solid #5fa8d3;
    transform:translateX(-100%);
    transition: transform all 0.3s ease;
}
.content-name 
{
    position:absolute;
    bottom:5px;
    right:0px;
    transition: all 0.3s ease;
}
.form input:focus + .label-name  .content-name,
.form input:valid + .label-name .content-name
{
    transform: translateY(-150%);
    font-size:14px;
    color:#5fa8d3;
}
.form input:focus + .label-name::after,
.form input:valid + .label-name::after
{
transform:translateX(0%);
}

@media only screen and (max-width:767px)
{
    .border-layout
    {
        margin-top:35px;
    }
    
}
@media only screen and (max-width:991px) and (min-width:768px)
{
    .container
    {
        max-width: 1000px;
    } 
    .label-form
    {
        font-size:26px;
    }
}
@media only screen and (max-width:880px) and (min-width:768px)
{

}
</style>
  </head>
  <body  dir="rtl">
    <!--<div class='text-center' id="loading">-->
    <!--<h2 id='loadingText'><h2>-->
    <!--</div>-->
    <!--onload="reloader()"-->
    <!-- navbar -->
    <?php include 'navbar.php'; ?>
<!-- start fixed social icon -->
<div class="share animated flash slower">
    <div class="toggle icon">
        <i class='fas fa-share-alt' id="icon-share"></i>
    </div>
        <ul>
            <li><a href="https://www.facebook.com/take.achance.359"><i class='fab fa-facebook-f icon-facebook' aria-hidden="true"></i></a></li> 
            <li><a href="https://twitter.com/takeach13143934"><i class='fab fa-twitter icon-twitter' aria-hidden="true"></i></a></li> 
            <li><a href="https://www.youtube.com/channel/UCWcJwXluKFRnSEFkiZBvPhg"><i class='fab fa-youtube icon-youtube' aria-hidden="true"></i></a></li> 
            <li><a href="https://www.instagram.com/takeachancenpo"><i class='fab fa-instagram icon-instagram' aria-hidden="true"></i></a></li> 
            <li><a href="https://wa.me/00962796069492"><i class='fab fa-whatsapp icon-whatsapp' aria-hidden="true"></i></a></li> 
        </ul>
</div>
<!-- end fixed social icon -->
<div class="goshan animated flash slower">
        <a href='goshan.php'><div class="toggle icon">
            <img src='../assets/img/donateIcon.png' style='width:70px'>
        </div></a>

</div>
<!-- End fixed social icon -->
<div class='container' style='margin-top:50px;'>
    <div class='row'>
        <div class='col-md text-right animated bounceInRight slow'>
            <div class="border-layout">
                <h2 class='text-center label-form'>الإدارة العامة</h2>
                <div class="form-row" style='margin-top:20px;margin-bottom:-30px;'>
                    <div class="form-group col">
                        
                    <h5 style='color:#FC5272'>
                           <i class="fas fa-mobile"></i> 
                            <b>موبايل</b>
                    </h5>
                    <h4 style='direction:ltr;font-size:19px'><?php echo $rowData[1];?></h4>
                    </div>
                </div>
                <div class="form-row" style='margin-bottom:-30px;'>
                    <div class="form-group col">
                        
                    <h5 style='color:#0080BB'>
                           <img src='../assets/img/mobile.png' width='23px'> 
                            <b>هاتف</b>
                    </h5>
                    <h4 style='direction:ltr;font-size:19px'><?php echo $rowData[2];?></h4>
                    </div>
                </div>
                <div class="form-row" style='margin-bottom:-30px;'>
                    <div class="form-group col">
                        
                    <h5 style='color:#ECE813'>
                            <i class="far fa-envelope"></i> 
                            <b>البريد الإلكتروني</b>
                    </h5>
                    <h4 style='direction:ltr;font-size:19px'><?php echo $rowData[3];?></h4>
                    </div>
                </div>
                <div class="form-row" style='margin-bottom:-30px;'>
                    <div class="form-group col">
                        
                    <h5 style='color:#FC5272;'>
                     <i class="fas fa-map-marker-alt"></i>
                    <b>موقعنا</b>
                    </h5>
                    <h4 style='direction:ltr;font-size:19px;line-height:28px'>
                    <?php echo $rowData[4];?>
                    </h4>
                    </div>
                </div>
                <div class="form-row" style='margin-bottom:-30px;'>
                    <div class="form-group col">
                        
                    <h5 style='color:#0080BB'>
                      <i class="far fa-credit-card"></i>
                        <b>رقم الحساب</b>
                    </h5>
                    <h4 style='direction:ltr;font-size:19px'> <?php echo $rowData[5];?></h4>
                    </div>
                </div>  
                <div class="form-row" style='margin-bottom:-13px;'>
                    <div class="form-group col">
                        
                    <h5 style='color:#ECE813'>
                        <i class="fas fa-credit-card"></i>
                        <b>الرقم الدولي للحساب البنكي</b>
                    </h5>
                    <h4 style='direction:ltr;font-size:19px'><?php echo $rowData[6];?></h4>
                    </div>
                </div>  
                
                
            </div>
        </div>
        <!-- End col-md -->
        <div class='col-md text-right  animated bounceInLeft slow' >
            <div class='border-layout'>
                <h2 class='text-center label-form'>تواصل معنا</h2>
                <form class='form' action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
                <div class='form-row form-style'>
                    <div class='form-group col-md-12'>
                        <input type='text' name="name" autocomplete="off" required />
                        <label class='label-name' style='border-color:#FC5272;color:#FC5272'>
                        <span class='content-name'>الإسم</span>
                        </label>
                    </div>
                    <!-- End form-group -->
                </div>
                <!-- End form-row -->
                <div class='form-row form-style'>
                    <div class='form-group col-md-12'>
                        <input type='text' name="email" autocomplete="off" required />
                        <label class='label-name' style='border-color:#0080BB;color:#0080BB'>
                        <span class='content-name'>البريد الإلكتروني</span>
                        </label>
                    </div>
                    <!-- End form-group -->
                </div>
                <!-- End form-row -->
                <div class='form-row form-style'>
                    <div class='form-group col-md-12'>
                        <input type='text' name="phone" autocomplete="off" required />
                        <label class='label-name' style='border-color:#ECE813;color:#ECE813'>
                        <span class='content-name'>رقم الموبايل</span>
                        </label>
                    </div>
                    <!-- End form-group -->
                </div>
                <!-- End form-row -->
                <div class='form-row form-style'>
                    <div class='form-group col-md-12'>
                        <input type='text' name="subject" autocomplete="off" required />
                        <label class='label-name' style='border-color:#FC5272;color:#FC5272'>
                        <span class='content-name'>الموضوع</span>
                        </label>
                    </div>
                    <!-- End form-group -->
                </div>
                <!-- End form-row -->
                <div class='form-row form-style'>
                    <div class='form-group col-md-12'>
                        <input type='text' name="content" autocomplete="off" required />
                        <label class='label-name' style='border-color:#0080BB;color:#0080BB'>
                        <span class='content-name'>الرسالة</span>
                        </label>
                    </div>
                    <!-- End form-group -->
                </div>
                <!-- End form-row -->
                <div class="form-row">
                    <div class="form-group col-md-12 text-center">
                        <button class='btn btn-success btn-outline-maincolor hvr-icon-spin' type='submit' name='send' >إرسال <i class="fas fa-paper-plane hvr-icon"></i></button>
                    </div>
                    <!-- end form-group -->
                </div>
                <!-- End form-row -->
                </form>
            </div>
            <!-- end border-layout -->
        </div>
        <!-- End col-md -->
    </div>
    <!-- End row -->
</div>
<!-- End container -->


<div class='row no-gutters' id="row-footer" style='width:100%;margin-top:30px;'>
        <div class='container'>
            <div class="col-md-12 text-center">
                <h4 style='padding-bottom: 0;'>
                    <span>خذ فرصة لتتغير...</span>
                    <span>خذ فرصة لتحلم...</span>
                    <span> خذ فرصة لتكون أنت....</span>
                </h4>

            </div>
        </div>
        <!-- End container -->
    </div>
    <!-- End row -->

    <!-- end footer -->
<!-- assets / js -->
    <?php include '../jsFile.php'; ?>
    <script>

<?php
if(!isset($_SESSION))
  session_start();
if(isset($_SESSION["sendSuccess"]) && $_SESSION["sendSuccess"] == 1)
{ 
?>
Swal.fire(
  'تم الإرسال بنجاح',
  'سيتم التواصل معك في أقرب وقت',
  'success'
)
<?php
$_SESSION["sendSuccess"] = 0;
}
?>
</script>
 <script>

<?php
if(!isset($_SESSION))
  session_start();
if(isset($_SESSION["errorSend"]) && $_SESSION["errorSend"] == 1)
{ 
?>
Swal.fire(
  '',
  '<?php echo $errorList;?>',
  'error'
)
<?php
$_SESSION["errorSend"] = 0;
}
?>
</script>

  </body>
</html>
<!-- onload="reloader()" -->
