ok

Mini Shell

Direktori : /home/importfo/www/theglobeinternational.com/admin/
Upload File :
Current File : /home/importfo/www/theglobeinternational.com/admin/product1.php

<?php include("function.php") ?>


<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <link rel="shortcut icon" href="images/favicon_1.png">

        <title>Admin | Gallery</title>

        <!-- Base Css Files -->
        <link href="css/bootstrap.min.css" rel="stylesheet" />

        <!-- Font Icons -->
        <link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
        <link href="assets/ionicon/css/ionicons.min.css" rel="stylesheet" />
        <link href="css/material-design-iconic-font.min.css" rel="stylesheet">

        <!-- animate css -->
        <link href="css/animate.css" rel="stylesheet" />

        <!-- Waves-effect -->
        <link href="css/waves-effect.css" rel="stylesheet">

        <!-- Custom Files -->
        <link href="css/helper.css" rel="stylesheet" type="text/css" />
        <link href="css/style.css" rel="stylesheet" type="text/css" />

        <script src="js/modernizr.min.js"></script>
        <link href="assets/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
        <link href="assets/select2/select2.css" rel="stylesheet" type="text/css" />
        <script src="https://cdn.ckeditor.com/4.14.1/standard/ckeditor.js"></script>
        <script>
            function getSubcat(val) {
                $.ajax({
                type: "POST",
                url: "get_subcat.php",
                data:'spare_id='+val,
                success: function(data){
                    $("#subcategory").html(data);
                }
                });
            }
            function selectCountry(val) {
            $("#search-box").val(val);
            $("#suggesstion-box").hide();
            }
        </script>
    </head>



    <body class="fixed-left">
        
        <!-- Begin page -->
        <div id="wrapper">
        
            <!-- Top Bar Start -->
           <?php include("top.php"); ?>
            <!-- Top Bar End -->


            <!-- ========== Left Sidebar Start ========== -->
            <?php include("sidebar.php"); ?>
            <!-- Left Sidebar End --> 



            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->                      
            <div class="content-page">
                <!-- Start content -->
                <div class="content">
                    <div class="container">

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="pull-left page-title">Add Product </h4>
                                <ol class="breadcrumb pull-right">
                                    <li><a href="dashboard.php">Dashboard</a></li>
                                    <li class="active">Add Product </li>
                                </ol>
                            </div>
                        </div>
                         <?php 
                            if(isset($_GET['delete']))
                            {
                              $delete=$_GET['delete'];
                            }
                            else
                            {
                              $delete=0;
                              $slug="";
                            }
                              $sql="delete from parts where p_id='$delete'";
                              $res=mysqli_query($db,$sql);
                            ?>

                        <?php 
                            if(isset($_GET['slug']))
                            {
                              $slug=$_GET['slug'];
                            }
                            else
                            {
                              $slug=0;
                            }
                            $sql="select * from parts p INNER JOIN spare_cat_main scm ON p.spare_id=scm.spare_id INNER JOIN spare_parts sp ON p.spare_id=sp.spare_id where p.title_slug='$slug' GROUP by p.p_id ";
                            $res=mysqli_query($db,$sql);
                            $row=mysqli_fetch_array($res);
                            
                            ?>

                        <div class="row">
                            <div class="col-sm-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading"><h3 class="panel-title">Add Product</h3></div>
                                    <div class="panel-body">
                                        <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data">                                    
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Select category</label>
                                                <div class="col-md-6"> 
                                                    <select class="form-control" name="spare_id" onChange="getSubcat(this.value);"  required>
                                                        
                                                        <?php
                                                        if(isset($_GET['slug']))
                                                        {?>
                                                            <?php $select=machinparts(); ?>
                                                            <option value="<?php echo $row['spare_id'];?>"> <?php echo $row['machine_name']?></option>
                                                        <?php }
                                                         ?>
                                                        }
                                                        <option value="">Select Category</option>
                                                        <?php $select=machinparts(); ?>
                                                            <?php foreach ($select as $key => $value)
                                                        {?>
                                                            <option value="<?php echo $key?>"> <?php echo $value?></option>
                                                        <?php  } ?>
                                                    </select>
                                                </div>
                                                
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Sub category</label>
                                                <div class="col-md-6"> 
                                                    <select name="s_id"  id="subcategory" class="form-control" required>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Product Title</label>
                                                <div class="col-md-6"> 
                                                    <input type="text" class="form-control" name="title" value="<?php echo $row['title'] ?>" > 
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Price</label>
                                                <div class="col-md-2"> 
                                                    <input type="number" class="form-control" id="cBalance" name="price" value="<?php echo $row['price'] ?>" >
                                                </div>
                                                 <label class="col-md-1 control-label">Discount </label>
                                                <div class="col-md-1"> 
                                                    <input type="number" class="form-control" placeholder="%" id="chDiscount" name="dis" value="<?php echo $row['dis'] ?>" >
                                                </div>
                                                 <label class="col-md-2 control-label">Total Price</label>
                                                <div class="col-md-2"> 
                                                    <input type="number" id="result" class="form-control" name="total_price" value="<?php echo $row['total_price'] ?>" > 
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Note</label>
                                                <div class="col-md-10"> 
                                                   <textarea class="ckeditor m input sm" id="editor" rows="5" name="editor4"><?php echo $row['note']?></textarea> 
                                                </div>
                                            </div>
                                           
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Product Future</label>
                                                <div class="col-md-10"> 
                                                   <textarea class="ckeditor m input sm" id="editor" rows="5" name="editor1"><?php echo $row['future']?></textarea> 
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Product Desc</label>
                                                <div class="col-md-10"> 
                                                    <textarea class="wysihtml5 form-control" id="editor" rows="5" name="editor2"><?php echo $row['desc']?></textarea> 
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Product Application</label>
                                                <div class="col-md-10"> 
                                                    <textarea class="wysihtml5 form-control" id="editor" rows="5" name="editor3"><?php echo $row['app']?></textarea> 
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">Product Image</label>
                                                <div class="col-md-5">
                                                    <p style="color: red;">[Minimum upload image-1 AND Maximun upload image-5]</p>
                                                    <div class="fileUpload btn btn-primary waves-effect waves-light">
                                                        <span>upload image here...</span>
                                                        <input type="file" name="image[]" class="upload" multiple="multiple" accept="image/*">
                                                    </div>
                                                </div>
                                                <div class="col-md-5">
                                                    <?php
                                                    $temp = explode(',',$row['parts_image']);
                                                    foreach($temp as $key=>$images)
                                                    {
                                                    ?>
                                                        <img src="upload/<?php echo $images ?>"style="width:100px;">
                                                    <?php } ?>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-2 control-label"></label>
                                                <div class="col-md-10">
                                                  <button type="submit" name="<?php if(isset($_GET['slug'])){ echo "Update"; }else { echo "Submit";} ?>" class="btn btn-purple waves-effect waves-light"><?php if(isset($_GET['slug'])){ echo "Update"; }else { echo "Submit";} ?></button>
                                                </div>
                                            </div>
                                        </form>
                                        <?php
                                            if(isset($_POST['Submit']))
                                            {
                                                if (!empty($_FILES['image']))
                                                {
                                                    if(count($_FILES['image']['name']) > 0)
                                                    {
                                                        //Loop through each file
                                                        $filearr=array();
                                                        for($i=0; $i<count($_FILES['image']['name']); $i++)
                                                        {
                                                            //Get the temp file path
                                                            $tmpFilePath = $_FILES['image']['tmp_name'][$i];
                                                            if($tmpFilePath != "")
                                                            {
                                                                $shortname = $_FILES['image']['name'][$i];
                                                                //$filename =$_FILES['files']['name'][$i];
                                                                $filename = $shortname. '.png';
                                                                $filePath = "upload/".$filename;
                                                                //Upload the file into the temp dir
                                                                if(move_uploaded_file($tmpFilePath, $filePath))
                                                                {
                                                                    array_push($filearr,$filename);
                                                                    $files[] = $shortname;
                                                                }
                                                            }
                                                        }
                                                        $file_name1=implode(',',$filearr);
                                                        $s_id=$_POST['s_id'];
                                                        $spare_id=$_POST['spare_id'];
                                                        $title=$_POST['title'];
                                                        $price=$_POST['price'];
                                                        $dis=$_POST['dis'];
                                                        $top=$_POST['top'];
                                                        $total_price=$_POST['total_price'];
                                                        $editor1=$_POST['editor1'];
                                                        $editor2=$_POST['editor2'];
                                                        $editor3=$_POST['editor3'];
                                                        $editor4=$_POST['editor4'];
                                                             
                                                        $title_slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $title)));

                                                        $sql="INSERT INTO `parts` (`p_id`, `s_id`, `spare_id`, `title`, `title_slug`, `price`,`dis`,`total_price`,`note`, `future`, `desc`, `app`, `parts_image`, `status`) VALUES (NULL, '$s_id', '$spare_id', '$title', '$title_slug', '$price','$dis','$total_price','$editor4', '$editor1', '$editor2', '$editor3', '$file_name1', '$top')";
                                                        $res=mysqli_query($db,$sql);
                                                        if($res==1)
                                                        {
                                                            echo ("<script LANGUAGE='JavaScript'>window.alert('Data Save.!');window.location.href='product.php';</script>");
                                                                    // echo "save data";
                                                        }
                                                        else
                                                        {
                                                            echo ("<script LANGUAGE='JavaScript'>window.alert('Data Not Save.!');window.location.href='product.php';</script>");
                                                                    /*echo "data not save";*/
                                                        }
                                                    }
                                                }
                                            }
                                        ?>
                                        <?php
                                        if(isset($_POST['Update']))
                                        {
                                            if (!empty($_FILES['image']))
                                            {
                                                if(count($_FILES['image']['name']) > 0)
                                                {
                                                    //Loop through each file
                                                    $filearr=array();
                                                    for($i=0; $i<count($_FILES['image']['name']); $i++)
                                                    {
                                                        //Get the temp file path
                                                        $tmpFilePath = $_FILES['image']['tmp_name'][$i];
                                                        if($tmpFilePath != "")
                                                        {
                                                            $shortname = $_FILES['image']['name'][$i];
                                                            //$filename =$_FILES['files']['name'][$i];
                                                            $filename = $shortname. '.png';
                                                            $filePath = "upload/".$filename;
                                                            //Upload the file into the temp dir
                                                            if(move_uploaded_file($tmpFilePath, $filePath))
                                                           {
                                                                array_push($filearr,$filename);
                                                                $files[] = $shortname;
                                                            }
                                                        }
                                                    }
                                                    $file_name1=implode(',',$filearr);

                                                    $slug=$_GET['slug'];
                                                    $s_id=$_POST['s_id'];
                                                    $spare_id=$_POST['spare_id'];
                                                    $title=$_POST['title'];
                                                    $price=$_POST['price'];
                                                    $dis=$_POST['dis'];
                                                    $total_price=$_POST['total_price'];
                                                    $editor1=$_POST['editor1'];
                                                    $editor2=$_POST['editor2'];
                                                    $editor3=$_POST['editor3'];
                                                    $editor4=$_POST['editor4'];
                                                    $title_slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $title)));
                                                    $sql="update `parts` set `s_id`='$s_id',`spare_id`='$spare_id',`title`='$title',`title_slug`='$title_slug',`price`='$price',`dis`='$dis',`total_price`='$total_price',`note`='$editor4',`future`='$editor1',`desc`='$editor2',`app`='$editor3',`parts_image`='$file_name1',`status`='$top' where title_slug='$slug'";
                                                    $res=mysqli_query($db,$sql);
                                                    if($res==1)
                                                    {
                                                        echo ("<script LANGUAGE='JavaScript'>window.alert('Succesfully Updated');window.location.href='product.php';</script>");
                                                        /*echo "data save";*/
                                                    }
                                                    else
                                                    {
                                                        echo ("<script LANGUAGE='JavaScript'>window.alert('Not Updated Data.!');window.location.href='product.php';</script>");
                                                        /*echo "data not save";*/
                                                    }
                                                }
                                            }
                                        }
                                    ?>
                                    </div> <!-- panel-body -->
                                </div> <!-- panel -->
                            </div> <!-- col -->
                        </div> <!-- End row -->


                            <div class="row">
                            <div class="col-md-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">View Product</h3>
                                        
                                    </div>
                                    
                                    <div class="panel-body">
                                        <div class="row">
                                            <div class="col-md-12 col-sm-12 col-xs-12">
                                               <table id="datatable" class="table table-striped table-bordered">
                                                    <thead>
                                                        <tr>
                                                            <th>ID</th>
                                                            <th>Top Item</th>
                                                            <th>Categories</th>
                                                            <th>Sub categories</th>
                                                            <th>Product Title</th>
                                                            <th>price</th>
                                                            <th>Discount</th>
                                                            <th>Total Price</th>
                                                            <!-- <th>Note</th> -->
                                                            <th>Product Image</th>
                                                            <th>Setting</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php
                                                            $sql="SELECT p.*,sc.machine_name,sp.spare_name FROM spare_cat_main sc INNER JOIN spare_parts sp ON sc.spare_id = sp.spare_id INNER JOIN parts p ON p.s_id = sp.s_id ORDER BY p.status DESC";
                                                            $res=mysqli_query($db,$sql);
                                                            while($row=mysqli_fetch_array($res))
                                                            {
                                                                $temp = explode(',',$row['parts_image'] );
                                                        ?>
                                                        <tr>
                                                            <td><?php echo $row['p_id']; ?></td>
                                                            <td><button type="button" class="btn btn-info userinfo" data-id="<?php echo $id ?>"><?php echo $row['status'] ?></button>
                                                                   
                                                                </td>
                                                            <td><?php echo $row['machine_name']; ?></td>
                                                            <td><?php echo $row['spare_name']; ?></td>
                                                            <td><?php echo $row['title']; ?></td>
                                                            <td><?php echo $row['price']; ?></td>
                                                            <td><?php echo $row['dis']; ?></td>
                                                            <td><?php echo $row['total_price']; ?></td>
                                                            <!-- <td><?php echo $row['note']; ?></td> -->
                                                           
                                                            <td>
                                                                <?php
                                                                    foreach($temp as $images){ 
                                                                    echo "<img src='upload/{$images}' height='70' width='70' />";
                                                                }?>
                                                            </td>

                                                            <td>
                                                                <a href="product.php?slug=<?php echo $row['title_slug']; ?>">
                                                                    <button class="btn btn-icon waves-effect waves-light btn-primary m-b-5"> <i class="fa fa-pencil"></i> </button>
                                                                </a>
                                                                <a href="product.php?delete=<?php echo $row['p_id']; ?>">
                                                                    <button class="btn btn-icon waves-effect waves-light btn-danger m-b-5" onclick="return confirm('Are you sure you want to delete this item?');"> <i class="fa fa-remove"></i> </button>
                                                                </a>
                                                            </td>
                                                           
                                                            
                                                        </tr>
                                                    <?php } ?>
                                                       
                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                        </div> <!-- End Row -->
                    </div> <!-- container -->
                               
                </div> <!-- content -->

                <?php include("footer.php") ?>

            </div>
            <!-- ============================================================== -->
            <!-- End Right content here -->
            <!-- ============================================================== -->


            <!-- Right Sidebar -->
            
            <!-- /Right-bar -->


        </div>
        <!-- END wrapper -->
    
        <script>
            var resizefunc = [];
        </script>

        <!-- jQuery  -->
        <script src="js/jquery.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <script src="js/waves.js"></script>
        <script src="js/wow.min.js"></script>
        <script src="js/jquery.nicescroll.js" type="text/javascript"></script>
        <script src="js/jquery.scrollTo.min.js"></script>
        <script src="assets/jquery-detectmobile/detect.js"></script>
        <script src="assets/fastclick/fastclick.js"></script>
        <script src="assets/jquery-slimscroll/jquery.slimscroll.js"></script>
        <script src="assets/jquery-blockui/jquery.blockUI.js"></script>


        <!-- CUSTOM JS -->
        <script src="js/jquery.app.js"></script>
        <script src="assets/datatables/jquery.dataTables.min.js"></script>
        <script src="assets/datatables/dataTables.bootstrap.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $('#datatable').dataTable();
            } );
        </script>
         <script type="text/javascript">
            jQuery(document).ready(function() {
            jQuery(".select2").select2({
                    width: '100%'
                });
             });
        </script>
        <script>
            CKEDITOR.replace( 'editor1' );
        </script>
        <script>
            CKEDITOR.replace( 'editor2' );
        </script>
        <script>
            CKEDITOR.replace( 'editor3' );
        </script>
        <script>
            CKEDITOR.replace( 'editor4' );
        </script>
         <script>
            $(document).on("change keyup blur", "#chDiscount", function() {
            var main = $('#cBalance').val();
            var disc = $('#chDiscount').val();
            var dec = (disc / 100).toFixed(2); //its convert 10 into 0.10
            var mult = main * dec; // gives the value for subtract from main value
            var discont = main - mult;
            $('#result').val(discont);
            });
        </script>
        <script src="assets/select2/select2.min.js" type="text/javascript"></script>
        <!-- CUSTOM JS -->
        
        <script type="text/javascript" src="assets/bootstrap-wysihtml5/wysihtml5-0.3.0.js"></script>
        <script type="text/javascript" src="assets/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>
        <script src="//cdn.ckeditor.com/4.11.1/standard/ckeditor.js"></script>
        <!--form validation init-->
        <script src="https://cdn.ckeditor.com/[version.number]/[distribution]/ckeditor.js"></script>
        <div class="container">
   <!-- Modal -->
   <div class="modal fade" id="empModal" role="dialog">
    <div class="modal-dialog modeldiolog" >
 
     <!-- Modal content-->
     <div class="modal-content">
      <div class="modal-header">
        <img class="modellogo" src="assets/images/logo/annie logo.png">
        <h4 class="modal-title newtitle" style="color: #f94301">Let us get in touch with you!</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      <div class="modal-body">
        
      </div>
     <!--  <div class="modal-footer">
       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div> -->
     </div>
    </div>
   </div>


  </div>
 

<script type="text/javascript">
    $(document).ready(function(){

 $('.userinfo').click(function(){
   
   var userid = $(this).data('id');

   // AJAX request
   $.ajax({
    url: 'ajaxfile.php',
    type: 'post',
    data: {userid: userid},
    success: function(response){ 
      // Add response in Modal body
      $('.modal-body').html(response);

      // Display Modal
      $('#empModal').modal('show'); 
    }
  });
 });
});
</script>
       

    </body>
</html>

        
       






Zerion Mini Shell 1.0