mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-28 01:30:27 +00:00
Merge pull request #2260 from int2001/hrdlog
This one adds HRDLog-Support to Cloudlog
This commit is contained in:
@@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
|
||||
| be upgraded / downgraded to.
|
||||
|
|
||||
*/
|
||||
$config['migration_version'] = 126;
|
||||
$config['migration_version'] = 127;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -206,7 +206,7 @@ class adif extends CI_Controller {
|
||||
|
||||
|
||||
$custom_errors .= $this->logbook_model->import($record, $this->input->post('station_profile'),
|
||||
$this->input->post('skipDuplicate'), $this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), true, $this->input->post('operatorName'));
|
||||
$this->input->post('skipDuplicate'), $this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), $his->input->post('markHrd'), true, $this->input->post('operatorName'));
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -461,9 +461,9 @@ class API extends CI_Controller {
|
||||
|
||||
|
||||
if(isset($obj['station_profile_id'])) {
|
||||
$this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, false, false, true);
|
||||
$this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, NULL, false, false, true);
|
||||
} else {
|
||||
$this->logbook_model->import($record, 0, NULL, NULL, NULL, NULL, false, false, true);
|
||||
$this->logbook_model->import($record, 0, NULL, NULL, NULL, NULL, NULL, false, false, true);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
171
application/controllers/Hrdlog.php
Normal file
171
application/controllers/Hrdlog.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
Controller to interact with the hrdlog.net API
|
||||
*/
|
||||
|
||||
class Hrdlog extends CI_Controller {
|
||||
|
||||
/*
|
||||
* Upload QSO to hrdlog.net
|
||||
* When called from the url cloudlog/hrdlog/upload, the function loops through all station_id's with a hrdlog code defined.
|
||||
* All QSOs not previously uploaded, will then be uploaded, one at a time
|
||||
*/
|
||||
public function upload() {
|
||||
$this->setOptions();
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$station_ids = $this->logbook_model->get_station_id_with_hrdlog_code();
|
||||
|
||||
if ($station_ids) {
|
||||
foreach ($station_ids as $station) {
|
||||
$hrdlog_code = $station->hrdlog_code;
|
||||
if($this->mass_upload_qsos($station->station_id, $hrdlog_code)) {
|
||||
echo "QSOs have been uploaded to hrdlog.net.";
|
||||
log_message('info', 'QSOs have been uploaded to hrdlog.net.');
|
||||
} else{
|
||||
echo "No QSOs found for upload.";
|
||||
log_message('info', 'No QSOs found for upload.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "No station profiles with a hrdlog Code found.";
|
||||
log_message('error', "No station profiles with a hrdlog Code found.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setOptions() {
|
||||
$this->config->load('config');
|
||||
ini_set('memory_limit', '-1');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function gets all QSOs from given station_id, that are not previously uploaded to hrdlog.
|
||||
* Adif is build for each qso, and then uploaded, one at a time
|
||||
*/
|
||||
function mass_upload_qsos($station_id, $hrdlog_code) {
|
||||
$i = 0;
|
||||
$data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id);
|
||||
$errormessages=array();
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AdifHelper');
|
||||
|
||||
if ($data['qsos']) {
|
||||
foreach ($data['qsos']->result() as $qso) {
|
||||
$adif = $CI->adifhelper->getAdifLine($qso);
|
||||
|
||||
if ($qso->COL_HRDLOG_QSO_UPLOAD_STATUS == 'M') {
|
||||
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif, true);
|
||||
} else {
|
||||
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif);
|
||||
}
|
||||
|
||||
if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate')) ){
|
||||
$this->markqso($qso->COL_PRIMARY_KEY);
|
||||
$i++;
|
||||
} elseif ((substr($result['status'],0,11) == 'auth_error')) {
|
||||
log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON);
|
||||
log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']);
|
||||
log_message('error', 'hrdlog upload stopped for Station_ID: ' .$station_id);
|
||||
$errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
|
||||
break; /* If key is invalid, immediate stop syncing for more QSOs of this station */
|
||||
} else {
|
||||
log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON);
|
||||
log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']);
|
||||
$errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
|
||||
}
|
||||
}
|
||||
$result['status'] = 'OK';
|
||||
$result['count'] = $i;
|
||||
$result['errormessages'] = $errormessages;
|
||||
return $result;
|
||||
} else {
|
||||
$result['status'] = 'Error';
|
||||
$result['count'] = $i;
|
||||
$result['errormessages'] = $errormessages;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function marks QSO with given primarykey as uploaded to hrdlog
|
||||
*/
|
||||
function markqso($primarykey) {
|
||||
$this->logbook_model->mark_hrdlog_qsos_sent($primarykey);
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for displaying the uid for manually selecting log for upload to hrdlog
|
||||
*/
|
||||
public function export() {
|
||||
$this->load->model('stations');
|
||||
|
||||
$data['page_title'] = "HRDlog.net Logbook";
|
||||
|
||||
$data['station_profiles'] = $this->stations->all_of_user();
|
||||
$data['station_profile'] = $this->stations->stations_with_hrdlog_code();
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('hrdlog/export');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for ajax-function when selecting log for upload to hrdlog
|
||||
*/
|
||||
public function upload_station() {
|
||||
$this->setOptions();
|
||||
$this->load->model('stations');
|
||||
|
||||
$postData = $this->input->post();
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$result = $this->logbook_model->exists_hrdlog_code($postData['station_id']);
|
||||
$hrdlog_code = $result->hrdlog_code;
|
||||
header('Content-type: application/json');
|
||||
$result = $this->mass_upload_qsos($postData['station_id'], $hrdlog_code);
|
||||
if ($result['status'] == 'OK') {
|
||||
$stationinfo = $this->stations->stations_with_hrdlog_code();
|
||||
$info = $stationinfo->result();
|
||||
|
||||
$data['status'] = 'OK';
|
||||
$data['info'] = $info;
|
||||
$data['infomessage'] = $result['count'] . " QSOs are now uploaded to hrdlog";
|
||||
$data['errormessages'] = $result['errormessages'];
|
||||
echo json_encode($data);
|
||||
} else {
|
||||
$data['status'] = 'Error';
|
||||
$data['info'] = 'Error: No QSOs found to upload.';
|
||||
$data['errormessages'] = $result['errormessages'];
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function mark_hrdlog() {
|
||||
// Set memory limit to unlimited to allow heavy usage
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
||||
|
||||
$this->load->model('adif_data');
|
||||
|
||||
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id);
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
foreach ($data['qsos']->result() as $qso)
|
||||
{
|
||||
$this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY);
|
||||
}
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('hrdlog/mark_hrdlog', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
}
|
||||
@@ -505,7 +505,7 @@ class Lotw extends CI_Controller {
|
||||
$station_id = $this->logbook_model->find_correct_station_id($record['station_callsign'], $record['my_gridsquare']);
|
||||
|
||||
if ($station_id != NULL) {
|
||||
$result = $this->logbook_model->import($record, $station_id, NULL, TRUE, NULL, NULL, true, false); // Create the Entry
|
||||
$result = $this->logbook_model->import($record, $station_id, NULL, TRUE, NULL, NULL, NULL, true, false); // Create the Entry
|
||||
if ($result == "") {
|
||||
$lotw_status = 'QSO imported';
|
||||
} else {
|
||||
|
||||
@@ -75,6 +75,7 @@ $lang['menu_labels'] = 'Labels';
|
||||
$lang['menu_logbook_of_the_world'] = 'Logbook of the World';
|
||||
$lang['menu_eqsl_import_export'] = 'eQSL Import / Export';
|
||||
$lang['menu_qrz_logbook'] = 'QRZ Logbook';
|
||||
$lang['menu_hrd_logbook'] = 'HRDLog Logbook';
|
||||
$lang['menu_qo_100_dx_club_upload'] = 'QO-100 Dx Club Upload';
|
||||
$lang['menu_api_keys'] = 'API Keys';
|
||||
$lang['menu_hardware_interfaces'] = 'Hardware Interfaces';
|
||||
|
||||
@@ -73,6 +73,7 @@ $lang['menu_print_requested_qsls'] = 'Tulosta pyydetyt QSL:t';
|
||||
$lang['menu_logbook_of_the_world'] = 'Logbook of the World';
|
||||
$lang['menu_eqsl_import_export'] = 'eQSL Tuonti / Vienti';
|
||||
$lang['menu_qrz_logbook'] = 'QRZ Logi';
|
||||
$lang['menu_hrd_logbook'] = 'HRDLog Logi';
|
||||
$lang['menu_qo_100_dx_club_upload'] = 'QO-100 Dx Club Lähetys';
|
||||
$lang['menu_api_keys'] = 'API Keys';
|
||||
$lang['menu_hardware_interfaces'] = 'Hardware Interfaces';
|
||||
|
||||
@@ -75,6 +75,7 @@ $lang['menu_labels'] = 'Etiketten';
|
||||
$lang['menu_logbook_of_the_world'] = 'Logbook of the World';
|
||||
$lang['menu_eqsl_import_export'] = 'eQSL Import / Export';
|
||||
$lang['menu_qrz_logbook'] = 'QRZ Logbuch';
|
||||
$lang['menu_hrd_logbook'] = 'HRDLog Logbuch';
|
||||
$lang['menu_qo_100_dx_club_upload'] = 'QO-100 Dx Club Upload';
|
||||
$lang['menu_api_keys'] = 'API-Schlüssel';
|
||||
$lang['menu_hardware_interfaces'] = 'Hardware-Schnittstellen';
|
||||
|
||||
@@ -75,9 +75,10 @@ $lang['menu_labels'] = 'Наклейки';
|
||||
$lang['menu_logbook_of_the_world'] = 'Logbook of the World';
|
||||
$lang['menu_eqsl_import_export'] = 'Импорт / экспорт eQSL';
|
||||
$lang['menu_qrz_logbook'] = 'QRZ Logbook';
|
||||
$lang['menu_hrd_logbook'] = 'HRDLog Logbook';
|
||||
$lang['menu_qo_100_dx_club_upload'] = 'Загрузка в QO-100 Dx Club';
|
||||
$lang['menu_api_keys'] = 'ключи API';
|
||||
$lang['menu_hardware_interfaces'] = 'Аппаратные интерфейсы';
|
||||
$lang['menu_help'] = 'Помощь';
|
||||
$lang['menu_forum'] = 'Форум';
|
||||
$lang['menu_logout'] = 'Выход';
|
||||
$lang['menu_logout'] = 'Выход';
|
||||
|
||||
@@ -42,7 +42,6 @@ class AdifHelper {
|
||||
'FORCE_INIT',
|
||||
'GRIDSQUARE',
|
||||
'HEADING',
|
||||
'HRDLOG_QSO_UPLOAD_STATUS',
|
||||
'IOTA',
|
||||
'ITUZ',
|
||||
'K_INDEX',
|
||||
@@ -64,6 +63,7 @@ class AdifHelper {
|
||||
'PRECEDENCE',
|
||||
'PROP_MODE',
|
||||
'PUBLIC_KEY',
|
||||
'HRDLOG_QSO_UPLOAD_STATUS',
|
||||
'QRZCOM_QSO_UPLOAD_STATUS',
|
||||
'QSLMSG',
|
||||
'QSL_RCVD',
|
||||
|
||||
42
application/migrations/127_add_hrdlog_fields.php
Normal file
42
application/migrations/127_add_hrdlog_fields.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_add_hrdlog_fields extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
if (!$this->db->field_exists('hrdlogrealtime', 'station_profile')) {
|
||||
$fields = array(
|
||||
'hrdlogrealtime tinyint(1)'
|
||||
);
|
||||
$this->dbforge->add_column('station_profile', $fields);
|
||||
}
|
||||
|
||||
if (!$this->db->field_exists('hrdlog_code', 'station_profile')) {
|
||||
$fields = array(
|
||||
'hrdlog_code varchar(20) DEFAULT NULL',
|
||||
);
|
||||
$this->dbforge->add_column('station_profile', $fields);
|
||||
}
|
||||
|
||||
if ( (!$this->db->field_exists('COL_HRDLOG_QSO_UPLOAD_DATE', $this->config->item('table_name'))) &&
|
||||
(!$this->db->field_exists('COL_HRDLOG_QSO_UPLOAD_STATUS', $this->config->item('table_name')))) {
|
||||
$fields = array(
|
||||
'COL_HRDLOG_QSO_UPLOAD_DATE datetime default NULL',
|
||||
'COL_HRDLOG_QSO_UPLOAD_STATUS varchar(10) default NULL'
|
||||
);
|
||||
$this->dbforge->add_column($this->config->item('table_name'), $fields);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if ($this->db->field_exists('hrdlogrealtime', 'station_profile')) {
|
||||
$this->dbforge->drop_column('station_profile', 'hrdlogrealtime');
|
||||
}
|
||||
if ($this->db->field_exists('hrdlog_code', 'station_profile')) {
|
||||
$this->dbforge->drop_column('station_profile', 'hrdlog_code');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -252,6 +252,10 @@ class Logbook_model extends CI_Model {
|
||||
$data['COL_MY_GRIDSQUARE'] = strtoupper(trim($station['station_gridsquare']));
|
||||
}
|
||||
|
||||
if ($this->exists_hrdlog_code($station_id)) {
|
||||
$data['COL_HRDLOG_QSO_UPLOAD_STATUS'] = 'N';
|
||||
}
|
||||
|
||||
if ($this->exists_qrz_api_key($station_id)) {
|
||||
$data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'N';
|
||||
}
|
||||
@@ -506,12 +510,26 @@ class Logbook_model extends CI_Model {
|
||||
$this->upload_amsat_status($data);
|
||||
}
|
||||
|
||||
// No point in fetching qrz api key and qrzrealtime setting if we're skipping the export
|
||||
// No point in fetching hrdlog code or qrz api key and qrzrealtime setting if we're skipping the export
|
||||
if (!$skipexport) {
|
||||
|
||||
$result = $this->exists_qrz_api_key($data['station_id']);
|
||||
|
||||
// Push qso to qrz if apikey is set, and realtime upload is enabled, and we're not importing an adif-file
|
||||
$result = $this->exists_hrdlog_code($data['station_id']);
|
||||
// Push qso to hrdlog if code is set, and realtime upload is enabled, and we're not importing an adif-file
|
||||
if (isset($result->hrdlog_code) && $result->hrdlogrealtime == 1) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AdifHelper');
|
||||
$qso = $this->get_qso($last_id)->result();
|
||||
|
||||
$adif = $CI->adifhelper->getAdifLine($qso[0]);
|
||||
$result = $this->push_qso_to_hrdlog($result->hrdlog_code, $data['COL_STATION_CALLSIGN'], $adif);
|
||||
if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate') || ($result['status'] == 'auth_error') )){
|
||||
$this->mark_hrdlog_qsos_sent($last_id);
|
||||
}
|
||||
}
|
||||
$result = ''; // Empty result from previous hrdlog-attempt for safety
|
||||
$result = $this->exists_qrz_api_key($data['station_id']);
|
||||
// Push qso to qrz if apikey is set, and realtime upload is enabled, and we're not importing an adif-file
|
||||
if (isset($result->qrzapikey) && $result->qrzrealtime == 1) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AdifHelper');
|
||||
@@ -545,6 +563,24 @@ class Logbook_model extends CI_Model {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function checks if a HRDLog Code exists in the table with the given station id
|
||||
*/
|
||||
function exists_hrdlog_code($station_id) {
|
||||
$sql = 'select hrdlog_code, hrdlogrealtime from station_profile
|
||||
where station_id = ' . $station_id;
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$result = $query->row();
|
||||
|
||||
if ($result) {
|
||||
return $result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function checks if a QRZ API Key exists in the table with the given station id
|
||||
*/
|
||||
@@ -583,6 +619,59 @@ class Logbook_model extends CI_Model {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function uploads a QSO to HRDLog with the API given.
|
||||
* $adif contains a line with the QSO in the ADIF format. QSO ends with an <EOR>
|
||||
*/
|
||||
function push_qso_to_hrdlog($apikey, $station_callsign, $adif, $replaceoption = false) {
|
||||
$url = 'https://robot.hrdlog.net/newentry.aspx';
|
||||
|
||||
$post_data['Code'] = $apikey;
|
||||
if ($replaceoption) {
|
||||
$post_data['Cmd'] = 'UPDATE';
|
||||
$post_data['ADIFKey'] = $adif;
|
||||
}
|
||||
$post_data['ADIFData'] = $adif;
|
||||
|
||||
$post_data['Callsign'] = $station_callsign;
|
||||
|
||||
|
||||
$post_encoded=http_build_query($post_data);
|
||||
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_POST, true);
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_encoded);
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
|
||||
$content = curl_exec($ch);
|
||||
if ($content){
|
||||
if (stristr($content,'<insert>1')) {
|
||||
$result['status'] = 'OK';
|
||||
return $result;
|
||||
} elseif (stristr($content,'<insert>0')) {
|
||||
$result['status'] = 'duplicate';
|
||||
$result['message'] = $content;
|
||||
return $result;
|
||||
} elseif (stristr($content,'Unknown user</error>')) {
|
||||
$result['status'] = 'auth_error';
|
||||
$result['message'] = $content;
|
||||
return $result;
|
||||
} else {
|
||||
$result['status'] = 'error';
|
||||
$result['message'] = $content;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
if(curl_errno($ch)){
|
||||
$result['status'] = 'error';
|
||||
$result['message'] = 'Curl error: '. curl_errno($ch);
|
||||
return $result;
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function uploads a QSO to QRZ with the API given.
|
||||
* $adif contains a line with the QSO in the ADIF format. QSO ends with an <EOR>
|
||||
@@ -655,6 +744,23 @@ class Logbook_model extends CI_Model {
|
||||
return $response === 200;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function marks QSOs as uploaded to HRDLog.
|
||||
* $primarykey is the unique id for that QSO in the logbook
|
||||
*/
|
||||
function mark_hrdlog_qsos_sent($primarykey) {
|
||||
$data = array(
|
||||
'COL_HRDLOG_QSO_UPLOAD_DATE' => date("Y-m-d H:i:s", strtotime("now")),
|
||||
'COL_HRDLOG_QSO_UPLOAD_STATUS' => 'Y',
|
||||
);
|
||||
|
||||
$this->db->where('COL_PRIMARY_KEY', $primarykey);
|
||||
|
||||
$this->db->update($this->config->item('table_name'), $data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function marks QSOs as uploaded to QRZ.
|
||||
* $primarykey is the unique id for that QSO in the logbook
|
||||
@@ -940,6 +1046,10 @@ class Logbook_model extends CI_Model {
|
||||
'COL_CNTY' => $uscounty
|
||||
);
|
||||
|
||||
if ($this->exists_hrdlog_code($data['station_id'])) {
|
||||
$data['COL_HRDLOG_QSO_UPLOAD_STATUS'] = 'M';
|
||||
}
|
||||
|
||||
if ($this->exists_qrz_api_key($data['station_id'])) {
|
||||
$data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'M';
|
||||
}
|
||||
@@ -1311,6 +1421,23 @@ class Logbook_model extends CI_Model {
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns the QSOs from the logbook, which have not been either marked as uploaded to hrdlog, or has been modified with an edit
|
||||
*/
|
||||
function get_hrdlog_qsos($station_id){
|
||||
$sql = 'select *, dxcc_entities.name as station_country from ' . $this->config->item('table_name') . ' thcv ' .
|
||||
' left join station_profile on thcv.station_id = station_profile.station_id' .
|
||||
' left outer join dxcc_entities on thcv.col_my_dxcc = dxcc_entities.adif' .
|
||||
' where thcv.station_id = ' . $station_id .
|
||||
' and (COL_HRDLOG_QSO_UPLOAD_STATUS is NULL
|
||||
or COL_HRDLOG_QSO_UPLOAD_STATUS = ""
|
||||
or COL_HRDLOG_QSO_UPLOAD_STATUS = "M"
|
||||
or COL_HRDLOG_QSO_UPLOAD_STATUS = "N")';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns the QSOs from the logbook, which have not been either marked as uploaded to qrz, or has been modified with an edit
|
||||
*/
|
||||
@@ -1371,6 +1498,25 @@ class Logbook_model extends CI_Model {
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns all the station_id's with HRDLOG Code
|
||||
*/
|
||||
function get_station_id_with_hrdlog_code() {
|
||||
$sql = 'select station_id, hrdlog_code from station_profile
|
||||
where coalesce(hrdlog_code, "") <> ""';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$result = $query->result();
|
||||
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns all the station_id's with QRZ API Key's
|
||||
*/
|
||||
@@ -2590,9 +2736,10 @@ class Logbook_model extends CI_Model {
|
||||
* $markLoTW - used in ADIF import to mark QSOs as exported to LoTW when importing QSOs
|
||||
* $dxccAdif - used in ADIF import to determine if DXCC From ADIF is used, or if Cloudlog should try to guess
|
||||
* $markQrz - used in ADIF import to mark QSOs as exported to QRZ Logbook when importing QSOs
|
||||
* $markHrd - used in ADIF import to mark QSOs as exported to HRDLog.net Logbook when importing QSOs
|
||||
* $skipexport - used in ADIF import to skip the realtime upload to QRZ Logbook when importing QSOs from ADIF
|
||||
*/
|
||||
function import($record, $station_id = "0", $skipDuplicate = false, $markLotw = false, $dxccAdif = false, $markQrz = false, $skipexport = false, $operatorName = false, $apicall = false) {
|
||||
function import($record, $station_id = "0", $skipDuplicate = false, $markLotw = false, $dxccAdif = false, $markQrz = false, $markHrd = false,$skipexport = false, $operatorName = false, $apicall = false) {
|
||||
// be sure that station belongs to user
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
@@ -2931,12 +3078,19 @@ class Logbook_model extends CI_Model {
|
||||
$operatorName = (!empty($record['operator'])) ? $record['operator'] : '';
|
||||
}
|
||||
|
||||
// If user checked to mark QSOs as uploaded to QRZ Logbook, or else we try to find info in ADIF import.
|
||||
// If user checked to mark QSOs as uploaded to QRZ or HRDLog Logbook, or else we try to find info in ADIF import.
|
||||
if ($markHrd != null) {
|
||||
$input_hrdlog_qso_upload_status = 'Y';
|
||||
$input_hrdlog_qso_upload_date = $date = date("Y-m-d H:i:s", strtotime("now"));
|
||||
}
|
||||
|
||||
if ($markQrz != null) {
|
||||
$input_qrzcom_qso_upload_status = 'Y';
|
||||
$input_qrzcom_qso_upload_date = $date = date("Y-m-d H:i:s", strtotime("now"));
|
||||
}
|
||||
else {
|
||||
$input_hrdlog_qso_upload_date = (!empty($record['hrdlog_qso_upload_date'])) ? $record['hrdlog_qso_upload_date'] : null;
|
||||
$input_hrdlog_qso_upload_status = (!empty($record['hrdlog_qso_upload_status'])) ? $record['hrdlog_qso_upload_status'] : '';
|
||||
$input_qrzcom_qso_upload_date = (!empty($record['qrzcom_qso_upload_date'])) ? $record['qrzcom_qso_upload_date'] : null;
|
||||
$input_qrzcom_qso_upload_status = (!empty($record['qrzcom_qso_upload_status'])) ? $record['qrzcom_qso_upload_status'] : '';
|
||||
}
|
||||
@@ -3052,6 +3206,8 @@ class Logbook_model extends CI_Model {
|
||||
'COL_PRECEDENCE' => (!empty($record['precedence'])) ? $record['precedence'] : '',
|
||||
'COL_PROP_MODE' => (!empty($record['prop_mode'])) ? $record['prop_mode'] : '',
|
||||
'COL_PUBLIC_KEY' => (!empty($record['public_key'])) ? $record['public_key'] : '',
|
||||
'COL_HRDLOG_QSO_UPLOAD_DATE' => $input_hrdlog_qso_upload_date,
|
||||
'COL_HRDLOG_QSO_UPLOAD_STATUS' => $input_hrdlog_qso_upload_status,
|
||||
'COL_QRZCOM_QSO_UPLOAD_DATE' => $input_qrzcom_qso_upload_date,
|
||||
'COL_QRZCOM_QSO_UPLOAD_STATUS' => $input_qrzcom_qso_upload_status,
|
||||
'COL_QSL_RCVD' => $input_qsl_rcvd,
|
||||
|
||||
@@ -91,9 +91,11 @@ class Stations extends CI_Model {
|
||||
'station_cq' => xss_clean($this->input->post('station_cq', true)),
|
||||
'station_itu' => xss_clean($this->input->post('station_itu', true)),
|
||||
'state' => $state,
|
||||
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
|
||||
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
|
||||
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
|
||||
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
|
||||
'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)),
|
||||
'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)),
|
||||
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
|
||||
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
|
||||
'oqrs' => xss_clean($this->input->post('oqrs', true)),
|
||||
'oqrs_email' => xss_clean($this->input->post('oqrsemail', true)),
|
||||
'oqrs_text' => xss_clean($this->input->post('oqrstext', true)),
|
||||
@@ -133,8 +135,10 @@ class Stations extends CI_Model {
|
||||
'station_itu' => xss_clean($this->input->post('station_itu', true)),
|
||||
'state' => $state,
|
||||
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
|
||||
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
|
||||
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
|
||||
'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)),
|
||||
'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)),
|
||||
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
|
||||
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
|
||||
'oqrs' => xss_clean($this->input->post('oqrs', true)),
|
||||
'oqrs_email' => xss_clean($this->input->post('oqrsemail', true)),
|
||||
'oqrs_text' => xss_clean($this->input->post('oqrstext', true)),
|
||||
@@ -342,6 +346,35 @@ class Stations extends CI_Model {
|
||||
}
|
||||
}
|
||||
|
||||
function stations_with_hrdlog_code() {
|
||||
$sql = "select station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, modc.modcount, notc.notcount, totc.totcount
|
||||
from station_profile
|
||||
left outer join (
|
||||
select count(*) modcount, station_id
|
||||
from ". $this->config->item('table_name') .
|
||||
" where COL_HRDLOG_QSO_UPLOAD_STATUS = 'M'
|
||||
group by station_id
|
||||
) as modc on station_profile.station_id = modc.station_id
|
||||
left outer join (
|
||||
select count(*) notcount, station_id
|
||||
from " . $this->config->item('table_name') .
|
||||
" where (coalesce(COL_HRDLOG_QSO_UPLOAD_STATUS, '') = ''
|
||||
or COL_HRDLOG_QSO_UPLOAD_STATUS = 'N')
|
||||
group by station_id
|
||||
) as notc on station_profile.station_id = notc.station_id
|
||||
left outer join (
|
||||
select count(*) totcount, station_id
|
||||
from " . $this->config->item('table_name') .
|
||||
" where COL_HRDLOG_QSO_UPLOAD_STATUS = 'Y'
|
||||
group by station_id
|
||||
) as totc on station_profile.station_id = totc.station_id
|
||||
where coalesce(station_profile.hrdlog_code, '') <> ''
|
||||
and station_profile.user_id = " . $this->session->userdata('user_id');
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
function stations_with_qrz_api_key() {
|
||||
$sql = "select station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, modc.modcount, notc.notcount, totc.totcount
|
||||
from station_profile
|
||||
|
||||
@@ -59,6 +59,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-10">
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="markHrd" value="1" id="markHrdImport">
|
||||
<label class="form-check-label" for="markHrdImport">Mark imported QSOs as uploaded to HRDLog.net Logbook</label>
|
||||
</div>
|
||||
<div class="small form-text text-muted">Select if ADIF being imported does not contain this information.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-10">
|
||||
<div class="form-check-inline">
|
||||
|
||||
96
application/views/hrdlog/export.php
Normal file
96
application/views/hrdlog/export.php
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
<div class="container adif">
|
||||
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<ul class="nav nav-tabs card-header-tabs pull-right" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="export-tab" data-toggle="tab" href="#export" role="tab" aria-controls="import" aria-selected="true">Upload Logbook</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="mark-tab" data-toggle="tab" href="#mark" role="tab" aria-controls="export" aria-selected="false">Mark QSOs</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="export" role="tabpanel" aria-labelledby="export-tab">
|
||||
<p>Here you can see and upload all QSOs which have not been previously uploaded to a HRDLog logbook.</p>
|
||||
<p>You need to set a HRDLog Logbook API Code in your station profile. Only station profiles with an API Key set are displayed.</p>
|
||||
<p>The Code can be demanded at <a href="http://www.hrdlog.net/EditUser.aspx" target="new" class="link">http://www.hrdlog.net/EditUser.aspx</a></p>
|
||||
<p><span class="badge badge-warning">Warning</span>This might take a while as QSO uploads are processed sequentially.</p>
|
||||
|
||||
<?php
|
||||
if ($station_profile->result()) {
|
||||
echo '
|
||||
|
||||
<table class="table table-bordered table-hover table-striped table-condensed text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Profile name</td>
|
||||
<td>Station callsign</td>
|
||||
<td>Edited QSOs not uploaded</td>
|
||||
<td>Total QSOs not uploaded</td>
|
||||
<td>Total QSOs uploaded</td>
|
||||
<td>Actions</td>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($station_profile->result() as $station) { // Fills the table with the data
|
||||
echo '<tr>';
|
||||
echo '<td>' . $station->station_profile_name . '</td>';
|
||||
echo '<td>' . $station->station_callsign . '</td>';
|
||||
echo '<td id ="modcount'.$station->station_id.'">' . $station->modcount . '</td>';
|
||||
echo '<td id ="notcount'.$station->station_id.'">' . $station->notcount . '</td>';
|
||||
echo '<td id ="totcount'.$station->station_id.'">' . $station->totcount . '</td>';
|
||||
echo '<td><button id="HrdlogUpload" type="button" name="HrdlogUpload" class="btn btn-primary btn-sm ld-ext-right" onclick="ExportHrd('. $station->station_id .')"><i class="fas fa-cloud-upload-alt"></i> Upload<div class="ld ld-ring ld-spin"></div></button></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tfoot></table>';
|
||||
|
||||
}
|
||||
else {
|
||||
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Nothing found!</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div class="tab-pane fade" id="mark" role="tabpanel" aria-labelledby="home-tab">
|
||||
|
||||
<form class="form" action="<?php echo site_url('hrdlog/mark_hrdlog'); ?>" method="post" enctype="multipart/form-data">
|
||||
<select name="station_profile" class="custom-select mb-4 mr-sm-4" style="width: 30%;">
|
||||
<option value="0">Select Station Location</option>
|
||||
<?php foreach ($station_profiles->result() as $station) { ?>
|
||||
<option value="<?php echo $station->station_id; ?>">Callsign: <?php echo $station->station_callsign; ?> (<?php echo $station->station_profile_name; ?>)</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p><span class="badge badge-warning">Warning</span> If a date range is not selected then all QSOs will be marked!</p>
|
||||
<p class="card-text">From date:</p>
|
||||
<div class="row">
|
||||
<div class="input-group date col-md-3" id="datetimepicker5" data-target-input="nearest">
|
||||
<input name="from" type="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker5" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="card-text">To date:</p>
|
||||
<div class="row">
|
||||
<div class="input-group date col-md-3" id="datetimepicker6" data-target-input="nearest">
|
||||
<input name="to" "totype="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker2"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker6" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit" class="btn-sm btn-primary" value="Export">Mark QSOs as exported to HRDLog Logbook</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
22
application/views/hrdlog/mark_hrdlog.php
Normal file
22
application/views/hrdlog/mark_hrdlog.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<div class="container">
|
||||
<br>
|
||||
<?php if($this->session->flashdata('message')) { ?>
|
||||
<!-- Display Message -->
|
||||
<div class="alert-message error">
|
||||
<p><?php echo $this->session->flashdata('message'); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
QSOs marked
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">Yay, it's done!</h3>
|
||||
<p class="card-text">The QSOs are marked as exported to HRDLog Logbook.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -71,7 +71,7 @@ function load_was_map() {
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/sections/continents.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "adif" || $this->uri->segment(1) == "qrz" || $this->uri->segment(1) == "webadif") { ?>
|
||||
<?php if ($this->uri->segment(1) == "adif" || $this->uri->segment(1) == "qrz" || $this->uri->segment(1) == "hrdlog" ||$this->uri->segment(1) == "webadif") { ?>
|
||||
<!-- Javascript used for ADIF Import and Export Areas -->
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/moment.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/tempusdominus-bootstrap-4.min.js"></script>
|
||||
@@ -1702,6 +1702,9 @@ $(document).ready(function(){
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "hrdlog") { ?>
|
||||
<script src="<?php echo base_url(); ?>assets/js/sections/hrdlog.js"></script>
|
||||
<?php } ?>
|
||||
<?php if ($this->uri->segment(1) == "qrz") { ?>
|
||||
<script src="<?php echo base_url(); ?>assets/js/sections/qrzlogbook.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
@@ -260,6 +260,7 @@ $oqrs_requests = $CI->oqrs_model->oqrs_requests($location_list);
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('eqsl/import');?>" title="eQSL import / export"><i class="fas fa-sync"></i> <?php echo lang('menu_eqsl_import_export'); ?></a>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('hrdlog/export');?>" title="Upload to HRDLog.net logbook"><i class="fas fa-sync"></i> <?php echo lang('menu_hrd_logbook'); ?></a>
|
||||
<a class="dropdown-item" href="<?php echo site_url('qrz/export');?>" title="Upload to QRZ.com logbook"><i class="fas fa-sync"></i> <?php echo lang('menu_qrz_logbook'); ?></a>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('webadif/export');?>" title="Upload to webADIF"><i class="fas fa-sync"></i> <?php echo lang('menu_qo_100_dx_club_upload'); ?></a>
|
||||
|
||||
@@ -249,6 +249,20 @@
|
||||
<small id="eqslhelp" class="form-text text-muted">eQSL QTH Nickname.</small>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-6"> <label for="hrdlog_code">HRDLog.net Logbook API Key</label>
|
||||
<input type="text" class="form-control" name="hrdlog_code" id="hrdlog_code" aria-describedby="hrdlog_codeHelp">
|
||||
<small id="hrdlog_codeHelp" class="form-text text-muted">Find your API key on <a href="http://www.hrdlog.net/EditUser.aspx" target="_blank">HRDLog Userprofile</a></small>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="hrdlogrealtime">HRDLog.net Logbook Realtime Upload</label> <select class="custom-select" id="hrdlogrealtime" name="hrdlogrealtime">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0" selected>No</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning" role="alert">
|
||||
QRZ.com Logbook Requires Paid Subscription
|
||||
</div>
|
||||
|
||||
@@ -371,6 +371,27 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<h5 class="card-header">HRDLog.net</h5>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="webadifApiKey">HRDLog.net API Code</label>
|
||||
<input type="text" class="form-control" name="hrdlog_code" id="hrdlog_code" aria-describedby="hrdlog_codeHelp" value="<?php if(set_value('hrdlog_code') != "") { echo set_value('hrdlog_code'); } else { echo $my_station_profile->hrdlog_code; } ?>">
|
||||
<small id="hrdlog_codeHelp" class="form-text text-muted">Create your API Code on <a href="http://www.hrdlog.net/EditUser.aspx" target="_blank">HRDLog.net Userprofile page</a></small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="hrdlogrealtime">HRDLog.net Realtime Upload</label>
|
||||
<select class="custom-select" id="hrdlogrealtime" name="hrdlogrealtime">
|
||||
<option value="1" <?php if ($my_station_profile->hrdlogrealtime == 1) { echo " selected =\"selected\""; } ?>>Yes</option>
|
||||
<option value="0" <?php if ($my_station_profile->hrdlogrealtime == 0) { echo " selected =\"selected\""; } ?>>No</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
|
||||
@@ -69,6 +69,9 @@
|
||||
# Upload QSOs to LoTW if certs have been provided every hour. <br>
|
||||
0 */1 * * * curl --silent <?php echo site_url();?>/lotw/lotw_upload &>/dev/null <br>
|
||||
<br>
|
||||
# Upload QSOs to HRDLog.net Logbook (ignore cron job if this integration is not required) <br>
|
||||
0 */6 * * * curl --silent <?php echo site_url();?>/hrdlog/upload &>/dev/null <br>
|
||||
<br>
|
||||
# Upload QSOs to QRZ Logbook (ignore cron job if this integration is not required) <br>
|
||||
0 */6 * * * curl --silent <?php echo site_url();?>/qrz/upload &>/dev/null <br>
|
||||
<br>
|
||||
@@ -153,4 +156,4 @@
|
||||
|
||||
<br><br>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
59
assets/js/sections/hrdlog.js
Normal file
59
assets/js/sections/hrdlog.js
Normal file
@@ -0,0 +1,59 @@
|
||||
$(function () {
|
||||
$('#datetimepicker5').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$('#datetimepicker6').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
|
||||
function ExportHrd(station_id) {
|
||||
if ($(".alert").length > 0) {
|
||||
$(".alert").remove();
|
||||
}
|
||||
if ($(".errormessages").length > 0) {
|
||||
$(".errormessages").remove();
|
||||
}
|
||||
$(".ld-ext-right").addClass('running');
|
||||
$(".ld-ext-right").prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/hrdlog/upload_station',
|
||||
type: 'post',
|
||||
data: {'station_id': station_id},
|
||||
success: function (data) {
|
||||
$(".ld-ext-right").removeClass('running');
|
||||
$(".ld-ext-right").prop('disabled', false);
|
||||
if (data.status == 'OK') {
|
||||
$.each(data.info, function(index, value){
|
||||
$('#modcount'+value.station_id).html(value.modcount);
|
||||
$('#notcount'+value.station_id).html(value.notcount);
|
||||
$('#totcount'+value.station_id).html(value.totcount);
|
||||
});
|
||||
$(".card-body").append('<div class="alert alert-success" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>' + data.infomessage + '</div>');
|
||||
}
|
||||
else {
|
||||
$(".card-body").append('<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>' + data.info + '</div>');
|
||||
}
|
||||
|
||||
if (data.errormessages.length > 0) {
|
||||
$(".card-body").append('' +
|
||||
'<div class="errormessages"><p>\n' +
|
||||
' <button class="btn btn-danger" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">\n' +
|
||||
' Show error messages\n' +
|
||||
' </button>\n' +
|
||||
' </p>\n' +
|
||||
' <div class="collapse" id="collapseExample">\n' +
|
||||
' <div class="card card-body"><div class="errors"></div>\n' +
|
||||
' </div>\n' +
|
||||
' </div></div>');
|
||||
$.each(data.errormessages, function(index, value) {
|
||||
$(".errors").append('<li>' + value);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user