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); } }
function get_one_comment_array($v = array(), $all_parties = array()) { global $TPL; $current_user =& singleton("current_user"); $new = $v; $token = new token(); if ($token->select_token_by_entity_and_action("comment", $new["commentID"], "add_comment_from_email")) { if ($token->get_value("tokenHash")) { $new["hash"] = $token->get_value("tokenHash"); $new["hashKey"] = "{Key:" . $new["hash"] . "}"; $new["hashHTML"] = " <em class=\"faint\">" . $new["hashKey"] . "</em>"; } $ip = interestedParty::get_interested_parties("comment", $new["commentID"]); foreach ((array) $ip as $email => $info) { $all_parties += $ip; if ($info["selected"]) { $sel[] = $email; } } foreach ($all_parties as $email => $i) { in_array($email, (array) $sel) and $recipient_selected[] = $i["identifier"]; } if (interestedParty::is_external("comment", $new["commentID"])) { $new["external"] = " loud"; $label = "<em class='faint warn'>[ External Conversation ]</em>"; } else { $label = "<em class='faint'>[ Internal Conversation ]</em>"; } foreach ((array) $all_parties as $email => $info) { $recipient_ops[$info["identifier"]] = $info["name"] . " <" . $email . ">"; } $new["recipient_editor"] = "<span class='nobr' style='width:100%;display:inline;' class='recipient_editor'>"; $new["recipient_editor"] .= "<span class='noprint hidden' id='recipient_dropdown_" . $new["commentID"] . "'>\n <form action='" . $TPL["url_alloc_updateRecipients"] . "' method='post'>\n <select name='comment_recipients[]' multiple='true' data-callback='save_recipients'>\n " . page::select_options($recipient_ops, $recipient_selected) . "\n </select>\n <input type='hidden' name='commentID' value='" . $new["commentID"] . "'>\n <input type='submit' value='Go' style='display:none'>\n </form>\n </span>"; $new["recipient_editor"] .= "<a class='magic recipient_editor_link' id='r_e_" . $new["commentID"] . "' style='text-decoration:none' href='#x'>" . $label . "</a>"; $new["recipient_editor"] .= "</span>"; $new["reply"] = '<a href="" class="noprint commentreply">reply</a>'; } if ($v["timeSheetID"]) { $timeSheet = new timeSheet(); $timeSheet->set_id($v["timeSheetID"]); $v["ts_label"] = " (Time Sheet #" . $timeSheet->get_id() . ")"; } $new["attribution"] = comment::get_comment_attribution($v); $new["commentCreatedUserEmail"] = comment::get_comment_author_email($v); $s = commentTemplate::populate_string(config::get_config_item("emailSubject_taskComment"), $entity, $id); $new["commentEmailSubject"] = $s . " " . $new["hashKey"]; if (!$_GET["commentID"] || $_GET["commentID"] != $v["commentID"]) { if ($options["showEditButtons"] && $new["comment_buttons"]) { $new["form"] = '<form action="' . $TPL["url_alloc_comment"] . '" method="post">'; $new["form"] .= '<input type="hidden" name="entity" value="' . $v["commentType"] . '">'; $new["form"] .= '<input type="hidden" name="entityID" value="' . $v["commentLinkID"] . '">'; $new["form"] .= '<input type="hidden" name="commentID" value="' . $v["commentID"] . '">'; $new["form"] .= '<input type="hidden" name="comment_id" value="' . $v["commentID"] . '">'; $new["form"] .= $new["comment_buttons"]; $new["form"] .= '<input type="hidden" name="sessID" value="' . $TPL["sessID"] . '">'; $new["form"] .= '</form>'; } $v["commentMimeParts"] and $files = unserialize($v["commentMimeParts"]); if (is_array($files)) { foreach ($files as $file) { $new["files"] .= '<div align="center" style="float:left; display:inline; margin-right:14px;">'; $new["files"] .= "<a href=\"" . $TPL["url_alloc_getMimePart"] . "part=" . $file["part"] . "&entity=comment&id=" . $v["commentID"] . "\">"; $new["files"] .= get_file_type_image($file["name"]) . "<br>" . page::htmlentities($file["name"]); $new["files"] .= " (" . get_size_label($file["size"]) . ")</a>"; $new["files"] .= '</div>'; } } $v["commentEmailRecipients"] and $new["emailed"] = 'Emailed to ' . page::htmlentities($v["commentEmailRecipients"]); } return (array) $new; }
function close_related_entity() { global $TPL; // It checks for approved transactions and only approves the timesheets // or expenseforms that are completely paid for by an invoice item. $db = new db_alloc(); $q = prepare("SELECT amount, currencyTypeID, status \n FROM transaction \n WHERE invoiceItemID = %d \n ORDER BY transactionCreatedTime DESC \n LIMIT 1\n ", $this->get_id()); $db->query($q); $row = $db->row(); $total = $row["amount"]; $currency = $row["currencyTypeID"]; $status = $row["status"]; $timeSheetID = $this->get_value("timeSheetID"); $expenseFormID = $this->get_value("expenseFormID"); if ($timeSheetID) { $timeSheet = new timeSheet(); $timeSheet->set_id($timeSheetID); $timeSheet->select(); $db = new db_alloc(); if ($timeSheet->get_value("status") == "invoiced") { // If the time sheet doesn't have any transactions and it is in // status invoiced, then we'll simulate the "Create Default Transactions" // button being pressed. $q = prepare("SELECT count(*) as num_transactions \n FROM transaction \n WHERE timeSheetID = %d \n AND invoiceItemID IS NULL\n ", $timeSheet->get_id()); $db->query($q); $row = $db->row(); if ($row["num_transactions"] == 0) { $_POST["create_transactions_default"] = true; $timeSheet->createTransactions($status); $TPL["message_good"][] = "Automatically created time sheet transactions."; } // Get total of all time sheet transactions. $q = prepare("SELECT SUM(amount) AS total \n FROM transaction \n WHERE timeSheetID = %d \n AND status != 'rejected' \n AND invoiceItemID IS NULL\n ", $timeSheet->get_id()); $db->query($q); $row = $db->row(); $total_timeSheet = $row["total"]; if ($total >= $total_timeSheet) { $timeSheet->pending_transactions_to_approved(); $timeSheet->change_status("forwards"); $TPL["message_good"][] = "Closed Time Sheet #" . $timeSheet->get_id() . " and marked its Transactions: " . $status; } else { $TPL["message_help"][] = "Unable to close Time Sheet #" . $timeSheet->get_id() . " the sum of the Time Sheet's *Transactions* (" . page::money($timeSheet->get_value("currencyTypeID"), $total_timeSheet, "%s%mo %c") . ") is greater than the Invoice Item Transaction (" . page::money($currency, $total, "%s%mo %c") . ")"; } } } else { if ($expenseFormID) { $expenseForm = new expenseForm(); $expenseForm->set_id($expenseFormID); $expenseForm->select(); $total_expenseForm = $expenseForm->get_abs_sum_transactions(); if ($total == $total_expenseForm) { $expenseForm->set_status("approved"); $TPL["message_good"][] = "Approved Expense Form #" . $expenseForm->get_id() . "."; } else { $TPL["message_help"][] = "Unable to approve Expense Form #" . $expenseForm->get_id() . " the sum of Expense Form Transactions does not equal the Invoice Item Transaction."; } } } }
global $timeSheetItem; global $timeSheetItemID; global $db; $current_user =& singleton("current_user"); global $TPL; $timeSheetID = $_POST["timeSheetID"] or $timeSheetID = $_GET["timeSheetID"]; $db = new db_alloc(); $timeSheet = new timeSheet(); if ($timeSheetID) { $timeSheet = new timeSheet(); $timeSheet->set_id($timeSheetID); $timeSheet->select(); $timeSheet->set_values(); } // Manually update the Client Billing field if ($_REQUEST["updateCB"] && $timeSheet->get_id() && $timeSheet->can_edit_rate()) { $project = new project(); $project->set_id($timeSheet->get_value("projectID")); $project->select(); $timeSheet->set_value("customerBilledDollars", page::money($project->get_value("currencyTypeID"), $project->get_value("customerBilledDollars"), "%mo")); $timeSheet->set_value("currencyTypeID", $project->get_value("currencyTypeID")); $timeSheet->save(); } // Manually update the person's rate if ($_REQUEST["updateRate"] && $timeSheet->get_id() && $timeSheet->can_edit_rate()) { $row_projectPerson = projectPerson::get_projectPerson_row($timeSheet->get_value("projectID"), $timeSheet->get_value("personID")); if (!$row_projectPerson) { alloc_error("The person has not been added to the project."); } else { $q = prepare("SELECT timeSheetItemID from timeSheetItem WHERE timeSheetID = %d", $timeSheet->get_id()); $db = new db_alloc();
function add_timeSheetItem($stuff) { $current_user =& singleton("current_user"); $errstr = "Failed to record new time sheet item. "; $taskID = $stuff["taskID"]; $projectID = $stuff["projectID"]; $duration = $stuff["duration"]; $comment = $stuff["comment"]; $emailUID = $stuff["msg_uid"]; $emailMessageID = $stuff["msg_id"]; $date = $stuff["date"]; $unit = $stuff["unit"]; $multiplier = $stuff["multiplier"]; if ($taskID) { $task = new task(); $task->set_id($taskID); $task->select(); $projectID = $task->get_value("projectID"); $extra = " for task " . $taskID; } $projectID or alloc_error(sprintf($errstr . "No project found%s.", $extra)); $row_projectPerson = projectPerson::get_projectPerson_row($projectID, $current_user->get_id()); $row_projectPerson or alloc_error($errstr . "The person(" . $current_user->get_id() . ") has not been added to the project(" . $projectID . ")."); if ($row_projectPerson && $projectID) { if ($stuff["timeSheetID"]) { $q = prepare("SELECT *\n FROM timeSheet\n WHERE status = 'edit'\n AND personID = %d\n AND timeSheetID = %d\n ORDER BY dateFrom\n LIMIT 1\n ", $current_user->get_id(), $stuff["timeSheetID"]); $db = new db_alloc(); $db->query($q); $row = $db->row(); $row or alloc_error("Couldn't find an editable time sheet with that ID."); } else { $q = prepare("SELECT *\n FROM timeSheet\n WHERE status = 'edit'\n AND projectID = %d\n AND personID = %d\n ORDER BY dateFrom\n LIMIT 1\n ", $projectID, $current_user->get_id()); $db = new db_alloc(); $db->query($q); $row = $db->row(); } // If no timeSheets add a new one if (!$row) { $project = new project(); $project->set_id($projectID); $project->select(); $timeSheet = new timeSheet(); $timeSheet->set_value("projectID", $projectID); $timeSheet->set_value("status", "edit"); $timeSheet->set_value("personID", $current_user->get_id()); $timeSheet->set_value("recipient_tfID", $current_user->get_value("preferred_tfID")); $timeSheet->set_value("customerBilledDollars", page::money($project->get_value("currencyTypeID"), $project->get_value("customerBilledDollars"), "%mo")); $timeSheet->set_value("currencyTypeID", $project->get_value("currencyTypeID")); $timeSheet->save(); $timeSheetID = $timeSheet->get_id(); // Else use the first timesheet we found } else { $timeSheetID = $row["timeSheetID"]; } $timeSheetID or alloc_error($errstr . "Couldn't locate an existing, or create a new Time Sheet."); // Add new time sheet item if ($timeSheetID) { $timeSheet = new timeSheet(); $timeSheet->set_id($timeSheetID); $timeSheet->select(); $tsi = new timeSheetItem(); $tsi->currency = $timeSheet->get_value("currencyTypeID"); $tsi->set_value("timeSheetID", $timeSheetID); $d = $date or $d = date("Y-m-d"); $tsi->set_value("dateTimeSheetItem", $d); $tsi->set_value("timeSheetItemDuration", $duration); $tsi->set_value("timeSheetItemDurationUnitID", $unit); if (is_object($task)) { $tsi->set_value("description", $task->get_name()); $tsi->set_value("taskID", sprintf("%d", $taskID)); $_POST["timeSheetItem_taskID"] = sprintf("%d", $taskID); // this gets used in timeSheetItem->save(); } $tsi->set_value("personID", $current_user->get_id()); $tsi->set_value("rate", page::money($timeSheet->get_value("currencyTypeID"), $row_projectPerson["rate"], "%mo")); $tsi->set_value("multiplier", $multiplier); $tsi->set_value("comment", $comment); $tsi->set_value("emailUID", $emailUID); $tsi->set_value("emailMessageID", $emailMessageID); $tsi->save(); $id = $tsi->get_id(); $tsi = new timeSheetItem(); $tsi->set_id($id); $tsi->select(); $ID = $tsi->get_value("timeSheetID"); } } if ($ID) { return array("status" => "yay", "message" => $ID); } else { alloc_error($errstr . "Time not added."); } }
function save_invoice_timeSheetItems($invoiceID, $timeSheetID) { $timeSheet = new timeSheet(); $timeSheet->set_id($timeSheetID); $timeSheet->select(); $currency = $timeSheet->get_value("currencyTypeID"); $timeSheet->load_pay_info(); $amount = $timeSheet->pay_info["total_customerBilledDollars"] or $amount = $timeSheet->pay_info["total_dollars"]; $project = $timeSheet->get_foreign_object("project"); $client = $project->get_foreign_object("client"); $db = new db_alloc(); $q1 = $db->query(prepare("SELECT * FROM timeSheetItem WHERE timeSheetID = %d", $timeSheetID)); while ($row = $db->row($q1)) { if (imp($timeSheet->pay_info["customerBilledDollars"])) { $iiUnitPrice = $timeSheet->pay_info["customerBilledDollars"]; } else { $iiUnitPrice = page::money($currency, $row["rate"], "%mo"); } unset($str); if ($row["comment"] && !$row["commentPrivate"]) { $str = $row["comment"]; } // Look for an existing invoiceItem $q = prepare("SELECT invoiceItem.invoiceItemID\n FROM invoiceItem\n LEFT JOIN invoice ON invoiceItem.invoiceID = invoice.invoiceID\n WHERE invoiceItem.timeSheetID = %d\n AND invoiceItem.timeSheetItemID = %d\n AND invoiceItem.invoiceID = %d\n AND invoice.invoiceStatus != 'finished'\n ORDER BY iiDate DESC LIMIT 1\n ", $timeSheet->get_id(), $row["timeSheetItemID"], $invoiceID); $q2 = $db->query($q); $r2 = $db->row($q2); $ii = new invoiceItem(); if ($r2["invoiceItemID"]) { $ii->set_id($r2["invoiceItemID"]); } $ii->currency = $currency; $ii->set_value("invoiceID", $invoiceID); $ii->set_value("timeSheetID", $timeSheet->get_id()); $ii->set_value("timeSheetItemID", $row["timeSheetItemID"]); $ii->set_value("iiMemo", "Time Sheet for " . person::get_fullname($timeSheet->get_value("personID")) . ", Project: " . $project->get_value("projectName") . ", " . $row["description"] . "\n" . $str); $ii->set_value("iiQuantity", $row["timeSheetItemDuration"] * $row["multiplier"]); $ii->set_value("iiUnitPrice", $iiUnitPrice); $ii->set_value("iiAmount", $iiUnitPrice * $row["timeSheetItemDuration"] * $row["multiplier"]); $ii->set_value("iiDate", $row["dateTimeSheetItem"]); $ii->set_value("iiTax", config::get_config_item("taxPercent")); $ii->save(); } }
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 show_new_invoiceItem($template) { global $TPL; global $invoice; global $invoiceID; $current_user =& singleton("current_user"); // Don't show entry form if no ID if (!$invoiceID) { return; } $TPL["div1"] = ""; $TPL["div2"] = " class=\"hidden\""; $TPL["div3"] = " class=\"hidden\""; $TPL["div4"] = " class=\"hidden\""; if (is_object($invoice) && $invoice->get_value("invoiceStatus") == 'edit' && $current_user->have_role('admin')) { // If we are editing an existing invoiceItem if (is_array($_POST["invoiceItem_edit"])) { $invoiceItemID = key($_POST["invoiceItem_edit"]); $invoiceItem = new invoiceItem(); $invoiceItem->currency = $invoice->get_value("currencyTypeID"); $invoiceItem->set_id($invoiceItemID); $invoiceItem->select(); $invoiceItem->set_tpl_values("invoiceItem_"); $TPL["invoiceItem_buttons"] = ' <button type="submit" name="invoiceItem_delete[' . $invoiceItemID . ']" value="1" class="delete_button">Delete<i class="icon-trash"></i></button> <button type="submit" name="invoiceItem_save[' . $invoiceItemID . ']" value="1" class="save_button">Save Item<i class="icon-edit"></i></button> '; if ($invoiceItem->get_value("timeSheetID")) { unset($TPL["div2"]); $TPL["div1"] = " class=\"hidden\""; $TPL["sbs_link"] = "timeSheet_ii"; } else { if ($invoiceItem->get_value("expenseFormID")) { unset($TPL["div3"]); $TPL["div1"] = " class=\"hidden\""; $TPL["sbs_link"] = "expenseForm_ii"; } else { if ($invoiceItem->get_value("productSaleID")) { unset($TPL["div4"]); $TPL["div1"] = " class=\"hidden\""; $TPL["sbs_link"] = "productSale_ii"; } } } // Else default values for creating a new invoiceItem } else { $invoiceItem = new invoiceItem(); $invoiceItem->set_values("invoiceItem_"); $TPL["invoiceItem_buttons"] = ' <button type="submit" name="invoiceItem_save" value="1" class="save_button">Add Item<i class="icon-plus-sign"></i></button> '; } // Build dropdown lists for timeSheet and expenseForm options. if ($invoice->get_value("clientID")) { // Time Sheet dropdown $db = new db_alloc(); $q = prepare("SELECT projectID FROM project WHERE clientID = %d", $invoice->get_value("clientID")); $db->query($q); $projectIDs = array(); while ($row = $db->row()) { $projectIDs[] = $row["projectID"]; } if ($projectIDs) { $q = prepare("SELECT timeSheet.*, project.projectName \n FROM timeSheet\n LEFT JOIN project ON project.projectID = timeSheet.projectID \n WHERE timeSheet.projectID IN (%s) \n AND timeSheet.status != 'finished'\n GROUP BY timeSheet.timeSheetID\n ORDER BY timeSheetID\n ", $projectIDs); $db->query($q); $timeSheetStatii = timeSheet::get_timeSheet_statii(); while ($row = $db->row()) { $t = new timeSheet(); $t->read_db_record($db); $t->load_pay_info(); $dollars = $t->pay_info["total_customerBilledDollars"] or $dollars = $t->pay_info["total_dollars"]; $timeSheetOptions[$row["timeSheetID"]] = "Time Sheet #" . $t->get_id() . " " . $row["dateFrom"] . " " . $dollars . " for " . person::get_fullname($row["personID"]) . ", Project: " . $row["projectName"] . " [" . $timeSheetStatii[$t->get_value("status")] . "]"; } $TPL["timeSheetOptions"] = page::select_options($timeSheetOptions, $invoiceItem->get_value("timeSheetID"), 150); } // Expense Form dropdown $db = new db_alloc(); $q = prepare("SELECT expenseFormID, expenseFormCreatedUser\n FROM expenseForm \n WHERE expenseFormFinalised = 1 \n AND seekClientReimbursement = 1\n AND clientID = %d\n ORDER BY expenseForm.expenseFormCreatedTime", $invoice->get_value("clientID")); $db->query($q); while ($row = $db->row()) { $expenseFormOptions[$row["expenseFormID"]] = "Expense Form #" . $row["expenseFormID"] . " " . page::money(config::get_config_item("currency"), expenseForm::get_abs_sum_transactions($row["expenseFormID"]), "%s%m %c") . " " . person::get_fullname($row["expenseFormCreatedUser"]); } if ($invoiceItem->get_value("expenseFormID")) { $id = $invoiceItem->get_value("expenseFormID"); } $TPL["expenseFormOptions"] = page::select_options($expenseFormOptions, $id, 90); $q = prepare("SELECT *\n FROM productSale\n WHERE clientID = %d\n AND status = 'admin'\n ", $invoice->get_value("clientID")); $invoice->get_value("projectID") and $q .= prepare(" AND projectID = %d", $invoice->get_value("projectID")); $db->query($q); while ($row = $db->row()) { $productSale = new productSale(); $productSale->set_id($row["productSaleID"]); $productSale->select(); $ps_row = $productSale->get_amounts(); $productSaleOptions[$row["productSaleID"]] = "Sale #" . $row["productSaleID"] . " " . $ps_row["total_sellPrice"] . " " . person::get_fullname($row["personID"]); } if ($invoiceItem->get_value("productSaleID")) { $id = $invoiceItem->get_value("productSaleID"); } $TPL["productSaleOptions"] = page::select_options($productSaleOptions, $id, 90); } $TPL["invoiceItem_iiQuantity"] or $TPL["invoiceItem_iiQuantity"] = 1; $TPL["invoiceItem_invoiceID"] = $invoice->get_id(); include_template($template); } }