Initial Commit of AgileBill Open Source
This commit is contained in:
35
themes/default/blocks/asset_invoice/ajax.js
Normal file
35
themes/default/blocks/asset_invoice/ajax.js
Normal file
@@ -0,0 +1,35 @@
|
||||
// JavaScript Document
|
||||
var http=getHTTPObject();
|
||||
|
||||
function assignInvoice(id, items) {
|
||||
var itemstring='';
|
||||
for(var i=0; i<items.length; i++) {
|
||||
itemstring += '&items['+ items[i]['id'] + ']=' + items[i]['value'];
|
||||
if(items[i]['value'] == '0') {
|
||||
alert('All products must be assigned');
|
||||
return void(0);
|
||||
}
|
||||
}
|
||||
var url = 'ajax.php?do[]=asset_invoice:assign&invoice_id='+id+itemstring;
|
||||
http.open("GET", url, true);
|
||||
http.onreadystatechange = function() {
|
||||
if (http.readyState == 4) {
|
||||
try {
|
||||
if(http.responseText=='true') {
|
||||
document.getElementById(id).innerHTML='<b><center>Success! Asset(s) assigned for invoice # ' + id + '</center></b>';
|
||||
} else {
|
||||
alert(http.responseText);
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
}
|
||||
http.send(null);
|
||||
}
|
||||
|
||||
function setItemValue(items, itemId, value) {
|
||||
for(var i=0; i<items.length; i++) {
|
||||
if(items[i]['id'] == itemId) {
|
||||
items[i]['value'] = value;
|
||||
}
|
||||
}
|
||||
}
|
60
themes/default/blocks/asset_invoice/invoice.tpl
Normal file
60
themes/default/blocks/asset_invoice/invoice.tpl
Normal file
@@ -0,0 +1,60 @@
|
||||
<script src="themes/default/blocks/asset_invoice/ajax.js" type="text/javascript"></script>
|
||||
{if !$invoices}
|
||||
<b>No invoices found</b>
|
||||
{else}
|
||||
{foreach from=$invoices item=i}
|
||||
|
||||
<form target="_blank">
|
||||
<table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#666666">
|
||||
<tr>
|
||||
<th colspan="2" bgcolor="#999999" scope="col"><font color="#FFFFFF">Invoice # {$i.id} </font></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="10%"><strong>Customer</strong></td>
|
||||
<td width="90%">{$i.first_name} {$i.last_name}, {$i.address1} {$i.address2}, {$i.city}, {$i.state} {$i.zip} </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" bgcolor="#CCCCCC">
|
||||
<div id="{$i.id}">
|
||||
<table width="100%" border="1" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC" bgcolor="#FFFFFF">
|
||||
<tr>
|
||||
<th scope="col">SKU</th>
|
||||
<th scope="col">PRODUCT NAME </th>
|
||||
<th scope="col">ASSIGN ASSET </th>
|
||||
</tr>
|
||||
{foreach from=$i.items item=p}
|
||||
<tr>
|
||||
<td>{$p.sku}</td>
|
||||
<td>{$p.name}</td>
|
||||
<td>
|
||||
<select name="items" onchange="setItemValue(items_{$i.id}, {$p.id}, this.value)">
|
||||
<option value="0">- SELECT ASSET -</option>
|
||||
{foreach from=$assets item=a}
|
||||
<option value="{$a.id}">{$a.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right">
|
||||
<input type="button" value="Assign Now" onclick="assignInvoice('{$i.id}', items_{$i.id});" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<input type="hidden" name="_page" value="asset_invoice:assign" />
|
||||
<input type="hidden" name="do[]" value="asset_invoice:assign" />
|
||||
<input type="hidden" name="invoice_id" value="{$i.id}" />
|
||||
<input type="hidden" name="pool_id" value="{$VAR.pool_id}" />
|
||||
</form>
|
||||
<script>
|
||||
var items_{$i.id} = [];
|
||||
{$i.itemsJs}
|
||||
</script>
|
||||
{/foreach}
|
||||
{/if}
|
16
themes/default/blocks/asset_invoice/main.tpl
Normal file
16
themes/default/blocks/asset_invoice/main.tpl
Normal file
@@ -0,0 +1,16 @@
|
||||
{$method->exe("asset_invoice","main")}
|
||||
{if !$pools}
|
||||
<h3>No Asset Pools Configured</h3>
|
||||
{else}
|
||||
<h3>Select an Asset Pool</h3>
|
||||
<form>
|
||||
<select name="pool_id">
|
||||
{foreach from=$pools item=p}
|
||||
<option value="{$p.id}">{$p.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input type="hidden" name="_page" value="asset_invoice:invoice" />
|
||||
<input type="hidden" name="do[]" value="asset_invoice:invoice" />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
{/if}
|
Reference in New Issue
Block a user