function is_owner($person = "") { $project = new project(); $project->set_id($this->get_value("projectID")); $project->select(); return $project->is_owner($person); }
public static function get_list($_FORM) { /* * * Get a list of task history items with sophisticated filtering and somewhat sophisticated output * * (n.b., the output from this generally needs to be post-processed to handle the semantic meaning of changes in various fields) * */ $filter = audit::get_list_filter($_FORM); if (is_array($filter) && count($filter)) { $where_clause = " WHERE " . implode(" AND ", $filter); } if ($_FORM["projectID"]) { $entity = new project(); $entity->set_id($_FORM["projectID"]); $entity->select(); } else { if ($_FORM["taskID"]) { $entity = new task(); $entity->set_id($_FORM["taskID"]); $entity->select(); } } $q = "SELECT *\n FROM audit\n {$where_clause}\n ORDER BY dateChanged"; $db = new db_alloc(); $db->query($q); $items = array(); while ($row = $db->next_record()) { $audit = new audit(); $audit->read_db_record($db); $rows[] = $row; } return $rows; }
function is_owner($person = "") { if (!$this->get_id()) { return true; } else { $project = new project(); $project->set_id($this->get_value("projectID")); $project->select(); return $project->is_owner($person); } }
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); } } }
function show_projects($template_name) { global $TPL; global $default; $_FORM = task::load_form_data($defaults); $arr = task::load_task_filter($_FORM); is_array($arr) and $TPL = array_merge($TPL, $arr); if (is_array($_FORM["projectID"])) { $projectIDs = $_FORM["projectID"]; foreach ($projectIDs as $projectID) { $project = new project(); $project->set_id($projectID); $project->select(); $_FORM["projectID"] = array($projectID); $TPL["graphTitle"] = urlencode($project->get_value("projectName")); $arr = task::load_task_filter($_FORM); is_array($arr) and $TPL = array_merge($TPL, $arr); include_template($template_name); } } }
function translate_meta_tfID($tfID = "") { // The special -1 and -2 tfID's represent META TF, i.e. calculated at runtime // -1 == META: Project TF if ($tfID == -1) { if ($this->get_value("projectID")) { $project = new project(); $project->set_id($this->get_value("projectID")); $project->select(); $tfID = $project->get_value("cost_centre_tfID"); } if (!$tfID) { alloc_error("Unable to use META: Project TF. Please ensure the project has a TF set, or adjust the transactions."); } // -2 == META: Salesperson TF } else { if ($tfID == -2) { if ($this->get_value("personID")) { $person = new person(); $person->set_id($this->get_value("personID")); $person->select(); $tfID = $person->get_value("preferred_tfID"); if (!$tfID) { alloc_error("Unable to use META: Salesperson TF. Please ensure the Saleperson has a Preferred Payment TF."); } } else { alloc_error("Unable to use META: Salesperson TF. No product salesperson set."); } } else { if ($tfID == -3) { $tfID = $this->get_value("tfID"); $tfID or alloc_error("Unable to use META: Sale TF not set."); } } } return $tfID; }
function export_csv($projectID) { $project = new project(); $project->set_id($projectID); $project->select(); $retstr = '"Task Name","Estimated Time","Assignee"'; // Export all tasks in the project $taskOptions["projectIDs"] = array($project->get_id()); $taskOptions["return"] = "array"; $taskOptions["taskView"] = "byProject"; $tasks = task::get_list($taskOptions); // Sort by taskID--we assume taskIDs were assigned linearly on import/creation--so as to produce an identical file foreach ($tasks as $task) { $taskIDs[] = $task['taskID']; } array_multisort($taskIDs, $tasks); foreach ($tasks as $task) { $assignee = new person(); $assignee->set_id($task['personID']); $assignee->select(); $estimatedHours = $task['timeExpected']; is_numeric($estimatedHours) or $estimatedHours = 0; $retstr .= "\n" . export_escape_csv($task['taskName']) . ',' . export_escape_csv($estimatedHours) . ',' . export_escape_csv($assignee->get_name(array("format" => "nick"))); } return $retstr; }
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); }
$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']]); } if (!$row['personID']) { $name = "Unassigned"; } else { $name = $people[$row['personID']]['username']; } if ($row['field'] != "taskStatus" || array_search($row['taskStatus'], $status_types) !== FALSE) { $taskName = escape_xml($row['taskName']); $project = null; if ($show_project) { $project = new project(); $project->set_id($row['projectID']); $project->select(); } if ($summary) { if ($show_project) { $projectName = $project->get_value('projectShortName'); } $el['desc'] = sprintf('%s: %d %s "%s" %s', $name, $row['taskID'], $projectName, $taskName, $row['taskStatus']); } else { if ($show_project) { $projectName = "(" . $project->get_value("projectName") . ")"; } if ($row['field'] == "taskStatus") { $el['desc'] = sprintf('Task #%d "%s" %s status changed to %s', $row['taskID'], $taskName, $projectName, $row['taskStatus']); } else { if ($row['field'] == "personID") {
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 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; }
alloc_redirect($TPL["url_alloc_project"] . "projectID=" . $project->get_id()); } } else { if ($_POST["delete"]) { $project->read_globals(); $project->delete(); alloc_redirect($TPL["url_alloc_projectList"]); // If they are creating a new project that is based on an existing one } else { if ($_POST["copy_project_save"] && $_POST["copy_projectID"] && $_POST["copy_project_name"]) { $p = new project(); $p->set_id($_POST["copy_projectID"]); if ($p->select()) { $p2 = new project(); $p2->read_row_record($p->row()); $p2->set_id(""); $p2->set_value("projectName", $_POST["copy_project_name"]); $p2->set_value("projectShortName", ""); $p2->save(); $TPL["message_good"][] = "Project details copied successfully."; // Copy project people $q = prepare("SELECT * FROM projectPerson WHERE projectID = %d", $p->get_id()); $db = new db_alloc(); $db->query($q); while ($row = $db->row()) { $projectPerson = new projectPerson(); $projectPerson->currency = $p->get_value("currencyTypeID"); $projectPerson->read_row_record($row); $projectPerson->set_id(""); $projectPerson->set_value("projectID", $p2->get_id()); $projectPerson->save();
function is_alive() { $type = $this->get_value('reminderType'); if ($type == "project") { $project = new project(); $project->set_id($this->get_value('reminderLinkID')); if ($project->select() == false || $project->get_value('projectStatus') == "Archived") { return false; } } else { if ($type == "task") { $task = new task(); $task->set_id($this->get_value('reminderLinkID')); if ($task->select() == false || substr($task->get_value("taskStatus"), 0, 6) == 'closed') { return false; } } else { if ($type == "client") { $client = new client(); $client->set_id($this->get_value('reminderLinkID')); if ($client->select() == false || $client->get_value('clientStatus') == "Archived") { return false; } } } } return true; }
/* * 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["projectID"]) { usleep(300000); $project = new project(); $project->set_id($_GET["projectID"]); $project->select(); $tf_sel = $project->get_value("cost_centre_tfID") or $tf_sel = config::get_config_item("mainTfID"); $tf = new tf(); $options = page::select_options($tf->get_assoc_array("tfID", "tfName"), $tf_sel); echo "<select id=\"tfID\" name=\"tfID\">" . $options . "</select>"; }
function get_printable_timeSheet_file($timeSheetID, $timeSheetPrintMode, $printDesc, $format) { global $TPL; $TPL["timeSheetID"] = $timeSheetID; $TPL["timeSheetPrintMode"] = $timeSheetPrintMode; $TPL["printDesc"] = $printDesc; $TPL["format"] = $format; $db = new db_alloc(); if ($timeSheetID) { $timeSheet = new timeSheet(); $timeSheet->set_id($timeSheetID); $timeSheet->select(); $timeSheet->set_tpl_values(); $person = $timeSheet->get_foreign_object("person"); $TPL["timeSheet_personName"] = $person->get_name(); $timeSheet->set_tpl_values("timeSheet_"); // Display the project name. $project = new project(); $project->set_id($timeSheet->get_value("projectID")); $project->select(); $TPL["timeSheet_projectName"] = $project->get_value("projectName", DST_HTML_DISPLAY); // Get client name $client = $project->get_foreign_object("client"); $client->set_tpl_values(); $TPL["clientName"] = $client->get_value("clientName", DST_HTML_DISPLAY); $TPL["companyName"] = config::get_config_item("companyName"); $TPL["companyNos1"] = config::get_config_item("companyACN"); $TPL["companyNos2"] = config::get_config_item("companyABN"); unset($br); $phone = config::get_config_item("companyContactPhone"); $fax = config::get_config_item("companyContactFax"); $phone and $TPL["phone"] = "Ph: " . $phone; $fax and $TPL["fax"] = "Fax: " . $fax; $timeSheet->load_pay_info(); $db->query(prepare("SELECT max(dateTimeSheetItem) AS maxDate\n ,min(dateTimeSheetItem) AS minDate\n ,count(timeSheetItemID) as count\n FROM timeSheetItem \n WHERE timeSheetID=%d ", $timeSheetID)); $db->next_record(); $timeSheet->set_id($timeSheetID); $timeSheet->select() || alloc_error("Unable to select time sheet, trying to use id: " . $timeSheetID); $TPL["period"] = format_date(DATE_FORMAT, $db->f("minDate")) . " to " . format_date(DATE_FORMAT, $db->f("maxDate")); $TPL["img"] = config::get_config_item("companyImage"); $TPL["companyContactAddress"] = config::get_config_item("companyContactAddress"); $TPL["companyContactAddress2"] = config::get_config_item("companyContactAddress2"); $TPL["companyContactAddress3"] = config::get_config_item("companyContactAddress3"); $email = config::get_config_item("companyContactEmail"); $email and $TPL["companyContactEmail"] = "Email: " . $email; $web = config::get_config_item("companyContactHomePage"); $web and $TPL["companyContactHomePage"] = "Web: " . $web; $TPL["footer"] = config::get_config_item("timeSheetPrintFooter"); $TPL["taxName"] = config::get_config_item("taxName"); $default_header = "Time Sheet"; $default_id_label = "Time Sheet ID"; $default_contractor_label = "Contractor"; $default_total_label = "TOTAL AMOUNT PAYABLE"; if ($timeSheetPrintMode == "money") { $default_header = "Tax Invoice"; $default_id_label = "Invoice Number"; } if ($timeSheetPrintMode == "estimate") { $default_header = "Estimate"; $default_id_label = "Estimate Number"; $default_contractor_label = "Issued By"; $default_total_label = "TOTAL AMOUNT ESTIMATED"; } if ($format != "html") { // Build PDF document $font1 = ALLOC_MOD_DIR . "util/fonts/Helvetica.afm"; $font2 = ALLOC_MOD_DIR . "util/fonts/Helvetica-Oblique.afm"; $pdf_table_options = array("showLines" => 0, "shaded" => 0, "showHeadings" => 0, "xPos" => "left", "xOrientation" => "right", "fontSize" => 10, "rowGap" => 0, "fontSize" => 10); $cols = array("one" => "", "two" => "", "three" => "", "four" => ""); $cols3 = array("one" => "", "two" => ""); $cols_settings["one"] = array("justification" => "right"); $cols_settings["three"] = array("justification" => "right"); $pdf_table_options2 = array("showLines" => 0, "shaded" => 0, "showHeadings" => 0, "width" => 400, "fontSize" => 10, "xPos" => "center", "xOrientation" => "center", "cols" => $cols_settings); $cols_settings2["gst"] = array("justification" => "right"); $cols_settings2["money"] = array("justification" => "right"); $pdf_table_options3 = array("showLines" => 2, "shaded" => 0, "width" => 400, "xPos" => "center", "fontSize" => 10, "cols" => $cols_settings2, "lineCol" => array(0.8, 0.8, 0.8), "splitRows" => 1, "protectRows" => 0); $cols_settings["two"] = array("justification" => "right", "width" => 80); $pdf_table_options4 = array("showLines" => 2, "shaded" => 0, "width" => 400, "showHeadings" => 0, "fontSize" => 10, "xPos" => "center", "cols" => $cols_settings, "lineCol" => array(0.8, 0.8, 0.8)); $pdf = new Cezpdf(); $pdf->ezSetMargins(90, 90, 90, 90); $pdf->selectFont($font1); $pdf->ezStartPageNumbers(436, 80, 10, 'right', 'Page {PAGENUM} of {TOTALPAGENUM}'); $pdf->ezStartPageNumbers(200, 80, 10, 'left', '<b>' . $default_id_label . ': </b>' . $TPL["timeSheetID"]); $pdf->ezSetY(775); $TPL["companyName"] and $contact_info[] = array($TPL["companyName"]); $TPL["companyContactAddress"] and $contact_info[] = array($TPL["companyContactAddress"]); $TPL["companyContactAddress2"] and $contact_info[] = array($TPL["companyContactAddress2"]); $TPL["companyContactAddress3"] and $contact_info[] = array($TPL["companyContactAddress3"]); $TPL["companyContactEmail"] and $contact_info[] = array($TPL["companyContactEmail"]); $TPL["companyContactHomePage"] and $contact_info[] = array($TPL["companyContactHomePage"]); $TPL["phone"] and $contact_info[] = array($TPL["phone"]); $TPL["fax"] and $contact_info[] = array($TPL["fax"]); $pdf->selectFont($font2); $y = $pdf->ezTable($contact_info, false, "", $pdf_table_options); $pdf->selectFont($font1); $line_y = $y - 10; $pdf->setLineStyle(1, "round"); $pdf->line(90, $line_y, 510, $line_y); $pdf->ezSetY(782); $image_jpg = ALLOC_LOGO; if (file_exists($image_jpg)) { $pdf->ezImage($image_jpg, 0, sprintf("%d", config::get_config_item("logoScaleX")), 'none'); $y = 700; } else { $y = $pdf->ezText($TPL["companyName"], 27, array("justification" => "right")); } $nos_y = $line_y + 22; $TPL["companyNos2"] and $nos_y = $line_y + 34; $pdf->ezSetY($nos_y); $TPL["companyNos1"] and $y = $pdf->ezText($TPL["companyNos1"], 10, array("justification" => "right")); $TPL["companyNos2"] and $y = $pdf->ezText($TPL["companyNos2"], 10, array("justification" => "right")); $pdf->ezSetY($line_y - 20); $y = $pdf->ezText($default_header, 20, array("justification" => "center")); $pdf->ezSetY($y - 20); $ts_info[] = array("one" => "<b>" . $default_id_label . ":</b>", "two" => $TPL["timeSheetID"], "three" => "<b>Date Issued:</b>", "four" => date("d/m/Y")); $ts_info[] = array("one" => "<b>Client:</b>", "two" => $TPL["clientName"], "three" => "<b>Project:</b>", "four" => $TPL["timeSheet_projectName"]); $ts_info[] = array("one" => "<b>" . $default_contractor_label . ":</b>", "two" => $TPL["timeSheet_personName"], "three" => "<b>Billing Period:</b>", "four" => $TPL["period"]); if ($timeSheetPrintMode == "estimate") { // This line needs to be glued to the above line $temp = array_pop($ts_info); $temp["three"] = ""; // Nuke Billing Period for the Estimate version of the pdf. $temp["four"] = ""; // Nuke Billing Period for the Estimate version of the pdf. $ts_info[] = $temp; } $y = $pdf->ezTable($ts_info, $cols, "", $pdf_table_options2); $pdf->ezSetY($y - 20); if ($timeSheetPrintMode == "money" || $timeSheetPrintMode == "estimate") { list($rows, $info) = $this->get_timeSheetItem_list_money($TPL["timeSheetID"]); $cols2 = array("desc" => "Description", "units" => "Units", "money" => "Charges", "gst" => $TPL["taxName"]); $taxPercent = config::get_config_item("taxPercent"); if ($taxPercent === '') { unset($cols2["gst"]); } $rows[] = array("desc" => "<b>TOTAL</b>", "units" => $info["total_units"], "money" => $info["total"], "gst" => $info["total_gst"]); $y = $pdf->ezTable($rows, $cols2, "", $pdf_table_options3); $pdf->ezSetY($y - 20); if ($taxPercent !== '') { $totals[] = array("one" => "TOTAL " . $TPL["taxName"], "two" => $info["total_gst"]); } $totals[] = array("one" => "TOTAL CHARGES", "two" => $info["total"]); $totals[] = array("one" => "<b>" . $default_total_label . "</b>", "two" => "<b>" . $info["total_inc_gst"] . "</b>"); $y = $pdf->ezTable($totals, $cols3, "", $pdf_table_options4); } else { if ($timeSheetPrintMode == "units") { list($rows, $info) = $this->get_timeSheetItem_list_units($TPL["timeSheetID"]); $cols2 = array("desc" => "Description", "units" => "Units"); $rows[] = array("desc" => "<b>TOTAL</b>", "units" => "<b>" . $info["total"] . "</b>"); $y = $pdf->ezTable($rows, $cols2, "", $pdf_table_options3); } else { if ($timeSheetPrintMode == "items") { list($rows, $info) = $this->get_timeSheetItem_list_items($TPL["timeSheetID"]); $cols2 = array("date" => "Date", "units" => "Units", "multiplier_string" => "Multiplier", "desc" => "Description"); $rows[] = array("date" => "<b>TOTAL</b>", "units" => "<b>" . $info["total"] . "</b>"); $y = $pdf->ezTable($rows, $cols2, "", $pdf_table_options3); } } } $pdf->ezSetY($y - 20); $pdf->ezText(str_replace(array("<br>", "<br/>", "<br />"), "\n", $TPL["footer"]), 10); $pdf->ezStream(array("Content-Disposition" => "timeSheet_" . $timeSheetID . ".pdf")); // Else HTML format } else { if (file_exists(ALLOC_LOGO)) { $TPL["companyName"] = '<img alt="Company logo" src="' . $TPL["url_alloc_logo"] . '" />'; } $TPL["this_tsp"] = $this; $TPL["main_alloc_title"] = "Time Sheet - " . APPLICATION_NAME; include_template(dirname(__FILE__) . "/../templates/timeSheetPrintM.tpl"); } } }
if (!$productSale->get_id()) { $TPL["message_help"][] = "To create a new Sale, optionally select a Client and/or Project and click the Create Sale button."; } else { if ($productSale->get_value("status") == "edit") { $TPL["message_help"][] = "Add as many Sale Items as you like by clicking the 'New' link multiple times, and then clicking the\n Save Items button.<br><br>When you are done adding Sale Items click the 'Allocate -->' button\n to setup the resulting transactions from this Sale."; } else { if ($productSale->get_value("status") == "allocate") { $TPL["message_help"][] = "If necessary, adjust the transactions below. When you're done, submit this Sale\n to the Adminstrator, you will no longer be able to edit this Sale.\n\n <br><br>Generally, the transactions for the Sale Items will add up correctly if the\n <b>Sell Price</b> is equal to <b>Transactions Incoming</b>, and the <b>Margin</b> is\n equal to <b>Transactions Other</b>."; } else { if ($productSale->get_value("status") == "admin" && $productSale->have_perm(PERM_APPROVE_PRODUCT_TRANSACTIONS)) { $TPL["message_help"][] = "Please review the Sale Transactions carefully. If accurate <b>approve</b> and save the transactions,\n then move this Sale to status 'Completed'."; } else { if ($productSale->get_value("status") == "admin") { $TPL["message_help"][] = "This Sale is awaiting approval from the Administrator."; } } } } } if ($productSale->get_value("projectID")) { $project = new project(); $project->set_id($productSale->get_value("projectID")); $project->select(); $ptf = $project->get_value("cost_centre_tfID"); $ptf and $TPL["project_tfID"] = " (TF: " . tf::get_name($ptf) . ")"; $ptf or $TPL["project_tfID"] = " (No project TF)"; } $TPL["taxName"] = config::get_config_item("taxName"); $TPL["main_alloc_title"] = "Sale - " . APPLICATION_NAME; $productSale->get_id() and $TPL["main_alloc_title"] = "Sale " . $productSale->get_id() . " - " . APPLICATION_NAME; include_template("templates/productSaleM.tpl");
/** * Convert a comma separated string of names, into an array with email addresses * @param string $people * @param string $entity the related entity that can assist in the look up * @param integer $entityID the id of the related entity * @return array an array of people, indexed by their email address */ public function get_people($options = array(), $entity = "", $entityID = "") { $person_table =& get_cached_table("person"); $people = $options; if ($entity && $entityID) { $e = new $entity(); $e->set_id($entityID); $e->select(); in_array("default", $people) and $default_recipients = $e->get_all_parties(); in_array("internal", $people) and $internal_recipients = $e->get_all_parties(); } // remove default and internal from the array $clean_people = array_diff($people, array("default", "internal")); if (is_object($e)) { $projectID = $e->get_project_id(); $p = new project(); $p->set_id($projectID); $p->select(); $client = $p->get_foreign_object("client"); $clientID = $client->get_id(); } foreach ((array) $default_recipients as $email => $info) { if ($info["selected"]) { $rtn[$email] = $this->reduce_person_info($info); } } foreach ((array) $internal_recipients as $email => $info) { if ($info["selected"] && !$info["external"]) { $rtn[$email] = $this->reduce_person_info($info); } } foreach ((array) $clean_people as $person) { $bad_person = true; $person = trim($person); // personID if (is_numeric($person)) { if ($person_table[$person]["personActive"]) { $rtn[$person_table[$person]["emailAddress"]] = $person_table[$person]; $bad_person = false; continue; } // email addresses } else { if (in_str("@", $person)) { foreach ($person_table as $pid => $data) { if (same_email_address($person, $data["emailAddress"]) && $data["personActive"]) { $rtn[$data["emailAddress"]] = $data; $bad_person = false; continue 2; } } if ($ccID = clientContact::find_by_email($person)) { $cc = new clientContact(); $cc->set_id($ccID); $cc->select(); $rtn[$cc->get_value("clientContactEmail")] = $cc->row(); $bad_person = false; continue; } // If we get here, then return the email address entered list($e, $n) = parse_email_address($person); $rtn[$e] = array("emailAddress" => $e, "name" => $n); $bad_person = false; continue; // usernames, partial and full names } else { foreach ($person_table as $pid => $data) { // If matches username if (strtolower($person) == strtolower($data["username"]) && $data["personActive"]) { $rtn[$data["emailAddress"]] = $data; $bad_person = false; continue 2; } } foreach ($person_table as $pid => $data) { // If matches name if (strtolower($person) == strtolower($data["firstName"] . " " . $data["surname"]) && $data["personActive"]) { $rtn[$data["emailAddress"]] = $data; $bad_person = false; continue 2; } } foreach ($person_table as $pid => $data) { // If matches a section of name, eg: a search for "Ale" will match the full name "Alex Lance" if (strtolower($person) == strtolower(substr(strtolower($data["firstName"] . " " . $data["surname"]), 0, strlen($person))) && $data["personActive"]) { $rtn[$data["emailAddress"]] = $data; $bad_person = false; continue 2; } } if ($ccID = clientContact::find_by_nick($person, $clientID)) { $cc = new clientContact(); $cc->set_id($ccID); $cc->select(); $rtn[$cc->get_value("clientContactEmail")] = $cc->row(); $bad_person = false; continue; } if ($ccID = clientContact::find_by_name($person, $projectID)) { $cc = new clientContact(); $cc->set_id($ccID); $cc->select(); $rtn[$cc->get_value("clientContactEmail")] = $cc->row(); $bad_person = false; continue; } if ($ccID = clientContact::find_by_partial_name($person, $projectID)) { $cc = new clientContact(); $cc->set_id($ccID); $cc->select(); $rtn[$cc->get_value("clientContactEmail")] = $cc->row(); $bad_person = false; continue; } } } if ($bad_person) { die("Unable to find person: " . $person); } } foreach ((array) $rtn as $id => $p) { $rtn[$id] = $this->reduce_person_info($p); } return (array) $rtn; }
{ global $person_query; global $project; global $TPL; $db = new db_alloc(); $db->query($person_query); while ($db->next_record()) { $person = new person(); $person->read_db_record($db); $person->set_values("person_"); $TPL["graphTitle"] = urlencode($person->get_name()); include_template($template_name); } } $projectID = $_POST["projectID"] or $projectID = $_GET["projectID"]; if ($projectID) { $project = new project(); $project->set_id($projectID); $project->select(); $TPL["navigation_links"] = $project->get_navigation_links(); $person_query = prepare("SELECT person.*\n FROM person, projectPerson\n WHERE person.personID = projectPerson.personID\n AND projectPerson.projectID=%d", $project->get_id()); } else { if ($_GET["personID"]) { $person_query = prepare("SELECT * FROM person WHERE personID = %d ORDER BY username", $_GET["personID"]); } else { $person_query = prepare("SELECT * FROM person ORDER BY username"); } } $TPL["projectID"] = $projectID; $TPL["main_alloc_title"] = "Allocation Graph - " . APPLICATION_NAME; include_template("templates/personGraphM.tpl");
function get_client_and_project_dropdowns_and_links($clientID = false, $projectID = false, $onlymine = false) { // This function returns dropdown lists and links for both client and // project. The two dropdown lists are linked, in that if you change the // client, then the project dropdown dynamically updates global $TPL; $project = new project(); $project->set_id($projectID); $project->select(); if (!$clientID) { $clientID = $project->get_value("clientID"); } $client = new client(); $client->set_id($clientID); $client->select(); $options["clientStatus"] = "Current"; $ops = client::get_list($options); $ops = array_kv($ops, "clientID", "clientName"); $client->get_id() and $ops[$client->get_id()] = $client->get_value("clientName"); $client_select = "<select id=\"clientID\" name=\"clientID\" onChange=\"makeAjaxRequest('" . $TPL["url_alloc_updateProjectListByClient"] . "clientID='+\$('#clientID').attr('value')+'&onlymine=" . sprintf("%d", $onlymine) . "','projectDropdown')\"><option></option>"; $client_select .= page::select_options($ops, $clientID, 100) . "</select>"; $client_link = $client->get_link(); $project_select = '<div id="projectDropdown" style="display:inline">' . $project->get_dropdown_by_client($clientID, $onlymine) . '</div>'; $project_link = $project->get_link(); return array($client_select, $client_link, $project_select, $project_link); }