Asset Management Development Task List
[X] Create Base Plugin
-[ ] Create Admin Menus
+[X] Create Admin Menus
[X] Main: Asset Mgt
[X] Create Database Tables
[X] Create Data Classes for Tables
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Assets support class
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release assetsSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+/*
+ * This class provides some standard methods used by this plugin
+ */
+class GlmAssetsSupport
+{
+
+ /**
+ * 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;
+
+ }
+
+
+
+
+
+}
\ No newline at end of file
'type' => 'money',
'use' => 'a'
),
+/*
+ // IMage
+ 'image' => array (
+ 'field' => 'image',
+ 'type' => 'image',
+ 'use' => 'a'
+ ),
+*/
// Facility
'facility' => array (
/**
* Gaslight Media Members Database
- * Asset Management - Asset Admin
+ * Asset Management - Asset Admin - Asset Management
*
* PHP version 5.5
*
* @version 0.1
*/
+require_once GLM_MEMBERS_ASSETS_PLUGIN_CLASS_PATH.'/assetsSupport.php';
+
/*
* This class performs the work of handling images passed to it via
* an AJAX call that goes through the WorPress AJAX Handler.
*
*/
-class GlmMembersAdmin_ajax_assetManagement
+class GlmMembersAdmin_ajax_assetManagement extends GlmAssetsSupport
{
/**
public function modelAction ($actionData = false)
{
- require_once GLM_MEMBERS_ASSETS_PLUGIN_CLASS_PATH.'/data/dataFacilities.php';
- $Facilities = new GlmDataAssetsFacilities($this->wpdb, $this->config);
+ require_once GLM_MEMBERS_ASSETS_PLUGIN_CLASS_PATH.'/data/dataAssetItems.php';
+ $Assets = new GlmDataAssetsAssetItems($this->wpdb, $this->config);
if (!isset($_REQUEST) || !isset($_REQUEST['option'])) {
die('No option specified.');
switch($_REQUEST['option']) {
- case 'newFacility':
+ case 'newAsset':
- $facility = $Facilities->newEntry();
+ $asset = $Assets->newEntry();
- $view = 'facilityForm';
+ $view = 'assetForm';
$templateData = array(
'status' => '0',
'use' => 'add',
- 'facility' => $facility['fieldData']
+ 'asset' => $asset['fieldData']
);
break;
- case 'addNewFacility':
+ case 'addNewAsset':
- $facility = $Facilities->insertEntry();
+ $asset = $Assets->insertEntry();
- // If facility was not added
- if (!is_array($facility) || trim($facility['fieldData']['id']) == '') {
+ // If asset was not added
+ if (!is_array($asset) || trim($facility['asset']['id']) == '') {
- $view = 'facilityForm';
+ $view = 'assetForm';
- // New facility was not added so we need to redisplay the form.
+ // New asset was not added so we need to redisplay the form.
$templateData = array(
'status' => 1,
- 'use' => 'add',
- 'cities' => $cities,
- 'states' => $this->config['states'],
- 'countries' => $this->config['countries']
+ 'use' => 'add'
);
- // Facility Added
+ // Asset Added
} else {
- $view = 'facilityLine';
+ $view = 'assetLine';
$templateData = array(
'status' => '0',
- 'facility' => $facility
+ 'asset' => $asset
);
}
break;
- case 'editFacility':
+ case 'editAsset':
- $facilityId = 0;
+ $assetId = 0;
if (isset($_REQUEST) && isset($_REQUEST['id']) ) {
- $facilityId = $_REQUEST['id'] + 0;
+ $assetId = $_REQUEST['id'] + 0;
}
- if ($facilityId > 0) {
- $facility = $Facilities->editEntry($facilityId);
- //echo " <pre>".print_r($facility,1)."</pre>";
- //die();
- $view = 'facilityForm';
+ if ($assetId > 0) {
+
+ $asset = $Assets->editEntry($facilityId);
+
+ $view = 'assetForm';
$templateData = array(
'status' => '0',
'use' => 'edit',
- 'facility' => $facility['fieldData']
+ 'asset' => $asset['fieldData']
);
} else {
- die('1'.$this->config['terms']['assets_term_facility_cap'].' not found!');
+ die('1'.$this->config['terms']['assets_term_asset_cap'].' not found!');
}
break;
- case 'updateFacility':
+ case 'updateAsset':
$id = $_REQUEST['id'] - 0;
if ($id <= 0) {
- die('2'.$this->config['terms']['assets_term_facility_cap'].' ID not provided! Unable to edit.');
+ die('2'.$this->config['terms']['assets_term_asset_cap'].' ID not provided! Unable to edit.');
}
- $facility = $Facilities->updateEntry($id);
+ $asset = $Assets->updateEntry($id);
- // If facility was not propertlyupdated
- if (!is_array($facility) || trim($facility['fieldData']['id']) == '') {
+ // If asset was not propertlyupdated
+ if (!is_array($asset) || trim($asset['fieldData']['id']) == '') {
- $view = 'facilityForm';
+ $view = 'assetForm';
- // New facility was not added so we need to redisplay the form.
+ // New asset was not added so we need to redisplay the form.
$templateData = array(
'status' => 2,
- 'use' => 'add',
- 'cities' => $cities,
- 'states' => $this->config['states'],
- 'countries' => $this->config['countries']
+ 'use' => 'add'
);
} else {
- die('0'.$facility['fieldData']['name']);
+ die('0'.$asset['fieldData']['name']);
}
break;
}
- /**
- * 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;
-
- }
-
-
-
}
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Asset Management - Asset Admin - Facility Management
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+require_once GLM_MEMBERS_ASSETS_PLUGIN_CLASS_PATH.'/assetsSupport.php';
+
+/*
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_facilityManagement extends GlmAssetsSupport
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This contructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This modelAction takes an AJAX image upload and stores the image in the
+ * media/images directory of the plugin.
+ *
+ * This model action does not return, it simply does it's work then calls die();
+ *
+ * Status characters returned
+ * 0 - Submission OK
+ * 1 - Faciltiy not found when trying to edit
+ * 2 - ID not provided for facility update on form submission
+ *
+ */
+ public function modelAction ($actionData = false)
+ {
+
+ require_once GLM_MEMBERS_ASSETS_PLUGIN_CLASS_PATH.'/data/dataFacilities.php';
+ $Facilities = new GlmDataAssetsFacilities($this->wpdb, $this->config);
+
+ if (!isset($_REQUEST) || !isset($_REQUEST['option'])) {
+ 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',
+ 'use' => 'add',
+ 'facility' => $facility['fieldData']
+ );
+
+ break;
+
+ case 'addNewFacility':
+
+ $facility = $Facilities->insertEntry();
+
+ // If facility was not added
+ if (!is_array($facility) || trim($facility['fieldData']['id']) == '') {
+
+ $view = 'facilityForm';
+
+ // New facility was not added so we need to redisplay the form.
+ $templateData = array(
+ 'status' => 1,
+ 'use' => 'add',
+ 'cities' => $cities,
+ 'states' => $this->config['states'],
+ 'countries' => $this->config['countries']
+ );
+
+ // Facility Added
+ } else {
+
+ $view = 'facilityLine';
+
+ $templateData = array(
+ 'status' => '0',
+ 'facility' => $facility
+ );
+
+ }
+
+ break;
+
+ case 'editFacility':
+
+ $facilityId = 0;
+ if (isset($_REQUEST) && isset($_REQUEST['id']) ) {
+ $facilityId = $_REQUEST['id'] + 0;
+ }
+
+ if ($facilityId > 0) {
+ $facility = $Facilities->editEntry($facilityId);
+ //echo " <pre>".print_r($facility,1)."</pre>";
+ //die();
+ $view = 'facilityForm';
+
+ $templateData = array(
+ 'status' => '0',
+ 'use' => 'edit',
+ 'facility' => $facility['fieldData']
+ );
+
+ } else {
+ die('1'.$this->config['terms']['assets_term_facility_cap'].' not found!');
+ }
+
+ break;
+
+ case 'updateFacility':
+
+ $id = $_REQUEST['id'] - 0;
+ if ($id <= 0) {
+ die('2'.$this->config['terms']['assets_term_facility_cap'].' ID not provided! Unable to edit.');
+ }
+
+ $facility = $Facilities->updateEntry($id);
+
+ // If facility was not propertlyupdated
+ if (!is_array($facility) || trim($facility['fieldData']['id']) == '') {
+
+ $view = 'facilityForm';
+
+ // New facility was not added so we need to redisplay the form.
+ $templateData = array(
+ 'status' => 2,
+ 'use' => 'add',
+ 'cities' => $cities,
+ 'states' => $this->config['states'],
+ 'countries' => $this->config['countries']
+ );
+
+ } else {
+ die('0'.$facility['fieldData']['name']);
+ }
+
+ break;
+
+ default:
+ die('No valid option provided');
+ break;
+ }
+
+ $templateData['$glmPluginMediaUrl'] = GLM_MEMBERS_PLUGIN_MEDIA_URL;
+ $html = $this->generateHTML($templateData, 'admin/assets/'.$view.'.html');
+ die($html);
+
+
+ die('Nothing Here');
+
+ }
+
+}
lead_time INTEGER NULL, -- Actual lead time required to request this item - Abstract "interval" type
reuse_time INTEGER NULL, -- Actual time required to prepair this type for reuse for this item - Abstract "interval" type
cost FLOAT NULL, -- Default cost for use of this asset type
+ ++image TINYTEXT NULL, -- Asset Image
facility INTEGER NULL, -- Pointer to facility
-- Map location data has to go here
PRIMARY KEY (id),
status TINYINT NULL, -- Status of this assignment - Config list "assignment_status"
name TINYTEXT NULL, -- Name of this assignment (Event, requester, ...)
account INTEGER NULL, -- Pointer to account record
- start_time DATETIME NULL, -- Start time of assignment
- end_time DATETIME NULL, -- End time of assignment
+ --start_time DATETIME NULL, -- Start time of assignment
+ --end_time DATETIME NULL, -- End time of assignment
PRIMARY KEY (id),
INDEX (start_time),
INDEX (end_time),
asset_item INTEGER NULL, -- Pointer to asset_item
asset_type INTEGER NULL, -- Pointer to asset_type
quant INTEGER NULL, -- Quantity of asset_item assigned - Default to 1
+ ++start_time DATETIME NULL, -- Start time of assignment
+ ++end_time DATETIME NULL, -- End time of assignment
hold_release_time DATETIME NULL, -- Time at which hold on this asset item is released (0 if assignment is complete)
PRIMARY KEY (id),
INDEX (asset_assignment),
$glmMembersAssetsAddOnValidActions = array(
'adminActions' => array(
'ajax' => array(
+ 'facilityManagement' => GLM_MEMBERS_ASSETS_PLUGIN_SLUG,
'assetManagement' => GLM_MEMBERS_ASSETS_PLUGIN_SLUG
),
'assets' => array(
--- /dev/null
+{$status} {* first character of this file is a status flag for the calling AJAX code. *}
+
+*** Still Building Form ***<br>
+
+ <style type='text/css'>
+ .assets-dialog-box {
+ display: grid;
+ grid-gap: 5px 5px;
+ grid-template-columns: 8rem auto;
+ }
+ .assets-facility-descr {
+ width: 30em !important;
+ }
+ .assets-asset-input-prompt {
+ padding: 5px 0 0 5px;
+ }
+ .assetsAssetInputReqired {
+ color: red;
+ }
+ </style>
+
+
+ {* Asset Dialog Box *}
+
+ <form id="assetForm" method="post" enctype="multipart/form-data">
+
+ <input type="hidden" name="glm_action" value="assetManagement">
+ {if $use == 'add'}
+ <input type="hidden" name="option" value="addNewAsset">
+ {/if}
+ {if $use == 'edit'}
+ <input type="hidden" name="option" value="updateAsset">
+ <input type="hidden" name="id" value="{$asset.id}">
+ {/if}
+
+ <div class="assets-dialog-box">
+
+ <div class="glm-required assets-asset-input-prompt">Name:</div>
+ <div><input type="text" name="name" class="glm-form-text-intput glm-form-text-input-medium" value="{$asset.name}" required><span id="assetsAssetInputMsg_name" class="assetsAssetInputReqired"></span></div>
+
+ <div class="assets-asset-input-prompt">Description:</div>
+ <div><textarea name="descr" class="glm-form-textarea assets-asset-descr">{$asset.descr}</textarea></div>
+
+ <div class="assets-asset-input-prompt">{$terms.assets_term_facility_cap} Image:</div>
+ <div>
+ {if $asset.image}
+ <input type="checkbox" name="logo_delete"> Delete Image<br>
+ <img src="{$glmPluginMediaUrl}/images/small/{$asset.image}"><br>
+ <a href="{$glmPluginMediaUrl}/images/large/{$asset.image}" target="assetImage">{$asset.image}</a><br>
+ {/if}
+ <b>New image:</b> <input id="assetImage" type="file" name="image_new">
+ </div>
+
+ <div> </div><div> </div>
+
+ <div><span class="glm-required">*</span> Required</div>
+ <div>
+ <input class="button button-primary" type="submit" name="Click Here"
+ {if $use == 'add'} value="Add New {$terms.assets_term_asset_cap}" {/if}
+ {if $use == 'edit'} value="Update {$terms.assets_term_asset_cap}" {/if}
+ >
+ <a id="assetsDialogCancel" class="button button-primary">Cancel</a>
+ </div>
+
+ </div> {* assetsAssetDialog *}
+
+
+ </form>
.assets-dialog-box {
display: grid;
grid-gap: 5px 5px;
- grid-template-columns: 8rem auto;
+ grid-template-columns: 8em auto;
}
.assets-facility-descr {
width: 30em !important;
.assets-facility-input-prompt {
padding: 5px 0 0 5px;
}
- .assetsFacilityInputMsg {
+ .assetsFacilityInputReqired {
color: red;
}
</style>
- {* New Facility Dialog Box *}
+ {* Facility Dialog Box *}
<form id="facilityForm" method="post" enctype="multipart/form-data">
<div class="assets-dialog-box">
<div class="glm-required assets-facility-input-prompt">Name:</div>
- <div><input type="text" name="name" class="glm-form-text-intput glm-form-text-input-medium" value="{$facility.name}" required><span id="assetsFacilityInputMsg_name" class="assetsFacilityInputMsg"></span></div>
+ <div><input type="text" name="name" class="glm-form-text-intput glm-form-text-input-medium" value="{$facility.name}" required><span id="assetsFacilityInputMsg_name" class="assetsFaclityInputReqired"></span></div>
<div class="assets-facility-input-prompt">Description:</div>
<div><textarea name="descr" class="glm-form-textarea assets-facility-descr">{$facility.descr}</textarea></div>
{$status} {* first character of this file is a status flag for the calling AJAX code. *}
<div style="grid-column: 1 / span 7;" class="facility_{$facility.fieldData.id} facility-name" data-id="{$facility.fieldData.id}">{$facility.fieldData.name}</div>
-<div style="grid-column: 2 / span 6;" id="facilityEditLinks_{$facility.fieldData.id}" class="glm-hidden facility_{$facility.fieldData.id}">
+<div style="grid-column: 2 / span 6;" id="facilityEditLinks_{$facility.fieldData.id}" class="assetsEditLinks glm-hidden facility_{$facility.fieldData.id}">
<a class="facility-edit button glm-button-small" data-id="{$facility.fieldData.id}">Edit</a>
<a class="facility-delete button glm-button-small" data-id="{$facility.fieldData.id}">Delete</a>
+ <a class="asset-add button glm-button-small" data-id="{$facility.fieldData.id}">Add Asset</a>
</div>
.assets-admin-content {
display: grid;
grid-gap: 0 0;
- grid-template-columns: 1rem 1rem 1rem auto auto auto auto;
+ grid-template-columns: 1em 1em 1em auto auto auto auto;
}
.facility-name {
font-weight: bold;
margin-top: 10px;
- font-size: 1rem;
+ font-size: 1.1em;
}
- .assets-colum-title {
+ .assets-column-title {
font-weight: bold;
}
.assets-dialog-box {
display: grid;
grid-gap: 5px 5px;
- grid-template-columns: 8rem auto;
+ grid-template-columns: 8em auto;
}
.assets-facility-descr {
width: 30em !important;
.assetsFacilityInputMsg {
color: red;
}
+ .assetsEditLinks {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ }
</style>
{* First indent here *}
- <div style="grid-column: 2 / span 6;" id="facilityEditLinks_{$facility.id}" class="glm-hidden facility_{$facility.id}">
+ <div style="grid-column: 2 / span 6;" id="facilityEditLinks_{$facility.id}" class="assetsEditLinks glm-hidden facility_{$facility.id}">
<a class="facility-edit button glm-button-small" data-id="{$facility.id}">Edit</a>
<a class="facility-delete button glm-button-small" data-id="{$facility.id}">Delete</a>
+ <a class="glm-assets-add-asset-button button glm-button-small" data-id="{$facility.id}">Add Asset</a>
</div>
- <div style="grid-column: 2 / span 3;" class="assets-colum-title facility_{$facility.id} glm-hidden">Asset Type</div>
- <div class="assets-colum-title facility_{$facility.id} glm-hidden">Name</div>
- <div class="assets-colum-title facility_{$facility.id} glm-hidden">Number</div>
- <div class="assets-colum-title facility_{$facility.id} glm-hidden">Quantity</div>
+ <div style="grid-column: 2 / span 3;" class="assets-column-title facility_{$facility.id} glm-hidden">Asset Type</div>
+ <div class="assets-column-title facility_{$facility.id} glm-hidden">Name</div>
+ <div class="assets-column-title facility_{$facility.id} glm-hidden">Number</div>
+ <div class="assets-column-title facility_{$facility.id} glm-hidden">Quantity</div>
<div style="grid-column: 2 / span 3;" class="facility_{$facility.id} glm-hidden">Room</div>
<div class="facility_{$facility.id} glm-hidden">Ballroom</div>
<div style="grid-column: 3 / span 5;" class="facility_{$facility.id} glm-hidden"><a href="#edit">Edit</a> <a href="#edit">Delete</a></div>
- <div style="grid-column: 3 / span 2;" class="assets-colum-title facility_{$facility.id} glm-hidden">Start</div>
- <div class="assets-colum-title facility_{$facility.id} glm-hidden">End</div>
- <div class="assets-colum-title facility_{$facility.id} glm-hidden">Account</div>
- <div class="assets-colum-title facility_{$facility.id} glm-hidden">Quantity</div>
+ <div style="grid-column: 3 / span 2;" class="assets-column-title facility_{$facility.id} glm-hidden">Start</div>
+ <div class="assets-column-title facility_{$facility.id} glm-hidden">End</div>
+ <div class="assets-column-title facility_{$facility.id} glm-hidden">Account</div>
+ <div class="assets-column-title facility_{$facility.id} glm-hidden">Quantity</div>
{foreach $asset.assignments as $assignment}
jQuery(document).ready(function($){
- var facilityEditFlag = false;
+ var editFlag = false;
var facilityHoverId = false;
var currentFormAction = false;
// File Line Hover Action
$('.facility-name').live( 'mouseenter', function() {
- if (facilityEditFlag) {
+ if (editFlag) {
return;
}
if (facilityHoverId) {
function clearFacilityExpand() {
facilityLinksEditSelected();
- facilityEditFlag = false;
+ editFlag = false;
facilityHoverId = false;
}
-
-
-
-
-
- // Facility dialog box
+ // Add / Edit dialog box
$('#assetsDialog').dialog({
autoOpen: false,
width: 600,
// Cancel facility dialog box
$('#assetsDialogCancel').live('click', function() {
$('#assetsDialog').dialog('close');
- facilityEditFlag = false;
+ editFlag = false;
});
-
+ /*
+ * Facility
+ */
+
// Add a facility
$('#glm-assets-add-facility-button').live('click', function(event) {
- facilityEditFlag = true;
+ editFlag = true;
$.ajax({
- url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=assetManagement&option=newFacility',
+ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=facilityManagement&option=newFacility',
type: $(this).attr("method"),
dataType: 'html',
processData: false,
// Edit a facility
$('.facility-edit').live('click', function(event) {
- facilityEditFlag = true;
+ editFlag = true;
$.ajax({
- url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=assetManagement&option=editFacility&id=' + facilityHoverId,
+ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=facilityManagement&option=editFacility&id=' + facilityHoverId,
type: $(this).attr("method"),
dataType: 'html',
processData: false,
event.preventDefault();
$.ajax({
- url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=assetManagement&option=' + thisOption,
+ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=facilityManagement&option=' + thisOption,
type: $(this).attr("method"),
dataType: 'html',
data: new FormData(this),
// If all is good add this facility to the top of the list for now
if (status == 0) {
- facilityEditFlag = false;
+ editFlag = false;
if (currentFormAction == 'add') {
$('#assetsFacilitiesContainer').prepend(html);
});
});
+ /*
+ * Asset
+ */
+
+ // Add an Asset
+ $('.glm-assets-add-asset-button').live('click', function(event) {
+ editFlag = true;
+ var facilityId = $(this).attr('data-id');
+ $.ajax({
+ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=assetManagement&option=newAsset&facility=',
+ type: $(this).attr("method"),
+ dataType: 'html',
+ processData: false,
+ contentType: false,
+ success: function (data, status)
+ {
+ currentFormAction = 'add';
+ var status = data.charAt(0);
+ $('#assetsDialog').html(data.substring(1));
+ $('#assetsDialog').dialog( "option", "title", "Add a new {$terms.assets_term_asset_cap}" );
+ $('#assetsDialog').dialog('open');
+ },
+ error: function (xhr, desc, err)
+ {
+ alert("Sorry, we were unable to talk to our systems at the moment. Please try again.");
+ }
+ });
+ });
+
+
+ // Submit Asset Form
+ $('#assetForm').live('submit', function(event) {
+
+ if (currentFormAction == 'add') {
+ var thisOption = 'addNewAsset';
+ }
+ if (currentFormAction == 'edit') {
+ var thisOption = 'updateAsset';
+ }
+
+ event.preventDefault();
+ $.ajax({
+ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=assetManagement&option=' + thisOption,
+ type: $(this).attr("method"),
+ dataType: 'html',
+ data: new FormData(this),
+ processData: false,
+ contentType: false,
+ success: function (data, status)
+ {
+ var status = data.charAt(0);
+ var html = data.substring(1);
+
+ // If all is good add this asset to the top of the list for now
+ if (status == 0) {
+
+ editFlag = false;
+
+ if (currentFormAction == 'add') {
+// Need to fix this $('#assetsAssetsContainer').prepend(html);
+ $('#assetsDialog').dialog('close');
+ }
+ if (currentFormAction == 'edit') {
+ $('#facility_' + facilityHoverId).html(html);
+// *** $('#facility_' + facilityHoverId).html(html);
+ $('#assetsDialog').dialog('close');
+ }
+ }
+
+ // if status....
+
+ },
+ error: function (xhr, desc, err)
+ {
+ alert("Sorry, we were unable to talk to our systems at the moment. Please try again.");
+ }
+ });
+ });
function flashNotice(notice) {
notice.fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);