コード例 #1
0
ファイル: exchangeRate.inc.php プロジェクト: cjbayliss/alloc
 public static function convert($currency, $amount, $destCurrency = false, $date = false, $format = "%m")
 {
     $date or $date = date("Y-m-d");
     $destCurrency or $destCurrency = config::get_config_item("currency");
     $er = exchangeRate::get_er($currency, $destCurrency, $date);
     return page::money($destCurrency, $amount * $er, $format);
 }
コード例 #2
0
 function render()
 {
     $current_user =& singleton("current_user");
     global $TPL;
     // Get averages for hours worked over the past fortnight and year
     $t = new timeSheetItem();
     $day = 60 * 60 * 24;
     //mktime(0,0,0,date("m"),date("d")-1, date("Y"))
     $today = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
     $yestA = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
     $yestB = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
     $fortn = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 14, date("Y")));
     list($hours_sum_today, $dollars_sum_today) = $t->get_averages($today, $current_user->get_id());
     list($hours_sum_yesterday, $dollars_sum_yesterday) = $t->get_averages($yestA, $current_user->get_id(), null, $yestB);
     list($hours_sum_fortnight, $dollars_sum_fortnight) = $t->get_averages($fortn, $current_user->get_id());
     list($hours_avg_fortnight, $dollars_avg_fortnight) = $t->get_fortnightly_average($current_user->get_id());
     $TPL["hours_sum_today"] = sprintf("%0.2f", $hours_sum_today[$current_user->get_id()]);
     $TPL["dollars_sum_today"] = page::money_print($dollars_sum_today[$current_user->get_id()]);
     $TPL["hours_sum_yesterday"] = sprintf("%0.2f", $hours_sum_yesterday[$current_user->get_id()]);
     $TPL["dollars_sum_yesterday"] = page::money_print($dollars_sum_yesterday[$current_user->get_id()]);
     $TPL["hours_sum_fortnight"] = sprintf("%0.2f", $hours_sum_fortnight[$current_user->get_id()]);
     $TPL["dollars_sum_fortnight"] = page::money_print($dollars_sum_fortnight[$current_user->get_id()]);
     $TPL["hours_avg_fortnight"] = sprintf("%0.2f", $hours_avg_fortnight[$current_user->get_id()]);
     $TPL["dollars_avg_fortnight"] = page::money(config::get_config_item("currency"), $dollars_avg_fortnight[$current_user->get_id()], "%s%m %c");
     $TPL["dateFrom"] = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 28, date("Y")));
     $TPL["dateTo"] = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
     return true;
 }
コード例 #3
0
ファイル: product.php プロジェクト: cjbayliss/alloc
function show_productCost_list($productID, $template, $percent = false)
{
    global $TPL;
    unset($TPL["display"], $TPL["taxOptions"]);
    // otherwise the commissions don't display.
    if ($productID) {
        $t = new meta("currencyType");
        $currency_array = $t->get_assoc_array("currencyTypeID", "currencyTypeID");
        $db = new db_alloc();
        $query = prepare("SELECT * \n                        FROM productCost \n                       WHERE productID = %d \n                         AND isPercentage = %d\n                         AND productCostActive = true\n                    ORDER BY productCostID", $productID, $percent);
        $db->query($query);
        while ($db->next_record()) {
            $productCost = new productCost();
            $productCost->read_db_record($db);
            $productCost->set_tpl_values();
            $TPL["currencyOptions"] = page::select_options($currency_array, $productCost->get_value("currencyTypeID"));
            $TPL["taxOptions"] = page::select_options(array("" => "Exempt", 1 => "Included", 0 => "Excluded"), $productCost->get_value("tax"));
            // Hardcoded AUD because productCost table uses percent and dollars in same field
            $percent and $TPL["amount"] = page::money("AUD", $productCost->get_value("amount"), "%mo");
            include_template($template);
        }
    }
}
コード例 #4
0
ファイル: productSale.php プロジェクト: cjbayliss/alloc
function show_productSale_list($productSaleID, $template)
{
    global $TPL;
    global $productSaleItemsDoExist;
    $productSale = new productSale();
    $productSale->set_id($productSaleID);
    $productSale->select();
    $productSale->set_tpl_values();
    $taxName = config::get_config_item("taxName");
    $product = new product();
    $ops = $product->get_assoc_array("productID", "productName");
    $query = prepare("SELECT *\n                      FROM productSaleItem \n                     WHERE productSaleID = %d", $productSaleID);
    $db = new db_alloc();
    $db->query($query);
    while ($db->next_record()) {
        $productSaleItemsDoExist = true;
        $productSaleItem = new productSaleItem();
        $productSaleItem->read_db_record($db);
        $productSaleItem->set_tpl_values();
        $TPL["itemSellPrice"] = $productSaleItem->get_value("sellPrice");
        $TPL["itemMargin"] = $productSaleItem->get_amount_margin();
        $TPL["itemSpent"] = $productSaleItem->get_amount_spent();
        $TPL["itemEarnt"] = $productSaleItem->get_amount_earnt();
        $TPL["itemOther"] = $productSaleItem->get_amount_other();
        $TPL["itemCosts"] = page::money(config::get_config_item("currency"), product::get_buy_cost($productSaleItem->get_value("productID")) * $productSaleItem->get_value("quantity"), "%s%mo %c");
        $TPL["itemTotalUnallocated"] = $productSaleItem->get_amount_unallocated();
        $TPL["productList_dropdown"] = page::select_options($ops, $productSaleItem->get_value("productID"));
        $TPL["productLink"] = "<a href=\"" . $TPL["url_alloc_product"] . "productID=" . $productSaleItem->get_value("productID") . "\">" . page::htmlentities($ops[$productSaleItem->get_value("productID")]) . "</a>";
        $TPL["transactions"] = $productSale->get_transactions($productSaleItem->get_id());
        if ($taxName) {
            $TPL["sellPriceTax_check"] = sprintf(" <input type='checkbox' name='sellPriceIncTax[]' value='%d'%s> inc %s", $productSaleItem->get_id(), $productSaleItem->get_value("sellPriceIncTax") ? ' checked' : '', $taxName);
            $TPL["sellPriceTax_label"] = $productSaleItem->get_value("sellPriceIncTax") ? " inc " . $taxName : " ex " . $taxName;
        }
        include_template($template);
    }
}
コード例 #5
0
ファイル: project.php プロジェクト: cjbayliss/alloc
function show_transaction($template)
{
    global $db;
    global $TPL;
    global $projectID;
    $current_user =& singleton("current_user");
    $transaction = new transaction();
    if (isset($projectID) && $projectID) {
        $query = prepare("SELECT transaction.*\n                          FROM transaction\n                          WHERE transaction.projectID = %d\n                      ORDER BY transactionModifiedTime desc\n                        ", $projectID);
        $db->query($query);
        while ($db->next_record()) {
            $transaction = new transaction();
            $transaction->read_db_record($db);
            $transaction->set_values("transaction_");
            $tf = $transaction->get_foreign_object("tf");
            $tf->set_values();
            $tf->set_values("tf_");
            $TPL["transaction_username"] = $db->f("username");
            $TPL["transaction_amount"] = page::money($TPL["transaction_currenyTypeID"], $TPL["transaction_amount"], "%s%mo");
            $TPL["transaction_type_link"] = $transaction->get_transaction_type_link() or $TPL["transaction_link"] = $transaction->get_value("transactionType");
            include_template($template);
        }
    }
}
コード例 #6
0
ファイル: updateCostPrice.php プロジェクト: cjbayliss/alloc
 * 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";
