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);
    }
}
Пример #2
0
 function get_help()
 {
     if ($this->help_topic) {
         page::help($this->help_topic);
     }
 }
Пример #3
0
 function set_option_tpl_values()
 {
     // Set template values to provide options for edit selects
     global $TPL;
     $current_user =& singleton("current_user");
     global $isMessage;
     $db = new db_alloc();
     $projectID = $_GET["projectID"] or $projectID = $this->get_value("projectID");
     $TPL["personOptions"] = "<select name=\"personID\"><option value=\"\">" . $this->get_personList_dropdown($projectID, "personID") . "</select>";
     $TPL["managerPersonOptions"] = "<select name=\"managerID\"><option value=\"\">" . $this->get_personList_dropdown($projectID, "managerID") . "</select>";
     $TPL["estimatorPersonOptions"] = "<select name=\"estimatorID\"><option value=\"\">" . $this->get_personList_dropdown($projectID, "estimatorID") . "</select>";
     // TaskType Options
     $taskType = new meta("taskType");
     $taskType_array = $taskType->get_assoc_array("taskTypeID", "taskTypeID");
     $TPL["taskTypeOptions"] = page::select_options($taskType_array, $this->get_value("taskTypeID"));
     // Project dropdown
     $TPL["projectOptions"] = task::get_project_options($projectID);
     // We're building these two with the <select> tags because they will be
     // replaced by an AJAX created dropdown when the projectID changes.
     $TPL["parentTaskOptions"] = $this->get_parent_task_select();
     $TPL["interestedPartyOptions"] = $this->get_task_cc_list_select();
     $db->query(prepare("SELECT fullName, emailAddress, clientContactPhone, clientContactMobile\n                          FROM interestedParty\n                     LEFT JOIN clientContact ON interestedParty.clientContactID = clientContact.clientContactID\n                         WHERE entity='task' \n                           AND entityID = %d\n                           AND interestedPartyActive = 1\n                      ORDER BY fullName", $this->get_id()));
     while ($db->next_record()) {
         $value = interestedParty::get_encoded_interested_party_identifier($db->f("fullName"), $db->f("emailAddress"));
         $phone = array("p" => $db->f('clientContactPhone'), "m" => $db->f('clientContactMobile'));
         $TPL["interestedParties"][] = array('key' => $value, 'name' => $db->f("fullName"), 'email' => $db->f("emailAddress"), 'phone' => $phone);
     }
     $TPL["task_taskStatusLabel"] = $this->get_task_status("label");
     $TPL["task_taskStatusColour"] = $this->get_task_status("colour");
     $TPL["task_taskStatusValue"] = $this->get_value("taskStatus");
     $TPL["task_taskStatusOptions"] = page::select_options(task::get_task_statii_array(true), $this->get_value("taskStatus"));
     // Project label
     if (has("project")) {
         $p = new project();
         $p->set_id($this->get_value("projectID"));
         $p->select();
         $TPL["projectName"] = $p->get_display_value();
     }
     $taskPriorities = config::get_config_item("taskPriorities") or $taskPriorities = array();
     $projectPriorities = config::get_config_item("projectPriorities") or $projectPriorities = array();
     $priority = $this->get_value("priority") or $priority = 3;
     $TPL["priorityOptions"] = page::select_options(array_kv($taskPriorities, null, "label"), $priority);
     $TPL["priorityLabel"] = " <div style=\"display:inline; color:" . $taskPriorities[$priority]["colour"] . "\">[";
     if (is_object($p)) {
         list($priorityFactor, $daysUntilDue) = $this->get_overall_priority($p->get_value("projectPriority"), $this->get_value("priority"), $this->get_value("dateTargetCompletion"));
         $str = "Task priority: " . $taskPriorities[$this->get_value("priority")]["label"] . "<br>";
         $str .= "Project priority: " . $projectPriorities[$p->get_value("projectPriority")]["label"] . "<br>";
         $str .= "Days until due: " . $daysUntilDue . "<br>";
         $str .= "Calculated priority: " . $priorityFactor;
         $TPL["priorityLabel"] .= page::help($str, $this->get_priority_label());
     } else {
         $TPL["priorityLabel"] .= $this->get_priority_label();
     }
     $TPL["priorityLabel"] .= "]</div>";
     // If we're viewing the printer friendly view
     if ($_GET["media"] == "print") {
         // Parent Task label
         $t = new task();
         $t->set_id($this->get_value("parentTaskID"));
         $t->select();
         $TPL["parentTask"] = $t->get_display_value();
         // Task Type label
         $TPL["taskType"] = $this->get_value("taskTypeID");
         // Priority
         $TPL["priority"] = $this->get_value("priority");
         // Assignee label
         $p = new person();
         $p->set_id($this->get_value("personID"));
         $p->select();
         $TPL["person"] = $p->get_display_value();
     }
 }
