Пример #1
0
 function is_owner()
 {
     $tf = new tf();
     $tf->set_id($this->get_value("tfID"));
     $tf->select();
     return $tf->is_owner();
 }
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
function show_expenseFormList($template_name)
{
    global $db;
    global $TPL;
    global $transactionRepeat;
    $current_user =& singleton("current_user");
    $db = new db_alloc();
    $transactionRepeat = new transactionRepeat();
    if (!$_GET["tfID"] && !$current_user->have_role("admin")) {
        $tfIDs = $current_user->get_tfIDs();
        $tfIDs and $sql = prepare("WHERE tfID in (%s)", $tfIDs);
    } else {
        if ($_GET["tfID"]) {
            $sql = prepare("WHERE tfID = %d", $_GET["tfID"]);
        }
    }
    $db->query("select * FROM transactionRepeat " . $sql);
    while ($db->next_record()) {
        $i++;
        $transactionRepeat->read_db_record($db);
        $transactionRepeat->set_values();
        $TPL["tfName"] = tf::get_name($transactionRepeat->get_value("tfID"));
        $TPL["fromTfName"] = tf::get_name($transactionRepeat->get_value("fromTfID"));
        include_template($template_name);
    }
    $TPL["tfID"] = $tfID;
}
Пример #5
0
 function render()
 {
     global $TPL;
     $ops["owner"] = 1;
     $TPL["tfListRows"] = tf::get_list($ops);
     if ($TPL["tfListRows"]) {
         return true;
     }
 }
Пример #6
0
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);
        }
    }
}
Пример #7
0
 * 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";
