2022-10-05 14:15:29 +00:00
|
|
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
|
|
/*
|
|
|
|
Path: application\controllers\Welcome.php
|
|
|
|
|
|
|
|
Displays the welcome to Cloudlog version 2.0 view to help users with migration from version 1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class Welcome extends CI_Controller {
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
|
2022-10-11 13:54:34 +00:00
|
|
|
if($this->optionslib->get_option('version2_trigger') == "false") {
|
2022-10-10 18:56:46 +00:00
|
|
|
$data['page_title'] = "Welcome to Cloudlog Version 2.0";
|
|
|
|
|
|
|
|
// load stations model
|
|
|
|
$this->load->model('stations');
|
|
|
|
$data['CountAllStationLocations'] = $this->stations->CountAllStationLocations();
|
2022-10-11 15:54:32 +00:00
|
|
|
|
2022-10-10 18:56:46 +00:00
|
|
|
// load logbooks model
|
|
|
|
$this->load->model('logbooks_model');
|
|
|
|
$data['NumberOfStationLogbooks'] = $this->logbooks_model->CountAllStationLogbooks();
|
|
|
|
|
|
|
|
// load api model
|
|
|
|
$this->load->model('api_model');
|
|
|
|
$data['NumberOfAPIKeys'] = $this->api_model->CountKeysWithNoUserID();
|
2022-10-11 15:54:32 +00:00
|
|
|
|
2022-10-10 18:56:46 +00:00
|
|
|
// load note model
|
|
|
|
$this->load->model('note');
|
|
|
|
$data['NumberOfNotes'] = $this->note->CountAllNotes();
|
2022-10-11 13:54:34 +00:00
|
|
|
|
2022-10-11 14:06:17 +00:00
|
|
|
if($data['CountAllStationLocations'] == 0 || $data['NumberOfStationLogbooks'] == 0 || $data['NumberOfAPIKeys'] > 0 || $data['NumberOfNotes'] > 0) {
|
2022-10-11 13:26:46 +00:00
|
|
|
// load views
|
|
|
|
$this->load->view('interface_assets/mini_header', $data);
|
|
|
|
$this->load->view('welcome/index');
|
|
|
|
$this->load->view('interface_assets/footer');
|
|
|
|
} else {
|
|
|
|
$data['NoMigrationRequired'] = false;
|
2022-10-11 13:59:17 +00:00
|
|
|
$this->optionslib->update('version2_trigger', "true", "yes");
|
2022-10-11 13:26:46 +00:00
|
|
|
redirect('dashboard');
|
|
|
|
}
|
2022-10-10 18:56:46 +00:00
|
|
|
} else {
|
2022-10-11 13:26:46 +00:00
|
|
|
redirect('dashboard');
|
2022-10-10 18:56:46 +00:00
|
|
|
}
|
2022-10-05 14:15:29 +00:00
|
|
|
}
|
2022-10-09 13:55:46 +00:00
|
|
|
|
|
|
|
public function locationsclaim() {
|
|
|
|
try {
|
|
|
|
// load model Stations and call function ClaimAllStationLocations
|
|
|
|
$this->load->model('stations');
|
|
|
|
$this->stations->ClaimAllStationLocations();
|
|
|
|
|
|
|
|
echo "All Station Locations Claimed";
|
|
|
|
} catch (Exception $e) {
|
|
|
|
log_message('error', 'Error Claiming Station Locations during Migration. '.$e->getMessage());
|
|
|
|
echo "Error Claiming Station Locations during Migration. See Logs for further information";
|
|
|
|
}
|
|
|
|
}
|
2022-10-09 15:46:37 +00:00
|
|
|
|
|
|
|
public function defaultlogbook() {
|
|
|
|
try {
|
|
|
|
// load model Stations and call function ClaimAllStationLocations
|
|
|
|
$this->load->model('logbooks_model');
|
|
|
|
$this->logbooks_model->CreateDefaultLogbook();
|
|
|
|
|
|
|
|
echo "Default Logbook Created";
|
|
|
|
} catch (Exception $e) {
|
|
|
|
log_message('error', 'Error Creating Default Logbook during Migration. '.$e->getMessage());
|
|
|
|
echo "Error Creating Default Logbook during Migration. See Logs for further information";
|
|
|
|
}
|
|
|
|
}
|
2022-10-10 14:06:01 +00:00
|
|
|
|
|
|
|
public function claimnotes() {
|
|
|
|
try {
|
|
|
|
// load model Stations and call function ClaimAllStationLocations
|
|
|
|
$this->load->model('note');
|
|
|
|
$this->note->ClaimAllNotes();
|
|
|
|
|
|
|
|
echo "Notes all claimed";
|
|
|
|
} catch (Exception $e) {
|
|
|
|
log_message('error', 'Error claiming notes during Migration. '.$e->getMessage());
|
|
|
|
echo "Error claiming notes during Migration. See Logs for further information";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function claimapikeys() {
|
|
|
|
try {
|
|
|
|
// load model Stations and call function ClaimAllStationLocations
|
|
|
|
$this->load->model('api_model');
|
|
|
|
$this->api_model->ClaimAllAPIKeys();
|
|
|
|
|
|
|
|
echo "All API Keys claimed";
|
|
|
|
} catch (Exception $e) {
|
|
|
|
log_message('error', 'Error claiming API Keys during Migration. '.$e->getMessage());
|
|
|
|
echo "Error claiming API Keys during Migration. See Logs for further information";
|
|
|
|
}
|
|
|
|
}
|
2022-10-05 14:15:29 +00:00
|
|
|
}
|