<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon.png">
	<link rel="icon" type="image/png" sizes="96x96" href="assets/img/favicon.png">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

	<title>MYORI - KPDNKK</title>

	<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    <meta name="viewport" content="width=device-width" />


    <!-- Bootstrap core CSS     -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />

    <!-- Animation library for notifications   -->
    <link href="assets/css/animate.min.css" rel="stylesheet"/>

    <!--  Paper Dashboard core CSS    -->
    <link href="assets/css/paper-dashboard.css" rel="stylesheet"/>

    <!--  CSS for Demo Purpose, don't include it in your project     -->
    <link href="assets/css/demo.css" rel="stylesheet" />

    <!--  Fonts and icons     -->
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
    <link href="assets/css/themify-icons.css" rel="stylesheet">

</head>
<body>



<div class="wrapper">
    <div class="sidebar" data-background-color="white" data-active-color="danger">

    <!--
		Tip 1: you can change the color of the sidebar's background using: data-background-color="white | black"
		Tip 2: you can change the color of the active button using the data-active-color="primary | info | success | warning | danger"
	-->

    	<div class="sidebar-wrapper">
            <div class="logo">
            <img src="assets/img/logo.png" alt="logo.png" width="55%" style="display:block;margin:auto;"/>

                <a href="#" class="simple-text">
                    <b>PENGILANG</b>
                </a>
            </div>

            <ul class="nav">
                <li >
                    <a href="dashboard.html">
                        <i class="ti-stats-up"></i>
                        <p>Dashboard</p>
                    </a>
                </li>

                <li style="background-color:#EAEAEA;">
                        <a href="#" aria-disabled="disabled">
                            <i class="ti-home"></i>
                            <p>PENGILANG</p>
                        </a>
                    </li>                
                    <li >
                        <a href="edit_manu.php?id=M00001">
                            <i class="ti-angle-right"></i>
                            <p>&nbsp;Kemaskini Maklumat</p>
                        </a>
                    </li>                
    
                <!-- PRODUK -->
                <li style="background-color:#EAEAEA;">
                <a href="#" aria-disabled="disabled">
                    <i class="ti-package"></i>
                    <p>PRODUK</p>
                </a>
            </li>                
            <li>
                <a href="add_prod.php?id=M00001">
                    <i class="ti-angle-right"></i>
                    <p>&nbsp;Tambah Produk</p>
                </a>
            </li>                
            <li class="active">
                <a href="table_prod.php?id=M00001">
                    <i class="ti-angle-right"></i>
                    <p>&nbsp;Senarai Produk</p>
                </a>
            </li>                

            <!-- STIKER -->
                <!--
                <li style="background-color:#EAEAEA;">
                    <a href="#" aria-disabled="disabled">
                        <i class="ti-rss-alt"></i>
                        <p>STIKER</p>
                    </a>
                </li>                
                <li>
                    <a href="#">
                        <i class="ti-angle-right"></i>
                        <p>&nbsp;Mohon Stiker</p>
                    </a>
                </li>    
                <li>
                    <a href="#">
                        <i class="ti-angle-right"></i>
                        <p>&nbsp;Kemaskini Stiker</p>
                    </a>
                </li>                             
                <li>
                    <a href="#">
                        <i class="ti-angle-right"></i>
                        <p>&nbsp;Senarai Stiker</p>
                    </a>
                </li>  
            -->  

            <!-- TADBIR -->
            <li style="background-color:#EAEAEA;">
                <a href="#" aria-disabled="disabled">
                    <i class="ti-settings"></i>
                    <p>TADBIR</p>
                </a>
            </li>                
            <li>
                <a href="#">
                    <i class="ti-angle-right"></i>
                    <p>&nbsp;Pengguna</p>
                </a>
            </li>                



