?
Current Path : /home1/savoy/public_html/savoyglobal.net/koolkids/school/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/koolkids/school/application/models/documentmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?> <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class Documentmodel extends Model { function Documentmodel() { parent::Model(); } function searchdocument($postdata,$pagenum,$parent_id) { $data=array(); $this->db->from('directory'); $this->db->join('master','master.masterid=directory.directory_id'); $this->db->join('user','master.creator_id=user.user_id'); $this->db->join('directory_file','directory.directory_id=directory_file.directory_id','left'); $this->db->where('parent_id', $parent_id); $this->db->where('deleted', '0'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; $data['parent_id']=$parent_id; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $this->db->like($searchfield, $searchtext); } $this->db->select('directory.directory_id,directory.parent_id,directory.directory_name,user.username,master.created_time,directory.is_file,directory_file.file_name'); $this->db->from('directory'); $this->db->join('master','master.masterid=directory.directory_id'); $this->db->join('user','master.creator_id=user.user_id'); $this->db->join('directory_file','directory.directory_id=directory_file.directory_id','left'); $this->db->where('deleted', '0'); if($parent_id!="") $this->db->where('parent_id', $parent_id); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function insertdocument($postdata) { $data=array(); $this->db->trans_begin(); if(isset($postdata['to_upload'])) $is_file=1; else $is_file=0; $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array('directory_id'=>$masterid, 'directory_name'=>$postdata['directory_name'], 'parent_id'=>$postdata['parent_id'], 'is_file'=>$is_file); $this->db->insert('directory', $tbl1Values); if($is_file==1) { $tbl1Values=array('directory_id'=>$masterid, 'file_name'=>$postdata['file_name'], 'media_type'=>$postdata['media_type'], 'category'=>$postdata['category']); $this->db->insert('directory_file', $tbl1Values); } $data['resfunction']='searchdocument'; $data['parent_id']=$postdata['parent_id']; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updatedocument($postdata) { // $path = './school/uploads/'; // $tracepath=$this->documentmodel->tracepath($postdata['parent_id']); // echo $tracepath; // die(); $data=array(); $this->db->trans_begin(); // if (mkdir($path . $postdata['directory_name'], 0775)) // { $masterid = $this->mastermodel->updatemasterdata($postdata['masterid']); $tbl1Values=array( 'directory_name'=>$postdata['directory_name'], 'parent_id'=>$postdata['parent_id']); $this->db->where('directory_id', $postdata['masterid']); $this->db->update('directory', $tbl1Values); $data['resfunction']='searchdocument'; $data['parent_id']=$postdata['parent_id']; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } // } // else { // echo "Trouble"; // } } function tracepath($tempid) { $data=array(); $data['plocation']=''; $data['pid']=''; while($tempid!=0) { $directname=$this->mastermodel->get_data_srow('directory',$tempid,'directory_id'); $diName=$directname->directory_name; $tempid=$directname->parent_id; $dirid=$directname->directory_id; $data['plocation']=$diName.'/'.$data['plocation']; $data['pid']=$dirid.'/'.$data['pid']; } return $data; } }