function get_all_parties($invoiceID) { if ($invoiceID) { $invoice = new invoice(); $invoice->set_id($invoiceID); $invoice->select(); $interestedPartyOptions = $invoice->get_all_partieS($invoice->get_value("projectID"), $invoice->get_value("clientID")); } if (is_object($this) && $this->get_id()) { $interestedPartyOptions = interestedParty::get_interested_parties("invoiceRepeat", $this->get_id(), $interestedPartyOptions); } return $interestedPartyOptions; }
function attach_invoice($commentID, $entityID, $verbose) { $invoice = new invoice(); $invoice->set_id($entityID); $invoice->select(); $str = $invoice->generate_invoice_file($verbose, true); $rtn["name"] = "invoice_" . $entityID . ".pdf"; $rtn["blob"] = $str; $rtn["size"] = strlen($str); return $rtn; }
} } $timeSheet->set_value("billingNote", rtrim($timeSheet->get_value("billingNote"))); if ($TPL['message'] || $save_error) { // don't save or sql will complain $url = $TPL["url_alloc_timeSheet"]; } else { if (!$timeSheet->get_value("personID") && $timeSheetID) { //if TS ID is set but person ID is not, it's an existing timesheet this // user doesn't have access to (and will overwrite). Don't proceed. $url = $TPL["url_alloc_timeSheet"]; } else { if (!$TPL['message'] && $timeSheet->save()) { if ($add_timeSheet_to_invoiceID) { $invoice = new invoice(); $invoice->set_id($add_timeSheet_to_invoiceID); $invoice->add_timeSheet($timeSheet->get_id()); } if ($_POST["save_and_new"]) { $url = $TPL["url_alloc_timeSheet"]; } else { if ($_POST["save_and_returnToList"]) { $url = $TPL["url_alloc_timeSheetList"]; } else { if ($_POST["save_and_returnToProject"]) { $url = $TPL["url_alloc_project"] . "projectID=" . $timeSheet->get_value("projectID"); } else { $msg = page::htmlentities(urlencode($msg)); $url = $TPL["url_alloc_timeSheet"] . "timeSheetID=" . $timeSheet->get_id() . "&msg=" . $msg . "&dont_send_email=" . $_POST["dont_send_email"]; # Pass the taskID forward if we came from a task $url .= "&taskID=" . $_POST["taskID"];
function get_amount_allocated($fmt = "%s%mo") { // Return total amount used and total amount allocated if (is_object($this) && $this->get_id()) { $db = new db_alloc(); // Get most recent invoiceItem that this time sheet belongs to. $q = prepare("SELECT invoiceID\n FROM invoiceItem\n WHERE invoiceItem.timeSheetID = %d\n ORDER BY invoiceItem.iiDate DESC\n LIMIT 1\n ", $this->get_id()); $db->query($q); $row = $db->row(); $invoiceID = $row["invoiceID"]; if ($invoiceID) { $invoice = new invoice(); $invoice->set_id($invoiceID); $invoice->select(); $maxAmount = page::money($invoice->get_value("currencyTypeID"), $invoice->get_value("maxAmount"), $fmt); // Loop through all the other invoice items on that invoice $q = prepare("SELECT sum(iiAmount) AS totalUsed FROM invoiceItem WHERE invoiceID = %d", $invoiceID); $db->query($q); $row2 = $db->row(); return array(page::money($invoice->get_value("currencyTypeID"), $row2["totalUsed"], $fmt), $maxAmount); } } }
<?php /* * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions * Pty. Ltd. * * This file is part of the allocPSA application <*****@*****.**>. * * allocPSA is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or (at * your option) any later version. * * allocPSA is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public * License for more details. * * You should have received a copy of the GNU Affero General Public License * along with allocPSA. If not, see <http://www.gnu.org/licenses/>. */ require_once "../alloc.php"; if (!$current_user->is_employee()) { alloc_error("You do not have permission to access invoices", true); } $invoiceID = $_POST["invoiceID"] or $invoiceID = $_GET["invoiceID"]; $verbose = $_GET["verbose"]; $invoice = new invoice(); $invoice->set_id($invoiceID); $invoice->select(); $invoice->generate_invoice_file($verbose);
if (is_object($invoice) && $invoice->get_id()) { $q = prepare("SELECT * FROM invoiceRepeat WHERE invoiceID = %d LIMIT 1", $invoice->get_id()); $qid1 = $db->query($q); if ($db->row($qid1)) { $invoiceRepeat->read_db_record($db); $invoiceRepeat->set_values("invoiceRepeat_"); foreach (explode(" ", $TPL["invoiceRepeat_frequency"]) as $id) { if ($id) { $qid2 = $db->query("SELECT * FROM invoice WHERE invoiceRepeatID = %d AND invoiceRepeatDate = '%s'", $invoiceRepeat->get_id(), $id); if ($idrow = $db->row($qid2)) { $links[] = "<a href='" . $TPL["url_alloc_invoice"] . "invoiceID=" . $idrow["invoiceID"] . "'>" . $id . "</a>"; } else { $links[] = $id; } } } $TPL["message_help_no_esc"][] = "This invoice is also a template for the scheduled creation of new invoices on the following dates:\n <br>" . implode(" ", (array) $links) . "\n <br>Click the Repeating Invoice link for more information."; } if ($invoice->get_value("invoiceRepeatID")) { $ir = new invoiceRepeat(); $ir->set_id($invoice->get_value("invoiceRepeatID")); $ir->select(); $i = new invoice(); $i->set_id($ir->get_value("invoiceID")); $i->select(); $TPL["message_help_no_esc"][] = "This invoice was automatically generated by the\n <a href='" . $TPL["url_alloc_invoice"] . "invoiceID=" . $ir->get_value("invoiceID") . "'>\n repeating invoice " . $i->get_value("invoiceNum") . "</a>"; } } $TPL["invoice"] = $invoice; $TPL["invoiceRepeat"] = $invoiceRepeat; include_template("templates/invoiceM.tpl");
function update_invoice_dates($invoiceID) { $db = new db_alloc(); $db->query(prepare("SELECT max(iiDate) AS maxDate, min(iiDate) AS minDate\n FROM invoiceItem\n WHERE invoiceID=%d", $invoiceID)); $db->next_record(); $invoice = new invoice(); $invoice->set_id($invoiceID); $invoice->select(); $invoice->set_value("invoiceDateFrom", $db->f("minDate")); $invoice->set_value("invoiceDateTo", $db->f("maxDate")); return $invoice->save(); }
singleton("errors_thrown", true); singleton("errors_haltdb", false); #$today = $_REQUEST["today"] or $today = date("Y-m-d"); $q = prepare("SELECT invoiceRepeatDate.invoiceRepeatID\n , invoiceRepeatDate.invoiceDate\n , invoiceRepeat.invoiceID AS templateInvoiceID\n , invoiceRepeat.personID AS currentUser\n , invoiceRepeat.message\n , invoice.invoiceID\n FROM invoiceRepeatDate\n LEFT JOIN invoiceRepeat ON invoiceRepeatDate.invoiceRepeatID = invoiceRepeat.invoiceRepeatID\n LEFT JOIN invoice ON invoice.invoiceRepeatID = invoiceRepeatDate.invoiceRepeatID\n AND invoice.invoiceRepeatDate = invoiceRepeatDate.invoiceDate\n WHERE invoice.invoiceID IS NULL\n AND invoiceRepeatDate.invoiceDate <= '%s'", $today); $orig_current_user =& singleton("current_user"); $db = new db_alloc(); $id = $db->query($q); while ($row = $db->row($id)) { if ($row["currentUser"]) { $current_user = new person(); $current_user->load_current_user($row["currentUser"]); singleton("current_user", $current_user); } #echo "<br>Checking row: ".print_r($row,1); $invoice = new invoice(); $invoice->set_id($row["templateInvoiceID"]); $invoice->select(); $i = new invoice(); $i->set_value("invoiceRepeatID", $row["invoiceRepeatID"]); $i->set_value("invoiceRepeatDate", $row["invoiceDate"]); $i->set_value("invoiceNum", invoice::get_next_invoiceNum()); $i->set_value("clientID", $invoice->get_value("clientID")); $i->set_value("projectID", $invoice->get_value("projectID")); $i->set_value("invoiceName", $invoice->get_value("invoiceName")); $i->set_value("invoiceStatus", "edit"); $i->set_value("invoiceDateTo", $row["invoiceDate"]); $i->set_value("currencyTypeID", $invoice->get_value("currencyTypeID")); $i->set_value("maxAmount", $invoice->get_value("maxAmount")); $i->save(); #echo "<br>Created invoice: ".$i->get_id(); $q = prepare("SELECT * FROM invoiceItem WHERE invoiceID = %d", $invoice->get_id());