$db = new db_alloc();
$product = $_GET["product"];
$quantity = $_GET["quantity"];
$p = new product();
$p->set_id($product);
$p->select();
$p->set_tpl_values();
// Probably not valid XML, but jQuery will parse it.
echo "<data>\n";
echo "<price>" . page::money($TPL["sellPriceCurrencyTypeID"], $TPL["sellPrice"] * $quantity, "%m") . "</price>\n";
echo "<priceCurrency>" . $TPL["sellPriceCurrencyTypeID"] . "</priceCurrency>\n";
echo "<priceTax>" . ($TPL["sellPriceIncTax"] ? "1" : "") . "</priceTax>\n";
echo "<description>" . $TPL["description"] . "</description>\n";
echo "</data>\n";
コード例 #7
0
ファイル: transaction.inc.php プロジェクト: cjbayliss/alloc
 public static function get_list($_FORM)
 {
     $current_user =& singleton("current_user");
     global $TPL;
     /*
      * This is the definitive method of getting a list of transactions that need a sophisticated level of filtering
      *
      */
     $_FORM["tfIDs"] = transaction::reduce_tfs($_FORM);
     // Non-admin users must specify a valid TF
     if (!$current_user->have_role("admin") && !$_FORM["tfIDs"]) {
         return;
     }
     $filter = transaction::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     $filter["prevBalance"] and $filter2[] = $filter["prevBalance"];
     $filter["tfIDs"] and $filter2[] = $filter["tfIDs"];
     $filter2 and $filter2[] = " (status = 'approved') ";
     unset($filter["prevBalance"]);
     if (is_array($filter2) && count($filter2)) {
         $filter2 = " WHERE " . implode(" AND ", $filter2);
     }
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     $_FORM["sortTransactions"] or $_FORM["sortTransactions"] = "transactionDate";
     $order_by = "ORDER BY " . $_FORM["sortTransactions"];
     // Determine opening balance
     if (is_array($_FORM['tfIDs']) && count($_FORM['tfIDs'])) {
         $q = prepare("SELECT SUM( IF(fromTfID IN (%s),-amount,amount) * pow(10,-currencyType.numberToBasic) * exchangeRate) AS balance\n                      FROM transaction \n                 LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n                    " . $filter2, $_FORM['tfIDs']);
         $debug and print "\n<br>QUERY: " . $q;
         $db = new db_alloc();
         $db->query($q);
         $db->row();
         $_FORM["opening_balance"] = $db->f("balance");
         $running_balance = $db->f("balance");
     }
     $q = "SELECT *, \n                 (amount * pow(10,-currencyType.numberToBasic)) as amount1,\n                 (amount * pow(10,-currencyType.numberToBasic) * exchangeRate) as amount2,\n                 if(transactionModifiedTime,transactionModifiedTime,transactionCreatedTime) AS transactionSortDate,\n                 tf1.tfName as fromTfName,\n                 tf2.tfName as tfName\n            FROM transaction \n       LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n       LEFT JOIN tf tf1 ON transaction.fromTfID = tf1.tfID\n       LEFT JOIN tf tf2 ON transaction.tfID = tf2.tfID\n         " . $filter . " \n         " . $order_by;
     $debug and print "\n<br>QUERY2: " . $q;
     $db = new db_alloc();
     $db->query($q);
     $for_cyber = config::for_cyber();
     while ($row = $db->next_record()) {
         #echo "<pre>".print_r($row,1)."</pre>";
         $i++;
         $t = new transaction();
         if (!$t->read_db_record($db)) {
             continue;
         }
         $print = true;
         // If the destination of this TF is not the current TfID, then invert the $amount
         $amount = $row["amount2"];
         if (!in_array($row["tfID"], (array) $_FORM["tfIDs"])) {
             $amount = -$amount;
             $row["amount1"] = -$row["amount1"];
         }
         $row["amount"] = $amount;
         $row["transactionURL"] = $t->get_url();
         $row["transactionName"] = $t->get_name($_FORM);
         $row["transactionLink"] = $t->get_transaction_link($_FORM);
         $row["transactionTypeLink"] = $t->get_transaction_type_link() or $row["transactionTypeLink"] = $row["transactionType"];
         $row["transactionSortDate"] = format_date("Y-m-d", $row["transactionSortDate"]);
         $row["fromTfIDLink"] = "<a href=\"" . $TPL["url_alloc_transactionList"] . "tfID=" . $row["fromTfID"] . "\">" . page::htmlentities($row["fromTfName"]) . "</a>";
         $row["tfIDLink"] = "<a href=\"" . $TPL["url_alloc_transactionList"] . "tfID=" . $row["tfID"] . "\">" . page::htmlentities($row["tfName"]) . "</a>";
         if ($t->get_value("status") == "approved") {
             $running_balance += $amount;
             $row["running_balance"] = page::money(config::get_config_item("currency"), $running_balance, "%m %c");
         }
         if ($amount > 0) {
             $row["amount_positive"] = page::money($row["currencyTypeID"], $row["amount1"], "%m %c");
             $total_amount_positive += $amount;
         } else {
             $row["amount_negative"] = page::money($row["currencyTypeID"], $row["amount1"], "%m %c");
             $total_amount_negative += $amount;
         }
         // Cyber only hackery for ext ref field on product sales
         if ($for_cyber && $row["productSaleID"]) {
             $ps = new productSale();
             $ps->set_id($row["productSaleID"]);
             if ($ps->select()) {
                 $ps->get_value("extRef") and $row["product"] .= " (Ext ref: " . $ps->get_value("extRef") . ")";
             }
         }
         $transactions[$row["transactionID"]] = $row;
     }
     $_FORM["total_amount_positive"] = page::money(config::get_config_item("currency"), $total_amount_positive, "%s%m %c");
     $_FORM["total_amount_negative"] = page::money(config::get_config_item("currency"), $total_amount_negative, "%s%m %c");
     $_FORM["running_balance"] = page::money(config::get_config_item("currency"), $running_balance, "%s%m %c");
     return array("totals" => $_FORM, "rows" => (array) $transactions);
 }
コード例 #8
0
ファイル: task.inc.php プロジェクト: cjbayliss/alloc
 public static function get_list($_FORM)
 {
     $current_user =& singleton("current_user");
     /*
      * This is the definitive method of getting a list of tasks that need a sophisticated level of filtering
      *
      */
     list($filter, $having) = task::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["taskView"] or $_FORM["taskView"] = 'prioritised';
     // Zero is a valid limit
     if ($_FORM["limit"] || $_FORM["limit"] === 0 || $_FORM["limit"] === "0") {
         $limit = prepare("limit %d", $_FORM["limit"]);
     }
     $_FORM["return"] or $_FORM["return"] = "html";
     $_FORM["people_cache"] =& get_cached_table("person");
     $_FORM["timeUnit_cache"] =& get_cached_table("timeUnit");
     $_FORM["taskType_cache"] =& get_cached_table("taskType");
     if ($_FORM["taskView"] == "prioritised") {
         unset($filter["parentTaskID"]);
         $order_limit = " " . $limit;
     } else {
         $order_limit = " ORDER BY projectName,taskName " . $limit;
     }
     // Get a hierarchical list of tasks
     if (is_array($filter) && count($filter)) {
         $f = " WHERE " . implode(" AND ", $filter);
     }
     $uid = sprintf("%d", $current_user->get_id());
     $spread = sprintf("%d", config::get_config_item("taskPrioritySpread"));
     $scale = sprintf("%d", config::get_config_item("taskPriorityScale"));
     $scale_halved = sprintf("%d", config::get_config_item("taskPriorityScale") / 2);
     $q = "SELECT task.*\n                ,projectName\n                ,projectShortName\n                ,clientID\n                ,projectPriority\n                ,project.currencyTypeID as currency\n                ,rate\n                ,rateUnitID\n                ,GROUP_CONCAT(pendingTask.pendingTaskID) as pendingTaskIDs\n                ,GROUP_CONCAT(DISTINCT alltag.name SEPARATOR ', ') as tags\n            FROM task\n       LEFT JOIN project ON project.projectID = task.projectID\n       LEFT JOIN projectPerson ON project.projectID = projectPerson.projectID AND projectPerson.personID = '" . $uid . "'\n       LEFT JOIN pendingTask ON pendingTask.taskID = task.taskID\n       LEFT JOIN tag alltag ON alltag.taskID = task.taskID\n       LEFT JOIN tag seltag ON seltag.taskID = task.taskID\n                 " . $f . "\n        GROUP BY task.taskID\n                 " . $having . "\n                 " . $order_limit;
     $debug and print "\n<br>QUERY: " . $q;
     $_FORM["debug"] and print "\n<br>QUERY: " . $q;
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $task = new task();
         $task->read_db_record($db);
         $row["taskURL"] = $task->get_url();
         $row["taskName"] = $task->get_name($_FORM);
         $row["taskLink"] = $task->get_task_link($_FORM);
         $row["project_name"] = $row["projectShortName"] or $row["project_name"] = $row["projectName"];
         $row["projectPriority"] = $db->f("projectPriority");
         has("project") and $row["projectPriorityLabel"] = project::get_priority_label($db->f("projectPriority"));
         has("project") and list($row["priorityFactor"], $row["daysUntilDue"]) = $task->get_overall_priority($row["projectPriority"], $row["priority"], $row["dateTargetCompletion"]);
         $row["taskTypeImage"] = $task->get_task_image();
         $row["taskTypeSeq"] = $_FORM["taskType_cache"][$row["taskTypeID"]]["taskTypeSeq"];
         $row["taskStatusLabel"] = $task->get_task_status("label");
         $row["taskStatusColour"] = $task->get_task_status("colour");
         $row["creator_name"] = $_FORM["people_cache"][$row["creatorID"]]["name"];
         $row["manager_name"] = $_FORM["people_cache"][$row["managerID"]]["name"];
         $row["assignee_name"] = $_FORM["people_cache"][$row["personID"]]["name"];
         $row["closer_name"] = $_FORM["people_cache"][$row["closerID"]]["name"];
         $row["estimator_name"] = $_FORM["people_cache"][$row["estimatorID"]]["name"];
         $row["creator_username"] = $_FORM["people_cache"][$row["creatorID"]]["username"];
         $row["manager_username"] = $_FORM["people_cache"][$row["managerID"]]["username"];
         $row["assignee_username"] = $_FORM["people_cache"][$row["personID"]]["username"];
         $row["closer_username"] = $_FORM["people_cache"][$row["closerID"]]["username"];
         $row["estimator_username"] = $_FORM["people_cache"][$row["estimatorID"]]["username"];
         $row["newSubTask"] = $task->get_new_subtask_link();
         $_FORM["showPercent"] and $row["percentComplete"] = $task->get_percentComplete();
         $_FORM["showTimes"] and $row["timeActual"] = $task->get_time_billed() / 60 / 60;
         $row["rate"] = page::money($row["currency"], $row["rate"], "%mo");
         $row["rateUnit"] = $_FORM["timeUnit_cache"][$row["rateUnitID"]]["timeUnitName"];
         $row["priorityLabel"] = $task->get_priority_label();
         if (!$_FORM["skipObject"]) {
             $_FORM["return"] == "array" and $row["object"] = $task;
         }
         $row["padding"] = $_FORM["padding"];
         $row["taskID"] = $task->get_id();
         $row["parentTaskID"] = $task->get_value("parentTaskID");
         $row["parentTaskID_link"] = "<a href='" . $task->get_url(false, $task->get_value("parentTaskID")) . "'>" . $task->get_value("parentTaskID") . "</a>";
         $row["timeLimitLabel"] = $row["timeBestLabel"] = $row["timeWorstLabel"] = $row["timeExpectedLabel"] = $row["timeActualLabel"] = "";
         $row["timeLimit"] !== NULL and $row["timeLimitLabel"] = seconds_to_display_format($row["timeLimit"] * 60 * 60);
         $row["timeBest"] !== NULL and $row["timeBestLabel"] = seconds_to_display_format($row["timeBest"] * 60 * 60);
         $row["timeWorst"] !== NULL and $row["timeWorstLabel"] = seconds_to_display_format($row["timeWorst"] * 60 * 60);
         $row["timeExpected"] !== NULL and $row["timeExpectedLabel"] = seconds_to_display_format($row["timeExpected"] * 60 * 60);
         $row["timeActual"] !== NULL and $row["timeActualLabel"] = seconds_to_display_format($row["timeActual"] * 60 * 60);
         if ($_FORM["showComments"] && ($comments = comment::util_get_comments("task", $row["taskID"]))) {
             $row["comments"] = $comments;
         }
         if ($_FORM["taskView"] == "byProject") {
             $rows[$task->get_id()] = array("parentTaskID" => $row["parentTaskID"], "row" => $row);
         } else {
             if ($_FORM["taskView"] == "prioritised") {
                 $rows[$row["taskID"]] = $row;
                 if (is_array($rows) && count($rows)) {
                     uasort($rows, array("task", "priority_compare"));
                 }
             }
         }
     }
     if ($_FORM["taskView"] == "byProject") {
         $parentTaskID = $_FORM["parentTaskID"] or $parentTaskID = 0;
         $t = task::get_recursive_child_tasks($parentTaskID, (array) $rows);
         list($tasks, $done) = task::build_recursive_task_list($t, $_FORM);
         // This bit appends the orphan tasks onto the end..
         foreach ((array) $rows as $taskID => $r) {
             $row = $r["row"];
             $row["padding"] = 0;
             if (!$done[$taskID]) {
                 $tasks += array($taskID => $row);
             }
         }
     } else {
         if ($_FORM["taskView"] == "prioritised") {
             $tasks =& $rows;
         }
     }
     return (array) $tasks;
 }
