function show_time_sheets_list_for_classes($template_name, $doAdmin = false) { $current_user =& singleton("current_user"); global $TPL; if ($doAdmin) { $db = get_pending_admin_timesheet_db(); } else { $db = get_pending_timesheet_db(); } $people =& get_cached_table("person"); while ($db->next_record()) { $timeSheet = new timeSheet(); $timeSheet->read_db_record($db); $timeSheet->set_values(); unset($date); if ($timeSheet->get_value("status") == "manager") { $date = $timeSheet->get_value("dateSubmittedToManager"); } else { if ($timeSheet->get_value("status") == "admin") { $date = $timeSheet->get_value("dateSubmittedToAdmin"); } } unset($TPL["warning"]); // older than $current_user->prefs["timeSheetDaysWarn"] days if ($date && imp($current_user->prefs["timeSheetDaysWarn"]) && (mktime() - format_date("U", $date)) / 60 / 60 / 24 > $current_user->prefs["timeSheetDaysWarn"]) { $TPL["warning"] = page::help("This time sheet was submitted to you over " . $current_user->prefs["timeSheetDaysWarn"] . " days ago.", page::warn()); } $TPL["date"] = "<a href=\"" . $TPL["url_alloc_timeSheet"] . "timeSheetID=" . $timeSheet->get_id() . "\">" . $date . "</a>"; $TPL["user"] = $people[$timeSheet->get_value("personID")]["name"]; $TPL["projectName"] = $db->f("projectName"); include_template("../time/templates/" . $template_name); } }
public static function get_config_logo($anew = false) { global $TPL; $table =& get_cached_table("config", $anew); $val = ''; if (file_exists(ALLOC_LOGO)) { $val = '<img src="' . $TPL["url_alloc_logo"] . 'type=small" alt="' . $table['companyName']['value'] . '" />'; } else { $val = $table['companyName']['value']; } return $val; }
function show_announcements($template_name) { global $TPL; $people =& get_cached_table("person"); $query = "SELECT announcement.* \n FROM announcement \n ORDER BY displayFromDate DESC"; $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $announcement = new announcement(); $announcement->read_db_record($db); $announcement->set_values(); $TPL["personName"] = $people[$announcement->get_value("personID")]["name"]; $TPL["odd_even"] = $TPL["odd_even"] == "odd" ? "even" : "odd"; include_template($template_name); } }
function update_search_index_doc(&$index) { $p =& get_cached_table("person"); $personID = $this->get_value("personID"); $person_field = $personID . " " . $p[$personID]["username"] . " " . $p[$personID]["name"]; $itemModifiedUser = $this->get_value("itemModifiedUser"); $itemModifiedUser_field = $itemModifiedUser . " " . $p[$itemModifiedUser]["username"] . " " . $p[$itemModifiedUser]["name"]; $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->get_id())); $doc->addField(Zend_Search_Lucene_Field::Text('name', $this->get_value("itemName"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('desc', $this->get_value("itemNotes"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('type', $this->get_value("itemType"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('author', $this->get_value("itemAuthor"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('creator', $person_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('modifier', $itemModifiedUser_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateModified', str_replace("-", "", $this->get_value("itemModifiedTime")), "utf-8")); $index->addDocument($doc); }
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(); }
function update_search_index_doc(&$index) { $p =& get_cached_table("person"); $creatorID = $this->get_value("creatorID"); $creator_field = $creatorID . " " . $p[$creatorID]["username"] . " " . $p[$creatorID]["name"]; $closerID = $this->get_value("closerID"); $closer_field = $closerID . " " . $p[$closerID]["username"] . " " . $p[$closerID]["name"]; $personID = $this->get_value("personID"); $person_field = $personID . " " . $p[$personID]["username"] . " " . $p[$personID]["name"]; $managerID = $this->get_value("managerID"); $manager_field = $managerID . " " . $p[$managerID]["username"] . " " . $p[$managerID]["name"]; $taskModifiedUser = $this->get_value("taskModifiedUser"); $taskModifiedUser_field = $taskModifiedUser . " " . $p[$taskModifiedUser]["username"] . " " . $p[$taskModifiedUser]["name"]; $status = $this->get_value("taskStatus"); if ($this->get_value("projectID")) { $project = new project(); $project->set_id($this->get_value("projectID")); $project->select(); $projectName = $project->get_name(); $projectShortName = $project->get_name(array("showShortProjectLink" => true)); $projectShortName && $projectShortName != $projectName and $projectName .= " " . $projectShortName; } $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->get_id())); $doc->addField(Zend_Search_Lucene_Field::Text('name', $this->get_value("taskName"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('project', $projectName, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('pid', $this->get_value("projectID"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('creator', $creator_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('closer', $closer_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('assignee', $person_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('manager', $manager_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('modifier', $taskModifiedUser_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('desc', $this->get_value("taskDescription"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('priority', $this->get_value("priority"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('limit', $this->get_value("timeLimit"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('best', $this->get_value("timeBest"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('worst', $this->get_value("timeWorst"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('expected', $this->get_value("timeExpected"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('type', $this->get_value("taskTypeID"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('status', $status, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateCreated', str_replace("-", "", $this->get_value("dateCreated")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateAssigned', str_replace("-", "", $this->get_value("dateAssigned")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateClosed', str_replace("-", "", $this->get_value("dateClosed")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateTargetStart', str_replace("-", "", $this->get_value("dateTargetStart")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateTargetCompletion', str_replace("-", "", $this->get_value("dateTargetCompletion")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateStart', str_replace("-", "", $this->get_value("dateActualStart")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateCompletion', str_replace("-", "", $this->get_value("dateActualCompletion")), "utf-8")); $index->addDocument($doc); }
public static function get_list($_FORM = array()) { $filter = productSale::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>"; if (is_array($filter) && count($filter)) { $f = " WHERE " . implode(" AND ", $filter); } $f .= " ORDER BY IFNULL(productSaleDate,productSaleCreatedTime)"; $db = new db_alloc(); $query = prepare("SELECT productSale.*, project.projectName, client.clientName\n FROM productSale \n LEFT JOIN client ON productSale.clientID = client.clientID\n LEFT JOIN project ON productSale.projectID = project.projectID\n " . $f); $db->query($query); $statii = productSale::get_statii(); $people =& get_cached_table("person"); $rows = array(); while ($row = $db->next_record()) { $productSale = new productSale(); $productSale->read_db_record($db); $row["amounts"] = $productSale->get_amounts(); $row["statusLabel"] = $statii[$row["status"]]; $row["salespersonLabel"] = $people[$row["personID"]]["name"]; $row["creatorLabel"] = $people[$row["productSaleCreatedUser"]]["name"]; $row["productSaleLink"] = $productSale->get_link(); $rows[] = $row; } return (array) $rows; }
function update_search_index_doc(&$index) { $p =& get_cached_table("person"); $personID = $this->get_value("personID"); $person_field = $personID . " " . $p[$personID]["username"] . " " . $p[$personID]["name"]; $managerID = $this->get_value("approvedByManagerPersonID"); $manager_field = $managerID . " " . $p[$managerID]["username"] . " " . $p[$managerID]["name"]; $adminID = $this->get_value("approvedByAdminPersonID"); $admin_field = $adminID . " " . $p[$adminID]["username"] . " " . $p[$adminID]["name"]; $tf_field = $this->get_value("recipient_tfID") . " " . tf::get_name($this->get_value("recipient_tfID")); if ($this->get_value("projectID")) { $project = new project(); $project->set_id($this->get_value("projectID")); $project->select(); $projectName = $project->get_name(); $projectShortName = $project->get_name(array("showShortProjectLink" => true)); $projectShortName && $projectShortName != $projectName and $projectName .= " " . $projectShortName; } $q = prepare("SELECT dateTimeSheetItem, taskID, description, comment, commentPrivate \n FROM timeSheetItem \n WHERE timeSheetID = %d \n ORDER BY dateTimeSheetItem ASC", $this->get_id()); $db = new db_alloc(); $db->query($q); while ($r = $db->row()) { $desc .= $br . $r["dateTimeSheetItem"] . " " . $r["taskID"] . " " . $r["description"] . "\n"; $r["comment"] && $r["commentPrivate"] or $desc .= $r["comment"] . "\n"; $br = "\n"; } $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->get_id())); $doc->addField(Zend_Search_Lucene_Field::Text('project', $projectName, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('pid', $this->get_value("projectID"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('creator', $person_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('desc', $desc, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('status', $this->get_value("status"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('tf', $tf_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('manager', $manager_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('admin', $admin_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateManager', str_replace("-", "", $this->get_value("dateSubmittedToManager")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateAdmin', str_replace("-", "", $this->get_value("dateSubmittedToAdmin")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateFrom', str_replace("-", "", $this->get_value("dateFrom")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateTo', str_replace("-", "", $this->get_value("dateTo")), "utf-8")); $index->addDocument($doc); }
function get_people_by_username($field = "username") { $people =& get_cached_table("person"); foreach ($people as $personID => $person) { $people_by_username[$person[$field]] = $person; } return $people_by_username; }
function get_list_summary($_FORM = array()) { //$_FORM["fromDate"] = "2010-08-20"; //$_FORM["projectID"] = "22"; $_FORM["maxCommentLength"] or $_FORM["maxCommentLength"] = 500; list($filter1, $filter2, $filter3) = comment::get_list_summary_filter($_FORM); is_array($filter1) && count($filter1) and $filter1 = " AND " . implode(" AND ", $filter1); is_array($filter2) && count($filter2) and $filter2 = " AND " . implode(" AND ", $filter2); is_array($filter3) && count($filter3) and $filter3 = " AND " . implode(" AND ", $filter3); if ($_FORM["clients"]) { $client_join = " LEFT JOIN clientContact on comment.commentCreatedUserClientContactID = clientContact.clientContactID"; $client_fields = " , clientContact.clientContactName"; } $q = prepare("SELECT commentID as id\n , commentCreatedUser as personID\n , UNIX_TIMESTAMP(commentCreatedTime) as sortDate\n , date(commentCreatedTime) as date\n , commentCreatedTime as displayDate\n , commentMasterID as taskID\n , task.taskName\n , SUBSTRING(comment.comment,1,%d) AS comment_text\n , commentCreatedUserText\n " . $client_fields . "\n FROM comment\n LEFT JOIN task on comment.commentMasterID = task.taskID\n " . $client_join . "\n WHERE commentMaster = 'task'\n " . $filter1 . "\n ORDER BY commentCreatedTime, commentCreatedUser", $_FORM["maxCommentLength"]); $q .= " "; $people =& get_cached_table("person"); $db = new db_alloc(); $db->query($q); while ($row = $db->row()) { $row["icon"] = 'icon-comments-alt'; $row["id"] = "comment_" . $row["id"]; $row["personID"] and $row["person"] = $people[$row["personID"]]["name"]; $row["clientContactName"] and $row["person"] = $row["clientContactName"]; $row["person"] or list($e, $row["person"]) = parse_email_address($row["commentCreatedUserText"]); $row["displayDate"] = format_date("Y-m-d g:ia", $row["displayDate"]); if (!$tasks[$row["taskID"]]) { $t = new task(); $t->set_id($row["taskID"]); $t->set_value("taskName", $row["taskName"]); $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true)); } $rows[$row["taskID"]][$row["sortDate"]][] = $row; } // Note that timeSheetItemID is selected twice so that the perms checking can work // timeSheetID is also used by the perms checking. $q2 = prepare("SELECT timeSheetItemID as id\n ,timeSheetItemID\n ,timeSheetID\n ,timeSheetItem.personID\n ,dateTimeSheetItem as date\n ,UNIX_TIMESTAMP(CONCAT(dateTimeSheetItem, ' 23:59:58')) as sortDate\n ,dateTimeSheetItem as displayDate\n ,timeSheetItem.taskID\n ,task.taskName\n ,timeSheetItemDuration as duration\n ,SUBSTRING(timeSheetItem.comment,1,%d) AS comment_text\n FROM timeSheetItem\n LEFT JOIN task on timeSheetItem.taskID = task.taskID\n WHERE 1\n " . $filter2 . "\n ORDER BY dateTimeSheetItem", $_FORM["maxCommentLength"]); $db->query($q2); while ($row = $db->row()) { $timeSheetItem = new timeSheetItem(); if (!$timeSheetItem->read_row_record($row)) { continue; } $row["icon"] = 'icon-time'; $row["id"] = "timeitem_" . $row["id"]; $row["person"] = $people[$row["personID"]]["name"]; if (!$tasks[$row["taskID"]]) { $t = new task(); $t->set_id($row["taskID"]); $t->set_value("taskName", $row["taskName"]); $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true)); } $totals[$row["taskID"]] += $row["duration"]; $rows[$row["taskID"]][$row["sortDate"]][] = $row; } // get manager's guestimates about time worked from tsiHint table $q3 = prepare("SELECT tsiHintID as id\n ,tsiHintID\n ,tsiHint.personID\n ,tsiHint.date\n ,UNIX_TIMESTAMP(CONCAT(tsiHint.date,' 23:59:59')) as sortDate\n ,tsiHint.date as displayDate\n ,tsiHint.taskID\n ,tsiHint.duration\n ,tsiHint.tsiHintCreatedUser\n ,SUBSTRING(tsiHint.comment,1,%d) AS comment_text\n ,task.taskName\n FROM tsiHint\n LEFT JOIN task on tsiHint.taskID = task.taskID\n WHERE 1\n " . $filter3 . "\n ORDER BY tsiHint.date", $_FORM["maxCommentLength"]); $db->query($q3); while ($row = $db->row()) { //$tsiHint = new tsiHint(); //if (!$tsiHint->read_row_record($row)) // continue; $row["icon"] = 'icon-bookmark-empty'; $row["id"] = "tsihint_" . $row["id"]; $row["person"] = $people[$row["personID"]]["name"]; $row["comment_text"] .= ' [by ' . $people[$row["tsiHintCreatedUser"]]["name"] . ']'; if (!$tasks[$row["taskID"]]) { $t = new task(); $t->set_id($row["taskID"]); $t->set_value("taskName", $row["taskName"]); $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true)); } $totals_tsiHint[$row["taskID"]] += $row["duration"]; $rows[$row["taskID"]][$row["sortDate"]][] = $row; } // If there is a time sheet entry for 2010-10-10 but there is no comment entry // for that date, then the time sheet entry will appear out of sequence i.e. at // the very end of the whole list. So we need to manually sort them. foreach ((array) $rows as $tid => $arr) { ksort($arr, SORT_NUMERIC); $rows[$tid] = $arr; } foreach ((array) $rows as $taskID => $dates) { $rtn .= comment::get_list_summary_header($tasks[$taskID], $totals[$taskID], $totals_tsiHint[$taskID], $_FORM); foreach ($dates as $date => $more_rows) { foreach ($more_rows as $row) { $rtn .= comment::get_list_summary_body($row); } } $rtn .= comment::get_list_summary_footer($rows, $tasks); } return $rtn; }
public static function money($c, $amount = null, $fmt = "%s%mo") { // Money print $c or $c = config::get_config_item('currency'); $currencies =& get_cached_table("currencyType"); $fmt = str_replace("%mo", page::money_out($c, $amount), $fmt); //%mo = money_out eg: 150.21 $fmt = str_replace("%mi", page::money_in($c, $amount), $fmt); //%mi = money_in eg: 15021 $fmt = str_replace("%m", page::money_fmt($c, $amount), $fmt); // %m = format eg: 150.2 => 150.20 $fmt = str_replace("%S", $currencies[$c]["currencyTypeLabel"], $fmt); // %S = mandatory symbol eg: $ imp($amount) and $fmt = str_replace("%s", $currencies[$c]["currencyTypeLabel"], $fmt); // %s = optional symbol eg: $ $fmt = str_replace("%C", $c, $fmt); // %C = mandatory code eg: AUD imp($amount) and $fmt = str_replace("%c", $c, $fmt); // %c = optional code eg: AUD $fmt = str_replace("%N", $currencies[$c]["currencyTypeName"], $fmt); // %N = mandatory name eg: Australian dollars imp($amount) and $fmt = str_replace("%n", $currencies[$c]["currencyTypeName"], $fmt); // %n = optional name eg: Australian dollars $fmt = str_replace(array("%mo", "%mi", "%m", "%S", "%s", "%C", "%c", "%N", "%n"), "", $fmt); // strip leftovers away return $fmt; }
function update_search_index_doc(&$index) { $person =& get_cached_table("person"); $clientModifiedUser = $this->get_value("clientModifiedUser"); $clientModifiedUser_field = $clientModifiedUser . " " . $person[$clientModifiedUser]["username"] . " " . $person[$clientModifiedUser]["name"]; $this->get_value("clientStreetAddressOne") and $postal[] = $this->get_value("clientStreetAddressOne"); $this->get_value("clientSuburbOne") and $postal[] = $this->get_value("clientSuburbOne"); $this->get_value("clientStateOne") and $postal[] = $this->get_value("clientStateOne"); $this->get_value("clientPostcodeOne") and $postal[] = $this->get_value("clientPostcodeOne"); $this->get_value("clientCountryOne") and $postal[] = $this->get_value("clientCountryOne"); $p = implode("\n", (array) $postal); $p and $p = "Postal Address:\n" . $p; $this->get_value("clientStreetAddressTwo") and $street[] = $this->get_value("clientStreetAddressTwo"); $this->get_value("clientSuburbTwo") and $street[] = $this->get_value("clientSuburbTwo"); $this->get_value("clientStateTwo") and $street[] = $this->get_value("clientStateTwo"); $this->get_value("clientPostcodeTwo") and $street[] = $this->get_value("clientPostcodeTwo"); $this->get_value("clientCountryTwo") and $street[] = $this->get_value("clientCountryTwo"); $s = implode("\n", (array) $street); $s and $s = "Street Address:\n" . $s; $p && $s and $p .= "\n\n"; $addresses = $p . $s; $this->get_value("clientPhoneOne") and $ph = "Ph: " . $this->get_value("clientPhoneOne"); $this->get_value("clientFaxOne") and $fx = "Fax: " . $this->get_value("clientFaxOne"); $ph and $ph = " " . $ph; $fx and $fx = " " . $fx; $name = $this->get_name() . $ph . $fx; $q = prepare("SELECT * FROM clientContact WHERE clientID = %d", $this->get_id()); $db = new db_alloc(); $db->query($q); while ($row = $db->row()) { $c .= $nl . $row["clientContactName"]; $row["clientContactEmail"] and $c .= " <" . $row["clientContactEmail"] . ">"; $c .= " | "; $row["clientContactStreetAddress"] and $c .= " " . $row["clientContactStreetAddress"]; $row["clientContactSuburb"] and $c .= " " . $row["clientContactSuburb"]; $row["clientContactState"] and $c .= " " . $row["clientContactState"]; $row["clientContactPostcode"] and $c .= " " . $row["clientContactPostcode"]; $row["clientContactCountry"] and $c .= " " . $row["clientContactCountry"]; $c .= " | "; $row["clientContactPhone"] and $c .= " Ph: " . $row["clientContactPhone"]; $row["clientContactMobile"] and $c .= " Mob: " . $row["clientContactMobile"]; $row["clientContactFax"] and $c .= " Fax: " . $row["clientContactFax"]; $row["primaryContact"] and $c .= " Primary contact"; $c .= " | "; $row["clientContactOther"] and $c .= " " . $row["clientContactOther"]; $nl = "|+|=|"; } $c and $contacts = $c; $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->get_id())); $doc->addField(Zend_Search_Lucene_Field::Text('name', $name, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('desc', $addresses, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('contact', $contacts, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('status', $this->get_value("clientStatus"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('modifier', $clientModifiedUser_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateModified', str_replace("-", "", $this->get_value("clientModifiedTime")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('category', $this->get_value("clientCategory"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateCreated', str_replace("-", "", $this->get_value("clientCreatedTime")), "utf-8")); $index->addDocument($doc); }
$TPL["search_title"] = "Item Search"; $today = date("Y") . "-" . date("m") . "-" . date("d"); if (!$noRedirect && is_numeric($needle)) { $query = prepare("SELECT itemID FROM item WHERE itemID = %d", $needle); $db->query($query); if ($db->next_record()) { alloc_redirect($TPL["url_alloc_item"] . "itemID=" . $db->f("itemID")); } } else { //open the index $index = new Zend_Search_Lucene(ATTACHMENTS_DIR . 'search/item'); $query = Zend_Search_Lucene_Search_QueryParser::parse($needle); $hits = $index->find($needle); $TPL["index_count"] = $index->count(); $TPL["hits_count"] = count($hits); $p =& get_cached_table("person"); foreach ($hits as $hit) { $d = $hit->getDocument(); $item = new item(); $item->set_id($d->getFieldValue('id')); $item->select(); $row = array(); $row["idx"] = $hit->id; $author = $item->get_value("itemAuthor"); $author and $author = " by " . $author; $row["title"] = $item->get_id() . " " . $item->get_link() . $author; $row["score"] = sprintf('%d%%', $hit->score * 100); $row["desc"] = page::htmlentities($d->getFieldValue('desc')); // get availability of loan $db2 = new db_alloc(); $query = prepare("SELECT * FROM loan WHERE itemID = %d AND dateReturned='0000-00-00'", $item->get_id());
/** * Get all time sheet item comments in a faked mbox format * @param integer $taskID which task the time sheet item comments relate to * @return string of mbox format emails */ public function get_timeSheetItem_comments($taskID) { $people =& get_cached_table("person"); has("time") and $rows = timeSheetItem::get_timeSheetItemComments($taskID); foreach ((array) $rows as $row) { $d = $row["timeSheetItemCreatedTime"] or $d = $row["date"]; $timestamp = format_date("U", $d); $name = $people[$row["personID"]]["name"]; $str .= $br . "From allocPSA " . date('D M j G:i:s Y', $timestamp); $str .= "\nFrom: " . $name; $str .= "\nDate: " . date("D, d M Y H:i:s O", $timestamp); $str .= "\n\n" . $name . " " . $row["duration"] . " " . $row["comment"]; $br = "\n\n"; } return $str; }
//come before any status changes. function gen_key($prefix = 0) { static $subidx = 0; //this falls apart if the feed runs to more than 9999 items return '!' . $prefix . sprintf("%04d", $subidx++); } // a single '&' can't be inserted into the XML stream because it's used to // create a character (&, <, etc). SimpleXML doesn't escape it, probably // for that reason. There should be no HTML in task titles so this should be // safe. function escape_xml($string) { return str_replace('&', '&', $string); } $people =& get_cached_table('person'); //the task history $trace = array(); $summary = $_GET['summary'] ? true : false; // summary mode is the abbreviated version for the IRC bot $status_types = config::get_config_item('rssStatusFilter'); // can't be filtered in the query because it would break the history playback // find the last max_events audit events that are status change or reassignment $query = prepare("SELECT audit.taskID, field, dateChanged, value, taskName, taskStatus, task.personID, audit.projectID\n FROM audit\n LEFT JOIN task AS task ON audit.taskID = task.taskID\n WHERE field IN ('taskStatus', 'personID')\n ORDER BY dateChanged DESC\n LIMIT %d", $max_events); $db->query($query); while ($row = $db->next_record()) { $key = $row['dateChanged'] . gen_key(1); $el = array("date" => $row['dateChanged']); //overwrite the new data (taskStatus, personID) with the correct (historical) data if ($trace[$row['taskID']]) { $row = array_merge($row, $trace[$row['taskID']]);
function populate_string($str, $entity, $entityID = false) { // Actually do the text substitution $current_user =& singleton("current_user"); is_object($current_user) and $swap["cu"] = person::get_fullname($current_user->get_id()); if ($entity == "timeSheet" && $entityID) { $timeSheet = new timeSheet(); $timeSheet->set_id($entityID); $timeSheet->select(); $timeSheet->load_pay_info(); foreach ($timeSheet->pay_info as $k => $v) { $swap[$k] = $v; } if ($timeSheet->get_value("approvedByManagerPersonID")) { $swap["tm"] = person::get_fullname($timeSheet->get_value("approvedByManagerPersonID")); } else { $project = $timeSheet->get_foreign_object("project"); $projectManagers = $project->get_timeSheetRecipients(); if (is_array($projectManagers) && count($projectManagers)) { $people =& get_cached_table("person"); foreach ($projectManagers as $pID) { $swap["tm"] .= $commar . $people[$pID]["name"]; $commar = ", "; } } } if ($timeSheet->get_value("approvedByAdminPersonID")) { $swap["tc"] = person::get_fullname($timeSheet->get_value("approvedByAdminPersonID")); } else { $people =& get_cached_table("person"); $timeSheetAdministrators = config::get_config_item('defaultTimeSheetAdminList'); if (count($timeSheetAdministrators)) { $swap["tc"] = ""; $comma = ""; foreach ($timeSheetAdministrators as $adminID) { $swap["tc"] .= $comma . $people[$adminID]["name"]; $comma = ", "; } } else { $swap["tc"] = 'no-one'; } } $swap["ti"] = $timeSheet->get_id(); $swap["to"] = person::get_fullname($timeSheet->get_value("personID")); $swap["ta"] = person::get_fullname($timeSheet->get_value("personID")); $swap["tf"] = $timeSheet->get_value("dateFrom"); $swap["tt"] = $timeSheet->get_value("dateTo"); $swap["ts"] = $timeSheet->get_timeSheet_status(); $swap["tu"] = config::get_config_item("allocURL") . "time/timeSheet.php?timeSheetID=" . $timeSheet->get_id(); $projectID = $timeSheet->get_value("projectID"); } if ($entity == "task" && $entityID) { $task = new task(); $task->set_id($entityID); $task->select(); $swap["ti"] = $task->get_id(); $swap["to"] = person::get_fullname($task->get_value("creatorID")); $swap["ta"] = person::get_fullname($task->get_value("personID")); $swap["tm"] = person::get_fullname($task->get_value("managerID")); $swap["tc"] = person::get_fullname($task->get_value("closerID")); $swap["tn"] = $task->get_value("taskName"); $swap["td"] = $task->get_value("taskDescription"); $swap["tu"] = config::get_config_item("allocURL") . "task/task.php?taskID=" . $task->get_id(); $swap["tp"] = $task->get_priority_label(); $swap["ts"] = $task->get_task_status("label"); $swap["teb"] = $task->get_value("timeBest"); $swap["tem"] = $task->get_value("timeExpected"); $swap["tew"] = $task->get_value("timeWorst"); $swap["tep"] = person::get_fullname($task->get_value("estimatorID")); //time estimate person, when it's implemented $projectID = $task->get_value("projectID"); } if ($entity == "project" && $entityID || $projectID) { $project = new project(); if ($projectID) { $project->set_id($projectID); } else { $project->set_id($entityID); } $project->select(); $swap["pn"] = $project->get_value("projectName"); $swap["pi"] = $project->get_id(); $clientID = $project->get_value("clientID"); } if ($entity == "client" && $entityID || $clientID) { $client = new client(); if ($clientID) { $client->set_id($clientID); } else { $client->set_id($entityID); } $client->select(); $swap["li"] = $client->get_id(); $swap["cc"] = $client->get_value("clientName"); } $swap["cd"] = config::get_config_item("companyContactAddress"); $swap["cd"] .= " " . config::get_config_item("companyContactAddress2"); $swap["cd"] .= " " . config::get_config_item("companyContactAddress3"); $swap["cd"] .= "\nP: " . config::get_config_item("companyContactPhone"); $swap["cd"] .= "\nF: " . config::get_config_item("companyContactFax"); $swap["cd"] .= "\nE: " . config::get_config_item("companyContactEmail"); $swap["cd"] .= "\nW: " . config::get_config_item("companyContactHomePage"); $swap["cn"] = config::get_config_item("companyName"); $swap["c1"] = config::get_config_item("companyContactAddress"); $swap["c2"] = config::get_config_item("companyContactAddress2"); $swap["c3"] = config::get_config_item("companyContactAddress3"); $swap["ce"] = config::get_config_item("companyContactEmail"); $swap["cp"] = config::get_config_item("companyContactPhone"); $swap["cf"] = config::get_config_item("companyContactFax"); $swap["cw"] = config::get_config_item("companyContactHomePage"); foreach ($swap as $k => $v) { $str = str_replace("%" . $k, $v, $str); } return $str; }
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 = "<empty>"; $changeDescription = "Client set to " . $newClientLink . "."; break; case 'clientContactID': $newClientContact = new clientContact($newValue); is_object($newClientContact) and $newClientContactLink = $newClientContact->get_link(); $newClientContactLink or $newClientContactLink = "<empty>"; $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 = "<empty>"; $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); }
} $TPL["mainTfOptions"] = page::select_options($options, config::get_config_item("mainTfID")); $TPL["outTfOptions"] = page::select_options($options, config::get_config_item("outTfID")); $TPL["inTfOptions"] = page::select_options($options, config::get_config_item("inTfID")); $TPL["taxTfOptions"] = page::select_options($options, config::get_config_item("taxTfID")); $TPL["expenseFormTfOptions"] = page::select_options($options, config::get_config_item("expenseFormTfID")); $tabops = array("home" => "Home", "client" => "Clients", "project" => "Projects", "task" => "Tasks", "time" => "Time", "invoice" => "Invoices", "sale" => "Sales", "person" => "People", "wiki" => "Wiki", "inbox" => "Inbox", "tools" => "Tools"); $selected_tabops = config::get_config_item("allocTabs") or $selected_tabops = array_keys($tabops); $TPL["allocTabsOptions"] = page::select_options($tabops, $selected_tabops); $m = new meta("currencyType"); $currencyOptions = $m->get_assoc_array("currencyTypeID", "currencyTypeName"); $TPL["currencyOptions"] = page::select_options($currencyOptions, config::get_config_item("currency")); $db = new db_alloc(); $display = array("", "username", ", ", "emailAddress"); $person = new person(); $people =& get_cached_table("person"); foreach ($people as $p) { $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");
function get_all_recipients() { $db = new db_alloc(); $query = "SELECT * FROM reminderRecipient WHERE reminderID = %d"; $db->query($query, $this->get_id()); $people =& get_cached_table("person"); $recipients = array(); $person = new reminderRecipient(); while ($db->next_record()) { $person->read_db_record($db); $id = $this->get_effective_person_id($person); // hash on person ID prevents multiple emails to the same person $recipients[$id] = $people[$id]; } return $recipients; }