function is_owner() { $tf = new tf(); $tf->set_id($this->get_value("tfID")); $tf->select(); return $tf->is_owner(); }
function add_inactive_tf($tfID, $options) { // add a tf to the array of options, if it's not already there global $TPL; if ($tfID && !array_key_exists($tfID, $options)) { $tf = new tf(); $tf->set_id($tfID); $tf->select(); $options[$tfID] = $tf->get_value("tfName"); } return $options; }
function add_tf($tfID, $options, $warningKey, $warningValue) { // add a tf to the array of options, if it's not already there global $TPL; if ($tfID && !array_key_exists($tfID, $options)) { $tf = new tf(); $tf->set_id($tfID); $tf->select(); $options[$tfID] = $tf->get_value("tfName"); $TPL[$warningKey] = sprintf($warningValue, $tf->get_value("tfName")); } return $options; }
function show_all_exp($template) { global $TPL; global $expenseForm; global $db; global $transaction_to_edit; if ($expenseForm->get_id()) { if ($_POST["transactionID"] && ($_POST["edit"] || is_object($transaction_to_edit) && $transaction_to_edit->get_id())) { // if edit is clicked OR if we've rejected changes made to something so are still editing it $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d AND transactionID<>%d ORDER BY transactionID DESC", $expenseForm->get_id(), $_POST["transactionID"]); } else { $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d ORDER BY transactionID DESC", $expenseForm->get_id()); } $db->query($query); while ($db->next_record()) { $transaction = new transaction(); $transaction->read_db_record($db); $transaction->set_values(); $transaction->get_value("quantity") and $TPL["amount"] = $transaction->get_value("amount") / $transaction->get_value("quantity"); $TPL["lineTotal"] = $TPL["amount"] * $transaction->get_value("quantity"); $tf = new tf(); $tf->set_id($transaction->get_value("fromTfID")); $tf->select(); $TPL["fromTfIDLink"] = $tf->get_link(); $tf = new tf(); $tf->set_id($transaction->get_value("tfID")); $tf->select(); $TPL["tfIDLink"] = $tf->get_link(); $projectID = $transaction->get_value("projectID"); if ($projectID) { $project = new project(); $project->set_id($transaction->get_value("projectID")); $project->select(); $TPL["projectName"] = $project->get_value("projectName"); } if ($transaction->get_value("fromTfID") == config::get_config_item("expenseFormTfID")) { $TPL['expense_class'] = "loud"; } else { $TPL['expense_class'] = ""; } include_template($template); } } }
} else { if (have_entity_perm("tf", PERM_READ, $current_user, true)) { // Person can only read TF records that they own $q = prepare("SELECT tf.tfID AS value, tf.tfName AS label\n FROM tf, tfPerson \n WHERE tfPerson.personID=%d \n AND tf.tfID=tfPerson.tfID \n AND (tf.tfActive = 1 OR tf.tfID = %d OR tf.tfID = %d)\n ORDER BY tfName", $current_user->get_id(), $transactionRepeat->get_value("tfID"), $transactionRepeat->get_value("fromTfID")); } else { alloc_error("No permissions to generate TF list"); } } //special case for disabled TF. Include it in the list, but also add a warning message. $tf = new tf(); $tf->set_id($transactionRepeat->get_value("tfID")); if ($tf->select() && !$tf->get_value("tfActive")) { $TPL["message_help"][] = "This expense is allocated to an inactive TF. It will not create transactions."; } $tf = new tf(); $tf->set_id($transactionRepeat->get_value("fromTfID")); if ($tf->select() && !$tf->get_value("tfActive")) { $TPL["message_help"][] = "This expense is sourced from an inactive TF. It will not create transactions."; } $m = new meta("currencyType"); $currencyOps = $m->get_assoc_array("currencyTypeID", "currencyTypeID"); $TPL["currencyTypeOptions"] = page::select_options($currencyOps, $transactionRepeat->get_value("currencyTypeID")); $TPL["tfOptions"] = page::select_options($q, $transactionRepeat->get_value("tfID")); $TPL["fromTfOptions"] = page::select_options($q, $transactionRepeat->get_value("fromTfID")); $TPL["basisOptions"] = page::select_options(array("weekly" => "weekly", "fortnightly" => "fortnightly", "monthly" => "monthly", "quarterly" => "quarterly", "yearly" => "yearly"), $transactionRepeat->get_value("paymentBasis")); $TPL["transactionTypeOptions"] = page::select_options(transaction::get_transactionTypes(), $transactionRepeat->get_value("transactionType")); if (is_object($transactionRepeat) && $transactionRepeat->get_id() && $current_user->have_role("admin")) { $TPL["adminButtons"] .= ' <select name="changeTransactionStatus"><option value="">Transaction Status<option value="approved">Approve<option value="rejected">Reject<option value="pending">Pending</select> '; }
$not_quoted = count($TPL["taskListRows"]) - $count_quoted_tasks; $not_quoted and $TPL["count_not_quoted_tasks"] = "(" . sprintf("%d", $not_quoted) . " tasks not included in estimate)"; } $TPL["invoice_links"] .= "<a href=\"" . $TPL["url_alloc_invoice"] . "clientID=" . $clientID . "&projectID=" . $project->get_id() . "\">New Invoice</a>"; } $TPL["navigation_links"] = $project->get_navigation_links(); $query = prepare("SELECT tfID AS value, tfName AS label \n FROM tf \n WHERE tfActive = 1\n ORDER BY tfName"); $TPL["commission_tf_options"] = page::select_options($query, $TPL["commission_tfID"]); $TPL["cost_centre_tfID_options"] = page::select_options($query, $TPL["project_cost_centre_tfID"]); $db->query($query); while ($db->row()) { $tf_array[$db->f("value")] = $db->f("label"); } if ($TPL["project_cost_centre_tfID"]) { $tf = new tf(); $tf->set_id($TPL["project_cost_centre_tfID"]); $tf->select(); $TPL["cost_centre_tfID_label"] = $tf->get_link(); } $query = prepare("SELECT roleName,roleID FROM role WHERE roleLevel = 'project' ORDER BY roleSequence"); $db->query($query); #$project_person_role_array[] = ""; while ($db->next_record()) { $project_person_role_array[$db->f("roleID")] = $db->f("roleName"); } $email_type_array = array("None" => "None", "Assigned Tasks" => "Assigned Tasks", "All Tasks" => "All Tasks"); $t = new meta("currencyType"); $currency_array = $t->get_assoc_array("currencyTypeID", "currencyTypeID"); $projectType_array = project::get_project_type_array(); $m = new meta("projectStatus"); $projectStatus_array = $m->get_assoc_array("projectStatusID", "projectStatusID");
} } else { if ($_POST["delete"]) { $person->delete(); alloc_redirect($TPL["url_alloc_personList"]); } } #$person = new person(); #$person->set_id($personID); #$person->select(); $person->set_values("person_"); if ($person->get_id()) { $q = prepare("SELECT tfPerson.tfID AS value, tf.tfName AS label \n FROM tf, tfPerson \n \t\t\t\t WHERE tf.tfID = tfPerson.tfID \n AND tfPerson.personID = %d \n AND (tf.tfActive = 1 OR tf.tfID = %d)", $person->get_id(), $person->get_value("preferred_tfID")); $TPL["preferred_tfID_options"] = page::select_options($q, $person->get_value("preferred_tfID")); $tf = new tf(); $tf->set_id($person->get_value("preferred_tfID")); $tf->select(); } $TPL["absence_url"] = $TPL["url_alloc_absence"] . "personID=" . $personID; $TPL["personActive"] = !$person->get_id() || $person->get_value("personActive") ? " checked" : ""; if (has("time")) { $timeUnit = new timeUnit(); $rate_type_array = $timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelB"); } $TPL["timeSheetRateUnit_select"] = page::select_options($rate_type_array, $person->get_value("defaultTimeSheetRateUnitID")); $TPL["timeSheetRateUnit_label"] = $rate_type_array[$person->get_value("defaultTimeSheetRateUnitID")]; if ($personID) { $TPL["main_alloc_title"] = "Person Details: " . $person->get_value("username") . " - " . APPLICATION_NAME; } else { $TPL["main_alloc_title"] = "New Person - " . APPLICATION_NAME; }
} $defaults = array("url_form_action" => $TPL["url_alloc_transactionList"], "form_name" => "transactionList_filter", "applyFilter" => $applyFilter, "tfID" => $tfID, "startDate" => $startDate, "endDate" => $endDate, "monthDate" => $monthDate); if ($download) { $_FORM = transaction::load_form_data($defaults); $rtn = transaction::get_list($_FORM); $totals = $rtn["totals"]; $rows = $rtn["rows"]; $csv = transaction::arr_to_csv($rows); header('Content-Type: application/octet-stream'); header("Content-Length: " . strlen($csv)); header('Content-Disposition: attachment; filename="' . date("Ymd_His") . '.csv"'); echo $csv; exit; } // Check perm of requested tf $tf = new tf(); $tf->set_id($tfID); $tf->select(); $TPL["tfID"] = $tfID; $_FORM = transaction::load_form_data($defaults); $rtn = transaction::get_list($_FORM); $TPL["totals"] = $rtn["totals"]; $TPL["transactionListRows"] = $rtn["rows"]; // Total balance $TPL["balance"] = $tf->get_balance(); // Total balance pending $TPL["pending_amount"] = $tf->get_balance(array("status" => "pending")); // Page and header title $TPL["title"] = "Statement for tagged fund: " . $tf->get_value("tfName"); $TPL["main_alloc_title"] = "TF: " . $tf->get_value("tfName") . " - " . APPLICATION_NAME; include_template("templates/transactionListM.tpl");
# } # $commar = "<br>"; # } # } $TPL["field_invoiceNum"] = '<input type="text" name="invoiceNum" value="' . $TPL["invoiceNum"] . '">'; $TPL["field_invoiceName"] = '<input type="text" name="invoiceName" value="' . $TPL["invoiceName"] . '">'; $TPL["field_maxAmount"] = '<input type="text" name="maxAmount" size="10" value="' . $invoice->get_value("maxAmount", DST_HTML_DISPLAY) . '"> '; $TPL["field_maxAmount"] .= page::help('invoice_maxAmount'); $TPL["field_invoiceDateFrom"] = page::calendar("invoiceDateFrom", $TPL["invoiceDateFrom"]); $TPL["field_invoiceDateTo"] = page::calendar("invoiceDateTo", $TPL["invoiceDateTo"]); $clientID = $invoice->get_value("clientID") or $clientID = $_GET["clientID"]; $projectID = $invoice->get_value("projectID") or $projectID = $_GET["projectID"]; list($client_select, $client_link, $project_select, $project_link) = client::get_client_and_project_dropdowns_and_links($clientID, $projectID); $tf = new tf(); if ($invoice->get_value("tfID")) { $tf->set_id($invoice->get_value("tfID")); $tf->select(); $tf_link = $tf->get_link(); $tf_sel = $invoice->get_value("tfID"); } $tf_sel or $tf_sel = config::get_config_item("mainTfID"); $tf_select = "<select id='tfID' name='tfID'>" . page::select_options($tf->get_assoc_array("tfID", "tfName"), $tf_sel) . "</select>"; // Main invoice buttons if ($current_user->have_role('admin')) { if (!$invoiceID) { $_GET["clientID"] and $TPL["clientID"] = $_GET["clientID"]; $TPL["invoice_buttons"] = ' <button type="submit" name="save" value="1" class="save_button">Create Invoice<i class="icon-ok-sign"></i></button> '; $TPL["field_clientID"] = $client_select; $TPL["field_projectID"] = $project_select;
define("CAN_APPROVE_TRANSACTIONS", 1); } else { define("CAN_APPROVE_TRANSACTIONS", 0); } $statuses = productSale::get_statii(); $statuses[$TPL["status"]] = "<b>" . $statuses[$TPL["status"]] . "</b>"; $TPL["statusText"] = implode(" | ", $statuses); $TPL["productSaleID"] = $productSale->get_id(); $showCosts = $_POST["showCosts"] or $_showCosts = $_GET["showCosts"]; $productSale->set_values(); list($client_select, $client_link, $project_select, $project_link) = client::get_client_and_project_dropdowns_and_links($clientID, $projectID); $TPL["show_client_options"] = $client_link; $TPL["show_project_options"] = $project_link; $tf = new tf(); if ($productSale->get_value("tfID")) { $tf->set_id($productSale->get_value("tfID")); $tf->select(); $TPL["show_tf_options"] = $tf->get_link(); $tf_sel = $productSale->get_value("tfID"); } $tf_sel or $tf_sel = config::get_config_item("mainTfID"); $tf_select = "<select name='tfID'>" . page::select_options($tflist, $tf_sel) . "</select>"; $TPL["show_person_options"] = person::get_fullname($productSale->get_value("personID")); $TPL["show_date"] = $productSale->get_value("productSaleDate"); $TPL["show_extRef"] = $productSale->get_value("extRef"); $TPL["show_extRefDate"] = $productSale->get_value("extRefDate"); if (!$productSale->get_id() || $productSale->get_value("status") != "finished" && !($productSale->get_value("status") == "admin" && !CAN_APPROVE_TRANSACTIONS)) { $TPL["show_client_options"] = $client_select; $TPL["show_project_options"] = $project_select; $TPL["show_tf_options"] = $tf_select; $personID = $productSale->get_value("personID") or $personID = $current_user->get_id();
function is_owner($person = "") { $current_user =& singleton("current_user"); if ($person == "") { $person = $current_user; } if ($this->get_value("expenseFormID")) { $expenseForm = $this->get_foreign_object("expenseForm"); return $expenseForm->is_owner($person); } if ($this->get_value("timeSheetID")) { $timeSheet = $this->get_foreign_object("timeSheet"); return $timeSheet->is_owner($person); } if ($this->get_value("productSaleItemID")) { $productSaleItem = $this->get_foreign_object("productSaleItem"); return $productSaleItem->is_owner(); } $toTf = new tf(); $toTf->set_id($this->get_value('tfID')); $toTf->select(); $fromTf = new tf(); $fromTf->set_id($this->get_value('fromTfID')); $fromTf->select(); return $toTf->is_owner($person) || $fromTf->is_owner($person); }