<!--
                <li>
                    <a href="user.html">
                        <i class="ti-user"></i>
                        <p>User Profile</p>
                    </a>
                </li>
                <li>
                    <a href="table.html">
                        <i class="ti-view-list-alt"></i>
                        <p>Table List</p>
                    </a>
                </li>
                <li>
                    <a href="typography.html">
                        <i class="ti-text"></i>
                        <p>Typography</p>
                    </a>
                </li>
                <li>
                    <a href="icons.html">
                        <i class="ti-pencil-alt2"></i>
                        <p>Icons</p>
                    </a>
                </li>
                <li>
                    <a href="maps.html">
                        <i class="ti-map"></i>
                        <p>Maps</p>
                    </a>
                </li>
                <li>
                    <a href="notifications.html">
                        <i class="ti-bell"></i>
                        <p>Notifications</p>
                    </a>
                </li>
				<li class="active-pro">
                    <a href="upgrade.html">
                        <i class="ti-export"></i>
                        <p>Upgrade to PRO</p>
                    </a>
                </li>
-->

            </ul>
    	</div>
    </div>

    <div class="main-panel">
		<nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar bar1"></span>
                        <span class="icon-bar bar2"></span>
                        <span class="icon-bar bar3"></span>
                    </button>
                    <a class="navbar-brand" href="#">PRODUK</a>
                </div>
                <div class="collapse navbar-collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li>
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="ti-panel"></i>
								<p>Stats</p>
                            </a>
                        </li>
                        <li class="dropdown">
                              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    <i class="ti-bell"></i>
                                    <p class="notification">5</p>
									<p>Notifications</p>
									<b class="caret"></b>
                              </a>
                              <ul class="dropdown-menu">
                                <li><a href="#">Notification 1</a></li>
                                <li><a href="#">Notification 2</a></li>
                                <li><a href="#">Notification 3</a></li>
                                <li><a href="#">Notification 4</a></li>
                                <li><a href="#">Another notification</a></li>
                              </ul>
                        </li>
						<li>
                            <a href="#">
								<i class="ti-settings"></i>
								<p>Settings</p>
                            </a>
                        </li>
                    </ul>

                </div>
            </div>
        </nav>


        <div class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-4 col-md-5">
                    <div class="card card-user">
                    <div class="image" style="height:206px !important">
                        <img src="assets/img/background2.jpg" alt="..."/>
                    </div>
                    <div class="content" style="margin-top:-70px">
                        <div class="author"> 
                          <img id="photo" class="avatar border-white" style="zoom:2.5;opacity:10% !important;" src="assets/img/logo.jpg" alt="..."/>
                          <h4 class="title"><span id="label_title"></span><br />
                             <a href="#"><small id="label_reg"></small></a>
                          </h4>
                        </div>
                    </div>
                    <hr>
                    <div class="text-center">
                        <div class="row">
                            <!--
                            <div class="col-md-3 col-md-offset-1">
                                <h5>12<br /><small>Files</small></h5>
                            </div>
                            -->
                            <div class="col-md-4 col-md-offset-2">
                                <h5>000<br /><small>Products</small></h5>
                            </div>
                            <div class="col-md-4">
                                <h5>000<br /><small>Stickers</small></h5>
                            </div>
                        </div>
                    </div>
                </div>
                        <div class="card hidden">
                            <div class="header">
                                <h4 class="title">Team Members</h4>
                            </div>
                            <div class="content">
                                <ul class="list-unstyled team-members">
                                            <li>
                                                <div class="row">
                                                    <div class="col-xs-3">
                                                        <div class="avatar">
                                                            <img src="assets/img/faces/face-0.jpg" alt="Circle Image" class="img-circle img-no-padding img-responsive">
                                                        </div>
                                                    </div>
                                                    <div class="col-xs-6">
                                                        DJ Khaled
                                                        <br />
                                                        <span class="text-muted"><small>Offline</small></span>
                                                    </div>

                                                    <div class="col-xs-3 text-right">
                                                        <btn class="btn btn-sm btn-success btn-icon"><i class="fa fa-envelope"></i></btn>
                                                    </div>
                                                </div>
                                            </li>
                                            <li>
                                                <div class="row">
                                                    <div class="col-xs-3">
                                                        <div class="avatar">
                                                            <img src="assets/img/faces/face-1.jpg" alt="Circle Image" class="img-circle img-no-padding img-responsive">
                                                        </div>
                                                    </div>
                                                    <div class="col-xs-6">
                                                        Creative Tim
                                                        <br />
                                                        <span class="text-success"><small>Available</small></span>
                                                    </div>

                                                    <div class="col-xs-3 text-right">
                                                        <btn class="btn btn-sm btn-success btn-icon"><i class="fa fa-envelope"></i></btn>
                                                    </div>
                                                </div>
                                            </li>
                                            <li>
                                                <div class="row">
                                                    <div class="col-xs-3">
                                                        <div class="avatar">
                                                            <img src="assets/img/faces/face-3.jpg" alt="Circle Image" class="img-circle img-no-padding img-responsive">
                                                        </div>
                                                    </div>
                                                    <div class="col-xs-6">
                                                        Flume
                                                        <br />
                                                        <span class="text-danger"><small>Busy</small></span>
                                                    </div>

                                                    <div class="col-xs-3 text-right">
                                                        <btn class="btn btn-sm btn-success btn-icon"><i class="fa fa-envelope"></i></btn>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-8 col-md-7">
                        <div class="card card-plain">
                            <div class="header">
                                <h4 class="title">Kemaskini Produk</h4>
                            </div>
                            <div class="content">
                                <form id="formid">

<?php
//receiving parameter
$id = $_GET['id'];
//echo $id;
echo "<input id='id' type='hidden' value='" .$id. "'/>";
?>                                

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label>Jenama </label>
                                                <input id="jenama" name="jenama" type="text" class="form-control border-input" placeholder="Jenama" value="" >
                                                <input id="manu" name="manu" type="text" class="form-control border-input hidden" placeholder="Manufacturer" value="M00001" >
                                                <input id="nfc" name="nfc" type="text" class="form-control border-input hidden" placeholder="NFC" value="" >
                                                </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Model</label>
                                                <input id="model" name="model" type="text" class="form-control border-input" placeholder="Model" >
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label>ID Produk# </label>
                                                <input id="produk" name="produk" type="text" class="form-control border-input" placeholder="ID Produk" value="" >
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">SKU#</label>
                                                <input id="sku" name="sku" type="text" class="form-control border-input" placeholder="No. SKU" >
                                            </div>
                                        </div>
                                    </div>

                                    <hr/>

                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>Jenis Produk</label>
                                                <select id="type" name="type" class="form-control border-input" placeholder="Jenis Produk">
                                                <option value="LED">LED</option>
                                                <option value="TOYS" selected>TOYS</option>
                                                <option value="FOOD">FOOD</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>Input Kuasa/Tenaga</label>
                                                <select id="attrib4" name="attrib4" class="form-control border-input" placeholder="Input Kuasa">
                                                    <option value="BAT" selected>Bateri</option>
                                                    <option value="ELT">Elektrik</option>
                                                    <option value="SOL">Solar</option>
                                                    <option value="OTH">Lain-lain</option>
                                                    <option value="NON">Tiada</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">&nbsp;</label>
                                                <input id="attrib5" name="attrib5" type="text" class="form-control border-input" placeholder="Nyatakan Input Kuasa" >
                                            </div>
                                        </div>                                        
                                    </div>

                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>Berat (g)</label>
                                                <input id="attrib6" name="attrib6" type="text" class="form-control border-input" placeholder="Berat" value="">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>Saiz</label>
                                                <input id="attrib7" name="attrib7" type="text" class="form-control border-input" placeholder="Saiz" value="" >
                                            </div>
                                        </div>                                             
                                    </div>

                                    <hr/>

                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>Tahun Keluaran</label>
                                                <input id="prod_year" name="prod_year" type="text" class="form-control border-input" placeholder="Tahun Keluaran" value="">
                                            </div>
                                        </div>
                                    </div>       
                                    
                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>Waranti</label>
                                                <input id="waranti" name="waranti" type="text" class="form-control border-input" placeholder="Waranti" value="">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>Insuran</label>
                                                <input id="insuran" name="insuran" type="text" class="form-control border-input" placeholder="Insuran" value="">
                                            </div>
                                        </div>                                        
                                    </div>    
                                    
                                    <hr/>

                                    <div class="row">
                                        <div class="col-md-8">
                                            <div class="form-group checkbox">
                                                <label><input id="check1" name="check1" type="checkbox" value="">Status HALAL</label>
                                            </div>
                                            <div class="form-group checkbox">
                                                <label><input id="check2" name="check2" type="checkbox" value="">Status Barangan Malaysia</label>
                                            </div>
                                            <div class="form-group checkbox">
                                                <label><input id="check3" name="check3" type="checkbox" value="">Status MESTI</label>
                                            </div>
                                            <div class="form-group checkbox">
                                                <label><input id="check4" name="check4" type="checkbox" value="">Status HACCP</label>
                                            </div>
                                        </div>
                                    </div>   
                            
                                    <hr/>


                                    <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>Photo</label>
                                            <input id="fileinput1" type="file" accept="image/gif, image/jpeg, image/png" />
                                        </div>
                                    </div>
                                    <!--
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>COC</label>
                                            <input id="fileinput2" type="file" accept="image/gif, image/jpeg, image/png" />
                                        </div>
                                    </div> 
