
<?php
include('header.php');
include("dbcon.php");
error_reporting(0);
if(isset($_POST['submit']))
{
    
    $title=$_POST['title'];
    $date=$_POST['date'];
    $description=$_POST['description'];
    
    $valid_formats = array("jpg","png","jpeg");
    $image = rand(1000,100000)."-".$_FILES['image']['name'];
    list($width, $height, $type, $attr) = getimagesize($image); 
    if($width>1600 || $height>637) 
    { 
    die("exceeded image dimension limits."); 
    } 
    $path1="uploads/news/".$image;
    move_uploaded_file($_FILES["image"]["tmp_name"], $path1);   

        
    $result="INSERT into `news`(`title`,`date`,`description`,`image`)VALUES('$title','$date','$description','$path1')";
    if (mysqli_query($con, $result)){
    header("location:media.php?message=success");
} 
 }   
?>



  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );

    $( function() {
    $( "#datepicker1" ).datepicker();
  } );
  </script>


<div class="clearfix">
</div>
<!-- BEGIN CONTAINER -->
<div class="page-container">

        <!-- BEGIN SIDEBAR -->
    <div class="page-sidebar-wrapper">
        <div class="page-sidebar navbar-collapse collapse">
            <!-- BEGIN SIDEBAR MENU -->
            <ul class="page-sidebar-menu">
                <li class="sidebar-toggler-wrapper">
                    <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
                    <div class="sidebar-toggler hidden-phone">
                    </div>
                    <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
                </li>
                
                
                <!--SEARCH-->
                <li class="sidebar-search-wrapper">
                    <!-- BEGIN RESPONSIVE QUICK SEARCH FORM -->
                    <form class="sidebar-search" action="#" method="POST">
                        <div class="form-container">
                            <div class="input-box">
                                <a href="javascript:;" class="remove"></a>
                                <input type="text" placeholder="Search..."/>
                                <input type="button" class="submit" value=" "/>
                            </div>
                        </div>
                    </form>
                    <!-- END RESPONSIVE QUICK SEARCH FORM -->
                </li>
                <!--SEARCH-->
                
                <li class="">
        
                    <a href="dashboard.php">
                    <i class="fa fa-desktop"></i>
                    <span class="title">Dashboard</span>
                    <span class="selected"></span>
                    </a>
                </li>
                
                

                    <li class="">
                    <a href="banner.php">
                    <i class="fa fa-home" aria-hidden="true"></i>
                    <span class="title">HOME</span>
                    <span class="arrow "></span>
                    </a>
                    <ul class="sub-menu">
                        <li><a href="banner.php">Banner Images</a></li>
                        <li><a href="welcome-note.php">Welcome Note</a></li>
                        <li><a href="clients.php">Clients</a></li>
                        
                    </ul>


                  </li>

                


                    <li class="">
                    <a href="aboutus.php">
                    <i class="fa fa-info-circle" aria-hidden="true"></i>
                    <span class="title">ABOUT US</span>
                    </a>
                </li>



                    <li class="">
                    <a href="javascript:;">
                    <i class="fa fa-tags" aria-hidden="true"></i>
                    <span class="title">SERVICES</span>
                    <span class="arrow "></span>
                    </a>

                    <ul class="sub-menu">
                        <li><a href="services-content.php">Services Contents</a></li>
                        <li><a href="services.php">Services List</a></li>
                        
                    </ul>


                  </li>
                
                    <li class="">
                    <a href="javascript:;">
                    <i class="fa fa-picture-o" aria-hidden="true"></i>
                    <span class="title">PORTFOLIO</span>
                    <span class="arrow "></span>
                    </a>

                    <ul class="sub-menu">
                        <li><a href="works.php">Works</a></li>
                        <li><a href="casestudy.php">Case Study</a></li>
                        
                    </ul>


                </li>



                    <li class="active">
                    <a href="media.php">
                    <i class="fa fa-calendar" aria-hidden="true"></i>
                    <span class="title">MEDIA</span>
                    </a>
                </li>




                    <li class="">
                    <a href="contactus.php">
                    <i class="fa fa-envelope" aria-hidden="true"></i>
                    <span class="title">ENQUIRIES</span>
                    </a>
                  </li>

                   <li class="">
                    <a href="newsletterlist.php">
                    <i class="fa fa-envelope" aria-hidden="true"></i>
                    <span class="title">NEWSLETTERS</span>
                    </a>
                  </li>



                    <li class="">
                    <a href="lock.php">
                    <i class="fa fa-bar-chart-o"></i>
                    <span class="title">Lock</span>
                    </a>
                </li>
                
                
                                </ul>
            <!-- END SIDEBAR MENU -->
        </div>
    </div>
    <!-- END SIDEBAR -->




            <!-- BEGIN CONTENT -->
            <div class="page-content-wrapper">
                <div class="page-content">
                    <!-- BEGIN PAGE HEADER-->
                    <div class="row">
                        <div class="col-md-12">
                            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                            <h3 class="page-title"><STRONG></STRONG></h3>
                            <ul class="page-breadcrumb breadcrumb">
                                <li>
                                    <i class="fa fa-picture-o"></i>
                                    <a href="media.php"><B>Media</B></a>
                                    <i class="fa fa-angle-right"></i>
                                    <a href=""><B>News</B></a>
            					</li>
                            </ul>
                            <!-- END PAGE TITLE & BREADCRUMB-->
                        </div>
                    </div>
                    <!-- END PAGE HEADER-->
                    <!-- BEGIN PAGE CONTENT-->
                    <div class="row profile">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="row">
                                        <div class="col-md-6 ">
                                            <div class="portlet">
                                                <div class="portlet-title">
                                                    <div class="caption">
                                                        <?php 
  if( $_GET['message'] == 'success' ) 
  { ?>
                    <p style="color:green;">
      <?php 
    echo "Record Added successfully"; ?>
                    </p>
 
    <?php
  } ?> 

    </div>
    <div class="tools">
    <a href="javascript:;" class="reload"></a>
    </div>
    </div>
    </div> 
    <div class="portlet-body form">
    <!-- BEGIN FORM-->
