JezK
Edit File: news_management_edit.php
<?php include('admin_functions.php'); if($_SESSION['username']=='') { echo "<script>location.replace('index.php');</script>" ; } ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript" src="https://www.google.com/jsapi"> </script> <script type="text/javascript"> // Load the Google Transliterate API google.load("elements", "1", { packages: "transliteration" }); function onLoad() { var options = { sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH, destinationLanguage: [google.elements.transliteration.LanguageCode.TELUGU], shortcutKey: 'ctrl+g', transliterationEnabled: true }; // Create an instance on TransliterationControl with the required // options. var control = new google.elements.transliteration.TransliterationControl(options); //new google.elements.transliteration.TransliterationControl(options); // Enable transliteration in the textbox with id // 'transliterateTextarea'. control.makeTransliteratable(['newstitletelugu']); control.makeTransliteratable(['descriptiontelugu']); } google.setOnLoadCallback(onLoad); </script> <?php $admin=new adm_functions(); $id = $_GET['id']; $newsdata = $admin->get_news_byid($id); $getMultipleImages=$admin->getNewsMultipleImagesWithID($id); //print_r($getMultipleImages);exit; $categoriesdata = $admin->get_category(); $statesdata = $admin->get_states(); $districtdata = $admin->get_districts_byid($newsdata['state']); $mandaldatadata = $admin->get_mandals_byid($newsdata['district']); $citiesdata = $admin->get_city_byid($newsdata['mandal']); $optiondist = ''; $optionmandal =''; $optioncity =''; if($citiesdata){ foreach($citiesdata as $key1=>$val1){ $select = ''; if($newsdata['city'] == $val1['cityid']){ $select ="selected=selected"; } $optioncity .= '<option value="'.$val1['cityid'].'" '.$select.'>'.$val1['cityname'].'</option>'; } } foreach($districtdata as $key1=>$val1){ $select = ''; if($newsdata['district'] == $val1['districtid']){ $select ="selected=selected"; } $optiondist .= '<option value="'.$val1['districtid'].'" '.$select.'>'.$val1['districtname'].'</option>'; } foreach($mandaldatadata as $key1=>$val1){ $select = ''; if($newsdata['mandal'] == $val1['mandalid']){ $select ="selected=selected"; } $optionmandal .= '<option value="'.$val1['mandalid'].'" '.$select.'>'.$val1['mandalname'].'</option>'; } foreach($statesdata as $key=>$val){ $select = ''; if($newsdata['state'] == $val['stateid']){ $select ="selected=selected"; } $optionstates .= '<option value="'.$val['stateid'].'" '.$select.'>'.$val['statename'].'</option>'; } $optionadataeng = ''; $optionadatatelugu = ''; foreach($categoriesdata as $key=>$val){ $select = ''; if($newsdata['category'] == $val['id']){ $select ="selected=selected"; } $optionadataeng .= '<option value="'.$val['id'].'" '.$select.'>'.$val['name_en'].'</option>'; $optionadatatelugu .= '<option value="'.$val['id'].'" '.$select.'>'.$val['name_te'].'</option>'; } if($_POST['submitbtn'] == "Update"){ $update = $admin->update_news($_POST,$_FILES,$_GET['id']); if($update == "200"){ echo "<script>alert('News updated successfully');</script>" ; echo "<script>location.replace('news_management.php');</script>" ; } } $currentPage='news_management'; include"header.php"; ?> <body onload="checklanguage('<?php echo $newsdata['language'];?>')"> <div class="main-panel"> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar bar1"></span> <span class="icon-bar bar2"></span> <span class="icon-bar bar3"></span> </button> <a class="navbar-brand" href="#">Edit News </a> </div> </div> <div class="collapse navbar-collapse"> </div> </nav> <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="text-right paddingBtm"><a href="news_management.php"><button class="btn btn-info btn-fill">Back</button></a></div> <form method="POST" enctype="multipart/form-data"> <div class="col-md-6 col-lg-6"> <div class="row form-group"> <label for="title" class="col-md-6 label-control">Language:</label> <div class="col-md-6"> <?php if($newsdata['language'] == "en") { $language ="English"; }else{ $language ="Telugu"; } echo $language; ?> </div> </div> <?php $title = ''; $titlete = ''; $description = ''; $descriptionte = ''; if($newsdata['language'] == "en"){ $title = $newsdata['title']; $description = $newsdata['description']; }else{ $titlete = $newsdata['title']; $descriptionte = $newsdata['description']; } ?> <div class="row form-group" id="titleenglishblock"> <label for="title" class="col-md-6 label-control">Title:</label> <div class="col-md-6"> <input type="text" class="form-control" name="newstitle" id="newstitle" value="<?php echo $title; ?>"> </div> </div> <div class="row form-group" id="newstitletelugublock" > <label for="title" class="col-md-6 label-control">Title:</label> <div class="col-md-6"> <input type="text" class="form-control" name="newstitletelugu" id="newstitletelugu" value="<?php echo $titlete; ?>"> </div> </div> <div class="row form-group"> <label for="category" class="col-md-6 label-control">Category:</label> <div class="col-md-6"> <select class="form-control" id="category" name="category" > <?php if($newsdata['language'] == "en"){ echo $optionadataeng; } else { echo $optionadatatelugu; }?> </select> </div> </div> <div class="row form-group"> <label for="description" class="col-md-6 label-control">States:</label> <div class="col-md-6"> <select id="state" class="form-control" name="state" id="state" onchange="districts_data(this.value)"> <?php echo $optionstates;?> </select> </div> </div> <div class="row form-group"> <label for="description" class="col-md-6 label-control">District:</label> <div class="col-md-6"> <select id="district" name="district" id="district" class="form-control" onchange="mandals_data(this.value)"> <?php echo $optiondist;?> </select> </div> </div> <div class="row form-group"> <label for="category" class="col-md-6 label-control">Mandal:</label> <div class="col-md-6"> <select class="form-control" id="mandal" name="mandal" onchange="city_data(this.value)"> <option value="" >select District</option> <?php echo $optionmandal;?> </select> </div> </div> <div class="row form-group"> <label for="category" class="col-md-6 label-control">City:</label> <div class="col-md-6"> <select class="form-control" id="city" name="city" > <option value="" >select District</option> <?php echo $optioncity;?> </select> </div> </div> <div class="row form-group"> <label for="end_date" class="col-md-6 label-control">News End Date:</label> <div class="col-md-6"> <input type="text" name="end_date" id="datetimepicker_mask" value="<?php echo $newsdata['expdate']; ?>"> </div> </div> <div class="row form-group"> <label for="image" class="col-md-6 label-control">Image:(Using control and mouse click you can upload multiple images)</label> <div class="col-md-6"> <input type="file" class="form-control" name="media_array[]" id="media1" multiple="multiple" onchange="validateImage();"><br/> <div id="loadimgdata"> <?php if(count($getMultipleImages)>0) { foreach($getMultipleImages as $img){ ?> <image height="150px" width="100px" class="removeimg" src="http://<?php echo $_SERVER['HTTP_HOST'].'/'.$img['image'];?>" ></image><a href="javascript:void(0)" class="delsty" onclick="return delimg('<?php echo $img['image_id'];?>','<?php echo $id;?>','<?php echo $newsdata['media'];?>')">X</a> <?php } } else if($newsdata['media']!='' && $newsdata['type'] == 1){?> <image height="150px" width="100px" class="removeimg" src="http://<?php echo $_SERVER['HTTP_HOST'].'/'.$newsdata['media'];?>" ></image> <?php }?> </div> </div> </div> <div class="row form-group"> <label for="image" class="col-md-6 label-control">Video:</label> <div class="col-md-6"> <input type="file" class="form-control" name="media" > <?php if($newsdata['type'] == 2){ ?> <video width="320" height="240" controls> <source src="http://<?php echo $_SERVER['HTTP_HOST'].'/'.$newsdata['media'];?>" type="video/mp4"></video> <?php } ?> <input type="hidden" name="editmedia" value="<?php echo $newsdata['media'];?>"/> <input type="hidden" name="editmediaposter" value="<?php echo $newsdata['image'];?>"/> </div> </div> <div class="row form-group" id="titleenglishblock"> <label for="title" class="col-md-6 label-control">Youtube share Url:[Post url,Eg:https://www.youtube.com/watch?v=8h4FMWK8RrM]</label> <div class="col-md-6"> <input type="text" class="form-control" name="youtubeUrl" id="youtubeUrl" value="<?php echo $newsdata['youtubeUrl'];?>"> </div> </div> <div style="margin-left:165px;font-family: arial;font-size: 12px;font-weight:bold;color:blue;">You can add either Images or Video Or youtube Share url to display in the App.</div><br/> <div class="row form-group"> <label for="image" class="col-md-6 label-control">Audio:</label> <div class="col-md-6"> <input type="file" class="form-control" name="audiomedia" > <?php if($newsdata['audio']!=''){?> <a href="http://<?php echo $_SERVER['HTTP_HOST'].'/'.$newsdata['audio']; ?>">Audio File</a> <?php }?> <input type="hidden" name="editaudio" value="<?php echo $newsdata['audio'];?>"/> </div> </div> <div class="row form-group"> <label for="image" class="col-md-6 label-control" style="width:22%">Edit By Admin(show in App):</label> <div class="col-md-6"> <input type="checkbox" name="editedby" value="1" <?php if($newsdata['editedby']==1){?>checked="checked"<?php }?>/> </div> </div> </div> <div class="col-md-6 col-lg-6"> <div class="row form-group" id="newsdescriptionenglish_block"> <label for="description" class="col-md-12 label-control">Description:</label> <div class="col-md-12"> <textarea type="text" class="form-control" name="descriptionenglish" rows="35" id="descriptionenglish" ><?php echo $description; ?></textarea> </div> </div> <div class="row form-group" id="newsdescriptiontelugu_block"> <label for="description" class="col-md-12 label-control">Description:</label> <div class="col-md-12"> <textarea type="text" class="form-control" name="descriptiontelugu" rows="35" id="descriptiontelugu" ><?php echo $descriptionte; ?></textarea> </div> </div> </div> <div style="clear:both;"></div> <div class="col-md-12 text-center"> <input type="hidden" name="imagepre" id="imagepre" value="<?php echo $newsdata['media']; ?>" > <input type="hidden" name="audiopre" id="audiopre" value="<?php echo $newsdata['audio'];?>" > <input type="hidden" name="newsid" id="newsid" value="<?php echo $_GET['id'];?>" > <input type="hidden" name="uid" id="uid" value="<?php echo $newsdata['uid'];?>" > <input type="hidden" name="mediatype" id="mediatype" value="<?php echo $newsdata['type'];?>" > <input type="hidden" name="language_edit" id="language_edit" value="<?php echo $newsdata['language'];?>" > <input type="submit" value="Update" name="submitbtn" id="submitbtn" class="btn btn-primary" onclick="return validate_postform()"> <input type="reset" value="Cancel" class="btn btn-danger" onclick="cancelpage()"> </div> </form> </div> </div> </div> </div> </body> <?php include"footer.php" ?> <link rel="stylesheet" type="text/css" href="./jquery.datetimepicker.css"/> <style type="text/css"> .custom-date-style { background-color: red !important; } .input{ } .input-wide{ width: 500px; } .removeimg{ position: relative; margin-bottom:6px; } .delsty { top: -68px; position: relative; background: #ff0000; border-radius: 50%; padding: 3px; color: #fff; /* right: -2px; */ z-index: 9; margin-left: -9px; } .col-md-2 { /* width: 2.66666667%; */ width: 16.6666666%; } textarea.form-control { max-width: 100%; padding: 10px 18px; resize: none; /*height: 250px;*/ } </style> <script src="./jquery.js"></script> <script src="build/jquery.datetimepicker.full.js"></script> <script>/* window.onerror = function(errorMsg) { $('#console').html($('#console').html()+'<br>'+errorMsg) }*/ $('#datetimepicker_mask').datetimepicker({ mask:'9999/19/39 29:59', minDate: 0 }); function cancelpage(){ location.replace('news_management.php'); } function languageoptions(language){ if(language == "te"){ document.getElementById('newstitletelugublock').style.display = "block"; document.getElementById('titleenglishblock').style.display = "none"; document.getElementById('newsdescriptiontelugu_block').style.display = "block"; document.getElementById('newsdescriptionenglish_block').style.display = "none"; }else{ document.getElementById('newstitletelugublock').style.display = "none"; document.getElementById('titleenglishblock').style.display = "block"; document.getElementById('newsdescriptiontelugu_block').style.display = "none"; document.getElementById('newsdescriptionenglish_block').style.display = "block"; } $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"getnews"+"&language="+language, success: function(result) { $("#category").html(result); //section_option += '<option value="'+result2[i].section_id+'">'+result2[i].section_name+'</option>'; } }); } function districts_data(stateid){ $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"getdistricts"+"&state="+stateid, success: function(result) { $("#district").html(result); //section_option += '<option value="'+result2[i].section_id+'">'+result2[i].section_name+'</option>'; } }); } function mandals_data(districtid){ $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"getmandals"+"&district="+districtid, success: function(result) { $("#mandal").html(result); //section_option += '<option value="'+result2[i].section_id+'">'+result2[i].section_name+'</option>'; } }); } function city_data(mandalid){ $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"getcity"+"&mandalid="+mandalid, success: function(result) { $("#city").html(result); //section_option += '<option value="'+result2[i].section_id+'">'+result2[i].section_name+'</option>'; } }); } function checklanguage(lan){ if(lan == "te"){ document.getElementById('newstitletelugublock').style.display = "block"; document.getElementById('titleenglishblock').style.display = "none"; document.getElementById('newsdescriptiontelugu_block').style.display = "block"; document.getElementById('newsdescriptionenglish_block').style.display = "none"; }else{ document.getElementById('newstitletelugublock').style.display = "none"; document.getElementById('titleenglishblock').style.display = "block"; document.getElementById('newsdescriptiontelugu_block').style.display = "none"; document.getElementById('newsdescriptionenglish_block').style.display = "block"; } } function validate_postform(){ var language = document.getElementById('language').value; var state = document.getElementById('state').value; var district = document.getElementById('district').value; var mandal = document.getElementById('mandal').value; var city = document.getElementById('city').value; var enddate = document.getElementById('datetimepicker_mask').value; var media = document.getElementById('media'); var mediaval=document.getElementById('media'); //var mediaval = $(input).val().toLowerCase(); var audiomedia = document.getElementById('audiomedia'); var audiomediaval=document.getElementById('audiomedia'); //var mediaval = $(input).val().toLowerCase(); if(language == "en"){ var newstitle = document.getElementById('newstitle').value; var description = document.getElementById('descriptionenglish').value; }else{ var newstitle = document.getElementById('newstitletelugu').value; var description = document.getElementById('descriptiontelugu').value; } if(language == '' || language.trim() == '') { alert('please Eneter the language'); return false; } if(newstitle == '' || newstitle.trim() == ''){ alert('please Eneter the news Title'); return false; } if(description == '' || description.trim() == ''){ alert('please Eneter the news Description'); return false; } if(state == '' || state.trim() == ''){ alert('please Eneter the state'); return false; } if(district == '' || district.trim() == ''){ alert('please Eneter the district'); return false; } if(mandal == '' || mandal.trim() == ''){ alert('please Eneter the mandal'); return false; } if(city == '' || city.trim() == ''){ alert('please Eneter the city'); return false; } if(enddate == '' || enddate.trim() == ''){ alert('please Eneter the enddate'); return false; } if(mediaval == ''){ alert('please Eneter the Media File'); return false; } if(audiomediaval == ''){ alert('please Eneter the audio File'); return false; } } function delimg(id,catid,media) { var x=confirm('Are you sure to delete this Image?'); if(x!='') { $.ajax({ url: "ajax_lc.php", type:"POST", data:"mode="+"deleteImg"+"&id="+id+"&cat="+catid+"&media="+media, success: function(result) { alert('Deleted image successfully'); $('#loadimgdata').html(''); $('#loadimgdata').html(result); } }); } } function validateImage() { for (var i = 0; i < $("#media1").get(0).files.length; ++i) { var file1=$("#media1").get(0).files[i].name; if(file1) { var t = file1.split('.').pop().toLowerCase(); if (t != "jpeg" && t != "jpg" && t != "png" && t != "bmp" && t != "gif") { alert('Please upload image like jpeg,jpg,gif,png and bmp'); $("#media1").val(''); return false; } } if (file1.size > 1024000) { alert('Max Upload size is 1MB only'); $("#media1").val(''); return false; } } } </script>