Google
Edit File: events.php
<?php include 'session.php'; error_reporting(0); ?> <!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 if (isset($_POST["event_edit"])) // var_dump($_POST); { $event_id = $_POST["event_nameid"]; $event_name = $_POST["event_name"]; $start_date = $_POST['from2']; $end_date = $_POST['to2']; $start_time = $_POST['timefrom2']; $end_time = $_POST['timeto2']; $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 = "https://".$_SERVER['HTTP_HOST']."/admin/pinaccle/".$raw; $accQry1 = "update event set event_name='$event_name',state=1,created_dt=NOW(),modified_dt=NOW(),event_logo='$url',start_dt='$start_date',end_dt='$end_date',start_time='$start_time',end_time='$end_time' where event_id ='$event_id'"; // $result = mysql_query($accQry, $db1->conn) ; if(!$result2 = $db1->db->query($accQry1)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $txt = "Event Updated Successfully"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; // $result1 = mysql_query($accQry, $db1->conn) ; } if (isset($_POST["event_add"])) { $event_name1 = $_POST["event_name1"]; $from = $_POST['from']; $to = $_POST['to']; $time_from = $_POST['timefrom']; $time_to = $_POST['timeto']; $uploaddir = './uploads/'; $filename = basename($_FILES['pic']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['pic']['tmp_name'], $raw)) $url = "https://".$_SERVER['HTTP_HOST']."/admin/pinaccle/".$raw; $accQry2 = "insert into event(event_name,event_logo,state,created_dt,modified_dt,start_dt,end_dt,start_time,end_time)values('$event_name1','$url',1,NOW(),NOW(),'$from','$to','$time_from','$time_to')"; // $result1 = mysql_query($accQry2, $db1->conn) ; if(!$result2 = $db1->db->query($accQry2)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $txt = "Event Added Successfully"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; } /* if (isset($_POST["event_edit"])) { $event_id = $_POST["event_nameid"]; $event_name = $_POST["event_name"]; $uploaddir = './uploads/'; $filename = basename($_FILES['upload']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['upload']['tmp_name'], $raw)) $url = "http://localhost/pinaccle".$raw; $accQry = "update event set event_name='$event_name',state=1,created_dt=NOW(),modified_dt=NOW(),event_logo='$url' where event_id ='$event_id'"; $result1 = mysql_query($accQry, $db1->conn) ; } //if (isset($_POST["event_add"])) if ($_SERVER['REQUEST_METHOD'] === 'POST') { echo "q"; $event_name1 = $_POST["event_name1"]; $uploaddir = './uploads/'; $filename = basename($_FILES['pic']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['pic']['tmp_name'], $raw)) echo "w"; { $url = "http://localhost/pinaccle".$raw; } echo "r"; $accQry1 = "insert into event(event_name,event_logo,state,created_dt,modified_dt)values('$event_name1','$url',1,NOW(),NOW())"; $result1 = mysql_query($accQry1, $db1->conn) ; echo "f"; } */ /*if (isset($_POST["submit_brand"])) echo "k"; { echo $checkbox1 = $_POST["chk1"]; var_dump($_POST); for($i=0;$i<sizeof($checkbox1);$i++) { $query = "insert into event (event_name,event_logo)values ('gggg',$checkbox1[$i]')"; $result1 = mysql_query($query, $db1->conn) ; } } */ if (isset($_POST["submit_brand"])) //('".$checkbox1[$i]."')"; { $checkbox1=$_POST["chk1"]; foreach($_POST["chk1"] as $chk2) { //$chk = $chk2; $in_ch= "insert into event(event_name,event_logo) values ('ggg','$chk2')"; $result2 = mysql_query($in_ch, $db1->conn) or die (mysql_error()) ; } // $in_ch= "insert into event(event_logo) values ('$chk')"; // $result2 = mysql_query($in_ch, $db1->conn) or die (mysql_error()) ; } if (isset($_POST["delete_event"])) //('".$checkbox1[$i]."')"; { $delete_event = $_POST['delete_event_name']; $deleteqry = "delete from event where event_id = '$delete_event'"; if(!$result5 = $db1->db->query($deleteqry)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $txt = "Event 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>Events</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>Events</h3> <a href="javascript:void(0);" data-toggle="modal" data-target="#myModal" class="newbuttontyle">Add New</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> <br> <div class=" col-sm-10 col-sm-offset-2" align="center"> <h4 id="myModalLabel" >Add 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 style =display:inline;" class="control-label" for="name">Event Name:</label> <input type="text" class="form-control" id="email" placeholder="Name" name="event_name1" required > </div> <br> <div class="form-group" > <label style="display:inline;" for="from">From </label> <input type="text" id="from" value="" name="from" placeholder="Select Start Date" required> </div> <br> <div> <label style="display:inline;" for="to">To </label> <input type="text" id="to" value="" name="to" placeholder = "Select End Date" required > </div> <br> <div> <label style="display:inline;">Time from </label> <input class="custom" type='time' value='now' name = "timefrom" required/> </div> <br> <div> <label style="display:inline;">Time Till </label> <input class="custom" type='time' value ='now' name="timeto" required /> </div> <br> <label class="control-label" for="email">Event Logo:</label> <br> <div class="form-group" id ="form2"> <input type="file" name="pic" > </div> <br> <button type="submit" name="event_add" class="btn btn-default col-sm-12" style="width:40%;">Add New Event</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> <br> <div class=" col-sm-10 col-sm-offset-2" align="center"> <h4 id="myModalLabel">Edit 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="text" class="form-control" id="event_id" placeholder="Id" name="event_nameid" > </div> <div class="form-group" id ="form1"> <label style= "display:inline" class="control-label" for="name">Event Name:</label> <input type="text" class="form-control" id="name_id" placeholder="Name" name="event_name" required > </div><br> <div class="form-group" > <label style="display:inline;" for="from">From </label> <input type="text" id="from_id2" value="" name="from2" required > </div> <br> <div> <label style="display:inline;" for="to">to </label> <input type="text" id="to_id2" value="" name="to2" required> </div> <br> <div> <label style="display:inline;">Time from </label> <input class="custom" type='time' id ="time_id" value='now1' name = "timefrom2" required /> </div> <br> <div> <label style="display:inline;">Time Till </label> <input class="custom" type='time' id="time_id2" value ='now1' name="timeto2" required /> </div> <br> <label class="control-label" for="email">Event Logo:</label> <br> <div class="form-group" id ="form2"> <input type="file" name="upload" > </div> <br> <button type="submit" name="event_edit" class="btn btn-default col-sm-12" style="width:40%;">Update Event 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 this event ? </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="myModal2" 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">Brand Details</h4></div> </div> <div class="form-group col-sm-10 col-sm-offset-2" align=""> <form action="" method ="post" enctype="multipart/form-data" align=""> <div class="checkbox" > <?php $accQry4 = "select * from brand"; if(!$result4 = $db1->db->query($accQry4)){ die('There was an error running the query [' . $dbl->db->error . ']'); } // $result1 = mysql_query($accQry, $db1->conn) ; $i = 1; // while ($row = mysql_fetch_assoc($result1)) { while ($row = $result4->fetch_assoc()) { // echo $row['brand_name'] ; ?> <label> <input type="checkbox" value="<?php echo $row['brand_id'] ; ?>" name="chk1[]" ><?php echo $row['brand_name'] ; ?></label> <?php $i++; } ?> </div> <br><br> <button type="submit" name="submit_brand" class="btn btn-default col-sm-12" style="width:40%;">Submit</button> <br><br><br><br><br><br> </form> </div> </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>Event Id</th> <th>Event Name</th> <th>Event Logo</th> <th>State</th> <th>Start Date</th> <th>End Date</th> <th>Start Time</th> <th>End Time</th> <th>Edit</th> <th>Brand Details</th> <th>View Brands </th> <th>Order Details</th> <th>Delete Event</th> </tr> </thead> <tbody> <?php $accQry5 = "select * from event order by created_dt desc"; // $result1 = mysql_query($accQry, $db1->conn) ; if(!$result5 = $db1->db->query($accQry5)){ die('There was an error running the query [' . $db->db->error . ']'); } $i = 1; while ($row = $result5->fetch_assoc()) { ?> <tr id="doc_rows" > <td class="center"><?Php echo $i ?></td> <td class="center"><?Php if($row['event_id'] != NULL){echo $row['event_id'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['event_name'] != NULL){echo $row['event_name'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['event_logo'] != NULL){ ?> <img src= "<?php echo $row['event_logo'] ; ?>" alt="Category Image" height="100" width="100"><?php }else{echo "N.A";} ?></td> <td class="center"><?Php if($row['state'] != NULL){echo $row['state'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['start_dt'] != NULL){echo $row['start_dt'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['end_dt'] != NULL){echo $row['end_dt'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['start_time'] != NULL){echo $row['start_time'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['end_time'] != NULL){echo $row['end_time'];}else{echo "-";} ?></td> <td class="center"><button id="button_id" style="color:white;background-color:#b0ca95;" onclick="myFunction(<?Php echo "'".$row['event_id']."','".$row['event_name']."','".$row['start_dt']."','".$row['end_dt']."','".$row['start_time']."','".$row['end_time']."' "?>)">Edit Event</button></td> <td class="center"><button id="button_id" style="color:white;background-color:#9a8baf;" onclick="window.location='per_brand.php?event_id=<?php echo $row['event_id']?> '" >Brand Details</button></td> <td class="center"><button id="button_id" style="color:white;background-color:#7bd6b7;" onclick="window.location='view_brands.php?event_id=<?php echo $row['event_id']?> '" >View Brands</button></td> <td class="center"><button id="button_id" style="color:white;background-color:#f0bb6d;" onclick="window.location='per_event_order.php?event_id=<?php echo $row['event_id']?> '" >Order Details</button></td> <td class="center"><button id="button_id" style="color:white;background-color:#fc6177;" onclick="deletefunction(<?Php echo "'".$row['event_id']."' "?>)">Delete Event</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> <link href="css/jquery-ui.css" rel="stylesheet"> <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 deletefunction(event_id) { document.getElementById("event_id_id").value=event_id; $('#myModal122').modal('show'); } function myFunction(event_id,event_name,start_date,end_date,start_time,end_time) { document.getElementById("event_id").value=event_id; document.getElementById("name_id").value=event_name; document.getElementById("from_id2").value=start_date; document.getElementById("to_id2").value=end_date; document.getElementById("time_id").value=start_time; document.getElementById("time_id2").value=end_time; $('#myModal1').modal('show'); document.getElementById("event_id").style.display="none"; // document.getElementById("form2").style.display="none"; } function brand() { $('#myModal2').modal('show'); } $( function() { var from = $( "#from" ) .datepicker({ changeMonth: true, numberOfMonths: 1, dateFormat: 'yy-mm-dd', }) // .on( "change", function() { // to.datepicker( "option", "minDate", getDate( this ) ); // }), to = $( "#to" ).datepicker({ changeMonth: true, numberOfMonths: 1, dateFormat: 'yy-mm-dd', }) // .on( "change", function() { // from.datepicker( "option", "maxDate", getDate( this ) ); // }); function getDate( element ) { var date; try { date = element.value; } catch( error ) { date = null; } return date; } } ); $( function() { var from = $( "#from_id2" ) .datepicker({ changeMonth: true, numberOfMonths: 1, dateFormat: 'yy-mm-dd', }) // .on( "change", function() { // to.datepicker( "option", "minDate", getDate( this ) ); // }), to = $( "#to_id2" ).datepicker({ changeMonth: true, numberOfMonths: 1, dateFormat: 'yy-mm-dd', }) // .on( "change", function() { // from.datepicker( "option", "maxDate", getDate( this ) ); // }); function getDate( element ) { var date; try { date = element.value; } catch( error ) { date = null; } return date; } } ); $(function(){ $('input[type="time"][value="now"]').each(function(){ var d = new Date(), h = d.getHours(), m = d.getMinutes(); if(h < 10) h = '0' + h; if(m < 10) m = '0' + m; $(this).attr({ 'value': h + ':' + m }); }); }); $(function(){ $('input[type="time"][value="now1"]').each(function(){ var d = new Date(), h = d.getHours(), m = d.getMinutes(); if(h < 10) h = '0' + h; if(m < 10) m = '0' + m; $(this).attr({ 'value': h + ':' + m }); }); }); </script> </body>