<?php $page = 'Products'; ?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Admin</title>

    <!-- Bootstrap Core CSS -->
    <link href="<?php echo base_url(); ?>assets/Backend/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="<?php echo base_url(); ?>assets/Backend/css/sb-admin.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="<?php echo base_url(); ?>assets/Backend/css/plugins/morris.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/Backend/font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="<?php echo base_url();?>assets/Backend/editor/css/font-awesome.min.css" rel="stylesheet" type="text/css">
	<link href="<?php echo base_url();?>assets/Backend/editor/css/froala_editor.min.css" rel="stylesheet" type="text/css">

<script>

	function display(check,id)
	{
		var ch = "#check"+id;
		var file = "p_image_"+id;
		var text = "text_"+id;
		var image = "image_"+id;
		var pimage = "pimage_"+id;
		if($(ch).is(':checked'))
		{
			document.getElementById(image).style.display = "none";
			//var image = "eimage_"+id;
			document.getElementById(pimage).style.display = "block";
			document.getElementById(file).removeAttribute('disabled');
			//document.getElementById('pd_image').setAttribute('required','true');
		}
		else
		{
			//var image = "image_"+id;
			//document.getElementById('text').value = image;
			document.getElementById(eimage).style.display = "none";
			document.getElementById(image).style.display = "block";
			document.getElementById(file).setAttribute('disabled','true');
		}
	}
		function show_image(input,id)
	{
		var image = "#pimage_"+id;
		if(input.files && input.files[0])
		{
			var reader = new FileReader();
			reader.onload = function(e)
			{
				var oimg = document.createElement('img');
				$(image)
						.attr('src',e.target.result);
			};
			reader.readAsDataURL(input.files[0]);
		}
	}
	function mybroucher() {
            var b = document.getElementById("chk").value;
			//alert(b);
			if(b == 1) {
               // alert("Hi");
				document.getElementById("broucher").removeAttribute('disabled');
            }

            }
  function mybroucher2() {

            var b = document.getElementById("chk1").value;

  		if(b == 'on') {
               // alert("Hi");
  			document.getElementById("broucher1").removeAttribute('disabled');
            }

            }

</script>


</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <?php include "include/header.php"; ?>

        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Edit News
				                     <a href="<?php echo base_url(); ?>App/news" class="btn btn-primary pull-right">Back</a>
                        </h1>
                    </div>
                </div>

                <!-- /.row -->
                <?php foreach($news as $sub_row);?>
				<div class="row">
                    <form role="form" action="<?php echo base_url(); ?>index.php/update/up_news/<?php echo $sub_row->n_id; ?>" method="post" enctype="multipart/form-data">
                        <div class="col-lg-6">


							<div class="form-group">
								<label>Name</label>
								<input type="text" name="n_title" value="<?php echo $sub_row->n_title; ?>" class="form-control" required >
							</div>

                           <div class="form-group">
                                <label>Upload Image</label><br>
								<input type="file" class="form-control form-control" id="p_image_<?php echo $sub_row->n_id;?>" name="n_image"
								onChange="show_image(this,'<?php echo $sub_row->n_id;?>');" required disabled >
							<input type="checkbox" id="check<?php echo $sub_row->n_id;?>" name="check" onClick="display(this,'<?php echo $sub_row->n_id;?>')">Change Image
                        </div>

                     
						  <!-- <div class="form-group">
								<label>Broucher</label>
								<input type="file" id="broucher" name="bro_image"  class="form-control" disabled >
							    <input type="checkbox" id="chk" name="check2" value="1" onclick="mybroucher()">Change Broucher
						   </div>  -->
                        </div>

                        <div class="col-lg-6">
							 <div class="form-group">
                                <label>Select Image</label><br>
								<img id="image_<?php echo $sub_row->n_id;?>" src="<?php echo base_url();?>assets/uploads/news/news_<?php echo $sub_row->n_id.'.jpg';?>" alt="" style="border:1px solid #ccc; width:350px; height: 180px;">
								<img id="pimage_<?php echo $sub_row->n_id;?>" src="<?php echo base_url();?>assets/Backend/a-great-ship.jpg" alt="" style="display:none; height: 150px; width: 350px;">
						    </div>

                        </div>


                    <div class="col-lg-12">
						<div class="form-group">
                                <label>Description</label>
                                <textarea class="form-control" name="n_description" id="edit" required  rows="10">
                                    <?php echo $sub_row->n_description;?>
                                </textarea>
                        </div>
                    	 <input type="submit" class="btn btn-primary" value="Save Information">
                         <input type="reset" class="btn btn-default">
                    </div>
                    </form>
                </div>
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery Version 1.11.0 -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/jquery-1.11.0.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/bootstrap.min.js"></script>

    <!-- Morris Charts JavaScript -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/plugins/morris/raphael.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/Backend/js/plugins/morris/morris.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/Backend/js/plugins/morris/morris-data.js"></script>
	<script src="<?php echo base_url(); ?>assets/Backend/editor/js/libs/jquery-1.11.1.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/froala_editor.min.js"></script>

  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/tables.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/lists.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/colors.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/font_family.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/font_size.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/block_styles.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/media_manager.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/video.min.js"></script>

  <script>
      $(function(){
        $('#edit').editable({inlineMode: false})
      });



  </script>
</body>

</html>
