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; }
function __construct($week_start = 1, $weeks_to_display = 4) { $this->db = new db_alloc(); $this->first_day_of_week = config::get_config_item("calendarFirstDay"); $this->set_cal_date_range($week_start, $weeks_to_display); $this->days_of_week = $this->get_days_of_week_array($this->first_day_of_week); }
function get() { // Check if we're using a VCS $class = "vcs_" . config::get_config_item("wikiVCS"); if (class_exists($class)) { $vcs = new $class(wiki_module::get_wiki_path()); } return $vcs; }
function visible() { $current_user =& singleton("current_user"); if (isset($current_user) && $current_user->is_employee()) { $timeSheetAdminPersonIDs = config::get_config_item("defaultTimeSheetAdminList"); if (in_array($current_user->get_id(), $timeSheetAdminPersonIDs) && has_pending_admin_timesheet()) { return true; } } }
function Start($row, $nuke_prev_sessions = true) { $this->key = md5($row["personID"] . "mix it up#@!" . md5(mktime() . md5(microtime()))); $this->Put("session_started", mktime()); if ($nuke_prev_sessions && config::get_config_item("singleSession")) { $this->db->query("DELETE FROM sess WHERE personID = %d", $row["personID"]); } $this->db->query("INSERT INTO sess (sessID,sessData,personID) VALUES ('%s','%s',%d)", $this->key, $this->Encode($this->session_data), $row["personID"]); $this->Put("username", strtolower($row["username"])); $this->Put("perms", $row["perms"]); $this->Put("personID", $row["personID"]); }
function apply_patch($f) { global $TPL; static $files; // Should never attempt to apply the same patch twice.. in case // there are function declarations in the .php patches. if ($files[$f]) { return; } $files[$f] = true; $db = new db_alloc(); $file = basename($f); $failed = false; $comments = array(); // This is an important patch that converts money from 120.34 to 12034. // We MUST ensure that the user has a currency set before applying this patch. if ($file == "patch-00188-alla.sql") { if (!config::get_config_item('currency')) { alloc_error("No default currency is set! Login to alloc (ignore any errors, you may need to manually change the url to config/config.php after logging in) go to Setup -> Finance and select a Main Currency. And then click the 'Update Transactions That Have No Currency' button. Then return here and apply this patch (patch-188). IT IS REALLY IMPORTANT THAT YOU FOLLOW THESE INSTRUCTIONS as the storage format for monetary amounts has changed.", true); } } // Try for sql file if (strtolower(substr($file, -4)) == ".sql") { list($sql, $comments) = parse_sql_file($f); foreach ($sql as $query) { if (!$db->query($query)) { #$TPL["message"][] = "<b style=\"color:red\">Error:</b> ".$f."<br>".$db->get_error(); $failed = true; alloc_error("<b style=\"color:red\">Error:</b> " . $f . "<br>" . $db->get_error()); } } if (!$failed) { $TPL["message_good"][] = "Successfully Applied: " . $f; } // Try for php file } else { if (strtolower(substr($file, -4)) == ".php") { $str = execute_php_file("../patches/" . $file); if ($str && !defined("FORCE_PATCH_SUCCEED_" . $file)) { #$TPL["message"][] = "<b style=\"color:red\">Error:</b> ".$f."<br>".$str; $failed = true; ob_end_clean(); alloc_error("<b style=\"color:red\">Error:</b> " . $f . "<br>" . $str); } else { $TPL["message_good"][] = "Successfully Applied: " . $f; } } } if (!$failed) { $q = prepare("INSERT INTO patchLog (patchName, patchDesc, patchDate) \n VALUES ('%s','%s','%s')", $file, implode(" ", $comments), date("Y-m-d H:i:s")); $db->query($q); } }
function show_all_exp($template) { global $TPL; global $expenseForm; global $db; global $transaction_to_edit; if ($expenseForm->get_id()) { if ($_POST["transactionID"] && ($_POST["edit"] || is_object($transaction_to_edit) && $transaction_to_edit->get_id())) { // if edit is clicked OR if we've rejected changes made to something so are still editing it $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d AND transactionID<>%d ORDER BY transactionID DESC", $expenseForm->get_id(), $_POST["transactionID"]); } else { $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d ORDER BY transactionID DESC", $expenseForm->get_id()); } $db->query($query); while ($db->next_record()) { $transaction = new transaction(); $transaction->read_db_record($db); $transaction->set_values(); $transaction->get_value("quantity") and $TPL["amount"] = $transaction->get_value("amount") / $transaction->get_value("quantity"); $TPL["lineTotal"] = $TPL["amount"] * $transaction->get_value("quantity"); $tf = new tf(); $tf->set_id($transaction->get_value("fromTfID")); $tf->select(); $TPL["fromTfIDLink"] = $tf->get_link(); $tf = new tf(); $tf->set_id($transaction->get_value("tfID")); $tf->select(); $TPL["tfIDLink"] = $tf->get_link(); $projectID = $transaction->get_value("projectID"); if ($projectID) { $project = new project(); $project->set_id($transaction->get_value("projectID")); $project->select(); $TPL["projectName"] = $project->get_value("projectName"); } if ($transaction->get_value("fromTfID") == config::get_config_item("expenseFormTfID")) { $TPL['expense_class'] = "loud"; } else { $TPL['expense_class'] = ""; } include_template($template); } } }
public static function download() { // Get default currency $default_currency = config::get_config_item("currency"); // Get list of active currencies $meta = new meta("currencyType"); $currencies = $meta->get_list(); foreach ((array) $currencies as $code => $currency) { if ($code == $default_currency) { continue; } if ($ret = exchangeRate::update_rate($code, $default_currency)) { $rtn[] = $ret; } if ($ret = exchangeRate::update_rate($default_currency, $code)) { $rtn[] = $ret; } } return $rtn; }
function show_productSale_new($template) { global $TPL; global $productSaleItemsDoExist; global $productSaleID; $taxName = config::get_config_item("taxName"); $productSaleItem = new productSaleItem(); $productSaleItem->set_values(); // wipe clean $product = new product(); $ops = $product->get_assoc_array("productID", "productName"); $TPL["productList_dropdown"] = page::select_options($ops, $productSaleItem->get_value("productID")); $productSaleItemsDoExist and $TPL["display"] = "display:none"; if ($taxName) { $TPL["sellPriceTax_check"] = sprintf(" <input type='checkbox' name='sellPriceIncTax[]' value='1'%s> inc %s", $productSaleItem->get_value("sellPriceIncTax") ? ' checked' : '', $taxName); } $TPL["psid"] = $productSaleID; // poorly named template variable to prevent clobbering include_template($template); }
function get_file($file, $rev = "") { global $TPL; $f = realpath(wiki_module::get_wiki_path() . $file); if (path_under_path(dirname($f), wiki_module::get_wiki_path())) { $mt = get_mimetype($f); if (strtolower($mt) != "text/plain") { $s = "<h6>Download File</h6>"; $s .= "<a href='" . $TPL["url_alloc_fileDownload"] . "file=" . urlencode($file) . "'>" . $file . "</a>"; $TPL["str_html"] = $s; include_template("templates/fileGetM.tpl"); exit; } // Get the regular revision ... $disk_file = file_get_contents($f) or $disk_file = ""; $vcs = vcs::get(); //$vcs->debug = true; // Get a particular revision if ($vcs) { $vcs_file = $vcs->cat($f, $rev); } if ($vcs && wiki_module::nuke_trailing_spaces_from_all_lines($disk_file) != wiki_module::nuke_trailing_spaces_from_all_lines($vcs_file)) { if (!$vcs_file) { $TPL["msg"] = "<div class='message warn noprint' style='margin-top:0px; margin-bottom:10px; padding:10px;'>\n Warning: This file may not be under version control.\n </div>"; } else { $TPL["msg"] = "<div class='message warn noprint' style='margin-top:0px; margin-bottom:10px; padding:10px;'>\n Warning: This file may not be the latest version.\n </div>"; } } if ($rev && $vcs_file) { $TPL["str"] = $vcs_file; } else { $TPL["str"] = $disk_file; } $wikiMarkup = config::get_config_item("wikiMarkup"); $TPL["str_html"] = $wikiMarkup($TPL["str"]); $TPL["rev"] = urlencode($rev); include_template("templates/fileGetM.tpl"); } }
<?php $extra = config::get_config_item("defaultInterestedParties"); $db = new db_alloc(); foreach ((array) $extra as $name => $email) { $db->query("UPDATE interestedParty set external = null WHERE emailAddress = '%s'", $email); }
<?php // Change email default From email addresses from Alex Lance <*****@*****.**> to alla@cyber.com.dsa $email = config::get_config_item("AllocFromEmailAddress"); $email = preg_replace("/^.*</", "", $email); $email = str_replace(">", "", $email); $configID = config::get_config_item_id("AllocFromEmailAddress"); $c = new config(); $c->set_id($configID); $c->select(); $c->set_value("value", $email); $c->save();
function find_email($debug = false, $get_blobs = false, $ignore_date = false) { $info = inbox::get_mail_info(); $mailbox = $this->get_value("commentMaster") . $this->get_value("commentMasterID"); $mail = new email_receive($info); $mail->open_mailbox(config::get_config_item("allocEmailFolder") . "/" . $mailbox, OP_HALFOPEN + OP_READONLY); $mail->check_mail(); $msg_nums = $mail->get_all_email_msg_uids(); $debug and print "<hr><br><b>find_email(): " . date("Y-m-d H:i:s") . " found " . count($msg_nums) . " emails for mailbox: " . $mailbox . "</b>"; // fetch and parse email foreach ((array) $msg_nums as $num) { $debug and print "<hr><br>Examining message number: " . $num; unset($mimebits); // this will stream output $mail->set_msg($num); $mail->get_msg_header(); $text = $mail->fetch_mail_text(); list($from1, $e1n) = parse_email_address($mail->mail_headers["from"]); list($from2, $e2n) = parse_email_address($this->get_value("commentCreatedUserText")); if (!$from2 && $this->get_value("commentCreatedUser")) { $p = new person(); $p->set_id($this->get_value("commentCreatedUser")); $p->select(); $from2 = $p->get_value("emailAddress"); } if (!$from2 && $this->get_value("commentCreatedUserClientContactID")) { $p = new clientContact(); $p->set_id($this->get_value("commentCreatedUserClientContactID")); $p->select(); $from2 = $p->get_value("clientContactEmail"); } $text1 = str_replace(array("\\s", "\n", "\r"), "", trim($text)); $text2 = str_replace(array("\\s", "\n", "\r"), "", trim($this->get_value("comment"))); $date = format_date("U", $this->get_value("commentCreatedTime")); $date1 = strtotime($mail->mail_headers["date"]) - 300; $date3 = strtotime($mail->mail_headers["date"]) + 300; similar_text($text1, $text2, $percent); if ($percent >= 99 && ($from1 == $from2 || !$from2 || same_email_address($from1, config::get_config_item("AllocFromEmailAddress"))) && ($date > $date1 && $date < $date3 || $ignore_date)) { $debug and print "<br><b style='color:green'>Found you! Msg no: " . $num . " in mailbox: " . $mailbox . " for commentID: " . $this->get_id() . "</b>"; foreach ((array) $mail->mail_parts as $v) { $s = $v["part_object"]; // structure $raw_data = imap_fetchbody($mail->connection, $mail->msg_uid, $v["part_number"], FT_UID | FT_PEEK); $thing = $mail->decode_part($s->encoding, $raw_data); $filename = $mail->get_parameter_attribute_value($s->parameters, "name"); $filename or $filename = $mail->get_parameter_attribute_value($s->parameters, "filename"); $filename or $filename = $mail->get_parameter_attribute_value($s->dparameters, "name"); $filename or $filename = $mail->get_parameter_attribute_value($s->dparameters, "filename"); $bits = array(); $bits["part"] = $v["part_number"]; $bits["name"] = $filename; $bits["size"] = strlen($thing); $get_blobs and $bits["blob"] = $thing; $filename and $mimebits[] = $bits; } $mail->close(); return array($mail, $text, $mimebits); } else { similar_text($text1, $text2, $percent); $debug and print "<br>TEXT: " . sprintf("%d", $text1 == $text2) . " (" . sprintf("%d", $percent) . "%)"; #$debug and print "<br>Text1:<br>".$text1."<br>* * *<br>"; #$debug and print "Text2:<br>".$text2."<br>+ + +</br>"; $debug and print "<br>FROM: " . sprintf("%d", $from1 == $from2 || !$from2 || same_email_address($from1, config::get_config_item("AllocFromEmailAddress"))); $debug and print " From1: " . page::htmlentities($from1); $debug and print " From2: " . page::htmlentities($from2); $debug and print "<br>DATE: " . sprintf("%d", $date > $date1 && $date < $date3) . " (" . date("Y-m-d H:i:s", $date) . " | " . date("Y-m-d H:i:s", $date1) . " | " . date("Y-m-d H:i:s", $date3) . ")"; $debug and print "<br>"; } } $mail->close(); return array(false, false, false); }
if ($tf->select() && !$tf->get_value("tfActive")) { $TPL["message_help"][] = "This expense is allocated to an inactive TF. It will not create transactions."; } $tf = new tf(); $tf->set_id($transactionRepeat->get_value("fromTfID")); if ($tf->select() && !$tf->get_value("tfActive")) { $TPL["message_help"][] = "This expense is sourced from an inactive TF. It will not create transactions."; } $m = new meta("currencyType"); $currencyOps = $m->get_assoc_array("currencyTypeID", "currencyTypeID"); $TPL["currencyTypeOptions"] = page::select_options($currencyOps, $transactionRepeat->get_value("currencyTypeID")); $TPL["tfOptions"] = page::select_options($q, $transactionRepeat->get_value("tfID")); $TPL["fromTfOptions"] = page::select_options($q, $transactionRepeat->get_value("fromTfID")); $TPL["basisOptions"] = page::select_options(array("weekly" => "weekly", "fortnightly" => "fortnightly", "monthly" => "monthly", "quarterly" => "quarterly", "yearly" => "yearly"), $transactionRepeat->get_value("paymentBasis")); $TPL["transactionTypeOptions"] = page::select_options(transaction::get_transactionTypes(), $transactionRepeat->get_value("transactionType")); if (is_object($transactionRepeat) && $transactionRepeat->get_id() && $current_user->have_role("admin")) { $TPL["adminButtons"] .= ' <select name="changeTransactionStatus"><option value="">Transaction Status<option value="approved">Approve<option value="rejected">Reject<option value="pending">Pending</select> '; } if (is_object($transactionRepeat) && $transactionRepeat->get_id() && $transactionRepeat->get_value("status") == "pending") { $TPL["message_help"][] = "This Repeating Expense will only create Transactions once its status is Approved."; } else { if (!$transactionRepeat->get_id()) { $TPL["message_help"][] = "Complete all the details and click the Save button to create an automatically Repeating Expense"; } } $transactionRepeat->get_value("status") and $TPL["statusLabel"] = " - " . ucwords($transactionRepeat->get_value("status")); $TPL["taxName"] = config::get_config_item("taxName"); $TPL["main_alloc_title"] = "Create Repeating Expense - " . APPLICATION_NAME; include_template("templates/transactionRepeatM.tpl");
function get_changes_list() { // This function returns HTML rows for the changes that have been made to this task $rows = array(); $people_cache =& get_cached_table("person"); $options = array("taskID" => $this->get_id()); $changes = audit::get_list($options); foreach ($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 'taskName': $changeDescription = "Task name set to '{$newValue}'."; break; case 'taskDescription': $changeDescription = "Task 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 'priority': $priorities = config::get_config_item("taskPriorities"); $changeDescription = sprintf('Task priority set to <span style="color: %s;">%s</span>.', $priorities[$newValue]["colour"], $priorities[$newValue]["label"]); break; case 'projectID': task::load_entity("project", $newValue, $newProject); is_object($newProject) and $newProjectLink = $newProject->get_project_link(); $newProjectLink or $newProjectLink = "<empty>"; $changeDescription = "Project changed set to " . $newProjectLink . "."; break; case 'parentTaskID': task::load_entity("task", $newValue, $newTask); if ($newValue) { $changeDescription = sprintf("Task set to a child of %d %s.", $newTask->get_id(), $newTask->get_task_link()); } else { $changeDescription = "Task no longer a child task."; } break; case 'duplicateTaskID': task::load_entity("task", $newValue, $newTask); if ($newValue) { $changeDescription = "Task set to a duplicate of " . $newTask->get_task_link(); } else { $changeDescription = "Task is no longer a duplicate."; } break; case 'personID': $changeDescription = "Task assigned to " . $people_cache[$newValue]["name"] . "."; break; case 'managerID': $changeDescription = "Task manager set to " . $people_cache[$newValue]["name"] . "."; break; case 'estimatorID': $changeDescription = "Task estimator set to " . $people_cache[$newValue]["name"] . "."; break; case 'taskTypeID': $changeDescription = "Task type set to " . $newValue . "."; break; case 'taskStatus': $changeDescription = sprintf('Task status set to <span style="background-color:%s">%s</span>.', task::get_task_status_thing("colour", $newValue), task::get_task_status_thing("label", $newValue)); break; case 'dateActualCompletion': case 'dateActualStart': case 'dateTargetStart': case 'dateTargetCompletion': case 'timeLimit': case 'timeBest': case 'timeWorst': case 'timeExpected': // 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; case 'timeLimit': $fieldDesc = "hours worked limit"; break; case 'timeBest': $fieldDesc = "best estimate"; break; case 'timeWorst': $fieldDesc = "worst estimate"; break; case 'timeExpected': $fieldDesc = "expected estimate"; } if ($newValue) { $changeDescription = "The {$fieldDesc} was set to {$newValue}."; } else { $changeDescription = "The {$fieldDesc} was removed."; } 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); }
function get_all_parties($projectID = "") { $db = new db_alloc(); $interestedPartyOptions = array(); if (!$projectID && is_object($this)) { $projectID = $this->get_value("projectID"); } if ($projectID) { $project = new project($projectID); $interestedPartyOptions = $project->get_all_parties(); } $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array(); foreach ($extra_interested_parties as $name => $email) { $interestedPartyOptions[$email] = array("name" => $name); } if (is_object($this)) { if ($this->get_value("personID")) { $p = new person(); $p->set_id($this->get_value("personID")); $p->select(); $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_value("firstName") . " " . $p->get_value("surname"), "role" => "assignee", "selected" => false, "personID" => $this->get_value("personID")); } if ($this->get_value("approvedByManagerPersonID")) { $p = new person(); $p->set_id($this->get_value("approvedByManagerPersonID")); $p->select(); $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_value("firstName") . " " . $p->get_value("surname"), "role" => "manager", "selected" => true, "personID" => $this->get_value("approvedByManagerPersonID")); } $this_id = $this->get_id(); } // return an aggregation of the current task/proj/client parties + the existing interested parties $interestedPartyOptions = interestedParty::get_interested_parties("timeSheet", $this_id, $interestedPartyOptions); return $interestedPartyOptions; }
<?php // We're dropping the product.buyCost fields, so we need to transfer them over to productCosts. $db = new db_alloc(); $db2 = new db_alloc(); $q = "SELECT * FROM product"; $db->query($q); while ($row = $db->row()) { $q = prepare("INSERT INTO productCost (productID,fromTfID,tfID,amount,currencyTypeID,description) VALUES ('%d','%d','%d','%d','%s','%s')", $row["productID"], config::get_config_item("mainTfID"), config::get_config_item("outTfID"), $row["buyCost"], $row["buyCostCurrencyTypeID"], "Product Acquisition"); $db2->query($q); }
$TPL["reminder_default_subject"] = $reminder->get_value('reminderSubject'); } else { if ($parentType == "client") { $TPL["reminder_default_subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_reminderClient"), "client", $parentID); $TPL["reminder_default_content"] = config::get_config_item("allocURL") . "client/client.php?clientID=" . $parentID; } else { if ($parentType == "project") { $TPL["reminder_default_subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_reminderProject"), "project", $parentID); $TPL["reminder_default_content"] = config::get_config_item("allocURL") . "project/project.php?projectID=" . $parentID; } else { if ($parentType == "task") { $TPL["reminder_default_subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_reminderTask"), "task", $parentID); $TPL["reminder_default_content"] = config::get_config_item("allocURL") . "task/task.php?taskID=" . $parentID; } else { if ($parentType == "general") { $TPL["reminder_default_subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_reminderOther"), ""); } } } } } $TPL["reminder_default_content"] .= "\n" . $reminder->get_value('reminderContent'); $TPL["parentType"] = $parentType; $TPL["parentID"] = $parentID; $TPL["reminderActive"] = $reminder->get_value("reminderActive"); if (!is_object($reminder) || !$reminder->get_id()) { $TPL["reminderActive"] = true; } if ($reminder->get_value("reminderHash")) { $db = new db_alloc(); $r = $db->qr("SELECT tokenAction\n FROM token \n LEFT JOIN tokenAction ON token.tokenActionID = tokenAction.tokenActionID\n WHERE token.tokenHash = '%s'", $reminder->get_value("reminderHash"));
function get_list_html($rows = array(), $_FORM = array()) { global $TPL; $TPL["productSaleListRows"] = $rows; $_FORM["taxName"] = config::get_config_item("taxName"); $TPL["_FORM"] = $_FORM; include_template(dirname(__FILE__) . "/../templates/productSaleListS.tpl"); }
function create_transaction($amount, $tfID, $status) { $transaction = new transaction(); $invoice = $this->get_foreign_object("invoice"); $this->currency = $invoice->get_value("currencyTypeID"); $db = new db_alloc(); // If there already a transaction for this invoiceItem, use it instead of creating a new one $q = prepare("SELECT * FROM transaction WHERE invoiceItemID = %d ORDER BY transactionCreatedTime DESC LIMIT 1", $this->get_id()); $db->query($q); if ($db->row()) { $transaction->set_id($db->f("transactionID")); $transaction->select(); } // If there already a transaction for this timeSheet, use it instead of creating a new one if ($this->get_value("timeSheetID")) { $q = prepare("SELECT * \n FROM transaction \n WHERE timeSheetID = %d \n AND fromTfID = %d\n AND tfID = %d\n AND amount = %d\n AND (invoiceItemID = %d or invoiceItemID IS NULL)\n ORDER BY transactionCreatedTime DESC LIMIT 1\n ", $this->get_value("timeSheetID"), config::get_config_item("inTfID"), $tfID, page::money($this->currency, $amount, "%mi"), $this->get_id()); $db->query($q); if ($db->row()) { $transaction->set_id($db->f("transactionID")); $transaction->select(); } } $transaction->set_value("amount", $amount); $transaction->set_value("currencyTypeID", $this->currency); $transaction->set_value("fromTfID", config::get_config_item("inTfID")); $transaction->set_value("tfID", $tfID); $transaction->set_value("status", $status); $transaction->set_value("invoiceID", $this->get_value("invoiceID")); $transaction->set_value("invoiceItemID", $this->get_id()); $transaction->set_value("transactionDate", $this->get_value("iiDate")); $transaction->set_value("transactionType", "invoice"); $transaction->set_value("product", sprintf("%s", $this->get_value("iiMemo"))); $this->get_value("timeSheetID") && $transaction->set_value("timeSheetID", $this->get_value("timeSheetID")); $transaction->save(); }
function show_comments() { global $timeSheetID; global $TPL; global $timeSheet; if ($timeSheetID) { $TPL["commentsR"] = comment::util_get_comments("timeSheet", $timeSheetID); $TPL["class_new_comment"] = "hidden"; $TPL["allParties"] = $timeSheet->get_all_parties($timeSheet->get_value("projectID")) or $TPL["allParties"] = array(); $TPL["entity"] = "timeSheet"; $TPL["entityID"] = $timeSheet->get_id(); $p = $timeSheet->get_foreign_object('project'); $TPL["clientID"] = $p->get_value("clientID"); $commentTemplate = new commentTemplate(); $ops = $commentTemplate->get_assoc_array("commentTemplateID", "commentTemplateName", "", array("commentTemplateType" => "timeSheet")); $TPL["commentTemplateOptions"] = "<option value=\"\">Comment Templates</option>" . page::select_options($ops); $timeSheetPrintOptions = config::get_config_item("timeSheetPrintOptions"); $timeSheetPrint = config::get_config_item("timeSheetPrint"); $ops = array("" => "Format as..."); foreach ($timeSheetPrint as $value) { $ops[$value] = $timeSheetPrintOptions[$value]; } $TPL["attach_extra_files"] = " "; $TPL["attach_extra_files"] .= "Attach Time Sheet "; $TPL["attach_extra_files"] .= '<select name="attach_timeSheet">' . page::select_options($ops) . '</select><br>'; include_template("../comment/templates/commentM.tpl"); } }
function add_tax($amount = 0) { return $amount * (config::get_config_item("taxPercent") / 100 + 1); }
} else { $email_receive->mark_seen(); // mark it seen so we don't poll for it again alloc_error("Could not create a task from this email. Email was not sent by a staff member. Email resides in INBOX."); } // Else if we have a key, append to comment } else { // Skip over emails that are from alloc. These emails are kept only for // posterity and should not be parsed and downloaded and re-emailed etc. if (same_email_address($email_receive->mail_headers["from"], ALLOC_DEFAULT_FROM_ADDRESS)) { $email_receive->mark_seen(); $email_receive->archive(); } else { inbox::process_one_email($email_receive); } } } catch (Exception $e) { // There may have been a database error, so let the database know it can run this next bit db_alloc::$stop_doing_queries = false; // Try forwarding the errant email try { $email_receive->forward(config::get_config_item("allocEmailAdmin"), "Email command failed", "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString()); // If that fails, try last-ditch email send } catch (Exception $e) { mail(config::get_config_item("allocEmailAdmin"), "Email command failed(2)", "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString()); } } } } $email_receive->expunge(); $email_receive->close();
function add_interested_party($data) { static $people; $data["emailAddress"] = str_replace(array("<", ">"), "", $data["emailAddress"]); // Add new entry $ip = new interestedParty(); $existing = interestedParty::exists($data["entity"], $data["entityID"], $data["emailAddress"]); if ($existing) { $ip->set_id($existing["interestedPartyID"]); $ip->select(); } $ip->set_value("entity", $data["entity"]); $ip->set_value("entityID", $data["entityID"]); $ip->set_value("fullName", $data["name"]); $ip->set_value("emailAddress", $data["emailAddress"]); $ip->set_value("interestedPartyActive", 1); if ($data["personID"]) { $ip->set_value("personID", $data["personID"]); $ip->set_value("fullName", person::get_fullname($data["personID"])); } else { $people or $people =& get_cached_table("person"); foreach ($people as $personID => $p) { if ($data["emailAddress"] && same_email_address($p["emailAddress"], $data["emailAddress"])) { $ip->set_value("personID", $personID); $ip->set_value("fullName", $p["name"]); } } } $extra_interested_parties = config::get_config_item("defaultInterestedParties"); if (!$ip->get_value("personID") && !in_array($data["emailAddress"], (array) $extra_interested_parties)) { $ip->set_value("external", 1); $q = prepare("SELECT * FROM clientContact WHERE clientContactEmail = '%s'", $data["emailAddress"]); $db = new db_alloc(); $db->query($q); if ($row = $db->row()) { $ip->set_value("clientContactID", $row["clientContactID"]); $ip->set_value("fullName", $row["clientContactName"]); } } $ip->save(); return $ip->get_id(); }
* 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"; /* Username, First_Name, Surname, Password, E-mail, Phone No, Comments */ $cur = config::get_config_item("currency"); $row = 1; if (($handle = fopen("../../David_People.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { foreach ($data as $key => $val) { # $data[$key] = utf8_encode($data[$key]); } $person = new person(); $person->currency = $cur; $person->set_value("username", $data[0]); $person->set_value("firstName", $data[1]); $person->set_value("surname", $data[2]); $person->set_value("password", encrypt_password($data[3])); $person->set_value("emailAddress", $data[4]); $person->set_value("phoneNo1", $data[5]); $person->set_value("comments", $data[6]);
$fromTfID = $db->f("tfID"); } else { $msg .= "<b>Warning: Could not find active TF for account '{$account}'</b><br>"; continue; } // Check for an existing transaction $query = prepare("SELECT * FROM transaction WHERE transactionType='expense' AND transactionDate='%s' AND product='%s' AND amount > %0.3f and amount < %0.3f", $date, $memo, $amount - 0.004, $amount + 0.004); $db->query($query); if ($db->next_record()) { $msg .= "Warning: Expense '{$memo}' on {$date} already exixsts.<br>"; continue; } // Create a transaction object and then save it $transaction = new transaction(); $transaction->set_value("companyDetails", $description); $transaction->set_value("product", $memo); $transaction->set_value("amount", $amount); $transaction->set_value("status", "pending"); $transaction->set_value("expenseFormID", "0"); $transaction->set_value("fromTfID", $fromTfID); $transaction->set_value("tfID", config::get_config_item("mainTfID")); $transaction->set_value("quantity", 1); $transaction->set_value("invoiceItemID", "0"); $transaction->set_value("transactionType", "expense"); $transaction->set_value("transactionDate", "{$date}"); $transaction->save(); $msg .= "Expense '{$memo}' on {$date} saved.<br>"; } $TPL["msg"] = $msg; } include_template("templates/expenseUploadM.tpl");
if ($_POST["delete"]) { $client->read_globals(); $client->delete(); alloc_redirect($TPL["url_alloc_clientList"]); } else { $client->set_id($clientID); $client->select(); } $client->set_values("client_"); } } } $m = new meta("clientStatus"); $clientStatus_array = $m->get_assoc_array("clientStatusID", "clientStatusID"); $TPL["clientStatusOptions"] = page::select_options($clientStatus_array, $client->get_value("clientStatus")); $clientCategories = config::get_config_item("clientCategories") or $clientCategories = array(); foreach ($clientCategories as $k => $v) { $cc[$v["value"]] = $v["label"]; } $TPL["clientCategoryOptions"] = page::select_options($cc, $client->get_value("clientCategory")); $client->get_value("clientCategory") and $TPL["client_clientCategoryLabel"] = $cc[$client->get_value("clientCategory")]; // client contacts if ($_POST["clientContact_save"] || $_POST["clientContact_delete"]) { $clientContact = new clientContact(); $clientContact->read_globals(); if ($_POST["clientContact_save"]) { #$clientContact->set_value('clientID', $_POST["clientID"]); $clientContact->save(); } if ($_POST["clientContact_delete"]) { $clientContact->delete();
public static function for_cyber() { return config::get_config_item("companyHandle") == "cybersource"; }
$peeps[$p["personID"]] = $p["name"]; } // get the default time sheet manager/admin options $TPL["defaultTimeSheetManagerListText"] = get_person_list(config::get_config_item("defaultTimeSheetManagerList")); $TPL["defaultTimeSheetAdminListText"] = get_person_list(config::get_config_item("defaultTimeSheetAdminList")); $days = array("Sun" => "Sun", "Mon" => "Mon", "Tue" => "Tue", "Wed" => "Wed", "Thu" => "Thu", "Fri" => "Fri", "Sat" => "Sat"); $TPL["calendarFirstDayOptions"] = page::select_options($days, config::get_config_item("calendarFirstDay")); $TPL["timeSheetPrintOptions"] = page::select_options($TPL["timeSheetPrintOptions"], $TPL["timeSheetPrint"]); $commentTemplate = new commentTemplate(); $ops = $commentTemplate->get_assoc_array("commentTemplateID", "commentTemplateName"); $TPL["rssStatusFilterOptions"] = page::select_options(task::get_task_statii_array(true), config::get_config_item("rssStatusFilter")); if (has("timeUnit")) { $timeUnit = new timeUnit(); $rate_type_array = $timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelB"); } $TPL["timesheetRate_options"] = page::select_options($rate_type_array, config::get_config_item("defaultTimeSheetUnit")); $TPL["main_alloc_title"] = "Setup - " . APPLICATION_NAME; include_template("templates/configM.tpl"); function get_person_list($personID_array) { global $peeps; $people = array(); foreach ($personID_array as $personID) { $people[] = $peeps[$personID]; } if (count($people) > 0) { return implode(", ", $people); } else { return "<i>none</i>"; } }
#e("E-------------------"); } } // If not found, append the comment to the mailbox if (!$found) { e("Appending this comment: " . $row["comment"]); $people_cache =& get_cached_table("person"); $name = $people_cache[$row["commentCreatedUser"]]["name"]; $email = add_brackets($people_cache[$row["commentCreatedUser"]]["emailAddress"]); $eml = array(); $eml[] = "From: " . $name . " " . $email; $eml[] = "Date: " . date('D M j G:i:s Y', strtotime($row["commentCreatedTime"])); $e = new $entity(); $e->set_id($entityID); $e->select(); $tpl = config::get_config_item("emailSubject_" . $entity . "Comment"); $tpl and $subject = commentTemplate::populate_string($tpl, $entity, $entityID); $entity != "task" and $prefix = ucwords($entity) . " Comment: "; $subject or $subject = $prefix . $entityID . " " . $e->get_name(DST_VARIABLE); $r = $db->qr("SELECT tokenHash FROM token WHERE tokenEntity = 'comment' AND tokenEntityID = %d", $row["commentID"]); $subject_header = "Subject: " . $subject . " {Key:" . $r["tokenHash"] . "}"; $eml[] = $subject_header; $recipients = comment::get_email_recipients(array("interested"), $entity, $entityID); list($to_address, $bcc, $successful_recipients) = comment::get_email_recipient_headers($recipients, $people_cache[$row["commentCreatedUser"]]["emailAddress"]); $eml[] = "To: " . $to_address; $eml[] = ""; $eml[] = $row["comment"]; $eml = implode("\n", $eml); //$eml = str_replace("\n","<br>",htmlentities($eml)); //TODO: remove //echo("<br><b style='font-size:70%'>".$eml."</b>"); $mail->mail_headers["subject"] = $subject_header;