芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/joolsmen.com/application/controllers/admin/Service.php
load->model('service_model','service'); $this->load->model('common_model','common_model'); $this->data['theme'] = 'admin'; $this->data['model'] = 'service'; $this->load->model('admin_model','admin'); $this->data['base_url'] = base_url(); $this->session->keep_flashdata('error_message'); $this->session->keep_flashdata('success_message'); $this->load->helper('user_timezone_helper'); $this->data['user_role']=$this->session->userdata('role'); } public function index() { redirect(base_url('subscriptions')); } public function subscriptions() { $this->common_model->checkAdminUserPermission(9); if($this->session->userdata('admin_id')) { $this->data['page'] = 'subscriptions'; $this->data['model'] = 'service'; $this->data['currency_code'] = settings('currency'); $this->data['list'] = $this->service->subscription_list(); $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } else { redirect(base_url()."admin"); } } public function delete_subsciption() { $inp = $this->input->post(); //echo json_encode($inp); $this->db->where('id', $inp['id']); $this->db->update('subscription_fee', ['status'=>0]); echo json_encode("success"); } public function add_subscription() { $this->common_model->checkAdminUserPermission(9); if($this->session->userdata('admin_id')) { $this->data['page'] = 'add_subscription'; $this->data['model'] = 'service'; $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } else { redirect(base_url()."admin"); } } public function check_subscription_name() { $subscription_name = $this->input->post('subscription_name'); $id = $this->input->post('subscription_id'); if(!empty($id)) { $this->db->select('*'); $this->db->where('subscription_name', $subscription_name); $this->db->where('id !=', $id); $this->db->from('subscription_fee'); $result = $this->db->get()->num_rows(); } else { $this->db->select('*'); $this->db->where('subscription_name', $subscription_name); $this->db->from('subscription_fee'); $result = $this->db->get()->num_rows(); } if ($result > 0) { $isAvailable = FALSE; } else { $isAvailable = TRUE; } echo json_encode( array( 'valid' => $isAvailable )); } public function save_subscription() { $this->common_model->checkAdminUserPermission(9); removeTag($this->input->post()); $data['subscription_name'] = $this->input->post('subscription_name'); $data['fee'] = $this->input->post('subscription_amount'); $data['currency_code'] = settings('currency'); $data['duration'] = $this->input->post('subscription_duration'); $data['fee_description'] = $this->input->post('fee_description'); $data['status'] = $this->input->post('status'); $result = $this->db->insert('subscription_fee', $data); if(!empty($result)) { $this->session->set_flashdata('success_message','Subscription added successfully'); echo 1; } else { $this->session->set_flashdata('error_message','Something wrong, Please try again'); echo 2; } } public function edit_subscription($id) { $this->common_model->checkAdminUserPermission(9); if($this->session->userdata('admin_id')) { $this->data['page'] = 'edit_subscription'; $this->data['model'] = 'service'; $this->data['subscription'] = $this->service->subscription_details($id); $this->data['currency_code'] = settings('currency'); //Currency Convertion $currency_code_old = $this->data['subscription']['currency_code']; $subscription_amount = get_gigs_currency($this->data['subscription']['fee'], $this->data['subscription']['currency_code'], $this->data['currency_code']); $this->data['subscription_amt'] = $subscription_amount; $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } else { redirect(base_url()."admin"); } } public function update_subscription() { $this->common_model->checkAdminUserPermission(9); removeTag($this->input->post()); $where['id'] = $this->input->post('subscription_id'); $data['subscription_name'] = $this->input->post('subscription_name'); $data['fee'] = $this->input->post('subscription_amount'); $data['currency_code'] = settings('currency'); $data['duration'] = $this->input->post('subscription_duration'); $data['fee_description'] = $this->input->post('fee_description'); $data['status'] = $this->input->post('status'); $result = $this->db->update('subscription_fee', $data, $where); if(!empty($result)) { $this->session->set_flashdata('success_message','Subscription updated successfully'); echo 1; } else { $this->session->set_flashdata('error_message','Something wrong, Please try again'); echo 2; } } public function service_providers() { $this->common_model->checkAdminUserPermission(12); $this->data['page'] = 'service_providers'; $this->data['subcategory']=$this->service->get_subcategory(); $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } public function provider_details($value='') { $this->common_model->checkAdminUserPermission(12); $this->data['page'] = 'provider_details'; $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } public function provider_list() { $this->common_model->checkAdminUserPermission(12); extract($_POST); if($this->input->post('form_submit')) { $this->data['page'] = 'service_providers'; $username = $this->input->post('username'); $email = $this->input->post('email'); $from = $this->input->post('from'); $to = $this->input->post('to'); $subcategory=$this->input->post('subcategory'); $this->data['lists'] = $this->service->provider_filter($username,$email,$from,$to,$subcategory); $this->data['subcategory']=$this->service->get_subcategory(); $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } else { $lists = $this->service->provider_list(); $data = array(); $no = $_POST['start']; foreach ($lists as $template) { $no++; $row = array(); $row[] = $no; $profile_img = $template->profile_img; if(empty($profile_img)){ $profile_img = 'assets/img/user.jpg'; } $row[] = '
'.$template->name.'
'; $row[] = $template->mobileno; $row[] = $template->email; $created_at='-'; if (isset($template->created_at)) { if (!empty($template->created_at) && $template->created_at != "0000-00-00 00:00:00") { $date_time = $template->created_at; $date_time = utc_date_conversion($date_time); $created_at = date("d M Y", strtotime($date_time)); } } $row[] = $created_at; $row[] = $template->subscription_name; $val = ''; $status = $template->status; $delete_status = $template->status; if($status == 2) { $val = ''; } elseif($status == 1) { $val = 'checked'; } $row[] ='
checkbox
'; $base_url=base_url()."providers/edit/".$template->id; $row[] ="
Edit
id."' data-id='".$template->id."'>
Delete
"; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->service->provider_list_all(), "recordsFiltered" => $this->service->provider_list_filtered(), "data" => $data, ); echo json_encode($output); } } public function service_list() { $this->common_model->checkAdminUserPermission(4); extract($_POST); $this->data['page'] = 'service_list'; if ($this->input->post('form_submit')) { $service_title = $this->input->post('service_title'); $category = $this->input->post('category'); $subcategory = $this->input->post('subcategory'); $from = $this->input->post('from'); $to = $this->input->post('to'); $this->data['list'] =$this->service->service_filter($service_title,$category,$subcategory,$from,$to); } else { $this->data['list'] = $this->service->service_list(); } $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } public function service_details($value='') { $this->common_model->checkAdminUserPermission(4); $this->data['page'] = 'service_details'; $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } /*change service list */ public function change_Status_service_list(){ $id=$this->input->post('id'); $status=$this->input->post('status'); if($status==0){ $avail=$this->service->check_booking_list($id); if($avail==0){ $this->db->where('id',$id); if($this->db->update('services',array('status' =>$status))){ echo "success"; }else{ echo "error"; } }else{ echo "1"; } }else{ $this->db->where('id',$id); if($this->db->update('services',array('status' =>$status))){ echo "success"; }else{ echo "error"; } } } public function change_Status() { $id=$this->input->post('id'); $status=$this->input->post('status'); $this->db->where('id',$id); $this->db->update('providers',array('status' =>$status)); } public function delete_provider() { $id=$this->input->post('id'); $data=array('delete_status'=>1); $this->db->where('id',$id); if($this->db->update('providers',$data)) { echo 1; } } public function service_requests() { if($this->session->userdata('admin_id')) { $this->data['page'] = 'service_requests'; $this->data['model'] = 'service'; $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } else { redirect(base_url()."admin"); } } public function request_list() { $lists = $this->service->request_list(); $data = array(); $no = $_POST['start']; foreach ($lists as $template) { $no++; $row = array(); $row[] = $no; $profile_img = $template['profile_img']; if(empty($profile_img)){ $profile_img = 'assets/img/user.jpg'; } $row[] = '
'.$template['username'].'
'; $row[] = $template['contact_number']; $row[] = $template['title']; $row[] = '
RM
'.$template['proposed_fee'].'
'; $row[] = '
'.date("d M Y", strtotime($template['request_date'])).'
'.date("H.i A", strtotime($template['request_time'])).'
'; $row[] = date("d M Y", strtotime($template['created'])); $val = ''; $status = $template['status']; if($status == -1) { $val = '
Expired
'; } if($status == 0) { $val = '
Pending
'; } elseif($status == 1) { $val = '
Accepted
'; } elseif($status == 2) { $val = '
Completed
'; } elseif($status == 3) { $val = '
Declined
'; } elseif($status == 4) { $val = '
Deleted
'; } $row[] = $val; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->service->request_list_all(), "recordsFiltered" => $this->service->request_list_filtered(), "data" => $data, ); //output to json format echo json_encode($output); } public function delete_service() { $id=$this->input->post('service_id'); $inputs['status']= '0'; $WHERE =array('id' => $id); $result=$this->service->update_service($inputs,$WHERE); if($result) { $this->session->set_flashdata('success_message','Service deleted successfully'); redirect(base_url()."service-list"); } else { $this->session->set_flashdata('error_message','Something wrong, Please try again'); redirect(base_url()."service-list"); } } //Added New public function edit_providers($id=NULL) { $this->common_model->checkAdminUserPermission(12); $this->data['countrycode']= $this->admin->get_country_code_config(); $this->data['category']=$this->service->get_category(); $this->data['subcategory']=$this->service->get_subcategory(); if(!empty($id)){ $this->data['user']=$this->service->edit_provider_data($id); $this->data['title']="Edit Provider"; }else{ $this->data['user']=array(); $this->data['title']="Add Provider"; } $this->data['page']="edit_provider"; $this->load->vars($this->data); $this->load->view($this->data['theme'].'/template'); } public function fetch_subcategorys() { $this->db->where('status', 1); $this->db->where('category', $_POST['id']); $query = $this->db->get('subcategories'); $result = $query->result(); $data = array(); if (!empty($result)) { foreach ($result as $r) { $data['value'] = $r->id; $data['label'] = $r->subcategory_name; $json[] = $data; } } echo json_encode($json); } public function check_provider_name() { $name = $this->input->post('name'); $id = $this->input->post('id'); if(!empty($id)) { $this->db->select('*'); $this->db->where('name', $name); $this->db->where('id !=', $id); $this->db->from('providers'); $result = $this->db->get()->num_rows(); } else { $this->db->select('*'); $this->db->where('name', $name); $this->db->from('providers'); $result = $this->db->get()->num_rows(); } if ($result > 0) { $isAvailable = FALSE; } else { $isAvailable = TRUE; } echo json_encode( array( 'valid' => $isAvailable )); } public function check_provider_mobile() { $mobileno = $this->input->post('mobileno'); $country_code = $this->input->post('country_code'); $id = $this->input->post('id'); if(!empty($id)) { $this->db->select('*'); $this->db->where('country_code', $country_code); $this->db->where('mobileno', $mobileno); $this->db->where('id !=', $id); $this->db->from('providers'); $result = $this->db->get()->num_rows(); } else { $this->db->select('*'); $this->db->where('country_code', $country_code); $this->db->where('mobileno', $mobileno); $this->db->from('providers'); $result = $this->db->get()->num_rows(); } if ($result > 0) { $isAvailable = FALSE; } else { $isAvailable = TRUE; } echo json_encode( array( 'valid' => $isAvailable )); } public function check_provider_email() { $email = $this->input->post('email'); $id = $this->input->post('id'); if(!empty($id)) { $this->db->select('*'); $this->db->where('email', $email); $this->db->where('id !=', $id); $this->db->from('providers'); $result = $this->db->get()->num_rows(); } else { $this->db->select('*'); $this->db->where('email', $email); $this->db->from('providers'); $result = $this->db->get()->num_rows(); } if ($result > 0) { $isAvailable = FALSE; } else { $isAvailable = TRUE; } echo json_encode( array( 'valid' => $isAvailable )); } public function update_provider() { $this->common_model->checkAdminUserPermission(12); $params=$this->input->post(); $user_id=''; $uploaded_file_name = ''; $profile_image = $this->input->post('profile_img'); if (!empty($profile_image)) { $params['profile_img'] = $profile_image; }else{ unset($params['profile_img']); } if(!empty($params['id'])){ $user_id=$params['id']; $params['updated_at'] = date('Y-m-d H:i:s'); $result=$this->db->where('id',$user_id)->update('providers',$params); }else{ $params['currency_code'] = 'INR'; $params['otp'] = '1234'; $params['share_code'] = $this->service->ShareCode(6,$params['name']); $params['created_at'] = date('Y-m-d H:i:s'); $params['is_agree'] = 1; $result=$this->db->insert('providers',$params); $user_id = $this->db->insert_id(); $token = $this->service->getToken(14,$user_id); $this->db->where('id', $user_id); $this->db->update('providers', array('token'=>$token)); //insert chat $chat_arr = ['sender_token'=>'0dreamsadmin', 'receiver_token'=>$token, 'message'=>'Hi! Welcome to TruelySell', 'status'=>'1', 'read_status'=>'0', 'utc_date_time'=>date('Y-m-d H:i:s')]; $this->db->insert('chat_table', $chat_arr); //insert wallet $data = array("token" => $token, 'currency_code' => 'INR', "user_provider_id" => $user_id, "type" => 1, "wallet_amt" => 0, "created_at" => date('Y-m-d H:i:s')); $wallet_result = $this->db->insert('wallet_table', $data); } //echo $this->db->last_query(); if($result==true){ if(empty($user_id)){ echo json_encode(['status'=>true,'msg'=>"Provider Details Added SuccesFullly..."]); }else{ echo json_encode(['status'=>true,'msg'=>"Provider Details Updated SuccesFullly..."]); } }else{ echo json_encode(['status'=>false,'msg'=>"Someting Went wrong in server end..."]); } } public function delete_provider_data() { $adminId = $this->session->userdata('admin_id'); if ($adminId > 1) { echo json_encode(['status'=>false,'msg'=>"Permission Denied.!!"]); }else{ $id = $this->input->post('user_id'); if (!empty($id)) { //$this->db->delete('users', array('id' => $id)); $data=array('delete_status'=>1); $this->db->where('id',$id); if($this->db->update('providers',$data)) { echo json_encode(['status'=>true,'msg'=>"Providers Details Deleted SuccesFullly."]); }else { echo json_encode(['status'=>false,'msg'=>"Someting went wrong on server end.."]); } }else { echo json_encode(['status'=>false,'msg'=>"Someting went wrong, Please try again !!"]); } } } }//Class end.