File: /home/barbeatleanalyti/www/m.beatleanalytics.com/application/views/beatleAdmin/managenews.php
<?php
include('include/header.php');
$this->load->model('Admin_model');
?>
<script>
$(document).ready(function(){
// ================== DELETE USER START FROM HERE ========================
$(".deluser").click(function(){
var txt;
var r = confirm("Would you like to delete this news");
if (r == true)
{
var deluser = $(this);
var id = deluser.attr('data-uid');
var token = 'deleteuser';
$.ajax({
type : 'POST',
url : 'deleteNewsById',
data : {id:id,token:token},
success : function(res)
{
//alert(res);
$("#rowid_"+id).hide('500');
}
});
}
else
{
}
});
$("#searchUser").change(function()
{
var usertype = $("#searchUser").val();
$.ajax({
type : 'POST',
url : 'SearchUserByType',
data : {usertype:usertype},
success : function(res)
{
if (res)
{
$("#hidedata").hide();
$("#showdata").html(res);
}
}
});
});
$('#example').DataTable();
$('#startdate').daterangepicker({
singleDatePicker: 0,
singleClasses: "picker_1"
}, function(start, end, label) {
console.log(start.toISOString(), end.toISOString(), label);
});
});
</script>
<style>
.ajaxcalldata
{
padding:5px;
color:#FFF;
cursor:pointer;
background-color:rgb(76,76,76);
}
.success_div
{
padding:100%; padding:10px; color:#FFF; background-color:#42af42;border-radius:4px; text-align:center;margin-top:20px;
}
.error_div
{
padding:100%; padding:10px; color:#FFF; background-color:#FF0000;border-radius:4px; text-align:center;margin-top:20px;
}
</style>
<?php
if($this->uri->segment(3) == '' || $this->uri->segment(3) == 'list') {
/*echo '<pre style="margin-left:200px;">';
print_r($productData);
echo '</pre>';*/
?>
<div class="right_col" role="main">
<div class="">
<div class="col-md-12 col-sm-12 col-xs-12">
<!-----------------------new theme--------------------------------->
<div class="new-theme">
<h1>News Details</h1>
<br>
<table id="datatable" class="table table-striped new-table">
<thead>
<tr>
<th>Title</th>
<th style="min-width: 100px !IMPORTANT;">Dates</th>
<th>Description</th>
<th>status</th>
<th style="max-width:50px !important;">Action</th>
</tr>
</thead>
<tbody>
<?php
if (empty($productData)){ ?>
<tr class="ng-hide">
<td colspan="13"><h1 class="text-center text-muted ng-scope">No any data found.</h1><!-- end ngIf: !UsersList.ui.loading --></td>
</tr>
<?php } else {
foreach ($productData as $keyuser=>$valuser){
?>
<tr id="rowid_<?php echo $valuser->newsid;?>">
<td align="left"><?php echo $valuser->title;?></td>
<td align="center"><?php echo $valuser->startdate.'<br />'.$valuser->enddate;?></td>
<td align="left"><?php echo $valuser->description;?></td>
<td align="center"><a href="<?php echo base_url()?>index.php/beatleAdmin/managenews/editstatus/<?php echo $valuser->newsid;?>/<?php if($valuser->active =='Y') echo 'N'; else echo 'Y';?>"><?php if($valuser->active =='Y') echo '<i style="font-size:30px;color:#249c27;" class="fa fa-check" aria-hidden="true"></i>'; else echo '<i style="font-size:30px;color:#a72b29;" class="fa fa-times" aria-hidden="true"></i>';?></a></td>
<td align="center" style="max-width:50px !important;">
<ul class="nav navbar-right panel_toolbox">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a href="managenews/edit/<?php echo $valuser->newsid;?>">Edit</a>
</li>
<li><a href="javascript:;" class="deluser" data-uid="<?php echo $valuser->newsid;?>">Delete</a>
</li>
</ul>
</li>
</li>
</ul></td>
</tr>
<?php
//}
}
}
?>
</tbody>
</table>
</div>
<!-----------------------// new theme------------------------------------->
<div class="x_panel" style="display:none;">
<div class="x_title">
<h2>Offers List<small></small></h2>
<!-- <ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Settings 1</a>
</li>
<li><a href="#">Settings 2</a>
</li>
</ul>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul> -->
<div class="clearfix"></div>
</div>
<div class="x_content">
<table id="datatable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Title</th>
<th>Dates</th>
<th>Description</th>
<th>status</th>
<th style="max-width:50px !important;">Action</th>
</tr>
</thead>
<tbody>
<?php
if (empty($productData)){ ?>
<tr class="ng-hide">
<td colspan="13"><h1 class="text-center text-muted ng-scope">No any data found.</h1><!-- end ngIf: !UsersList.ui.loading --></td>
</tr>
<?php } else {
foreach ($productData as $keyuser=>$valuser){
?>
<tr id="rowid_<?php echo $valuser->newsid;?>">
<td align="left"><?php echo $valuser->title;?></td>
<td align="center"><?php echo $valuser->startdate.'<br />'.$valuser->enddate;?></td>
<td align="left"><?php echo $valuser->description;?></td>
<td align="center"><a href="<?php echo base_url()?>index.php/beatleAdmin/managenews/editstatus/<?php echo $valuser->newsid;?>/<?php if($valuser->active =='Y') echo 'N'; else echo 'Y';?>"><?php if($valuser->active =='Y') echo '<i style="font-size:30px;color:#249c27;" class="fa fa-check" aria-hidden="true"></i>'; else echo '<i style="font-size:30px;color:#a72b29;" class="fa fa-times" aria-hidden="true"></i>';?></a></td>
<td align="center" style="max-width:50px !important;">
<ul class="nav navbar-right panel_toolbox">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a href="managenews/edit/<?php echo $valuser->newsid;?>">Edit</a>
</li>
<li><a href="javascript:;" class="deluser" data-uid="<?php echo $valuser->newsid;?>">Delete</a>
</li>
</ul>
</li>
</li>
</ul></td>
</tr>
<?php
//}
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php }
else if($this->uri->segment(3) == 'add' || $this->uri->segment(3) == 'edit') { ?>
<div class="right_col" role="main">
<div class="">
<div class="row">
<?php if (!empty($message) && $message == 'img_size_error'){ ?>
<div class="error_div">
Banner size suhould be match with our criteria ( Height 400 to 500) X ( Width 1000 to 1200)
.
</div>
<?php } else if (!empty($message) && $message == 'title_taken'){?>
<div class="error_div">
Title has been taken, please try again with different title.
</div>
<?php } else if (!empty($message) && $message == 'img_ext_error'){?>
<div class="error_div">
Please select image from slected format only.(jpg, jpeg, png)
</div>
<?php }else if (!empty($message) && $message == 'success'){ ?>
<div class="success_div">
Offer banner added successfuly.
</div>
<?php } ?>
<div class="col-md-12 col-sm-12 col-xs-12">
<!---news----->
<div class="">
<h1 class="sub-model">Add new news </h1>
<form class="form-horizontal form-label-left" novalidate name="createUserForm" method="post" id="createUserForm" action="" enctype="multipart/form-data" >
<?php
// echo "<pre>";
// print_r($data);
// echo "</pre>";
$orgname = "";
$mainOrgId = "";
$orgid_edit = "";
$title = "";
$spoint = "";
$epoint = "";
$description = "";
$startdate = "";
$comment = "";
$name = "";
$points = "";
$stock = "";
if($this->uri->segment(3) == 'add'){
echo '<input type="hidden" name="actionfollow" value="addnewproducts" >';
}else if($this->uri->segment(3) == 'edit'){
//print_r($productData);
$title = $productData[0]->title;
$description = $productData[0]->description;
$startdate = date("m/d/Y",strtotime($productData[0]->startdate))." - ".date("m/d/Y",strtotime($productData[0]->enddate));
echo '<input type="hidden" name="actionfollow" value="editproducts" >';
echo '<input type="hidden" name="productid" value="'.$productData[0]->newsid.'" >';
}
if(isset($data)){
$title = $data['title'];
$description = $data['description'];
//$startdate = $data['startdate'];
$startdate = date("m/d/Y",strtotime($data['startdate']))." - ".date("m/d/Y",strtotime($data['enddate']));
}
?>
<!-- <span class="section">Personal Info</span>-->
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="Stocks">Title <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="title" name="title" autocomplete="off" required="required" class="form-control col-md-7 col-xs-12" value="<?php echo $title?>" placeholder="Title of the news">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="addUserEmail2">Description<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<!--<input type="number" value="" placeholder="Stocks. e.g. 10, 25, 10 ..."> -->
<textarea id="description" name="description" autocomplete="off" placeholder="News description at here" required="required" class="form-control col-md-7 col-xs-12"><?php echo $description?></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="startdate">Date between<span class="required">* </span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input class="form-control has-feedback-left col-md-7 col-xs-12" value="<?php echo $startdate?>" id="startdate" name="startdate" data-validate-linked="startdate" type="text" required="required">
<span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
<span id="" class="sr-only">(success)</span>
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="submit" class="btn btn-primary">Cancel</button>
<input type="submit" class="btn btn-success" <?php if (!empty($productData)){echo 'name="editusersubmit" id="editusersubmit"';}else{ echo 'name="addusersubmit" id="addusersubmit"';}?> value="Submit">
</div>
</div>
</form>
</div>
<!---//news----->
<div class="x_panel" style="display:none;">
<div class="x_title">
<h2>Add new news </h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<form class="form-horizontal form-label-left" novalidate name="createUserForm" method="post" id="createUserForm" action="" enctype="multipart/form-data" >
<?php
// echo "<pre>";
// print_r($data);
// echo "</pre>";
$orgname = "";
$mainOrgId = "";
$orgid_edit = "";
$title = "";
$spoint = "";
$epoint = "";
$description = "";
$startdate = "";
$comment = "";
$name = "";
$points = "";
$stock = "";
if($this->uri->segment(3) == 'add'){
echo '<input type="hidden" name="actionfollow" value="addnewproducts" >';
}else if($this->uri->segment(3) == 'edit'){
//print_r($productData);
$title = $productData[0]->title;
$description = $productData[0]->description;
$startdate = date("m/d/Y",strtotime($productData[0]->startdate))." - ".date("m/d/Y",strtotime($productData[0]->enddate));
echo '<input type="hidden" name="actionfollow" value="editproducts" >';
echo '<input type="hidden" name="productid" value="'.$productData[0]->newsid.'" >';
}
if(isset($data)){
$title = $data['title'];
$description = $data['description'];
//$startdate = $data['startdate'];
$startdate = date("m/d/Y",strtotime($data['startdate']))." - ".date("m/d/Y",strtotime($data['enddate']));
}
?>
<!-- <span class="section">Personal Info</span>-->
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="Stocks">Title <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="title" name="title" autocomplete="off" required="required" class="form-control col-md-7 col-xs-12" value="<?php echo $title?>" placeholder="Title of the news">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="addUserEmail2">Description<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<!--<input type="number" value="" placeholder="Stocks. e.g. 10, 25, 10 ..."> -->
<textarea id="description" name="description" autocomplete="off" placeholder="News description at here" required="required" class="form-control col-md-7 col-xs-12"><?php echo $description?></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="startdate">Date between<span class="required">* </span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input class="form-control has-feedback-left col-md-7 col-xs-12" value="<?php echo $startdate?>" id="startdate" name="startdate" data-validate-linked="startdate" type="text" required="required">
<span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
<span id="" class="sr-only">(success)</span>
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="submit" class="btn btn-primary">Cancel</button>
<input type="submit" class="btn btn-success" <?php if (!empty($productData)){echo 'name="editusersubmit" id="editusersubmit"';}else{ echo 'name="addusersubmit" id="addusersubmit"';}?> value="Submit">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php include ('include/footer.php'); ?>