-->                               
                                </div>       
                                
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>&nbsp;</label>
                                            <textarea id="base1" name="base1" class="hidden"></textarea>      
                                            <img id="viewphoto1" src="" alt="" height="200px">                                 
                                        </div>
                                    </div>
                                    <!--
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>&nbsp;</label>
                                            <textarea id="base2" name="base2" class="hidden"></textarea>      
                                            <img id="viewphoto2" src="" alt="" height="200px">                                 
                                        </div>
                                    </div> 
-->                               
                                </div>                                    

<!--
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group">
                                                <label>About Me</label>
                                                <textarea rows="5" class="form-control border-input" placeholder="Here can be your description" value="Mike">Oh so, your weak rhyme
You doubt I'll bother, reading into it
I'll probably won't, left to my own devices
But that's the difference in our opinions.</textarea>
                                            </div>
                                        </div>
                                    </div>
-->                                    
                                    <div class="row">
                                            <br/>
                                            <br/>
                                            <br/>
                                    </div>
                                    <div class="text-center">
                                        
                                        <button id="simpan" type="button" class="btn btn-info btn-fill btn-wd">Simpan Maklumat</button>
                                        
                                    </div>
                                    <div class="clearfix"></div>
                                </form>
                            </div>
                        </div>
                    </div>


                </div>
            </div>
        </div>


        <footer class="footer">
            <div class="container-fluid">
                <nav class="pull-left">
                    <!--
                    <ul>

                        <li>
                            <a href="http://www.creative-tim.com">
                                Creative Tim
                            </a>
                        </li>
                        <li>
                            <a href="http://blog.creative-tim.com">
                               Blog
                            </a>
                        </li>
                        <li>
                            <a href="http://www.creative-tim.com/license">
                                Licenses
                            </a>
                        </li>
                    </ul>
                -->
                </nav>
				<div class="copyright pull-right">
                    &copy; <script>document.write(new Date().getFullYear())</script>, made with <i class="fa fa-heart heart"></i> by <a href="http://www.creative-tim.com">myori services</a>
                </div>
            </div>
        </footer>

    </div>
</div>


