Example #1
0
function show_finance_options($template)
{
    global $finance_options;
    global $TPL;
    foreach ($finance_options as $option) {
        if ($option["entity"] != "") {
            if (have_entity_perm($option["entity"], $option["action"], $current_user, true)) {
                $TPL["url"] = $TPL["url_alloc_" . $option["url"]];
                $TPL["params"] = $option["params"];
                $TPL["text"] = $option["text"];
                $TPL["br"] = "<br>\n";
                $option["br"] and $TPL["br"] = "<br><br>\n";
                include_template($template);
            }
        } else {
            if ($option["function"]) {
                $f = $option["function"];
                if ($f()) {
                    $TPL["url"] = $TPL["url_alloc_" . $option["url"]];
                    $TPL["params"] = $option["params"];
                    $TPL["text"] = $option["text"];
                    $TPL["br"] = "<br>\n";
                    $option["br"] and $TPL["br"] = "<br><br>\n";
                    include_template($template);
                }
            }
        }
    }
}
Example #2
0
function show_overdue($template_name)
{
    global $db;
    global $TPL;
    $current_user =& singleton("current_user");
    $db = new db_alloc();
    $temp = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
    $today = date("Y", $temp) . "-" . date("m", $temp) . "-" . date("d", $temp);
    $q = prepare("SELECT itemName,itemType,item.itemID,dateBorrowed,dateToBeReturned,loan.personID \n                  FROM loan,item \n                 WHERE dateToBeReturned < '%s' \n\t\t\t\t\t         AND dateReturned = '0000-00-00' \n\t\t\t\t\t         AND item.itemID = loan.itemID\n               ", $today);
    if (!have_entity_perm("loan", PERM_READ, $current_user, false)) {
        $q .= prepare("AND loan.personID = %d", $current_user->get_id());
    }
    $db->query($q);
    while ($db->next_record()) {
        $i++;
        $item = new item();
        $loan = new loan();
        $item->read_db_record($db);
        $loan->read_db_record($db);
        $item->set_values();
        $loan->set_values();
        $person = new person();
        $person->set_id($loan->get_value("personID"));
        $person->select();
        $TPL["person"] = $person->get_name();
        $TPL["overdue"] = "<a href=\"" . $TPL["url_alloc_item"] . "itemID=" . $item->get_id() . "&return=true\">Overdue!</a>";
        include_template($template_name);
    }
}
Example #3
0
 * 
 * allocPSA is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "../alloc.php";
