From c6d5516467d3b3d34b2c42be212dd4f091851f82 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 5 Nov 2019 08:13:42 -0700 Subject: [PATCH] Database Transactions: List view updates. Misc Action Bar adjustments. Include missing class for Conferences (Doh). --- app/access_controls/access_controls.php | 2 +- app/bridges/bridges.php | 2 +- app/call_block/call_block.php | 2 +- app/call_broadcast/call_broadcast.php | 2 +- app/call_center_active/call_center_queue.php | 2 +- app/call_centers/call_center_agents.php | 2 +- app/call_centers/call_center_queues.php | 2 +- app/call_flows/call_flows.php | 2 +- app/calls/calls.php | 2 +- app/calls_active/calls_active_inc.php | 1 - app/conference_centers/conference_centers.php | 2 +- app/conferences/conferences.php | 2 +- .../resources/classes/conferences.php | 385 ++++++++++++++++++ app/contacts/contacts.php | 2 +- .../database_transactions.php | 150 ++++--- 15 files changed, 467 insertions(+), 93 deletions(-) create mode 100644 app/conferences/resources/classes/conferences.php diff --git a/app/access_controls/access_controls.php b/app/access_controls/access_controls.php index ecd3dd455c..586e82d364 100644 --- a/app/access_controls/access_controls.php +++ b/app/access_controls/access_controls.php @@ -135,7 +135,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'access_controls.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo " \n"; echo " \n"; diff --git a/app/bridges/bridges.php b/app/bridges/bridges.php index 4e653b8cdc..6495be133e 100644 --- a/app/bridges/bridges.php +++ b/app/bridges/bridges.php @@ -174,7 +174,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'bridges.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo " \n"; echo " \n"; diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index c55024acec..d0307f0cdf 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -179,7 +179,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_block.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo " \n"; echo " \n"; diff --git a/app/call_broadcast/call_broadcast.php b/app/call_broadcast/call_broadcast.php index 3d0564f2e3..892d0815bd 100644 --- a/app/call_broadcast/call_broadcast.php +++ b/app/call_broadcast/call_broadcast.php @@ -140,7 +140,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_broadcast.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo " \n"; echo " \n"; diff --git a/app/call_center_active/call_center_queue.php b/app/call_center_active/call_center_queue.php index fdfc1d111b..fc6fba428b 100644 --- a/app/call_center_active/call_center_queue.php +++ b/app/call_center_active/call_center_queue.php @@ -96,7 +96,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_center_queue.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo " \n"; echo " \n"; diff --git a/app/call_centers/call_center_agents.php b/app/call_centers/call_center_agents.php index 52e72334c6..bb2b90b797 100644 --- a/app/call_centers/call_center_agents.php +++ b/app/call_centers/call_center_agents.php @@ -142,7 +142,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_center_agents.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo button::create(['type'=>'button','label'=>$text['button-status'],'icon'=>'user-clock','style'=>'margin-left: 15px;','link'=>'call_center_agent_status.php']); echo " \n"; diff --git a/app/call_centers/call_center_queues.php b/app/call_centers/call_center_queues.php index 0180a87f8b..cd0975fa84 100644 --- a/app/call_centers/call_center_queues.php +++ b/app/call_centers/call_center_queues.php @@ -141,7 +141,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_center_queues.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } if (permission_exists('call_center_agent_view')) { echo button::create(['type'=>'button','label'=>$text['button-agents'],'icon'=>'users','style'=>'margin-left: 15px;','link'=>'call_center_agents.php']); diff --git a/app/call_flows/call_flows.php b/app/call_flows/call_flows.php index a0f382a08f..1127057b31 100644 --- a/app/call_flows/call_flows.php +++ b/app/call_flows/call_flows.php @@ -160,7 +160,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_flows.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo " \n"; echo " \n"; diff --git a/app/calls/calls.php b/app/calls/calls.php index 340ab3a51e..7c133f790d 100644 --- a/app/calls/calls.php +++ b/app/calls/calls.php @@ -198,7 +198,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'calls.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo " \n"; echo " \n"; diff --git a/app/calls_active/calls_active_inc.php b/app/calls_active/calls_active_inc.php index 1ae8bcfc99..a2972eb836 100644 --- a/app/calls_active/calls_active_inc.php +++ b/app/calls_active/calls_active_inc.php @@ -120,7 +120,6 @@ echo "
\n"; echo "
".$text['title']." (".$num_rows.")
\n"; echo "
\n"; -// echo " \"".$text['label-refresh_pause']."\""; echo " ".button::create(['type'=>'button','title'=>$text['label-refresh_pause'],'icon'=>'sync-alt fa-spin','onclick'=>'refresh_stop()']).""; if (permission_exists('call_active_hangup') && $rows) { echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','onclick'=>"if (confirm('".$text['confirm-hangups']."')) { list_action_set('hangup'); list_form_submit('form_list'); } else { this.blur(); return false; }"]); diff --git a/app/conference_centers/conference_centers.php b/app/conference_centers/conference_centers.php index 4d83189756..a8395916c2 100644 --- a/app/conference_centers/conference_centers.php +++ b/app/conference_centers/conference_centers.php @@ -159,7 +159,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'conference_centers.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } echo ""; if (permission_exists('conference_active_advanced_view')) { diff --git a/app/conferences/conferences.php b/app/conferences/conferences.php index ae3dae0370..cfd773073c 100644 --- a/app/conferences/conferences.php +++ b/app/conferences/conferences.php @@ -166,7 +166,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'conferences.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } if (permission_exists('conference_active_view')) { echo button::create(['type'=>'button','label'=>$text['button-view_active'],'icon'=>'comments','style'=>'margin-left: 15px;','link'=>PROJECT_PATH.'/app/conferences_active/conferences_active.php']); diff --git a/app/conferences/resources/classes/conferences.php b/app/conferences/resources/classes/conferences.php new file mode 100644 index 0000000000..b6765f603a --- /dev/null +++ b/app/conferences/resources/classes/conferences.php @@ -0,0 +1,385 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2019 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//define the conferences class +if (!class_exists('conferences')) { + class conferences { + + /** + * declare private variables + */ + private $app_name; + private $app_uuid; + private $permission_prefix; + private $list_page; + private $table; + private $uuid_prefix; + private $toggle_field; + private $toggle_values; + + /** + * called when the object is created + */ + public function __construct() { + + //assign private variables + $this->app_name = 'conferences'; + $this->app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; + $this->permission_prefix = 'conference_'; + $this->list_page = 'conferences.php'; + $this->table = 'conferences'; + $this->uuid_prefix = 'conference_'; + $this->toggle_field = 'conference_enabled'; + $this->toggle_values = ['true','false']; + + } + + /** + * called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + /** + * delete records + */ + public function delete($records) { + if (permission_exists($this->permission_prefix.'delete')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->list_page); + exit; + } + + //delete multiple records + if (is_array($records) && @sizeof($records) != 0) { + + //build the delete array + foreach ($records as $x => $record) { + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + + //get the dialplan uuid + $sql = "select dialplan_uuid from v_conferences "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and conference_uuid = :conference_uuid "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['conference_uuid'] = $record['uuid']; + $database = new database; + $dialplan_uuid = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); + + //build array + $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; + $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['conference_users'][$x]['conference_uuid'] = $record['uuid']; + $array['conference_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + + } + } + + //delete the checked rows + if (is_array($array) && @sizeof($array) != 0) { + + //grant temporary permissions + $p = new permissions; + $p->add('conference_user_delete', 'temp'); + $p->add('dialplan_detail_delete', 'temp'); + $p->add('dialplan_delete', 'temp'); + + //execute delete + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->delete($array); + unset($array); + + //revoke temporary permissions + $p->delete('conference_user_delete', 'temp'); + $p->delete('dialplan_detail_delete', 'temp'); + $p->delete('dialplan_delete', 'temp'); + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //clear the cache + $cache = new cache; + $cache->delete("dialplan:".$_SESSION["context"]); + + //set message + message::add($text['message-delete']); + + } + unset($records); + } + } + } + + /** + * toggle records + */ + public function toggle($records) { + if (permission_exists($this->permission_prefix.'edit')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->list_page); + exit; + } + + //toggle the checked records + if (is_array($records) && @sizeof($records) != 0) { + + //get current toggle state + foreach($records as $x => $record) { + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + $record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'"; + } + } + if (is_array($record_uuids) && @sizeof($record_uuids) != 0) { + $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." "; + $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; + $sql .= "and ( ".implode(' or ', $record_uuids)." ) "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $database = new database; + $rows = $database->select($sql, $parameters, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + foreach ($rows as $row) { + $conferences[$row['uuid']]['state'] = $row['toggle']; + $conferences[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid']; + } + } + unset($sql, $parameters, $rows, $row); + } + + //build update array + $x = 0; + foreach($conferences as $uuid => $conference) { + $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid; + $array[$this->table][$x][$this->toggle_field] = $conference['state'] == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; + $array['dialplans'][$x]['dialplan_uuid'] = $conference['dialplan_uuid']; + $array['dialplans'][$x]['dialplan_enabled'] = $conference['state'] == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; + $x++; + } + + //save the changes + if (is_array($array) && @sizeof($array) != 0) { + + //grant temporary permissions + $p = new permissions; + $p->add('dialplan_edit', 'temp'); + + //save the array + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->save($array); + unset($array); + + //revoke temporary permissions + $p->delete('dialplan_edit', 'temp'); + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //clear the cache + $cache = new cache; + $cache->delete("dialplan:".$_SESSION["context"]); + + //set message + message::add($text['message-toggle']); + } + unset($records, $states); + } + + } + } + + /** + * copy records + */ + public function copy($records) { + if (permission_exists($this->permission_prefix.'add')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->list_page); + exit; + } + + //copy the checked records + if (is_array($records) && @sizeof($records) != 0) { + + //get checked records + foreach($records as $x => $record) { + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + $record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'"; + } + } + + //create insert array from existing data + if (is_array($record_uuids) && @sizeof($record_uuids) != 0) { + $sql = "select * from v_".$this->table." "; + $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; + $sql .= "and ( ".implode(' or ', $record_uuids)." ) "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $database = new database; + $rows = $database->select($sql, $parameters, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + $y = 0; + foreach ($rows as $x => $row) { + + //copy data + $array[$this->table][$x] = $row; + + //overwrite + $conference_uuid = uuid(); + $dialplan_uuid = uuid(); + $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $conference_uuid; + $array[$this->table][$x]['dialplan_uuid'] = $dialplan_uuid; + $array[$this->table][$x]['conference_description'] = trim($row['conference_description'].' ('.$text['label-copy'].')'); + + //get conference conference users + $sql = "select * from v_conference_users "; + $sql .= "where conference_uuid = :conference_uuid "; + $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; + $parameters['conference_uuid'] = $row['conference_uuid']; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $database = new database; + $conference_users = $database->select($sql, $parameters, 'all'); + unset($sql, $parameters); + + //insert the conference users in array + if (is_array($conference_users) && @sizeof($conference_users) != 0) { + foreach ($conference_users as $user) { + $array['conference_users'][$y]['conference_user_uuid'] = uuid(); + $array['conference_users'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['conference_users'][$y]['conference_uuid'] = $conference_uuid; + $array['conference_users'][$y]['user_uuid'] = $user['user_uuid']; + $y++; + } + } + + //build the dialplan xml + $dialplan_xml = "\n"; + $dialplan_xml .= " \n"; + $dialplan_xml .= " \n"; + $dialplan_xml .= " \n"; + $dialplan_xml .= " \n"; + $dialplan_xml .= "\n"; + + //insert the conference dialplan in array + $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_name'] = $row['conference_name']; + $array['dialplans'][$x]['dialplan_number'] = $row['conference_extension']; + $array['dialplans'][$x]['app_uuid'] = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; + $array['dialplans'][$x]['dialplan_xml'] = $dialplan_xml; + $array['dialplans'][$x]['dialplan_order'] = '333'; + $array['dialplans'][$x]['dialplan_context'] = $_SESSION['context']; + $array['dialplans'][$x]['dialplan_enabled'] = $row['conference_enabled']; + $array['dialplans'][$x]['dialplan_description'] = $row['conference_description'].' ('.$text['label-copy'].')'; + + } + } + unset($sql, $parameters, $rows, $row); + } + + //save the changes and set the message + if (is_array($array) && @sizeof($array) != 0) { + + //grant temporary permissions + $p = new permissions; + $p->add('conference_user_add', 'temp'); + $p->add('dialplan_add', 'temp'); + + //save the array + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->save($array); + unset($array); + + //revoke temporary permissions + $p->delete('conference_user_add', 'temp'); + $p->delete('dialplan_add', 'temp'); + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //clear the cache + $cache = new cache; + $cache->delete("dialplan:".$_SESSION["context"]); + + //set message + message::add($text['message-copy']); + + } + unset($records); + } + + } + } + + } +} + +?> \ No newline at end of file diff --git a/app/contacts/contacts.php b/app/contacts/contacts.php index 453a61157c..00dc3239cb 100644 --- a/app/contacts/contacts.php +++ b/app/contacts/contacts.php @@ -260,7 +260,7 @@ echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'contacts.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { - echo " ".$paging_controls_mini.""; + echo "".$paging_controls_mini.""; } if (permission_exists('contact_add')) { echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>'file-import','link'=>'contact_import.php','style'=>'margin-left: 15px;']); diff --git a/app/database_transactions/database_transactions.php b/app/database_transactions/database_transactions.php index 25c91f8fb1..3cef663bed 100644 --- a/app/database_transactions/database_transactions.php +++ b/app/database_transactions/database_transactions.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2016 + Portions created by the Initial Developer are Copyright (C) 2016 - 2019 the Initial Developer. All Rights Reserved. Contributor(s): @@ -27,10 +27,10 @@ //includes require_once "root.php"; require_once "resources/require.php"; + require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions - require_once "resources/check_auth.php"; if (permission_exists('database_transaction_view')) { //access granted } @@ -43,26 +43,34 @@ $language = new text; $text = $language->get(); +//get posted data + if (is_array($_POST['bridges'])) { + $action = $_POST['action']; + $search = $_POST['search']; + } + //get variables used to control the order - $order_by = $_GET["order_by"] != '' ? $_GET['order_by'] : 'transaction_date'; - $order = $_GET["order"] != '' ? $_GET['order'] : 'desc'; + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; //add the search term $search = strtolower($_GET["search"]); if ($search != '') { $sql_search = "and ("; - $sql_search .= " lower(app_name) like :search "; - $sql_search .= " or lower(transaction_code) like :search "; - $sql_search .= " or lower(transaction_address) like :search "; - $sql_search .= " or lower(transaction_type) like :search "; - $sql_search .= " or cast(transaction_date as text) like :search "; + $sql_search .= " lower(t.app_name) like :search "; + $sql_search .= " or lower(t.transaction_code) like :search "; + $sql_search .= " or lower(t.transaction_address) like :search "; + $sql_search .= " or lower(t.transaction_type) like :search "; + $sql_search .= " or cast(t.transaction_date as text) like :search "; $sql_search .= ") "; $parameters['search'] = '%'.$search.'%'; } //prepare to page the results - $sql = "select count(database_transaction_uuid) from v_database_transactions "; - $sql .= "where domain_uuid = :domain_uuid "; + $sql = "select count(*) from v_database_transactions as t "; + $sql .= "left outer join v_domains as d using (domain_uuid) "; + $sql .= "left outer join v_users as u using (user_uuid) "; + $sql .= "where t.domain_uuid = :domain_uuid "; $sql .= $sql_search; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; @@ -73,46 +81,42 @@ $param = "search=".$search; $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); + list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; //get the list - $sql = "select "; - $sql .= "t.database_transaction_uuid, d.domain_name, u.username, t.user_uuid, t.app_name, t.app_uuid, "; - $sql .= "t.transaction_code, t.transaction_address, t.transaction_type, t.transaction_date "; - $sql .= "from v_database_transactions as t "; - $sql .= "left outer join v_domains as d using (domain_uuid) "; - $sql .= "left outer join v_users as u using (user_uuid) "; - $sql .= "where t.domain_uuid = :domain_uuid "; - $sql .= $sql_search; - $sql .= order_by($order_by, $order); + $sql = str_replace('count(*)','t.database_transaction_uuid, d.domain_name, u.username, t.user_uuid, t.app_name, t.app_uuid, t.transaction_code, t.transaction_address, t.transaction_type, t.transaction_date', $sql); + $sql .= order_by($order_by, $order, 't.transaction_date', 'desc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; $result = $database->select($sql, $parameters, 'all'); - -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; + unset($sql); //additional includes require_once "resources/header.php"; //show the content - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo "
\n"; + echo "
".$text['title-database_transactions']." (".$num_rows.")
\n"; + echo "
\n"; + echo "\n"; + echo ""; + echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); + echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'bridges.php','style'=>($search == '' ? 'display: none;' : null)]); + if ($paging_controls_mini != '') { + echo "".$paging_controls_mini.""; + } echo " \n"; - echo "
\n"; - echo "
".$text['title-database_transactions']."
\n"; - echo " \n"; - echo " \n"; - echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; - echo "\n"; - echo "\n"; + echo $text['description-database_transactions']."\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); echo th_order_by('username', $text['label-user_uuid'], $order_by, $order); echo th_order_by('app_name', $text['label-app_name'], $order_by, $order); @@ -123,58 +127,44 @@ //echo th_order_by('transaction_old', $text['label-transaction_old'], $order_by, $order); //echo th_order_by('transaction_new', $text['label-transaction_new'], $order_by, $order); //echo th_order_by('transaction_result', $text['label-transaction_result'], $order_by, $order); - echo "\n"; - echo "\n"; + if (permission_exists('database_transaction_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; + } + echo "\n"; if (is_array($result)) { + $x = 0; foreach($result as $row) { if (permission_exists('database_transaction_edit')) { - $tr_link = "href='database_transaction_edit.php?id=".urlencode($row['database_transaction_uuid']).($page != '' ? "&page=".urlencode($page) : null).($search != '' ? "&search=".urlencode($search) : null)."'"; + $list_row_url = "database_transaction_edit.php?id=".urlencode($row['database_transaction_uuid']).($page != '' ? "&page=".urlencode($page) : null).($search != '' ? "&search=".urlencode($search) : null); } - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; if (permission_exists('database_transaction_edit')) { - echo "$v_link_label_view"; + echo " \n"; } - //if (permission_exists('database_transaction_delete')) { - // echo "$v_link_label_delete"; - //} - echo " \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); - } //end if results + $x++; + } + unset($result); + } - echo "\n"; - echo "\n"; - echo "\n"; - echo "
"; - echo "  \n"; - echo "
 
".escape($row['domain_name'])." ".escape($row['username'])." ".escape($row['app_name'])." ".escape($row['transaction_code'])." ".escape($row['transaction_address'])." ".escape($row['transaction_type'])." ".escape($row['transaction_date'])." ".escape($row['transaction_old']." ".escape($row['transaction_new']." ".escape($row['transaction_result']." "; + echo "
".escape($row['domain_name'])." ".escape($row['username'])." ".escape($row['app_name'])." ".escape($row['transaction_code'])." ".escape($row['transaction_address'])." ".escape($row['transaction_type'])." ".escape($row['transaction_date'])." ".escape($row['transaction_old']." ".escape($row['transaction_new']." ".escape($row['transaction_result']." "; + echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]); + echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; - echo " "; - echo "
\n"; - echo "
"; - echo "

"; + echo "\n"; + echo "
\n"; + echo "
".$paging_controls."
\n"; //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file