mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
First working Version with CL-Download to users
This commit is contained in:
@@ -65,33 +65,30 @@ class Clublog extends CI_Controller {
|
||||
$this->load->helper('file');
|
||||
|
||||
$this->load->model('clublog_model');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$station_profiles = $this->clublog_model->all_enabled($clean_userid);
|
||||
|
||||
if($station_profiles->num_rows()){
|
||||
$station_profiles = $this->clublog_model->all_enabled($clean_userid); // Fetch unique Calls per User with aggregated station_ids
|
||||
if ($station_profiles->num_rows()) {
|
||||
foreach ($station_profiles->result() as $station_row) {
|
||||
if($station_row->qso_total > 0) {
|
||||
$lastrec=$this->clublog_model->clublog_last_qsl_rcvd_date($station_row->station_callsign);
|
||||
$url='https://clublog.org/getmatches.php?api=608df94896cb9c5421ae748235492b43815610c9&email='.$clean_username.'&password='.$clean_password.'&callsign='.$station_row->station_callsign.'&startyear='.substr($lastrec,0,4).'&startmonth='.substr($lastrec,4,2).'&startday='.substr($lastrec,6,2);
|
||||
$request = curl_init($url);
|
||||
$lastrec=$this->clublog_model->clublog_last_qsl_rcvd_date($station_row->station_callsign);
|
||||
$url='https://clublog.org/getmatches.php?api=608df94896cb9c5421ae748235492b43815610c9&email='.$clean_username.'&password='.$clean_password.'&callsign='.$station_row->station_callsign.'&startyear='.substr($lastrec,0,4).'&startmonth='.substr($lastrec,4,2).'&startday='.substr($lastrec,6,2);
|
||||
$request = curl_init($url);
|
||||
|
||||
// recieve a file
|
||||
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($request);
|
||||
$info = curl_getinfo($request);
|
||||
curl_close ($request);
|
||||
// recieve a file
|
||||
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($request);
|
||||
$info = curl_getinfo($request);
|
||||
curl_close ($request);
|
||||
|
||||
if(curl_errno($request)) {
|
||||
echo curl_error($request);
|
||||
} else {
|
||||
$cl_qsls=json_decode($response);
|
||||
var_dump($cl_qsls);
|
||||
// todo: iterate
|
||||
// todo: transform plain band to real_band // no way to do that, so fallback to "like". e.g.: "6" was provided by Clublog. Do they mean 6m or 6cm?
|
||||
$this->logbook_model->clublog_update($oneqsl[2], $onesql[0], $onesql[3], 'Y', $station_row->station_callsign);
|
||||
if(curl_errno($request)) {
|
||||
echo curl_error($request);
|
||||
} else {
|
||||
$cl_qsls=json_decode($response);
|
||||
foreach ($cl_qsls as $oneqsl) {
|
||||
$this->logbook_model->clublog_update($oneqsl[2], $oneqsl[0], $oneqsl[3], 'Y', $station_row->station_callsign, $station_row->station_ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,13 +105,12 @@ class Clublog_model extends CI_Model {
|
||||
}
|
||||
|
||||
function all_enabled($userid) {
|
||||
$this->db->select('station_profile.station_id, station_profile.station_callsign, count('.$this->config->item('table_name').'.station_id) as qso_total');
|
||||
$this->db->from('station_profile');
|
||||
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left');
|
||||
$this->db->group_by('station_profile.station_id');
|
||||
$this->db->where('station_profile.user_id', $userid);
|
||||
$this->db->where('station_profile.clublogignore', 0);
|
||||
return $this->db->get();
|
||||
$sql="select sp.station_callsign, group_concat(sp.station_id) as station_ids from station_profile sp
|
||||
inner join users u on (u.user_id=sp.user_id)
|
||||
where u.user_clublog_name is not null and u.user_clublog_password is not null and sp.clublogignore=0 and u.user_id=?
|
||||
group by sp.station_callsign";
|
||||
$query = $this->db->query($sql,$userid);
|
||||
return $query;
|
||||
}
|
||||
|
||||
function all_with_count($userid) {
|
||||
|
||||
@@ -3209,19 +3209,21 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray =
|
||||
}
|
||||
}
|
||||
|
||||
function clublog_update($datetime, $callsign, $band, $qsl_status, $station_callsign) {
|
||||
function clublog_update($datetime, $callsign, $band, $qsl_status, $station_callsign, $station_ids) {
|
||||
|
||||
$logbooks_locations_array=explode(",",$station_ids);
|
||||
$data = array(
|
||||
'COL_CLUBLOG_QSO_DOWNLOAD_DATE' => date('Y-m-d'),
|
||||
'COL_CLUBLOG_QSO_DOWNLOAD_STATUS' => $qsl_status,
|
||||
);
|
||||
|
||||
$this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"');
|
||||
$this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i:%s\') = "'.$datetime.'"');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$this->db->where('COL_BAND', $band);
|
||||
$this->db->where("replace(replace(COL_BAND,'cm',''),'m','')", $band); // no way to achieve a real bandmatch, so fallback to match without unit. e.g.: "6" was provided by Clublog. Do they mean 6m or 6cm?
|
||||
$this->db->where('COL_STATION_CALLSIGN', $station_callsign);
|
||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||
|
||||
if ($this->db->update($this->config->item('table_name'), $data)) {
|
||||
if ($this->db->update($this->config->item('table_name'). ' use index (idx_HRD_COL_CALL_station_id)', $data)) {
|
||||
unset($data);
|
||||
return "Updated";
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user