</body>

    <!--   Core JS Files   -->
    <script src="assets/js/jquery-1.10.2.js" type="text/javascript"></script>
	<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>

	<!--  Checkbox, Radio & Switch Plugins -->
	<script src="assets/js/bootstrap-checkbox-radio.js"></script>

	<!--  Charts Plugin -->
	<script src="assets/js/chartist.min.js"></script>

    <!--  Notifications Plugin    -->
    <script src="assets/js/bootstrap-notify.js"></script>

    <!--  Google Maps Plugin    -->
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>

    <!-- Paper Dashboard Core javascript and methods for Demo purpose -->
	<script src="assets/js/paper-dashboard.js"></script>

	<!-- Paper Dashboard DEMO methods, don't include it in your project! -->
    <script src="assets/js/demo.js"></script>
    
    <script>

        $(document).ready(function() {

            var id = $('#id').val();
            console.log('id...', id);

            var url = "";
            url = url + "http://myori.afxtechnologies.com/";

            getData();            

            function getData(){
                $.ajax({
                    type: "get",
                    url: url + "/m/ws/get_product.php?id=" + id
                }).done(function(json) { 
                    //console.log(json);
                    var data = $.parseJSON(json);
                    if (data && data.length > 0) {
                        console.log('data...', data[0]);
                        $("#nfc").val(data[0].nfc).change();
                        $("#jenama").val(data[0].jenama).change();
                        $("#model").val(data[0].model).change();
                        $("#produk").val(data[0].produk).change();
                        $("#sku").val(data[0].sku).change();
                        $("#type").val(data[0].type).change();
                        //$("#kapasiti").val(data[0].attrib3).change();
                        $("#attrib4").val(data[0].attrib4).change();
                        $("#attrib5").val(data[0].attrib5).change();
                        $("#attrib6").val(data[0].attrib6).change();
                        $("#attrib7").val(data[0].attrib7).change();

                        $("#prod_year").val(data[0].prod_year).change();
                        $("#waranti").val(data[0].waranti).change();
                        $("#insuran").val(data[0].insuran).change();
                        
                        $("#label_title").html(data[0].jenama).change();
                        $("#label_reg").html(data[0].model).change();

                        if (data[0].photo) {
                            $('#photo').attr("src",data[0].photo).change();
                            $('#viewphoto1').attr("src",data[0].photo).change();
                            $("#base1").val(data[0].photo).change();
                        }
                    }               
                });	
            }

            function readURL(input, base, view) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();
                    reader.onload = function (e) {
                        //$('#falseinput').attr('src', e.target.result);
                        base.val(e.target.result);
                        view.attr("src", e.target.result).change();
                    };
                    reader.readAsDataURL(input.files[0]);
                }
            }  

            $('#fileinput1').on("change", function(){ 
                readURL(this, $('#base1'), $('#viewphoto1')); 
            }); 



            $("#simpan").click(function() {
                simpan();
            });

            function simpan() {
                console.log("simpan maklumat...");

                var formArray = $('#formid').serializeArray();
                var arr = objectifyForm(formArray);
                console.log(arr);

                post_Simpan(arr);

            }

            function objectifyForm(formArray) {//serialize data function
                var returnArray = {};
                for (var i = 0; i < formArray.length; i++){
                    returnArray[formArray[i]['name']] = formArray[i]['value'];
                }
                return returnArray;
            }     


            function post_Simpan(obj) {
                var json = JSON.stringify(obj);
                //console.log('json...', json);
                //console.log(url);
                $.ajax({
                    type: 'POST',
                    url: url + "/m/ws/post_item_update.php",
                    data: json, // or JSON.stringify ({name: 'jonas'}),
                    //contentType: "application/json",
                    //dataType: 'json',
                    success: function(data) { 
                        var msg = data;
                        if (msg && msg.indexOf('Error:') > -1){
                            alert('Simpan maklumat gagal !' + msg);
                        }
                        else {
                            alert('Simpan maklumat berjaya.'); 
                        }
                    },
                    error: function(){
                        alert('Simpan maklumat gagal !'); 
                    }
                });
            }                                 



        });

    </script>






</html>