コード例 #9
0
ファイル: productSale.inc.php プロジェクト: cjbayliss/alloc
 function move_forwards()
 {
     $current_user =& singleton("current_user");
     global $TPL;
     $status = $this->get_value("status");
     $db = new db_alloc();
     if ($this->get_value("clientID")) {
         $c = $this->get_foreign_object("client");
         $extra = " for " . $c->get_value("clientName");
         $taskDesc[] = "";
     }
     $taskname1 = "Sale " . $this->get_id() . ": raise an invoice" . $extra;
     $taskname2 = "Sale " . $this->get_id() . ": place an order to the supplier";
     $taskname3 = "Sale " . $this->get_id() . ": pay the supplier";
     $taskname4 = "Sale " . $this->get_id() . ": deliver the goods / action the work";
     $cyberadmin = 59;
     $taskDesc[] = "Sale items:";
     $taskDesc[] = "";
     foreach ((array) $this->get_productSaleItems() as $psiID => $psi_row) {
         $p = new product();
         $p->set_id($psi_row["productID"]);
         $taskDesc[] = "  " . page::money($psi_row["sellPriceCurrencyTypeID"], $psi_row["sellPrice"], "%S%mo") . " for " . $psi_row["quantity"] . " x " . $p->get_name();
         $hasItems = true;
     }
     if (!$hasItems) {
         return alloc_error("No sale items have been added.");
     }
     $amounts = $this->get_amounts();
     $taskDesc[] = "";
     $taskDesc[] = "Total: " . $amounts["total_sellPrice"];
     $taskDesc[] = "Total inc " . config::get_config_item("taxName") . ": " . $amounts["total_sellPrice_plus_gst"];
     $taskDesc[] = "";
     $taskDesc[] = "Refer to the sale in alloc for up-to-date information:";
     $taskDesc[] = config::get_config_item("allocURL") . "sale/productSale.php?productSaleID=" . $this->get_id();
     $taskDesc = implode("\n", $taskDesc);
     if ($status == "edit") {
         $this->set_value("status", "allocate");
         $items = $this->get_productSaleItems();
         foreach ($items as $r) {
             $psi = new productSaleItem();
             $psi->set_id($r["productSaleItemID"]);
             $psi->select();
             if (!$db->qr("SELECT transactionID FROM transaction WHERE productSaleItemID = %d", $psi->get_id())) {
                 $psi->create_transactions();
             }
         }
     } else {
         if ($status == "allocate") {
             $this->set_value("status", "admin");
             // 1. from salesperson to admin
             $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname1);
             if (config::for_cyber() && !$db->qr($q)) {
                 $task = new task();
                 $task->set_value("projectID", $cyberadmin);
                 // Cyber Admin Project
                 $task->set_value("taskName", $taskname1);
                 $task->set_value("managerID", $this->get_value("personID"));
                 // salesperson
                 $task->set_value("personID", 67);
                 // Cyber Support people (jane)
                 $task->set_value("priority", 3);
                 $task->set_value("taskTypeID", "Task");
                 $task->set_value("taskDescription", $taskDesc);
                 $task->set_value("dateTargetStart", date("Y-m-d"));
                 $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7));
                 $task->save();
                 $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName");
                 $p1 = new person();
                 $p1->set_id($this->get_value("personID"));
                 $p1->select();
                 $p2 = new person();
                 $p2->set_id(67);
                 $p2->select();
                 $recipients[$p1->get_value("emailAddress")] = array("name" => $p1->get_name(), "addIP" => true, "internal" => true);
                 $recipients[$p2->get_value("emailAddress")] = array("name" => $p2->get_name(), "addIP" => true, "internal" => true);
                 $comment = $p2->get_name() . ",\n\n" . $taskname1 . "\n\n" . $taskDesc;
                 $commentID = comment::add_comment("task", $task->get_id(), $comment, "task", $task->get_id());
                 $emailRecipients = comment::add_interested_parties($commentID, null, $recipients);
                 // Re-email the comment out, including any attachments
                 if (!comment::send_comment($commentID, $emailRecipients)) {
                     alloc_error("Email failed to send.");
                 } else {
                     $TPL["message_good"][] = "Emailed task comment to " . $p1->get_value("emailAddress") . ", " . $p2->get_value("emailAddress") . ".";
                 }
             }
         } else {
             if ($status == "admin" && $this->have_perm(PERM_APPROVE_PRODUCT_TRANSACTIONS)) {
                 $this->set_value("status", "finished");
                 if ($_REQUEST["changeTransactionStatus"]) {
                     $rows = $this->get_productSaleItems();
                     foreach ($rows as $row) {
                         $ids[] = $row["productSaleItemID"];
                     }
                     if ($ids) {
                         $q = prepare("UPDATE transaction SET status = '%s' WHERE productSaleItemID in (%s)", $_REQUEST["changeTransactionStatus"], $ids);
                         $db = new db_alloc();
                         $db->query($q);
                     }
                 }
                 // 2. from admin to salesperson
                 $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname2);
                 if (config::for_cyber() && !$db->qr($q)) {
                     $task = new task();
                     $task->set_value("projectID", $cyberadmin);
                     // Cyber Admin Project
                     $task->set_value("taskName", $taskname2);
                     $task->set_value("managerID", 67);
                     // Cyber Support people (jane)
                     $task->set_value("personID", $this->get_value("personID"));
                     // salesperson
                     $task->set_value("priority", 3);
                     $task->set_value("taskTypeID", "Task");
                     $task->set_value("taskDescription", $taskDesc);
                     $task->set_value("dateTargetStart", date("Y-m-d"));
                     $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7));
                     $task->save();
                     $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname1);
                     $rai_row = $db->qr($q);
                     if ($rai_row) {
                         $task->add_pending_tasks($rai_row["taskID"]);
                     }
                     $order_the_hardware_taskID = $task->get_id();
                     $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName");
                     $task->add_notification(3, 1, "Task " . $task->get_id() . " " . $taskname2, "Task status moved from pending to open.", array(array("field" => "metaPersonID", "who" => -2)));
                 }
                 // 3. from salesperson to admin
                 $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname3);
                 if (config::for_cyber() && !$db->qr($q)) {
                     $task = new task();
                     $task->set_value("projectID", $cyberadmin);
                     // Cyber Admin Project
                     $task->set_value("taskName", $taskname3);
                     $task->set_value("managerID", $this->get_value("personID"));
                     // salesperson
                     $task->set_value("personID", 67);
                     // Cyber Support people (jane)
                     $task->set_value("priority", 3);
                     $task->set_value("taskTypeID", "Task");
                     $task->set_value("taskDescription", $taskDesc);
                     $task->set_value("dateTargetStart", date("Y-m-d"));
                     $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7));
                     $task->save();
                     $task->add_pending_tasks($order_the_hardware_taskID);
                     $pay_the_supplier_taskID = $task->get_id();
                     $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName");
                     $task->add_notification(3, 1, "Task " . $task->get_id() . " " . $taskname3, "Task status moved from pending to open.", array(array("field" => "metaPersonID", "who" => -2)));
                 }
                 // 4. from admin to salesperson
                 $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname4);
                 if (config::for_cyber() && !$db->qr($q)) {
                     $task = new task();
                     $task->set_value("projectID", $cyberadmin);
                     // Cyber Admin Project
                     $task->set_value("taskName", $taskname4);
                     $task->set_value("managerID", 67);
                     // Cyber Support people
                     $task->set_value("personID", $this->get_value("personID"));
                     // salesperson
                     $task->set_value("priority", 3);
                     $task->set_value("taskTypeID", "Task");
                     $task->set_value("taskDescription", $taskDesc);
                     $task->set_value("dateTargetStart", date("Y-m-d"));
                     $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7));
                     $task->save();
                     $task->add_pending_tasks($pay_the_supplier_taskID);
                     $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName");
                     $task->add_notification(3, 1, "Task " . $task->get_id() . " " . $taskname4, "Task status moved from pending to open.", array(array("field" => "metaPersonID", "who" => -2)));
                 }
             }
         }
     }
 }
コード例 #10
0
ファイル: db_field.inc.php プロジェクト: cjbayliss/alloc
 function validate($parent)
 {
     global $TPL;
     if ($parent->doMoney && $this->type == "money") {
         $c = $parent->currency;
         if ($this->currency && isset($parent->data_fields[$this->currency])) {
             $c = $parent->get_value($this->currency);
         }
         if (!$c) {
             return "db_field::validate(): No currency specified for " . $parent->classname . "." . $this->name . " (currency:" . $c . ")";
         } else {
             if ($this->value != $parent->all_row_fields[$this->name]) {
                 $this->set_value(page::money($c, $this->value, "%mi"));
             }
         }
     }
 }