Пример #4
0
 public static function get_list($_FORM)
 {
     /*
      * This is the definitive method of getting a list of timeSheets that need a sophisticated level of filtering
      *
      */
     global $TPL;
     $current_user =& singleton("current_user");
     $_FORM["showShortProjectLink"] and $_FORM["showProjectLink"] = true;
     $filter = timeSheet::get_list_filter($_FORM);
     // Used in timeSheetListS.tpl
     $extra["showFinances"] = $_FORM["showFinances"];
     $debug = $_FORM["debug"];
     $debug and print "<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     $q = "SELECT timeSheet.*, person.personID, projectName, projectShortName\n            FROM timeSheet \n       LEFT JOIN person ON timeSheet.personID = person.personID\n       LEFT JOIN project ON timeSheet.projectID = project.projectID\n       LEFT JOIN timeSheetItem ON timeSheet.timeSheetID = timeSheetItem.timeSheetID \n                 " . $filter . "\n        GROUP BY timeSheet.timeSheetID\n        ORDER BY dateFrom,projectName,timeSheet.status,surname";
     $debug and print "Query: " . $q;
     $db = new db_alloc();
     $db->query($q);
     $status_array = timeSheet::get_timeSheet_statii();
     $people_array =& get_cached_table("person");
     while ($row = $db->next_record()) {
         $t = new timeSheet();
         if (!$t->read_db_record($db)) {
             continue;
         }
         $t->load_pay_info();
         if ($_FORM["timeSheetItemHours"] && !parse_operator_comparison($_FORM["timeSheetItemHours"], $t->pay_info["total_duration_hours"])) {
             continue;
         }
         $row["currencyTypeID"] = $t->get_value("currencyTypeID");
         $row["amount"] = $t->pay_info["total_dollars"];
         $amount_tallies[] = array("amount" => $row["amount"], "currency" => $row["currencyTypeID"]);
         $extra["amountTotal"] += exchangeRate::convert($row["currencyTypeID"], $row["amount"]);
         $extra["totalHours"] += $t->pay_info["total_duration_hours"];
         $row["totalHours"] += $t->pay_info["total_duration_hours"];
         $row["duration"] = $t->pay_info["summary_unit_totals"];
         if ($t->get_value("status") == "edit" && imp($current_user->prefs["timeSheetHoursWarn"]) && $t->pay_info["total_duration_hours"] >= $current_user->prefs["timeSheetHoursWarn"]) {
             $row["hoursWarn"] = page::help("This time sheet has gone over " . $current_user->prefs["timeSheetHoursWarn"] . " hours.", page::warn());
         }
         if ($t->get_value("status") == "edit" && imp($current_user->prefs["timeSheetDaysWarn"]) && (mktime() - format_date("U", $t->get_value("dateFrom"))) / 60 / 60 / 24 >= $current_user->prefs["timeSheetDaysWarn"]) {
             $row["daysWarn"] = page::help("This time sheet is over " . $current_user->prefs["timeSheetDaysWarn"] . " days old.", page::warn());
         }
         $row["person"] = $people_array[$row["personID"]]["name"];
         $row["status"] = $status_array[$row["status"]];
         $row["customerBilledDollars"] = $t->pay_info["total_customerBilledDollars"];
         $extra["customerBilledDollarsTotal"] += exchangeRate::convert($row["currencyTypeID"], $t->pay_info["total_customerBilledDollars"]);
         $billed_tallies[] = array("amount" => $row["customerBilledDollars"], "currency" => $row["currencyTypeID"]);
         if ($_FORM["showFinances"]) {
             list($pos, $neg) = $t->get_transaction_totals();
             $row["transactionsPos"] = page::money_print($pos);
             $row["transactionsNeg"] = page::money_print($neg);
             foreach ((array) $pos as $v) {
                 $pos_tallies[] = $v;
             }
             foreach ((array) $neg as $v) {
                 $neg_tallies[] = $v;
             }
         }
         $p = new project();
         $p->read_db_record($db);
         $row["projectLink"] = $t->get_link($p->get_name($_FORM));
         $rows[$row["timeSheetID"]] = $row;
     }
     $extra["amount_tallies"] = page::money_print($amount_tallies);
     $extra["billed_tallies"] = page::money_print($billed_tallies);
     $extra["positive_tallies"] = page::money_print($pos_tallies);
     $extra["negative_tallies"] = page::money_print($neg_tallies);
     if (!$_FORM["noextra"]) {
         return array("rows" => (array) $rows, "extra" => $extra);
     } else {
         return (array) $rows;
     }
 }