if (!have_entity_perm("config", PERM_UPDATE, $current_user, true)) {
    alloc_error("Permission denied.", true);
}
if ($_POST["test_email_gateway"]) {
    $info["host"] = config::get_config_item("allocEmailHost");
    $info["port"] = config::get_config_item("allocEmailPort");
    $info["username"] = config::get_config_item("allocEmailUsername");
    $info["password"] = config::get_config_item("allocEmailPassword");
    $info["protocol"] = config::get_config_item("allocEmailProtocol");
    if (!$info["host"]) {
        alloc_error("Email mailbox host not defined, assuming email receive function is inactive.");
    } else {
        $mail = new email_receive($info, $lockfile);
        $mail->open_mailbox(config::get_config_item("allocEmailFolder"));
        $mail->check_mail();
        $TPL["message_good"][] = "Connection succeeded!";
Example #4
0
        $transactionRepeat->save();
        alloc_redirect($TPL["url_alloc_transactionRepeat"] . "transactionRepeatID=" . $transactionRepeat->get_id());
    }
    $transactionRepeat->set_values();
}
$TPL["reimbursementRequired_checked"] = $transactionRepeat->get_value("reimbursementRequired") ? " checked" : "";
if ($transactionRepeat->get_value("transactionRepeatModifiedUser")) {
    $db->query("select username from person where personID=%d", $transactionRepeat->get_value("transactionRepeatModifiedUser"));
    $db->next_record();
    $TPL["user"] = $db->f("username");
}
if (have_entity_perm("tf", PERM_READ, $current_user, false)) {
    // Person can access all TF records
    $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")) {
Example #5
0
 * 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";
singleton("errors_thrown", true);
if (!have_entity_perm("inbox", PERM_READ, $current_user)) {
    alloc_error("Permission denied.", true);
}
$info = inbox::get_mail_info();
if (!$info["host"]) {
    alloc_error("Email mailbox host not defined, assuming email function is inactive.", true);
}
if ($_REQUEST["id"] && $_REQUEST["hash"] && !inbox::verify_hash($_REQUEST["id"], $_REQUEST["hash"])) {
    alloc_error("The IMAP ID for that email is no longer valid. Refresh the list and try again.");
} else {
    if ($_REQUEST["id"] && $_REQUEST["hash"]) {
        $_REQUEST["archive"] && inbox::archive_email($_REQUEST);
        // archive the email by moving it to another folder
        $_REQUEST["download"] && inbox::download_email($_REQUEST);
        // download it to a mbox file
        $_REQUEST["process"] && inbox::process_email($_REQUEST);
Example #6
0
 function load_productSale_filter($_FORM)
 {
     $current_user =& singleton("current_user");
     // display the list of project name.
     $db = new db_alloc();
     if (!$_FORM['showAllProjects']) {
         $filter = "WHERE projectStatus = 'Current' ";
     }
     $query = prepare("SELECT projectID AS value, projectName AS label FROM project {$filter} ORDER by projectName");
     $rtn["show_project_options"] = page::select_options($query, $_FORM["projectID"], 70);
     // display the list of user name.
     if (have_entity_perm("productSale", PERM_READ, $current_user, false)) {
         $rtn["show_userID_options"] = page::select_options(person::get_username_list(), $_FORM["personID"]);
     } else {
         $person = new person();
         $person->set_id($current_user->get_id());
         $person->select();
         $person_array = array($current_user->get_id() => $person->get_name());
         $rtn["show_userID_options"] = page::select_options($person_array, $_FORM["personID"]);
     }
     // display a list of status
     $status_array = productSale::get_statii();
     unset($status_array["create"]);
     $rtn["show_status_options"] = page::select_options($status_array, $_FORM["status"]);
     // display the date from filter value
     $rtn["showAllProjects"] = $_FORM["showAllProjects"];
     $options["clientStatus"] = array("Current");
     $options["return"] = "dropdown_options";
     $ops = client::get_list($options);
     $ops = array_kv($ops, "clientID", "clientName");
     $rtn["clientOptions"] = page::select_options($ops, $_FORM["clientID"]);
     // Get
     $rtn["FORM"] = "FORM=" . urlencode(serialize($_FORM));
     return $rtn;
 }
Example #7
0
 function load_timeSheet_filter($_FORM)
 {
     $current_user =& singleton("current_user");
     // display the list of project name.
     $db = new db_alloc();
     if (!$_FORM['showAllProjects']) {
         $filter = "WHERE projectStatus = 'Current' ";
     }
     $query = prepare("SELECT projectID AS value, projectName AS label FROM project {$filter} ORDER by projectName");
     $rtn["show_project_options"] = page::select_options($query, $_FORM["projectID"], 70);
     // display the list of user name.
     if (have_entity_perm("timeSheet", PERM_READ, $current_user, false)) {
         $rtn["show_userID_options"] = page::select_options(person::get_username_list(), $_FORM["personID"]);
     } else {
         $person = new person();
         $person->set_id($current_user->get_id());
         $person->select();
         $person_array = array($current_user->get_id() => $person->get_name());
         $rtn["show_userID_options"] = page::select_options($person_array, $_FORM["personID"]);
     }
     // display a list of status
     $status_array = timeSheet::get_timeSheet_statii();
     unset($status_array["create"]);
     if (!$_FORM["status"]) {
         $_FORM["status"][] = 'edit';
     }
     $rtn["show_status_options"] = page::select_options($status_array, $_FORM["status"]);
     // display the date from filter value
     $rtn["dateFrom"] = $_FORM["dateFrom"];
     $rtn["dateTo"] = $_FORM["dateTo"];
     $rtn["userID"] = $current_user->get_id();
     $rtn["showFinances"] = $_FORM["showFinances"];
     $rtn["showAllProjects"] = $_FORM["showAllProjects"];
     // Get
     $rtn["FORM"] = "FORM=" . urlencode(serialize($_FORM));
     return $rtn;
 }
Example #8
0
 public static function extra_links()
 {
     $current_user =& singleton("current_user");
     global $TPL;
     global $sess;
     $str = "<a href=\"" . $TPL["url_alloc_starList"] . "\" class=\"icon-star\"></a>&nbsp;&nbsp;&nbsp;";
     $str .= $current_user->get_link() . "&nbsp;&nbsp;&nbsp;";
     if (defined("PAGE_IS_PRINTABLE") && PAGE_IS_PRINTABLE) {
         $sess or $sess = new session();
         $str .= "<a href=\"" . $sess->url($_SERVER["REQUEST_URI"]) . "media=print\">Print</a>&nbsp;&nbsp;&nbsp;";
     }
     if (have_entity_perm("config", PERM_UPDATE, $current_user, true)) {
         $str .= "<a href=\"" . $TPL["url_alloc_config"] . "\">Setup</a>&nbsp;&nbsp;&nbsp;";
     }
     $url = $sess->url("../help/help.php?topic=" . $TPL["alloc_help_link_name"]);
     $str .= "<a href=\"" . $url . "\">Help</a>&nbsp;&nbsp;&nbsp;";
     $url = $TPL["url_alloc_logout"];
     $str .= "<a href=\"" . $url . "\">Logout</a>";
     return $str;
 }
Example #9
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;
 }