File: /var/www/html/nt/application/models/admin/Mmodule.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mmodule extends CI_Model {
public function __construct() {
parent::__construct();
}
public function get_active_parks() {
// Select active industrial parks from the database
$this->db->select('industrial_park_id, park_name');
$this->db->where('is_active', 1);
$query = $this->db->get('industrial_park_master');
// Return the result as an array
return $query->result_array();
}
public function saveModule($data) {
$this->db->insert('module_master', $data);
return $this->db->insert_id();
}
public function getModuleData() {
// Select required fields from plot_header and industrial_park_master tables
$this->db->select('module_master.*, industrial_park_master.park_name');
$this->db->from('module_master');
$this->db->join('industrial_park_master', 'module_master.industrial_park_id = industrial_park_master.industrial_park_id');
$this->db->order_by('module_master.module_id', 'DESC');
// Get plot data
$query = $this->db->get();
// Return results as array
return $query->result_array();
}
public function getmoduleDetails($moduleId) {
// Join plot_header with industrial_park_master to get park_name
$this->db->select('module_master.*, industrial_park_master.park_name,uom_master.name as uom_name');
$this->db->from('module_master');
$this->db->join('industrial_park_master', 'module_master.industrial_park_id = industrial_park_master.industrial_park_id');
$this->db->join('uom_master', 'module_master.uom_id = uom_master.uom_id');
$this->db->where('module_master.module_id', $moduleId);
$plotDetails = $this->db->get()->row_array();
return $plotDetails;
}
public function updateModule($moduleId, $moduleHeaderData) {
// Update plot header details with the specified plot header ID
$this->db->where('module_id', $moduleId);
$this->db->update('module_master', $moduleHeaderData);
}
}