| Current File : /www-data/newsites/application/models/Settings_m.php |
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Settings_m extends CI_Model {
function __construct() {
parent::__construct();
}
public function hash($string) {
return hash("sha512", $string . config_item("encryption_key"));
}
public function viewall($table, $array, $order_by) {
$this->db->select()->from($table)
->where($array)
->order_by($order_by);
$query = $this->db->get();
return $query->result();
}
public function view_unique($table)
{
$this->db->select("DISTINCT(schedule_date)");
$this->db->from($table);
$this->db->order_by('schedule_date', 'ASC');
$query=$this->db->get();
return $query->result();
}
public function get_single($table, $id) {
//print_r($id);
$query = $this->db->get_where($table, array('host_name' => $id));
//print_r($query);exit;
return $query->row();
}
public function get_email($table, $id) {
$query = $this->db->get_where($table, array('reg_email' => $id));
return $query->row();
}
public function get_single_slug($table, $slug) {
$query = $this->db->get_where($table, array('slug' => $slug));
return $query->row();
}
public function get_name($table, $id) {
$query = $this->db->get_where($table, array('id' => $id));
return $query->row()->name;
}
public function insert($table,$data) {
if($this->db->insert($table, $data)){
return $this->db->insert_id();
} else {
return FALSE;
}
}
public function update($table, $data, $id){
$this->db->where('id', $id);
if($this->db->update($table, $data)){
return TRUE;
} else {
return FALSE;
}
}
public function update_sent($table, $data, $id){
$this->db->where('client_name', $id);
if($this->db->update($table, $data)){
return TRUE;
} else {
return FALSE;
}
}
public function updateAll($table, $data, $where){
$this->db->where($where);
if($this->db->update($table, $data)){
return TRUE;
} else {
return FALSE;
}
}
public function delete($table, $id){
$this->db->where('id', $id);
$this->db->limit(1);
if($this->db->delete($table)){
return TRUE;
} else {
return FALSE;
}
}
public function convertYoutube($string,$width,$height) {
return preg_replace(
"/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i",
"<iframe width=".$width." height=".$height." src=\"//www.youtube.com/embed/$2?rel=0\" allowfullscreen></iframe>",
$string
);
}
function fetch_state($booking_date)
{
$this->db->select('DISTINCT(time_slot)');
$this->db->where('status', 1);
$this->db->where('booking_date', $booking_date);
$this->db->order_by('id', 'ASC');
$query = $this->db->get('balcony');
$output = '<option value="">Slot Timings</option>';
foreach($query->result() as $row)
{
$output .= '<option value="'.$row->time_slot.'">'.$row->time_slot.'</option>';
}
return $output;
}
function fetch_all_dates($booking_date)
{
$game_id=$this->uri->segment(3);
$this->db->select('DISTINCT(time_slot)');
$this->db->where('status', 1);
$this->db->where('booking_date', $booking_date);
$this->db->order_by('id', 'ASC');
$query = $this->db->get('balcony');
foreach($query->result() as $row)
{
$output .= '<div class="panel panel-primary_two">
<div class="panel-heading clearfix" style="color:#000">
<div class="col-sm-6 text-right"><b>'.$row->time_slot.'</b></div>
<div class="col-sm-6 text-left"><b class="price_display">0/-</b></div>
</div></div>';
}
return $output;
}
function fetch_price($members)
{
$game_id=$this->uri->segment(3);
$bdate=$this->uri->segment(4);
$this->db->select('DISTINCT(price)');
$this->db->where('status', 1);
$this->db->where('game_id', $game_id);
$this->db->where('members', $members);
$this->db->where('booking_date', $bdate);
$this->db->order_by('id', 'ASC');
$query = $this->db->get('balcony');
foreach($query->result() as $row)
{
$d=$this->uri->segment(4);
$timestamp = strtotime($d);
$newDate = date('D', $timestamp);
$mem=$this->input->post('members');
if($newDate == 'Mon' || $newDate == 'Tue' || $newDate == 'Wed'|| $newDate == 'Thu'|| $newDate == 'Fri') {
if($this->input->post('members') == 2){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 3){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 4){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 5){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 6){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 7){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 8){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
}
elseif($newDate == 'Sat'|| $newDate == 'Sun') {
if($this->input->post('members') == 2){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 3){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 4){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 5){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 6){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 7){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
if($this->input->post('members') == 8){
$output .= '<option value="'.$row->price.'">'.$mem * $row->price.'</option>';
}
}
}
return $output;
}
function diaplay_price($members)
{
$game_id=$this->uri->segment(3);
$bdate=$this->uri->segment(4);
$this->db->select('DISTINCT(price)');
$this->db->where('status', 1);
$this->db->where('game_id', $game_id);
$this->db->where('members', $members);
$this->db->where('booking_date', $bdate);
$this->db->order_by('id', 'ASC');
$query = $this->db->get('balcony');
foreach($query->result() as $row)
{
$d=$this->uri->segment(4);
$timestamp = strtotime($d);
$newDate = date('D', $timestamp);
$mem=$this->input->post('members');
if($newDate == 'Mon' || $newDate == 'Tue' || $newDate == 'Wed'|| $newDate == 'Thu'|| $newDate == 'Fri') {
$output .= $mem * $row->price."/-";
}
elseif($newDate == 'Sat'|| $newDate == 'Sun') {
$output .= $mem * $row->price."/-";
}
}
return $output;
}
public function update_person($table, $data, $id){
$this->db->where('reg_email', $id);
if($this->db->update($table, $data)){
return TRUE;
} else {
return FALSE;
}
}
public function update_admin($table, $data, $id){
$this->db->where('email', $id);
if($this->db->update($table, $data)){
return TRUE;
} else {
return FALSE;
}
}
function fetch_sub_category($country_id,$sub_id)
{
$this->db->where('parent_id', $country_id);
$this->db->order_by('id', 'ASC');
$query = $this->db->get('category');
$output = '<option value="'.$country_id.'">Select Sub Category</option>';
foreach($query->result() as $row)
{
$output .='<option value="'.$row->id.'" '.(($row->id==$sub_id)?'selected="selected"':"").'>'.$row->category_name.'</option>';
}
return $output;
}
function deleteid($id){
$this->db->where('product_id', $id);
$this->db->delete('product_types');
}
/* function cart_all(){
$this->db->select("products.id,product_types.product_type,product_types.product_id,product_types.product_tax");
$this->db->from('products');
$this->db->join('product_types', 'product_types.product_id = $id');
$query = $this->db->get();
return $query->result();
} */
}
/* End of file signin_m.php */