shell bypass 403
<?php
class Admin extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('Curd');
ob_start();
}
public function index(){
// print_r($_SESSION);
// $this->index_page_check();
$this->load->library("form_validation");
$this->load->view("admin/index");
}
public function forgot(){
$this->index_page_check();
$this->load->library("form_validation");
$this->load->view("admin/forgot");
}
function setting(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['setting_data']=$this->Curd->all_fetcher_order("settings","DESC");
$this->load->view("admin/setting",$data);
}
function pending_review(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['setting_data']=$this->Curd->all_fetcher_order("settings","DESC");
$this->load->view("admin/pending_review",$data);
}
function verify_review(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['setting_data']=$this->Curd->all_fetcher_order("settings","DESC");
$this->load->view("admin/verify_review",$data);
}
public function order_details(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['main_cat'] = $this->Curd->fetch_where_order("tb_main_category",array("*"),array("status"=>1),"ASC");
$data['order_res'] = $this->Curd->fetch_where_order("tb_order",array("*"),array("id"=>$this->uri->segment('3')),"DESC");
$this->load->view('admin/veiw_order',$data);
}
function update_product_price(){
// echo "<pre>";
// print_r($_POST);
// echo "</pre>";
// die();
$product_id = $this->input->post("product_id");
$this->Curd->delete("tb_product_price",array("product_id"=>$product_id));
// $color_id = $this->input->post("color_id");
// $color_id = $this->input->post("");
// print_r($_REQUEST['color_id']);
foreach($_REQUEST['color_id'] as $colo){
// echo $colo;
// echo "<br>";
$weight = $_REQUEST['weight'][$colo];
// print_r($weight);
$price = $_REQUEST['price'][$colo];
$reg_discount = $_REQUEST['reg_discount'][$colo];
$reg_sale_price = $_REQUEST['reg_sale_price'][$colo];
$qty = $_REQUEST['qty'][$colo];
for($ij=0;$ij<count($weight);$ij++){
$dsf =array("product_id"=>$product_id,"color_id"=>$colo,"weight"=>$weight[$ij],"price"=>$price[$ij],"reg_discount"=>$reg_discount[$ij],"reg_sale_price"=>$reg_sale_price[$ij],"qty"=>$qty[$ij],"status"=>1);
// print_r($dsf);
$this->Curd->insert("tb_product_price",$dsf);
}
}
redirect(base_url()."admin/view_product_weight/".base64_encode($product_id));
}
function contact_us(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['order_res'] = $this->Curd->all_fetcher_order("contact_us","DESC");
$this->load->view("admin/contact_us",$data);
}
function view_pages(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['order_res'] = $this->Curd->all_fetcher_order("pages","DESC");
$this->load->view("admin/view_pages",$data);
}
private function index_page_check(){
if(isset($_SESSION["token"])){
redirect(base_url("admin/dashboard"));
}
}
public function login_process(){
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("email","email","trim|valid_email|required");
$this->fv->set_rules("pwd","pwd","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/index");
}
else{
$email=$this->input->post("email");
$pwd=sha1($this->input->post("pwd"));
$res=$this->Curd->fetch_where("admin",array("id","status","role"),array("email"=>$email,"pwd"=>$pwd));
if($res==true){
foreach($res as $row){
$id=$row->id;
$status=$row->status;
$role=$row->role;
}
if($status==1){
$_SESSION["id"]=$id;
$_SESSION["role"]=$role;
$_SESSION['status']=$status;
$_SESSION["token"]=md5($id.$_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT']);
redirect(base_url()."admin/dashboard");
}else{
$this->session->set_flashdata('error_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error ! </strong> Your account is inactive </div>');
redirect(base_url()."admin/index");
}
}else{
$this->session->set_flashdata('error_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error ! </strong> Username Or Password Invalid</div>');
redirect(base_url()."admin/index");
}
}
}
public function forgot_process(){
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("email","email","trim|valid_email|required");
if($this->fv->run()==false){
$this->load->view("admin/forgot");
}
else{
$email=$this->input->post("email");
$res = $this->Curd->fetch_where("admin",array("*"),array("email"=>$email));
// $res=$this->Curd->fetch_where("admin",array("*"),array("email"=>$email));
// echo $this->db->last_query();
print_r($res);
if($res==true){
foreach($res as $row){
$id=$row->id;
$status=$row->status;
$show_pass=$row->show_pass;
$subject ="Your A/C Details";
$msg = "<table><tr><td colspan='2'>A/C Details</td></tr>"
. "<tr><td>Name</td><td>$row->name</td></tr>"
. "<tr><td>Phone</td><td>$row->phone</td></tr>"
. "<tr><td>Email ID</td><td>$row->email</td></tr>"
. "<tr><td>Password</td><td>$show_pass</td></tr>"
. "</table>";
// echo $msg;
$this->send_mail($row->email,$msg,$subject);
}
// die();
$this->session->set_flashdata('error_msg','<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>successfully! </strong> send password in your register email id</div>');
redirect(base_url()."admin/index");
}else{
$this->session->set_flashdata('error_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error ! </strong> This Email id is not register</div>');
redirect(base_url()."admin/forgot");
}
}
}
private function get_username(){
$res=$this->Curd->fetch_where("admin",array("name","email"),array("id"=>$_SESSION["id"]));
foreach($res as $row){
$name=$row->name;
$email=$row->email;
}
if(empty($name)){
return $email;
}
else{
return $name;
}
}
private function security_guard(){
if($_SESSION["token"]!=md5($_SESSION["id"].$_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT'])){
redirect(base_url()."admin/");
}
if($_SESSION['status']!=1){
redirect(base_url()."admin/");
}
}
public function dashboard(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->view("admin/dashboard",$data);
}
/* Start Testimonial */
public function view_testimonial(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['testi']=$this->Curd->all_fetcher_order("tb_testimonial","DESC");
$this->load->view("admin/view-testimonial",$data);
}
public function add_testimonial($t_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($t_id!=null){
$testi_id = base64_decode($t_id);
$data['testi_res'] = $this->Curd->fetch_where("tb_testimonial",array("*"),array("id"=>$testi_id));
}
$this->load->view("admin/add-testimonial",$data);
}
public function testimonial_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
// $data['main_cat_res'] = $this->Curd->fetch_where("tb_main_category",array("*"),array("status"=>1));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("title","Title","trim|required");
$this->fv->set_rules("name","Review By","trim|required");
// $this->fv->set_rules("snum","Sequence No.","trim|required");
$this->fv->set_rules("review","Review","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-testimonial",$data);
}
else{
$title=$this->input->post("title");
$name=$this->input->post("name");
// $snum=$this->input->post("snum");
$review=$this->input->post("review");
$rating_point=$this->input->post("rating_point");
$data=array("name"=>$name, "title"=>$title,"rating_point"=>$rating_point, "review"=>$review, "status"=>1);
if($this->Curd->insert("tb_testimonial",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/add_testimonial");
}
}
}
function temp_print(){
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script>
<?php
$order_no=base64_decode($this->input->get('id'));//$this->input->post("order_no");
$tol_pay=$cod_charge=$delivery_charges=$gr_total=0;
$this->db->or_where('order_no', $order_no);
$query = $this->db->get('tb_order');
if($query ->num_rows()> 0) {
foreach($query -> result() as $row)
{ }
}
$total_pay_amt = $row->order_price;
$c_name = $row->b_name;
$c_status=$row->order_staus;
$or_temp = '<table class="table table-bordered" border="1" cellspacing="0" cellpadding="0" style="width:100%">
<tr>
<td>S.No.</td>
<td>Products</td>
<td>HSN No.</td><td>SKU</td>
<td>Qty.</td>
<td>Price</td>
<td>Amount</td>
<td>Tax %</td>
<td>Tax Amount</td>
<td>Net Amount</td>
</tr>
<tbody style="text-align:center;">';
$p=0; $ta_amt1=$g_amt1=$n_total=0;
$order_list = array();
$this->db->or_where('order_no', $order_no);
$query = $this->db->get('tb_sub_order');
if($query ->num_rows()> 0) {
foreach($query -> result() as $r2)
{
$pay_amt = round(($r2->sale_price*100)/( 100+$r2->tax_per ),2);
$tx =round($pay_amt*$r2->tax_per/100,2);
$ta_amt = $tx*$r2->qty;
$g_amt = $pay_amt*$r2->qty;
$p++;
$tol =$r2->sale_price * $r2->qty;
$tol_pay +=$tol;
$pro_co="";
if($r2->product_color!="None"){
$pro_co="($r2->product_color)";
}
$or_temp.="<tr><td>$p</td>
<td>$r2->title ($r2->weight) $pro_co</td>
<td>$r2->hsn_no</td><td>$r2->sku</td>
<td>$r2->qty</td> <td>Rs.$pay_amt</td>
<td>Rs.$g_amt</td><td>$r2->tax_per</td>
<td>Rs.$ta_amt</td>
<td>Rs.$r2->total_price</td>
</tr>";
$ta_amt1= $ta_amt1+$ta_amt;
$g_amt1= $g_amt1+$g_amt;
$n_total = $n_total+$r2->total_price;
}
}
if($row->payment_method=='COD'){
$gr_total = $tol_pay+$row->cod_charge+$row->delivery_charges;
}else{
$gr_total = $tol_pay+$row->delivery_charges;
}
$g_amt1 = $n_total-$row->coupon_discount;
$pay_amt_3 = round(($g_amt1*100)/( 118 ),2);
$ta_amt1 =round($pay_amt_3*18/100,2);
$or_temp.='<tr>
<td colspan="5"> </td>
<td colspan="4">Total Product Value</td>
<td>Rs. '.$n_total.'</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="4">Discount Amount</td>
<td >Rs. '.$row->coupon_discount.'</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="4">Net Total Amount</td>
<td >Rs. '.$g_amt1.'</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="4">Total Taxable Value</td>
<td >Rs. '.$pay_amt_3.'</td>
</tr> ';
if(strtolower($row->b_state)=='delhi') {
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">CGST Amount</td>
<td>Rs. '.round($ta_amt1/2,2).'</td>
</tr>';
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">SGST Amount</td>
<td>Rs. '.round($ta_amt1/2,2).'</td>
</tr>';
}else{
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">IGST Amount</td>
<td>Rs. '.$ta_amt1.'</td>
</tr>';
}
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">Shipping Charge</td>
<td>Rs. '.$row->delivery_charges.'</td>
</tr>';
if($row->payment_method=='COD') { $or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">COD Charge</td>
<td>Rs. '.$row->cod_charge.'</td>
</tr>';
}
$or_temp.= '<tr>
<td colspan="5"> </td>
<td colspan="4">Total Invoice Value</td>
<td>Rs. '.$total_pay_amt.' </td>
</tr>
</tbody>
</table>';
$tracking_code='';
// if($row->tracking_code){ $tracking_code.='<p style="text-align:right;color: #4caf50;"><b><a target="_blank" href="'.base_url('admin/track?id='.$row->tracking_code).'">Track Your Order</a></b></p>'; }
$ddd='';
if($c_status =='Processing'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order is '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We are happy to let your know that your Order is being processing and will be shipped shortly.</p>' ;
}else if($c_status =='on the way'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been Shipped</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We are happy to let your know that your items have now been Shipped</p>' ;
}
else if($c_status =='Completed'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been Delivered</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We are happy to let your know that your items have now been Delivered</p>' ;
}
else if($c_status =='Returned'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We would like to let you know that your order has been returned back to us. </p>' ;
}
else if($c_status =='Refunded'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We would like to let you know that your order has been '.$c_status.' </p>' ;
}
else {
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We would like to let you know that your order has been '.$c_status.' </p>' ;
}
$df ='<div id = "content2" style=" box-shadow: 0px 5px 36px 4px #e5e5e5;
border-radius: 7px; padding: 12px 30px;
background: #f0f0f0;
width: 690px;
text-align: center; ">
<div style="border-bottom: 1px solid #d4d0d0;">
<img style="height:100px;" src="'.base_url('images/gutlooks.jpeg').'" style="height:60px;padding-bottom: 19px;">
</div>
'.$ddd.'
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Here is what you have Ordered:</b></p>
<p style="text-align:left"><b>Order No. :</b>'.$row->order_no.'</p>
<p style="text-align:left"><b>Order Date. :</b>'.$row->order_date.'</p>
'.$or_temp.'
<p style="text-align:left"><b>Your delivery Address:</b> <br>
Name:'.$row->b_name.' <br>
Phone:'.$row->mobile.' <br>
Address:'.$row->address.' <br>'.$row->landmark.' <br><br> City:'.$row->city.' State:'.$row->state.' Pincode:'.$row->pincode.' <br>
</p>'.$tracking_code.'
<table style="width:100%">
<tbody>
<tr><td colspan="2" style="text-align:left;">
<br>
Thanks,<br><br>
Team Gutlooks
</p>
</td></tr>
<tr ><td colspan="2" style="text-align:left;"><img src="'.base_url('images/gutlooks.jpeg').'" style="height:100px;/* padding: 7px 15px; *//* background: #fbfcfc; */text-align: left;border-radius: 11px;"></td></tr>
<tr><td colspan="2" style="text-align:left;">
<p style="
text-align: left;
border-radius: 11px;
">You may also contact us at: info@gutlooks.com</p>
</td></tr>
</tbody></table>
</div>';
echo $df;
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var HTML_Width = $("#content2").width();
var HTML_Height = $("#content2").height();
var top_left_margin = 15;
var PDF_Width = HTML_Width + (top_left_margin * 2);
var PDF_Height = (PDF_Width * 1.5) + (top_left_margin * 2);
var canvas_image_width = HTML_Width;
var canvas_image_height = HTML_Height;
var totalPDFPages = Math.ceil(HTML_Height / PDF_Height) - 1;
html2canvas($("#content2")[0]).then(function (canvas) {
var imgData = canvas.toDataURL("image/jpeg", 1.0);
var pdf = new jsPDF('p', 'pt', [PDF_Width, PDF_Height]);
pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin, canvas_image_width, canvas_image_height);
for (var i = 1; i <= totalPDFPages; i++) {
pdf.addPage(PDF_Width, PDF_Height);
pdf.addImage(imgData, 'JPG', top_left_margin, -(PDF_Height*i)+(top_left_margin*4),canvas_image_width,canvas_image_height);
}
pdf.save("invoice.pdf");
$("#content2").hide();
window.location.href = '<?php echo base_url();?>';
});
// var options = {
// //'width': 800,
// };
// options = {format:"PDF", background:"#fff"}
// var pdf = new jsPDF('p', 'pt', 'a4');
// pdf.addHTML($("#content2"), 2, 20, options, function() {
// pdf.save('invoice.pdf');
// window.location.href = '<?php echo base_url();?>';
// });
});
</script>
<?php
}
function temp($email,$order_no,$subject){
$tol_pay=$cod_charge=$delivery_charges=$gr_total=0;
$this->db->or_where('order_no', $order_no);
$query = $this->db->get('tb_order');
if($query ->num_rows()> 0) {
foreach($query -> result() as $row)
{ }
}
$total_pay_amt = $row->order_price;
$c_name = $row->b_name;
$c_status=$row->order_staus;
$or_temp = '<table class="table table-bordered" border="1" style="width:100%">
<tr>
<td>S.No.</td>
<td>Products</td>
<td>HSN No.</td><td>SKU</td>
<td>Qty.</td>
<td>Price</td>
<td>Amount</td>
<td>Tax %</td>
<td>Tax Amount</td>
<td>Net Amount</td>
</tr>
<tbody style="text-align:center;">';
$p=0; $ta_amt1=$g_amt1=$n_total=0;
$order_list = array();
$this->db->or_where('order_no', $order_no);
$query = $this->db->get('tb_sub_order');
if($query ->num_rows()> 0) {
foreach($query -> result() as $r2)
{
$pay_amt = round(($r2->sale_price*100)/( 100+$r2->tax_per ),2);
$tx =round($pay_amt*$r2->tax_per/100,2);
$ta_amt = $tx*$r2->qty;
$g_amt = $pay_amt*$r2->qty;
$p++;
$tol =$r2->sale_price * $r2->qty;
$tol_pay +=$tol;
$pro_co="";
if($r2->product_color!="None"){
$pro_co="($r2->product_color)";
}
$or_temp.="<tr><td>$p</td>
<td>$r2->title ($r2->weight) $pro_co</td>
<td>$r2->hsn_no</td><td>$r2->sku</td>
<td>$r2->qty</td> <td>Rs.$pay_amt</td>
<td>Rs.$g_amt</td><td>$r2->tax_per</td>
<td>Rs.$ta_amt</td>
<td>Rs.$r2->total_price</td>
</tr>";
$ta_amt1= $ta_amt1+$ta_amt;
$g_amt1= $g_amt1+$g_amt;
$n_total = $n_total+$r2->total_price;
}
}
if($row->payment_method=='COD'){
$gr_total = $tol_pay+$row->cod_charge+$row->delivery_charges;
}else{
$gr_total = $tol_pay+$row->delivery_charges;
}
$g_amt1 = $n_total-$row->coupon_discount;
$pay_amt_3 = round(($g_amt1*100)/( 118 ),2);
$ta_amt1 =round($pay_amt_3*18/100,2);
$or_temp.='<tr>
<td colspan="5"> </td>
<td colspan="4">Total Product Value</td>
<td>Rs. '.$n_total.'</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="4">Discount Amount</td>
<td >Rs. '.$row->coupon_discount.'</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="4">Net Total Amount</td>
<td >Rs. '.$g_amt1.'</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="4">Total Taxable Value</td>
<td >Rs. '.$pay_amt_3.'</td>
</tr> ';
if(strtolower($row->b_state)=='delhi') {
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">CGST Amount</td>
<td>Rs. '.round($ta_amt1/2,2).'</td>
</tr>';
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">SGST Amount</td>
<td>Rs. '.round($ta_amt1/2,2).'</td>
</tr>';
}else{
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">IGST Amount</td>
<td>Rs. '.$ta_amt1.'</td>
</tr>';
}
$or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">Shipping Charge</td>
<td>Rs. '.$row->delivery_charges.'</td>
</tr>';
if($row->payment_method=='COD') { $or_temp.=' <tr>
<td colspan="5"> </td>
<td colspan="4">COD Charge</td>
<td>Rs. '.$row->cod_charge.'</td>
</tr>';
}
$or_temp.= '<tr>
<td colspan="5"> </td>
<td colspan="4">Total Invoice Value</td>
<td>Rs. '.$total_pay_amt.' </td>
</tr>
</tbody>
</table>';
$tracking_code='';
if($row->tracking_code){
if($row->tracking_url =='https://tracklite.in/'){
$tracking_code.='<p style="text-align:right;color: #4caf50;"><b><a target="_blank" href="'.base_url('admin/track?id='.$row->tracking_code).'">Track Your Order</a></b></p>';
}else{
$tracking_code.='<p style="text-align:right;color: #4caf50;"><b><a target="_blank" href="https://app.shiprocket.co//tracking/'.$row->tracking_code.'">Track Your Order</a></b></p>';
}
}
$ddd='';
if($c_status =='Processing'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order is '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We are happy to let your know that your Order is being processing and will be shipped shortly.</p>' ;
}else if($c_status =='on the way'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been Shipped</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We are happy to let your know that your items have now been Shipped</p>' ;
}
else if($c_status =='Completed'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been Delivered</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We are happy to let your know that your items have now been Delivered</p>' ;
}
else if($c_status =='Returned'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We would like to let you know that your order has been returned back to us. </p>' ;
}
else if($c_status =='Refunded'){
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We would like to let you know that your order has been '.$c_status.' </p>' ;
}
else {
$ddd ='<h2 style="color: #4caf50;
text-align: center;
font-size: 23px;">Your Order has been '.$c_status.'</h2>
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Hello, '.$c_name.'!</b></p>
<p>Thanks again for making an order on (<a href="'.base_url('').'">'.base_url('').'</a>). We would like to let you know that your order has been '.$c_status.' </p>' ;
}
$df ='<div id = "content2" style=" box-shadow: 0px 5px 36px 4px #e5e5e5;
border-radius: 7px; padding: 12px 30px;
background: #f0f0f0;
width: 650px;
text-align: center; ">
<div style="border-bottom: 1px solid #d4d0d0;">
<img src="'.base_url('images/gutlooks.jpeg').'" style="height:100px;padding-bottom: 19px;">
</div>
'.$ddd.'
<hr style="border: 1px dotted;">
<p style="text-align:center"><b>Here is what you have Ordered:</b></p>
<p style="text-align:left"><b>Order No. :</b>'.$row->order_no.'</p>
<p style="text-align:left"><b>Order Date. :</b>'.$row->order_date.'</p>
'.$or_temp.'
<p style="text-align:left"><b>Your delivery Address:</b> <br>
Name:'.$row->b_name.' <br>
Phone:'.$row->mobile.' <br>
Address:'.$row->address.' <br>'.$row->landmark.' <br> City:'.$row->city.' State:'.$row->state.' Pincode:'.$row->pincode.' <br>
</p>'.$tracking_code.'
<p style="text-align:right;color: #4caf50; background: #4caf50;
padding: 10px;
text-align: center;"><b><a style="color:#fff;" target="_blank" href="'.base_url('admin/temp_print?id='.base64_encode($order_no)).'">Download Your receipt</a></b></p>
<table style="width:100%">
<tbody>
<tr><td colspan="2" style="text-align:left;">
<br>
Thanks,<br><br>
Team Gutlooks
</p>
</td></tr>
<tr ><td colspan="2" style="text-align:left;"><img src="'.base_url('images/gutlooks.jpeg').'" style="height:100px;/* padding: 7px 15px; *//* background: #fbfcfc; */text-align: left;border-radius: 11px;"></td></tr>
<tr><td colspan="2" style="text-align:left;">
<p style="
text-align: left;
border-radius: 11px;
">You may also contact us at: info@gutlooks.com</p>
</td></tr>
</tbody></table>
</div>';
// echo $df;
$this->send_mail1($email,$df,$subject);
}
function update_order_status(){
$od_id=$this->input->post("order_id");
$od_price=$this->input->post("order_price");
$order_no=$this->input->post("order_no");
$name=$this->input->post("name");
$mobile =$this->input->post("b_phone");
$data=array(
"order_staus"=>$this->input->post("order_staus")
);
if($this->Curd->update("tb_order", $data, "id", $od_id)){
if($email =$this->input->post("b_email")){
$subject = "Your Order Status is ".$this->input->post("order_staus") ;
$msg="";
if($this->input->post("order_staus")=='On Hold'){
$msg="<p>Hello $name,
Your order No. $order_no. couldn’t be confirmed as either your card issuer has declined the transaction against your purchase or you might have pressed back key while placing the order.
In case of any queries, feel free to <a href='".base_url('home/contact')."'>contact us</a> or whatsapp us on 8209722282 if you need any further help.</p>";
}
$msg .= "<table><tr><td colspan='2'>Order Details</td></tr>"
. "<tr><td>Name</td><td>$name</td></tr>"
. "<tr><td>Phone</td><td>$mobile</td></tr>"
. "<tr><td>Email ID</td><td>$email</td></tr>"
. "<tr><td>Order No.</td><td>$order_no</td></tr>"
. "<tr><td>Order Price</td><td>$od_price</td></tr>"
. "</table>";
if($this->input->post("order_staus")=='On Hold'){
$this->send_mail($email,$msg,$subject);
}else{
$this->temp($email,$order_no,$subject);
}
}
if($mobile){
$od_st = $this->input->post("order_staus");
if($od_st== 'on the way13'){
$msdf ="Received! Order No. $order_no of Rs. $od_price confirmed. We expect to deliver your order by Gutlooks. Thank You for shopping at Gutlooks!";
$this->send_sms($mobile,$msdf,'1207162022275237245');
}
else if($od_st== 'Completed'){
$msdf ="Hi $name, Your order No. $order_no of Rs. $od_price successfully delivered. Please rate your experience at https://g.page/r/CbgEfLWy2Wr5EAQ/review Thank you for trusting in us! -Gutlooks.";
$this->send_sms($mobile,$msdf,'1207162022283565117');
}
else if($od_st== 'Cancelled'){
$msdf ="Sorry! Your order No. $order_no couldn't be confirmed and has been cancelled. For more details contact us on 8209722282 See you again! -Gutlooks";
$this->send_sms($mobile,$msdf,'1207162075295906989');
}
else if($od_st== 'Cancelled by customer'){
$msdf ="Sorry! Your order No. $order_no couldn't be confirmed and has been cancelled. For more details contact us on 8209722282 See you again! -Gutlooks";
$this->send_sms($mobile,$msdf,'1207162075295906989');
}
}
redirect(base_url()."admin/order_details/".$od_id);
}else{
redirect(base_url()."admin/view_order");
}
}
function mailtemp(){
$ds ='<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#f7f7f7" style="max-width:500px;margin:auto;padding:12px;font-family:arial;color:#565a5c;background-color:#f5f5f5;border:1px solid #e8e8e8">
<tbody>
<tr>
<td align="center">
<img src="'.base_url('images/gutlooks.jpeg').'" style="height:100px;" title="Gutlooks" alt="Gutlooks" class="CToWUd">
<hr style="border:none;border-bottom:1px solid #bbbbbb;margin-top:15px">
</td>
</tr>
<tr>
<td>
<p style="font-size:14px"> #cust_d</p>
</td>
</tr>
<tr>
<td>
<p style="font-size:14px">Best Regards,<br>Team Gutlooks</p>
</td>
</tr>
</tbody>
</table> ';
return $ds;
}
function send_mail1($to_email,$dda,$subject){
$temp_msg = $dda;
require_once(APPPATH.'third_party/class.phpmailer.php');
require_once(APPPATH.'third_party/class.smtp.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "gutlooks.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Username = "info@gutlooks.com";
$mail->Password = "AD#%#kP#5";
$mail->AddAddress($to_email);
$mail->SetFrom($mail->Username);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $temp_msg;
if($mail->Send()){return true;}else {return false;}
}
function send_mail($to_email,$dda,$subject){
$d_temp = $this->mailtemp();
$temp_msg = str_ireplace('#cust_d',$dda, $d_temp);
require_once(APPPATH.'third_party/class.phpmailer.php');
require_once(APPPATH.'third_party/class.smtp.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "gutlooks.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Username = "info@gutlooks.com";
$mail->Password = "AD#%#kP#5";
$mail->AddAddress($to_email);
$mail->SetFrom($mail->Username);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $temp_msg;
if($mail->Send()){return true;}else {return false;}
}
public function send_sms($mobiles,$message,$template_id)
{
// print_r($response);
// print_r($err);
// die();
}
function update_order_details(){
$od_id=$this->input->post("order_id");
$data=array(
"invoice_date"=>$this->input->post("invoice_date"),
"invoice_no"=>$this->input->post("invoice_no"),
"tracking_code"=>$this->input->post("tracking_code"),
"carrier_name"=>$this->input->post("carrier_name"),
"tracking_url"=>$this->input->post("tracking_url"),
"pay_status"=>$this->input->post("pay_status"),
// "payment_method"=>$this->input->post("payment_method"),
"b_name"=>$this->input->post("b_name"),
"b_phone"=>$this->input->post("b_phone"),
"b_email"=>$this->input->post("b_email"),
"gstno"=>$this->input->post("gstno"),
"b_add"=>$this->input->post("b_add"),
"b_landmark"=>$this->input->post("b_landmark"),
"b_state"=>$this->input->post("b_state"),
"b_city"=>$this->input->post("b_city"),
"b_pincode"=>$this->input->post("b_pincode"),
"full_name"=>$this->input->post("full_name"),
"mobile"=>$this->input->post("mobile"),
"address"=>$this->input->post("address"),
"landmark"=>$this->input->post("landmark"),
"state"=>$this->input->post("state"),
"city"=>$this->input->post("city"),
"pincode"=>$this->input->post("pincode")
);
if($this->Curd->update("tb_order", $data, "id", $od_id)){
redirect(base_url()."admin/order_details/".$od_id);
}else{
redirect(base_url()."admin/view_order");
}
}
public function testimonial_update($testi_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("title","Title","trim|required");
$this->fv->set_rules("name","Review By","trim|required");
// $this->fv->set_rules("snum","Sequence No.","trim|required");
$this->fv->set_rules("review","Review","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-testimonial",$data);
}
else{
$testi_id = base64_decode($testi_id);
$title=$this->input->post("title");
$name=$this->input->post("name");
// $snum=$this->input->post("snum");
$review=$this->input->post("review");
$rating_point=$this->input->post("rating_point");
$data=array("name"=>$name, "title"=>$title,"rating_point"=>$rating_point, "review"=>$review);
if($this->Curd->update("tb_testimonial", $data, "id", $testi_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_testimonial");
}
}
}
public function testi_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$testi_id = $this->input->post('testi_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_testimonial",array("status"=>$status),"id",$testi_id)){
echo 1;
}
}
public function delete_testimonial($testi_id){
$data["username"]=$this->get_username();
$this->security_guard();
$testi_id = base64_decode($testi_id);
if($this->Curd->delete("tb_testimonial",array("id"=>$testi_id))){
redirect(base_url()."admin/view_testimonial");
}
}
/* Start Slider Work*/
public function view_slider(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['slider_res']=$this->Curd->all_fetcher_order("tb_slider","DESC");
$this->load->view("admin/view-slider",$data);
}
public function add_slider($s_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($s_id!=null){
$slider_id = base64_decode($s_id);
$data['slider_res'] = $this->Curd->fetch_where("tb_slider",array("*"),array("id"=>$slider_id));
}
$this->load->view("admin/add-slider",$data);
}
public function slider_process(){
$config['upload_path'] = './uploads/slider';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 90000; //KB
// $config['max_width'] = 1920;
// $config['max_height'] = 820;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if($_FILES["slider_img"]['error']==0){
if(!file_exists('uploads/slider/'.$_FILES["slider_img"]["name"])){
if ( ! $this->upload->do_upload('slider_img'))
{
$data = array('error' => $this->upload->display_errors());
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->view('admin/add-slider', $data);
}else{
$data = array('success_msg' =>'Image Upload successfully done','error' => ' ');
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($this->Curd->insert("tb_slider",array("name"=>$this->upload->data("file_name"),"page_link"=>$this->input->post("page_link"),"banner_type"=>$this->input->post("banner_type"),"status"=>1,"created"=>$this->Curd->getdate()))){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_slider");
}
}
}else{
$data=array('error' => 'File Already Exist');
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->view('admin/add-slider',$data);
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Error ! </strong>Choose Your Slider Image</div>');
redirect(base_url()."admin/add_slider");
}
}
public function slider_update($s_id){
$config['upload_path'] = './uploads/slider';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 2000; //KB
$config['max_width'] = 1920;
$config['max_height'] = 820;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if($_FILES["slider_img"]['error']==0){
if(!file_exists('uploads/slider/'.$_FILES["slider_img"]["name"])){
if ( ! $this->upload->do_upload('slider_img'))
{
$data = array('error' => $this->upload->display_errors());
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->view('admin/add-slider', $data);
}else{
$slider_id = base64_decode($s_id);
$data = array('success_msg' =>'Image Upload successfully done','error' => ' ');
$data['edit_slider']=$this->Curd->fetch_where('tb_slider',array('id','name'),array('id'=>$slider_id));
foreach($data['edit_slider'] as $sli){
$old_img=$sli->name;
if($old_img!=""){
unlink("./uploads/slider/".$old_img);
}
}
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($this->Curd->update("tb_slider",array("name"=>$this->upload->data("file_name"),"page_link"=>$this->input->post("page_link"),"banner_type"=>$this->input->post("banner_type")),"id",$slider_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_slider");
}
}
}else{
$data=array('error' => 'File Already Exist');
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->view('admin/add-slider',$data);
}
}else{
// print_r($_POST);
$slider_id = base64_decode($s_id);
$dataaa= array();
if($this->input->post("page_link")){
$dataaa['page_link']=$this->input->post("page_link");
}
if($this->input->post("banner_type")){
$dataaa['banner_type']=$this->input->post("banner_type");
}
if(!empty($dataaa)){
$this->Curd->update("tb_slider",$dataaa,"id",$slider_id);
// echo $this->db->last_query();
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_slider");
}
else{
redirect(base_url()."admin/view_slider");
}
}
}
public function slider_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$slider_id = $this->input->post('slider_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_slider",array("status"=>$status),"id",$slider_id)){
echo 1;
}
}
public function delete_slider($s_id){
$data["username"]=$this->get_username();
$this->security_guard();
$slider_id = base64_decode($s_id);
$res=$this->Curd->fetch_where('tb_slider',array('id','name'),array('id'=>$slider_id));
foreach($res as $sli){
$old_img=$sli->name;
if($old_img!=""){
unlink("./uploads/slider/".$old_img);
}
}
if($this->Curd->delete("tb_slider",array("id"=>$slider_id))){
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Delete Successfully</div>');
redirect(base_url()."admin/view_slider");
}
}
/*End Slider Work*/
//for upload image data
public function do_upload_maincategory($path){
$config['upload_path'] = './uploads/main_category/';
$config['allowed_types'] = 'jpg|png|jpeg';
$config['encrypt_name'] = TRUE;
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($path))
{
$error = array('error' => $this->upload->display_errors());
return json_encode(array("error"=>true,"msg"=>$error["error"]));
}
else
{
$data = $this->upload->data();
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
return json_encode(array("error"=>false,"name"=>$data['file_name']));
}
}
/*Start Main Category*/
public function view_main_category(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['main_cat_res']=$this->Curd->all_fetcher_order("tb_main_category","DESC");
$this->load->library(array("form_validation"=>"fv"));
$this->load->view("admin/view-main-category",$data);
}
public function add_main_category($m_c_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($m_c_id!=null){
$main_cat_id = base64_decode($m_c_id);
$data['main_cat_res'] = $this->Curd->fetch_where("tb_main_category",array("*"),array("id"=>$main_cat_id));
}
$this->load->view("admin/add-main-category",$data);
}
public function main_category_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("main_cat_name","Main Category","trim|required|is_unique[tb_main_category.name]");
if($this->fv->run()==false){
$this->load->view("admin/add-main-category",$data);
}
else{
$main_cat_name=$this->input->post("main_cat_name");
$menu_types=$this->input->post("menu_types");
$img_path=array("image");
$img1=json_decode($this->do_upload_maincategory($img_path[0]),true);
if($img1['error']===true){
$pic_1_error=$img1['msg'];
}else{
$images1=$img1["name"];
}
if(empty($pic_1_error)){
$data=array("name"=>$main_cat_name,"menu_types"=>$menu_types,"image"=>$images1,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_main_category",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_main_category");
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong> Image1:'.$pic_1_error.'<br> Image2:'.$pic_2_error.'</div>');
redirect(base_url()."admin/add_main_category");
}
}
}
public function main_category_update($m_c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("main_cat_name","Main Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-main-category",$data);
}
else{
$main_cat_id = base64_decode($m_c_id);
$main_cat_name = $this->input->post("main_cat_name");
$menu_types = $this->input->post("menu_types");
$pic1=($_FILES['image']['error']);
if(isset($_FILES['image'])){
if($_FILES['image']['error']>0){
$data=array("name"=>$main_cat_name,"menu_types"=>$menu_types,"updated"=>$this->Curd->getdate());
}else{
$res = $this->Curd->fetch_where("tb_main_category",array("*"),array("id"=>$main_cat_id));
$img_path=array("image");
$img1=json_decode($this->do_upload_maincategory($img_path[0]),true);
if($img1['error']===true){
$pic_1_error=$img1['msg'];
}else{
$images1=$img1["name"];
}
if($res[0]->img_1!=""){
unlink("./uploads/main_category/".$res[0]->image);
}
$data=array("name"=>$main_cat_name,"menu_types"=>$menu_types,"image"=>$images1,"updated"=>$this->Curd->getdate());
}
$this->Curd->update("tb_main_category",$data,"id",$main_cat_id);
// echo $this->db->last_query();
}
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_main_category");
}
}
public function main_category_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$main_cat_id = $this->input->post('mc_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_main_category",array("status"=>$status),"id",$main_cat_id)){
echo 1;
}
}
public function delete_main_category($m_c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$main_cat_id = base64_decode($m_c_id);
if($this->Curd->delete("tb_main_category",array("id"=>$main_cat_id))){
redirect(base_url()."admin/view_main_category");
}
}
function settings(){
if($this->Curd->update("settings",array("cod_amt"=>$this->input->post('cod_amt'),"shipping_amt"=>$this->input->post('shipping_amt')),"id",'1')){
redirect(base_url()."admin/setting");
}
}
/*End Main Category*/
/*Start home page Popup*/
public function view_popup(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['popup_res']=$this->Curd->all_fetcher_order("tb_popup","DESC");
$this->load->view("admin/view-popup",$data);
}
public function add_popup($s_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($s_id!=null){
$slider_id = base64_decode($s_id);
$data['popup_res'] = $this->Curd->fetch_where("tb_popup",array("*"),array("id"=>$slider_id));
}
$this->load->view("admin/add-popup",$data);
}
public function popup_process(){
$config['upload_path'] = './uploads/popup';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 20000; //KB
$config['max_width'] = 1200;
$config['max_height'] = 1200;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if($_FILES["slider_img"]['error']==0){
if(!file_exists('uploads/popup/'.$_FILES["slider_img"]["name"])){
if ( ! $this->upload->do_upload('slider_img'))
{
$data = array('error' => $this->upload->display_errors());
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->view('admin/add-popup', $data);
}else{
$data = array('success_msg' =>'Image Upload successfully done','error' => ' ');
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$url = $this->input->post("url");
if($this->Curd->insert("tb_popup",array("name"=>$this->upload->data("file_name"),"url"=>$url,"status"=>1))){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_popup");
}
}
}else{
$data=array('error' => 'File Already Exist');
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->view('admin/add-popup',$data);
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Error ! </strong>Choose Your Slider Image</div>');
redirect(base_url()."admin/add_popup");
}
}
public function popup_update($s_id){
$config['upload_path'] = './uploads/popup';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 2000; //KB
$config['max_width'] = 1700;
$config['max_height'] = 600;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
$url = $this->input->post("url");
$slider_id = base64_decode($s_id);
if($_FILES["slider_img"]['error']==0){
if(!file_exists('uploads/popup/'.$_FILES["slider_img"]["name"])){
if ( ! $this->upload->do_upload('slider_img'))
{
$data = array('error' => $this->upload->display_errors());
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($this->Curd->update("tb_popup",array("url"=>$url),"id",$slider_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_popup");
}
//$this->load->view('admin/add-banner', $data);
}else{
$data = array('success_msg' =>'Image Upload successfully done','error' => ' ');
$data['edit_slider']=$this->Curd->fetch_where('tb_popup',array('id','name'),array('id'=>$slider_id));
foreach($data['edit_slider'] as $sli){
$old_img=$sli->name;
if($old_img!=""){
unlink("./uploads/popup/".$old_img);
}
}
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($this->Curd->update("tb_popup",array("name"=>$this->upload->data("file_name"),"url"=>$url),"id",$slider_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_popup");
}
}
}else{
$data=array('error' => 'File Already Exist');
$data['username']=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->view('admin/add-popup',$data);
}
}else{
if($this->Curd->update("tb_popup",array("url"=>$url),"id",$slider_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_popup");
}
}
}
public function popup_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$slider_id = $this->input->post('slider_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_popup",array("status"=>$status),"id",$slider_id)){
echo 1;
}
}
public function delete_popup($s_id){
$data["username"]=$this->get_username();
$this->security_guard();
$slider_id = base64_decode($s_id);
$old_img = $this->Curd->fetch_where("tb_popup",array("*"),array("id"=>$slider_id));
if($old_img==true){
unlink("./uploads/popup/".$old_img[0]->name);
}
if($this->Curd->delete("tb_popup",array("id"=>$slider_id))){
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Delete Successfully</div>');
redirect(base_url()."admin/view_popup");
}
}
/* End Popup Home Page*/
/*Start Header Offer Code*/
public function view_offer(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['offer_res'] = $this->Curd->all_fetcher_order("tb_offer","DESC");
$this->load->view("admin/view-offer",$data);
}
public function add_offer($o_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($o_id!=null){
$o_id = base64_decode($o_id);
$data['offer_res'] = $this->Curd->fetch_where("tb_offer",array("*"),array("id"=>$o_id));
}
$this->load->view("admin/add-offer",$data);
}
public function offer_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("title","Title","trim|required|is_unique[tb_offer.title]");
if($this->fv->run()==false){
$this->load->view("admin/add-offer",$data);
}
else{
$title=$this->input->post("title");
$desc=$this->input->post("desc");
$url =str_replace(' ', '-', $title);
$data=array(
"title"=>$title,
"description"=>$desc,
"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_offer",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_offer");
}
}
}
public function offer_update($b_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("title","Title","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-offer",$data);
}
else{
$offer_id = base64_decode($b_id);
$title=$this->input->post("title");
$desc=$this->input->post("desc");
$url =str_replace(' ', '-', $title);
$data=array(
"title"=>$title,
"description"=>$desc,
"status"=>1,
"updated"=>$this->Curd->getdate());
if($this->Curd->update("tb_offer",$data,"id",$offer_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_offer");
}
}
}
public function offer_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$blog_id = $this->input->post('offer_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_offer",array("status"=>$status),"id",$blog_id)){
echo 1;
}
}
public function delete_offer($b_id){
$data["username"]=$this->get_username();
$this->security_guard();
$blog_id = base64_decode($b_id);
if($this->Curd->delete("tb_offer",array("id"=>$blog_id))){
redirect(base_url()."admin/view_offer");
}
}
/*End Header Offer Code*/
public function edit_pages(){
$data["username"]=$this->get_username();
$this->security_guard();
$page_id = $this->uri->segment('3');
$data['blog_res'] = $this->Curd->fetch_where("pages",array("*"),array("id"=>$page_id));
$this->load->view("admin/edit-pages",$data);
}
/*start Blogs*/
public function view_blog(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['blog_res'] = $this->Curd->all_fetcher_order("tb_blog","DESC");
$this->load->view("admin/view-blog",$data);
}
public function add_blog($b_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($b_id!=null){
$blog_id = base64_decode($b_id);
$data['blog_res'] = $this->Curd->fetch_where("tb_blog",array("*"),array("id"=>$blog_id));
}
$this->load->view("admin/add-blog",$data);
}
public function blog_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("b_title","Title","trim|required|is_unique[tb_blog.title]");
if($this->fv->run()==false){
$this->load->view("admin/add-blog",$data);
}
else{
$b_title=$this->input->post("b_title");
$b_desc=$this->input->post("b_desc");
$meta_title=$this->input->post("meta_title");
$meta_desc=$this->input->post("meta_desc");
$meta_keyword=$this->input->post("meta_keyword");
$url =str_replace(' ', '-', $b_title);
$data=array(
"title"=>$b_title,
"url"=>strtolower($url),
"description"=>$b_desc,
"status"=>1,
"meta_title"=>$meta_title,
"meta_desc"=>$meta_desc,
"meta_keyword"=>$meta_keyword,
"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_blog",$data)){
$last_id=$this->last_id();
$chk = $this->upload_blog_image($_FILES['blogfile'],$last_id);
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Success ! </strong>Insert Successfully'.$chk.'</div>');
redirect(base_url()."admin/add_blog");
}
}
}
public function upload_blog_image($filename,$blog_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->library('upload');
$_FILES['blogfile'] = $filename;
if(isset($_FILES['blogfile']) && $_FILES['blogfile']['error'][0]==0){
$count = count($_FILES['blogfile']['name']);
$files = $_FILES;
for($i=0; $i<$count; $i++):
$_FILES['blogfile']['name']= $files['blogfile']['name'][$i];
$_FILES['blogfile']['type']= $files['blogfile']['type'][$i];
$_FILES['blogfile']['tmp_name']= $files['blogfile']['tmp_name'][$i];
$_FILES['blogfile']['error']= $files['blogfile']['error'][$i];
$_FILES['blogfile']['size']= $files['blogfile']['size'][$i];
$fileName = time()."_".$i.$this->get_ext($_FILES["blogfile"]["name"]);
$config['upload_path'] = './assets/uploads/blog/'; //path folder
$config['allowed_types'] = 'gif|jpg|png|jpeg|bmp';
$config['file_name'] = $fileName;
$this->upload->initialize($config);
if($this->upload->do_upload("blogfile")){
if($this ->Curd->update('tb_blog',array('image' => $fileName),'id' , $blog_id)){
$gbr = $this->upload->data();
echo $this->_create_thumbs_blog($gbr['file_name']);
}
}else{
echo $this->upload->display_errors();
}
endfor;
}else{
echo "Image is empty or type of Image not allowed";
}
}
function _create_thumbs_blog($file_name){
// Image resizing config
$config = array(
// Large Image
array(
'image_library' => 'GD2',
'source_image' => './assets/uploads/blog/'.$file_name,
'maintain_ratio'=> FALSE,
'width' => 480,
'height' => 855,
'new_image' => './assets/uploads/blog/medium/'.$file_name
),
);
$this->load->library('image_lib', $config[0]);
foreach ($config as $item){
$this->image_lib->initialize($item);
if(!$this->image_lib->resize()){
return false;
}
$this->image_lib->clear();
}
}
public function page_update(){
$data["username"]=$this->get_username();
$this->security_guard();
$page_id = $this->input->post("page_id");
$b_title=$this->input->post("b_title");
$b_desc=$this->input->post("page_content");
$data=array(
"page_name"=>$b_title,
"page_content"=>$b_desc);
if($this->Curd->update(" pages",$data,"id",$page_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Update Successfully'.$chk.'</div>');
redirect(base_url()."admin/view_pages");
}
}
public function blog_update($b_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("b_title","Title","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-blog",$data);
}
else{
$blog_id = base64_decode($b_id);
$b_title=$this->input->post("b_title");
$b_desc=$this->input->post("b_desc");
$meta_title=$this->input->post("meta_title");
$meta_desc=$this->input->post("meta_desc");
$meta_keyword=$this->input->post("meta_keyword");
$url =str_replace(' ', '-', $b_title);
$data=array(
"title"=>$b_title,
"url"=>strtolower($url),
"description"=>$b_desc,
"status"=>1,
"meta_title"=>$meta_title,
"meta_desc"=>$meta_desc,
"meta_keyword"=>$meta_keyword,
"created"=>$this->Curd->getdate());
if($this->Curd->update("tb_blog",$data,"id",$blog_id)){
if($_FILES['blogfile']['error'][0]==0){
$gallery = $this->Curd->fetch_where("tb_blog",array("image"),array("id"=>$blog_id));
if(isset($gallery)):
foreach($gallery as $g_row){
$image = $g_row->image;
if($image!=""){
unlink("./assets/uploads/blog/".$image);
unlink("./assets/uploads/blog/medium/".$image);
}
}
endif;
$chk = $this->upload_blog_image($_FILES['blogfile'],$blog_id);
}
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Update Successfully'.$chk.'</div>');
redirect(base_url()."admin/view_blog");
}
}
}
public function blog_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$blog_id = $this->input->post('blog_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_blog",array("status"=>$status),"id",$blog_id)){
echo 1;
}
}
public function delete_blog($b_id){
$data["username"]=$this->get_username();
$this->security_guard();
$blog_id = base64_decode($b_id);
if($this->Curd->delete("tb_blog",array("id"=>$blog_id))){
redirect(base_url()."admin/view_blog");
}
}
/*Start Deals of Months*/
public function view_deals_category(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['deal_cat_res']=$this->Curd->all_fetcher_order("tb_deals_of_month","DESC");
$this->load->library(array("form_validation"=>"fv"));
$this->load->view("admin/view-deals-category",$data);
}
public function add_deals_category($m_c_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['main_cat_res'] = $this->Curd->fetch_where("tb_main_category",array("*"),array("status"=>1));
if($m_c_id!=null){
$deal_cat_id = base64_decode($m_c_id);
$data['deal_cat_res'] = $this->Curd->fetch_where("tb_deals_of_month",array("*"),array("id"=>$deal_cat_id));
}
$this->load->view("admin/add-deals-category",$data);
}
public function deals_category_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("main_cat_id","Main Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-deals-category",$data);
}
else{
$main_cat_id=$this->input->post("main_cat_id");
$img_path=array("image");
$img1=json_decode($this->do_upload_maincategory($img_path[0]),true);
if($img1['error']===true){
$pic_1_error=$img1['msg'];
}else{
$images1=$img1["name"];
}
if(empty($pic_1_error)){
$data=array("main_cat_id"=>$main_cat_id,"image"=>$images1,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_deals_of_month",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_deals_category");
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong> Image1:'.$pic_1_error.'<br> Image2:'.$pic_2_error.'</div>');
redirect(base_url()."admin/add_deals_category");
}
}
}
public function deals_category_update($d_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("main_cat_id","Main Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-deals-category",$data);
}
else{
$deals_id = base64_decode($d_id);
$main_cat_id = $this->input->post("main_cat_id");
$pic1=($_FILES['image']['error']);
if(isset($_FILES['image'])){
if($_FILES['image']['error']>0){
$data=array("main_cat_id"=>$main_cat_id,"updated"=>$this->Curd->getdate());
}else{
$res = $this->Curd->fetch_where("tb_deals_of_month",array("*"),array("id"=>$deals_id));
$img_path=array("image");
$img1=json_decode($this->do_upload_maincategory($img_path[0]),true);
if($img1['error']===true){
$pic_1_error=$img1['msg'];
}else{
$images1=$img1["name"];
}
if($res[0]->image!=""){
unlink("./uploads/main_category/".$res[0]->image);
}
$data=array("main_cat_id"=>$main_cat_id,"image"=>$images1,"updated"=>$this->Curd->getdate());
}
$this->Curd->update("tb_deals_of_month",$data,"id",$deals_id);
}
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_deals_category");
}
}
public function deals_category_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$d_id_for_status = $this->input->post('d_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_deals_of_month",array("status"=>$status),"id",$d_id_for_status)){
echo 1;
}
}
public function delete_deals_category($m_c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$main_cat_id = base64_decode($m_c_id);
if($this->Curd->delete("tb_deals_of_month",array("id"=>$main_cat_id))){
redirect(base_url()."admin/view_deals_category");
}
}
/*End Main Category*/
/*Start Category*/
public function add_sub_category(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->view("admin/add_sub_category",$data);
}
public function view_category(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['cat_res'] = $this->Curd->innerJoinCategory("tb_category","tb_main_category");
$this->load->view("admin/view-category",$data);
}
public function add_category($c_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['main_cat_res'] = $this->Curd->fetch_where("tb_main_category",array("*"),array("status"=>1));
if($c_id!=null){
$cat_id = base64_decode($c_id);
$data['cat_res'] = $this->Curd->fetch_where("tb_category",array("*"),array("id"=>$cat_id));
}
$this->load->view("admin/add-category",$data);
}
public function insert_sub_category(){
$data["username"]=$this->get_username();
$this->security_guard();
$category_id=$this->input->post("category_id");
$cat_name=$this->input->post("sub_cat_name");
$main_category_name=$this->input->post("main_category_id");
$res = $this->Curd->fetch_where("tb_sub_category",array("id"),array("name"=>$cat_name,"category_id"=>$category_id));
if($res==false){
$data1['name'] =$cat_name;
$data1['category_id'] =$category_id;
$data1['status'] ="1";
$data1['created'] =$this->Curd->getdate();
// $data=array("name"=>$cat_name,"main_cat_id"=>$main_cat_id,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_sub_category",$data1)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/add_sub_category/".base64_encode($category_id)."/".$main_category_name);
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error ! </strong>Already Exist</div>');
redirect(base_url()."admin/add_sub_category/".base64_encode($category_id)."/".$main_category_name);
}
}
public function update_sub_category(){
$data["username"]=$this->get_username();
$this->security_guard();
$cat_id=$this->uri->segment("3");
$category_id=$this->input->post("category_id");
$cat_name=$this->input->post("sub_cat_name");
$main_category_name=$this->input->post("main_category_id");
$res = $this->Curd->fetch_where("tb_sub_category",array("id"),array("id"=>$cat_id));
// echo $this->db->last_Query();
if($res==false){
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error ! </strong>Some Error</div>');
// echo "Error";
redirect(base_url()."admin/add_sub_category/".base64_encode($category_id)."/".$main_category_name);
}else{
$data1['name'] =$cat_name;
$data1['status'] ="1";
$data1['created'] =$this->Curd->getdate();
// $data=array("name"=>$cat_name,"main_cat_id"=>$main_cat_id,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->update("tb_sub_category",$data1,"id",$cat_id)){
// echo $this->db->last_Query();
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/add_sub_category/".base64_encode($category_id)."/".$main_category_name);
}
}
}
public function category_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['main_cat_res'] = $this->Curd->fetch_where("tb_main_category",array("*"),array("status"=>1));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("main_cat_id","Select Main Category","trim|required");
$this->fv->set_rules("cat_name","Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-category",$data);
}
else{
$main_cat_id=$this->input->post("main_cat_id");
$cat_name=$this->input->post("cat_name");
$res = $this->Curd->fetch_where("tb_category",array("id"),array("name"=>$cat_name,"main_cat_id"=>$main_cat_id));
if($res==false){
$comp_logo = $_FILES["photo"]["name"];
if($comp_logo){
if($vf = $this->upload_category_image($comp_logo,'sub_category/','photo')){
$data1['photos'] =$vf;
}
}
$data1['name'] =$cat_name;
$data1['main_cat_id'] =$main_cat_id;
$data1['status'] ="1";
$data1['created'] =$this->Curd->getdate();
// $data=array("name"=>$cat_name,"main_cat_id"=>$main_cat_id,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_category",$data1)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_category");
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error ! </strong>Already Exist</div>');
redirect(base_url()."admin/add_category");
}
}
}
public function category_update($c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("cat_name","Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-category",$data);
}
else{
$cat_id = base64_decode($c_id);
$cat_name = $this->input->post("cat_name");
$main_cat_id = $this->input->post("main_cat_id");
$comp_logo = $_FILES["photo"]["name"];
if($comp_logo){
if($vf = $this->upload_category_image($comp_logo,'sub_category/','photo')){
$data1['photos'] =$vf;
}
}
$data1['name'] =$cat_name;
$data1['main_cat_id'] =$main_cat_id;
$data1['updated'] =$this->Curd->getdate();
// print_r($data1);
if($this->Curd->update("tb_category",$data1,"id",$cat_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
// echo "Done";
redirect(base_url()."admin/view_category");
}else{
// echo "Eror";
}
}
}
function upload_category_image($comp_logo,$folder,$field_name){
$ext = end((explode(".", $comp_logo)));
$edt = "brand_".time();
$vf = $edt.".".$ext;
$ex = ".".$ext;
$config['upload_path'] = './uploads/'.$folder;
$config['allowed_types'] = 'gif|jpg|png|jpeg|bmp';
$config['max_size'] = '9999999';
$config['overwrite'] = 'true';
$config['file_name'] = $vf;
$config['type'] = $ex;
$config['max_width'] = '10240';
$config['max_height'] = '7680';
$this->load->library('upload', $config);
$result = $this->upload->do_upload($field_name);
print_r($this->upload->display_errors());
if (!$result) { }else{
return $vf;
}
}
public function sub_category_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$cat_id = $this->input->post('c_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_sub_category",array("status"=>$status),"id",$cat_id)){
echo 1;
}
}
public function category_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$cat_id = $this->input->post('c_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_category",array("status"=>$status),"id",$cat_id)){
echo 1;
}
}
public function delete_product(){
$data["username"]=$this->get_username();
$this->security_guard();
$pro_id = base64_decode($this->uri->segment('3'));
if($this->Curd->delete("tb_product",array("id"=>$pro_id))){
$this->Curd->delete("tb_product_price",array("product_id"=>$pro_id));
redirect(base_url()."admin/view_product");
}
}
public function delete_sub_category($c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$cat_id = base64_decode($c_id);
if($this->Curd->delete("tb_sub_category",array("id"=>$cat_id))){
redirect($_SERVER['HTTP_REFERER']);
}
}
public function delete_category($c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$cat_id = base64_decode($c_id);
if($this->Curd->delete("tb_category",array("id"=>$cat_id))){
redirect(base_url()."admin/view_category");
}
}
/*End Category*/
/*Start Subcategory*/
public function view_subcategory(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['subcat_res'] = $this->Curd->innerJoinSubcategory("tb_subcategory","tb_category","tb_main_category");
$this->load->view("admin/view-subcategory",$data);
}
public function add_subcategory($sc_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['main_cat_res'] = $this->Curd->fetch_where("tb_main_category",array("*"),array("status"=>1));
$data['cat_res'] = $this->Curd->fetch_where("tb_category",array("*"),array("status"=>1));
if($sc_id!=null){
$subcat_id = base64_decode($sc_id);
$data['subcat_res'] = $this->Curd->fetch_where("tb_subcategory",array("*"),array("id"=>$subcat_id));
}
$this->load->view("admin/add-subcategory",$data);
}
public function get_cat_ajax(){
$id = $this->input->post("main_cat_id");
$data = $this->Curd->fetch_where_order("tb_category", array('id','name'), array('main_cat_id'=>$id), "desc");
$option = [];
if($data==true){
foreach ($data as $row) {
@$option.= "<option value='".$row->id."'>$row->name</option>";
}
}else{
$option = "<option value='0'>No Category</option>";
}
print_r($option);
}
public function get_sub_cat_ajax(){
$id = $this->input->post("cat_id");
$data = $this->Curd->fetch_where_order("tb_sub_category", array('id','name'), array('category_id'=>$id), "desc");
$option = [];
if($data==true){
foreach ($data as $row) {
@$option.= "<option value='".$row->id."'>$row->name</option>";
}
}else{
$option = "<option value='0'>No Category</option>";
}
print_r($option);
}
public function subcategory_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['cat_res'] = $this->Curd->fetch_where("tb_category",array("*"),array("status"=>1));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("maincat_id","Select Main Category","trim|required");
$this->fv->set_rules("cat_id","Select Category","trim|required");
$this->fv->set_rules("subcat_name","Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-subcategory",$data);
}
else{
$main_cat_id = $this->input->post("maincat_id");
$cat_id=$this->input->post("cat_id");
$subcat_name=$this->input->post("subcat_name");
$data=array("name"=>$subcat_name,"cat_id"=>$cat_id,"main_cat_id"=>$main_cat_id,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_subcategory",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_subcategory");
}
}
}
public function subcategory_update($sc_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("maincat_id","Main Category","trim|required");
$this->fv->set_rules("cat_id","Category","trim|required");
$this->fv->set_rules("subcat_name","Sub Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-subcategory",$data);
}
else{
$subcat_id = base64_decode($sc_id);
$subcat_name = $this->input->post("subcat_name");
$main_cat_id = $this->input->post("maincat_id");
$cat_id = $this->input->post("cat_id");
$data=array("name"=>$subcat_name,"cat_id"=>$cat_id,"main_cat_id"=>$main_cat_id,"updated"=>$this->Curd->getdate());
if($this->Curd->update("tb_subcategory",$data,"id",$subcat_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_subcategory");
}
}
}
public function subcategory_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$subcat_id = $this->input->post('sc_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_subcategory",array("status"=>$status),"id",$subcat_id)){
echo 1;
}
}
public function delete_subcategory($c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$cat_id = base64_decode($c_id);
if($this->Curd->delete("tb_subcategory",array("id"=>$cat_id))){
redirect(base_url()."admin/view_subcategory");
}
}
/*End Subcategory*/
/*Product Work*/
public function view_product(){
$data["username"]=$this->get_username();
$this->security_guard();
$idd = $_SESSION["id"];
$data['product_res'] = $this->Curd->get_query("select * from tb_product where v_id=$idd");
$this->load->view("admin/view-product",$data);
}
public function add_product($pro_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['main_cat_res'] = $this->Curd->fetch_where("tb_main_category",array("*"),array("status"=>1));
$data['cat_res'] = $this->Curd->fetch_where("tb_category",array("*"),array("status"=>1));
if($pro_id!=null){
$product_id = base64_decode($pro_id);
$data['product_res'] = $this->Curd->fetch_where("tb_product",array("*"),array("id"=>$product_id));
$data['gallery_res'] = $this->Curd->fetch_where("tb_gallery",array("name"),array("product_id"=>$product_id));
}
$this->load->view("admin/add-product",$data);
}
private function last_id(){
$insert_id = $this->db->insert_id();
return $insert_id;
}
/*start weight work*/
public function view_weight(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['weight_res']=$this->Curd->all_fetcher_order("tb_weight","DESC");
$this->load->library(array("form_validation"=>"fv"));
$this->load->view("admin/view-weight",$data);
}
public function add_weight($s_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($s_id!=null){
$weight_id = base64_decode($s_id);
$data['weight_res'] = $this->Curd->fetch_where("tb_weight",array("*"),array("id"=>$weight_id));
}
$this->load->view("admin/add-weight",$data);
}
public function weight_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("weight_name","Weight","trim|required|is_unique[tb_weight.name]");
if($this->fv->run()==false){
$this->load->view("admin/add-weight",$data);
}
else{
$weight_name=$this->input->post("weight_name");
$data=array("name"=>$weight_name,"status"=>1);
if($this->Curd->insert("tb_weight",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/add_weight");
}
}
}
public function weight_update($w_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("weight_name","Size Name","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-weight",$data);
}
else{
$weight_id = base64_decode($w_id);
$weight_name = $this->input->post("weight_name");
$data=array("name"=>$weight_name);
if($this->Curd->update("tb_weight",$data,"id",$weight_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_weight");
}
}
}
public function delete_weight($w_id){
$data["username"]=$this->get_username();
$this->security_guard();
$weight_id = base64_decode($w_id);
if($this->Curd->delete("tb_weight",array("id"=>$weight_id))){
redirect(base_url()."admin/view_weight");
}
}
/*end size wrok*/
/*start Color work*/
public function view_color(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['weight_res']=$this->Curd->all_fetcher_order("tb_colors","DESC");
$this->load->library(array("form_validation"=>"fv"));
$this->load->view("admin/view-color",$data);
}
public function add_color($s_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($s_id!=null){
$weight_id = base64_decode($s_id);
$data['weight_res'] = $this->Curd->fetch_where("tb_colors",array("*"),array("id"=>$weight_id));
}
$this->load->view("admin/add-color",$data);
}
public function color_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("weight_name","Weight","trim|required|is_unique[tb_weight.name]");
if($this->fv->run()==false){
$this->load->view("admin/add-color",$data);
}
else{
$weight_name=$this->input->post("weight_name");
$data=array("name"=>$weight_name,"status"=>1);
if($this->Curd->insert("tb_colors",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/add_color");
}
}
}
public function color_update($w_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("weight_name","Size Name","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-color",$data);
}
else{
$weight_id = base64_decode($w_id);
$weight_name = $this->input->post("weight_name");
$data=array("name"=>$weight_name);
if($this->Curd->update("tb_colors",$data,"id",$weight_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_color");
}
}
}
public function delete_color($w_id){
$data["username"]=$this->get_username();
$this->security_guard();
$weight_id = base64_decode($w_id);
if($this->Curd->delete("tb_colors",array("id"=>$weight_id))){
redirect(base_url()."admin/view_color");
}
}
public function delete_order_details(){
$data["username"]=$this->get_username();
$this->security_guard();
$ref_page =$_SERVER['HTTP_REFERER'];
$order_id = base64_decode($this->uri->segment('3'));
if($this->Curd->delete("tb_order",array("order_no"=>$order_id))){
$this->Curd->delete("tb_sub_order",array("order_no"=>$order_id));
// $res = $this->Curd->fetch_where("tb_sub_order",array("*"),array("order_no"=>$row->order_no));
redirect($ref_page);
}
}
/*end size wrok*/
/*Product Weight*/
public function view_product_weight($id){
$data["username"]=$this->get_username();
$this->security_guard();
$data['product_id'] = base64_decode($id);
$this->load->view('admin/view-product-weight',$data);
}
public function product_weight_process(){
$product_id = $this->input->post("product_id");
$weight = $this->input->post("weight");
$price = $this->input->post("price");
$reg_discount = $this->input->post("reg_discount");
$reg_sale_price = $this->input->post("reg_sale_price");
$qty = $this->input->post("qty");
$this->Curd->delete("tb_product_price",array("product_id"=>$product_id));
for($i=0;$i<count($weight);$i++){
$this->Curd->insert("tb_product_price",array("product_id"=>$product_id,"weight"=>$weight[$i],"price"=>$price[$i],"reg_discount"=>$reg_discount[$i],"reg_sale_price"=>$reg_sale_price[$i],"qty"=>$qty[$i],"status"=>1));
}
echo 1;
}
/*Product Weight*/
public function product_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['cat_res'] = $this->Curd->fetch_where("tb_category",array("*"),array("status"=>1));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("p_title","Title","trim|required");
// $this->fv->set_rules("p_cat","Select Category","trim|required");
// $this->fv->set_rules("p_sku","SKU","trim|required|is_unique[tb_product.sku]");
if($this->fv->run()==false){
$this->load->view("admin/add-product",$data);
}
else{
$p_title=$this->input->post("p_title");
$maincat_id = $this->input->post("p_maincat");
$cat_id=$this->input->post("p_cat");
$pack_type=$this->input->post("p_pack_type");
$origin=$this->input->post("p_origin");
$sku = $this->input->post("p_sku");
$desc=$this->input->post("p_desc");
$meta_title = $this->input->post('meta_title');
$meta_keyword = $this->input->post('meta_keyword');
$meta_desc = $this->input->post('meta_desc');
$comp_logo = $_FILES["size_chart"]["name"];
$vf=NULL;
if($comp_logo){
if($vf = $this->banner_img($comp_logo,'size_chart/','size_chart')){ }
}
$data=array("title"=>$p_title,
"main_cat_id"=>$maincat_id,
"cat_id"=>$cat_id,"size_chart"=>$vf,
"v_id"=>$_SESSION["id"],
"sku"=>$sku,
"description" =>$desc,
"pack_type"=>$pack_type,
"origin"=>$origin,
"meta_title"=>$meta_title,
"meta_keyword"=>$meta_keyword,
"pro_short"=>$this->input->post('pro_short'),
"featured_product"=>$this->input->post('featured_product'),
"exclusive_product"=>$this->input->post('exclusive_product'),
"tax_per"=>$this->input->post('tax_per'),
"hsn_no"=>$this->input->post('hsn_no'),
"video_link"=>$this->input->post('video_link'),
"meta_desc"=>$meta_desc,"color_list"=>json_encode($this->input->post('color_list')),
"status"=>1,
"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_product",$data)){
$last_id=$this->last_id();
$this->upload_image($_FILES['productfile'],$last_id);
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_product");
}
}
}
function banner_img($comp_logo,$folder,$field_name){
$ext = end((explode(".", $comp_logo)));
$edt = "comp_".time();
$vf = $edt.".".$ext;
$ex = ".".$ext;
$config['upload_path'] = './'.$folder;
$config['allowed_types'] = '*';
$config['max_size'] = '9999999';
$config['overwrite'] = 'true';
$config['file_name'] = $vf;
$config['type'] = $ex;
$config['max_width'] = '10240';
$config['max_height'] = '7680';
$this->load->library('upload', $config);
$result = $this->upload->do_upload($field_name);
// print_r($this->upload->display_errors());
if (!$result) { }else{
return $vf;
}
}
//Product Update Process
public function product_update($p_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['cat_res'] = $this->Curd->fetch_where("tb_category",array("*"),array("status"=>1));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("p_title","Title","trim|required");
// $this->fv->set_rules("p_cat","Select Category","trim|required");
// $this->fv->set_rules("p_sku","SKU","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-product",$data);
}
else{
$product_id = base64_decode($p_id);
$p_title=$this->input->post("p_title");
$maincat_id = $this->input->post("p_maincat");
$cat_id=$this->input->post("p_cat");
$sub_cat_id=$this->input->post("sub_cat");
$sku=$this->input->post("p_sku");
$pack_type=$this->input->post("p_pack_type");
$origin=$this->input->post("p_origin");
$desc=$this->input->post("p_desc");
$meta_title = $this->input->post('meta_title');
$meta_keyword = $this->input->post('meta_keyword');
$meta_desc = $this->input->post('meta_desc');
$comp_logo = $_FILES["size_chart"]["name"];
$vf=NULL;
if($comp_logo){
if($vf = $this->banner_img($comp_logo,'size_chart/','size_chart')){ }
}
$data=array("title"=>$p_title,
"main_cat_id"=>$maincat_id,
"size_chart"=>$vf,
"cat_id"=>$cat_id,
"sub_cat"=>$sub_cat_id,
"sku"=>$sku,
"description" =>$desc,
"pack_type"=>$pack_type,
"origin"=>$origin,
"meta_title"=>$meta_title,
"featured_product"=>$this->input->post('featured_product'),
"exclusive_product"=>$this->input->post('exclusive_product'),
"pro_short"=>$this->input->post('pro_short'),
"tax_per"=>$this->input->post('tax_per'),
"hsn_no"=>$this->input->post('hsn_no'),
"video_link"=>$this->input->post('video_link'),
"color_list"=>json_encode($this->input->post('color_list')),
"meta_keyword"=>$meta_keyword,
"meta_desc"=>$meta_desc,
"updated"=>$this->Curd->getdate());
if($this->Curd->update("tb_product",$data,"id",$product_id)){
if($_FILES['productfile']['error'][0]==0){
$gallery = $this->Curd->fetch_where("tb_gallery",array("name"),array("product_id"=>$product_id));
if(isset($gallery) && $gallery==true):
foreach($gallery as $g_row){
$name = $g_row->name;
if($name!=""){
unlink("./uploads/gallery/".$name);
unlink("./uploads/gallery/small/".$name);
unlink("./uploads/gallery/medium/".$name);
}
}
endif;
if($this->Curd->delete("tb_gallery",array("product_id"=>$product_id))){
$this->upload_image($_FILES['productfile'],$product_id);
}
}
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_product");
}
}
}
public function upload_image($filename,$pro_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->load->library('upload');
$_FILES['productfile'] = $filename;
if(isset($_FILES['productfile']) && $_FILES['productfile']['error'][0]==0){
$count = count($_FILES['productfile']['name']);
$files = $_FILES;
for($i=0; $i<$count; $i++):
$_FILES['productfile']['name']= $files['productfile']['name'][$i];
$_FILES['productfile']['type']= $files['productfile']['type'][$i];
$_FILES['productfile']['tmp_name']= $files['productfile']['tmp_name'][$i];
$_FILES['productfile']['error']= $files['productfile']['error'][$i];
$_FILES['productfile']['size']= $files['productfile']['size'][$i];
$fileName = time()."_".$i.$this->get_ext($_FILES["productfile"]["name"]);
$config['upload_path'] = './uploads/gallery/'; //path folder
$config['allowed_types'] = 'gif|jpg|png|jpeg|bmp';
$config['file_name'] = $fileName;
$this->upload->initialize($config);
if($this->upload->do_upload("productfile")){
if($this ->Curd->insert('tb_gallery',array('product_id' => $pro_id,'name' => $fileName))){
$gbr = $this->upload->data();
$this->_create_thumbs($gbr['file_name']);
}
}else{
echo $this->upload->display_errors();
}
endfor;
}else{
echo "Image is empty or type of Image not allowed";
}
}
private function get_ext($name){
$extension = ".".pathinfo($name, PATHINFO_EXTENSION);
return $extension;
}
function _create_thumbs($file_name){
// Image resizing config
$config = array(
// Large Image
array(
'image_library' => 'GD2',
'source_image' => './uploads/gallery/'.$file_name,
'maintain_ratio'=> FALSE,
'width' => 1080,
'height' => 1350,
'new_image' => './uploads/gallery/large/'.$file_name
),
// Medium Image
array(
'image_library' => 'GD2',
'source_image' => './uploads/gallery/'.$file_name,
'maintain_ratio'=> FALSE,
'width' => 320,
'height' => 400,
'new_image' => './uploads/gallery/medium/'.$file_name
),
// Small Image
array(
'image_library' => 'GD2',
'source_image' => './uploads/gallery/'.$file_name,
'maintain_ratio'=> FALSE,
'width' => 64,
'height' => 80,
'new_image' => './uploads/gallery/small/'.$file_name
));
$this->load->library('image_lib', $config[0]);
foreach ($config as $item){
$this->image_lib->initialize($item);
if(!$this->image_lib->resize()){
return false;
}
$this->image_lib->clear();
}
}
/*End Product Work*/
public function product_review_status(){
$data["username"]=$this->get_username();
$this->security_guard();
$review_id = $this->input->post('product_id_for_status');
$status = $this->input->post('status');
$review= $this->input->post('review');
$product_id= $this->input->post('product_id');
if($this->Curd->update("rating_review",array("is_active"=>$status),"id",$review_id)){
$cc="";
if($review==1){ $cc=", total_s1 = total_s1+1"; }
else if($review==2){ $cc=", total_s2 = total_s2+1"; }
else if($review==3){ $cc=", total_s3 = total_s3+1"; }
else if($review==4){ $cc=", total_s4 = total_s4+1"; }
else if($review==5){ $cc=", total_s5 = total_s5+1"; }
$qer="UPDATE `tb_product` SET `total_cnt` = total_cnt+1 $cc WHERE `id` = $product_id;";
$this->db->query($qer);
echo 1;
}
}
public function product_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$product_id = $this->input->post('product_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_product",array("status"=>$status),"id",$product_id)){
echo 1;
}
}
public function featured_product_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$product_id = $this->input->post('product_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_product",array("featured_product"=>$status),"id",$product_id)){
echo 1;
}
}
/*Start coupon work*/
public function view_coupon(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['coupon_res'] = $this->Curd->all_fetcher_order("tb_coupon","DESC");
$this->load->view("admin/view-coupon",$data);
}
public function add_coupon($c_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($c_id!=null){
$cat_id = base64_decode($c_id);
$data['coupon_res'] = $this->Curd->fetch_where("tb_coupon",array("*"),array("id"=>$cat_id));
}
$this->load->view("admin/add-coupon",$data);
}
public function coupon_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("coupon_type","Select Main Category","trim|required");
$this->fv->set_rules("discount_type","Category","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-category",$data);
}
else{
$coupon_type=$this->input->post("coupon_type");
$discount_type=$this->input->post("discount_type");
$discount=$this->input->post("discount");
$promo_code=$this->input->post("promo_code");
$min_value = $this->input->post("min_value");
$start_date=$this->input->post("start_date");
$expire_date=$this->input->post("expire_date");
$res = $this->Curd->fetch_where("tb_coupon",array("id"),array("promo_code"=>$promo_code));
if($res==false){
$data=array("coupon_type"=>$coupon_type,"discount"=>$discount,"discount_type"=>$discount_type,"promo_code"=>$promo_code,"min_value"=>$min_value,"start"=>$start_date,"expire"=>$expire_date,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->insert("tb_coupon",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_coupon");
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error ! </strong>Already Exist</div>');
redirect(base_url()."admin/view_coupon");
}
}
}
public function coupon_update($c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_rules("coupon_type","Select Coupon type","trim|required");
$this->fv->set_rules("discount_type","Select Discount Type","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-coupon",$data);
}
else{
$coupon_id = base64_decode($c_id);
$coupon_type=$this->input->post("coupon_type");
$discount_type=$this->input->post("discount_type");
$discount=$this->input->post("discount");
$promo_code=$this->input->post("promo_code");
$min_value = $this->input->post("min_value");
$start_date=$this->input->post("start_date");
$expire_date=$this->input->post("expire_date");
$data=array("coupon_type"=>$coupon_type,"discount"=>$discount,"discount_type"=>$discount_type,"promo_code"=>$promo_code,"min_value"=>$min_value,"start"=>$start_date,"expire"=>$expire_date,"status"=>1,"created"=>$this->Curd->getdate());
if($this->Curd->update("tb_coupon",$data,"id",$coupon_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_coupon");
}
}
}
public function coupon_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$coupon_id = $this->input->post('c_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_coupon",array("status"=>$status),"id",$coupon_id)){
echo 1;
}
}
public function delete_coupon($c_id){
$data["username"]=$this->get_username();
$this->security_guard();
$cat_id = base64_decode($c_id);
if($this->Curd->delete("tb_coupon",array("id"=>$cat_id))){
redirect(base_url()."admin/view_coupon");
}
}
/*End Coupon Code*/
/*Start Delivery Location Code with Charge*/
public function view_delivery_location(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['location_res']=$this->Curd->all_fetcher_order("locations","DESC");
$this->load->library(array("form_validation"=>"fv"));
$this->load->view("admin/view-delivery-location",$data);
}
public function add_delivery_location($id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$data['states'] = $this->Curd->fetch_where("states",array("*"),array("country_id"=>101));
$data['cities'] = $this->Curd->all_fetcher_order("cities","ASC");
if($id!=null){
$loc_id = base64_decode($id);
$data['location_res'] = $this->Curd->fetch_where("locations",array("*"),array("id"=>$loc_id));
}
$this->load->view("admin/add-delivery-location",$data);
}
public function delivery_location_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("state","Location","trim|required");
$this->fv->set_rules("city","Location","trim|required");
$this->fv->set_rules("pincode","Location","trim|required");
$this->fv->set_rules("charge","Location","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-delivery-location",$data);
}
else{
$state=$this->input->post("state");
$city=$this->input->post("city");
$pincode=$this->input->post("pincode");
$charge=$this->input->post("charge");
$data=array("pincode"=>$pincode,"city_name"=>$city,"state_name"=>$state,"country_name"=>'India',"charge"=>$charge);
if($this->Curd->insert("locations",$data)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_delivery_location");
}
}
}
public function delivery_location_update($d_id){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("state","Location","trim|required");
$this->fv->set_rules("city","Location","trim|required");
$this->fv->set_rules("pincode","Location","trim|required");
$this->fv->set_rules("charge","Location","trim|required");
if($this->fv->run()==false){
$this->load->view("admin/add-delivery-location",$data);
}
else{
$location_id = base64_decode($d_id);
$state=$this->input->post("state");
$city=$this->input->post("city");
$pincode=$this->input->post("pincode");
$charge=$this->input->post("charge");
$data=array("pincode"=>$pincode,"city_name"=>$city,"state_name"=>$state,"country_name"=>'India',"charge"=>$charge);
if($this->Curd->update("locations",$data,"id",$location_id)){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Update Successfully</div>');
redirect(base_url()."admin/view_delivery_location");
}
}
}
public function delivery_location_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$main_cat_id = $this->input->post('mc_id_for_status');
$status = $this->input->post('status');
if($this->Curd->update("tb_main_category",array("status"=>$status),"id",$main_cat_id)){
echo 1;
}
}
public function delete_delivery_location($d_id){
$data["username"]=$this->get_username();
$this->security_guard();
$location_id = base64_decode($d_id);
if($this->Curd->delete("locations",array("id"=>$location_id))){
redirect(base_url()."admin/view_delivery_location");
}
}
/*End Delivery Location Code with Charge*/
public function get_city_ajax(){
$id = $this->input->post("state_id");
$data = $this->Curd->fetch_where_order("cities", array('id','name'), array('state_id'=>$id), "desc");
$option = [];
if($data==true){
foreach ($data as $row) {
@$option.= "<option value='".$row->name."'>$row->name</option>";
}
}else{
$option = "<option value='0'>No City</option>";
}
print_r($option);
}
function user_export_csv(){
$filename = 'users_list_'.date('Ymd').'.csv';
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/csv; ");
$this->load->dbutil();
$query = $this->db->query("SELECT id, first_name,last_name,email,mobile,status,created as signup_date,birthdate FROM tb_user order by id desc");
echo $this->dbutil->csv_from_result($query);
}
public function delete_user($u_id){
$data["username"]=$this->get_username();
$this->security_guard();
$user_id = base64_decode($u_id);
if($this->Curd->delete("tb_user",array("id"=>$user_id))){
redirect(base_url()."admin/view_user");
}
}
public function delete_vendor($u_id){
$data["username"]=$this->get_username();
$this->security_guard();
$user_id = base64_decode($u_id);
if($this->Curd->delete("admin",array("id"=>$user_id))){
redirect(base_url()."admin/view_vendor");
}
}
function dob_send_sms(){
$do = $this->input->get('dob');
$uid = $this->input->get('uid');
$this->db->like('birthdate',date('d-m',strtotime($do)));
if($uid){$this->db->where('id',$uid);}
$this->db->order_by('id','desc');
$query = $this->db->get('tb_user');
// echo $this->db->last_query();
if($query->num_rows()>0){
foreach($query->result() as $row){
$name = $row->first_name." ".$row->last_name;
// echo $row->birthdate;
$mobile= $row->mobile;
if($mobile){
// echo $mobile = "8700389425";
$msdf ="Dear $name,Wishing you a very happy Birthday from the entire team of Gutlooks! As a special birthday treat, we are giving you 10% off on your next order. Please WhatsApp at 8209722282 to collect your coupon code. See you soon!";
$this->send_sms($mobile,$msdf,'1207162711125710304');
}
}
}
echo "<script>alert('Birthday Wishing Successfully!');window.location.href='".$_SERVER['HTTP_REFERER']."';</script>";
}
/*User Work*/
public function view_user(){
$data["username"]=$this->get_username();
$this->security_guard();
$do = $this->input->get('dob');
if($do){
$data['dob'] = $do;
$data['user_res'] = $this->Curd->fetch_customer($do);
}else{
$data['dob'] = '';
$data['user_res'] = $this->Curd->all_fetcher_order("tb_user","DESC");
}
// fetch_where_order($tab_name,$data,$cnd,$order_by)
//
$this->load->view("admin/view-user",$data);
}
public function view_vendor(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['user_res'] = $this->Curd->all_fetcher_order("admin","DESC");
$this->load->view("admin/view-vendor",$data);
}
function order_view_details(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['main_cat'] = $this->Curd->fetch_where_order("tb_main_category",array("*"),array("status"=>1),"ASC");
$data['order_res'] = $this->Curd->fetch_where_order("tb_order",array("*"),array("id"=>$this->uri->segment('3')),"DESC");
// $this->load->view('admin/veiw_order',$data);
// $data['user_id'] = $this->uri->segment('3');
$this->load->view("admin/order_view_details",$data);
}
function view_customer_order(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['user_id'] = $this->uri->segment('3');
$this->load->view("admin/view_customer_order",$data);
}
function view_customer_details(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['user_id'] = $this->uri->segment('3');
$this->load->view("admin/view_customer_details",$data);
}
public function user_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$user_id = $this->input->post('user_id_for_status');
$status = $this->input->post('status');
var_dump($status);
if($this->Curd->update("tb_user",array("status"=>$status),"id",$user_id)){
echo 1;
}
}
public function vendor_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$user_id = $this->input->post('user_id_for_status');
$status = $this->input->post('status');
var_dump($status);
if($this->Curd->update("admin",array("status"=>$status),"id",$user_id)){
echo 1;
}
}
function order_export_csv(){
$filename = 'order_list_'.date('Ymd').'.csv';
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/csv; ");
$this->load->dbutil();
$to =$this->input->get('to_date');
$from =$this->input->get('from_date');
$status =$this->input->get('order_staus');
$this->db->select('s.invoice_no,s.invoice_date,s.order_date,sc.*,s.full_name as name,s.mobile,s.gstno,s.b_email,s.pincode,s.b_state,s.order_staus,s.delivery_charges,s.cod_charge,s.order_price as total_order_amount,s.coupon_discount,s.payment_method');
$this->db->from('tb_order as s');
if(($from) &&($to) ) {
$dw= "s.invoice_date BETWEEN '$to' AND '$from'";
$this->db->where($dw); }
if($status) { $this->db->where('s.order_staus',$status); }
// $query=$this->db->get('tb_order');
$this->db->join('tb_sub_order as sc', 'sc.order_no = s.order_no', 'left');
$query = $this->db->get();
// echo $this->db->last_query();
// $query = $this->db->query("SELECT * FROM tb_order order by id desc");
echo $this->dbutil->csv_from_result($query);
}
public function view_order(){
$data["username"]=$this->get_username();
$this->security_guard();
$to =$this->input->get('to_date');
$from =$this->input->get('from_date');
$status =$this->input->get('order_staus');
$data['order_res'] = $this->Curd->all_order_list($to,$from,$status);
$this->load->view("admin/view-order",$data);
}
public function order_print(){
$data["username"]=$this->get_username();
$this->security_guard();
// $data['order_res'] = $this->Curd->all_fetcher_order("tb_order","DESC");
$data['order_res'] = $this->Curd->fetch_where_order("tb_order",array("*"),array("id"=>$this->uri->segment('3')),"DESC");
$this->load->view("admin/order_print",$data);
}
public function random_strings($length_of_string)
{
$str_result = '0123456789ABCDEFGHIJ';
return substr(str_shuffle("E".$str_result),
1, $length_of_string);
}
public function user_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("mobile","Mobile","trim|required|is_unique[tb_user.mobile]");
if($this->fv->run()==false){
$this->load->view("admin/add-user",$data);
}
else{
$first_name = $this->input->post("first_name");
$last_name = $this->input->post("last_name");
$mobile = $this->input->post("mobile");
$pwd = $this->input->post("pwd");
$reffer_code = $this->input->post("reffer_code");
$DOB = $this->input->post("DOB");
$gender = $this->input->post('gender');
$res=$this->Curd->fetch_where("tb_user",array("id"),array("mobile"=>$mobile));
if($res==false){
$data = array("reffer_code"=>$this->random_strings(6),"first_name"=>$first_name,"last_name"=>$last_name,"otp"=>'8756',"birthdate"=>$DOB,"mobile"=>$mobile,"gender"=>$gender,"pwd"=>sha1($pwd),"status"=>1,"verify"=>1,"created"=>$this->Curd->getdate(),"ip_address"=>$this->input->ip_address());
if($this->Curd->insert("tb_user",$data)){
$message = "Welcome to GOAIM. Purchase you Membership for get Extra Discount";
$this->welcome($mobile,$message);
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_user");
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Internal Problem</div>');
redirect(base_url()."admin/add_user");
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Already Exist</div>');
redirect(base_url()."admin/add_user");
}
}
}
public function vendor_process(){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("mobile","Mobile","trim|required|is_unique[admin.phone]");
if($this->fv->run()==false){
$this->load->view("admin/add_vendor",$data);
}
else{
$first_name = $this->input->post("first_name");
$mobile = $this->input->post("mobile");
$pwd=$this->input->post("pwd");
$email = $this->input->post("email");
$res=$this->Curd->fetch_where("admin",array("id"),array("phone"=>$mobile));
if($res==false){
$data = array("name"=>$first_name,"email"=>$email,
"phone"=>$mobile,"role"=>'2',
"pwd"=>sha1($pwd),
"status"=>1,"show_pass"=>$pwd);
$dsf=$this->Curd->insert("admin",$data);
// echo $this->db->last_query();
if($dsf){
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Insert Successfully</div>');
redirect(base_url()."admin/view_vendor");
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Internal Problem</div>');
redirect(base_url()."admin/add_vendor");
}
}else{
$this->session->set_flashdata('success_msg','<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong>Already Exist</div>');
redirect(base_url()."admin/add_vendor");
}
}
}
public function add_user($u_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($u_id!=null){
$user_id = base64_decode($u_id);
$data['user_res'] = $this->Curd->fetch_where("tb_user",array("*"),array("id"=>$user_id));
}
$this->load->view("admin/add-user",$data);
}
public function add_vendor($u_id=null){
$data["username"]=$this->get_username();
$this->security_guard();
$this->load->library(array("form_validation"=>"fv"));
if($u_id!=null){
$user_id = base64_decode($u_id);
// $user_id = $u_id;
$data['user_res'] = $this->Curd->fetch_where("admin",array("*"),array("id"=>$user_id));
}
$this->load->view("admin/add_vendor",$data);
}
public function view_order_address(){
$id = $this->input->post('order_id');
$res = $this->Curd->fetch_where("tb_order",array("*"),array("id"=>$id));
if($res==true){
foreach($res as $row){
$delivery_name = $row->full_name;
$delivery_mobile = $row->mobile;
$delivery_address = $row->address;
$delivery_pincode =$row->pincode;
$delivery_city = $row->city;
$delivery_state = $row->state;
$delivery_landmark = $row->landmark;
$delivery_charges = $row->delivery_charges;
}?>
<tr>
<td>Delivery Name</td>
<td><?=$delivery_name?></td>
</tr>
<tr>
<td>Delivery Mobile</td>
<td><?=$delivery_mobile?></td>
</tr>
<tr>
<td>Delivery Pincode</td>
<td><?=$delivery_pincode?></td>
</tr>
<tr>
<td>Delivery Address</td>
<td><?=$delivery_address?></td>
</tr>
<tr>
<td>Delivery Landmark</td>
<td><?=$delivery_landmark?></td>
</tr>
<tr>
<td>Delivery City</td>
<td><?=$delivery_city?></td>
</tr>
<tr>
<td>Delivery State</td>
<td><?=$delivery_state?></td>
</tr>
<tr>
<td>Delivery Charges</td>
<td><?=$delivery_charges?></td>
</tr>
<?php }
}
public function suborder_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$id = $this->input->post('order_id_for_status');
$status = $this->input->post('status');
if($this->Curd->array_update("tb_sub_order",array("status"=>$status,"status_date"=>$this->Curd->getdate()),array("id"=>$id))){
echo 1;
}else{
echo 0;
}
}
public function order_status_changer(){
$data["username"]=$this->get_username();
$this->security_guard();
$id = $this->input->post('order_id_for_status');
$status = $this->input->post('status');
if($this->Curd->array_update("tb_order",array("status"=>$status,"order_update"=>$this->Curd->getdate()),array("order_no"=>$id))){
$this->Curd->array_update("tb_sub_order",array("status"=>$status,"status_date"=>$this->Curd->getdate()),array("order_no"=>$id));
echo 1;
}else{
echo 0;
}
}
public function print_invoice($order_no){
$data["username"]=$this->get_username();
$this->security_guard();
$data['addtional_info'] = $this->Curd->fetch_where("tb_order",array("delivery_charges","coupon_discount"),array("order_no"=>base64_decode($order_no)));
$data['suborder_res'] = $this->Curd->fetch_where("tb_sub_order",array("*"),array("order_no"=>base64_decode($order_no)));
$this->load->view("admin/print_invoice",$data);
}
public function view_sub_order($order_no){
$data["username"]=$this->get_username();
$this->security_guard();
$data['addtional_info'] = $this->Curd->fetch_where("tb_order",array("delivery_charges","coupon_discount"),array("order_no"=>base64_decode($order_no)));
$data['suborder_res'] = $this->Curd->fetch_where("tb_sub_order",array("*"),array("order_no"=>base64_decode($order_no)));
$this->load->view("admin/view-sub-order",$data);
}
public function view_inventory(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['product_res'] = $this->Curd->all_fetcher_order("tb_product","DESC");
$this->load->view('admin/view-inventory',$data);
}
public function add_product_stock(){
$id = $this->input->post("id_for_qty");
$qty = intval($this->input->post("qty"));
$res = $this->Curd->fetch_where("tb_product_price",array("qty"),array("id"=>$id));
$total_qty = $res[0]->qty+$qty;
$res = $this->Curd->update("tb_product_price",array("qty"=>$total_qty),"id",$id);
if($res==true){
echo json_encode(array("status"=>1,"msg"=>"Stock Update Successfully","output"=>$total_qty));
}else{
echo json_encode(array("status"=>0,"msg"=>"Internal Problem"));
}
}
public function view_sale_report(){
$data["username"]=$this->get_username();
$this->security_guard();
$data['order_res'] = $this->Curd->last_week_data("tb_order");
$this->load->view("admin/view-sale-report",$data);
}
public function change_pwd(){
$data["username"]=$this->get_username();
$this->load->library(array("form_validation"=>"fv"));
$this->security_guard();
$this->load->view('admin/change-password',$data);
}
public function logout(){
$this->session->sess_destroy();
redirect(base_url("admin"));
}
public function change_pwd_process(){
$this->load->library(array("form_validation"=>"fv"));
$this->fv->set_error_delimiters("<span class='text-danger'>","</span>");
$this->fv->set_rules("c_pwd","Current Password","trim|required");
$this->fv->set_rules("new_pwd","New Password","trim|required|min_length[6]");
$this->fv->set_rules("rpwd","Confirm Password","trim|required|matches[new_pwd]");
if($this->fv->run()==false){
$this->change_pwd();
}else{
$c_pwd=sha1($this->input->post('c_pwd'));
$new_pwd=sha1($this->input->post('new_pwd'));
$rpwd=$this->input->post('rpwd');
$res=$this->Curd->fetch_where('admin',array('pwd'),array('id'=>$_SESSION['id']));
foreach ($res as $row){
$pwd=$row->pwd;
}
if($pwd===$c_pwd){
if($this->Curd->update('admin',array('pwd'=>$new_pwd,'show_pass'=>$rpwd,),'id',$_SESSION['id'])){
$this->session->set_flashdata('success_msg','<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success ! </strong> Password Update Succesfully</div>');
redirect('admin/change_pwd');
}
}else{
$this->session->set_flashdata('error_msg','<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Failure ! </strong> Current Password Does Not Matchs</div>');
redirect('admin/change_pwd');
}
}
}
public function welcome($mobiles,$message)
{
$Curl_Session = curl_init('http://xprtsms.com/app/smsapi/index.php');
// $Curl_Session = curl_init('37.48.104.215');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "senderid=ALTEST&routeid=100118&contacts=$mobiles&key=55D50FE5F3D1E7&msg=$message");
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER,1);
$response=curl_exec ($Curl_Session);
$err = curl_error($Curl_Session);
curl_close ($Curl_Session);
}
}
?>