whoami7 - Manager
:
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
home
/
papecmvm
/
www
/
application
/
models
/
Upload File:
files >> //proc/thread-self/root/proc/self/root/home/papecmvm/www/application/models/App_17042023.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class App extends CI_Model { function __construct(){ parent::__construct(); //load our second db2 and put in $db22 $CI = & get_instance(); $this->db = $CI->load->database('default', TRUE); $this->db2 = $CI->load->database('db2', TRUE); } public function insertData($table,$data) { $dates=array('lasttime'=> date("Y-m-d H:i:s")); //$this->db2->update('lastmodifytime',$dates); $query=$this->db2->insert($table, $data); return $this->db2->insert_id(); /*if(!$query) { //redirect('welcome/errorpage'); show_error("ERROR", 500 ); exit; }*/ } public function getDatamodel($table) { $query=$this->db2->get($table); if(!$query) { //redirect('welcome/errorpage'); show_error("ERROR", 500 ); exit; } return $query->result_array(); } public function getDatamodelCount($table) { return $this->db2->count_all_results($table); } public function getDatamodelCountWhere($table, $where) { $query = $this->db2->get_where($table, $where); return $count = $query->num_rows(); //echo $this->db2->last_query(); die; } public function DeleteData($table,$where) { $query=$this->db2->delete($table, $where); if(!$query) { //redirect('welcome/errorpage'); show_error("ERROR", 500 ); exit; } } public function DetailData($table,$where,$order='NULL') { if($order != 'NULL'){ $this->db2->order_by($order); } $result=$this->db2->get_where($table, $where); if(!$result) { //redirect('welcome/errorpage'); show_error("ERROR", 500 ); exit; } return $result->result_array(); } public function UpdateData($table,$data,$where) { $dates=array('lasttime'=> date("Y-m-d H:i:s")); //$this->db2->update('lastmodifytime',$dates); $query=$this->db2->update($table, $data,$where); if(!$query) { //redirect('welcome/errorpage'); show_error("ERROR", 500 ); exit; } } public function generate_password($length = 8) { $chars = 'abcdefghijklmnopqrstuvwxyz'. '0123456789'; $str = ''; $max = strlen($chars) - 1; for ($i=0; $i < $length; $i++) $str .= $chars[mt_rand(0, $max)]; return $str; } public function decryptdata($sData) { $url_id=base64_decode($sData); $id=(double)$url_id/6752415; return $id; } public function encryptdata($sData) { $id=(double)$sData*6752415; return base64_encode($id); } public function sortingdata($selectdata,$table,$order) { $this->db2->select($selectdata); $this->db2->from($table); $this->db2->order_by($order); return $this->db2->get()->result_array(); } //=============== CREATED BY NIKITA PRAJAPATI ============================== public function sortingWheredata($selectdata,$table,$where,$order_id,$order) { //$this->db2->_protect_identifiers = FALSE; if($where!="null"){ $this->db2->where($where); } $sel=$this->db2->select($selectdata,false); $this->db2->from($table); $this->db2->order_by($order_id,$order); return $this->db2->get()->result_array(); } public function sortingWheredata_OR($selectdata,$table,$where,$order_id,$order) { if($where!="null"){ $this->db2->or_where($where); } $this->db2->select($selectdata,false); $this->db2->from($table); $this->db2->order_by($order_id,$order); return $this->db2->get()->result_array(); } public function LimitWheredata($selectdata,$table,$where,$order_id,$order,$lmt) { if($where!="null"){ $this->db2->where($where); } $this->db2->select($selectdata); $this->db2->from($table); $this->db2->order_by($order_id,$order); $this->db2->limit($lmt); return $this->db2->get()->result_array(); } public function containdetail($where) { $session_data=$this->session->all_userdata(); $lang=$session_data['flang']; $this->db2->order_by("menu_position", "asc"); $sel= $this->db2->select('*'); $this->db2->from($lang.'tblmenu'); $this->db2->where($where); $this->db2->join($lang.'tblcontent', $lang.'tblmenu.menu_content = '.$lang.'tblcontent.content_id','left'); $this->db2->join('tblbanners', 'tblbanners.banner_id ='.$lang.'tblcontent.banner_id','left'); return $this->db2->get()->result_array(); /* $query=$this->db2->get(); if(!$query) { //redirect('welcome/errorpage'); show_error("ERROR", 500 ); exit; } return $query->result_array(); */ } //page view in backend........... public function pagedetail($where) { $session_data=$this->session->all_userdata(); $lang=$session_data['flang']; $sel= $this->db2->select('*'); $this->db2->from($lang.'tblcontent'); $this->db2->where($where); $this->db2->join('tblbanners', 'tblbanners.banner_id ='.$lang.'tblcontent.banner_id','left'); return $this->db2->get()->result_array(); } public function portfolio_model($where='NULL'){ if($where!='NULL'){ $this->db2->where($where); } $this->db2->from('tbl_portfolio_category as p1'); $this->db2->join('tbl_port_sub_cat as p2', 'p2.pid = p1.portfolio_cat_id','left'); $this->db2->join('tbl_portfolio as p3', 'p3.port_sub_cat = p2.psid','left'); return $this->db2->get()->result_array(); } public function people_model($where='NULL'){ $this->db2->where($where); $this->db2->group_by('p1.port_sub_cat'); $this->db2->from('tbl_portfolio as p1'); $this->db2->join('tbl_portfolio_category as p2', 'p2.portfolio_cat_id = p1.portfolio_cat_id','left'); $this->db2->join('tbl_port_sub_cat as s2', 's2.psid = p1.port_sub_cat','left'); return $this->db2->get()->result_array(); } public function people_modelxxx($where='NULL'){ $session_data=$this->session->all_userdata(); $lang=$session_data['flang']; if($where!='NULL'){ $this->db2->where($where); } $this->db2->select('*, GROUP_CONCAT(p1.portfolio_name) as fname, GROUP_CONCAT(p1.portfolio_image_path) as i, GROUP_CONCAT(p1.prot_desc) as d'); //$this->db2->group_concat('p1.portfolio_name'); $this->db2->from($lang.'tbl_portfolio as p1'); $this->db2->group_by('p1.port_sub_cat'); $this->db2->join('tbl_portfolio_category as p2', 'p2.portfolio_cat_id = p1.portfolio_cat_id','left'); $this->db2->join('tbl_port_sub_cat as s2', 's2.psid = p1.port_sub_cat','left'); return $this->db2->get()->result_array(); } //send Feedb2ack email // /*public function emailsend($to,$sub,$msg) { $email_config = Array( 'protocol' => 'smtp', 'smtp_host' => 'mail.paperpush.com', 'smtp_port' => '26', 'smtp_user' => 'noreply@paperpush.com', 'smtp_pass' => '$12noreply34', 'mailtype' => 'html', 'starttls' => true, 'newline' => "\r\n" ); $this->load->library('email', $email_config); $this->email->set_header('MIME-Version', '1.0; charset=utf-8'); $this->email->set_header('Content-type', 'text/html'); $this->email->from('noreply@paperpush.com', 'PAPERPUSH'); $this->email->to($to); //$this->email->cc('teamleader@gmail.com'); //$this->email->cc('admin@gmail.com'); $this->email->subject($sub); $this->email->message($msg); $this->email->send(); //echo $this->email->print_debugger(); }*/ public function emailsend($to,$sub,$msg) { require_once(APPPATH . 'third_party/phpmailer/class.phpmailer.php'); require_once(APPPATH . 'third_party/phpmailer/class.smtp.php'); try { $mail = new PHPMailer(true); //New instance, with exceptions enabled $mail->IsSMTP(); // tell the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication //$mail->SMTPSecure = 'ssl'; $mail->Port = 26; // set the SMTP server port $mail->Host = "mail.paperpush.com"; // SMTP server $mail->Username = "noreply@paperpush.com"; // SMTP server username $mail->Password = "$12noreply34"; // SMTP server password //$mail->AddReplyTo($from,$email); $mail->From = "noreply@paperpush.com"; $mail->FromName = "PAPERPUSH"; $mail->AddAddress($to); $mail->Subject = $sub; $mail->WordWrap = 80; // set word wrap $mail->MsgHTML($msg); $mail->IsHTML(true); // send as HTML //$mail->SMTPDebug = 2; $sentmail = $mail->Send(); if ($sentmail) { //echo "email sent"; } else { //echo "Not sent" . $mail->ErrorInfo; } $mail->Timeout = 3600; // echo "<meta HTTP-EQUIV='REFRESH' content='0; url=../upload_resume.php?task=sent'>"; } catch (phpmailerException $e) { //$e->errorMessage(); } } /*public function emailsend_reg($to,$sub,$msg) { $email_config = Array( 'protocol' => 'smtp', 'smtp_host' => 'mail.paperpush.com', 'smtp_port' => '26', 'smtp_user' => 'noreply@paperpush.com', 'smtp_pass' => '$12noreply34', 'mailtype' => 'html', 'starttls' => true, 'newline' => "\r\n" ); $this->load->library('email', $email_config); $this->email->set_header('MIME-Version', '1.0; charset=utf-8'); $this->email->set_header('Content-type', 'text/html'); $this->email->from('noreply@paperpush.com', 'PAPERPUSH'); $this->email->to($to); //$this->email->cc('teamleader@gmail.com'); //$this->email->cc('admin@gmail.com'); $this->email->subject($sub); $this->email->message($msg); $this->email->send(); }*/ public function emailsend_reg($to,$sub,$msg) { require_once(APPPATH . 'third_party/phpmailer/class.phpmailer.php'); require_once(APPPATH . 'third_party/phpmailer/class.smtp.php'); try { $mail = new PHPMailer(true); //New instance, with exceptions enabled $mail->IsSMTP(); // tell the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication //$mail->SMTPSecure = 'ssl'; $mail->Port = 26; // set the SMTP server port $mail->Host = "mail.paperpush.com"; // SMTP server $mail->Username = "noreply@paperpush.com"; // SMTP server username $mail->Password = "$12noreply34"; // SMTP server password //$mail->AddReplyTo($from,$email); $mail->From = "noreply@paperpush.com"; $mail->FromName = "PAPERPUSH"; $mail->AddAddress($to); $mail->Subject = $sub; $mail->WordWrap = 80; // set word wrap $mail->MsgHTML($msg); $mail->IsHTML(true); // send as HTML //$mail->SMTPDebug = 2; $sentmail = $mail->Send(); if ($sentmail) { //echo "email sent"; } else { //echo "Not sent" . $mail->ErrorInfo; } $mail->Timeout = 3600; // echo "<meta HTTP-EQUIV='REFRESH' content='0; url=../upload_resume.php?task=sent'>"; } catch (phpmailerException $e) { //$e->errorMessage(); } } /*public function emailsend_reject($to,$sub,$msg) { $email_config = Array( 'protocol' => 'smtp', 'smtp_host' => 'mail.paperpush.com', 'smtp_port' => '26', 'smtp_user' => 'noreply@paperpush.com', 'smtp_pass' => '$12noreply34', 'mailtype' => 'html', 'starttls' => true, 'newline' => "\r\n" ); $this->load->library('email', $email_config); $this->email->set_header('MIME-Version', '1.0; charset=utf-8'); $this->email->set_header('Content-type', 'text/html'); $this->email->from('noreply@paperpush.com', 'PAPERPUSH'); $this->email->to($to); //$this->email->cc('teamleader@gmail.com'); //$this->email->cc('admin@gmail.com'); $this->email->subject($sub); $this->email->message($msg); $this->email->send(); }*/ public function emailsend_reject($to,$sub,$msg) { require_once(APPPATH . 'third_party/phpmailer/class.phpmailer.php'); require_once(APPPATH . 'third_party/phpmailer/class.smtp.php'); try { $mail = new PHPMailer(true); //New instance, with exceptions enabled $mail->IsSMTP(); // tell the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication //$mail->SMTPSecure = 'ssl'; $mail->Port = 26; // set the SMTP server port $mail->Host = "mail.paperpush.com"; // SMTP server $mail->Username = "noreply@paperpush.com"; // SMTP server username $mail->Password = "$12noreply34"; // SMTP server password //$mail->AddReplyTo($from,$email); $mail->From = "noreply@paperpush.com"; $mail->FromName = "PAPERPUSH"; $mail->AddAddress($to); $mail->Subject = $sub; $mail->WordWrap = 80; // set word wrap $mail->MsgHTML($msg); $mail->IsHTML(true); // send as HTML //$mail->SMTPDebug = 2; $sentmail = $mail->Send(); if ($sentmail) { //echo "email sent"; } else { //echo "Not sent" . $mail->ErrorInfo; } $mail->Timeout = 3600; // echo "<meta HTTP-EQUIV='REFRESH' content='0; url=../upload_resume.php?task=sent'>"; } catch (phpmailerException $e) { //$e->errorMessage(); } } public function emailsend2($to, $sub, $msg) { require_once(APPPATH . 'third_party/phpmailer/class.phpmailer.php'); require_once(APPPATH . 'third_party/phpmailer/class.smtp.php'); try { $mail = new PHPMailer(true); //New instance, with exceptions enabled $mail->IsSMTP(); // tell the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication //$mail->SMTPSecure = 'ssl'; $mail->Port = 26; // set the SMTP server port $mail->Host = "mail.paperpush.com"; // SMTP server $mail->Username = "noreply@paperpush.com"; // SMTP server username $mail->Password = "$12noreply34"; // SMTP server password //$mail->AddReplyTo($from,$email); $mail->From = "noreply@paperpush.com"; $mail->FromName = "PAPERPUSH"; $mail->AddAddress($to); $mail->Subject = $sub; $mail->WordWrap = 80; // set word wrap $mail->MsgHTML($msg); $mail->IsHTML(true); // send as HTML //$mail->SMTPDebug = 2; $sentmail = $mail->Send(); if ($sentmail) { //echo "email sent"; } else { //echo "Not sent" . $mail->ErrorInfo; } $mail->Timeout = 3600; // echo "<meta HTTP-EQUIV='REFRESH' content='0; url=../upload_resume.php?task=sent'>"; } catch (phpmailerException $e) { //$e->errorMessage(); } } public function pagesesstion() { //----- send link session ----- //set a 404 page if ($this->uri->segment(3) === FALSE){ $id=""; } else{ $id= urldecode($this->uri->segment(3)); } if($id!=""){ $where=array('slug'=>$id); $this->session->set_userdata('flang', ''); } } public function Captchaimage() { $randomnr = rand(1000, 9999); $this->session->set_userdata('ramdom',md5($randomnr)); $im = imagecreatetruecolor(100, 38); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 150, 150, 150); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 200, 35, $grey); //path to font - this is just an example you can use any font you like: $font ='fontcaptcha/arial.ttf'; imagettftext($im, 20, 4, 22, 30, $black, $font, $randomnr); imagettftext($im, 20, 4, 15, 32, $white, $font, $randomnr); //prevent caching on client side: header("Expires: Wed, 1 Jan 2997 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header ("Content-type: image/gif"); imagegif($im); imagedestroy($im); } public function menugroupdata($id){ $where1=array('menushortcode'=>$id); $view=$this->model->DetailData('tblmenugroup',$where1); $this->db2->order_by("menu_position", "asc"); $this->db2->select('*'); $this->db2->from('tblmenu'); $where= array('menugroup' => $view[0]['menugroup_id']); $this->db2->where($where); $this->db2->join('tblcontent', 'tblcontent.content_id = tblmenu.menu_content','left'); $this->db2->join('tblbanners', 'tblbanners.banner_id = tblcontent.banner_id','left'); return $qry=$this->db2->get()->result_array(); //echo "<pre>"; //print_r($qry); } public function setting_model($where='null',$order_by='null',$order='null'){ if($where!='null'){ $this->db2->where($where); } if($order_by!="null"){ $this->db2->order_by($order_by,$order); } $this->db2->from('tbl_other_detail as o1'); $this->db2->join('tblcontent as c', 'o1.other_link = c.content_id','left'); $query=$this->db2->get();//->result_array(); if(!$query) { show_error("ERROR", 500 ); exit; }else{ return $query->result_array(); } } public function chklogin_fun($email,$pwd){ return $this->db2->query("SELECT `cr_id` AS reg_id , `email_address`,password,activation_code,'tbl_candidate_registration' AS `tbl`,'cr_id' AS `id`,'candidate' AS type FROM `tbl_candidate_registration` where email_address='".$email."' AND password ='".$pwd."' UNION SELECT `r_id` AS reg_id , `email_address`,password,activation_code,'tbl_registation' AS `tbl`,'r_id' AS `id`,'family' AS type FROM tbl_registation where email_address='".$email."' AND password ='".$pwd."'")->result_array(); } public function getAccess($id){ $where = array('a.afrom' => $id); $this->db2->select('a.afrom, a.ato, a.folder, r.name, a.aid'); $this->db2->join('tbl_registration as r', 'r.rid = a.ato','left'); $query = $this->db2->get_where('tbl_access as a', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function officeModel($id){ $where = array('a.ato' => $id, 'a.folder !=' => ''); $this->db2->select('a.*, r.*'); $this->db2->join('tbl_registration as r', 'r.rid = a.afrom','left'); $query = $this->db2->get_where('tbl_access as a', $where)->result_array(); //echo $this->db2->last_query(); '<pre>'; print_r($query); die; return $query; } public function officeModelNoti($rid){ $where = array('a.ato' => $rid); $this->db2->order_by('a.id', 'DESC'); $this->db2->limit(25); $this->db2->select('a.id, a.afrom, a.ato, a.banned, a.given, a.status as sts, a.date, r.*'); $this->db2->join('tbl_registration as r', 'r.rid = a.afrom','left'); $query = $this->db2->get_where('tbl_access_notification as a', $where)->result_array(); //echo '<pre>'; print_r($query); die; return $query; } public function viewOfficeModel($id, $rid){ $where = array('r.rid' => $id, 'a.folder !=' => '', 'a.ato' => $rid); $this->db2->select('a.*, r.*'); $this->db2->join('tbl_access as a', 'a.afrom = r.rid','left'); $query = $this->db2->get_where('tbl_registration as r', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function office_form_data($fid){ $where = array('f.fid' => $fid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.*, i.*, r.name, r2.name as cname'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $this->db2->join('tbl_form_info as i', 'i.fid = f.fid','left'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function sales_form_data($fid){ $where = array('f.fid' => $fid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.*, i.*, r.name, r2.name as cname, l1.l_name as party_ledger, l2.l_name as sub_ledger'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $this->db2->join('tbl_ledger as l1', 'l1.lid = f.m_ledger_name'); $this->db2->join('tbl_form_info as i', 'i.fid = f.fid','left'); $this->db2->join('tbl_ledger as l2', 'l2.lid = i.s_ledger_name'); $result = $this->db2->get_where('tbl_form as f', $where)->result_array(); //echo $this->db2->last_query(); die; foreach ($result as $key => &$value) { $fiid = $value['fi_id']; $this->db2->select('e.*, e.eid as exp_id, o.*'); $this->db2->join('tbl_expense as e', 'e.eid = o.ex_name','left'); $sub = $this->db2->get_where('tbl_other_expens o', array('fi_id' => $fiid))->result_array(); $value['expenses'] = $sub; } return $result; } public function office_form_contra($fid){ $where = array('f.fid' => $fid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.*, r.name, r2.name as cname, l1.l_name as party_ledger, l2.l_name as sun_ledger'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $this->db2->join('tbl_ledger as l1', 'l1.lid = f.m_ledger_name'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function office_form_paymet($fid){ $where = array('f.fid' => $fid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.*, r.name, r2.name as cname, l1.l_name as party_ledger, l2.l_name as debit_ledger, l3.l_name as credit_ledger'); $this->db2->join('tbl_ledger as l1', 'l1.lid = f.m_ledger_name'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger_two'); $this->db2->join('tbl_ledger as l3', 'l3.lid = f.ms_ledger'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function office_form_credit($fid){ $where = array('f.fid' => $fid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.*, i.*'); $this->db2->join('tbl_form_info as i', 'i.fid = f.fid','left'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function of_cr($fid){ $where = array('f.fid' => $fid); $this->db2->select('f.*, r.name, r2.name as cname, l.l_name as party_ledger, l3.l_name as master_ledger'); $this->db2->join('tbl_ledger as l', 'l.lid = f.m_ledger_name','left'); $this->db2->join('tbl_ledger as l3', 'l3.lid = f.ms_ledger','left'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get_where('tbl_form as f', $where)->result_array(); //echo $this->db2->last_query(); die; foreach ($query as $key => &$value) { $f_id = $value['fid']; $this->db2->select('i.s_ledger_name, i.amt_taxable, l2.l_name as sub_ledger'); $this->db2->join('tbl_ledger as l2', 'l2.lid = i.s_ledger_name','left'); $sub = $this->db2->get_where('tbl_form_info i', array('fid' => $f_id))->result_array(); $value['info'] = $sub; } return $query; } public function office_form_receipt($fid){ $where = array('f.fid' => $fid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.*, r.name, r2.name as cname, l.l_name as party_ledger, l2.l_name as cr_ledger, l3.l_name as dr_ledger'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $this->db2->join('tbl_ledger as l', 'l.lid = f.m_ledger_name','left'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger','left'); $this->db2->join('tbl_ledger as l3', 'l3.lid = f.ms_ledger_two','left'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function office_form_journal($fid){ $where = array('f.fid' => $fid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.*, r.name, r2.name as cname, l.l_name as party_ledger, l2.l_name as cr_ledger, l3.l_name as dr_ledger'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $this->db2->join('tbl_ledger as l', 'l.lid = f.m_ledger_name','left'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger','left'); $this->db2->join('tbl_ledger as l3', 'l3.lid = f.ms_ledger_two','left'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function formNoti(){ $where = array('f.release_status' => 'released', 'f.approve_status' => 'panding', 'f.l_noti' => 'unseen'); $this->db2->select('f.fid, f.cid, f.oid, f.path, f.release_status, f.date_time, f.l_noti, r.name as oname, r2.name as cname'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid','left'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid','left'); $this->db2->order_by('f.fid', 'DESC'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function formNotiTwo(){ $where = array('release_status' => 'error', 'approve_status' => 'panding', 'f.l_noti' => 'unseen'); $this->db2->select('f.fid, f.cid, f.oid, f.path, f.release_status, f.date_time, f.l_noti, r.name as oname, r2.name as cname'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid','left'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid','left'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function formNotiOffice($rid){ $where = array('release_status' => 'error', 'approve_status' => 'panding', 'oid' => $rid); $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.fid, f.cid, f.oid, f.path, f.release_status, f.date_time, f.o_noti, f.note, f.stage, f.voucher_type, r.name as oname, r2.name as cname'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid','left'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid','left'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModel($limit, $offset, $sts="NULL"){ if($sts != 'NULL'){ if($sts == 'panding'){ $where = array('f.approve_status' => $sts, 'f.release_status !=' => 'error'); }else{ $where = array('f.approve_status' => $sts); } $this->db2->where($where); } $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r.mobile, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get('tbl_form as f', $limit, $offset); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModel2($id, $limit, $offset, $sts="NULL"){ if($sts != 'NULL'){ if($sts == 'panding'){ $where = array('oid' => $id, 'f.approve_status' => $sts, 'f.release_status !=' => 'error'); }else{ $where = array('oid' => $id, 'f.approve_status' => $sts); } $this->db2->where($where); }else{ $where = array('oid' => $id); } $this->db2->order_by('fid', 'DESC'); $this->db2->select('r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $query = $this->db2->get_where('tbl_form as f', $where, $limit, $offset); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModelRej($limit, $offset, $sts="NULL"){ if($sts != 'NULL'){ $where = array('f.release_status' => $sts); $this->db2->where($where); } $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r.mobile, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get('tbl_form as f', $limit, $offset); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModelRej2($id, $limit, $offset, $sts="NULL"){ if($sts != 'NULL'){ $where = array('oid' => $id, 'f.release_status' => $sts); $this->db2->where($where); }else{ $where = array('oid' => $id); } $this->db2->order_by('fid', 'DESC'); $this->db2->select('r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $query = $this->db2->get_where('tbl_form as f', $where, $limit, $offset); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModelDate($fdate, $tdate){ $fdate = date("Y-m-d", strtotime($fdate)); $tdate = date("Y-m-d", strtotime($tdate)); $this->db2->where('f.m_date >=', $fdate); $this->db2->where('f.m_date <=', $tdate); $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get('tbl_form as f'); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModelDate2($id, $fdate, $tdate){ //$where = array('oid' => $id); $fdate = date("Y-m-d", strtotime($fdate)); $tdate = date("Y-m-d", strtotime($tdate)); $this->db2->where('f.m_date >=', $fdate); $this->db2->where('f.m_date <=', $tdate); $this->db2->where('oid', $id); $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get('tbl_form as f'); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModelCustom($src){ $this->db2->like('voucher_no', $src); $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get('tbl_form as f'); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getFormModelCustom2($id, $src){ $this->db2->where('oid', $id); $this->db2->like('voucher_no', $src); $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get('tbl_form as f'); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getAjaxFormModel($limit, $offset, $type){ if($type != 'all'){ $where = array('approve_status' => $type); $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r.mobile, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get_where('tbl_form as f', $where, $limit, $offset); }else{ $this->db2->order_by('fid', 'DESC'); $this->db2->select('r.name, r.mobile, r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $this->db2->join('tbl_registration as r', 'r.rid = f.oid'); $query = $this->db2->get('tbl_form as f', $limit, $offset); } //echo $this->db2->last_query(); die; return $query->result_array(); } public function getAjaxFormModel2($id, $limit, $offset, $type){ if($type != 'all'){ $where = array('oid' => $id, 'approve_status' => $type); }else{ $where = array('oid' => $id); } $this->db2->order_by('fid', 'DESC'); $this->db2->select('r2.name as cname, f.*'); $this->db2->join('tbl_registration as r2', 'r2.rid = f.cid'); $query = $this->db2->get_where('tbl_form as f', $where, $limit, $offset); //echo $this->db2->last_query(); die; return $query->result_array(); } public function custUploads($rid){ $this->db2->select('a.*, b.name, b.folder_code'); $this->db2->from('cust_upload_notify as a'); $this->db2->where('a.n_to', $rid); $this->db2->where('a.status', '0'); $this->db2->order_by('a.n_id', 'DESC'); $this->db2->join('tbl_registration as b', 'b.rid = a.n_from', 'LEFT'); $query = $this->db2->get(); //echo $this->db2->last_query(); die; return $query->result_array(); } public function custUploads2($rid){ $this->db2->select('a.*, b.name, b.folder_code'); $this->db2->from('cust_upload_notify as a'); $this->db2->where('a.n_to', $rid); $this->db2->limit(10); $this->db2->order_by('a.n_id', 'DESC'); $this->db2->join('tbl_registration as b', 'b.rid = a.n_from', 'LEFT'); $query = $this->db2->get(); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getItemModel(){ $this->db2->order_by('i.id', 'DESC'); $this->db2->select('i.*, c.cname, g.gname'); $this->db2->from('tbl_item as i'); $this->db2->join('tbl_group as g', 'g.gid = i.gid', 'LEFT'); $this->db2->join('tbl_item_cat as c', 'c.cid = i.cid', 'LEFT'); $query = $this->db2->get(); //echo $this->db2->last_query(); die; return $query->result_array(); } Public function get_pagination($table, $limit, $offset) { $query = $this->db2->get($table, $limit, $offset); return $query->result_array(); } Public function get_pagination_where($table, $limit, $offset, $where) { $this->db2->select('*'); $this->db2->from($table); $this->db2->where($where); $this->db2->limit($limit, $offset); $query = $this->db2->get()->result_array(); //echo "<pre>"; //print_r($query); die; //echo $this->db2->last_query(); die; return $query; } public function getExcelData(){ $this->db2->order_by('f.fid', 'DESC'); $this->db2->select('f.fid, f.m_date, f.voucher_no, f.d, f.m, f.ref_no, f.m_ledger_name, f.m_effect, f.amt_gross'); $result = $this->db2->get('tbl_form as f')->result_array(); foreach ($result as $key => &$value) { $fid = $value['fid']; $this->db2->select('i.s_ledger_name, i.s_effect, i.amt_taxable'); $sub = $this->db2->get_where('tbl_form_info as i', array('fid' => $fid))->result_array(); foreach ($sub as $k => &$value1) { $name = "name_".$k; $eff = "eff_".$k; $taxable = "taxable_".$k; $value[$name] = $sub[$k]['s_ledger_name']; $value[$eff] = $sub[$k]['s_effect']; $value[$taxable] = $sub[$k]['amt_taxable']; } unset($value['fid']); } return $result; } public function sm($fid){ $where = array('a.fid' => $fid); $this->db2->select('a.*, l.*'); $this->db2->join('tbl_ledger as l', 'l.lid = a.m_ledger_name'); $query = $this->db2->get_where('tbl_form as a', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function salesModel($fid){ $where = array('a.fid' => $fid); $this->db2->select('a.amt_gross, b.amt_taxable, b.s_aot, b.c_aot, b.u_aot, b.i_aot, b.discount_two, c.item_name as item, c.cid, b.item_name,b.qty, b.rate, b.s_ledger_name,l.*'); $this->db2->join('tbl_form_info as b', 'b.fid = a.fid'); $this->db2->join('tbl_item as c', 'c.id = b.item_name'); $this->db2->join('tbl_ledger as l', 'l.lid = b.s_ledger_name'); $query = $this->db2->get_where('tbl_form as a', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function sales_two_model($fid){ $where = array('a.fid' => $fid); $this->db2->select('a.*, l.l_name as dr_ledger, b.*, l2.l_name as cr_ledger'); $this->db2->join('tbl_ledger as l', 'l.lid = a.m_ledger_name'); $this->db2->join('tbl_form_info as b', 'b.fid = a.fid'); $this->db2->join('tbl_ledger as l2', 'l2.lid = b.s_ledger_name'); $query = $this->db2->get_where('tbl_form as a', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function salesExpenseModel($fid){ $where = array('a.fid' => $fid); $this->db2->select('a.sgst, a.cgst, a.ugst,a.igst, b.*'); $this->db2->join('tbl_other_expens as b', 'b.fi_id = a.fi_id'); //$this->db2->join('tbl_expense as c', 'c.eid = b.eid'); $query = $this->db2->get_where('tbl_form_info as a', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function xml_contra($fid){ $where = array('f.fid' => $fid); $this->db2->select('f.*, l.l_name as party_ledger, l2.l_name as sub_ledger'); $this->db2->join('tbl_ledger as l', 'l.lid = f.m_ledger_name'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function xml_journal($fid){ $where = array('f.fid' => $fid); $this->db2->select('f.*, l.*, l2.l_name as l_name_one, l3.l_name as l_name_two'); $this->db2->join('tbl_ledger as l', 'l.lid = f.m_ledger_name'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger'); $this->db2->join('tbl_ledger as l3', 'l3.lid = f.ms_ledger_two'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function xml_credit_one($fid){ $where = array('f.fid' => $fid); $this->db2->select('f.*, l.*, l2.l_name as l_name_one'); $this->db2->join('tbl_ledger as l', 'l.lid = f.m_ledger_name'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger');; $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function xml_credit_two($fid){ $where = array('f.fid' => $fid); $this->db2->select('f.*'); //$this->db2->join('tbl_ledger as l', 'l.lid = f.s_ledger_name'); ,l.l_name as debit_ledger $result = $this->db2->get_where('tbl_form_info as f', $where)->result_array(); //echo $this->db2->last_query(); die; foreach ($result as $key => &$value) { $sln = $value['s_ledger_name']; $this->db2->select('l.l_name'); $sub = $this->db2->get_where('tbl_ledger l', array('lid' => $sln))->result_array(); $value['debit_ledger'] = $sub[0]['l_name']; } return $result; } public function xml_debit_one($fid){ $where = array('f.fid' => $fid); $this->db2->select('f.*, l.*, l2.l_name as l_name_one'); $this->db2->join('tbl_ledger as l', 'l.lid = f.m_ledger_name'); $this->db2->join('tbl_ledger as l2', 'l2.lid = f.ms_ledger'); $query = $this->db2->get_where('tbl_form as f', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function xml_debit_two($fid){ $where = array('f.fid' => $fid); $this->db2->select('f.*'); //$this->db2->join('tbl_ledger as l', 'l.lid = f.s_ledger_name'); ,l.l_name as debit_ledger $result = $this->db2->get_where('tbl_form_info as f', $where)->result_array(); //echo $this->db2->last_query(); die; foreach ($result as $key => &$value) { $sln = $value['s_ledger_name']; $this->db2->select('l.l_name'); $sub = $this->db2->get_where('tbl_ledger l', array('lid' => $sln))->result_array(); $value['credit_ledger'] = $sub[0]['l_name']; } return $result; } public function availFile($path){ $where = array('path' => $path); $query = $this->db2->get_where('tbl_form_status', $where); //echo $this->db2->last_query(); die; return $query->result_array(); } public function getGenXML($limit, $offset){ $this->db2->select('a.*, b.name'); $this->db2->order_by('x_id', 'DESC'); $this->db2->join('tbl_registration as b', 'b.rid = a.x_by'); $query = $this->db2->get('tbl_xml as a', $limit, $offset)->result_array(); return $query; } /*public function getGroupedVoucher(){ $this->db2->select('gv.*, r.name'); $this->db2->join('tbl_registration as r', 'r.rid = gv.updated_by', 'left'); $query = $this->db2->get('tbl_grouped_voucher as gv')->result_array(); foreach ($query as $key => &$value) { $gr = explode('|', $value['gid']); if($value['gid'] != ''){ foreach ($gr as $key => &$v) { $gid = $v; $this->db2->select('gname'); $group = $this->db2->get_where('tbl_group', array('gid' => $gid))->result_array(); $temp = []; if(!empty($group)){ $temp['gname'] = $group[0]['gname']; } $gr[$key] = $temp; } $value['group'] = $gr; } } return $query; } */ public function getGroupedVoucher(){ $this->db2->select('gv.*, r.name, c.gname, d.sg_name'); $this->db2->join('tbl_registration as r', 'r.rid = gv.updated_by', 'left'); $this->db2->join('tbl_group as c', 'c.gid = gv.gid', 'LEFT'); $this->db2->join('tbl_subgroup as d', 'd.sg_id = gv.sg_id', 'LEFT'); $query = $this->db2->get('tbl_grouped_voucher as gv')->result_array(); return $query; } /*public function getLedger($limit, $offset){ $this->db2->select('l.*, b.name as cust_name'); $this->db2->order_by("l.lid", "DESC"); $this->db2->join('tbl_registration as b', 'b.rid = l.rid', 'LEFT'); $query = $this->db2->get('tbl_ledger as l', $limit, $offset)->result_array(); foreach ($query as $key => &$value) { $gr = explode(',', $value['gid']); if($value['gid'] != ''){ foreach ($gr as $key => &$v) { $gid = $v; $this->db2->select('gname'); $group = $this->db2->get_where('tbl_group', array('gid' => $gid))->result_array(); $temp = []; if(!empty($group)){ $temp['gname'] = $group[0]['gname']; } $gr[$key] = $temp; } $value['group'] = $gr; } } echo "<pre>"; print_r ($query); echo "</pre>"; die; return $query; }*/ /* public function getLedger($limit, $offset){ $this->db2->select('l.*, b.name as cust_name, c.gname, d.sg_name'); $this->db2->order_by("l.lid", "DESC"); $this->db2->join('tbl_registration as b', 'b.rid = l.rid', 'LEFT'); $this->db2->join('tbl_group as c', 'c.gid = l.gid', 'LEFT'); $this->db2->join('tbl_subgroup as d', 'd.sg_id = l.sg_id', 'LEFT'); $query = $this->db2->get('tbl_ledger as l', $limit, $offset)->result_array(); /*foreach ($query as $key => &$value) { $gr = explode(',', $value['gid']); if($value['gid'] != ''){ foreach ($gr as $key => &$v) { $gid = $v; $this->db2->select('gname'); $group = $this->db2->get_where('tbl_group', array('gid' => $gid))->result_array(); $temp = []; if(!empty($group)){ $temp['gname'] = $group[0]['gname']; } $gr[$key] = $temp; } $value['group'] = $gr; } }*/ //echo "<pre>"; print_r ($query); echo "</pre>"; die; //return $query; //} public function getLedger($limit, $offset){ $this->db2->select('a.rid, a.name, a.email, a.mobile, a.gst, a.pan, a.rid'); $this->db2->where('a.type', 'customer'); $this->db2->order_by("a.rid", "DESC"); $query = $this->db2->get('tbl_registration as a', $limit, $offset)->result_array(); foreach ($query as $k => &$v) { $ledger_count = $this->db2->get_where('tbl_ledger', array('rid' => $v['rid']))->num_rows(); $v['ledger_count'] = $ledger_count; } //echo "<pre>"; print_r ($query); echo "</pre>"; die; return $query; } public function getLedgerView($rid, $limit, $offset){ $this->db2->select('a.*,c.gname, d.sg_name'); $this->db2->where("a.rid", $rid); $this->db2->order_by("a.rid", "DESC"); $this->db2->join('tbl_group as c', 'c.gid = a.gid', 'LEFT'); $this->db2->join('tbl_subgroup as d', 'd.sg_id = a.sg_id', 'LEFT'); $query = $this->db2->get('tbl_ledger as a', $limit, $offset)->result_array(); //echo "<pre>"; print_r ($query); echo "</pre>"; die; return $query; } public function getLedgerXml($rid){ $this->db2->select('a.*,c.gname, d.sg_name'); $this->db2->where("a.rid", $rid); $this->db2->order_by("a.rid", "DESC"); $this->db2->join('tbl_group as c', 'c.gid = a.gid', 'LEFT'); $this->db2->join('tbl_subgroup as d', 'd.sg_id = a.sg_id', 'LEFT'); $query = $this->db2->get('tbl_ledger as a')->result_array(); //echo "<pre>"; print_r ($query); echo "</pre>"; die; return $query; } public function getFormStatus($where){ $this->db2->where($where); $this->db2->select('fs.*, r.name'); $this->db2->join('tbl_registration as r', 'r.rid = fs.oid'); $query = $this->db2->get('tbl_form_status as fs')->result_array(); return $query; } public function selGroup_x($where){ $this->db2->select('gv.*'); $this->db2->where($where); $query = $this->db2->get('tbl_grouped_voucher as gv')->result_array(); foreach ($query as $key => &$value) { $gr = explode('|', $value['gid']); if($value['gid'] != ''){ foreach ($gr as $key => &$v) { $gid = $v; $this->db2->select('gname, gid'); $group = $this->db2->get_where('tbl_group', array('gid' => $gid))->result_array(); $temp = []; if(!empty($group)){ $temp['gname'] = $group[0]['gname']; $temp['gid'] = $group[0]['gid']; } $gr[$key] = $temp; } $value['group'] = $gr; } } return $query[0]['group']; } public function selGroup($where, $cid){ $this->db2->select('a.*'); $this->db2->from('tbl_grouped_voucher as a'); $this->db2->where($where); $query = $this->db2->get()->result_array(); if(!empty($query)){ $sub_arr = []; $main_arr = []; foreach ($query as $key => $value) { $gid = $value['gid']; $sg_id = $value['sg_id']; if($sg_id != 0){ $where_sgid = array('b.sg_id' => $sg_id, 'b.rid' => $cid); $this->db2->select('b.*'); $this->db2->from('tbl_ledger as b'); $this->db2->where($where_sgid); $sub_arr[] = $this->db2->get()->result_array(); }else{ $where_gid = array('c.gid' => $gid, 'c.rid' => $cid); $this->db2->select('c.*'); $this->db2->from('tbl_ledger as c'); $this->db2->where($where_gid); $main_arr[] = $this->db2->get()->result_array(); } } $sub2 = []; if(!empty($sub_arr)){ $sub2 = []; foreach ($sub_arr as $key => $value) { foreach ($value as $k => $v) { $sub2[] = $v; } } } $main2 = []; if(!empty($main_arr)){ $main2 = []; foreach ($main_arr as $key => $value) { foreach ($value as $k => $v) { $main2[] = $v; } } } //echo "<pre>"; print_r ($sub2); echo "</pre>"; //echo "<pre>"; print_r ($main2); echo "</pre>"; $arr = array_merge($sub2, $main2); $result = array(); foreach ($arr as $key => $value){ if(!in_array($value, $result)) $result[$key]=$value; } //echo "<pre>"; print_r ($query); echo "</pre>"; die; $query = $arr; //echo "<pre>"; print_r ($query); echo "</pre>"; die; }else{ $query = []; } //echo "<pre>"; print_r ($query); echo "</pre>"; die; return $query; } public function maxId($table, $id){ //$maxid = $this->db->query('SELECT MAX($id) AS `maxid` FROM $table')->row()->maxid; $this->db2->select("MAX($id) as maxid"); $this->db2->from($table); $max = $this->db2->get()->row('maxid'); //echo $this->db2->last(); return $max; } public function get_unit($id){ $this->db2->where('i.id', $id); $this->db2->select('i.*, u.*'); $this->db2->join('tbl_unit as u', 'u.uid = i.uid'); $this->db2->from('tbl_item as i'); return $this->db2->get()->result_array(); } public function get_gl($gid, $rid){ //select * from tbl_ledger where find_in_set('5', cast(gid as char)) > 0 OR find_in_set('6', cast(gid as char)) > 0 OR find_in_set('10', cast(gid as char)) > 0 $temp = ""; foreach ($gid as $key => $value) { $temp.="find_in_set('".$value."', cast(gid as char)) > 0 OR "; } $trim = rtrim($temp,'OR '); $trim = "rid = ".$rid." AND (".$trim.")"; $this->db2->select('*'); $this->db2->from('tbl_ledger'); $this->db2->where($trim); $data = $this->db2->get()->result_array(); //echo $this->db2->last_query(); return $data; } public function getFormLedger($cid){ $this->db2->where('a.rid', $cid); $this->db2->select('a.*'); $this->db2->from('tbl_ledger as a'); $query = $this->db2->get()->result_array(); //echo "<pre>"; print_r ($query); echo "</pre>"; die; return $query; } public function getGroupID($group){ $this->db2->where('a.gname', $group); $this->db2->select('a.gid'); $this->db2->from('tbl_group as a'); $query = $this->db2->get()->row('gid'); return $query; } public function getSubGroupID($sub_group){ $this->db2->where('a.sg_name', $sub_group); $this->db2->select('a.sg_id'); $this->db2->from('tbl_subgroup as a'); $query = $this->db2->get()->row('sg_id'); return $query; } public function get_cust_data($table,$where,$limit, $start){ $this->db2->select('*'); $this->db2->from($table); $this->db2->where($where); $this->db2->order_by('cu_id', 'DESC'); $this->db2->limit($limit, $start); $query = $this->db2->get()->result_array(); return $query; } public function search_cust_file($where,$limit,$start){ $rid = $where['cu_from']; $year = $where['year']; $month = $where['month']; $stage = $where['stage']; $kword = $where['search']; $status = $where['status']; $this->db2->where('cu_from', $rid); $this->db2->where('year', $year); $this->db2->where('month', $month); $this->db2->where('stage', $stage); $this->db2->where('trash', '0'); if($status != 'all'){ $this->db2->where('file_status', $status); } if($kword != null && $kword != ''){ $this->db2->where("(`file_name` LIKE '%$kword%')"); } $this->db2->select('*'); $this->db2->from('cust_upload'); $this->db2->order_by('cu_id', "DESC"); if($limit !=NULL && $start != NULL){ $this->db2->limit($limit, $start); } $query = $this->db2->get()->result_array(); //echo $this->db2->last_query(); die; return $query; } public function search_cust_file2($where,$limit,$start){ $code = $where['code']; $year = $where['year']; $month = $where['month']; $stage = $where['stage']; $kword = $where['search']; $status = $where['status']; $this->db2->where('code', $code); $this->db2->where('year', $year); $this->db2->where('month', $month); $this->db2->where('stage', $stage); $this->db2->where('trash', '0'); if($status != 'all'){ $this->db2->where('file_status', $status); } if($kword != null && $kword != ''){ $this->db2->where("(`file_name` LIKE '%$kword%')"); } $this->db2->select('*'); $this->db2->from('cust_upload'); $this->db2->order_by('cu_id', "DESC"); if($limit !=NULL && $start != NULL){ $this->db2->limit($limit, $start); } $query = $this->db2->get()->result_array(); //echo $this->db2->last_query(); die; return $query; } public function uploadNotiAdmin(){ $this->db2->select('a.*, b.name'); $this->db2->join('tbl_registration as b', 'b.rid = a.cu_from'); $this->db2->from('cust_upload_notify_admin as a'); $this->db2->order_by('a.cu_id', 'DESC'); $this->db2->limit(10); return $this->db2->get()->result_array(); } }
Copyright ©2021 || Defacer Indonesia