コード例 #11
0
ファイル: project.inc.php プロジェクト: cjbayliss/alloc
 function get_changes_list()
 {
     // This function returns HTML rows for the changes that have been made to this project
     $rows = array();
     $people_cache =& get_cached_table("person");
     $timeUnit = new timeUnit();
     $timeUnits = array_reverse($timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelA"), true);
     $options = array("projectID" => $this->get_id());
     $changes = audit::get_list($options);
     foreach ((array) $changes as $audit) {
         $changeDescription = "";
         $newValue = $audit['value'];
         switch ($audit['field']) {
             case 'created':
                 $changeDescription = $newValue;
                 break;
             case 'dip':
                 $changeDescription = "Default parties set to " . interestedParty::abbreviate($newValue);
                 break;
             case 'projectShortName':
                 $changeDescription = "Project nickname set to '{$newValue}'.";
                 break;
             case 'projectComments':
                 $changeDescription = "Project description set to <a class=\"magic\" href=\"#x\" onclick=\"\$('#audit" . $audit["auditID"] . "').slideToggle('fast');\">Show</a> <div class=\"hidden\" id=\"audit" . $audit["auditID"] . "\"><div>" . $newValue . "</div></div>";
                 break;
             case 'clientID':
                 $newClient = new client($newValue);
                 is_object($newClient) and $newClientLink = $newClient->get_link();
                 $newClientLink or $newClientLink = "&lt;empty&gt;";
                 $changeDescription = "Client set to " . $newClientLink . ".";
                 break;
             case 'clientContactID':
                 $newClientContact = new clientContact($newValue);
                 is_object($newClientContact) and $newClientContactLink = $newClientContact->get_link();
                 $newClientContactLink or $newClientContactLink = "&lt;empty&gt;";
                 $changeDescription = "Client contact set to " . $newClientContactLink . ".";
                 break;
             case 'projectType':
                 $changeDescription = "Project type set to " . $newValue . ".";
                 break;
             case 'projectBudget':
                 $changeDescription = "Project budget set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'currencyTypeID':
                 $changeDescription = "Project currency set to " . $newValue . ".";
                 break;
             case 'projectStatus':
                 $changeDescription = "Project status set to " . $newValue . ".";
                 break;
             case 'projectName':
                 $changeDescription = "Project name set to '{$newValue}'.";
                 break;
             case 'cost_centre_tfID':
                 $newCostCentre = new tf($newValue);
                 is_object($newCostCentre) and $newCostCentreLink = $newCostCentre->get_link();
                 $newCostCentreLink or $newCostCentreLink = "&lt;empty&gt;";
                 $changeDescription = "Cost centre TF set to " . $newCostCentreLink . ".";
                 break;
             case 'customerBilledDollars':
                 $changeDescription = "Client billing set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'defaultTaskLimit':
                 $changeDescription = "Default task limit set to " . $newValue . ".";
                 break;
             case 'defaultTimeSheetRate':
                 $changeDescription = "Default time sheet rate set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'defaultTimeSheetRateUnitID':
                 $changeDescription = "Default time sheet rate unit set to '" . $timeUnits[$newValue] . "'.";
                 break;
             case 'projectPriority':
                 $priorities = config::get_config_item("projectPriorities");
                 $changeDescription = sprintf('Project priority set to <span style="color: %s;">%s</span>.', $priorities[$newValue]["colour"], $priorities[$newValue]["label"]);
                 break;
             case 'dateActualCompletion':
             case 'dateActualStart':
             case 'dateTargetStart':
             case 'dateTargetCompletion':
                 // these cases are more or less identical
                 switch ($audit['field']) {
                     case 'dateActualCompletion':
                         $fieldDesc = "actual completion date";
                         break;
                     case 'dateActualStart':
                         $fieldDesc = "actual start date";
                         break;
                     case 'dateTargetStart':
                         $fieldDesc = "estimate/target start date";
                         break;
                     case 'dateTargetCompletion':
                         $fieldDesc = "estimate/target completion date";
                         break;
                 }
                 if (!$newValue) {
                     $changeDescription = "The {$fieldDesc} was removed.";
                 } else {
                     $changeDescription = "The {$fieldDesc} set to {$newValue}.";
                 }
                 break;
         }
         $rows[] = "<tr><td class=\"nobr\">" . $audit["dateChanged"] . "</td><td>{$changeDescription}</td><td>" . page::htmlentities($people_cache[$audit["personID"]]["name"]) . "</td></tr>";
     }
     return implode("\n", $rows);
 }
コード例 #12
0
ファイル: timeSheetItem.inc.php プロジェクト: cjbayliss/alloc
 public static function get_list($_FORM)
 {
     /*
      * This is the definitive method of getting a list of timeSheetItems that need a sophisticated level of filtering
      *
      */
     global $TPL;
     $filter = timeSheetItem::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     $q = "SELECT * FROM timeSheetItem\n       LEFT JOIN timeSheet ON timeSheet.timeSheetID = timeSheetItem.timeSheetID\n                 " . $filter . "\n        ORDER BY timeSheet.timeSheetID,dateTimeSheetItem asc";
     $debug and print "Query: " . $q;
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $print = true;
         $t = new timeSheet();
         $t->read_db_record($db);
         $tsi = new timeSheetItem();
         $tsi->read_db_record($db);
         $tsi->currency = $t->get_value("currencyTypeID");
         $row["secondsBilled"] = $row["hoursBilled"] = $row["timeLimit"] = $row["limitWarning"] = "";
         # set these for the CLI
         if ($tsi->get_value("taskID")) {
             $task = $tsi->get_foreign_object('task');
             $row["secondsBilled"] = $task->get_time_billed();
             $row["hoursBilled"] = sprintf("%0.2f", $row["secondsBilled"] / 60 / 60);
             $task->get_value('timeLimit') && $row["hoursBilled"] > $task->get_value('timeLimit') and $row["limitWarning"] = 'Exceeds Limit!';
             $row["timeLimit"] = $task->get_value("timeLimit");
         }
         $row["rate"] = $tsi->get_value("rate", DST_HTML_DISPLAY);
         $row["worth"] = page::money($tsi->currency, $row["rate"] * $tsi->get_value("multiplier") * $tsi->get_value("timeSheetItemDuration"), "%m");
         $rows[$row["timeSheetItemID"]] = $row;
     }
     if ($print && $_FORM["return"] == "array") {
         return $rows;
     }
 }
