function save() { $current_user =& singleton("current_user"); $timeSheet = new timeSheet(); $timeSheet->set_id($this->get_value("timeSheetID")); $timeSheet->select(); $timeSheet->load_pay_info(); list($amount_used, $amount_allocated) = $timeSheet->get_amount_allocated("%mo"); $this->currency = $timeSheet->get_value("currencyTypeID"); $this->set_value("comment", rtrim($this->get_value("comment"))); $amount_of_item = $this->calculate_item_charge($timeSheet->get_value("currencyTypeID"), $timeSheet->get_value("customerBilledDollars")); if ($amount_allocated && $amount_of_item + $amount_used > $amount_allocated) { alloc_error("Adding this Time Sheet Item would exceed the amount allocated on the Pre-paid invoice. Time Sheet Item not saved."); } // If unit is changed via CLI if ($this->get_value("timeSheetItemDurationUnitID") && $timeSheet->pay_info["project_rateUnitID"] && $timeSheet->pay_info["project_rateUnitID"] != $this->get_value("timeSheetItemDurationUnitID") && !$timeSheet->can_edit_rate()) { alloc_error("Not permitted to edit time sheet item unit."); } if (!$this->get_value("timeSheetItemDurationUnitID") && $timeSheet->pay_info["project_rateUnitID"]) { $this->set_value("timeSheetItemDurationUnitID", $timeSheet->pay_info["project_rateUnitID"]); } // Last ditch perm checking - useful for the CLI if (!is_object($timeSheet) || !$timeSheet->get_id()) { alloc_error("Unknown time sheet."); } if ($timeSheet->get_value("status") != "edit" && !$this->skip_tsi_status_check) { alloc_error("Time sheet is not at status edit"); } if (!$this->is_owner()) { alloc_error("Time sheet is not editable for you."); } $rtn = parent::save(); $timeSheet->update_related_invoices(); return $rtn; }
foreach ($projectManagers as $pID) { $TPL["managers"] .= $commar . $people[$pID]["name"]; $commar = ", "; } } $clientID = $project->get_value("clientID"); $projectID = $project->get_id(); // Get client name $client = $project->get_foreign_object("client"); $TPL["clientName"] = $client_link; $TPL["clientID"] = $clientID = $client->get_id(); $TPL["show_client_options"] = $client_link; } list($client_select, $client_link, $project_select, $project_link) = client::get_client_and_project_dropdowns_and_links($clientID, $projectID, true); $TPL["invoice_link"] = $timeSheet->get_invoice_link(); list($amount_used, $amount_allocated) = $timeSheet->get_amount_allocated(); if ($amount_allocated) { $TPL["amount_allocated_label"] = "Amount Used / Allocated:"; $TPL["amount_allocated"] = $amount_allocated; $TPL["amount_used"] = $amount_used . " / "; } if (!$timeSheet->get_id() || $timeSheet->get_value("status") == "edit" || $timeSheet->get_value("status") == "rejected") { $TPL["show_project_options"] = $project_select; $TPL["show_client_options"] = $client_select; } else { $TPL["show_project_options"] = $project_link; $TPL["show_client_options"] = $client_link; } if (is_object($timeSheet) && $timeSheet->get_id() && $timeSheet->have_perm(PERM_TIME_INVOICE_TIMESHEETS) && !$timeSheet->get_invoice_link() && $timeSheet->get_value("status") != "finished") { $p = $timeSheet->get_foreign_object("project"); $ops["invoiceStatus"] = "edit";