<?php
 $bannerid=$_GET['id'];
 if($id==$bannerid)
{
?>
<form action="media.php" class="form-horizontal form-bordered" method="post"  enctype="multipart/form-data" name="slider">
<div class="form-body">
                                                         
<div class="form-group">
<label class="control-label col-md-3"><b>News Title</b></label>
<div class="col-md-9">
<input type="text" class="form-control select2me" id="title1" name="title" style="width:100%;"  autocomplete="off" />
</div>
</div>


<div class="form-group">
<label class="control-label col-md-3"><b>Date</b></label>
<div class="col-md-9">
<input type="text" class="form-control select2me" id="datepicker" name="date" style="width:100%;"  autocomplete="off" />
</div>
</div>



<div class="form-group last">
<label class="control-label col-md-3"><b>Image Upload</b></label>
<div class="col-md-9">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
<img src="http://www.placehold.it/640x426/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
</div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
<div>
<span class="btn default btn-file">
<span class="fileupload-new"><i class="fa fa-paper-clip"></i> Select Image</span>
<span class="fileupload-exists"><i class="fa fa-undo"></i> Change</span>
<input type="file" class="default" name="image" />
</span>
<a href="#" class="btn red fileupload-exists" data-dismiss="fileupload"><i class="fa fa-trash-o"></i> Remove</a>
</div>
</div>
<span class="label label-danger">NOTE! Image Size 640x426 Pixels.</span>
</div>
</div>


<div class="form-group">
<label class="control-label col-md-3"><b>Description</b></label>
 <div class="col-md-9">
  <textarea  name="description" class="ckeditor form-control" rows="10">
 </textarea> 
  </div></div>


</div>
<div class="form-actions fluid">
<div class="row">
<div class="col-md-12">
<div class="col-md-offset-3 col-md-9">
<input type="submit" class="btn green" name="submit" value="Save">
<a href="banner.php" class="btn default" >Reset</a>
</div>
</div>
</div>
</div>
</form>
     <?php 
    }
    else
    { 
    ?>
<form action="update-bannerimage.php" class="form-horizontal form-bordered" method="post"  enctype="multipart/form-data" name="slider">
<?php
$bannerid=$_GET['id'];
$results="SELECT * FROM `banner` WHERE id =$bannerid";
$res=mysqli_query($con,$results);
$r=mysqli_fetch_array($res);
?>
<div class="form-body">
<input type="hidden" name="id" value="<?php echo $r['id'];?>">

 <div class="form-group">
<label class="control-label col-md-3"><b>Content</b></label>
<div class="col-md-9">
<input type="text" class="form-control input-large select2me" id="title2" name="title2"  autocomplete="off" value="<?php echo $r['content'];?>"/>
</div>
</div>

<div class="form-group last">
 <label class="control-label col-md-3"><b>Image Upload</b></label>
<div class="col-md-9">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
<img src="<?php echo $r['image'];?>" width="250px" height="250" alt=""/>
</div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
<div>
<span class="btn default btn-file">
<span class="fileupload-new"><i class="fa fa-paper-clip"></i> Select Image</span>
<span class="fileupload-exists"><i class="fa fa-undo"></i> Change</span>
<input type="file" class="default" name="image" />
</span>
<a href="#" class="btn red fileupload-exists" data-dismiss="fileupload"><i class="fa fa-trash-o"></i> Remove</a>
</div>
</div>
<span class="label label-danger">NOTE! Image Size 250X250 Pixels.</span>
</div>
</div>
</div>
<div class="form-actions fluid">
<div class="row">
<div class="col-md-12">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn green" ><i class="fa fa-check"></i> Update</button>
<a href="slider.php" class="btn default" >Reset</a>
</div>
</div>
</div>
</div>
</form>  
<!--END FORM-->
<?php
}
?>
</div>
</div>
<!-- END PORTLET-->
<div class="col-md-6">
<div id="dump">
<div id="loader"></div> 
<div class="portlet">
<div class="portlet-body">
<div class="scroller" data-height="700px" data-always-visible="1" data-rail-visible1="1">
<table class="table table-hover">
<thead>
<tr>
<td width="5%" class="hidden-xs text-center"><b>#</b></td>