コード例 #13
0
ファイル: invoice.inc.php プロジェクト: cjbayliss/alloc
 public static function get_list($_FORM)
 {
     /*
      * This is the definitive method of getting a list of invoices that need a sophisticated level of filtering
      *
      */
     global $TPL;
     $filter1_where = invoice::get_list_filter($_FORM);
     $filter2_having = invoice::get_list_filter2($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "<pre>filter1_where: " . print_r($filter1_where, 1) . "</pre>";
     $debug and print "<pre>filter2_having: " . print_r($filter2_having, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     is_array($filter1_where) && count($filter1_where) and $f1_where = " WHERE " . implode(" AND ", $filter1_where);
     is_array($filter2_having) && count($filter2_having) and $f2_having = " HAVING " . implode(" AND ", $filter2_having);
     $q1 = "CREATE TEMPORARY TABLE invoice_details\n          SELECT SUM(invoiceItem.iiAmount * pow(10,-currencyType.numberToBasic)) as iiAmountSum\n               , invoice.*\n               , client.clientName\n            FROM invoice\n       LEFT JOIN invoiceItem on invoiceItem.invoiceID = invoice.invoiceID\n       LEFT JOIN client ON invoice.clientID = client.clientID\n       LEFT JOIN currencyType on invoice.currencyTypeID = currencyType.currencyTypeID\n              {$f1_where}\n        GROUP BY invoice.invoiceID\n        ORDER BY invoiceDateFrom";
     $db = new db_alloc();
     #$db->query("DROP TABLE IF EXISTS invoice_details");
     $db->query($q1);
     $q2 = "SELECT invoice_details.*\n               , SUM(transaction_approved.amount) as amountPaidApproved\n               , SUM(transaction_pending.amount) as amountPaidPending\n               , SUM(transaction_rejected.amount) as amountPaidRejected\n            FROM invoice_details\n       LEFT JOIN invoiceItem on invoiceItem.invoiceID = invoice_details.invoiceID\n       LEFT JOIN transaction transaction_approved on invoiceItem.invoiceItemID = transaction_approved.invoiceItemID AND transaction_approved.status='approved'\n       LEFT JOIN transaction transaction_pending on invoiceItem.invoiceItemID = transaction_pending.invoiceItemID AND transaction_pending.status='pending'\n       LEFT JOIN transaction transaction_rejected on invoiceItem.invoiceItemID = transaction_rejected.invoiceItemID AND transaction_rejected.status='rejected'\n        GROUP BY invoice_details.invoiceID\n              {$f2_having}\n        ORDER BY invoiceDateFrom";
     // Don't do this! It doubles the totals!
     //LEFT JOIN tfPerson ON tfPerson.tfID = transaction_approved.tfID OR tfPerson.tfID = transaction_pending.tfID OR tfPerson.tfID = transaction_rejected.tfID
     $debug and print "<pre>Query1: " . $q1 . "</pre>";
     $debug and print "<pre>Query2: " . $q2 . "</pre>";
     $db->query($q2);
     while ($row = $db->next_record()) {
         $print = true;
         $i = new invoice();
         $i->read_db_record($db);
         $row["amountPaidApproved"] = page::money($row["currencyTypeID"], $row["amountPaidApproved"], "%mo");
         $row["amountPaidPending"] = page::money($row["currencyTypeID"], $row["amountPaidPending"], "%mo");
         $row["amountPaidRejected"] = page::money($row["currencyTypeID"], $row["amountPaidRejected"], "%mo");
         $row["invoiceLink"] = $i->get_invoice_link();
         $payment_status = array();
         $row["statii"] = invoice::get_invoice_statii();
         $row["payment_statii"] = invoice::get_invoice_statii_payment();
         $row["amountPaidApproved"] == $row["iiAmountSum"] and $payment_status[] = "fully_paid";
         $row["amountPaidApproved"] > $row["iiAmountSum"] and $payment_status[] = "over_paid";
         $row["amountPaidRejected"] > 0 and $payment_status[] = "rejected";
         #$row["amountPaidApproved"] > 0 && $row["amountPaidApproved"] < $row["iiAmountSum"] and $payment_status[] = "partly_paid";
         $row["amountPaidApproved"] < $row["iiAmountSum"] and $payment_status[] = "pending";
         foreach ((array) $payment_status as $ps) {
             $row["image"] .= invoice::get_invoice_statii_payment_image($ps);
             $row["status_label"] .= $ps;
         }
         $row["_FORM"] = $_FORM;
         $row = array_merge($TPL, (array) $row);
         $rows[$row["invoiceID"]] = $row;
     }
     return $rows;
 }
コード例 #14
0
 function create_transactions()
 {
     $db = new db_alloc();
     $db2 = new db_alloc();
     $product = $this->get_foreign_object("product");
     $productSale = $this->get_foreign_object("productSale");
     $productName = $product->get_value("productName");
     $taxName = config::get_config_item("taxName");
     $taxTfID = config::get_config_item("taxTfID");
     $mainTfID = $productSale->get_value("tfID");
     // Next transaction represents the amount that someone has paid the
     // sellPrice amount for the product. This money is transferred from
     // the Incoming transactions TF, to the Main Finance TF.
     $this->create_transaction(config::get_config_item("inTfID"), $mainTfID, page::money($this->get_value("sellPriceCurrencyTypeID"), $this->get_value("sellPrice"), "%mo"), "Product Sale: " . $productName, $this->get_value("sellPriceCurrencyTypeID"));
     // Now loop through all the productCosts for the sale items product.
     $query = prepare("SELECT productCost.*, product.productName\n                        FROM productCost \n                   LEFT JOIN product ON product.productID = productCost.productID\n                       WHERE productCost.productID = %d \n                         AND isPercentage != 1\n                         AND productCostActive = true\n                    ORDER BY productCostID", $this->get_value("productID"));
     $db2->query($query);
     while ($productCost_row = $db2->next_record()) {
         $amount = page::money($productCost_row["currencyTypeID"], $productCost_row["amount"] * $this->get_value("quantity"), "%mo");
         $this->create_transaction($productCost_row["tfID"], config::get_config_item("outTfID"), $amount, "Product Cost: " . $productCost_row["productName"] . " " . $productCost_row["description"], $productCost_row["currencyTypeID"], $productCost_row["productCostID"]);
     }
     // Need to do the percentages separately because they rely on the $totalUnallocated figure
     $totalUnallocated = page::money(config::get_config_item("currency"), $this->get_amount_unallocated(), "%mo");
     // Now loop through all the productCosts % COMMISSIONS for the sale items product.
     $query = prepare("SELECT productCost.*, product.productName\n                        FROM productCost \n                   LEFT JOIN product ON product.productID = productCost.productID\n                       WHERE productCost.productID = %d \n                         AND isPercentage = 1\n                         AND productCostActive = true\n                    ORDER BY productCostID", $this->get_value("productID"));
     $db2->query($query);
     while ($productComm_row = $db2->next_record()) {
         $amount = page::money($productComm_row["currencyTypeID"], $totalUnallocated * $productComm_row["amount"] / 100, "%mo");
         $this->create_transaction($mainTfID, $productComm_row["tfID"], $amount, "Product Commission: " . $productComm_row["productName"] . " " . $productComm_row["description"], config::get_config_item("currency"), $productComm_row["productCostID"]);
     }
 }
コード例 #15
0
ファイル: expenseForm.inc.php プロジェクト: cjbayliss/alloc
 public static function get_list($_FORM = array())
 {
     global $TPL;
     $filter = expenseForm::get_list_filter($_FORM);
     if (is_array($filter) && count($filter)) {
         $f = " AND " . implode(" AND ", $filter);
     }
     $db = new db_alloc();
     $dbTwo = new db_alloc();
     $transDB = new db_alloc();
     $expenseForm = new expenseForm();
     $transaction = new transaction();
     $rr_options = expenseForm::get_reimbursementRequired_array();
     $q = prepare("SELECT expenseForm.*\n                        ,SUM(transaction.amount * pow(10,-currencyType.numberToBasic)) as formTotal\n                        ,transaction.currencyTypeID\n                    FROM expenseForm, transaction\n               LEFT JOIN currencyType on transaction.currencyTypeID = currencyType.currencyTypeID\n                   WHERE expenseForm.expenseFormID = transaction.expenseFormID\n                         " . $f . "\n                GROUP BY expenseForm.expenseFormID, transaction.currencyTypeID\n                ORDER BY expenseFormID");
     $db->query($q);
     while ($row = $db->row()) {
         $amounts[$row["expenseFormID"]] .= $sp[$row["expenseFormID"]] . page::money($row["currencyTypeID"], $row["formTotal"], "%s%m");
         $sp[$row["expenseFormID"]] = " + ";
         $allrows[$row["expenseFormID"]] = $row;
     }
     foreach ((array) $allrows as $expenseFormID => $row) {
         $expenseForm = new expenseForm();
         if ($expenseForm->read_row_record($row)) {
             $expenseForm->set_values();
             $row["formTotal"] = $amounts[$expenseFormID];
             $row["expenseFormModifiedUser"] = person::get_fullname($expenseForm->get_value("expenseFormModifiedUser"));
             $row["expenseFormModifiedTime"] = $expenseForm->get_value("expenseFormModifiedTime");
             $row["expenseFormCreatedUser"] = person::get_fullname($expenseForm->get_value("expenseFormCreatedUser"));
             $row["expenseFormCreatedTime"] = $expenseForm->get_value("expenseFormCreatedTime");
             unset($extra);
             $expenseForm->get_value("paymentMethod") and $extra = " (" . $expenseForm->get_value("paymentMethod") . ")";
             $row["rr_label"] = $rr_options[$expenseForm->get_value("reimbursementRequired")] . $extra;
             $rows[] = $row;
         }
     }
     return (array) $rows;
 }
コード例 #16
0
ファイル: invoice.php プロジェクト: cjbayliss/alloc
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);
    }
}
コード例 #17
0
<?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/>.
*/
define("NO_REDIRECT", 1);
require_once "../alloc.php";
if ($_GET["project"] && $_GET["person"]) {
    $rate = projectPerson::get_rate($_GET["project"], $_GET["person"]);
    $project = new project($_GET["project"]);
    $currency = $project->get_value("currencyTypeID") or $currency = config::get_config_item("currency");
    $rate['rate'] = page::money($currency, $rate['rate'], '%mo');
    echo alloc_json_encode($rate);
}
コード例 #18
0
ファイル: invoiceEntity.inc.php プロジェクト: cjbayliss/alloc
 function save_invoice_productSaleItems($invoiceID, $productSaleID)
 {
     $productSale = new productSale();
     $productSale->set_id($productSaleID);
     $productSale->select();
     $db = new db_alloc();
     $q = prepare("SELECT * FROM productSaleItem WHERE productSaleID = %d", $productSale->get_id());
     $q1 = $db->query($q);
     while ($row = $db->row($q1)) {
         $q = prepare("SELECT * FROM invoiceItem WHERE productSaleID = %d AND productSaleItemID = %d", $productSaleID, $row["productSaleItemID"]);
         $db = new db_alloc();
         $q2 = $db->query($q);
         $r2 = $db->row($q2);
         $ii = new invoiceItem();
         if ($r2) {
             $ii->set_id($r2["invoiceItemID"]);
         }
         $ii->currency = $row["sellPriceCurrencyTypeID"];
         $ii->set_value("invoiceID", $invoiceID);
         $ii->set_value("productSaleID", $productSale->get_id());
         $ii->set_value("productSaleItemID", $row["productSaleItemID"]);
         $ii->set_value("iiMemo", "Sale (" . $productSale->get_id() . ") item for " . person::get_fullname($productSale->get_value("personID")) . ", " . $row["description"]);
         $ii->set_value("iiQuantity", $row["quantity"]);
         $row["sellPrice"] = page::money($ii->currency, $row["sellPrice"] / $row["quantity"], "%mo");
         $ii->set_value("iiUnitPrice", $row["sellPrice"]);
         $ii->set_value("iiAmount", $row["sellPrice"] * $row["quantity"]);
         $d = $productSale->get_value("productSaleDate") or $d = $productSale->get_value("productSaleModifiedTime") or $d = $productSale->get_value("productSaleCreatedTime");
         $ii->set_value("iiDate", $d);
         //$ii->set_value("iiTax",config::get_config_item("taxPercent")); // product sale items are always excl GST
         $ii->save();
     }
 }
