From f2de84e7adeb740ebadf34a57d32b9cddfc5886d Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Fri, 15 Sep 2017 16:43:22 -0400 Subject: [PATCH] adding header admin view file , fixing some data class data fixing dataclass and database tables adding some admin view files --- classes/data/dataBuySell.php | 2 +- defines.php | 2 +- models/admin/buySell/index.php | 106 +++++++++--------- .../create_database_V0.0.1.sql | 9 +- setup/databaseScripts/dbVersions.php | 38 +++++++ views/admin/buySell/list.html | 43 +++++++ views/admin/header.html | 8 ++ 7 files changed, 148 insertions(+), 60 deletions(-) create mode 100644 setup/databaseScripts/dbVersions.php create mode 100644 views/admin/header.html diff --git a/classes/data/dataBuySell.php b/classes/data/dataBuySell.php index 032d885..ef139f1 100644 --- a/classes/data/dataBuySell.php +++ b/classes/data/dataBuySell.php @@ -112,7 +112,7 @@ class GlmDataBuySell extends GlmDataAbstract * Table Name */ - $this->table = GLM_MEMBERS_BUY_SELL_PLUGIN_DB_PREFIX . 'buy_sell'; + $this->table = GLM_MEMBERS_BUY_SELL_PLUGIN_DB_PREFIX . 'items'; // -- Conditions Table //CREATE TABLE {prefix}conditions ( diff --git a/defines.php b/defines.php index f3fed47..203ee52 100644 --- a/defines.php +++ b/defines.php @@ -13,7 +13,7 @@ define('GLM_MEMBERS_BUY_SELL_PLUGIN_SLUG', 'glm-member-db-buy-sell'); // Database table prefixes - change if using add-on tables global $wpdb; -define('GLM_MEMBERS_BUY_SELL_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_membersBuySell'); +define('GLM_MEMBERS_BUY_SELL_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_membersBuySell_'); define('GLM_MEMBERS_BUY_SELL_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersBuySellDbVersion'); // Determine which system we're running on - If not provided, assume PRODUCTION diff --git a/models/admin/buySell/index.php b/models/admin/buySell/index.php index deeb4e0..de65370 100644 --- a/models/admin/buySell/index.php +++ b/models/admin/buySell/index.php @@ -1,7 +1,7 @@ fields['admin_phone']['required'] = true; // Check for Member Menu Use - } elseif (defined('GLM_JOB_MEMBER_MENU')) { + } elseif (defined('GLM_item_MEMBER_MENU')) { // Try to get member ID $memberID = (isset($_REQUEST['member']) ? $_REQUEST['member'] : 0); @@ -167,19 +167,19 @@ class GlmMembersAdmin_buySell_index extends GlmDataBuySell $option = $_REQUEST['option']; } - // get the Job id for use in the edit, add and delete options + // get the item id for use in the edit, add and delete options // Get obit ID if supplied - if (isset($_REQUEST['job'])) { + if (isset($_REQUEST['item'])) { // Make sure it's numeric - $this->job_id= ($_REQUEST['job'] - 0); + $this->item_id= ($_REQUEST['item'] - 0); - if ($this->job_id <= 0) { - $this->job_id = false; + if ($this->item_id <= 0) { + $this->item_id = false; } } - $job_data = $this->getList($where); + $item_data = $this->getList($where); // echo '
', print_r($this->getList()), '
'; // echo '
', print_r($_REQUEST), '
'; @@ -187,31 +187,31 @@ class GlmMembersAdmin_buySell_index extends GlmDataBuySell switch ($option) { case 'add': - $job = $this->newEntry(); + $item = $this->newEntry(); $view_file = 'edit'; break; case 'insert': - $job = $this->insertEntry(); - $this->job_id = $job['fieldData']['id']; + $item = $this->insertEntry(); + $this->item_id = $item['fieldData']['id']; - if ($job['status']) { - $haveJob = true; - $jobAdded = true; + if ($item['status']) { + $haveItem = true; + $itemAdded = true; // Update created timestamp and name slug for URLs - //$this->updateSlug($this->JobID); + //$this->updateSlug($this->itemID); // Get this again so we have the created date - $job = $this->editEntry($this->job_id); + $item = $this->editEntry($this->item_id); $option = 'edit'; - $jobAdded = true; + $itemAdded = true; } else { $option = 'add'; - $jobAddError = true; + $itemAddError = true; } $view_file = 'edit'; @@ -219,67 +219,67 @@ class GlmMembersAdmin_buySell_index extends GlmDataBuySell break; case 'edit': - $job = $this->editEntry($this->job_id); + $item = $this->editEntry($this->item_id); - // If we have a good Job - if ($job['status']) { - $haveJob = true; + // If we have a good item + if ($item['status']) { + $haveItem = true; } $view_file = 'edit'; break; case 'update': - // Try to update this Job - $job = $this->updateEntry($this->job_id); + // Try to update this item + $item = $this->updateEntry($this->item_id); // Check if that was successful - if ($job['status']) { - $jobUpdated = true; + if ($item['status']) { + $itemUpdated = true; - $job = $this->editEntry($this->job_id); + $item = $this->editEntry($this->item_id); } else { - $jobUpdateError = true; + $itemUpdateError = true; } - $haveJob = true; + $haveItem = true; $view_file = 'edit'; break; case 'delete': - $job = $this->deleteEntry($this->job_id,true); + $item = $this->deleteEntry($this->item_id,true); - if ($job) { - $jobDeleted = true; + if ($item) { + $itemDeleted = true; } else { - $jobDeleteError = true; + $itemDeleteError = true; } $view_file = "list"; - $job_data = $this->getList(); + $item_data = $this->getList(); break; default: - $job_data = $this->getList($where); + $item_data = $this->getList($where); $view_file = 'list'; break; } // echo '
', print_r($this->getList()), '
'; // Compile template data $templateData = array( - 'jobData' => $job_data, + 'itemData' => $item_data, 'memberList' => $member_list, 'lockedToMember' => $lockedToMember, 'haveMember' => $haveMember, 'memberID' => $memberID, - 'jobID' => $this->job_id, - 'haveJob' => $haveJob, - 'jobUpdated' => $jobUpdated, - 'jobUpdateError' => $jobUpdateError, - 'jobAdded' => $jobAdded, - 'jobAddError' => $jobAddError, + 'itemID' => $this->item_id, + 'haveItem' => $haveItem, + 'itemUpdated' => $itemUpdated, + 'itemUpdateError' => $itemUpdateError, + 'itemAdded' => $itemAdded, + 'itemAddError' => $itemAddError, 'option' => $option, - 'job' => $job, + 'item' => $item, 'assetsUrl' => GLM_MEMBERS_BUY_SELL_PLUGIN_URL . 'assets/', ); diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql index 9a048b7..0772e54 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -12,7 +12,7 @@ -- all queries must be separated by a line with four dashes -- Conditions Table -CREATE TABLE {prefix}buy_sell ( +CREATE TABLE {prefix}items ( id INT NOT NULL AUTO_INCREMENT, topic int NULL , title TEXT NULL , @@ -37,11 +37,10 @@ CREATE TABLE {prefix}buy_sell ( ---- -- Job Titles default entries in table -INSERT INTO {prefix}buy_sell ( +INSERT INTO {prefix}items ( id,title,descr,topic,contact_email,contact_name,contact_phone,post_date,visible, terms,location,item_expiration,image_3,post,image_1, company,member,image_2 -) VALUES ( 1, 1,"DESCRIPTION",'SALARY', 'EMAIL LOCATION', 'CONTACT NAME', '453-3443', NOW(), true, -'facility operations', 'REQUIREMENTS', 'JOB LOCATION', 30, 'JOB DURATION', 'DEADLINE', 'POSITION AVAILABLE', -'COMPANY', 1, 'JOB BENEFITS' +) VALUES ( 1, "TITLE", "DESCR", 1, "CONTACT_EMAIL", "CONTACT_NAME", "CONTACT_PHONE", NOW(), true, "TERMS", "LOCATION", 60, "IMAGE_3", "POST", +"IMAGE_1", "COMPANY", 1, "IMAGE_2" ); \ No newline at end of file diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php new file mode 100644 index 0000000..f8e872f --- /dev/null +++ b/setup/databaseScripts/dbVersions.php @@ -0,0 +1,38 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + + +/********************************************************************** + * NOTE: THIS IS A BUY SELL FILE - DO NOT USE UNMODIFIED + * + * Please change all references to conditions, Conditions, or CONDITIONS to a name + * appropriate for your new Add-On. + * + * This file lists all versions of the database tables for this add-on. + * The last entry in the array below should be for the most recent + * version and should match the "create_database_V..." file in this + * directory. + * + * NOTE: When first creating a new add-on with database tables, there + * should only be one line in the array below and there should be no + * "update_database..." files in this directory. + * + * Remove this message before using this file in production! + **********************************************************************/ + + +$glmMembersBuySellDbVersions = array( + '0.0.1' => array('version' => '0.0.1', 'tables' => 1, 'date' => '09/15/2017'), +); diff --git a/views/admin/buySell/list.html b/views/admin/buySell/list.html index e69de29..47b00b9 100644 --- a/views/admin/buySell/list.html +++ b/views/admin/buySell/list.html @@ -0,0 +1,43 @@ +{include file='admin/header.html'} +{if $haveMember} + +{if !$lockedToMember} + +{/if} + +{/if} + {if $itemData} +
+ New item +
+
+
Topic
+
Forsale Item
+
Item Post Date
+
Post For
+
+ {foreach $itemData as $item=>$data} +
+
+
+
{$data.topic.name}
+
{$data.title}
+
{$data.post_date.timestamp|date_format:"%Y-%m-%d"}
+
{$data.item_expiration.name}
+
+
+
+ Edit + Delete +
+
+ {/foreach} + + {else if} +
No Items
+ {/if} +{include file='admin/footer.html'} \ No newline at end of file diff --git a/views/admin/header.html b/views/admin/header.html new file mode 100644 index 0000000..69d6081 --- /dev/null +++ b/views/admin/header.html @@ -0,0 +1,8 @@ +
+

Items

+ +
+ + -- 2.17.1