function email_move_status_to_finished($direction, $info) { if ($direction == "forwards") { //requires INVOICE_TIMESHEETS if (!$this->have_perm(PERM_TIME_INVOICE_TIMESHEETS)) { //no permission, go away alloc_error("You do not have permission to change this timesheet."); } //transactions $q = prepare("SELECT DISTINCT transaction.transactionDate, transaction.product, transaction.status\n FROM transaction\n JOIN tf ON tf.tfID = transaction.tfID OR tf.tfID = transaction.fromTfID\n RIGHT JOIN tfPerson ON tfPerson.personID = %d AND tfPerson.tfID = tf.tfID\n WHERE transaction.timeSheetID = %d\n ", $this->get_value('personID'), $this->get_id()); $db = new db_alloc(); $db->query($q); //the email itself $email = array(); $email["type"] = "timesheet_finished"; $email["to"] = $info["timeSheet_personID_email"]; $email["subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_timeSheetCompleted"), "timeSheet", $this->get_id()); $email["body"] = <<<EOD To: {$info["timeSheet_personID_name"]} Time Sheet: {$info["url"]} For Project: {$info["projectName"]} Your timesheet has been completed by {$info["current_user_name"]}. EOD; if ($db->num_rows() > 0) { $email["body"] .= "Transaction summary:\n"; $status_ops = array("pending" => "Pending", "approved" => "Approved", "rejected" => "Rejected"); while ($db->next_record()) { $email["body"] .= $db->f("transactionDate") . " for " . $db->f("product") . ": " . $status_ops[$db->f("status")] . "\n"; } } $msg[] = $this->shootEmail($email); $this->set_value("status", "finished"); return $msg; } }
$person->set_value("perms", implode(",", $_POST["perm_select"])); } if ($_POST["password1"] && $_POST["password1"] == $_POST["password2"]) { $person->set_value('password', encrypt_password($_POST["password1"])); } else { if (!$_POST["password1"] && $personID) { // nothing required here, just don't update the password field } else { alloc_error("Please re-type the passwords"); } } if ($_POST["username"]) { $q = prepare("SELECT personID FROM person WHERE username = '******'", $_POST["username"]); $db = new db_alloc(); $db->query($q); $num_rows = $db->num_rows(); $row = $db->row(); if ($num_rows > 0 && !$person->get_id() || $num_rows > 0 && $person->get_id() != $row["personID"]) { alloc_error("That username is already taken. Please select another."); } } else { alloc_error("Please enter a username."); } $person->set_value("personActive", $_POST["personActive"] ? 1 : "0"); $max_alloc_users = get_max_alloc_users(); if (!$person->get_id() && $max_alloc_users && get_num_alloc_users() >= $max_alloc_users && $_POST["personActive"]) { alloc_error(get_max_alloc_users_message()); } if (!$TPL["message"]) { $person->set_value("availability", rtrim($person->get_value("availability"))); $person->set_value("areasOfInterest", rtrim($person->get_value("areasOfInterest")));