<td width="20%" class="hidden-xs text-center"><b>Image</b></td>
<td width="20%" class="hidden-xs text-center"><b>Title</b></td>
<td width="15%" class="text-right hidden-xs"><b>Action</b></td>
</tr>
</thead>
<?php
$res="select * from news";
$rs=mysqli_query($con,$res);
$serial=1;
while($r=mysqli_fetch_array($rs))
{ 
?>  
    <tbody>
    <tr>
    <td class="hidden-xs text-center"><?php  echo $serial++;?></td>
    
    <td class="hidden-xs text-center"><img src="<?php echo $r['image'];?>" align="" height="100px" width="100"/></td>
    
    <td class="hidden-xs text-center"><?php echo $r['title'];?></td>
    <td class="text-right hidden-xs">
    <a href="sliderdelete.php?id=<?php  echo $r['id'];?>" class="btn default btn-xs red"><i class="fa fa-trash-o "></i></a></td>
    </tr>
    <?php
	}
	?>   
    </tbody>
    </table>
    </div>
    </div>
    </div>
    </div>
   <!--end col-md-4-->
    </div>
    <!--end row-->
   </div>
    </div>
    </div>
    </div>
    </div>
    <!--END PAGE CONTENT-->
    </div>
    </div>
    <!-- END CONTENT -->
    </div>
        <!--END CONTAINER-->

<?php
include('footer.php');
?>
        <!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
        <!-- BEGIN CORE PLUGINS -->
        <!--[if lt IE 9]>
        <script src="assets/plugins/respond.min.js"></script>
        <script src="assets/plugins/excanvas.min.js"></script> 
        <![endif]-->
        <script src="assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
        <script src="assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
        <script src="assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="assets/plugins/bootstrap/js/bootstrap2-typeahead.min.js" type="text/javascript"></script>
        <script src="assets/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
        <script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
        <script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
        <script src="assets/plugins/jquery.cokie.min.js" type="text/javascript"></script>
        <script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
        <!-- END CORE PLUGINS -->               
        <!-- BEGIN PAGE LEVEL PLUGINS -->
        <script type="text/javascript" src="assets/plugins/fuelux/js/spinner.min.js"></script>
        <script type="text/javascript" src="assets/plugins/ckeditor/ckeditor.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script>
        <script type="text/javascript" src="assets/plugins/select2/select2.min.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-wysihtml5/wysihtml5-0.3.0.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
        <script type="text/javascript" src="assets/plugins/clockface/js/clockface.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-daterangepicker/moment.min.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>
        <script type="text/javascript" src="assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
        <script type="text/javascript" src="assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
        <script type="text/javascript" src="assets/plugins/jquery-multi-select/js/jquery.multi-select.js"></script>
        <script type="text/javascript" src="assets/plugins/jquery-multi-select/js/jquery.quicksearch.js"></script>
        <script src="assets/plugins/bootstrap-switch/static/js/bootstrap-switch.min.js" type="text/javascript"></script>
        <script src="assets/plugins/jquery-tags-input/jquery.tagsinput.min.js" type="text/javascript"></script>
        <script src="assets/plugins/bootstrap-markdown/js/bootstrap-markdown.js" type="text/javascript"></script>
        <script src="assets/plugins/bootstrap-markdown/lib/markdown.js" type="text/javascript"></script>
        <script src="assets/plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
        <script src="assets/plugins/bootstrap-touchspin/bootstrap.touchspin.js" type="text/javascript"></script>
        <!-- END PAGE LEVEL PLUGINS -->
        <!-- BEGIN PAGE LEVEL SCRIPTS -->
        <script src="assets/scripts/app.js"></script>
        <script src="assets/scripts/form-components.js"></script>
        <!-- END PAGE LEVEL SCRIPTS -->
        <script>
            jQuery(document).ready(function() {       
            // initiate layout and plugins
               App.init();
               FormComponents.init();
            });   
        </script>
        <!-- BEGIN GOOGLE RECAPTCHA -->
        <script type="text/javascript">
            var RecaptchaOptions = {
               theme : 'custom',
               custom_theme_widget: 'recaptcha_widget'
            };
        </script>
        <script type="text/javascript" src="https://www.google.com/recaptcha/api/challenge?k=6LcrK9cSAAAAALEcjG9gTRPbeA0yAVsKd8sBpFpR"></script>
        <!-- END GOOGLE RECAPTCHA -->
        <!-- END JAVASCRIPTS -->
    </body>
    <!-- END BODY -->
</html>