MMCT TEAM
Server IP : 103.191.208.50  /  Your IP : 216.73.216.53
Web Server : LiteSpeed
System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64
User : celkcksm ( 1031)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, popen, exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0777) :  /home/celkcksm/cms.acadevo.in/application/models/lms/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/cms.acadevo.in/application/models/lms/Book_model.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');


/**
 * 
 */
class Book_model extends BaseModel
{

    function __constuct(){
        parent::__construct(); 
    }

    public function store_book_data($data,$db_group=null,$return_query=FALSE){
        if($this->db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        $this->table='institute_lms_books';
        return $this->store($data,FALSE,$return_query);
    }

    public function update_book_data($data,$param,$batch=FALSE,$db_group=null,$return_query=FALSE){
        if($this->db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        $this->table='institute_lms_books';
        return $this->modify($data,$param,$batch,$return_query);
    }

    public function delete_book_data($param,$db_group=null,$return_query=FALSE){
        if($this->db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        $this->table='institute_lms_books';
        return $this->remove($param,0,$return_query);
    }


    public function get_book($param,$single_row=TRUE,$db_group=null,$return_query=FALSE){
        if($this->db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        $this->table='institute_lms_books';
        if($single_row==TRUE){
            return $this->get_one($param,'',$return_query);
        }else if($single_row==FALSE){
            return $this->get_many($param,null,null,$return_query);
        }       
    }
    
    public function get_book_author($param,$single_row=TRUE,$db_group=null,$return_query=FALSE){
        if($this->db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        $this->table='institute_lms_authors';
        if($single_row==TRUE){
            return $this->get_one($param,'',$return_query);
        }else if($single_row==FALSE){
            return $this->get_many($param,null,null,$return_query);
        }       
    }

    


    public function _get_book_data($post=array(),$param=array(),$count=FALSE,$return_query=FALSE,$db_group=null){
        if($db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        
        $this->_db->select('institute_lms_books.*,institute_lms_authors.author_name,institute_lms_category.category_name,institute_lms_rack.rack_name,institute_lms_publishers.publisher_name');
        $this->_db->join('institute_lms_category','institute_lms_category.category_id=institute_lms_books.book_category_id','LEFT');
        $this->_db->join('institute_lms_authors','institute_lms_authors.author_id=institute_lms_books.book_author_id','LEFT');
        $this->_db->join('institute_lms_rack','institute_lms_rack.rack_id=institute_lms_books.book_rack_id','LEFT');
        $this->_db->join('institute_lms_publishers','institute_lms_publishers.publisher_id=institute_lms_books.book_publisher_id','LEFT');

        $i = 0;

        if(isset($param['inst_id'])){
            $this->_db->where('book_inst_id',$param['inst_id']);
        }

        if(isset($param['inst_type'])){
            $this->_db->where('book_inst_type',$param['inst_type']);
        }

        if(isset($param['book_is_available'])){
            $this->_db->where('book_is_available',$param['book_is_available']);
        }

        if(isset($param['book_available_copy']) && $param['book_available_copy']==true){
            $this->_db->where('book_available_copy!=',0);
        }

        if(isset($post['stock_id']) && $post['stock_id']!='0'){
            if($post['stock_id']=='in_stock'){
                $this->_db->where('book_available_copy>',0);
            }else if($post['stock_id']=='out_of_stock'){
                $this->_db->where('book_available_copy',0);
            }            
        }

        if(isset($post['category_id']) && $post['category_id']>0){
            $this->_db->where('book_category_id',$post['category_id']);
        }

        if(isset($post['publisher_id']) && $post['publisher_id']>0){
            $this->_db->where('book_publisher_id',$post['publisher_id']);
        }

        if(isset($post['rack_id']) && $post['rack_id']>0){
            $this->_db->where('book_rack_id',$post['rack_id']);
        }

        if(isset($post['language_id']) && $post['language_id']>0){
            $this->_db->where('book_language_id',$post['language_id']);
        }

        if(isset($param['column_search'])){
            foreach ($param['column_search'] as $item)
            {
                if(isset($post['search']['value']) && $post['search']['value'])
                {
                    
                    if($i===0)
                    {
                        $this->_db->group_start();
                        $this->_db->like($item, $post['search']['value']);
                    }
                    else
                    {
                        $this->_db->or_like($item, $post['search']['value']);
                    }

                    if(count($param['column_search']) - 1 == $i)
                        $this->_db->group_end();
                }
                
                $i++;
            }
        }

            
        if(isset($post['order']))
        {
            $column_order=$param['column_order'];
            $this->_db->order_by($column_order[$post['order']['0']['column']], $post['order']['0']['dir']);
        } 
        else if(isset($param['order']))
        {
            $order = $param['order'];
            $this->_db->order_by(key($order), $order[key($order)]);
        }

        if($count==FALSE){
            if(isset($post['length']) && $post['length'] != -1){
                $this->_db->limit($post['length'],$post['start']);   
            }
            
            $query = $this->_db->get('institute_lms_books');

            if($return_query==FALSE){
                return $query->result();
            }else if($return_query==TRUE){
                return $this->_db->last_query();
            }       
            
        }else if($count==TRUE){
            $query = $this->_db->get('institute_lms_books');
            if($return_query==FALSE){
                return $query->num_rows();
            }else if($return_query==TRUE){
                return $this->_db->last_query();
            }           
        }
        
    }

    public function get_book_data($param=array(),$db_group=null,$return_query=FALSE){
        if($db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        
        $this->_db->select('institute_lms_books.*,institute_lms_authors.author_name,institute_lms_category.category_name,institute_lms_rack.rack_name,institute_lms_publishers.publisher_name');
        $this->_db->join('institute_lms_category','institute_lms_category.category_id=institute_lms_books.book_category_id','LEFT');
        $this->_db->join('institute_lms_authors','institute_lms_authors.author_id=institute_lms_books.book_author_id','LEFT');
        $this->_db->join('institute_lms_rack','institute_lms_rack.rack_id=institute_lms_books.book_rack_id','LEFT');
        $this->_db->join('institute_lms_publishers','institute_lms_publishers.publisher_id=institute_lms_books.book_publisher_id','LEFT');

        $i = 0;

        if (isset($param['book_ids'])) {
            if (!is_array($param['book_ids'])) {
                $param['book_ids'] = explode(',', $param['book_ids']); // Convert comma-separated string to array
            }
            $this->_db->where_in('book_id', $param['book_ids']);
        }
        

        if(isset($param['inst_id'])){
            $this->_db->where('book_inst_id',$param['inst_id']);
        }

        if(isset($param['inst_type'])){
            $this->_db->where('book_inst_type',$param['inst_type']);
        }

        if(isset($param['inst_available'])){
            $this->_db->where('book_is_available',$param['inst_available']);
        }

        if(isset($param['book_available_copy']) && $param['book_available_copy']==true){
            $this->_db->where('book_available_copy!=',0);
        }

        if(isset($param['stock_id']) && $param['stock_id']!='0'){
            if($param['stock_id']=='in_stock'){
                $this->_db->where('book_available_copy>',0);
            }else if($param['stock_id']=='out_of_stock'){
                $this->_db->where('book_available_copy',0);
            }            
        }

        if(isset($param['category_id']) && $param['category_id']>0){
            $this->_db->where('book_category_id',$param['category_id']);
        }

        if(isset($param['publisher_id']) && $param['publisher_id']>0){
            $this->_db->where('book_publisher_id',$param['publisher_id']);
        }

        if(isset($param['rack_id']) && $param['rack_id']>0){
            $this->_db->where('book_rack_id',$param['rack_id']);
        }

        if(isset($param['language_id']) && $param['language_id']>0){
            $this->_db->where('book_language_id',$param['language_id']);
        }
            
        if(isset($param['order']))
        {
            $order = $param['order'];
            $this->_db->order_by(key($order), $order[key($order)]);
        }

        $query = $this->_db->get('institute_lms_books');
        if($return_query==FALSE){
            return $query->result();
        }else if($return_query==TRUE){
            return $this->_db->last_query();
        }
        
    }

    public function get_total_books($param=null,$or_param=null,$group_by=NULL,$db_group=null,$return_query=FALSE){
        if($db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        $this->table='institute_lms_books';
        return $this->_get_total_count($param,$or_param,$group_by,$return_query);
    }

    public function get_last_book($param=null,$or_param=null,$order_by=NULL,$db_group=null,$return_query=FALSE){
        if($db_group!==null){
            $this->_db=$this->load->database($db_group, TRUE);
        }
        $this->table='institute_lms_books';
        return $this->_get_last($param,$or_param,$order_by,$return_query);
    }
}

MMCT - 2023