<!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</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>

                <!-- PENGILANG -->
                <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>  
                <!-- PENGILANG -->                   

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

                <!-- PELEKAT -->
                <li style="background-color:#EAEAEA;">
                    <a href="#" aria-disabled="disabled">
                        <i class="ti-ticket"></i>
                        <p>PELEKAT MYORI</p>
                    </a>
                </li>                
                <li>
                    <a href="add_prod.php?id=M00001">
                        <i class="ti-angle-right"></i>
                        <p>&nbsp;Permohonan Pelekat</p>
                    </a>
                </li>                
                <li >
                    <a href="table_prod.php?id=M00001">
                        <i class="ti-angle-right"></i>
                        <p>&nbsp;Rekod Pelekat</p>
                    </a>
                </li>   
                <!-- PELEKAT -->  

                <!-- ADUAN -->
                <li style="background-color:#EAEAEA;">
                    <a href="#" aria-disabled="disabled">
                        <i class="ti-email"></i>
                        <p>ADUAN</p>
                    </a>
                </li>                
                <li>
                    <a href="add_prod.php?id=M00001">
                        <i class="ti-angle-right"></i>
                        <p>&nbsp;Senarai Aduan</p>
                    </a>
                </li>                
                <!-- ADUAN -->        

                <!-- JEJAKAN -->
                <li style="background-color:#EAEAEA;">
                    <a href="#" aria-disabled="disabled">
                        <i class="ti-location-pin"></i>
                        <p>JEJAKAN</p>
                    </a>
                </li>                
                <li>
                    <a href="add_prod.php?id=M00001">
                        <i class="ti-angle-right"></i>
                        <p>&nbsp;Jejakan Produk</p>
                    </a>
                </li>                
                <!-- ADUAN -->                    

                <!-- 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> 
                <!-- TADBIR -->               

            </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 &gt; TAMBAH 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-12 col-md-12">
                        <div class="card card-plain">
                            <div class="header">
                                <h4 class="title">Maklumat Produk</h4>
                            </div>
                            <div class="content">
                                <form id="formid">

                                    <div class="row">
                                        <div class="col-md-4">
                                            <label>Jenama</label>
                                            <input id="jenama" name="jenama" type="text" class="form-control border-input" placeholder="Jenama" value="" >
                                        </div>
                                        <div class="col-md-4">
                                            <label>No. SKU</label>
                                            <input id="sku" name="sku" type="text" class="form-control border-input" placeholder="No. SKU" value="" >
                                        </div>
                                        <div class="col-md-4">
                                            <label>Tahun Keluaran</label>
                                            <input id="keluaran" name="keluaran" type="text" class="form-control border-input" placeholder="Tahun Keluaran" value="" >
                                        </div>                                                                                
                                    </div>
                                    <div class="row">
                                        <div class="col-md-4">
                                            <label>Model</label>
                                            <input id="model" name="model" type="text" class="form-control border-input" placeholder="Model" value="" >
                                        </div>
                                        <div class="col-md-4">
                                            <label>ID Produk</label>
                                            <input id="produk" name="produk" type="text" class="form-control border-input" placeholder="ID Produk" value="" >
                                        </div>
                                        <div class="col-md-4">
                                            <label>URL Produk</label>
                                            <input id="url" name="url" type="text" class="form-control border-input" placeholder="URL Produk" value="" >
                                        </div>                                                                                
                                    </div>         
                                    <div class="row">
                                        <div class="col-md-4">
                                            <label>Jenis Produk</label>
											<select id="jenis" name="jenis" class="form-control border-input">
                                                <option value="LED">LED</option>
                                                <option value="TOYS" selected>PERMAINAN</option>
											</select>
                                        </div>                                                                           
                                    </div>  
                                    
                                    <hr/>

                                    <div class="row">
                                        <div class="header">
                                            <h4 class="title">Spesifikasi Jenis Produk</h4><br/>
                                        </div>
                                        <div class="col-md-4" style="padding:0px;">
                                            <div class="col-md-6">
                                                <label>Input Kuasa Tenaga</label>
                                                <input id="input" name="input" type="text" class="form-control border-input" placeholder="Input" value="" >
                                            </div>                                            <div class="col-md-6">
                                                <label>Jenis Input Kuasa / Tenaga</label>
                                                <select id="jenis_input" name="jenis_input" class="form-control border-input">
                                                    <option value="000" >Tiada</option>
                                                    <option value="001" selected>Bateri</option>
                                                    <option value="002" >Solar</option>
                                                    <option value="003">Punca Elektrik</option>
                                                </select>                                            
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <label>Lingkungan Umur</label>
                                            <select id="umur" name="umur" class="form-control border-input">
                                                <option value="000" >Tiada</option>
                                                <option value="001" selected>5 - 7 tahun</option>
                                            </select>                                         
                                        </div>
                                        <div class="col-md-4">
                                            <label>Bahan Buatan</label>
                                            <select id="bahan" name="bahan" class="form-control border-input">
                                                <option value="000" >Tiada</option>
                                                <option value="001" selected>Plastik</option>
                                                <option value="002" >Kaca</option>
                                                <option value="003" >Kayu</option>
                                                <option value="004" >Besi</option>
                                                <option value="005" >Lain-lain</option>
                                            </select> 
                                        </div>                                                                                
                                    </div>

                                    <div class="row">
                                        <div class="col-md-4" style="padding:0px;">
                                            <div class="col-md-6">
                                                <label>Berat Produk</label>
                                                <input id="berat" name="berat" type="text" class="form-control border-input" placeholder="Berat Produk" value="" >
                                            </div>                                            
                                            <div class="col-md-6">
                                                <label>Unit</label>
                                                <select id="berat_unit" name="berat_unit" class="form-control border-input">
                                                    <option value="000" >Tiada</option>
                                                    <option value="001" selected>gram</option>
                                                    <option value="002" >kilogram</option>
                                                    <option value="003" >liter</option>
                                                    <option value="004" >tan</option>
                                                </select>                                             
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <label>Waranti</label>
                                            <input id="waranti" name="waranti" type="text" class="form-control border-input" placeholder="Waranti" value="" >
                                        </div>                                                                              
                                    </div>      
                                    <div class="row">
                                        <div class="col-md-4" style="padding:0px;">
                                            <div class="col-md-6">
                                                <label>Saiz Produk (L x W x H)</label>
                                                <input id="sazi" name="saiz" type="text" class="form-control border-input" placeholder="Saiz Produk" value="" >
                                            </div>                                            
                                            <div class="col-md-6">
                                                <label>Unit</label>
                                                <select id="saiz_unit" name="saiz_unit" class="form-control border-input">
                                                    <option value="000" >Tiada</option>
                                                    <option value="001" selected>cm</option>
                                                    <option value="002" >meter</option>
                                                </select>                                             
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <label>Insuran</label>
                                            <input id="insuran" name="insuran" type="text" class="form-control border-input" placeholder="Insuran" value="" >
                                        </div>                                                                              
                                    </div>                                    
                                    
                                    <hr/>

                                    <div class="row">
                                        <div class="col-md-4">
                                            <label>Gambar</label>
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <img src="assets/img/produk/toy-01.png" alt="img1" height="200px" style="border:1px dashed #C0C0C0;">
                                                </div>
                                                <div class="col-md-6">
                                                    <img src="assets/img/produk/toy-01.png" alt="img2" height="200px" style="border:1px dashed #C0C0C0;">
                                                </div>                                                
                                            </div>
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <img src="assets/img/produk/toy-01.png" alt="img3" height="200px" style="border:1px dashed #C0C0C0;">
                                                </div>
                                                <div class="col-md-6">
                                                    <img src="" alt="img4" height="200px" style="border:1px dashed #C0C0C0;">
                                                </div>                                                
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <label>Dokumen COC</label>
                                        </div>
                                        <div class="col-md-4">
                                            <label>Logo Pensijilan</label>
                                        </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">
                                            <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/";


            function getData(){
                $.ajax({
                    type: "get",
                    url: url + "/m/ws/get_manu_detail.php?id=" + id
                    }).done(function(json) { 
                    //console.log(json);
                    var data = $.parseJSON(json);
                    console.log('data...', data);
                    
                    if (data && data.length > 0) {
                        console.log('data0...', data[0]);
                        $("#name").val(data[0].name).change();
                        $("#regno").val(data[0].regno).change();
                        $("#address").val(data[0].address).change();
                        $("#postcode").val(data[0].postcode).change();
                        $("#town").val(data[0].town).change();
                        $("#state").val(data[0].state).change();
                        $("#telephone").val(data[0].telephone).change();
                        $("#fax").val(data[0].fax).change();
                        $("#url").val(data[0].url).change();
                        $("#officer").val(data[0].officer).change();
                        $("#phone").val(data[0].phone).change();
                        $("#email").val(data[0].email).change();
                        $("#type").val(data[0].type).change();

                        $("#label_title").html(data[0].name).change();
                        $("#label_reg").html(data[0].regno).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')); 
            });   

            $('#fileinput2').on("change", function(){ 
                readURL(this, $('#base2'), $('#viewphoto2')); 
            });    

            $("#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_detail.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>
