<?php include('site-header.php'); ?>

  <!-- end of LOGO CONTAINER -->

  <!-- - - - - - - - - - - - - -->

  <!-- start of SIDEBAR        -->

  <!-- - - - - - - - - - - - - -->

  <?php include('left-nevigation.php'); ?>

  <!-- - - - - - - - - - - - - -->

  <!-- end of SIDEBAR          -->

  <!-- - - - - - - - - - - - - -->

  <main id="playground">

    <script src="ckeditor/ckeditor.js"></script>

    <!-- - - - - - - - - - - - - -->

    <!-- start of TOP NAVIGATION -->

    <!-- - - - - - - - - - - - - -->

    <nav class="navbar navbar-top navbar-static-top">

      <div class="container-fluid">

        <!-- sidebar collapse and toggle buttons get grouped for better mobile display -->

        <div class="navbar-header nav">

          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-top"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>

        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->

        <div class="collapse navbar-collapse" id="navbar-top">

          <ul class="nav navbar-nav navbar-right">

            <li class="dropdown user-profile"> <a href="logout.php" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">

              <div class="user-img-container"> <img src="demofiles/demoimage.gif" alt=""> </div>

              Sign Out <span class="chat-status success"></span> </a> </li>

          </ul>

        </div>

      </div>

      <!-- end of container-fluid -->

    </nav>

    <!-- - - - - - - - - - - - - -->

    <!-- end of TOP NAVIGATION   -->

    <!-- - - - - - - - - - - - - -->

    <!-- PAGE TITLE -->

    <!-- Php code -->

    <?php

    extract($_POST);

    if(isset($cate))

    {

      $cname = $catename;

      $sel = "insert into tbl_service_home(ser_name) values('$cname')";

      if(mysqli_query($link,$sel))

      {

        $msg = "<p style='color:green;'>Add Category!!!</p>";

      }

      else

      {

        $msg = "<p style='color:red;'> Category Already Exits!!!</p>";

      }

    }

    ?>

    <!-- delete Category -->

    <?php

    if(isset($_GET['del']))

    {

      $id = $_GET['del'];

      if(mysqli_query($link,"delete from tbl_service_home where ser_id=$id"))

      { 

        echo "<script>location.href='updat-service-home.php';</script>";

        $msg = "<p style='color:red;'>Delete Category!!!</p>";

      }



    }

    ?>

    <!-- Delete product  -->

    <?php

    if(isset($_GET['del_ser']))

    {

      $id = $_GET['del_ser'];

      if(mysqli_query($link,"delete from tbl_service_desc where ser=$id"))

      { 

        echo "<script> location.href='updat-service-home.php?message=delete successfully!!!';</script>";

      }



    }

    ?>

    <!-- Add Product (DATEBASE) -->

    <?php

    echo $tmp = $_FILES['att']['tmp_name'];

    echo $fnn = $_FILES['att']['name'];

    if(isset($Product))

    {

      $cate = $pro_category;

      $que1 = mysqli_query($link,"select * from tbl_service_desc where ser_category='$cate'");

      echo $row = mysqli_num_rows($que1);

      if($row<1)

      {

        $query1 ="insert into tbl_service_desc(ser_category,ser_desc) values('$pro_category','$ser_desc')";

        if(mysqli_query($link,$query1))

        {

          echo "<script> location.href='updat-service-home.php?message=Service Added Successfully!!!';</script>";

        }

      }

      else

      {

        echo "<script> location.href='updat-service-home.php?message=Only One Description add in one category!!!';</script>";

      }

    }

    ?>

    <!-- /php code -->

    <section id="page-title" class="row">

      <div class="col-md-8">

        <h1>Dashboard</h1>

        <p class="lead">Update Home product</p>

      </div>

      <div class="col-md-4">

        <ol class="breadcrumb pull-right no-margin-bottom">

         

          <li><a href="dashboard.php">Dashboard</a></li>

          <li class="active">Update Product</li>

        </ol>

      </div>

    </section>

    <div class="container-fluid">

      <div class="row" style="background-color:#1a2a42; color:white;">

        <div class="col-md-8" style="border:1px solid black;">

          <div><?php if(!empty($_GET['message'])) {

                  echo $message = $_GET['message'];}?></div>

          <form method="post">

            <div class="row">

              <div class="col-md-12">

                <label>Description:</label>

                <textarea id="ckeditor1" name="ser_desc"></textarea>

                <br>

                <label>Service:</label>

                <select class="form-control" name="pro_category">

                   <option>select service</option>

                 <?php

                  $sel = mysqli_query($link,"select * from tbl_service_home");

                  while($arr = mysqli_fetch_assoc($sel))

                  {

                  ?>

                   <option><?=$arr['ser_name'];?></option>

                  <?php

                  }

                  ?>

               </select>

               <br>

               <input type="submit" name="Product" value="Add" class="btn btn-primary form-control">

              </div>

            </div>

            <!-- table Product -->

            <div class="row">

              <div>

                <table class="table border">

                  <thead>

                    <th>Sn</th>

                    <th>Service Desc</th>

                    <th>Category</th>

                    <th>Action</th>

                  </thead>

                  <tbody>

                      <?php

                      $sel = mysqli_query($link,"select * from tbl_service_desc");

                      $sn=1;

                      while($arr = mysqli_fetch_assoc($sel))

                      {

                      ?>

                      <tr>

                      <td><?=$sn;?></td>

                      <td><?=mb_strimwidth($arr['ser_desc'],0,300,"...");?></td>

                      <td><?=$arr['ser_category'];?></td>

                      <td><a href="edit-home-product.php?edit_ser=<?=$arr['ser'];?>"><span class="glyphicon glyphicon-edit" style="color:green;"></span></a>&nbsp;&nbsp;&nbsp;</a><a href="?del_ser=<?=$arr['ser'];?>"><span class="glyphicon glyphicon-remove-circle" style="color:red;"></span></a></td>

                      </tr>

                      <?php

                      $sn++;

                      }

                      ?>

                  </tbody>

                </table>

              </div>

            </div>

        </form>

        </div>

        <?php

        $sel = mysqli_query($link,"select * from tbl_category_home");

        $row = mysqli_num_rows($sel);

        ?>

        <form method="post">

          <div class="col-md-4" style="border:0px solid white;">

            <div><?=$msg;?></div>

            <?php

            if($row<4)

            {

            ?>

            <div class="col-md-6">

              <input type="text" name="catename" value"" class="form-control" Placeholder="Add Service" style="color:red;">

            </div>

            <div class="col-md-6">

              <input type="submit" name="cate" value="Add Category" class="btn btn-success">

            </div>

            <?php

            }

            else

            {

              $msg = "<p style='color:red;'>Only Five Category Add!!!</p>";

            }

            ?>

            <div class="row">

            <div class="col-md-12">

              <table class="table-responsive table border">

                <thead>

                  <th>Sn</th>

                  <th>Category</th>

                  <th>Action</th>

                </thead>

                <tbody>

                <?php

                $sn=1;

                $sel = mysqli_query($link,"select * from tbl_service_home");

                while($arr = mysqli_fetch_assoc($sel))

                {

                ?>

                <tr>

                  <td><?=$sn;?></td>

                  <td style="color:white"><?=$arr['ser_name'];?></td>

                  <td><a href="edit-home-product.php?edit_cate=<?=$arr['ser_id'];?>"><span class="glyphicon glyphicon-edit" style="color:green;"></span></a>&nbsp;&nbsp;&nbsp;</a><a href="?del=<?=$arr['ser_id'];?>"><span class="glyphicon glyphicon-remove-circle" style="color:red;"></span></a></td>

                </tr>

                <?php

                $sn++;

                }

                ?>

                </tbody>

              </table>

            </div>

          </div>

          </div>

          <!-- table category -->

        </form>

      </div>

    </div>

    <script>

      CKEDITOR.replace(ckeditor1)

      CKEDITOR.replace(ckeditor2)  

    </script>

    <!-- / container-fluid -->

 <?php include('site-footer.php'); ?>