adding current changes to front end form entry. Using wpdb insert to add data to...
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 4 Apr 2016 12:34:49 +0000 (08:34 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 4 Apr 2016 12:42:44 +0000 (08:42 -0400)
css/admin.css
css/front.css
js/front.js
models/front/events/frontAdd.php
views/admin/events/edit.html
views/front/events/frontAdd.html

index 3dcfb8c..f8dbf91 100644 (file)
@@ -7,7 +7,9 @@ and open the template in the editor.
     Created on : 15-Feb-2016, 1:53:23 PM
     Author     : anthony
 */
-
+#occurrences{
+    display: none;
+}
 .catField{
     display: block;
 }
index a1a1924..85c06c4 100644 (file)
   height: 22px;
   background-position: 0px 0px !important;
 }
+.timeDropDown{
+    width: 30%;
+}
 
index 7c7dccd..bf46cf1 100644 (file)
@@ -19,7 +19,9 @@ var EventFront = {
             this.preventDefault();
             return false;
         });
-        jQuery("#sdate").datepicker();
+        jQuery("#sdate, #edate").datepicker({
+            dateFormat: 'dd-mm-yy'    
+        });
     }
 };
 
index 639e045..3ec2191 100644 (file)
@@ -19,7 +19,7 @@ require_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/models/front/events/baseAction.p
  * @author    Steve Sutton <steve@gaslightmedia.com>
  * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
  */
-class GLmMembersFront_events_frontAdd extends GlmMembersFront_events_baseAction
+class GLmMembersFront_events_frontAdd extends GlmDataEvents
 {
     /**
      * modelAction
@@ -31,56 +31,125 @@ class GLmMembersFront_events_frontAdd extends GlmMembersFront_events_baseAction
      */
     public function modelAction($actionData = false)
     {
-        $status = null;
-        $action = '';
-        $settings = $event = array();
-
-        if ( isset($_REQUEST['glm_event_from']) ) {
-            $fromDate = filter_var($_REQUEST['glm_event_from'], FILTER_SANITIZE_STRING);
-        } else {
-            $fromDate = date('m/d/Y');
-        }
-        $this->dateRange = "start_time >= '{$fromDate}'";
+        $events = new GlmDataEvents($this->wpdb, $this->config );
+        $newEvent = $events->newEntry();
+        
+         if($_REQUEST['newEvent'] == "Add Event"){
+             
+             // parse dates and times
+             date_default_timezone_set('America/New_York');
+             $date = date('y/m/d h:i:s a', time());
+             $starting = trim(filter_var($_REQUEST['starting'], FILTER_SANITIZE_STRING));
+             $startTime = trim(filter_var($_REQUEST['shour'],FILTER_SANITIZE_STRING)) . ':' . trim(filter_var($_REQUEST['smin'],FILTER_SANITIZE_STRING)) . " " . trim(filter_var($_REQUEST['sampam'],FILTER_SANITIZE_STRING)) ;
+             $smilitaryTime = date("H:i:s", strtotime($startTime));
+             $starting_date = strtotime($starting . " " . $smilitaryTime);
+             $mysqlStart = date("Y-m-d H:i:s",$starting_date);
+             
+             $ending = trim(filter_var($_REQUEST['ending'], FILTER_SANITIZE_STRING));
+             $endTime = trim(filter_var($_REQUEST['ehour'],FILTER_SANITIZE_STRING)) . ':' . trim(filter_var($_REQUEST['emin'],FILTER_SANITIZE_STRING)) . " " . trim(filter_var($_REQUEST['eampam'],FILTER_SANITIZE_STRING)) ;
+             $emilitaryTime = date("H:i:s", strtotime($endTime));
+             $ending_date = strtotime($ending . " " . $emilitaryTime);
+             $mysqlEnd = date("Y-m-d H:i:s",$ending_date);
+        
+             // events table data
+             $name = trim(filter_var($_REQUEST['event_name'],FILTER_SANITIZE_STRING));
+             $intro = trim(filter_var($_REQUEST['intro'],FILTER_SANITIZE_STRING));
+             $descr = trim(filter_var($_REQUEST['descr'],FILTER_SANITIZE_STRING));
+             $cost = trim(filter_var($_REQUEST['event_cost'],FILTER_SANITIZE_STRING));
+             $url = trim(filter_var($_REQUEST['url'],FILTER_SANITIZE_STRING));
+             $admin_name = trim(filter_var($_REQUEST['admin_name'],FILTER_SANITIZE_STRING));
+             $admin_org = trim(filter_var($_REQUEST['admin_org'],FILTER_SANITIZE_STRING));
+             
+             // locations table data
+             $place = trim(filter_var($_REQUEST['place'],FILTER_SANITIZE_STRING));
+             $address = trim(filter_var($_REQUEST['address'],FILTER_SANITIZE_STRING));
+             $city = trim(filter_var($_REQUEST['city'],FILTER_SANITIZE_STRING));
+             $state = trim(filter_var($_REQUEST['state'],FILTER_SANITIZE_STRING));
+             $zip = trim(filter_var($_REQUEST['zip'],FILTER_SANITIZE_STRING));
+             $contactEmail = trim(filter_var($_REQUEST['contact_email'],FILTER_SANITIZE_STRING));
+             $contactPhone = trim(filter_var($_REQUEST['contact_phone'],FILTER_SANITIZE_STRING));
 
-        if ( isset($_REQUEST['eventId']) && $eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) {
-            $search = true;
-            $action = 'event-detail';
-        } else {
-            $search = true;
-            $action = 'event-detail';
-            $eventslug =  get_query_var( 'eventslug' );
-            //echo '<pre>$eventslug: ' . print_r($eventslug, true) . '</pre>';
-            $sql = "
-                SELECT id
-                  FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "events
-                  WHERE name_slug = '$eventslug'";
-            $eventId = $this->wpdb->get_var($sql);
-        }
 
-        $categories = $this->getCategories();
-        switch ($action) {
-        case 'event-detail':
-            $event = $this->getModelEventData($eventId);
-            //echo '<pre>$event: ' . print_r($event, true) . '</pre>';
-            $view = 'detail.html';
-            break;
-        default:
-            // for the dashboard need to get list of event categories and
-            // filter out the events
-            $events = $this->getModelEventsData();
-            $view = 'agenda.html';
-            $categoryEvents = array();
-            break;
+             
+             $eventData = array(
+                            'status'   => '20',
+                            'created'  => $date,
+                            'updated'  => $date,
+                            'name'     => $name,
+                            'intro'    => $intro,
+                            'descr'    => $descr,
+                            'image'    => $event['img'],
+                            'cost'     => $cost,
+                            'url'      => $url,
+                            'admin_name' => $admin_name,
+                            'admin_org'  => $admin_org
+                        );
+            $this->wpdb->insert(
+                        GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
+                        $eventData,
+                        array(
+                             '%d',
+                             '%s',
+                             '%s',
+                             '%s',
+                             '%s',
+                             '%s',
+                             '%s',
+                             '%d',
+                             '%s',
+                             '%s',
+                             '%s',
+                        )
+                    );   
+                    $lastID = $this->wpdb->insert_id;
+                    $timeData = array(
+                            'event' => $lastID,
+                            'start_time' => $mysqlStart,
+                            'end_time' => $mysqlEnd,
+                        );
+            $this->wpdb->insert(
+                        GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'times',
+                        $timeData,
+                        array(
+                             '%d',
+                             '%s',
+                             '%s'
+                        )
+                    );
+            $locationData = array(
+                            'event' => $lastID,
+                            'name' => $place,
+                            'address' => $address,
+                            'city'   => $city,
+                            'state'  => $state,
+                            'zip'    => $zip,
+                            'phone'  => $contactPhone,
+                            'email'  => $contactEmail
+                            
+            );
+             $this->wpdb->insert(
+                        GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'locations',
+                        $locationData,
+                        array(
+                             '%d',
+                             '%s',
+                             '%s',
+                             '%d',
+                             '%s',
+                             '%s',
+                             '%s',
+                             '%s'
+                        )
+                    );
         }
-        
+         
         // Compile template data
         $templateData = array(
             'siteBaseUrl' => GLM_MEMBERS_EVENTS_SITE_BASE_URL,
             'currentUrl'  => $_SERVER['HTTP_REFERER'],
             'categories'  => $categories,
             'fromDate'    => $fromDate,
-            'event'       => $event,
+            'event'       => $newEvent,
             'permalink'   => $permalink,
             'title'       => $title,
             'mainImgUrl'  => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/'
index 0f527b1..2fbfa87 100644 (file)
             </p>
         </div>
     </div>
-
+    <div id='occurrences' title="Occurence">
+         {foreach $times as $t}
+           
+          {/foreach}
+          <input type="button" value="Delete Recurrence"> 
+    </div>
     <script type="text/javascript">
         jQuery(document).ready(function($) {
 
                         fixedWeekCount : false,
                         eventClick: function(calEvent, jsEvent, view) {
 
-                            alert('Event: ' + calEvent.title);
-//                            alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
-//                            alert('View: ' + view.name);
-                                // change the border color just for fun
-                                $(this).css('border-color', 'red');
+//                            alert('Event: ' + calEvent.title);
+                            $("#occurrences").dialog();
+                            $(this).css('border-color', 'red');
                         },
                         dayClick: function(date, allDay, jsEvent, view) {
 
                                 alert('Clicked on the slot: ' + date);
                             }
 
+
                             alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
 
                             alert('Current view: ' + view.name);
                             // change the day's background color just for fun
                             $(this).css('background-color', 'red');
 
+                        alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
+                        alert('Current view: ' + view.name);
+
+
+
                         }
         {/if}
                     });
index 1203d89..3ce053e 100644 (file)
@@ -1,28 +1,28 @@
 
 <!-- Status and Description -->
 <h2> Add Your Event </h2>
-<form action="{$thisUrl}?page={$thisPage}" name="frontAddForm" id="frontForm">
-    <table id="glm-table-descr" class="glm-admin-table glm-event-table">
-     
+<form action="{$thisUrl}" method="post" name="frontAddForm" id="frontForm">
+    <table id="glm-table-descr" class="glm-admin-table glm-event-table">      
         <tr>
-            <th {if $event.fieldRequired.name}class="glm-required"{/if}>Event Name:</th>
-            <td {if $event.fieldFail.name}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
-                <input type="text" name="name" value="{$event.fieldData.name}" class="glm-form-text-input-medium" placeholder="Name of this event.">
+            <th>Event Name:</th>
+            <td>
+                <input type="text" name="event_name" value="" class="glm-form-text-input-medium glm-required" placeholder="Name of this event.">
                 {if $event.fieldFail.name}<p>{$event.fieldFail.name}</p>{/if}<br>
             </td>
-        </tr>
+        </tr>       
+        
         <tr>
             <th> Start Date </th>
-            <td><input class="hasDatepicker" id="sdate" name="starting" maxlength="100" type="text"></td>
+            <td><input class="glm-datetime-input" id="sdate" name="starting" maxlength="100" type="text"></td>
         </tr>
         <tr>
             <th> End Date </th>
-            <td><input class="hasDatepicker" id="edate" name="starting" maxlength="100" type="text"></td>
+            <td><input class="glm-datetime-input" id="edate" name="ending" maxlength="100" type="text"></td>
         </tr>
         <tr>
             <th> Start Time </th>
         <td>
-               <select name="btime[h]">
+               <select class="timeDropDown" name="shour">
                 <option value="">hh</option>
                 <option value="1">01</option>
                 <option value="2">02</option>
                 <option value="10">10</option>
                 <option value="11">11</option>
                 <option value="12">12</option>
-        </select>&nbsp;:&nbsp;<select name="btime[i]">
+        </select>&nbsp;:&nbsp;<select class="timeDropDown" name="smin">
                 <option value="">mm</option>
                 <option value="0">00</option>
                 <option value="15">15</option>
                 <option value="30">30</option>
                 <option value="45">45</option>
-        </select>&nbsp;<select name="btime[A]">
+        </select>&nbsp;<select class="timeDropDown" name="sampam">
                 <option value="">am/pm</option>
                 <option value="AM">AM</option>
                 <option value="PM">PM</option>
@@ -52,8 +52,8 @@
           <tr>
             <th> End Time </th>
         <td>
-               <select name="btime[h]">
-                <option value="">hh</option>
+               <select class="timeDropDown" name="ehour">
+                <option value="">Hour</option>
                 <option value="1">01</option>
                 <option value="2">02</option>
                 <option value="3">03</option>
                 <option value="10">10</option>
                 <option value="11">11</option>
                 <option value="12">12</option>
-        </select>&nbsp;:&nbsp;<select name="btime[i]">
-                <option value="">mm</option>
+        </select>&nbsp;:&nbsp;<select class="timeDropDown" name="emin">
+                <option value="">Minute</option>
                 <option value="0">00</option>
                 <option value="15">15</option>
                 <option value="30">30</option>
                 <option value="45">45</option>
-        </select>&nbsp;<select name="btime[A]">
-                <option value="">am/pm</option>
+        </select>&nbsp;<select class="timeDropDown" name="eampm">
+                <option value="">AM/PM</option>
                 <option value="AM">AM</option>
                 <option value="PM">PM</option>
         </select>
        </td>
         </tr>
-{if $haveEvent}
-        <tr>
-            <th>Name for URLs:</th>
-            <td>{$event.fieldData.name_slug}</td>
-        </tr>
         <tr>
-            <th>Created:</th>
-            <td>{$event.fieldData.created.datetime}</td>
+            <th {if $event.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
+            <td {if $event.fieldFail.url}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+                <input type="text" name="url" value="{$event.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: http://www.gaslightmedia.com">
+                {if $event.fieldFail.url}<p>{$event.fieldFail.url}</p>{/if}<br>
+            </td>
         </tr>
         <tr>
-            <th>Last Updated:</th>
-            <td>{$event.fieldData.updated.datetime}</td>
+            <th {if $event.fieldRequired.intro}class="glm-required"{/if}>Intro Text:</th>
+            <td {if $event.fieldFail.intro}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+                <textarea name="intro" class="glm-form-textarea">{$event.fieldData.intro}</textarea>
+                {if $event.fieldFail.intro}<p>{$event.fieldFail.intro}</p>{/if}
+            </td>
         </tr>
         <tr>
-            <th>Last Approved:</th>
-            <td>{$event.fieldData.approved.datetime}</td>
+            <td>
+               <label>Facebook</label>
+            </td>
+            <td>
+               <input name="facebook" maxlength="100" type="text">
+            </td>
         </tr>
-{/if}
-
         <tr>
-            <th>Categories</th>
-            <td class="glm-item-container">
-            
-                <!--  Add new category dialog -->
-            
-                <div id="newCategoryButton" class="button button-secondary glm-right">Add a new Category</div>
-                <div id="newCategoryDialog" class="glm-dialog-box" title="Enter a New Category">
-                        <table class="glm-admin-table">
-                            <tr>
-                                <th class="glm-required">Category Name:</th>
-                                <td id="newCatNameTD">
-                                    <input id="newCatName" type="text" name="newCatName" class="glm-form-text-input">
-                                    <div id="newCatNameRequired"></div>
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Parent Category:</th>
-                                <td>
-                                    <select id="newCatParent" name="newCatParent">
-                        {if $categories}
-                                        <option value=""></option>
-                            {foreach $categories as $t}
-                                {if !$t.parent} <!-- don't show child categories -->
-                                        <option value="{$t.id}" data-parent="{$t.name}">{$t.name}</option>
-                                {/if}
-                            {/foreach}
-                        {/if}
-                                    </select>
-                                    <br>OR<br>
-                                    <input id="newCatParentName" type="text" name="newCatParentName" placeholder="Enter a new parent name."> 
-                                </td>
-                            </tr>
-                        </table>
-                        <p><span class="glm-required">*</span> Required</p>
-                        <a id="newCategoryCancel" class="button button-primary glm-right">Cancel</a>
-                        <input id="newCategorySubmit" type="submit" value="Add new Category">
-                </div>
-                
-                <!-- Category Selection -->
-                
-                <select name="categorySelect" id="categorySelect">
-    {if $categories}
-                    <option id="categoryNone" value=""></option>
-        {foreach $categories as $v}
-                    <option value="{$v.id}" data-parent="{$v.parent}">
-                        {if $v.parent_id}&nbsp;&nbsp;&nbsp;&nbsp;{/if}{$v.name}
-                    </option>
-        {/foreach}
-    {else}
-                    <option id="" value="">(No Categories Listed - Select "Add a new Category" to the right. )</option>  
-    {/if}
-                </select>&nbsp;&nbsp; Select a category to add to box below.<br>
-                <div id="activeCategories" class="glm-dynSelect-box">
-                
-    {if isset($event.fieldData.categories) && $event.fieldData.categories}
-        {foreach $event.fieldData.categories as $c}
-                    <div data-id="{$c.id}" class="glm-dynSelect-item glm-events-category">
-                        {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name} 
-                        <span data-id="{$c.id}" class="glm-dynSelect-delete catDelete">X</span>
-                        <input type="hidden" name="category[{$c.id}]" value="{$c.id}">
-                   </div>                    
-        {/foreach}
-    {/if}                    
-                </div>
+            <td>
+               <label>Twitter</label>
+            </td>
+            <td>
+               <input name="twitter" maxlength="100" type="text">
             </td>
         </tr>
         <tr>
-            <th {if $event.fieldRequired.intro}class="glm-required"{/if}>Intro Text:</th>
-            <td {if $event.fieldFail.intro}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
-                <textarea name="intro" class="glm-form-textarea">{$event.fieldData.intro}</textarea>
-                {if $event.fieldFail.intro}<p>{$event.fieldFail.intro}</p>{/if}
+            <th {if $event.fieldRequired.cost}class="glm-required"{/if}>Cost:</th>
+            <td {if $event.fieldFail.cost}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+                <input type="text" name="cost" value="{$event.fieldData.cost}" class="glm-form-text-input-medium">
             </td>
         </tr>
         <tr>
             </td>
         </tr>
         <tr>
-            <th {if $event.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
-            <td {if $event.fieldFail.url}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
-                <input type="text" name="url" value="{$event.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: http://www.gaslightmedia.com">
-                {if $event.fieldFail.url}<p>{$event.fieldFail.url}</p>{/if}<br>
+            <td>
+               <label style="color: red;">Place</label>
+            </td>
+            <td>
+               <input name="place" maxlength="100" type="text">
             </td>
         </tr>
         <tr>
-            <th {if $event.fieldRequired.ticket_url}class="glm-required"{/if}>Ticketing Address (URL):</th>
-            <td {if $event.fieldFail.ticket_url}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
-                <input type="text" name="ticket_url" value="{$event.fieldData.ticket_url}" class="glm-form-text-input-medium" placeholder="ex: http://www.gaslightmedia.com/ticketing/">
-                {if $event.fieldFail.ticket_url}<p>{$event.fieldFail.ticket_url}</p>{/if}<br>
+            <td>
+               <label >Address</label>
+            </td>
+            <td>
+               <input name="adress" maxlength="100" type="text">
             </td>
         </tr>
         <tr>
-            <th {if $event.fieldRequired.cost}class="glm-required"{/if}>Description of Cost:</th>
-            <td {if $event.fieldFail.cost}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
-                <input type="text" name="cost" value="{$event.fieldData.cost}" class="glm-form-text-input-medium">
-                {if $event.fieldFail.cost}<p>{$event.fieldFail.cost}</p>{/if}<br>
+            <td>
+               <label style="color: red;">City</label>
+            </td>
+            <td>
+               <input name="city" maxlength="100" type="text">
             </td>
         </tr>
         <tr>
-            <th {if $event.fieldRequired.notes}class="glm-required"{/if}>Notes:</th>
-            <td {if $event.fieldFail.notes}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
-                <textarea name="notes" class="glm-form-textarea">{$event.fieldData.notes}</textarea>
-                {if $event.fieldFail.notes}<p>{$event.fieldFail.notes}</p>{/if}
+            <td>
+               <label >State</label>
+            </td>
+            <td>
+               <input name="state" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+               <label >ZIP</label>
+            </td>
+            <td>
+               <input name="zip" maxlength="100" type="text">
             </td>
-            
         </tr>
+        <tr>
+            <td>
+               <label>Event Contact Person<br>(published on Web site)</label>
+            </td>
+            <td class="fieldcell">
+               <input name="contact_name" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+               <label>Contact Email<br>(published on Web site)</label>
+            </td>
+            <td>
+               <input name="contact_email" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+               <label style="color: red;">Contact Phone<br>(published on Web site)</label>
+            </td>
+            <td>
+               <input name="contact_phone" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+               <label style="color: red;">Contact Name Submitting Event</label>
+            </td>
+            <td>
+               <input name="admin_name" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+               <label style="color: red;">Organization Name Submitting Event</label>
+            </td>
+            <td>
+               <input name="admin_org" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+               <label>Event File</label>
+            </td>
+            <td>
+               <input name="file_rmv" type="file">
+            </td>
+        </tr>
+        <tr>
+            <td>
+               <label>File Name</label>
+            </td>
+            <td>
+               <input name="filename" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <label style="color: red;">Phone</label>
+            </td>
+            <td>
+               <input name="admin_phone" maxlength="100" type="text">
+            </td>
+        </tr>
+        <tr>
+            <td>
+
+               <label style="color: red;">Email Address</label>
+            </td>
+            <td>
+               <input name="admin_email" maxlength="100" type="text">
+            </td>
+        </tr>
+        
+
+
 
     </table>
-<input id="newEvent" type="submit" value="Add Event">
-<input name="option" value="submit" type="hidden">
+<input id="newEvent" name='newEvent' type="submit" value="Add Event">
+<!--<input name="option" value="submit" type="hidden">-->
 </form>
 
+