From: Chuck Scott Date: Fri, 9 Mar 2018 14:11:22 +0000 (-0500) Subject: Another update for development of the Assets Dashboard. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=cbc4278dd9ce14f5f75e0e63a74f982f8d079ff3;p=WP-Plugins%2Fglm-member-db-assets.git Another update for development of the Assets Dashboard. --- diff --git a/models/admin/ajax/assetManagement.php b/models/admin/ajax/assetManagement.php index 3fa6dec..aaded14 100644 --- a/models/admin/ajax/assetManagement.php +++ b/models/admin/ajax/assetManagement.php @@ -69,9 +69,6 @@ class GlmMembersAdmin_ajax_assetManagement public function modelAction ($actionData = false) { -ini_set('log_errors_max_len', 20000); -trigger_error(print_r($_REQUEST,1),E_USER_NOTICE); - require_once GLM_MEMBERS_ASSETS_PLUGIN_CLASS_PATH.'/data/dataFacilities.php'; $Facilities = new GlmDataAssetsFacilities($this->wpdb, $this->config); @@ -79,18 +76,73 @@ trigger_error(print_r($_REQUEST,1),E_USER_NOTICE); die('No option specified.'); } +trigger_error("Option = ".$_REQUEST['option'],E_USER_NOTICE); + switch($_REQUEST['option']) { + case 'newFacility': + + $facility = $Facilities->newEntry(); + + $view = 'facilityForm'; + + $templateData = array( + 'status' => '0', + 'facility' => $facility['fieldData'] + ); + + break; + + case 'editFacility': + + $facilityId = 0; + if (isset($_REQUEST) && isset($_REQUEST['id']) ) { + $facilityId = $_REQUEST['id'] + 0; + } + + if ($facilityId > 0) { + $facility = $Facilities->editEntry($facilityId); +//echo "
".print_r($facility,1)."
"; +//die(); + $view = 'facilityForm'; + + $templateData = array( + 'status' => '0', + 'facility' => $facility['fieldData'] + ); + + } else { + die("2Facility not found!"); + } + + break; + case 'addNewFacility': $newFacility = $Facilities->insertEntry(); + $newFacilityAdded = true; if (!is_array($newFacility) || trim($newFacility['fieldData']['id']) == '') { - $newFacility['status'] = 0; + + $view = 'facilityForm'; + + // New facility was not added so we need to redisplay the form. + $templateData = array( + 'status' => 1, + 'cities' => $cities, + 'states' => $this->config['states'], + 'countries' => $this->config['countries'] + ); + } - $response = json_encode($newFacility, JSON_FORCE_OBJECT); - die($response); + $view = 'facilityLine'; + + // New facility was not added so we need to redisplay the form. + $templateData = array( + 'status' => '0', + 'facility' => $newFacility + ); break; @@ -98,11 +150,95 @@ trigger_error(print_r($_REQUEST,1),E_USER_NOTICE); die('No valid option provided'); break; } -die('done'); + + $templateData['$glmPluginMediaUrl'] = GLM_MEMBERS_PLUGIN_MEDIA_URL; + $html = $this->generateHTML($templateData, 'admin/assets/'.$view.'.html'); + die($html); die('Nothing Here'); } + /** + * Merge template and data to produce HTML + * + * Checks the theme's view directories and the view directories for + * this plugin for a matching view file. + * + * Note that $view needs to have the proper view directory path + * includes. (i.e. "/views/front/registrations/summary.html") + * + * $view may also be a template as a string if $viewIsString is true. + * + * @param $data array Array of data to merge with the template + * @param $view string Name of view file (see above)) + * @param $viewIsString boolean If true, $view is a string containing the view. + * + * @access public + * @return void + */ + function generateHTML($data, $view, $viewIsString = false) + { + + // Load Smarty Template support + $smarty = new smartyTemplateSupport(); + + // Add standard parameters + require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php'; + + // Add data from model to Smarty template + if (is_array($data) && count($data) > 0) { + foreach ($data as $k => $d) { + $smarty->templateAssign($k, $d); + } + } + + // If is supplied as a string + if ($viewIsString) { + + $out = $smarty->template->fetch('eval:'.$view); + + // Otherwise $view is a file name + } else { + + // Get the specified view file - check theme first + $viewPath = GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR."/views"; + $viewPath2 = GLM_MEMBERS_ASSETS_PLUGIN_PATH . "/views"; // Save default + + // If the view is not found in the theme, fall back to views in the plugin + if (!is_file($viewPath.'/'.$view)) { + + // Next try the plugin/add-on + $viewPath = GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . "/views"; + + if (!is_file($viewPath.'/'.$view)) { + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("Bad or missing view file when generating checkout HTML: $viewPath/$view", E_USER_NOTICE); + } + + } + + } + + // Update the Smarty view path + $smarty->template->setTemplateDir($viewPath); + + // If the view path doesn't match the default, add the default (using theme view) + if ($viewPath2 != $viewPath) { + $smarty->template->addTemplateDir($viewPath2); + } + + // Generate output from model data and view + $out = $smarty->template->fetch($view); + + } + + return $out; + + } + + + } diff --git a/models/admin/assets/index.php b/models/admin/assets/index.php index 9cc35f0..7519d0e 100644 --- a/models/admin/assets/index.php +++ b/models/admin/assets/index.php @@ -83,24 +83,14 @@ class GlmMembersAdmin_assets_index extends GlmDataAssetsFacilities // Get all facility data with assets items and any future assignments of those assets items $facilities = $this->getList(); - if (is_array($facilities) && count(facilities) > 0) { + if (is_array($facilities) && count($facilities) > 0) { $haveFacilities = true; } - // Get cities list - require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'; - $Cities = new GlmDataCities($this->wpdb, $this->config); - $cities = $Cities->getList(); - - -//echo "
".print_r($this->config,1)."
"; - // Compile template data $templateData = array( 'haveFacilities' => $haveFacilities, - 'cities' => $cities, - 'states' => $this->config['states'], - 'countries' => $this->config['countries'] + 'facilities' => $facilities ); // Return status, any suggested view, and any data to controller diff --git a/views/admin/assets/facilityForm.html b/views/admin/assets/facilityForm.html new file mode 100644 index 0000000..5bfd495 --- /dev/null +++ b/views/admin/assets/facilityForm.html @@ -0,0 +1,109 @@ +{$status} + + + + + {* New Facility Dialog Box *} + +
+ + + + +
+ +
Name:
+
+ +
Description:
+
+ +
Address:
+
+ +
City:
+
+ +
+ +
State:
+
+ +
+ +
ZIP / Postal Code:
+
+ +
Country:
+
+ +
+ + + +
Phone:
+
+ +
URL:
+
+ +
E-Mail Address:
+
+ +
Facility Map:
+
+

+ Facility map file must be a standard image file such as JPG, PNG, or GIF and + of adequate size and resolution. Images larger than 1200 pixels wide may be + too large for the page. +

+ +

******* IMAGE URL NOT WORKING *********

+ + {$facility.facility_map}
+ Delete Image
+ New image: +
+ +
 
 
+ +
* Required
+
+ + Cancel +
+ +
{* assetsFacilityDialog *} + + +
diff --git a/views/admin/assets/facilityLine.html b/views/admin/assets/facilityLine.html new file mode 100644 index 0000000..ef7e5ce --- /dev/null +++ b/views/admin/assets/facilityLine.html @@ -0,0 +1,4 @@ +{$status} + +
{$facility.fieldData.name}
+
Edit Delete
diff --git a/views/admin/assets/index.html b/views/admin/assets/index.html index a6d3f23..04f3207 100644 --- a/views/admin/assets/index.html +++ b/views/admin/assets/index.html @@ -41,49 +41,51 @@ Add a Facility +
{if $haveFacilities} - -
{foreach $facilities as $facility} -
{$facility.name}
+
{$facility.name} {$facility.id}
{* First indent here *} - + -
Asset Type
-
Name
-
Number
-
Quantity
+
Asset Type
+
Name
+
Number
+
Quantity
{foreach $facility.assets as $asset} -
Room
-
Ballroom
-
101
-
1
+
Room
+
Ballroom
+
101
+
1
{* Second indent here *} -
Edit Delete
+ -
Start
-
End
-
Account
-
Quantity
+
Start
+
End
+
Account
+
Quantity
{foreach $asset.assignments as $assignment} -
1/1/2018 07:00 AM
-
1/1/2018 05:00 PM
-
Gaslight Media
-
1
+
1/1/2018 07:00 AM
+
1/1/2018 05:00 PM
+
Gaslight Media
+
class="facility_{$facility.id} glm-hidden"1
{* Third indent here *} -
Edit Delete
+ {/foreach} {* assignments *} @@ -93,351 +95,158 @@ {else} {* if haveFacilities *} -
No Facilities Listed
+
No Facilities Listed
{/if} {* if haveFacilities *} + +
{* assetsFacilitiesContainer *} -
{* assets-admin-content *} - - {* glm-admin-table-inner *} - - {* glm-admin-table *} + {* assets-admin-inner *} - {* New Facility Dialog Box *} -
-
- +
{* glm-admin-table-inner *} -
- -
Name:
-
- -
Description:
-
- -
Address:
-
- -
City:
-
- -
- -
State:
-
- -
- -
ZIP / Postal Code:
-
- -
Country:
-
- -
- - - -
Phone:
-
- -
URL:
-
- -
E-Mail Address:
-
- -
Facility Map:
-
-

- Facility map file must be a standard image file such as JPG, PNG, or GIF and - of adequate size and resolution. Images larger than 1200 pixels wide may be - too large for the page. -

- (image url here)
- Delete Image
- New image: -
- -
 
 
- -
* Required
-
- Add New Facility - Cancel -
- -
{* assetsFacilityDialog *} - - - - + {* glm-admin-table *}
{* facility_name *}
- +
+
+