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; }
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();