$current_user->check_employee();
if ($_REQUEST["owner"]) {
    $TPL["owner_checked"] = " checked";
} else {
    $TPL["owner_checked"] = "";
}
if ($_REQUEST["showall"]) {
    $TPL["showall_checked"] = " checked";
}
$TPL["main_alloc_title"] = "TF List - " . APPLICATION_NAME;
$TPL["tfListRows"] = tf::get_list($_REQUEST);
include_template("templates/tfListM.tpl");
Пример #8
0
function show_new_person($template)
{
    global $TPL;
    $TPL["person_buttons"] = '
        <button type="submit" name="person_save" value="1" class="save_button">Add<i class="icon-plus-sign"></i></button>';
    $tfPerson = new tfPerson();
    $tfPerson->set_values("person_");
    include_template($template);
}
function show_person_options()
{
    global $TPL;
    echo page::select_options(person::get_username_list($TPL["person_personID"]), $TPL["person_personID"]);
}
$db = new db_alloc();
$tf = new tf();
$tfID = $_GET["tfID"] or $tfID = $_POST["tfID"];
if ($tfID) {
    $tf->set_id($tfID);
    $tf->select();
} else {
    $tf_is_new = true;
}
if ($_POST["save"]) {
    $tf->read_globals();
    if ($_POST["isActive"]) {
        $tf->set_value("tfActive", 1);
    } else {
        $tf->set_value("tfActive", 0);
    }
    if ($tf->get_value("tfName") == "") {
Пример #9
0
    $q = prepare("SELECT tfID AS value, tfName AS label \n                  FROM tf \n                 WHERE tfActive = 1 \n                    OR tf.tfID = %d \n                    OR tf.tfID = %d \n              ORDER BY tfName", $transactionRepeat->get_value("tfID"), $transactionRepeat->get_value("fromTfID"));
} 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>
  ';
Пример #10
0
 if ($_POST["field_quotes"] == "double") {
     $quotes = "\"";
 }
 while ($db->next_record()) {
     $odd_even = $odd_even == "even" ? "odd" : "even";
     $TPL["result_row"] .= sprintf($start_row_separator, $odd_even);
     foreach ($fields as $k => $field) {
         $field = end(explode(".", $field));
         if (stripos("ModifiedUser", $field) !== FALSE || stripos("personID", $field) !== FALSE) {
             $person = new person();
             $person->set_id($db->f($field));
             $person->select();
             $result = $person->get_name(array("format" => "nick"));
         } else {
             if (stripos("tfID", $field) !== FALSE) {
                 $result = tf::get_name($db->f($field));
             } else {
                 $result = $db->f($field);
             }
         }
         $TPL["result_row"] .= $start_field_separator;
         $TPL["result_row"] .= $quotes . $result . $quotes;
         if (isset($fields[$k + 1]) || !$_POST["generate_file"]) {
             $TPL["result_row"] .= $end_field_separator;
         }
     }
     $TPL["result_row"] .= $end_row_separator;
     $counter++;
 }
 $TPL["counter"] = "Number of rows(s): " . $counter;
 if ($_POST["generate_file"]) {
Пример #11
0
{
    global $tflist;
    $temp = $tflist;
    foreach ($remove_these as $dud) {
        unset($temp[$dud]);
    }
    echo page::select_options($temp, $selected);
    return;
}
$productID = $_GET["productID"] or $productID = $_POST["productID"];
$product = new product();
if ($productID) {
    $product->set_id($productID);
    $product->select();
}
$tf = new tf();
$tflist = $tf->get_assoc_array("tfID", "tfName");
$extra_options = array("-1" => "META: Project TF", "-2" => "META: Salesperson TF", config::get_config_item("mainTfID") => "Main Finance TF (" . tf::get_name(config::get_config_item("mainTfID")) . ")", config::get_config_item("outTfID") => "Outgoing Funds TF (" . tf::get_name(config::get_config_item("outTfID")) . ")", config::get_config_item("inTfID") => "Incoming Funds TF (" . tf::get_name(config::get_config_item("inTfID")) . ")");
// Prepend the META options to the tflist.
$tflist = $extra_options + $tflist;
$TPL["companyTF"] = $tflist[config::get_config_item("mainTfID")];
$TPL["taxTF"] = $tflist[config::get_config_item("taxTfID")];
$taxRate = config::get_config_item("taxPercent") / 100.0;
$TPL["taxRate"] = $taxRate;
if ($_POST["save"]) {
    $product->read_globals();
    $product->set_value("productActive", isset($_POST["productActive"]) ? 1 : 0);
    !$product->get_value("productName") and alloc_error("Please enter a Product Name.");
    !$product->get_value("sellPrice") and alloc_error("Please enter a Sell Price.");
    if (!$TPL["message"]) {
        $product->save();
Пример #12
0
 } else {
     $mostRecentTransactionDate = format_date("U", $dbMaxDate->f("latestDate"));
     $nextScheduled = timeWarp($mostRecentTransactionDate, $timeBasisString);
 }
 echo "<br>Attempting repeating transaction: " . $transactionRepeat->get_value("product") . " ... ";
 //echo '<br><br>$nextScheduled <= $today && $nextScheduled >= $startDate && $nextScheduled <= $finishDate';
 //echo "<br>".$nextScheduled." <= ".$today." && ".$nextScheduled." >= ".$startDate." && ".$nextScheduled." <= ".$finishDate;
 while ($nextScheduled <= $today && $nextScheduled >= $startDate && $nextScheduled <= $finishDate) {
     $tf = new tf();
     $tf->set_id($transactionRepeat->get_value("tfID"));
     $tf->select();
     if (!$tf->get_value("tfActive")) {
         echo "<br>Skipping because tf not active: " . $tf->get_value("tfName");
         continue 2;
     }
     $tf = new tf();
     $tf->set_id($transactionRepeat->get_value("fromTfID"));
     $tf->select();
     if (!$tf->get_value("tfActive")) {
         echo "<br>Skipping because tf not active: " . $tf->get_value("tfName");
         continue 2;
     }
     $amount = page::money_out($transactionRepeat->get_value("currencyTypeID"), $transactionRepeat->get_value("amount"));
     $transaction = new transaction();
     $transaction->set_value("fromTfID", $transactionRepeat->get_value("fromTfID"));
     $transaction->set_value("tfID", $transactionRepeat->get_value("tfID"));
     $transaction->set_value("companyDetails", $transactionRepeat->get_value("companyDetails"));
     $transaction->set_value("amount", $amount);
     $transaction->set_value("currencyTypeID", $transactionRepeat->get_value("currencyTypeID"));
     $transaction->set_value("product", $transactionRepeat->get_value("product"));
     $transaction->set_value("transactionType", $transactionRepeat->get_value("transactionType"));
Пример #13
0
}
if ($productSale->have_perm(PERM_APPROVE_PRODUCT_TRANSACTIONS)) {
    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("&nbsp;&nbsp;|&nbsp;&nbsp;", $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;
Пример #14
0
 /**
  * Convert a tf from its name to its tf ID
  * @param mixed $name a tf name
  * @return integer the tf's ID
  */
 public function get_tfID($options)
 {
     return tf::get_tfID($options);
 }
Пример #15
0
/*
 * 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/>.
*/
define("NO_REDIRECT", 1);
require_once "../alloc.php";
if ($_GET["projectID"]) {
    usleep(300000);
    $project = new project();
    $project->set_id($_GET["projectID"]);
    $project->select();
    $tf_sel = $project->get_value("cost_centre_tfID") or $tf_sel = config::get_config_item("mainTfID");
    $tf = new tf();
    $options = page::select_options($tf->get_assoc_array("tfID", "tfName"), $tf_sel);
    echo "<select id=\"tfID\" name=\"tfID\">" . $options . "</select>";
}
Пример #16
0
        $TPL["count_incomplete_tasks"] = count($TPL["taskListRows"]);
        $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");
Пример #17
0
 function update_search_index_doc(&$index)
 {
     $p =& get_cached_table("person");
     $personID = $this->get_value("personID");
     $person_field = $personID . " " . $p[$personID]["username"] . " " . $p[$personID]["name"];
     $managerID = $this->get_value("approvedByManagerPersonID");
     $manager_field = $managerID . " " . $p[$managerID]["username"] . " " . $p[$managerID]["name"];
     $adminID = $this->get_value("approvedByAdminPersonID");
     $admin_field = $adminID . " " . $p[$adminID]["username"] . " " . $p[$adminID]["name"];
     $tf_field = $this->get_value("recipient_tfID") . " " . tf::get_name($this->get_value("recipient_tfID"));
     if ($this->get_value("projectID")) {
         $project = new project();
         $project->set_id($this->get_value("projectID"));
         $project->select();
         $projectName = $project->get_name();
         $projectShortName = $project->get_name(array("showShortProjectLink" => true));
         $projectShortName && $projectShortName != $projectName and $projectName .= " " . $projectShortName;
     }
     $q = prepare("SELECT dateTimeSheetItem, taskID, description, comment, commentPrivate \n                    FROM timeSheetItem \n                   WHERE timeSheetID = %d \n                ORDER BY dateTimeSheetItem ASC", $this->get_id());
     $db = new db_alloc();
     $db->query($q);
     while ($r = $db->row()) {
         $desc .= $br . $r["dateTimeSheetItem"] . " " . $r["taskID"] . " " . $r["description"] . "\n";
         $r["comment"] && $r["commentPrivate"] or $desc .= $r["comment"] . "\n";
         $br = "\n";
     }
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->get_id()));
     $doc->addField(Zend_Search_Lucene_Field::Text('project', $projectName, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('pid', $this->get_value("projectID"), "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('creator', $person_field, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('desc', $desc, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('status', $this->get_value("status"), "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('tf', $tf_field, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('manager', $manager_field, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('admin', $admin_field, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('dateManager', str_replace("-", "", $this->get_value("dateSubmittedToManager")), "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('dateAdmin', str_replace("-", "", $this->get_value("dateSubmittedToAdmin")), "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('dateFrom', str_replace("-", "", $this->get_value("dateFrom")), "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('dateTo', str_replace("-", "", $this->get_value("dateTo")), "utf-8"));
     $index->addDocument($doc);
 }
Пример #18
0
function show_invoiceItem_list()
{
    global $invoiceID;
    global $TPL;
    global $invoice;
    $current_user =& singleton("current_user");
    $template = "templates/invoiceItemListR.tpl";
    $db = new db_alloc();
    $db2 = new db_alloc();
    $q = prepare("SELECT *\n                  FROM invoiceItem \n                 WHERE invoiceItem.invoiceID = %d \n              ORDER BY iiDate,invoiceItem.invoiceItemID", $invoiceID);
    $db->query($q);
    while ($db->next_record()) {
        $invoiceItem = new invoiceItem();
        $invoiceItem->currency = $invoice->get_value("currencyTypeID");
        if (!$invoiceItem->read_db_record($db)) {
            continue;
        }
        $invoiceItem->set_tpl_values("invoiceItem_");
        unset($transaction_sum);
        unset($transaction_info);
        unset($transaction_statii);
        unset($one_approved);
        unset($one_rejected);
        unset($one_pending);
        unset($br);
        unset($sel);
        unset($amount);
        unset($TPL["invoiceItem_buttons_top"], $TPL["invoiceItem_buttons"], $TPL["transaction_info"], $TPL["status_label"]);
        // If editing a invoiceItem then don't display it in the list
        if (is_array($_POST["invoiceItem_edit"]) && key($_POST["invoiceItem_edit"]) == $invoiceItem->get_id()) {
            continue;
        }
        $q = prepare("SELECT *\n                       , transaction.amount * pow(10,-currencyType.numberToBasic) AS transaction_amount\n                       , transaction.tfID AS transaction_tfID\n                       , transaction.fromTfID AS transaction_fromTfID\n                       , transaction.status AS transaction_status  \n                       , transaction.currencyTypeID\n                    FROM transaction \n               LEFT JOIN currencyType on transaction.currencyTypeID = currencyType.currencyTypeID\n                   WHERE transaction.invoiceItemID = %d", $invoiceItem->get_id());
        $db2->query($q);
        while ($db2->next_record()) {
            $transaction = new transaction();
            if (!$transaction->read_db_record($db2)) {
                $other_peoples_transactions .= "<br>Tansaction access denied for transaction #" . $db2->f("transactionID");
                continue;
            }
            if ($db2->f("transaction_status") == "approved") {
                $one_approved = true;
            }
            if ($db2->f("transaction_status") == "rejected") {
                $one_rejected = true;
            }
            if ($db2->f("transaction_status") == "pending") {
                $one_pending = true;
            }
            $amounts[$invoiceItem->get_id()] += $db2->f("transaction_amount");
            $db2->f("transaction_status") != "rejected" and $transaction_sum += $db2->f("transaction_amount");
            $transaction_info .= $br . ucwords($db2->f("transaction_status")) . " Transaction ";
            $transaction_info .= "<a href=\"" . $TPL["url_alloc_transaction"] . "transactionID=" . $db2->f("transactionID") . "\">#" . $db2->f("transactionID") . "</a>";
            $transaction_info .= " from ";
            $transaction_info .= "<a href=\"" . $TPL["url_alloc_transactionList"] . "tfID=" . $db2->f("transaction_fromTfID") . "\">" . tf::get_name($db2->f("transaction_fromTfID")) . "</a>";
            $transaction_info .= " to <a href=\"" . $TPL["url_alloc_transactionList"] . "tfID=" . $db2->f("transaction_tfID") . "\">" . tf::get_name($db2->f("transaction_tfID")) . "</a>";
            $transaction_info .= " for <b>" . page::money($db2->f("currencyTypeID"), $db2->f("transaction_amount"), "%s%m") . "</b>";
            $br = "<br>";
        }
        $TPL["transaction_info"] = $transaction_info;
        $TPL["transaction_info"] .= $other_peoples_transactions;
        // Sets the background colour of the invoice item boxes based on transaction.status
        if (!$one_rejected && !$one_pending && $one_approved) {
            $TPL["box_class"] = " approved";
            $transaction_status = "approved";
        } else {
            if ($one_rejected) {
                $TPL["box_class"] = " rejected";
                $transaction_status = "rejected";
            } else {
                if ($one_pending) {
                    $transaction_status = "pending";
                    $TPL["box_class"] = " warn";
                } else {
                    $TPL["box_class"] = " pending";
                    $transaction_status = "";
                }
            }
        }
        $sel[$transaction_status] = " checked";
        if ($sel["rejected"]) {
            $TPL["status_label"] = "<b>[Not Going To Be Paid]</b>";
        } else {
            if ($sel["pending"]) {
                $TPL["status_label"] = "<b>[Pending]</b>";
            } else {
                if ($sel["approved"]) {
                    $TPL["status_label"] = "<b>[Paid]</b>";
                }
            }
        }
        if ($transaction_sum > 0 && $transaction_sum < $invoiceItem->get_value("iiAmount", DST_HTML_DISPLAY)) {
            $TPL["status_label"] = "<b>[Paid in part]</b>";
            $TPL["box_class"] = " warn";
        } else {
            if ($transaction_sum > $invoiceItem->get_value("iiAmount")) {
                $TPL["status_label"] = "<b>[Overpaid]</b>";
            }
        }
        $TPL["status_label"] or $TPL["status_label"] = "<b>[No Transactions Created]</b>";
        if ($invoice->get_value("invoiceStatus") == "reconcile") {
            if ($amounts[$invoiceItem->get_id()] === null) {
                $amount = $invoiceItem->get_value("iiAmount", DST_HTML_DISPLAY);
                if (config::get_config_item("taxPercent") && $invoiceItem->get_value("iiTax") == 0) {
                    $amount = page::money($invoice->get_value("currencyTypeID"), $amount * (config::get_config_item("taxPercent") / 100 + 1), "%m");
                }
            } else {
                $amount = page::money($invoice->get_value("currencyTypeID"), $amounts[$invoiceItem->get_id()], "%m");
            }
            $selected_tfID = $db2->f("transaction_tfID");
            if (!$selected_tfID && $invoiceItem->get_value("timeSheetID")) {
                $timeSheet = $invoiceItem->get_foreign_object("timeSheet");
                $project = $timeSheet->get_foreign_object("project");
                $selected_tfID = $project->get_value("cost_centre_tfID");
            } else {
                if (!$selected_tfID && $invoiceItem->get_value("transactionID")) {
                    $transaction = $invoiceItem->get_foreign_object("transaction");
                    $project = $transaction->get_foreign_object("project");
                    $selected_tfID = $project->get_value("cost_centre_tfID");
                    $selected_tfID or $selected_tfID = $transaction->get_value("tfID");
                }
            }
            $selected_tfID or $selected_tfID = config::get_config_item("mainTfID");
            #$tf_options = page::select_options($tf_array, $selected_tfID);
            #$tf_options = "<select name=\"invoiceItemAmountPaidTfID[".$invoiceItem->get_id()."]\">".$tf_options."</select>";
            #$TPL["invoiceItem_buttons"] = "<input size=\"8\" type=\"text\" id=\"ap_".$invoiceItem->get_id()."\" name=\"invoiceItemAmountPaid[".$invoiceItem->get_id()."]\" value=\"".$amount."\">";
            #$TPL["invoiceItem_buttons"].= $tf_options;
            unset($radio_buttons);
            if ($current_user->have_role('admin')) {
                $radio_buttons = "<label class='radio corner' for=\"invoiceItemStatus_rejected_" . $invoiceItem->get_id() . "\">Not Going To Be Paid";
                $radio_buttons .= "<input type=\"radio\" id=\"invoiceItemStatus_rejected_" . $invoiceItem->get_id() . "\" name=\"invoiceItemStatus[" . $invoiceItem->get_id() . "]\"";
                $radio_buttons .= " value=\"rejected\"" . $sel["rejected"] . ">";
                $radio_buttons .= "</label>";
                $radio_buttons .= "&nbsp;&nbsp;";
                $radio_buttons .= "<label class='radio corner' for=\"invoiceItemStatus_pending_" . $invoiceItem->get_id() . "\">Pending";
                $radio_buttons .= "<input type=\"radio\" id=\"invoiceItemStatus_pending_" . $invoiceItem->get_id() . "\" name=\"invoiceItemStatus[" . $invoiceItem->get_id() . "]\"";
                $radio_buttons .= " value=\"pending\"" . $sel["pending"] . ">";
                $radio_buttons .= "</label>";
                $radio_buttons .= "&nbsp;&nbsp;";
                $radio_buttons .= "<label class='radio corner' for=\"invoiceItemStatus_approved_" . $invoiceItem->get_id() . "\">Paid";
                $radio_buttons .= "<input type=\"radio\" id=\"invoiceItemStatus_approved_" . $invoiceItem->get_id() . "\" name=\"invoiceItemStatus[" . $invoiceItem->get_id() . "]\"";
                $radio_buttons .= " value=\"approved\"" . $sel["approved"] . ">";
                $radio_buttons .= "</label>";
                $TPL["invoiceItem_buttons_top"] = $radio_buttons;
                $TPL["invoiceItem_buttons_top"] .= "&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"text\" size=\"7\" name=\"invoiceItemAmountPaid[" . $invoiceItem->get_id() . "]\" value=\"" . $amount . "\">";
                $TPL["invoiceItem_buttons_top"] .= "<input type=\"hidden\" name=\"invoiceItemAmountPaidTfID[" . $invoiceItem->get_id() . "]\" value=\"" . $selected_tfID . "\">";
            }
            unset($TPL["invoiceItem_buttons"]);
        } else {
            if ($invoice->get_value("invoiceStatus") == "finished") {
            } else {
                if (is_object($invoice) && $invoice->get_value("invoiceStatus") == "edit") {
                    $TPL["invoiceItem_buttons"] = '
        <button type="submit" name="invoiceItem_delete[' . $invoiceItem->get_id() . ']" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
        <button type="submit" name="invoiceItem_edit[' . $invoiceItem->get_id() . ']" value="1">Edit<i class="icon-edit"></i></button>
      ';
                }
            }
        }
        if ($invoiceItem->get_value("timeSheetID")) {
            $t = new timeSheet();
            $t->set_id($invoiceItem->get_value("timeSheetID"));
            $t->select();
            $t->load_pay_info();
            $amount = $t->pay_info["total_customerBilledDollars"] or $amount = $t->pay_info["total_dollars"];
            $TPL["invoiceItem_iiMemo"] = "<a href=\"" . $TPL["url_alloc_timeSheet"] . "timeSheetID=" . $invoiceItem->get_value("timeSheetID") . "\">" . $invoiceItem->get_value("iiMemo") . " (Currently: \$" . $amount . ", Status: " . $t->get_timeSheet_status() . ")</a>";
        } else {
            if ($invoiceItem->get_value("expenseFormID")) {
                $ep = $invoiceItem->get_foreign_object("expenseForm");
                $total = $ep->get_abs_sum_transactions();
                $TPL["invoiceItem_iiMemo"] = "<a href=\"" . $TPL["url_alloc_expenseForm"] . "expenseFormID=" . $invoiceItem->get_value("expenseFormID") . "\">" . $invoiceItem->get_value("iiMemo") . " (Currently: " . page::money(config::get_config_item("currency"), $total, "%s%m %c") . ", Status: " . $ep->get_status() . ")</a>";
            }
        }
        $TPL["currency"] = $invoice->get_value("currencyTypeID");
        include_template($template);
    }
}
Пример #19
0
function show_new_transaction($template)
{
    global $timeSheet;
    global $TPL;
    global $db;
    global $percent_array;
    if ($timeSheet->get_value("status") == "invoiced" && $timeSheet->have_perm(PERM_TIME_INVOICE_TIMESHEETS)) {
        $tf = new tf();
        $options = $tf->get_assoc_array("tfID", "tfName");
        $TPL["tf_options"] = page::select_options($options, $none);
        $transactionType_options = transaction::get_transactionTypes();
        $TPL["transactionType_options"] = page::select_options($transactionType_options);
        $status_options = array("pending" => "Pending", "approved" => "Approved", "rejected" => "Rejected");
        $TPL["status_options"] = page::select_options($status_options);
        $TPL["transaction_timeSheetID"] = $timeSheet->get_id();
        $TPL["transaction_transactionDate"] = date("Y-m-d");
        $TPL["transaction_product"] = "";
        $TPL["transaction_buttons"] = '
            <button type="submit" name="transaction_save" value="1" class="save_button">Add<i class="icon-plus-sign"></i></button>
      ';
        $TPL["percent_dropdown"] = page::select_options($percent_array, $empty);
        include_template($template);
    }
}
Пример #20
0
}
$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");
Пример #21
0
        alloc_redirect($TPL["url_alloc_personList"]);
    }
} 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;
Пример #22
0
 public static function get_list($_FORM = array())
 {
     $current_user =& singleton("current_user");
     list($filter1, $filter2) = tf::get_list_filter($_FORM);
     if (is_array($filter1) && count($filter1)) {
         $f = " AND " . implode(" AND ", $filter1);
     }
     if (is_array($filter2) && count($filter2)) {
         $f2 = " AND " . implode(" AND ", $filter2);
     }
     $db = new db_alloc();
     $q = prepare("SELECT transaction.tfID as id, tf.tfName, transactionID, transaction.status,\n                         sum(amount * pow(10,-currencyType.numberToBasic) * exchangeRate) AS balance\n                    FROM transaction\n               LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n               LEFT JOIN tf on transaction.tfID = tf.tfID\n                   WHERE 1 AND transaction.status != 'rejected' " . $f2 . "\n                GROUP BY transaction.status,transaction.tfID");
     $db->query($q);
     while ($row = $db->row()) {
         if ($row["status"] == "approved") {
             $adds[$row["id"]] = $row["balance"];
         } else {
             if ($row["status"] == "pending") {
                 $pending_adds[$row["id"]] = $row["balance"];
             }
         }
     }
     $q = prepare("SELECT transaction.fromTfID as id, tf.tfName, transactionID, transaction.status,\n                         sum(amount * pow(10,-currencyType.numberToBasic) * exchangeRate) AS balance\n                    FROM transaction\n               LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n               LEFT JOIN tf on transaction.fromTfID = tf.tfID\n                   WHERE 1 AND transaction.status != 'rejected' " . $f2 . "\n                GROUP BY transaction.status,transaction.fromTfID");
     $db->query($q);
     while ($row = $db->row()) {
         if ($row["status"] == "approved") {
             $subs[$row["id"]] = $row["balance"];
         } else {
             if ($row["status"] == "pending") {
                 $pending_subs[$row["id"]] = $row["balance"];
             }
         }
     }
     $q = prepare("SELECT tf.* \n                    FROM tf \n               LEFT JOIN tfPerson ON tf.tfID = tfPerson.tfID \n                   WHERE 1 " . $f . "\n                GROUP BY tf.tfID \n                ORDER BY tf.tfName");
     $db->query($q);
     while ($row = $db->row()) {
         $tf = new tf();
         $tf->read_db_record($db);
         $tf->set_values();
         $total = $adds[$db->f("tfID")] - $subs[$db->f("tfID")];
         $pending_total = $pending_adds[$db->f("tfID")] - $pending_subs[$db->f("tfID")];
         if (have_entity_perm("transaction", PERM_READ, $current_user, $tf->is_owner())) {
             $row["tfBalance"] = page::money(config::get_config_item("currency"), $total, "%s%m %c");
             $row["tfBalancePending"] = page::money(config::get_config_item("currency"), $pending_total, "%s%m %c");
             $row["total"] = $total;
             $row["pending_total"] = $pending_total;
         } else {
             $row["tfBalance"] = "";
             $row["tfBalancePending"] = "";
             $row["total"] = "";
             $row["pending_total"] = "";
         }
         $nav_links = $tf->get_nav_links();
         $row["nav_links"] = implode(" ", $nav_links);
         $row["tfActive_label"] = "";
         $tf->get_value("tfActive") and $row["tfActive_label"] = "Y";
         $rows[$tf->get_id()] = $row;
     }
     return (array) $rows;
 }
Пример #23
0
        foreach (array(ALLOC_LOGO, ALLOC_LOGO_SMALL) as $logo) {
            if (file_exists($logo)) {
                if (unlink($logo)) {
                    $TPL["message_good"][] = "Deleted " . $logo;
                }
            }
            if (file_exists($logo)) {
                alloc_error("Unable to delete " . $logo);
            }
        }
    }
}
get_cached_table("config", true);
// flush cache
if (has("finance")) {
    $tf = new tf();
    $options = $tf->get_assoc_array("tfID", "tfName");
}
$TPL["mainTfOptions"] = page::select_options($options, config::get_config_item("mainTfID"));
$TPL["outTfOptions"] = page::select_options($options, config::get_config_item("outTfID"));
$TPL["inTfOptions"] = page::select_options($options, config::get_config_item("inTfID"));
$TPL["taxTfOptions"] = page::select_options($options, config::get_config_item("taxTfID"));
$TPL["expenseFormTfOptions"] = page::select_options($options, config::get_config_item("expenseFormTfID"));
$tabops = array("home" => "Home", "client" => "Clients", "project" => "Projects", "task" => "Tasks", "time" => "Time", "invoice" => "Invoices", "sale" => "Sales", "person" => "People", "wiki" => "Wiki", "inbox" => "Inbox", "tools" => "Tools");
$selected_tabops = config::get_config_item("allocTabs") or $selected_tabops = array_keys($tabops);
$TPL["allocTabsOptions"] = page::select_options($tabops, $selected_tabops);
$m = new meta("currencyType");
$currencyOptions = $m->get_assoc_array("currencyTypeID", "currencyTypeName");
$TPL["currencyOptions"] = page::select_options($currencyOptions, config::get_config_item("currency"));
$db = new db_alloc();
$display = array("", "username", ", ", "emailAddress");
Пример #24
0
 function load_transaction_filter($_FORM)
 {
     global $TPL;
     $rtn["statusOptions"] = page::select_options(array("" => "", "pending" => "Pending", "approved" => "Approved", "rejected" => "Rejected"), $_FORM["status"]);
     $transactionTypeOptions = transaction::get_transactionTypes();
     $rtn["transactionTypeOptions"] = page::select_options($transactionTypeOptions, $_FORM["transactionType"]);
     $rtn["startDate"] = $_FORM["startDate"];
     $rtn["endDate"] = $_FORM["endDate"];
     if ($_FORM["monthDate"]) {
         $rtn["startDate"] = format_date("Y-m-", $_FORM["monthDate"]) . "01";
         $t = format_date("U", $_FORM["monthDate"]);
         $rtn["endDate"] = date("Y-m-d", mktime(1, 1, 1, date("m", $t) + 1, 1, date("Y", $t)));
     }
     $display_format = "M";
     // Fiddle $_FORM["monthDate"]. It may be a real date (2010-11-23) so change the last 2 chars to "01".
     $_FORM["monthDate"] = substr_replace($_FORM["monthDate"], "01", 8);
     // If this month is January, go from last Feb to this Feb
     $m = date("m") + 1;
     $y = date("Y");
     // jump back a year iff it's December now
     if ($m == 13) {
         $m = 1;
     } else {
         $y -= 1;
     }
     $label_monthDate = date($display_format);
     for ($j = 0; $j < 13; $j++) {
         $label = date($display_format, mktime(0, 0, 0, $m, 1, $y));
         $monthDate = date("Y-m-d", mktime(0, 0, 0, $m, 1, $y));
         $bold = false;
         if ($monthDate == format_date("Y-m-d", $_FORM["monthDate"])) {
             $bold = true;
         }
         $link = $TPL["url_alloc_transactionList"] . "tfID=" . $_FORM["tfID"] . "&monthDate=" . $monthDate . "&applyFilter=true";
         $bold and $rtn["month_links"] .= "<b>";
         $rtn["month_links"] .= $sp . "<a href=\"" . $link . "\">" . $label . "</a>";
         $bold and $rtn["month_links"] .= "</b>";
         $sp = "&nbsp;&nbsp;";
         if ($m == 12) {
             $m = 1;
             $y += 1;
         } else {
             $m += 1;
         }
     }
     if ($_FORM["sortTransactions"] == "transactionSortDate") {
         $rtn["checked_transactionSortDate"] = " checked";
     } else {
         $rtn["checked_transactionDate"] = " checked";
     }
     $tf = new tf();
     $options = $tf->get_assoc_array("tfID", "tfName");
     $rtn["tfOptions"] = page::select_options($options, $_FORM["tfID"]);
     $rtn["fromTfOptions"] = page::select_options($options, $_FORM["fromTfID"]);
     $rtn["transactionID"] = $_FORM["transactionID"];
     $rtn["expenseFormID"] = $_FORM["expenseFormID"];
     $rtn["product"] = $_FORM["product"];
     $rtn["amount"] = $_FORM["amount"];
     return $rtn;
 }