D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
grandhou
/
www
/
admin
/
Filename :
add-pkg.php
back
Copy
<?php include('include/constant.php'); require_once "includes/includepath.php"; $objval = new validate(); $objgen = new general(); $hdnval = 1; $hdnval1 = 1; $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : "1"; if($_GET['msg']==3) { $msg2 = "Wedding details Inserted Successfully."; } if($_GET['msg']==2) { $msg2 = "Image Deleted Successfully."; } if(isset($_GET['del'])) { $id= $_GET['del']; $img_res = $objgen->get_Onerow("pkg_images","AND id=".$id); if(file_exists("../photos/thumb/".stripslashes($img_res['image']))) unlink("../photos/thumb/".stripslashes($img_res['image'])); $msg = $objgen->del_Row('pkg_images','id='.$id); } if(isset($_GET['del1'])) { $id= $_GET['del1']; $img_res = $objgen->get_Onerow("pkg_ace","AND id=".$id); if(file_exists("../photos/thumb/".stripslashes($img_res['ace2']))) unlink("../photos/thumb/".stripslashes($img_res['ace2'])); $msg = $objgen->del_Row('pkg_ace','id='.$id); } if(isset($_POST['Create'])) { $heading = trim($_POST['heading']); $Path4=$_FILES["listimage11"]["name"]; move_uploaded_file($_FILES["listimage11"]["tmp_name"],"upload/" .$_FILES["listimage11"]["name"]); $rules = array(); $rules[] = "required,heading,Enter the Heading"; $errors = $objval->validateFields($_POST, $rules); if(empty($errors)) { $msg = $objgen->ins_Row('tour_packages','heading,listimage',"'".addslashes($heading)."','".addslashes($Path4)."'"); if($msg=="") { $inrt_id = $objgen->get_insetId(); // print_r($_FILES);exit; if(isset($_FILES["image"])) { foreach($_FILES["image"]["name"] as $key=>$val) { $file = basename($_FILES["image"]["name"][$key]); if($file!="") { $ext = $objgen->extfind($file); $image_name = "pkg_".$key.$ext; move_uploaded_file($_FILES["image"]["tmp_name"][$key],"../photos/thumb/".$image_name); $msg = $objgen->ins_Row("pkg_images","pkg_id,image","$inrt_id,'".$image_name."'"); } } } if(isset($_FILES["image2"])) { foreach($_FILES["image2"]["name"] as $key=>$val) { $file = basename($_FILES["image2"]["name"][$key]); if($file!="") { $ext = $objgen->extfind($file); $image_name = "pkg_".$key.$ext; move_uploaded_file($_FILES["image2"]["tmp_name"][$key],"../photos/thumb/".$image_name); $msg = $objgen->ins_Row("pkg_ace","pkg_id,ace1,ace2","$inrt_id,'".$_POST['image1'][$key]."','".$image_name."'"); } } } $heading = ""; header("location:add-pkg.php?msg=3"); } } } if(isset($_GET['edit'])) { $id = $_GET['edit']; $result = $objgen->get_Onerow("tour_packages","AND id=".$id); $heading = stripslashes($result['heading']); $listimage = stripslashes($result['listimage']); } if(isset($_POST['Update'])) { $heading = trim($_POST['heading']); $imgFile4 = $_FILES['listimage']['name']; $tmp_dir4 = $_FILES['listimage']['tmp_name']; $imgSize4 = $_FILES['listimage']['size']; if($imgFile4) { $upload_dir4 = 'upload/'; // upload directory $imgExt4 = strtolower(pathinfo($imgFile4,PATHINFO_EXTENSION)); // get image extension $valid_extensions4 = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions $listimage = rand(1000,1000000).".".$imgExt4; if(in_array($imgExt4, $valid_extensions4)) { if($imgSize4 < 5000000) { unlink($upload_dir4.$listimage); move_uploaded_file($tmp_dir4,$upload_dir4.$listimage); } else { $errMSG4 = "Sorry, your file is too large it should be less then 5MB"; } } else { $errMSG4 = "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; } } else { // if no image selected the old image remain as it is. $listimage = $listimage; // old image from database } $rules = array(); $rules[] = "required,heading,Enter the Heading"; $errors = $objval->validateFields($_POST, $rules); if(empty($errors)) { $msg = $objgen->upd_Row('tour_packages',"heading='".addslashes($heading)."',listimage='".addslashes($listimage)."'","id=".$id); if($msg=="") { if(isset($_FILES["image_edit"])) { foreach($_FILES["image_edit"]["name"] as $key=>$val) { $file = basename($_FILES["image_edit"]["name"][$key]); if($file!="") { $img_res = $objgen->get_Onerow("pkg_images","AND id=".$key); if(file_exists("../photos/thumb/".stripslashes($img_res['image']))) unlink("../photos/thumb/".stripslashes($img_res['image'])); $ext = $objgen->extfind($file); $image_name = "pkg_".$key.$ext; move_uploaded_file($_FILES["image_edit"]["tmp_name"][$key],"../photos/thumb/".$image_name); $msg = $objgen->upd_Row("pkg_images","image='".$image_name."'","id=".$key); } } } if(isset($_FILES["image"])) { foreach($_FILES["image"]["name"] as $key=>$val) { $file = basename($_FILES["image"]["name"][$key]); if($file!="") { $ext = $objgen->extfind($file); $image_name = "pkg_".$key.$ext; move_uploaded_file($_FILES["image"]["tmp_name"][$key],"../photos/thumb/".$image_name); $msg = $objgen->ins_Row("pkg_images","pkg_id,image","$id,'".$image_name."'"); } } } header("location:edit-pkg.php?msg=1&page=".$page); } } } if(isset($_POST['Cancel'])) { header("location:edit-pkg.php?page=".$page); } ?> <!DOCTYPE html> <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>Admin| Add Weddings</title> <link rel="shortcut icon" href="upload/favicon.ico"> <link type="text/css" href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link type="text/css" href="bootstrap/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'> <script src="<?php echo $tiny; ?>" referrerpolicy="origin"></script> </head> <body oncontextmenu="return false;"> <script> document.onkeydown = function(e) { if(event.keyCode == 123) { return false; } if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){ return false; } if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){ return false; } if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){ return false; } } </script> <?php include('include/header.php');?> <?php include('include/pdo.php');?> <div class="wrapper"> <div class="container"> <div class="row"> <?php include('include/sidebar.php');?> <div class="span9"> <div class="header"> <h1 class="page-title" ><?php if(isset($_GET['edit'])){ echo "Edit"; } else { echo "Add"; } ?> Weddings</h1> </div> <ul class="breadcrumb"> <li><a href="index.php">Home</a> <span class="divider">/</span></li> <li class="active"><?php if(isset($_GET['edit'])){ echo "Edit"; } else { echo "Add"; } ?> Weddings</li> </ul> <div class="content"> <div class="module"> <div class="module-body"> <?php if($msg2!="") { ?> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong><?php echo $msg2; ?></strong> </div> <?php } ?> <?php if (!empty($errors)) { ?> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> <?php echo "Please fix the following errors:<br>"; ?> <div> <?php foreach ($errors as $error1) echo "<div> - ".$error1." </div>"; ?> </div> </div> <?php } ?> <?php if($msg!="") { ?> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> <?php echo $msg; ?> </div> <?php } ?> <br /> <form action="" method="post" name="frm_add" enctype="multipart/form-data"> <div class="control-group"> <label class="control-label" for="basicinput">Heading</label> <div class="controls"> <input type="text" id="heading" name="heading" value="<?php echo $heading; ?>" required> </div> </div> <?php if(isset($_GET['edit'])) {?><label>Listing Image (500 x 600)</label> <img src="upload/<?php echo $listimage;?>" width="100px" height="100px" alt="No Image"> <input type="file" name="listimage" accept="image/*" /> <?php } else{?><label>Listing Image (500 x 600)</label> <input type="file" name="listimage11" id="listimage11" value="" class="span8 tip" > <?php } ?> <div style="clear:both;padding-bottom:15px;"></div> <div style="clear:both;padding-bottom:15px;"></div> <script> function js_show_em() { var hdnval =$('#hdnval').val(); var hdnval_inc = parseInt(hdnval)+1; var html_data = '<div id="div_'+hdnval+'"><label>Image '+hdnval_inc+'</label><input name="image[]" type="file" class="input-xlarge" /> <a href="javascript:void(0);" onclick="js_hide_em('+hdnval+')"><img src="images/minus.png" width="20" height="20" /></a></div>'; $('#up_image').append(html_data); $('#hdnval').val(hdnval_inc); } function js_hide_em(id) { $( '#div_'+id ).remove(); } </script> <script> $(document).ready(function () { var mySelect = $('#first-disabled2'); $('#special').on('click', function () { mySelect.find('option:selected').prop('disabled', true); mySelect.selectpicker('refresh'); }); $('#special2').on('click', function () { mySelect.find('option:disabled').prop('disabled', false); mySelect.selectpicker('refresh'); }); $('#basic2').selectpicker({ liveSearch: true, maxOptions: 1 }); }); </script> <h3>Gallery Images</h3> <?php if($id!="") { $i=1; $img_cnt = $objgen->get_AllRowscnt("pkg_images","AND pkg_id=".$id); if($img_cnt>0) { $img_arr = $objgen->get_AllRows("pkg_images",0,$img_cnt,"id asc","AND pkg_id=".$id); foreach($img_arr as $key=>$val) { ?> <div> <label>Image <?=$i?></label> <img src="../photos/thumb/<?=$val['image'];?>" height="50" width="50"> <input name="image_edit[<?=$val['id']?>]" type="file" class="input-xlarge" value="<?=$val['image'];?>"/> <div><?php echo $val['image'];?> <a href="add-pkg.php?del=<?=$val['id']?>&page=<?=$page?>&edit=<?=$id?>" role="button" onClick="return confirm('Are you want to delete this Image?')"><i class="icon-trash"></i></a> </div> </div> <?php $i++; $hdnval++; } } } ?> <label>Image <?=$hdnval?></label> <div id="up_image"> <input name="image[]" type="file" class="input-xlarge" /> <a href="javascript:void(0);" onclick="js_show_em()"> <img src="images/plus.png" width="20" height="20" /> </a> </div> <input name="hdnval" id="hdnval" type="hidden" value="<?=$hdnval?>"> <div> <div style="clear:both;padding-bottom:15px;"></div> <div style="clear:both;padding-bottom:15px;"></div> <div style="clear:both;padding-bottom:15px;"></div> <div style="clear:both;padding-bottom:15px;"></div> <?php if(isset($_GET['edit'])) { ?> <button class="btn btn-primary" type="submit" name="Update"><i class="icon-save"></i> Update</button> <button class="btn btn-primary" type="submit" name="Cancel"><i class="icon-save"></i> Cancel</button> <?php } else { ?> <button class="btn btn-primary" type="submit" name="Create"><i class="icon-save"></i> Save</button> <?php } ?> </div> </form> </div> </div> </div><!--/.content--> </div><!--/.span9--> </div> </div><!--/.container--> </div><!--/.wrapper--> <?php include('include/footer.php');?> <script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></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>'); } ); </script> <script src="lib/bootstrap/js/bootstrap.js"></script> <script type="text/javascript"> $("[rel=tooltip]").tooltip(); $(function() { $('.demo-cancel-click').click(function(){return false;}); }); </script> <script src="bootstrap/js/jquery.min.js" type="text/javascript"></script> <script src="bootstrap/js/script.js" type="text/javascript"></script> </body>