2012-04-07 16:36:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Cat extends CI_Model {
|
|
|
|
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
// Call the Model constructor
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
function update($result) {
|
|
|
|
|
|
|
|
$this->db->where('radio', $result['radio']);
|
|
|
|
$query = $this->db->get('cat');
|
|
|
|
|
|
|
|
if ($query->num_rows() > 0)
|
|
|
|
{
|
2016-11-16 16:59:53 +00:00
|
|
|
if($result['radio'] == "SatPC32") {
|
|
|
|
// Update the record
|
|
|
|
foreach ($query->result() as $row)
|
|
|
|
{
|
|
|
|
$radio_id = $row->id;
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'sat_name' => $result['sat_name'],
|
|
|
|
'downlink_freq' => $result['downlink_freq'],
|
|
|
|
'uplink_freq' => $result['uplink_freq'],
|
|
|
|
'downlink_mode' => $result['downlink_mode'],
|
|
|
|
'uplink_mode' => $result['uplink_mode'],
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->db->where('id', $radio_id);
|
|
|
|
$this->db->update('cat', $data);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Update the record
|
|
|
|
foreach ($query->result() as $row)
|
|
|
|
{
|
|
|
|
$radio_id = $row->id;
|
2012-04-07 16:36:38 +00:00
|
|
|
|
2016-11-16 16:59:53 +00:00
|
|
|
$data = array(
|
|
|
|
'frequency' => $result['frequency'],
|
|
|
|
'mode' => $result['mode'],
|
|
|
|
);
|
2012-04-07 16:36:38 +00:00
|
|
|
|
2016-11-16 16:59:53 +00:00
|
|
|
$this->db->where('id', $radio_id);
|
|
|
|
$this->db->update('cat', $data);
|
|
|
|
}
|
2012-04-07 16:36:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Add a new record
|
|
|
|
|
2016-11-16 16:59:53 +00:00
|
|
|
if($result['radio'] == "SatPC32") {
|
|
|
|
$data = array(
|
|
|
|
'radio' => $result['radio'],
|
|
|
|
'frequency' => $result['frequency'],
|
|
|
|
'mode' => $result['mode'],
|
|
|
|
'sat_name' => $result['sat_name'],
|
|
|
|
'downlink_freq' => $result['downlink_freq'],
|
|
|
|
'uplink_freq' => $result['uplink_freq'],
|
|
|
|
'downlink_mode' => $result['downlink_mode'],
|
|
|
|
'uplink_mode' => $result['uplink_mode'],
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$data = array(
|
|
|
|
'radio' => $result['radio'],
|
|
|
|
'frequency' => $result['frequency'],
|
|
|
|
'mode' => $result['mode']
|
|
|
|
);
|
|
|
|
}
|
2012-04-07 16:36:38 +00:00
|
|
|
|
|
|
|
$this->db->insert('cat', $data);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-12-10 15:51:41 +00:00
|
|
|
|
2012-04-07 16:36:38 +00:00
|
|
|
|
|
|
|
function status() {
|
2012-04-08 12:17:14 +00:00
|
|
|
//$this->db->where('radio', $result['radio']);
|
|
|
|
$query = $this->db->get('cat');
|
2012-04-07 16:36:38 +00:00
|
|
|
|
2012-04-08 15:47:18 +00:00
|
|
|
return $query;
|
2012-04-07 16:36:38 +00:00
|
|
|
}
|
|
|
|
|
2012-04-08 12:17:14 +00:00
|
|
|
/* Return list of radios */
|
|
|
|
function radios() {
|
|
|
|
$this->db->select('id, radio');
|
|
|
|
$query = $this->db->get('cat');
|
|
|
|
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
2019-09-06 15:55:13 +00:00
|
|
|
|
|
|
|
function radio_status($id) {
|
2020-05-12 21:51:56 +00:00
|
|
|
|
|
|
|
return $this->db->query('SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE 1');
|
|
|
|
|
2019-09-06 15:55:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-13 20:14:39 +00:00
|
|
|
function delete($id) {
|
|
|
|
$this->db->where('id', $id);
|
|
|
|
$this->db->delete('cat');
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-08 12:17:14 +00:00
|
|
|
|
|
|
|
|
2012-04-07 16:36:38 +00:00
|
|
|
}
|
|
|
|
?>
|