Пример #5
0
 public static function money_print($rows = array())
 {
     $mainCurrency = config::get_config_item("currency");
     foreach ((array) $rows as $row) {
         $sums[$row["currency"]] += $row["amount"];
         $k = $row["currency"];
     }
     // If there's only one currency, then just return that figure.
     if (count($sums) == 1) {
         return page::money($k, $sums[$k], "%s%m %c");
     }
     // Else if there's more than one currency, we'll provide a tooltip of the aggregation.
     foreach ((array) $sums as $currency => $amount) {
         $str .= $sep . page::money($currency, $amount, "%s%m %c");
         $sep = " + ";
         if ($mainCurrency == $currency) {
             $total += $amount;
         } else {
             $total += exchangeRate::convert($currency, $amount);
         }
     }
     $total = page::money($mainCurrency, $total, "%s%m %c");
     if ($str && $str != $total) {
         $rtn = page::help(page::exclaim() . "<b>Approximate currency conversion</b><br>" . $str . " = " . $total, page::exclaim() . $total);
     } else {
         if ($str) {
             $rtn = $str;
         }
     }
     return $rtn;
 }
Пример #6
0
}
# if ($invoice->get_id() && is_dir(ATTACHMENTS_DIR."invoice".DIRECTORY_SEPARATOR.$invoice->get_id())) {
#   $rows = get_attachments("invoice",$invoice->get_id());
#   foreach ($rows as $arr) {
#     if ($invoice->has_attachment_permission($current_user)) {
#       $TPL["invoice_download"] .= $commar.$arr["file"]."&nbsp;&nbsp;".$arr["mtime"];
#     } else {
#       $TPL["invoice_download"] .= $commar.$arr["text"];
#     }
#     $commar = "<br>";
#   }
# }
$TPL["field_invoiceNum"] = '<input type="text" name="invoiceNum" value="' . $TPL["invoiceNum"] . '">';
$TPL["field_invoiceName"] = '<input type="text" name="invoiceName" value="' . $TPL["invoiceName"] . '">';
$TPL["field_maxAmount"] = '<input type="text" name="maxAmount" size="10" value="' . $invoice->get_value("maxAmount", DST_HTML_DISPLAY) . '"> ';
$TPL["field_maxAmount"] .= page::help('invoice_maxAmount');
$TPL["field_invoiceDateFrom"] = page::calendar("invoiceDateFrom", $TPL["invoiceDateFrom"]);
$TPL["field_invoiceDateTo"] = page::calendar("invoiceDateTo", $TPL["invoiceDateTo"]);
$clientID = $invoice->get_value("clientID") or $clientID = $_GET["clientID"];
$projectID = $invoice->get_value("projectID") or $projectID = $_GET["projectID"];
list($client_select, $client_link, $project_select, $project_link) = client::get_client_and_project_dropdowns_and_links($clientID, $projectID);
$tf = new tf();
if ($invoice->get_value("tfID")) {
    $tf->set_id($invoice->get_value("tfID"));
    $tf->select();
    $tf_link = $tf->get_link();
    $tf_sel = $invoice->get_value("tfID");
}
$tf_sel or $tf_sel = config::get_config_item("mainTfID");
$tf_select = "<select id='tfID' name='tfID'>" . page::select_options($tf->get_assoc_array("tfID", "tfName"), $tf_sel) . "</select>";
// Main invoice buttons