コード例 #19
0
 function get_timeSheetItem_list_money($timeSheetID)
 {
     global $TPL;
     list($db, $customerBilledDollars, $timeSheet, $unit_array, $currency) = $this->get_timeSheetItem_vars($timeSheetID);
     $taxPercent = config::get_config_item("taxPercent");
     $taxPercentDivisor = $taxPercent / 100 + 1;
     while ($db->next_record()) {
         $timeSheetItem = new timeSheetItem();
         $timeSheetItem->read_db_record($db);
         $taskID = sprintf("%d", $timeSheetItem->get_value("taskID"));
         $num = $timeSheetItem->calculate_item_charge($currency, $customerBilledDollars ? $customerBilledDollars : $timeSheetItem->get_value("rate"));
         if ($taxPercent !== '') {
             $num_minus_gst = $num / $taxPercentDivisor;
             $gst = $num - $num_minus_gst;
             if ($num_minus_gst + $gst != $num) {
                 $num_minus_gst += $num - ($num_minus_gst + $gst);
                 // round it up.
             }
             $rows[$taskID]["money"] += page::money($timeSheet->get_value("currencyTypeID"), $num_minus_gst, "%mo");
             $rows[$taskID]["gst"] += page::money($timeSheet->get_value("currencyTypeID"), $gst, "%mo");
             $info["total_gst"] += $gst;
             $info["total"] += $num_minus_gst;
         } else {
             $rows[$taskID]["money"] += page::money($timeSheet->get_value("currencyTypeID"), $num, "%mo");
             $info["total"] += $num;
         }
         $unit = $unit_array[$timeSheetItem->get_value("timeSheetItemDurationUnitID")];
         $units[$taskID][$unit] += sprintf("%0.2f", $timeSheetItem->get_value("timeSheetItemDuration") * $timeSheetItem->get_value("multiplier"));
         unset($str);
         $d = $timeSheetItem->get_value('taskID', DST_HTML_DISPLAY) . ": " . $timeSheetItem->get_value('description', DST_HTML_DISPLAY);
         $d && !$rows[$taskID]["desc"] and $str[] = "<b>" . $d . "</b>";
         //inline because the PDF needs it that way
         // Get task description
         if ($taskID && $TPL["printDesc"]) {
             $t = new task();
             $t->set_id($taskID);
             $t->select();
             $d2 = str_replace("\r\n", "\n", $t->get_value("taskDescription", DST_HTML_DISPLAY));
             $d2 .= "\n";
             $d2 && !$d2s[$taskID] and $str[] = $d2;
             $d2 and $d2s[$taskID] = true;
         }
         $c = str_replace("\r\n", "\n", $timeSheetItem->get_value("comment"));
         !$timeSheetItem->get_value("commentPrivate") && $c and $str[] = page::htmlentities($c);
         is_array($str) and $rows[$taskID]["desc"] .= trim(implode(DEFAULT_SEP, $str));
     }
     // Group by units ie, a particular row/task might have  3 Weeks, 2 Hours of work done.
     $units or $units = array();
     foreach ($units as $tid => $u) {
         unset($commar);
         foreach ($u as $unit => $amount) {
             $rows[$tid]["units"] .= $commar . $amount . " " . $unit;
             $commar = ", ";
             $i[$unit] += $amount;
         }
     }
     unset($commar);
     $i or $i = array();
     foreach ($i as $unit => $amount) {
         $info["total_units"] .= $commar . $amount . " " . $unit;
         $commar = ", ";
     }
     $info["total_inc_gst"] = page::money($timeSheet->get_value("currencyTypeID"), $info["total"] + $info["total_gst"], "%s%mo");
     // If we are in dollar mode, then prefix the total with a dollar sign
     $info["total"] = page::money($timeSheet->get_value("currencyTypeID"), $info["total"], "%s%mo");
     $info["total_gst"] = page::money($timeSheet->get_value("currencyTypeID"), $info["total_gst"], "%s%mo");
     $rows or $rows = array();
     $info or $info = array();
     return array($rows, $info);
 }
コード例 #20
0
ファイル: timeSheet.inc.php プロジェクト: cjbayliss/alloc
 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);
         }
     }
 }
コード例 #21
0
ファイル: wagesUpload.php プロジェクト: cjbayliss/alloc
 // Convert the date to yyyy-mm-dd
 if (!preg_match("|^([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})\$|i", $transactionDate, $matches)) {
     $msg .= "<b>Warning: Could not convert date '{$transactionDate}'</b><br>";
     continue;
 }
 $transactionDate = sprintf("%04d-%02d-%02d", $matches[3], $matches[2], $matches[1]);
 // Strip $ and , from amount
 $amount = str_replace(array('$', ','), array(), $amount);
 if (!preg_match("/^[-]?[0-9]+(\\.[0-9]+)?\$/", $amount)) {
     $msg .= "<b>Warning: Could not convert amount '{$amount}'</b><br>";
     continue;
 }
 // Negate the amount - Wages are a debit from TF's
 $amount = -$amount;
 // Check for an existing transaction for this wage - note we have to use a range or amount because it is floating point
 $query = prepare("SELECT transactionID\n                        FROM transaction\n                        WHERE fromTfID=%d AND transactionDate='%s' AND amount=%d", $fromTfID, $transactionDate, page::money(config::get_config_item("currency"), $amount, "%mi"));
 $db->query($query);
 if ($db->next_record()) {
     $msg .= "Warning: Salary for employee #{$employeeNum} {$name} on {$transactionDate} already exists as transaction #" . $db->f("transactionID") . "<br>";
     continue;
 }
 // Create a transaction object and then save it
 $transaction = new transaction();
 $transaction->set_value("currencyTypeID", config::get_config_item("currency"));
 $transaction->set_value("fromTfID", $fromTfID);
 $transaction->set_value("tfID", config::get_config_item("outTfID"));
 $transaction->set_value("transactionDate", $transactionDate);
 $transaction->set_value("amount", $amount);
 $transaction->set_value("companyDetails", "");
 $transaction->set_value("product", $account);
 $transaction->set_value("status", "approved");
