} $statusoptions .= "</select> <span id=\"orderstatusupdated\" style=\"display:none;padding-top:14px;\"><img src=\"images/icons/tick.png\" /></span>"; $orderdata = unserialize($orderdata); if ($invoiceid == "0") { $paymentstatus = "<span class=\"textgreen\">" . $aInt->lang("orders", "noinvoicedue") . "</span>"; } else { if (!$invoicestatus) { $paymentstatus = "<span class=\"textred\">Invoice Deleted</span>"; } else { if ($invoicestatus == "Paid") { $paymentstatus = "<span class=\"textgreen\">" . $aInt->lang("status", "complete") . "</span>"; } else { if ($invoicestatus == "Unpaid") { $paymentstatus = "<span class=\"textred\">" . $aInt->lang("status", "incomplete") . "</span>"; } else { $paymentstatus = getInvoiceStatusColour($invoicestatus); } } } } run_hook("ViewOrderDetailsPage", array("orderid" => $id, "ordernum" => $ordernum, "userid" => $userid, "amount" => $amount, "paymentmethod" => $paymentmethod, "invoiceid" => $invoiceid, "status" => $orderstatus)); $clientnotes = array(); $result = select_query("tblnotes", "tblnotes.*,(SELECT CONCAT(firstname,' ',lastname) FROM tbladmins WHERE tbladmins.id=tblnotes.adminid) AS adminuser", array("userid" => $userid, "sticky" => "1"), "modified", "DESC"); while ($data = mysql_fetch_assoc($result)) { $data['created'] = fromMySQLDate($data['created'], 1); $data['modified'] = fromMySQLDate($data['modified'], 1); $data['note'] = autoHyperLink(nl2br($data['note'])); $clientnotes[] = $data; } if (count($clientnotes)) { echo "<div id=\"clientsimportantnotes\">\n";
$currency = getCurrency($userid); $gatewaysarray = getGatewaysArray(); $aInt->sortableTableInit("nopagination"); $result = select_query("tblinvoiceitems", "tblinvoices.*", array("type" => "Item", "relid" => $id), "invoiceid", "ASC", "", "tblinvoices ON tblinvoices.id=tblinvoiceitems.invoiceid"); while ($data = mysql_fetch_array($result)) { $invoiceid = $data['id']; $date = $data['date']; $duedate = $data['duedate']; $total = $data['total']; $paymentmethod = $data['paymentmethod']; $status = $data['status']; $date = fromMySQLDate($date); $duedate = fromMySQLDate($duedate); $total = formatCurrency($total); $paymentmethod = $gatewaysarray[$paymentmethod]; $status = getInvoiceStatusColour($status); $invoicelink = "<a href=\"invoices.php?action=edit&id=" . $invoiceid . "\">"; $tabledata[] = array($invoicelink . $invoiceid . "</a>", $date, $duedate, $total, $paymentmethod, $status, $invoicelink . "<img src=\"images/edit.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"" . $aInt->lang("global", "edit") . "\"></a>"); } echo "<h2>" . $aInt->lang("billableitems", "relatedinvoices") . "</h2>" . $aInt->sortableTable(array($aInt->lang("fields", "invoicenum"), $aInt->lang("fields", "invoicedate"), $aInt->lang("fields", "duedate"), $aInt->lang("fields", "total"), $aInt->lang("fields", "paymentmethod"), $aInt->lang("fields", "status"), ""), $tabledata); } echo "\n<p align=\"center\"><input type=\"submit\" value=\""; echo $aInt->lang("global", "savechanges"); echo "\" class=\"button\" /></p>\n</form>\n\n"; } } $content = ob_get_contents(); ob_end_clean(); $aInt->content = $content; $aInt->jquerycode = $jquerycode; $aInt->jscode = $jscode;
if ($qryorderby == "id") { $qryorderby = "tblinvoices`.`invoicenum` " . $order . ",`tblinvoices`.`id"; } $result = select_query("tblinvoices", "", implode(" AND ", $filters), $qryorderby, $order, $page * $limit . ("," . $limit)); while ($data = mysql_fetch_array($result)) { $id = $data['id']; $invoicenum = $data['invoicenum']; $date = $data['date']; $duedate = $data['duedate']; $datepaid = $data['datepaid']; $credit = $data['credit']; $total = $data['total']; $paymentmethod = $data['paymentmethod']; $paymentmethod = $gatewaysarray[$paymentmethod]; $status = $data['status']; $status = getInvoiceStatusColour($status, false); $date = fromMySQLDate($date); $duedate = fromMySQLDate($duedate); $datepaid = $datepaid == "0000-00-00 00:00:00" ? "-" : fromMySQLDate($datepaid); $total = formatCurrency($credit + $total); if (!$invoicenum) { $invoicenum = $id; } $tabledata[] = array("<input type=\"checkbox\" name=\"selectedinvoices[]\" value=\"" . $id . "\" class=\"checkall\">", "<a href=\"invoices.php?action=edit&id=" . $id . "\">" . $invoicenum . "</a>", $date, $duedate, $datepaid, "<a href=\"invoices.php?action=invtooltip&id=" . $id . "&userid=" . $userid . generate_token("link") . ("\" class=\"invtooltip\" lang=\"\">" . $total . "</a>"), $paymentmethod, $status, "<a href=\"invoices.php?action=edit&id=" . $id . "\"><img src=\"images/edit.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"" . $aInt->lang("global", "edit") . "\"></a>", "<a href=\"#\" onClick=\"doDelete('" . $id . "');return false\"><img src=\"images/delete.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"" . $aInt->lang("global", "delete") . "\"></a>"); } $tableformurl = $_SERVER['PHP_SELF'] . "?userid=" . $userid . "&filter=1"; if ($page) { $tableformurl .= "&page=" . $page; } $tableformbuttons = "<input type=\"submit\" value=\"" . $aInt->lang("invoices", "markpaid") . "\" class=\"btn-success\" name=\"markpaid\" onclick=\"return confirm('" . $aInt->lang("invoices", "markpaidconfirm", "1") . "')\" /> <input type=\"submit\" value=\"" . $aInt->lang("invoices", "markunpaid") . "\" name=\"markunpaid\" onclick=\"return confirm('" . $aInt->lang("invoices", "markunpaidconfirm", "1") . "')\" /> <input type=\"submit\" value=\"" . $aInt->lang("invoices", "markcancelled") . "\" name=\"markcancelled\" onclick=\"return confirm('" . $aInt->lang("invoices", "markcancelledconfirm", "1") . "')\" /> <input type=\"submit\" value=\"" . $aInt->lang("invoices", "duplicateinvoice") . "\" name=\"duplicateinvoice\" onclick=\"return confirm('" . $aInt->lang("invoices", "duplicateinvoiceconfirm", "1") . "')\" /> <input type=\"submit\" value=\"" . $aInt->lang("invoices", "sendreminder") . "\" name=\"paymentreminder\" onclick=\"return confirm('" . $aInt->lang("invoices", "sendreminderconfirm", "1") . "')\" /> <input type=\"submit\" value=\"" . $aInt->lang("invoices", "merge") . "\" name=\"merge\" onclick=\"return confirm('" . $aInt->lang("invoices", "mergeconfirm", "1") . "')\" /> <input type=\"submit\" value=\"" . $aInt->lang("invoices", "masspay") . "\" name=\"masspay\" onclick=\"return confirm('" . $aInt->lang("invoices", "masspayconfirm", "1") . "')\" /> <input type=\"submit\" value=\"" . $aInt->lang("global", "delete") . "\" class=\"btn-danger\" name=\"massdelete\" onclick=\"return confirm('" . $aInt->lang("invoices", "massdeleteconfirm", "1") . "')\" />"; echo $aInt->sortableTable(array("checkall", array("id", $aInt->lang("fields", "invoicenum")), array("date", $aInt->lang("fields", "invoicedate")), array("duedate", $aInt->lang("fields", "duedate")), array("datepaid", $aInt->lang("fields", "datepaid")), array("total", $aInt->lang("fields", "total")), array("paymentmethod", $aInt->lang("fields", "paymentmethod")), array("status", $aInt->lang("fields", "status")), "", ""), $tabledata, $tableformurl, $tableformbuttons);
public function getInvoices($status = "", $userid = "", $orderby = "id", $sort = "DESC", $limit = "") { global $whmcs; $where = array(); if ($status) { $where['status'] = $status; } if ($userid) { $where['userid'] = $userid; } $where["(select count(id) from tblinvoiceitems where invoiceid=tblinvoices.id and type='Invoice')"] = array("sqltype" => "<=", "value" => 0); $invoices = array(); $result = select_query("tblinvoices", "tblinvoices.*,total-COALESCE((SELECT SUM(amountin-amountout) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id),0) AS balance", $where, $orderby, $sort, $limit); while ($data = mysql_fetch_array($result)) { $id = $data['id']; $invoicenum = $data['invoicenum']; $date = $data['date']; $duedate = $data['duedate']; $credit = $data['credit']; $total = $data['total']; $balance = $data['balance']; $status = $data['status']; if ($status == "Unpaid") { $this->totalbalance += $balance; } $date = fromMySQLDate($date, 0, 1); $duedate = fromMySQLDate($duedate, 0, 1); $rawstatus = strtolower($status); if (!$invoicenum) { $invoicenum = $id; } $invoices[] = array("id" => $id, "invoicenum" => $invoicenum, "datecreated" => $date, "datedue" => $duedate, "total" => formatCurrency($credit + $total), "balance" => formatCurrency($balance), "status" => getInvoiceStatusColour($status), "rawstatus" => $rawstatus, "statustext" => $whmcs->get_lang("invoices" . $rawstatus)); } return $invoices; }
$invoiceids = get_query_val("mod_project", "invoiceids", array("id" => $projectid)); $invoicesoutputarr = explode(",", $invoiceids); foreach ($invoicesoutputarr as $invoiceid) { if ($invoiceid) { $data = get_query_vals("tblinvoices", "id,date,datepaid,total,paymentmethod,status", array("id" => $invoiceid)); echo "<tr><td><a href=\"invoices.php?action=edit&id=" . $data['id'] . "\">" . $data['id'] . "</a></td><td>" . fromMySQLdate($data['date']) . "</td><td>" . fromMySQLdate($data['datepaid']) . "</td><td>" . formatCurrency($data['total']) . "</td><td>" . $gateways[$data['paymentmethod']] . "</td><td>" . getInvoiceStatusColour($data['status']) . "</td></tr>"; continue; } } $invoiceid = ""; $ticketinvoicesquery = !empty($ticketinvoicelinks) ? "(" . implode(" OR ", $ticketinvoicelinks) . ") OR " : ""; $result = select_query("tblinvoices", "", "id IN (SELECT invoiceid FROM tblinvoiceitems WHERE description LIKE '%Project #" . $projectid . "%' OR " . $ticketinvoicesquery . " (type='Project' AND relid='" . $projectid . "'))", "id", "ASC"); while ($data = mysql_fetch_array($result)) { $invoiceid = $data['id']; if (!in_array($invoiceid, $invoicesoutputarr)) { echo "<tr><td><a href=\"invoices.php?action=edit&id=" . $data['id'] . "\">" . $data['id'] . "</a></td><td>" . fromMySQLdate($data['date']) . "</td><td>" . fromMySQLdate($data['datepaid']) . "</td><td>" . formatCurrency($data['total']) . "</td><td>" . $gateways[$data['paymentmethod']] . "</td><td>" . getInvoiceStatusColour($data['status']) . "</td></tr>"; } } if (!$invoiceid && !$invoicesoutputarr) { echo "<tr id=\"noassociatedinvoicesfound\"><td colspan=\"6\" align=\"center\">" . $vars['_lang']['noassociatedinvoicesfound'] . "</td></tr>"; } echo "</table>\n</div>"; echo "<form method=\"post\" action=\"" . $modulelink . "&a=addquickinvoice\"><p align=\"center\"><b>" . $vars['_lang']['quickinvoice'] . "</b> <input type=\"text\" name=\"newinvoice\""; if (!$userid) { echo " disabled value=\"" . $vars['_lang']['associateclienttousefeature'] . "\""; } echo " style=\"width:50%;\" /> @ <input type=\"text\" name=\"newinvoiceamt\" size=\"10\" "; if (!$userid) { echo " disabled "; } echo " /> <input type=\"submit\" id=\"quickcreatebtn\" value=\"" . $vars['_lang']['create'] . "\" ";