Updates for grouped Amenities
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 14 Jun 2016 19:47:35 +0000 (15:47 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 14 Jun 2016 19:47:35 +0000 (15:47 -0400)
Fix for the delete of groups.
fix the edit amenity and add amenity pages when there are no groups

models/admin/settings/amenities.php
views/admin/settings/amenities.html

index fd2532f..48a306d 100644 (file)
@@ -147,8 +147,6 @@ class GlmMembersAdmin_settings_amenities extends GlmDataAmenities
                     if ( $id > 0 ) {
                         $this->updateEntry( $id );
                     }
-                    //echo '<pre>$id: ' . print_r($id, true) . '</pre>';
-                    //echo '<pre>$_REQUEST: ' . print_r($_REQUEST, true) . '</pre>';
                     // Delete the current entries for the grouped amenities
                     $this->wpdb->delete(
                         GLM_MEMBERS_PLUGIN_DB_PREFIX . 'grouped_amenities',
@@ -194,7 +192,14 @@ class GlmMembersAdmin_settings_amenities extends GlmDataAmenities
 
                 case 'deleteGroup':
                     if ( $id > 0 ) {
-                        $groupData->deleteEntry( $id );
+                        $groupData->deleteEntry( $id, true );
+
+                        // Delete the current entries for the grouped amenities
+                        $this->wpdb->delete(
+                            GLM_MEMBERS_PLUGIN_DB_PREFIX . 'grouped_amenities',
+                            array( 'group_id' => $id ),
+                            array( '%d' )
+                        );
                     } 
                     break;
 
index 0ab54a1..397e09c 100644 (file)
                                         <td>Groups</td>
                                     </tr>
                                 </thead>
-                                {foreach $groups as $group}
-                                    <tr>
-                                        <td>
-                                            <label>
-                                                <input type="hidden" name="grouped[group][{$group.id}]" value="0">
-                                                <input type="checkbox" name="grouped[group][{$group.id}]" value="1">
-                                                {$group.name}
-                                            </label>
-                                        </td>
-                                        <td>
-                                            <label>
-                                                <input type="hidden" name="grouped[searchable][{$group.id}]" value="0">
-                                                <input type="checkbox" name="grouped[searchable][{$group.id}]" value="1">
-                                                Searchable
-                                            </label>
-                                        </td>
-                                    </tr>
-                                {/foreach}
+                                {if $haveGroups}
+                                    {foreach $groups as $group}
+                                        <tr>
+                                            <td>
+                                                <label>
+                                                    <input type="hidden" name="grouped[group][{$group.id}]" value="0">
+                                                    <input type="checkbox" name="grouped[group][{$group.id}]" value="1">
+                                                    {$group.name}
+                                                </label>
+                                            </td>
+                                            <td>
+                                                <label>
+                                                    <input type="hidden" name="grouped[searchable][{$group.id}]" value="0">
+                                                    <input type="checkbox" name="grouped[searchable][{$group.id}]" value="1">
+                                                    Searchable
+                                                </label>
+                                            </td>
+                                        </tr>
+                                    {/foreach}
+                                {/if}
                             </table>
                         </td>
                     </tr>
                                         <td>Groups</td>
                                     </tr>
                                 </thead>
-                                {foreach $groups as $group}
-                                    <tr>
-                                        <td>
-                                            <label>
-                                                <input type="hidden" name="grouped[group][{$group.id}]" value="0">
-                                                <input id="editAmenityGroup_{$group.id}" class="amenityGroup" type="checkbox" name="grouped[group][{$group.id}]" value="1">
-                                                {$group.name}
-                                            </label>
-                                        </td>
-                                        <td>
-                                            <label>
-                                                <input type="hidden" name="grouped[searchable][{$group.id}]" value="0">
-                                                <input id="editAmenityGroupSearchable_{$group.id}" class="amenitySearch" type="checkbox" name="grouped[searchable][{$group.id}]" value="1">
-                                                Searchable
-                                            </label>
-                                        </td>
-                                    </tr>
-                                {/foreach}
+                                {if $haveGroups}
+                                    {foreach $groups as $group}
+                                        <tr>
+                                            <td>
+                                                <label>
+                                                    <input type="hidden" name="grouped[group][{$group.id}]" value="0">
+                                                    <input id="editAmenityGroup_{$group.id}" class="amenityGroup" type="checkbox" name="grouped[group][{$group.id}]" value="1">
+                                                    {$group.name}
+                                                </label>
+                                            </td>
+                                            <td>
+                                                <label>
+                                                    <input type="hidden" name="grouped[searchable][{$group.id}]" value="0">
+                                                    <input id="editAmenityGroupSearchable_{$group.id}" class="amenitySearch" type="checkbox" name="grouped[searchable][{$group.id}]" value="1">
+                                                    Searchable
+                                                </label>
+                                            </td>
+                                        </tr>
+                                    {/foreach}
+                                {/if}
                             </table>
                         </td>
                     </tr>
             $("#newGroupDialog").dialog("close");
         });
 
-        var id = false;
+        var group_id = false;
         $('.deleteGroupButton').click( function() {
-            id = $(this).attr('data-groupID');
+            group_id = $(this).attr('data-groupID');
             $("#deleteGroupDialog").dialog("open");
         });
         $('#deleteGroupConfirm').click( function() {
             $("#deleteGroupDialog").dialog("close");
-            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=amenities&option=deleteGroup&id=" + id + "&option2=group";
+            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=amenities&option=deleteGroup&id=" + group_id + "&option2=group";
         });
         $('#deleteGroupCancel').click( function() {
             $("#deleteGroupDialog").dialog("close");