コード例 #22
0
ファイル: timeSheet.php プロジェクト: cjbayliss/alloc
function show_new_timeSheet($template)
{
    global $TPL;
    global $timeSheet;
    global $timeSheetID;
    $current_user =& singleton("current_user");
    // Don't show entry form for new timeSheet.
    if (!$timeSheetID) {
        return;
    }
    if (is_object($timeSheet) && ($timeSheet->get_value("status") == 'edit' || $timeSheet->get_value("status") == 'rejected') && ($timeSheet->get_value("personID") == $current_user->get_id() || $timeSheet->have_perm(PERM_TIME_INVOICE_TIMESHEETS))) {
        $TPL["currency"] = page::money($timeSheet->get_value("currencyTypeID"), '', "%S");
        // If we are editing an existing timeSheetItem
        $timeSheetItem_edit = $_POST["timeSheetItem_edit"] or $timeSheetItem_edit = $_GET["timeSheetItem_edit"];
        $timeSheetItemID = $_POST["timeSheetItemID"] or $timeSheetItemID = $_GET["timeSheetItemID"];
        if ($timeSheetItemID && $timeSheetItem_edit) {
            $timeSheetItem = new timeSheetItem();
            $timeSheetItem->currency = $timeSheet->get_value("currencyTypeID");
            $timeSheetItem->set_id($timeSheetItemID);
            $timeSheetItem->select();
            $timeSheetItem->set_values("tsi_");
            $TPL["tsi_rate"] = $timeSheetItem->get_value("rate", DST_HTML_DISPLAY);
            $taskID = $timeSheetItem->get_value("taskID");
            $TPL["tsi_buttons"] = '
         <button type="submit" name="timeSheetItem_delete" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
         <button type="submit" name="timeSheetItem_save" value="1" class="save_button default">Save Item<i class="icon-ok-sign"></i></button>
         ';
            $timeSheetItemDurationUnitID = $timeSheetItem->get_value("timeSheetItemDurationUnitID");
            $TPL["tsi_commentPrivate"] and $TPL["commentPrivateChecked"] = " checked";
            $TPL["ts_rate_editable"] = $timeSheet->can_edit_rate();
            $timeSheetItemMultiplier = $timeSheetItem->get_value("multiplier");
            // Else default values for creating a new timeSheetItem
        } else {
            $TPL["tsi_buttons"] = '<button type="submit" name="timeSheetItem_save" value="1" class="save_button">Add Item<i class="icon-plus-sign"></i></button>';
            $TPL["tsi_personID"] = $current_user->get_id();
            $timeSheet->load_pay_info();
            $TPL["tsi_rate"] = $timeSheet->pay_info["project_rate"];
            $timeSheetItemDurationUnitID = $timeSheet->pay_info["project_rateUnitID"];
            $TPL["ts_rate_editable"] = $timeSheet->can_edit_rate();
        }
        $taskID or $taskID = $_GET["taskID"];
        $TPL["taskListDropdown_taskID"] = $taskID;
        $TPL["taskListDropdown"] = $timeSheet->get_task_list_dropdown("mine", $timeSheet->get_id(), $taskID);
        $TPL["tsi_timeSheetID"] = $timeSheet->get_id();
        $timeUnit = new timeUnit();
        $unit_array = $timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelA");
        $TPL["tsi_unit_options"] = page::select_options($unit_array, $timeSheetItemDurationUnitID);
        $timeSheetItemDurationUnitID and $TPL["tsi_unit_label"] = $unit_array[$timeSheetItemDurationUnitID];
        $m = new meta("timeSheetItemMultiplier");
        $tsMultipliers = $m->get_list();
        foreach ($tsMultipliers as $k => $v) {
            $multiplier_array[$k] = $v["timeSheetItemMultiplierName"];
        }
        $TPL["tsi_multiplier_options"] = page::select_options($multiplier_array, $timeSheetItemMultiplier);
        include_template($template);
    }
}
コード例 #23
0
ファイル: tf.inc.php プロジェクト: cjbayliss/alloc
 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;
 }
コード例 #24
0
ファイル: invoiceItem.inc.php プロジェクト: cjbayliss/alloc
 public static function get_list($_FORM)
 {
     $filter = invoiceItem::get_list_filter($_FORM);
     if (is_array($filter) && count($filter)) {
         $f = " WHERE " . implode(" AND ", $filter);
     }
     $q = prepare("SELECT * FROM invoiceItem \n               LEFT JOIN invoice ON invoice.invoiceID = invoiceItem.invoiceID\n               LEFT JOIN client ON client.clientID = invoice.clientID\n               " . $f);
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->row()) {
         $row["iiAmount"] = page::money($row["currencyTypeID"], $row["iiAmount"], "%mo");
         $row["iiUnitPrice"] = page::money($row["currencyTypeID"], $row["iiUnitPrice"], "%mo");
         $rows[$row["invoiceItemID"]] = $row;
     }
     return (array) $rows;
 }
コード例 #25
0
ファイル: page.inc.php プロジェクト: cjbayliss/alloc
 public static function money_print($rows = array())
 {
     $mainCurrency = config::get_config_item("currency");
     foreach ((array) $rows as $row) {
         $sums[$row["currency"]] += $row["amount"];
         $k = $row["currency"];
     }
     // If there's only one currency, then just return that figure.
     if (count($sums) == 1) {
         return page::money($k, $sums[$k], "%s%m %c");
     }
     // Else if there's more than one currency, we'll provide a tooltip of the aggregation.
     foreach ((array) $sums as $currency => $amount) {
         $str .= $sep . page::money($currency, $amount, "%s%m %c");
         $sep = " + ";
         if ($mainCurrency == $currency) {
             $total += $amount;
         } else {
             $total += exchangeRate::convert($currency, $amount);
         }
     }
     $total = page::money($mainCurrency, $total, "%s%m %c");
     if ($str && $str != $total) {
         $rtn = page::help(page::exclaim() . "<b>Approximate currency conversion</b><br>" . $str . " = " . $total, page::exclaim() . $total);
     } else {
         if ($str) {
             $rtn = $str;
         }
     }
     return $rtn;
 }
コード例 #26
0
ファイル: config.php プロジェクト: cjbayliss/alloc
         $y = imagesy($img);
         $save = imagecreatetruecolor($x / ($y / 40), $y / ($y / 40));
         imagecopyresized($save, $img, 0, 0, 0, 0, imagesx($save), imagesy($save), $x, $y);
         imagejpeg($save, ALLOC_LOGO_SMALL, 100);
     }
 }
 foreach ($_POST as $name => $value) {
     if (in_array($name, $fields_to_save)) {
         $id = config::get_config_item_id($name);
         $c = new config();
         $c->set_id($id);
         $c->select();
         if ($types[$name] == "text") {
             //current special case for the only money field
             if ($name == "defaultTimeSheetRate") {
                 $value = page::money(0, $_POST[$name], "%mi");
                 $c->set_value("value", $value);
             } else {
                 $c->set_value("value", $_POST[$name]);
             }
             $TPL[$name] = page::htmlentities($value);
         } else {
             if ($types[$name] == "array") {
                 $c->set_value("value", serialize($_POST[$name]));
                 $TPL[$name] = $_POST[$name];
             }
         }
         $c->save();
         $TPL["message_good"] = "Saved configuration.";
     }
 }
コード例 #27
0
ファイル: checkRepeat.php プロジェクト: cjbayliss/alloc
 $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());
 $id2 = $db->query($q);
 while ($item = $db->row($id2)) {
     $ii = new invoiceItem();
     $ii->currency = $i->get_value("currencyTypeID");
     $ii->set_value("invoiceID", $i->get_id());
     $ii->set_value("iiMemo", $item["iiMemo"]);
     $ii->set_value("iiUnitPrice", page::money($ii->currency, $item["iiUnitPrice"], "%mo"));
     $ii->set_value("iiAmount", page::money($ii->currency, $item["iiAmount"], "%mo"));
     $ii->set_value("iiQuantity", $item["iiQuantity"]);
     $ii->save();
     #echo "<br>Created invoice item: ".$ii->get_id();
 }
 if ($row["message"]) {
     $ips = interestedParty::get_interested_parties("invoiceRepeat", $row["invoiceRepeatID"]);
     $recipients = array();
     foreach ($ips as $email => $info) {
         $recipients[$email] = $info;
         $recipients[$email]["addIP"] = true;
     }
     $commentID = comment::add_comment("invoice", $i->get_id(), $row["message"], "invoice", $i->get_id());
     if ($recipients) {
         $emailRecipients = comment::add_interested_parties($commentID, null, $recipients);
         comment::attach_invoice($commentID, $i->get_id(), $verbose = true);