Initial comming of full program to main branch
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<style>
|
||||
body {
|
||||
background-color: #333333;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
// Simple Script to create a MySQL View.
|
||||
|
||||
define("INITIALIZATION_FILE_NAME", "../xml/settings.xml");
|
||||
|
||||
// Retrieve Application Settings
|
||||
|
||||
$applicationSettings = simplexml_load_file(INITIALIZATION_FILE_NAME);
|
||||
|
||||
if (empty($applicationSettings)) {
|
||||
echo "Unable to load Application Settings." . PHP_EOL;
|
||||
exit();
|
||||
}
|
||||
|
||||
// Connect to the Database.
|
||||
|
||||
if ($applicationSettings->Environment == 'Production') {
|
||||
$host = 'localhost';
|
||||
} else {
|
||||
$host = '192.168.1.190';
|
||||
}
|
||||
|
||||
|
||||
$database = (string) $applicationSettings->DatabaseName;
|
||||
$user = (string) $applicationSettings->DatabaseUser;
|
||||
$password = (string) $applicationSettings->DatabasePassword;
|
||||
|
||||
try {
|
||||
$connection = new PDO("mysql:host={$host};dbname={$database}", $user, $password);
|
||||
} catch (PDOException | Exception $e) {
|
||||
echo "Unable to connect to the database. <br/>";
|
||||
echo "Error is: {$e->getMessage()}";
|
||||
exit();
|
||||
}
|
||||
|
||||
// Retrieve the View Names.
|
||||
|
||||
$views = array();
|
||||
|
||||
$directory = ".";
|
||||
|
||||
if (is_dir($directory)) {
|
||||
|
||||
if ($handle = opendir($directory)) {
|
||||
|
||||
while (false !== ($filename = readdir($handle))) {
|
||||
|
||||
if ($filename != "." && $filename != ".." && !is_dir("{$directory}/{$filename}")) {
|
||||
|
||||
if (substr($filename, 0, 5) !== "view_") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$views[] = $filename;
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($views) === 0) {
|
||||
echo "No views found. Views not created.";
|
||||
exit();
|
||||
}
|
||||
|
||||
// Create the Views
|
||||
|
||||
$created = 0;
|
||||
$not_created = 0;
|
||||
|
||||
foreach ($views as $view) {
|
||||
|
||||
if ((include "{$view}") != true) {
|
||||
echo "{$view} not found. View not created <br/>.";
|
||||
continue;
|
||||
}
|
||||
|
||||
$view = str_replace(".php", "", $view);
|
||||
|
||||
$connection->exec("drop view if exists {$view}");
|
||||
$connection->exec($SQL);
|
||||
|
||||
if ($connection->errorCode() != 0) {
|
||||
$not_created++;
|
||||
echo "Error creating view {$view}: <br/>";
|
||||
echo "<pre>";
|
||||
print_r($connection->errorInfo());
|
||||
echo "<br/>";
|
||||
} else {
|
||||
$created++;
|
||||
echo "{$view} was created. <br/>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<br/> {$created} Views were created. {$not_created} were not created due to errors.";
|
||||
?>
|
||||
@@ -0,0 +1,72 @@
|
||||
<style>
|
||||
body {
|
||||
background-color: #333333;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
// Simple Script to create a MySQL View.
|
||||
|
||||
define("INITIALIZATION_FILE_NAME", "../xml/settings.xml");
|
||||
|
||||
// Retrieve the View Name.
|
||||
|
||||
$view = $_GET["view"] ?? "";
|
||||
|
||||
if (empty($view)) {
|
||||
echo "No view name given. View not created.";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ((include "{$view}.php") != true) {
|
||||
echo "{$view}.php not found. View not created.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Retrieve Application Settings
|
||||
|
||||
$applicationSettings = simplexml_load_file(INITIALIZATION_FILE_NAME);
|
||||
|
||||
if (empty($applicationSettings)) {
|
||||
echo "Unable to load Application Settings." . PHP_EOL;
|
||||
exit();
|
||||
}
|
||||
|
||||
echo $applicationSettings->asXML();
|
||||
die();
|
||||
|
||||
// Connect to the Database.
|
||||
|
||||
$host = (string) $applicationSettings->DatabaseServer;
|
||||
$database = (string) $applicationSettings->DatabaseName;
|
||||
$user = (string) $applicationSettings->DatabaseUser;
|
||||
$password = (string) $applicationSettings->DatabasePassword;
|
||||
|
||||
try {
|
||||
$connection = new PDO("mysql:host={$host};dbname={$database}", $user, $password);
|
||||
} catch (PDOException | Exception $e) {
|
||||
echo "Unable to connect to the database. <br/>";
|
||||
echo "Error is: {$e->getMessage()}";
|
||||
exit();
|
||||
}
|
||||
|
||||
// Create the view.
|
||||
|
||||
$connection->exec("drop view if exists {$view}");
|
||||
|
||||
try {
|
||||
$connection->exec($SQL);
|
||||
} catch (Exception $e) {
|
||||
echo "Error creating view. <br/>";
|
||||
echo "Error is: {$e->getMessage()}";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($connection->errorCode() != 0) {
|
||||
echo "Error creating view. <br/>";
|
||||
echo "<pre>";
|
||||
print_r($connection->errorInfo());
|
||||
} else {
|
||||
echo "View {$view} was created.";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_counties as
|
||||
|
||||
select counties.*,
|
||||
date_format(county_created, '%c/%e/%Y %l:%i %p') as county_created_verbose,
|
||||
date_format(county_changed, '%c/%e/%Y %l:%i %p') as county_changed_verbose
|
||||
|
||||
from counties
|
||||
|
||||
order by county_name";
|
||||
?>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_dropdowns as
|
||||
|
||||
select dropdowns.*,
|
||||
date_format(dropdowntype_created, '%c/%e/%Y %l:%i %p') as dropdowntype_created_verbose,
|
||||
date_format(dropdowntype_changed, '%c/%e/%Y %l:%i %p') as dropdowntype_changed_verbose,
|
||||
dropdowntypes.*
|
||||
|
||||
from dropdowns
|
||||
|
||||
join dropdowntypes
|
||||
on dropdowntypes.dropdowntype_serial = dropdowns.dropdown_dropdowntype
|
||||
|
||||
order by dropdown_dropdowntype, dropdown_value";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_dropdowntypes as
|
||||
|
||||
select dropdowntypes.*,
|
||||
date_format(dropdowntype_created, '%c/%e/%Y %l:%i %p') as dropdowntype_created_verbose,
|
||||
date_format(dropdowntype_changed, '%c/%e/%Y %l:%i %p') as dropdowntype_changed_verbose
|
||||
|
||||
from dropdowntypes
|
||||
|
||||
order by dropdowntype_title";
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_journal as
|
||||
|
||||
select journal.*,
|
||||
date_format(journal.journal_timestamp, '%m/%d/%Y %l:%i %p') as journal_timestamp_verbose
|
||||
from journal
|
||||
order by journal_timestamp desc";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_notes as
|
||||
|
||||
select notes.*,
|
||||
date_format(note_timestamp, '%c/%e/%Y %l:%i %p') as note_timestamp_verbose
|
||||
from notes
|
||||
order by note_type, note_reference, note_timestamp desc";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_popovers as
|
||||
|
||||
select popovers.*,
|
||||
|
||||
date_format(popover_created, '%c/%e/%Y %l:%i %p') as popover_created_verbose,
|
||||
date_format(popover_changed, '%c/%e/%Y %l:%i %p') as popover_changed_verbose
|
||||
|
||||
from popovers
|
||||
|
||||
order by popover_title";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_rdis as
|
||||
|
||||
select rdis.*,
|
||||
date_format(rdi_entry_date, '%c/%e/%Y') as rdi_entry_date_verbose,
|
||||
date_format(rdi_permit_date, '%c/%e/%Y') as rdi_permit_date_verbose,
|
||||
date_format(rdi_created, '%c/%e/%Y %l:%i %p') as rdi_created_verbose,
|
||||
date_format(rdi_changed, '%c/%e/%Y %l:%i %p') as rdi_changed_verbose,
|
||||
|
||||
IF(
|
||||
rdi_phone IS NULL OR rdi_phone = '',
|
||||
'Not Provided',
|
||||
CONCAT('(', SUBSTRING(rdi_phone, 1, 3), ') ',
|
||||
SUBSTRING(rdi_phone, 4, 3), '-',
|
||||
SUBSTRING(rdi_phone, 7, 4)
|
||||
)) as rdi_phone_verbose,
|
||||
concat('$', format(rdi_value, 2)) as rdi_value_verbose,
|
||||
format(rdi_size, 0) as rdi_size_verbose
|
||||
|
||||
|
||||
from rdis";
|
||||
|
||||
//-- on counties.county_serial = counties.county_serial";
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_reports as
|
||||
|
||||
select reports.*,
|
||||
|
||||
date_format(report_created, '%c/%e/%Y %l:%i %p') as report_created_verbose,
|
||||
date_format(report_changed, '%c/%e/%Y %l:%i %p') as report_changed_verbose
|
||||
|
||||
from reports
|
||||
|
||||
order by report_description";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_searchhistories as
|
||||
|
||||
select searchhistories.*,
|
||||
date_format(searchhistory_created, '%c/%e/%Y %l:%i %p') as searchhistory_created_verbose,
|
||||
date_format(searchhistory_changed, '%c/%e/%Y %l:%i %p') as searchhistory_changed_verbose
|
||||
|
||||
from searchhistories";
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_statuses as
|
||||
|
||||
select statuses.*,
|
||||
|
||||
date_format(status_created, '%c/%e/%Y %l:%i %p') as status_created_verbose,
|
||||
date_format(status_changed, '%c/%e/%Y %l:%i %p') as status_changed_verbose
|
||||
|
||||
from statuses
|
||||
|
||||
order by status_name";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_subscriptions as
|
||||
|
||||
select subscriptions.*,
|
||||
date_format(subscription_created, '%c/%e/%Y %l:%i %p') as subscription_created_verbose,
|
||||
date_format(subscription_changed, '%c/%e/%Y %l:%i %p') as subscription_changed_verbose
|
||||
|
||||
from subscriptions
|
||||
|
||||
order by subscription_title";
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_supporttickets as
|
||||
|
||||
select supporttickets.*,
|
||||
date_format(supportticket_created, '%c/%e/%Y %l:%i %p') as supportticket_created_verbose,
|
||||
date_format(supportticket_changed, '%c/%e/%Y %l:%i %p') as supportticket_changed_verbose,
|
||||
|
||||
category.dropdown_value as supportticket_catagory_verbose,
|
||||
status.dropdown_value as supoortticket_status_verbose
|
||||
|
||||
from supporttickets
|
||||
|
||||
join dropdowns category
|
||||
on category.dropdown_serial = supporttickets.supportticket_category
|
||||
|
||||
left join dropdowns status
|
||||
on status.dropdown_serial = supporttickets.supportticket_status";
|
||||
?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_users as
|
||||
|
||||
select users.*,
|
||||
date_format(user_login, '%c/%e/%Y %l:%i %p') as user_login_verbose,
|
||||
date_format(user_created, '%c/%e/%Y %l:%i %p') as user_created_verbose,
|
||||
date_format(user_changed, '%c/%e/%Y %l:%i %p') as user_changed_verbose
|
||||
from users
|
||||
|
||||
order by users.user_name";
|
||||
?>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$SQL = "create view view_usersubscriptions as
|
||||
|
||||
select usersubscriptions.*, subscriptions.*,
|
||||
date_format(usersubscription_timestamp, '%m/%d/%Y %l:%i %p') as usersubscription_timestamp_verbose,
|
||||
date_format(usersubscription_stop_date, '%m/%d/%Y') as usersubscription_stop_date_verbose,
|
||||
|
||||
case when usersubscription_stop_date < CURDATE() then 'EXPIRED' else 'ACTIVE' end as usersubscription_status
|
||||
|
||||
from usersubscriptions
|
||||
|
||||
left join subscriptions
|
||||
on subscriptions.subscription_serial = usersubscriptions.usersubscription_subscription_serial
|
||||
|
||||
order by usersubscriptions.usersubscription_stop_date desc";
|
||||
?>
|
||||
Reference in New Issue
Block a user