ok
Direktori : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/ |
Current File : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/files-details-add.php |
<?php include "header.php";?> <div class="content-wrapper" style="background:white;"> <div class="clearfix"></div> <section class="content"> <div class="row"> <div class="col-xs-12"> <div> <div class="box-header"> <h3 class="box-title"><b>Add Files Details: </b></h3> </div> <div class="box-body"> <div class="col-lg-12"> <!-- Content Section Starts Here --> <div id="content-div"> <form action="" enctype="multipart/form-data" method="post" id="add_form" accept-charset="utf-8"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label class="required" for="file_name">File Name</label> <input type="text" name="file_name" id="file_name" class="form-control tip" required="required" placeholder="Enter File Name" /> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="file_size">File Size</label> <input type="text" name="file_size" id="file_size" class="form-control tip" required="required" placeholder="Enter File Size" /> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="order_no">Order Number</label> <input type="text" name="order_no" id="order_no" class="form-control tip" required="required" placeholder="Enter Order Number" /> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label class="control-label required" for="type">Type</label> <select name="type" class="form-control select2" style="width:100%" id="type"> <option value="1">FILES</option> <option value="2">URL</option> </select> </div> </div> <div id="files_section"></div> <!--<div class="col-md-4"> <div class="form-group"> <label class="required" for="file">Choose Files</label> <input type="file" name="photo" id="photo" value="" class="form-control tip" required="required" /> </div> <span style="color: red;" id="photospan"></span> </div>--> <div class="col-sm-4"> <div class="form-group"> <label class="control-label required" for="category">Category</label> <select name="category" class="form-control select2" style="width:100%;" id="category" required> <option value="">Select Category</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_category` WHERE status=1"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $data) { ?> <option value="<?=$data['id']?>"><?=$data['name']?></option> <?php } ?> </select> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label class="control-label required" for="headings">Tab - Headings</label> <select name="headings" class="form-control select2" style="width:100%;" id="headings" required> <option value="">Select Tab - Headings</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_tab_headings` WHERE status=1"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $data) { ?> <option value="<?=$data['id']?>"><?=$data['name']?></option> <?php } ?> </select> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label class="control-label required" for="status">Status</label> <select name="status" class="form-control select2" style="width:100%" id="status"> <option value="1">Active</option> <option value="0">In-Active</option> </select> </div> </div> <div class="row"> <div class="col-lg-12" style="padding: 0px;"><br> <div class="form-group" style="text-align:center;"> <input type="submit" id="add_files" name="add_files" value="Add Files" class="btn btn-success" /> </div> </div> </div> </div> </form> </div> <div id="loading-div" style="display: none;"> <center> <img src="img/loading.gif" style="width: 250px;"><br><b class="blinking">Processing Please Wait...</b></center> <br><br><br><br> </div> <div class="form-group" style="text-align:center;"> <a href="home-news-add.php"><button class="btn btn-primary" ><i class="fa fa-refresh"></i> Reset Form</button></a> <a href="home_news.php"><button class="btn btn-warning" ><i class="fa fa-chevron-left"></i> Back to List</button></a> </div> <!-- Content Section Endsss Here --> <div class="clearfix"></div> </div> </div> </div> </div> </section> <script> /*var photo = document.getElementById("photo"); photo.onchange = function() { console.log(photo); $('#photospan').text(''); if(this.files[0].size > 5500000){ $('#photospan').text('File Size Maximum 5 mb Allowed'); alert("File is too big!"); this.value = ""; }; };*/ function photo_onChange(){ var photo = document.getElementById("photo"); console.log(photo); $('#photospan').text(''); if(this.files[0].size > 5500000){ $('#photospan').text('File Size Maximum 5 mb Allowed'); alert("File is too big!"); this.value = ""; }; } </script> <script> $("#type").change(function () { files_Type(); }); function files_Type(){ $("#photo").change(function () { photo_onChange(); }); $("#files_section").empty(); var type = $("#type").val(); console.log(type); if(type==1){ var row = '<div class="col-md-4">'+ '<div class="form-group">'+ '<label class="required" for="file">Choose Files</label>'+ '<input type="file" name="photo" id="photo" value="" class="form-control tip" required="required" />'+ '<span style="color: red;" id="photospan"></span>'+ '</div>'+ '</div>'; $("#files_section").append(row); } else if(type==2){ var row = '<div class="col-md-4">'+ '<div class="form-group">'+ '<label class="required" for="files_url">File Url</label>'+ '<input type="text" name="files_url" id="files_url" class="form-control tip" required="required" placeholder="Enter Files Url" />'+ '</div>'+ '</div>'; $("#files_section").append(row); } } $(document).ready(function(){ files_Type(); }); $(function() { console.log( "ready!" ); }); $(document).ready(function(){ $('#add_form').on('submit', function(e){ e.preventDefault(); $("#loading-div").show(); $("#content-div").hide(); $("#add_files").attr('disabled','disabled'); console.log('News Form Submit Option Start...'); var formData = new FormData(this); formData.append('type', 'files_add'); $.ajax({ url: 'apis/files-api.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { console.log(response); if(response['status']==200){ //put success coode alert(response['message']); $("#loading-div").hide(); $("#content-div").show(); $('#add_form').trigger("reset"); $("#add_files").removeAttr('disabled'); }else{ //put falied code $("#loading-div").hide(); alert(response['message']); $("#add_files").removeAttr('disabled'); } } }); }); }); </script> <style> table,td,th{ padding:5px; } th{ border: 1px solid black; } td{ border: 1px solid black; border-style: dashed; } </style> <?php include "footer.php";?>