Google
Edit File: view_menu.php
<?php include 'session.php';?> <!DOCTYPE html> <?php include 'reader.php'; //$dbl = new ConDB(); $sessionQuery = "select username from admin_pass"; //$sessionResult = mysql_query($accQry, $db1->conn); if(!$sessionResult = $db1->db->query($sessionQuery)){ die('There was an error running the query [' . $db1->db->error . ']'); } $row = $sessionResult->fetch_assoc(); //$row = mysql_fetch_assoc($sessionResult); //if ($row['session'] == $_SESSION["keys"]) { //} else { //$row = $sessionResult->fetch_assoc(); if ($row['username'] == $_SESSION["keys"]) { } else { // header("Location: login.php"); } ?> <?php $brand_id = $_GET['brand_id']; // $brand_id ; $event_id_new = $_GET['event_id']; //echo $event_id_new ; if (isset($_POST["menu_add"])) { $item_name1 = $_POST["item_name"]; $item_price = $_POST["item_price"]; $item_description = $_POST["item_description"]; if($_POST['choose'] == "veg") { $category = 1 ; } else if ($_POST['choose'] == "non-veg") { $category = 0 ; } $uploaddir = './uploads/'; $filename = basename($_FILES['pic']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['pic']['tmp_name'], $raw)) //$url = "http://localhost/pinaccle".$raw; $url = "http://".$_SERVER['HTTP_HOST']."/admin/pinaccle/".$raw; $accQry1 = "insert into menu_items (name,price,image,description,created_dt,modified_dt,brand_id,event_id,is_veg)values ('$item_name1','$item_price','$url','$item_description',NOW(),NOW(),'$brand_id','$event_id_new','$category')"; // $result1 = mysql_query($accQry1, $db1->conn) ; if(!$result1 = $db1->db->query($accQry1)){ die('There was an error running the query [' . $dbl->db->error . ']'); } sleep(5); $txt = "Menu Item Added Successfully"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; } if (isset($_POST["menu_edit"])) { $item_id = $_POST["item_id1"]; $item_name = $_POST["item_name1"]; $item_price1 = $_POST["item_price1"]; $item_description1 = $_POST["item_description1"]; if($_POST['choose1'] == "veg") { $category1 = 1; } else if ($_POST['choose1'] == "non-veg") { $category1 = 0 ; } $uploaddir = './uploads/'; $filename = basename($_FILES['upload']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['upload']['tmp_name'], $raw)) //$url = "http://localhost/pinaccle".$raw; $url = "http://".$_SERVER['HTTP_HOST']."/admin/pinaccle/".$raw; $accQry2 = "update menu_items set name='$item_name',price='$item_price1',description='$item_description1', image='$url',modified_dt=NOW(),is_veg='$category1' where id ='$item_id'"; // $result1 = mysql_query($accQry, $db1->conn) ; if(!$result2 = $db1->db->query($accQry2)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $txt = "Menu Item Updated Successfully"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; } ?> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { include ('set_character_8.php'); require_once 'Classes/PHPExcel.php'; $uploaddir = './uploads/'; $filename = basename($_FILES['upload']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['upload']['tmp_name'], $raw)) { $Reader = PHPExcel_IOFactory::createReaderForFile($raw); $Reader->setReadDataOnly(true); $objXLS = $Reader->load($raw); $x = 2; while(1){ if(($objXLS->getSheet(0)->getCell("A$x")->getValue() == '')|| ($objXLS->getSheet(0)->getCell("B$x")->getValue() == '')) { break; } $menu_item_name = $objXLS->getSheet(0)->getCell("A$x")->getValue(); $price = $objXLS->getSheet(0)->getCell("B$x")->getValue(); $description = $objXLS->getSheet(0)->getCell("C$x")->getValue(); $veg_nonveg = $objXLS->getSheet(0)->getCell("D$x")->getValue(); $brand_id1 = $brand_id ; $event_id1 = $event_id_new; $insert3 ="insert into menu_items(name,price,description,is_veg,brand_id,event_id,created_dt,modified_dt) values ('$menu_item_name','$price','$description','$veg_nonveg','$brand_id1','$event_id1',NOW(),NOW())"; if(!$result3 = $db1->db->query($insert3)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $x++; } $txt = "Menu Items Uploaded Successfully"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; } } if (isset($_POST["delete_event"])) //('".$checkbox1[$i]."')"; { $delete_event = $_POST['delete_event_name']; $deleteqry = "delete from menu_items where id = '$delete_event'"; if(!$result5 = $db1->db->query($deleteqry)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $txt = "Menu Item Deleted"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; } ?> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Event Menu Details</title> <link type="text/css" href="css/bootstrap.min.css" rel="stylesheet"> <link type="text/css" href="css/bootstrap-responsive.min.css" rel="stylesheet"> <link type="text/css" href="css/theme.css" rel="stylesheet"> <link type="text/css" href="images/icons/css/font-awesome.css" rel="stylesheet"> <link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'> <link type="text/css" href="css/admin_menu_edit.css" rel="stylesheet"> <link type="text/css" href="css/switch.css" rel="stylesheet"> <style type="text/css"> #events_id{ color:#fff; }a:focus,a:hover{ color:black; text-decoration:none; } .dropdown-menu>li{ float:none; } .close { color: #000000; opacity: 1; } </style> </head> <body> <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container" style="min-height: 50px;"> <a class="brand" href="merchant.php"> Pinnacle </a> <ul style="list-style-type: none;text-decoration:none;color:black;float:right;padding-top:10px;"> <li class="dropdown" style="padding-top:10px;"> <a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#" style="color:black;"> <b><?php echo $login_session; ?></b><span class="caret"></span></a> <ul id="g-account-menu" class="dropdown-menu" role="menu"> <li><a href="logout.php">Logout</a></li> </ul> </li> </ul> </div> </div><!-- /navbar-inner --> </div><!-- /navbar --> <div class="wrapper"> <div class="container"> <div class="row"> <div> <?php include ('menu.php'); ?> </div> </div><br /> <div class="row"> <div> <div class="content"> <div class="module"> <div class="module-head"> <h3>Menu Items</h3> <a href="javascript:void(0);" data-toggle="modal" data-target="#myModal">Add New</a> <a class="btn mini blue-stripe" style="color:white;background-color:#6d9acd;" href="#" onclick="excelUpload(); return false;" style="cursor:pointer;">Excel upload</a> </div> <div class="module"> <div class="module-head"> </div> <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <div class="form-group col-sm-10 col-sm-offset-2" align="center"> <h3 id="myModalLabel">Add Menu Item</h3></div> </div> <div class="form-group col-sm-10 col-sm-offset-2" align="center"> <form action="" method ="post" enctype="multipart/form-data"> <br> <div class="form-group" id ="form1"> <label class="control-label" for="name">Item Name:</label> <input type="text" class="form-control" id="email" placeholder="Name" name="item_name" required> </div> <div class="form-group" id ="form1"> <label class="control-label" for="name">Item Price:</label> <input type="text" class="form-control" id="email" placeholder="Price" name="item_price" required> </div> <div class="form-group" id = "form1"> <label class="radio-inline"> <input type="radio" name="choose" value ="veg" required >Veg </label><br> <label class="radio-inline"> <input type="radio" name="choose" value ="non-veg">Non-Veg </label> </div> <br> <div class="form-group" id ="form1"> <label class="control-label" for="name">description:</label> <input type="text" class="form-control" id="email" placeholder="Description" name="item_description" > </div> <br> <label class="control-label" for="email">Item Image:</label> <br> <div class="form-group" id ="form2"> <input type="file" name="pic" > </div> <br><br> <button type="submit" name="menu_add" class="btn btn-default col-sm-12" style="width:40%;">Add Menu Item</button> <br><br><br><br><br><br> </form> </div> </div> <div id="myModal1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <div class="form-group col-sm-10 col-sm-offset-2" align="center"> <h3 id="myModalLabel">Edit Menu Item</h3></div> </div> <div class="form-group col-sm-10 col-sm-offset-2" align="center"> <form action="" method ="post" enctype="multipart/form-data"> <br> <div class="form-group" id ="form1"> <label class="control-label" for="name"></label> <input type="text" class="form-control" id="item_id" placeholder="Name" name="item_id1" > </div> <div class="form-group" id ="form1"> <label class="control-label" for="name">Item Name:</label> <input type="text" class="form-control" id="name_id" placeholder="Name" name="item_name1" required> </div> <div class="form-group" id ="form1"> <label class="control-label" for="name">Item Price:</label> <input type="text" class="form-control" id="price_id" placeholder="Price" name="item_price1" required > </div> <div> <label class="radio-inline"> <input type="radio" name="choose1" value="veg" id = "veg_id">veg </label><br> <label class="radio-inline"> <input type="radio" name="choose1" value = "non-veg" id="nonveg_id">non-veg </label> </div> <br> <div class="form-group" id ="form1"> <label class="control-label" for="name">description:</label> <input type="text" class="form-control" id="description_id" placeholder="Description" name="item_description1" > </div> <br> <label class="control-label" for="email">Item Image:</label> <br> <div class="form-group" id ="form2"> <input type="file" name="upload" > </div> <br><br> <button type="submit" name="menu_edit" class="btn btn-default col-sm-12" style="width:40%;">Update Menu Item Details</button> <br><br><br><br><br><br> </form> </div> </div> <div id="myModal122" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <br> <div class=" col-sm-10 col-sm-offset-2" align="center"> <h4 id="myModalLabel">Delete Event</h4></div> </div> <div class="form-group col-sm-10 col-sm-offset-2" align="center"> <form action="" method ="post" enctype="multipart/form-data"> <br> <div class="form-group" id ="form1"> <label class="control-label" for="name"></label> <input type="hidden" class="form-control" id="event_id_id" placeholder="Id" name="delete_event_name" > </div> <span style="color:black";>Are You Sure You Want To Delete The Menu Item ? </span> <br> <br> <button type="submit" name="delete_event" class="btn btn-default col-sm-12" style="width:10%;">YES</button> <button type="button" class="btn btn-default" data-dismiss="modal">NO</button><br><br><br> </form> </div> </div> <div id="myModal3" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h3 id="myModalLabel">Upload Excel File</h3> </div> <form action="" id="xl_form" method="post" enctype="multipart/form-data" class="form-horizontal row-fluid"> <div class="modal-body"> <input type="file" name="upload" class="span6"> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> <button type="submit" class="btn red" name="xl_upload" id="btnYes1">Upload</button> </div></form> </div> <div class="module-body table"> <table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table table-bordered table-striped display" width="100%"> <thead> <tr> <th>Sl No:</th> <th>Menu Item Name</th> <th>Price</th> <th>Menu Image</th> <th>Veg/Non Veg <th>Description</th> <th>Created Date</th> <th>Modified Date</th> <th>Edit</th> <th>Delete</th> </tr> </thead> <tbody> <?php $accQry4 = "select * from menu_items where brand_id = '$brand_id' AND event_id = '$event_id_new'"; // $result1 = mysql_query($accQry, $db1->conn) ; if(!$result4 = $db1->db->query($accQry4)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $i = 1; while ($row = $result4->fetch_assoc()) { ?> <tr id="doc_rows" > <td class="center"><?Php echo $i ?></td> <td class="center"><?Php if($row['name'] != NULL){echo $row['name'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['price'] != NULL){echo $row['price'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['image'] != NULL){ ?> <img src= "<?php echo $row['image'] ; ?>" alt="Category Image" height="100" width="100"><?php }else{echo "N.A";} ?></td> <td class="center"><?php if($row['is_veg'] == 1 ){echo "Veg";} else {echo "Non Veg";} ?> </td> <td class="center"><?Php if($row['description'] != NULL){echo $row['description'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['created_dt'] != NULL){echo $row['created_dt'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['modified_dt'] != NULL){echo $row['modified_dt'];}else{echo "-";} ?></td> <td class="center"><button id="button_id" style="color:white;background-color:#acc992;" onclick="myFunction(<?Php echo "'".$row['id']."','".$row['name']."','".$row['price']."','".$row['description']."','".$row['is_veg']."' "?>)">Edit Menu Item</button></td> <td class="center"><button id="button_id" style="color:white;background-color:#fc6177;" onclick="deletefunction(<?Php echo " '".$row['id']."' "?>)">Delete Menu Item</button></td> </tr> <?php $i++; } ?> </tbody> </table> </div> </div><!--/.module--> <br /> </div><!--/.content--> </div><!--/.span9--> </div> </div><!--/.container--> </div><!--/.wrapper--> <script src="scripts/jquery-1.9.1.min.js"></script> <script src="scripts/jquery-ui-1.10.1.custom.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="scripts/datatables/jquery.dataTables.js"></script> <script> $(document).ready(function() { $('.datatable-1').dataTable(); $('.dataTables_paginate').addClass("btn-group datatable-pagination"); $('.dataTables_paginate > a').wrapInner('<span />'); $('.dataTables_paginate > a:first-child').append('<i class="icon-chevron-left shaded"></i>'); $('.dataTables_paginate > a:last-child').append('<i class="icon-chevron-right shaded"></i>'); } ); $('#myModal').on('show', function() { var tit = $('.confirm-delete').data('title'); $('#myModal .modal-body p').html("Desea eliminar al usuario " + '<b>' + tit +'</b>' + ' ?'); var id = $(this).data('id'), removeBtn = $(this).find('.danger'); }) $('.confirm-delete').on('click', function(e) { e.preventDefault(); var id = $(this).data('id'); $('#myModal').data('id', id).modal('show'); }); function myFunction(id,name,price,description,is_veg) { document.getElementById("item_id").value=id; document.getElementById("name_id").value=name; document.getElementById("price_id").value=price; document.getElementById("description_id").value=description; if(is_veg == 1) { document.getElementById("veg_id").checked = true; } else { document.getElementById("nonveg_id").checked = true; } $('#myModal1').modal('show'); document.getElementById("item_id").style.display="none"; // document.getElementById("form2").style.display="none"; } function excelUpload() { $('#myModal3').modal('show'); } function deletefunction(event_id) { document.getElementById("event_id_id").value=event_id; $('#myModal122').modal('show'); } </script> </body>