changing the account header layout and removing the widget
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 11 Dec 2017 16:20:07 +0000 (11:20 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 11 Dec 2017 16:20:07 +0000 (11:20 -0500)
adding cart widget data to the account headers using a shortcode

css/front.css
models/front/registrations/cartLinkWidget.php
setup/frontHooks.php
setup/shortcodes.php
views/front/registrations/accountHeader.html [new file with mode: 0644]
views/front/registrations/registration.html

index 3b1f303..01ce393 100644 (file)
@@ -335,8 +335,14 @@ span.glm-error {
 #glm-reg-widget {
     display: inline-block;
 }
-
-
+#glm-header-reg-widget{
+    display: inline-block;
+    float: left;
+    margin-right: 5px;
+}
+#glm-header-reg-widget a{
+    text-decoration: none;
+}
 /*{{{ Media Queries */
 
 @media (min-width: 64.063em) {
index 4772923..d322db9 100644 (file)
@@ -81,6 +81,8 @@ class GlmMembersFront_registrations_cartLinkWidget
 
         $haveCart = false;
 
+        $viewAttr = isset($actionData['request']['view']) ? $actionData['request']['view'] : false;
+
         $cartData = apply_filters('glm_members_registrations_cart_summary_data', false, false);
 
         if (is_array($cartData) && $cartData['id']) {
@@ -91,10 +93,11 @@ class GlmMembersFront_registrations_cartLinkWidget
         $templateData = $cartData;
         $templateData['haveCart'] = $haveCart;
         $templateData['assetUrl'] = GLM_MEMBERS_REGISTRATIONS_PLUGIN_ASSETS_URL;
+        $templateData['regUrl'] = GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/';
 
         // echo "<pre>".print_r($templateData,1)."</pre>";
-        if($view){
-            $view = "accountHeader";
+        if($viewAttr){
+            $view = $viewAttr;
         }else{
             $view = 'cartLinkWidget';
         }
index c91f18a..f241572 100644 (file)
@@ -72,5 +72,5 @@ add_filter(
 );
 
 add_filter( 'glm_members_registrations_header', function($view ){
-    
+    echo do_shortcode( '[glm-members-registrations-cart-link-widget view="accountHeader"]' );
 },10,1);
\ No newline at end of file
index 216eb26..e69fed3 100644 (file)
@@ -113,6 +113,7 @@ $glmMembersRegistrationsShortcodes = array(
         'action'     => 'cartLinkWidget',
         'table'      => false,
         'attributes' => array(
+            'view'   => false
         )
     )
 
diff --git a/views/front/registrations/accountHeader.html b/views/front/registrations/accountHeader.html
new file mode 100644 (file)
index 0000000..29d556e
--- /dev/null
@@ -0,0 +1,109 @@
+<div id="accountHeader">
+    <div class="glm-right">
+        <div id="glm-header-reg-widget">
+            {if $haveCart}
+                <a href="{$cartUrl}">
+                    <div id="registrations-cart-link-widget" style="width: 80px;  padding: 5px; background-color: #ffffff; border: 1px black solid; position: relative">
+                        <div style="font-size: .5em; line-height: 1.1em;  left: 14px; top: 63px; z-index: 2; font-style: italic;">CART</div>
+                        <div style="font-size: .5em; line-height: 1.1em;  left: 22px; top: 44px; z-index: 2;">
+                            {$numb_events} Event{if $numb_events == 0 || $numb_events > 1}s{/if}<br>
+                            {$numb_registrants} Registrant{if $numb_registrants == 0 || $numb_registrants > 1}s{/if}
+                        </div>
+                    </div>
+                </a>
+            {else}
+                <div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #f0f0f0; border: 1px black solid; position: relative">
+                    <div style="font-size: .5em; line-height: 1.1em;  left: 14px; top: 65px; z-index: 2; font-style: italic;">CART</div>
+                    <div style="font-size: .5em; line-height: 1.1em;  left: 25px; top: 42px; z-index: 2;">
+                         Cart<br>Empty
+                    </div>
+                </div>
+            {/if}
+            {if $haveOtherRequests}
+                <a id='glm-cart-select-action' href="" onClick="return false;">
+                    <div id="registrations-cart-link-widget-requests" style="width: 80px; height: 1em; padding: 1px; background-color: #ffffff; border: 1px black solid; position: relative">
+                        <div style="font-size: .55em; line-height: 1.1em; left:3px; top: 3px; z-index: 2;">
+                        Select other Carts
+                        </div>
+                    </div>
+                </a>
+                <div id="glm-cart-select-dialog" title="Pending Registration Requests (carts)" class="glm-hidden" style="width: 100%">
+                    <center>
+                        <table>
+                            <thead>
+                                <tr><th>ID</th><th style="white-space: nowrap;">Date created</th><th style="white-space: nowrap;">Date last updated</th><th>Events</th><th>Registrants</th><th>Selected</th></tr>
+                            </thead>
+                            <tbody>
+                            {foreach $regRequests as $rr}
+                                <tr>
+                                    <td>
+                                        <a href="{$cartUrl}&cartId={$rr.id}">{$rr.id}</a>
+                                    </td>
+                                    <td style="white-space: nowrap;">{$rr.date_created.datetime}</td>
+                                    <td style="white-space: nowrap;">{$rr.last_update.datetime}</td>
+                                    <td style="white-space: nowrap;">{$rr.numb_events}</td>
+                                    <td style="white-space: nowrap;">{$rr.numb_registrants}</td>
+                                    <td>
+                                    {if $rr.id == $id}
+                                        Yes
+                                    {/if}
+                                    </td>
+                                </tr>
+                            {/foreach}
+                            </tbody>
+                        </table>
+                    </center>
+                </div>
+            {/if}
+        </div>
+    {if $loggedIn}
+        Logged in as {$loggedIn.fname} {$loggedIn.lname}
+        <a class="button tiny" href="{$regUrl}?page=login&option=logout">Logout</a>
+    {else}
+        <a id="appLogin" class="button tiny" href="{$regUrl}?page=login">Login</a>
+        <a id="register" class="button tiny" href="{$regUrl}?page=register">Create an Account</a>
+    {/if}
+    </div>
+    {if $page != 'register'}
+        <a href="{$regUrl}" class="button tiny">Register for Another Event</a>
+    {/if}
+    {if $page != 'cart'}
+        <a href="{$regUrl}?page=cart" class="button tiny">Return to Cart</a>
+    {/if}
+    &nbsp;
+
+</div>
+<script type="text/javascript">
+var glmWidget = {
+    updateWidget: function(){
+        // Make an ajax call and update the widget contents
+        jQuery.ajax({
+            context: this,
+            url: '{$ajaxUrl}',
+            data: { action: 'glm_members_admin_ajax', glm_action: 'cartLinkWidget' },
+        })
+        .done(function(html){
+            console.log('Call successfull');
+            jQuery('#glm-reg-widget').replaceWith(html)
+        })
+        .fail();
+    },
+};
+
+jQuery(document).ready(function($) {
+    pendDialog = $("#glm-cart-select-action").click(function () {
+        $("#glm-cart-select-dialog").dialog({
+            autoOpen: true,
+            resizable: false,
+            modal: true,
+            width: "auto",
+            closeText: "hide",
+            buttons: {
+                "Cancel": function () {
+                    $(this).dialog("close");
+                }
+            }
+        });
+    });
+});
+</script>
\ No newline at end of file
index b4248c4..83548ad 100644 (file)
 {/literal}
 <div class="glm-reg-event-list">
     <h1>{$terms.reg_term_registrations_name}</h1>
-    {include file='front/registrations/header.html'}
+    <!-- {include file='front/registrations/header.html'} -->
+    {apply_filters('glm_members_registrations_header', 'accountHeader')}
 
 {if $reg_bulletin}
     <div id="reg_bulletin">