Due date and notes being saved now.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 7 Dec 2017 17:54:30 +0000 (12:54 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 7 Dec 2017 17:54:30 +0000 (12:54 -0500)
Adding notes to the invoice creation page.
Also I updated the data type for the due_date in the abstract class and
now the due_date is being saved.

classes/data/dataInvoices.php
models/admin/billing/index.php
models/admin/billing/invoices.php
views/admin/billing/editInvoice.html
views/admin/billing/invoices.html
views/admin/billing/subHeader.html

index 948f0fd..a9a295f 100644 (file)
@@ -152,7 +152,7 @@ class GlmDataInvoices extends GlmDataAbstract
             // Due date
             'due_date' => array(
                 'field' => 'due_date',
-                'type'  => 'text',
+                'type'  => 'date',
                 'use'   => 'a',
             ),
 
@@ -239,7 +239,7 @@ class GlmDataInvoices extends GlmDataAbstract
             , ARRAY_A
         );
         foreach( $line_items as $line_item ) {
-            $amount_total += $line_item['amount'];
+            $amount_total += $line_item['amount'] * $line_item['quantity'];
         }
         $balance = $amount_total;
         $this->wpdb->update(
index 875da0a..7ffd2ba 100644 (file)
@@ -91,6 +91,7 @@ class GlmMembersAdmin_billing_index // extends GlmDataBilling
         $numbPending    = 0;
         $namesList      = false;
         $haveCategories = false;
+        $numberPending  = 0;
 
         // For lockedToMember
         $lockedToMember = false;
index 24ebda8..dbe8b15 100644 (file)
@@ -152,8 +152,8 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
         case 'insert':
             // Set transaction_time to current time.
             $_REQUEST['transaction_time'] = date('Y-m-d H:i:s');
-            echo '<pre>' . print_r( $_REQUEST, true ) . '</pre>';
             $_REQUEST['due_date'] = date('Y-m-d', strtotime($_REQUEST['due_date']));
+            echo '<pre>' . print_r( $_REQUEST, true ) . '</pre>';
             $invoices = $this->insertEntry();
             $this->invoice_id = $invoices['fieldData']['id'];
             // After the Invoice is created need to add each line item
@@ -335,12 +335,14 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
 
         $templateData = array(
             'option'              => $option,
+            'invoice_id'          => $this->invoice_id,
             'invoices'            => $invoices,
             'haveInvoices'        => $haveInvoices,
             'invoiceUpdated'      => $invoiceUpdated,
             'invoiceUpdateError'  => $invoiceUpdateError,
             'invoiceAdded'        => $invoiceAdded,
             'invoiceAddError'     => $invoiceAddError,
+            'invoiceInsertError'  => $invoiceInsertError,
             // 'numbTransactions' => $numbTransactions,
             'invoiceDeleted'      => $invoiceDeleted,
             'invoiceDeleteError'  => $invoiceDeleteError,
index 7d1981c..1556940 100644 (file)
                         <input type="text" name="due_date" required>
                     </div>
                 </div>
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-large-3">
+                        Notes
+                    </div>
+                    <div class="glm-columns glm-small-12 glm-large-9">
+                        <textarea name="notes"></textarea>
+                    </div>
+                </div>
 
             </div>
         </div>
 <script>
 jQuery(document).ready(function($){
     // Initialize variables for this page.
-    var invoiceTypeJSON = $.parseJSON( '{$invoiceTypeJSON}' );
-    var dialog, form,
-        line_item_type = $( 'select[name="line_item_type"]' ),
-        line_items     = [],
-        allFields      = $( [] ).add( line_item_type );
+    var dialog,                                                // Dialog for the add line_item form
+        form,                                                  // The add line_item form
+        line_item_type = $( 'select[name="line_item_type"]' ), // Line item type in the add line_item form
+        line_items     = [],                                   // Array holding line_items json objects
+        allFields      = $( [] ).add( line_item_type ),        // Array holding the form fields - add line_item form
+        invoiceTypeJSON = $.parseJSON( '{$invoiceTypeJSON}' ); // Json object with all of the invoices types
 
     /**
      * totalInvoice
index 27b8cf7..5e1dc21 100644 (file)
@@ -27,7 +27,7 @@
                     <td>{$t.id}</td>
                     <td> {$t.member_name} </td>
                     <td> {$t.transaction_time.datetime} </td>
-                    <td> {$t.due_date} </td>
+                    <td> {$t.due_date.date} </td>
                     <td> {$t.balance} </td>
                 </tr>
             {/foreach}
index 53c66c6..f7fcaf2 100644 (file)
@@ -1,6 +1,6 @@
 <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
     <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices"
-        class="nav-tab{if $thisAction==invoices && !$option} nav-tab-active{/if}">Search Invoices</a>
+        class="nav-tab{if $option == 'list'} nav-tab-active{/if}">Search Invoices</a>
     <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices&option=add"
-        class="nav-tab{if $option} nav-tab-active{/if}">Create Invoice</a>
+        class="nav-tab{if $option == 'add' || $option == 'edit'} nav-tab-active{/if}">Create Invoice</a>
 </h2>