Commit 910e6509 authored by RobertPlummer's avatar RobertPlummer

[NEW] Tracker Query Lib gets a boolean $desc variable, useful for getting...

[NEW] Tracker Query Lib gets a boolean $desc variable, useful for getting things like last inserted val (which is why I added it)
[NEW] Invoice Clients list
[FIX] Invoice fixes, and case modification, probably needs to be better addressed
parent d83097ba
......@@ -5160,6 +5160,7 @@ templates/tiki-list_file_gallery.tpl -text
templates/tiki-list_gallery.tpl -text
templates/tiki-list_integrator_repositories.tpl -text
templates/tiki-list_invite.tpl -text
templates/tiki-list_invoice_clients.tpl -text
templates/tiki-list_invoices.tpl -text
templates/tiki-list_kaltura_browse_entries.tpl -text
templates/tiki-list_kaltura_entries.tpl -text
......@@ -5636,6 +5637,7 @@ tests/testfile.txt -text
/tiki-list_gallery.php -text
/tiki-list_integrator_repositories.php -text
/tiki-list_invite.php -text
/tiki-list_invoice_clients.php -text
/tiki-list_invoices.php -text
/tiki-list_kaltura_entries.php -text
/tiki-list_object_permissions.php -text
......
......@@ -229,7 +229,7 @@ class TrackerQueryLib extends TikiLib
* )
* )
*/
function tracker_query($tracker, $start, $end, $itemId, $equals, $search, $fields, $status = "opc", $sort, $limit, $offset, $byName, $includeTrackerDetails = true, $delimiter = "[{|!|}]") {
function tracker_query($tracker, $start, $end, $itemId, $equals, $search, $fields, $status = "opc", $sort, $limit, $offset, $byName, $includeTrackerDetails = true, $desc = true, $delimiter = "[{|!|}]") {
global $tikilib;
$debug = false;
$params = array();
......@@ -361,7 +361,7 @@ class TrackerQueryLib extends TikiLib
".(isset($status_safe) && !empty($status_safe) ? $status_safe : "")."
GROUP BY
tiki_tracker_item_fields.itemId
tiki_tracker_item_fields.itemId ".($desc == true ? 'DESC' : 'ASC')."
ORDER BY
tiki_tracker_items.lastModif
".(isset($limit) && !empty($limit) ?
......@@ -409,7 +409,7 @@ class TrackerQueryLib extends TikiLib
/*Does the same thing as tracker_query, but uses tracker and field names rather than ids, a bit slower, but probably not noticed
*/
function tracker_query_by_names($tracker, $start, $end, $itemId, $equals, $search, $fields, $status, $sort, $limit, $offset, $includeTrackerDetails = true) {
function tracker_query_by_names($tracker, $start, $end, $itemId, $equals, $search, $fields, $status, $sort, $limit, $offset, $includeTrackerDetails) {
return $tracker = $this->tracker_query($tracker, $start, $end, $itemId, $equals, $search, $fields, $status, $sort, $limit, $offset, true, $includeTrackerDetails);
}
......
......@@ -20,10 +20,10 @@
{/foreach}
</select>
<table class='InvoiceDetails'>
<table class='InvoiceDetails' border="0" style='width: 100%;'>
<tr>
<td>
{tr}Invoice Number{/tr} <input name='InvoiceNumber' id='InvoiceNumber' type='text' value='{$invoice.$InvoiceNumber}' />
{tr}Invoice Number{/tr} <input name='InvoiceNumber' id='InvoiceNumber' type='text' value='{if $invoice.$InvoiceNumber}{$invoice.$InvoiceNumber}{else}{$NewInvoiceNumber}{/if}' />
<br />
{tr}Date Issued{/tr} <input name='DateIssued' id='DateIssued' value='{$invoice.$DateIssued}' />
</td>
......
<ul class="tiki-invoice-menu">
<li><a href="tiki-list_invoices.php">Invoice Summary</a></li>
<li><a href="tiki-edit_invoice.php">New Invoice</a></li>
<li><a href="tiki-list_invoices.php">Invoices</a></td>
<li><a href="tiki-list_invoice_clients.php">Clients</a></td>
<li><a href="tiki-invoice_reports.php">Reports</a></td>
<li><a href="tiki-admin_invoices.php">Settings</a></li>
</ul>
\ No newline at end of file
<div class="TikiInvoiceMenu">
{button href="tiki-list_invoices.php" _text="{tr}Invoices{/tr}"}
{button href="tiki-edit_invoice.php" _text="{tr}New Invoice{/tr}"}
{button href="tiki-list_invoice_clients.php" _text="{tr}Clients{/tr}"}
{button href="tiki-edit_invoice_client.php" _text="{tr}New Client{/tr}"}
{button href="tiki-invoice_reports.php" _text="{tr}Reports{/tr}"}
{button href="tiki-admin_invoices.php" _text="{tr}Settings{/tr}"}
</div>
\ No newline at end of file
{title help="Invoice"}{tr}Invoice Clients{/tr}{/title}
{include file='tiki-invoice_menu.tpl'}
{* vars to deal with keys that have spaces *}
{assign var=ClientId value="Client Id"}
{assign var=Address1 value="Address 1"}
{assign var=Address2 value="Address 2"}
{assign var=PostalCode value="Postal Code"}
{assign var=TaxStatus value="Tax Status"}
{assign var=ClientNotes value="Client Notes"}
{assign var=TaxCode value="Tax Code"}
{foreach from=$Clients item=Client}
<div>
<h3 class='ClientName'>{$Client.Name}</h3>
<div class='ClientDetails' style='display: none;'>
<table>
<tr>
<td>
{if $Client.$Address1}{$Client.$Address1}<br />{/if}
{if $Client.$Address2}{$Client.$Address2}<br />{/if}
{if $Client.City && $Client.Province && $Client.$PostalCode}{$Client.City} {$Client.Province}, {$Client.$PostalCode}<br />{/if}
{if $Client.Website}<a href='{$Client.Website}'>{$Client.Website}</a><br />{/if}
{tr}Tax Status:{/tr} {if $Client.$TaxStatus eq 'y'}{tr}Taxable{/tr}{else}Not Taxable{/if}<br />
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
{/foreach}
\ No newline at end of file
......@@ -4,6 +4,7 @@
{* vars to deal with keys that have spaces *}
{assign var=ClientId value="Client Id"}
{assign var=ClientName value="Client Name"}
{assign var=ItemAmounts value="Item Amounts"}
{assign var=WorkDescription value="Work Description"}
{assign var=InvoiceNumber value="Invoice Number"}
......@@ -11,22 +12,22 @@
{assign var=InvoiceNote value="Invoice Note"}
{assign var=InvoiceId value="Invoice Id"}
<table>
<table border="0" style="width: 100%;">
<tr>
<td>{tr}Invoice{/tr}</td>
<td>{tr}Date Issued{/tr}</td>
<td>{tr}Client Name{/tr}</td>
<td>{tr}Amount{/tr}</td>
<td>{tr}Status{/tr}</td>
<th>{tr}Invoice{/tr}</th>
<th>{tr}Date Issued{/tr}</th>
<th>{tr}Client Name{/tr}</th>
<th>{tr}Amount{/tr}</th>
<th>{tr}Status{/tr}</th>
</tr>
{foreach from=$invoices key=k item=invoice}
{foreach from=$Invoices item=Invoice}
<tr>
<td><a href='tiki-view_invoice.php?InvoiceId={$invoice.$InvoiceId}'>{$invoice.$InvoiceNumber}</a></td>
<td><a href='tiki-view_invoice.php?InvoiceId={$invoice.$InvoiceId}'>{$invoice.$DateIssued}</a></td>
<td><a href='tiki-view_invoice_client.php?invoice={$invoice.$ClientId}'>{$invoice.$ClientName}</a></td>
<td><a href='tiki-view_invoice.php?InvoiceId={$invoice.$InvoiceId}'>{$invoice.Amount}</a></td>
<td><a href='tiki-view_invoice.php?InvoiceId={$invoice.$InvoiceId}'>{$invoice.Status}</a></td>
<td><a href='tiki-view_invoice.php?InvoiceId={$Invoice.$InvoiceId}'>{$Invoice.$InvoiceNumber}</a></td>
<td><a href='tiki-view_invoice.php?InvoiceId={$Invoice.$InvoiceId}'>{$Invoice.$DateIssued}</a></td>
<td><a href='tiki-view_invoice_client.php?invoice={$Invoice.$ClientId}'>{$Invoice.$ClientName}</a></td>
<td><a href='tiki-view_invoice.php?InvoiceId={$Invoice.$InvoiceId}'>{$Invoice.Amount}</a></td>
<td><a href='tiki-view_invoice.php?InvoiceId={$Invoice.$InvoiceId}'>{$Invoice.Status}</a></td>
</tr>
{/foreach}
......
......@@ -102,6 +102,11 @@ if (!empty($_REQUEST['InvoiceId'])) {
$_REQUEST['InvoiceId'] = 0;
}
//give the user the last invoice number
$LastInvoice = end($trkqrylib->tracker_query_by_names("Invoices", null, null, null, null, null, null, null, null, 0, 1, true, false));
$NewInvoiceNumber = (isset($LastInvoice["Invoice Number"]) ? $LastInvoice["Invoice Number"] + 1 : 1);
$smarty->assign("NewInvoiceNumber", $NewInvoiceNumber);
$smarty->assign("InvoiceId", $_REQUEST['InvoiceId']);
$smarty->assign("clients", $trkqrylib->tracker_query_by_names("Invoice Clients"));
$smarty->assign("setting", end($trkqrylib->tracker_query_by_names("Invoice Settings")));
......
<?php
require_once('tiki-setup.php');
require_once('lib/profilelib/installlib.php');
require_once('lib/profilelib/profilelib.php');
require_once('lib/trackers/trackerquerylib.php');
global $tikilib, $trkqrylib;
$access->check_feature('feature_invoice');
$access->check_permission('tiki_p_admin');
//check if profile is created
$installer = new Tiki_Profile_Installer();
$profile = Tiki_Profile::fromNames( "profiles.tiki.org","Invoice" );
if (!$installer->isInstalled( $profile )) {
$smarty->assign('msg', tra('You need to apply the "Invoice" profile'));
$smarty->display("error.tpl");
die;
}
$headerlib->add_jq_onready("
$('.ClientName').each(function(i) {
$(this)
.click(function() {
$('.ClientDetails').eq(i).toggle('fast');
})
.css('cursor', 'pointer');
});
");
$smarty->assign("Clients", $trkqrylib->tracker_query_by_names("Invoice Clients"));
$smarty->assign("Settings", end($trkqrylib->tracker_query_by_names("Invoice Settings")));
// Display the template
$smarty->assign('mid', 'tiki-list_invoice_clients.tpl');
$smarty->display("tiki.tpl");
\ No newline at end of file
......@@ -18,51 +18,47 @@ if (!$installer->isInstalled( $profile )) {
die;
}
$invoices = $trkqrylib->tracker_query_by_names("Invoices");
$clients = $trkqrylib->tracker_query_by_names("Invoices Clients");
$settings = end($trkqrylib->tracker_query_by_names("Invoice Settings"));
$Invoices = $trkqrylib->tracker_query_by_names("Invoices");
foreach($invoices as $key => $invoice) {
$amount = 0;
$paid = 0;
$status = "";
foreach($Invoices as $I => $Invoice) {
$Amount = 0;
$Paid = 0;
$Status = "";
if (is_array($invoice["Item Amounts"])) {
foreach($invoice["Item Amounts"] as $key => $sum) {
$amount += $invoice["Item Amounts"][$key] * $invoice["Item Quantities"][$key];
if (is_array($Invoice["Item Amounts"])) {
foreach($Invoice["Item Amounts"] as $Key => $sum) {
$Amount += $Invoice["Item Amounts"][$Key] * $Invoice["Item Quantities"][$Key];
}
} else {
$amount = $invoice["Item Amounts"] * $invoice["Item Quantities"];
$Amount = $Invoice["Item Amounts"] * $Invoice["Item Quantities"];
}
$invoice["Amount"] = $amount;
$Invoices[$I]["Amount"] = $Amount;
if (is_array($invoice["Amounts Paid"])) {
foreach($invoice["Amounts Paid"] as $sum) {
$paid += $sum;
if (is_array($Invoice["Amounts Paid"])) {
foreach($Invoice["Amounts Paid"] as $Sum) {
$Paid += $Sum;
}
} else {
$paid = $invoice["Amounts Paid"];
$Paid = $Invoice["Amounts Paid"];
}
$invoice["Paid"] = $paid;
$Invoices[$I]["Paid"] = $Paid;
if ($amount == $paid) {
$status = "Paid";
if ($Amount == $Paid) {
$Status = "Paid";
} else {
$status = "Open";
$Status = "Open";
}
$invoice["Status"] = $status;
$Invoices[$I]["Status"] = $Status;
}
$smarty->assign("invoices", $invoices);
$smarty->assign("clients", $clients);
$smarty->assign("settings", $settings);
$smarty->assign("amount", $amount);
$smarty->assign("paid", $paid);
$smarty->assign("status", $status);
$smarty->assign("Invoices", $Invoices);
$smarty->assign("Settings", end($trkqrylib->tracker_query_by_names("Invoice Settings")));
$smarty->assign("Amount", $Amount);
$smarty->assign("Paid", $Paid);
$smarty->assign("Status", $Status);
// Display the template
$smarty->assign('mid', 'tiki-list_invoices.tpl');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment