Example #1
0
 function get_amount_other()
 {
     $db = new db_alloc();
     // Don't need to do numberToBasic conversion here
     $q = prepare("SELECT fromTfID, tfID,\n                         (amount * exchangeRate) as amount\n                    FROM transaction \n               LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n                   WHERE fromTfID != %d\n                     AND tfID != %d\n                     AND tfID != %d\n                     AND productSaleID = %d\n                     AND productSaleItemID = %d\n                     AND status != 'rejected'\n                     AND productCostID IS NULL\n                ", config::get_config_item("inTfID"), config::get_config_item("outTfID"), config::get_config_item("taxTfID"), $this->get_value("productSaleID"), $this->get_id());
     $db->query($q);
     $rows = array();
     while ($row = $db->row()) {
         $rows[] = $row;
     }
     return transaction::get_actual_amount_used($rows);
 }
Example #2
0
function show_transaction_list($template_name)
{
    global $timeSheet;
    global $TPL;
    $db = new db_alloc();
    $amount_so_far = $timeSheet->get_amount_so_far(true);
    $total_incoming = $timeSheet->pay_info["total_customerBilledDollars"];
    $db->query("SELECT * FROM transaction WHERE timeSheetID = %d AND fromTfID != %d\n               ", $timeSheet->get_id(), config::get_config_item("inTfID"));
    while ($row = $db->row()) {
        $has_transactions = true;
        $rows[] = $row;
    }
    $total_allocated = transaction::get_actual_amount_used($rows);
    $TPL["total_allocated"] = page::money($timeSheet->get_value("currencyTypeID"), $total_allocated, "%s%mo %c");
    $TPL["total_dollars"] = page::money($timeSheet->get_value("currencyTypeID"), $timeSheet->pay_info["total_dollars_not_null"], "%s%m %c");
    // used in js preload_field()
    $TPL["total_remaining"] = page::money($timeSheet->get_value("currencyTypeID"), $total_incoming - $amount_so_far, "%m");
    if ($has_transactions || $timeSheet->get_value("status") == "invoiced" || $timeSheet->get_value("status") == "finished") {
        if ($timeSheet->have_perm(PERM_TIME_INVOICE_TIMESHEETS) && $timeSheet->get_value("status") == "invoiced") {
            $p_button = "<input style=\"padding:1px 4px\" type=\"submit\" name=\"p_button\" value=\"P\" title=\"Mark transactions pending\">&nbsp;";
            $a_button = "<input style=\"padding:1px 4px\" type=\"submit\" name=\"a_button\" value=\"A\" title=\"Mark transactions approved\">&nbsp;";
            $r_button = "<input style=\"padding:1px 4px\" type=\"submit\" name=\"r_button\" value=\"R\" title=\"Mark transactions rejected\">&nbsp;";
            $session = "<input type=\"hidden\" name=\"sessID\" value=\"" . $TPL["sessID"] . "\">";
            $TPL["p_a_r_buttons"] = "<form action=\"" . $TPL["url_alloc_timeSheet"] . "timeSheetID=" . $timeSheet->get_id() . "\" method=\"post\">" . $p_button . $a_button . $r_button . $session . "</form>";
            $TPL["create_transaction_buttons"] = "<tr><td colspan=\"8\" align=\"center\" style=\"padding:10px;\">";
            $TPL["create_transaction_buttons"] .= "<form action=\"" . $TPL["url_alloc_timeSheet"] . "timeSheetID=" . $timeSheet->get_id() . "\" method=\"post\">";
            $TPL["create_transaction_buttons"] .= '
         <button type="submit" name="create_transactions_default" value="1" class="save_button">Create Default Transactions<i class="icon-cogs"></i></button>
        ';
            $TPL["create_transaction_buttons"] .= '
        <button type="submit" name="delete_all_transactions" value="1" class="delete_button">Delete Transactions<i class="icon-trash"></i></button>
        ';
            $TPL["create_transaction_buttons"] .= "<input type=\"hidden\" name=\"sessID\" value=\"" . $TPL["sessID"] . "\"></form></tr></tr>";
        }
        include_template($template_name);
    }
}