</td>
</tr>
<tr>
- <th>Code:</th>
+ <th class="glm-required">Parent:</th>
<td>
- <input type="text" name="qcode" class="glm-form-text-input">
- </td>
- </tr>
- <tr>
- <th class="glm-required">Category:</th>
- <td>
- <input type="text" name="category" class="glm-form-text-input" required>
+ <select name="parent">
+ <option value="0">(none)</option>
+ {if $haveInvoiceTypes}
+ {foreach $invoiceTypes as $type}
+ <option value="{$type.id}">{$type.name}</option>
+ {/foreach}
+ {/if}
+ </select>
</td>
</tr>
<tr>
</td>
</tr>
<tr>
- <th>Dynamic Amount:</th>
+ <th>Recurring:</th>
<td>
- <input type="hidden" name="dynamic_amount" class="glm-form-text-input" value="0">
- <input type="checkbox" name="dynamic_amount" class="glm-form-text-input" value="1">
+ <input type="hidden" name="recurring" class="glm-form-text-input" value="0">
+ <input type="checkbox" name="recurring" class="glm-form-text-input" value="1">
</td>
</tr>
<tr>
- <th>Notes:</th>
+ <th>Recurrence:</th>
<td>
- <textarea name="notes" class="glm-form-textarea"></textarea>
+ <select name="recurrence">
+ <option value="">(none)</option>
+ {foreach $recurrenceTypes as $typeId => $typeLabel}
+ <option value="{$typeId}">{$typeLabel}</option>
+ {/foreach}
+ </select>
</td>
</tr>
</table>
<!-- Add InvoiceTypes Button -->
<div id="deleteInvoiceTypeDialog" class="glm-dialog-box" title="Delete InvoiceType">
<center>
- <p>Are you sure you want to delete this inoiceType?</p>
- <p><div id="deleteInvoiceTypeConfirm" class="button button-primary">Yes, delete this inoiceType</div></p>
+ <p>Are you sure you want to delete this invoice Type?</p>
+ <p><div id="deleteInvoiceTypeConfirm" class="button button-primary">Yes, delete this invoice Type</div></p>
<p><div id="deleteInvoiceTypeCancel" class="button button-primary">Cancel</div></p>
</center>
</div>
<form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
<input type="hidden" name="glm_action" value="invoiceTypes">
<input type="hidden" name="option" value="update">
- <input id="editInvoiceTypeID" type="hidden" name="id" value="">
+ <input id="edit-id" type="hidden" name="id" value="">
<table class="glm-admin-table">
<tr>
<th class="glm-required">Invoice Type Name:</th>
<td>
- <input id="editInvoiceTypeName" type="text" name="name" class="glm-form-text-input" required>
+ <input id="edit-name" type="text" name="name" class="glm-form-text-input" required>
</td>
</tr>
<tr>
- <th>Code:</th>
+ <th class="glm-required">Parent:</th>
<td>
- <input id="editInvoiceTypeQCode" type="text" name="qcode" class="glm-form-text-input">
+ <select id="edit-parent" name="parent">
+ <option value="0">(none)</option>
+ {if $haveInvoiceTypes}
+ {foreach $invoiceTypes as $type}
+ {if !$type.parent.value} <!-- don't show child categories -->
+ <option value="{$type.id}">{$type.name}</option>
+ {/if}
+ {/foreach}
+ {/if}
+ </select>
</td>
</tr>
<tr>
- <th class="glm-required">Category:</th>
- <td>
- <input id="editInvoiceTypeCategory" type="text" name="category" class="glm-form-text-input" required>
- </td>
- </tr>
- <tr>
- <th class="glm-required">Amount:</th>
+ <th class="glm-required">Amount:Numbers only (999.99)</th>
<td>
- <input id="editInvoiceTypeAmount" type="text" name="amount" class="glm-form-text-input" required>
+ <input id="edit-amount" type="text" name="amount" class="glm-form-text-input" required>
</td>
</tr>
<tr>
- <th>Dynamic Amount:</th>
+ <th>Recurring:</th>
<td>
- <input type="hidden" name="dynamic_amount" class="glm-form-text-input" value="0">
- <input id="editInvoiceTypeDynamicAmount" type="checkbox" name="dynamic_amount" class="glm-form-text-input" value="1">
+ <input type="hidden" name="recurring" class="glm-form-text-input" value="0">
+ <input id="edit-recurring" type="checkbox" name="recurring" class="glm-form-text-input" value="1">
</td>
</tr>
<tr>
- <th>Notes:</th>
+ <th>Recurrence:</th>
<td>
- <textarea id="editInvoiceTypeNotes" name="notes" class="glm-form-textarea"></textarea>
+ <select id="edit-recurrence" name="recurrence">
+ <option value="">(none)</option>
+ {foreach $recurrenceTypes as $typeId => $typeLabel}
+ <option value="{$typeId}">{$typeLabel}</option>
+ {/foreach}
+ </select>
</td>
</tr>
</table>
<th>ID</th>
<th>InvoiceType</th>
<th>Amount</th>
+ <th>Recurring</th>
+ <th>Recurrence</th>
<th> </th>
</tr>
</thead>
{/if}
<td>{$t.id}</td>
<td>
- <a class="editInvoiceType"
- data-inoiceTypeID="{$t.id}"
- data-inoiceTypeName="{$t.name}"
- data-inoiceTypeQCode="{$t.qcode}"
- data-inoiceTypeCategory="{$t.category}"
- data-inoiceTypeAmount="{$t.amount}"
- data-inoiceTypeDynamicAmount="{$t.dynamic_amount}"
- data-inoiceTypeNotes="{$t.notes}">{$t.name}</a>
- </td>
- <td>
- {$t.amount}
+ <div{if $t.parent.value} class="glm-indent"{/if}>
+ <a class="editInvoiceType"
+ data-invoice-id="{$t.id}"
+ data-invoice-name="{$t.name}"
+ data-invoice-parent="{$t.parent}"
+ data-invoice-amount="{$t.amount}"
+ data-invoice-recurring="{$t.recurring.value}"
+ data-invoice-recurrence="{$t.recurrence}">{$t.name}</a>
+ </div>
</td>
+ <td>{$t.amount}</td>
+ <td>{if $t.recurring.value}Yes{else}No{/if}</td>
+ <td>{if $t.recurrence}{$recurrenceTypes[$t.recurrence]}{/if}</td>
<td>
- <div class="deleteInvoiceTypeButton button button-secondary glm-button-small glm-right" data-inoiceTypeID="{$t.id}">Delete</div>
+ <div class="deleteInvoiceTypeButton button button-secondary glm-button-small glm-right" data-invoiceTypeID="{$t.id}">Delete</div>
</td>
</tr>
{/foreach}
$("#newInvoiceTypeDialog").dialog("open");
});
$('.editInvoiceType').click( function() {
- $('#editInvoiceTypeDynamicAmount').prop( 'checked', false );
+ $('#editRecurring').prop( 'checked', false );
- var inoiceTypeID = $(this).data('inoicetypeid');
- var inoiceTypeName = $(this).data('inoicetypename');
- var inoiceTypeQCode = $(this).data('inoicetypeqcode');
- var inoiceTypeCategory = $(this).data('inoicetypecategory');
- var inoiceTypeAmount = $(this).data('inoicetypeamount');
- var inoiceTypeDynamicAmount = $(this).data('inoicetypedynamicamount');
- var inoiceTypeNotes = $(this).data('inoicetypenotes');
+ var invoiceID = $(this).data('invoice-id');
+ var invoiceName = $(this).data('invoice-name');
+ var invoiceParent = $(this).data('invoice-parent');
+ var invoiceAmount = $(this).data('invoice-amount');
+ var invoiceRecurring = $(this).data('invoice-recurring');
+ var invoiceRecurrence = $(this).data('invoice-recurrence');
- // Set the values of the edit form for the selected inoiceType
- $('#editInvoiceTypeID').val( inoiceTypeID );
- $('#editInvoiceTypeName').val( inoiceTypeName );
- $('#editInvoiceTypeQCode').val( inoiceTypeQCode );
- $('#editInvoiceTypeCategory').val( inoiceTypeCategory );
- $('#editInvoiceTypeAmount').val( inoiceTypeAmount );
- if ( inoiceTypeDynamicAmount === 1 ) {
- $('#editInvoiceTypeDynamicAmount').prop( 'checked', true );
+ // Set the values of the edit form for the selected invoiceType
+ $('#edit-id').val( invoiceID );
+ $('#edit-name').val( invoiceName );
+ $('#edit-parent').val( invoiceParent );
+ $('#edit-amount').val( invoiceAmount );
+ if ( invoiceRecurring === 1 ) {
+ $('#edit-recurring').prop( 'checked', true );
}
- $('#editInvoiceTypeNotes').val( inoiceTypeNotes );
+ console.log(invoiceRecurring);
+ $('#edit-recurrence').val( invoiceRecurrence );
$("#editInvoiceTypeDialog").dialog("open");
});
var id = false;
$('.deleteInvoiceTypeButton').click( function() {
- id = $(this).attr('data-inoiceTypeID');
+ id = $(this).attr('data-invoiceTypeID');
$("#deleteInvoiceTypeDialog").dialog("open");
});
$('#deleteInvoiceTypeConfirm').click( function() {