adding settings > global payment codes to the mgmt menu. Payment codes can be
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 27 Feb 2017 21:42:02 +0000 (16:42 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 27 Feb 2017 21:42:02 +0000 (16:42 -0500)
added, edited and deleted. Only global paymentcodes show up in the admin

classes/data/dataPaymentCode.php
css/admin.css [new file with mode: 0644]
models/admin/settings/registrationsPaymentCode.php
views/admin/settings/registrationsPaymentCode.html

index b4c82be..8395737 100644 (file)
@@ -107,6 +107,14 @@ class GlmDataRegistrationsPaymentCode extends GlmDataAbstract
          */
 
         $this->fields = array (
+            // ID
+            'id' => array (
+                'field' => 'id',
+                'type' => 'integer',
+                'view_only' => true,
+                'use' => 'a'
+            ),
+            
 
             // Payment Code Type
             'code_type' => array (
@@ -121,7 +129,7 @@ class GlmDataRegistrationsPaymentCode extends GlmDataAbstract
             'ref_type' => array (
                 'field' => 'ref_type',
                 'type' => 'list',
-                'list' => $this->config['payment_type'],
+                'list' => $this->config['pay_code_ref_type'],
                 'required' => true,
                 'use' => 'a'
             ),
diff --git a/css/admin.css b/css/admin.css
new file mode 100644 (file)
index 0000000..59ae731
--- /dev/null
@@ -0,0 +1,6 @@
+.editPaymentCode{
+    width: 44px;
+    text-align: center;
+    margin-right: 5px;
+    display: inline-block;
+}
\ No newline at end of file
index b2b78bd..f128382 100644 (file)
@@ -105,6 +105,10 @@ class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrat
         $option2            = '';
         $newPaymentCode     = $this->newEntry();
 
+        $global_paycode     = $this->config['pay_code_ref_type_numb']['Global'];
+
+        $enable_members = $this->config['settings']['enable_members'];
+
         // Check if a category ID is supplied
         $id = 0;
         if ( isset( $_REQUEST['id'] ) ) {
@@ -122,6 +126,7 @@ class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrat
                     if ( $id > 0 ) {
                         $this->updateEntry( $id );
                     }
+                    echo "no id";
                     break;
 
                 case 'delete':
@@ -140,7 +145,7 @@ class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrat
             $option2 = $_REQUEST['option2'];
         }
         // Get a current list of payment_codes
-        $payment_codes = $this->getList();
+        $payment_codes = $this->getList('ref_type = 10');
 
         if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
             glmMembersAdmin::addNotice( $payment_codes, 'DataBlock', 'Payment Code Data' );
@@ -171,11 +176,13 @@ class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrat
         }
         // Compile template data
         $templateData = array(
-            'havePaymentCode'  => $havePaymentCode,
-            'payment_codes'      => $payment_codes,
-            'groups'         => null,
-            'option2'        => $option2,
-            'newPaymentCode'     => $newPaymentCode,
+            'enable_members'    => $enable_members,
+            'havePaymentCode'   => $havePaymentCode,
+            'payment_codes'     => $payment_codes,
+            'groups'            => null,
+            'option2'           => $option2,
+            'newPaymentCode'    => $newPaymentCode,
+            'global_paycode'       => $global_paycode
         );
 
         // Return status, suggested view, and data to controller
index 612fa4b..d0900ea 100644 (file)
                 <!-- This is only temporary until we reinstate the "Used With" selection below -->
                 <table class="glm-admin-table">
                     <tr>
-                        <th class="glm-required">Payment Code Name:</th>
+                        <th class="glm-required">Payment Code:</th>
                         <td>
-                            <input type="text" name="name" class="glm-form-text-input">
+                            <input id="code" data-id="code" type="text" name="code" class="glm-form-text-input">
+                        </td>
+                    </tr>
+                    <tr>
+
+                        <td>
+                            <input type="hidden" value="{$global_paycode}" name="ref_type">
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>Payment Code Type:</th>
+                        <td>
+                            <select id="default-code-type" data-id="code_type" name="code_type">
+                                <option value=""></option>
+                                {foreach from=$newPaymentCode.fieldData.code_type.list item=v}
+                                <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                                    {$v.name}
+                                </option>
+                                {/foreach}
+                            </select>
+                        </td>
+                    </tr>
+                     <tr>
+                        <th>Payment Amount:</th>
+                        <td>
+                            <input id="amount" data-id="amount" type="text" name="amount" class="glm-form-text-input">
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>Payment Description:</th>
+                        <td>
+                            <input id="descr" data-id="descr" type="text" name="descr" class="glm-form-text-input">
                         </td>
                     </tr>
                 </table>
 
                 <!-- This is only temporary until we reinstate the "Used With" selection below -->
                 <table class="glm-admin-table">
+                      <tr>
+                        <th class="glm-required">Payment Code:</th>
+                        <td>
+                            <input id="edit-code" data-id="code" type="text" name="code" class="glm-form-text-input">
+                        </td>
+                    </tr>
+                    <tr>
+
+                        <td>
+                            <input type="hidden" value="{$global_paycode}" name="ref_type">
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>Payment Code Type:</th>
+                        <td>
+                            <select id="edit-code-type" data-id="code_type" name="code_type">
+                                <option value=""></option>
+                                {foreach from=$newPaymentCode.fieldData.code_type.list item=v}
+                                <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                                    {$v.name}
+                                </option>
+                                {/foreach}
+                            </select>
+                        </td>
+                    </tr>
+                     <tr>
+                        <th>Payment Amount:</th>
+                        <td>
+                            <input id="edit-amount" data-id="amount" type="text" name="amount" class="glm-form-text-input">
+                        </td>
+                    </tr>
                     <tr>
-                        <th class="glm-required">Payment Code Name:</th>
+                        <th>Payment Description:</th>
                         <td>
-                            <input id="editPaymentCodeName" type="text" name="name" class="glm-form-text-input">
+                            <input id="edit-descr" data-id="descr" type="text" name="descr" class="glm-form-text-input">
                         </td>
                     </tr>
                 </table>
         <table class="wp-list-table wideFat fixed posts glm-admin-table" style="width: 90%;">
             <thead>
                 <tr>
-                    <th>Payment Code</th>
+                    <th> Amount </th>
+                    <th> Description </th>
+                    <th> Payment Code</th>
+                    <th> Payment Code Type </th>
                     <th>&nbsp;</th>
                 </tr>
             </thead>
             <tbody>
+               
             {if $havePaymentCode}
                 {assign var="i" value="0"}
                 {foreach $payment_codes as $p}
                         <tr class="alternate">
                     {/if}
                             <td>
-                                <a class="editPaymentCode" data-amenityID="{$p.id}" data-amenityUsesValue="{$p.uses_value.value}">{$p.name}</a>
+                                <div id="paymentAmount_{$p.id}" data-paycodeID="{$p.id}" >{$p.amount}</div>
+                            </td>
+                            <td>
+                                <div id="paymentDescription_{$p.id}" data-paycodeID="{$p.id}">{$p.descr}</div>
+                            </td>
+                            <td>
+                                <div id="paymentCode_{$p.id}" data-paycodeID="{$p.id}">{$p.code}</div>
                             </td>
                             <td>
-                                <div class="deletePaymentCodeButton button button-secondary glm-button-small glm-right" data-amenityID="{$p.id}">Delete</div>
+                                <div id="paymentType_{$p.id}" data-value="{$p.code_type.value}" data-paycodeID="{$p.id}">{$p.code_type.name}</div>
+                            </td>
+                            <td>
+                                <div class="editPaymentCodeButton editPaymentCode button button-secondary glm-button-small glm-right" data-paycodeID="{$p.id}">Edit</div>
+                               
+                            </td>
+                            <td>
+                                <div class="deletePaymentCodeButton button button-secondary glm-button-small glm-right" data-paycodeID="{$p.id}">Delete</div>
                             </td>
                         </tr>
                 {/foreach}
             $("#newPaymentCodeDialog").dialog("open");
         });
         $('.editPaymentCode').click( function() {
-            var amenityID = $(this).attr('data-amenityID');
-            var amenityName = $(this).text();
-            var amenityUsesValue = parseInt($(this).attr('data-amenityUsesValue'));
-            var amenityDescr = $('#editPaymentCodeDescr_' + amenityID).html();
-            var amenityShortDescr = $('#editPaymentCodeShortDescr_' + amenityID).html();
-            $('#editPaymentCodeID').val(amenityID);
-            $('#editPaymentCodeName').val(amenityName.trim());
-            $('#editPaymentCodeUsesValue').prop('checked', amenityUsesValue);
-            $('.amenityGroup').each(function(){
-                $(this).prop('checked', false);
-            });
-            $('.amenitySearch').each(function(){
-                $(this).prop('checked', false);
-            });
+            var paycodeID        = $(this).attr('data-paycodeID');
+            var paycodeType      = $('#paymentType_' + paycodeID).html();
+            var paycodeDescr     = $('#paymentDescription_' + paycodeID).html();
+            var paycodeAmount    = $('#paymentAmount_' + paycodeID).html();
+            var paycode          = $('#paymentCode_' + paycodeID).html();
+            var paycodeTypeValue = $('#paymentType_' + paycodeID).data('value');
+
+            $('#editPaymentCodeID').val(paycodeID);
+            
+            $('#edit-code').val(paycode);
+            $('#edit-amount').val(paycodeAmount);
+            $('#edit-descr').val(paycodeDescr);
+            $('#edit-type').val(paycodeType);
+            
+            $("#edit-code-type option").filter(function() {
+                return parseInt($(this).val()) === parseInt(paycodeTypeValue); 
+            }).prop('selected', true);
+            
+            
             $("#editPaymentCodeDialog").dialog("open");
         });
         $('#editPaymentCodeCancel').click( function() {
 
         var id = false;
         $('.deletePaymentCodeButton').click( function() {
-            id = $(this).attr('data-amenityID');
+            id = $(this).attr('data-paycodeID');
             $("#deletePaymentCodeDialog").dialog("open");
         });
         $('#deletePaymentCodeConfirm').click( function() {
             $("#deletePaymentCodeDialog").dialog("close");
-            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=eventAmenities&option=delete&id=" + id;
+            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=registrationsPaymentCode&option=delete&id=" + id;
         });
         $('#deletePaymentCodeCancel').click( function() {
             $("#deletePaymentCodeDialog").dialog("close");