if ($parentType == "client") { $TPL["return_address"] = $TPL["url_alloc_client"] . "clientID=" . $parentID; $TPL["reminder_goto_parent"] = "<a href=\"" . $TPL["return_address"] . "\">Goto Client</a>"; } else { if ($parentType == "project") { $TPL["return_address"] = $TPL["url_alloc_project"] . "projectID=" . $parentID; $TPL["reminder_goto_parent"] = "<a href=\"" . $TPL["return_address"] . "\">Goto Project</a>"; } else { if ($parentType == "task") { $TPL["return_address"] = $TPL["url_alloc_task"] . "taskID=" . $parentID; $TPL["reminder_goto_parent"] = "<a href=\"" . $TPL["return_address"] . "\">Goto Task</a>"; } } } // recipients list($TPL["reminder_recipients"], $TPL["selected_recipients"]) = $reminder->get_recipient_options(); $recipients_display = array(); foreach ($TPL["selected_recipients"] as $recipient) { $recipients_display[] = $TPL["reminder_recipients"][$recipient]; } $TPL['recipients_display'] = implode($recipients_display, ", "); // date/time $_GET["reminderTime"] && $reminder->set_value("reminderTime", $_GET["reminderTime"]); $TPL["reminderTime"] = $reminder->get_value("reminderTime"); $TPL["reminderHash"] = $reminder->get_value("reminderHash"); $TPL["reminderAdvNoticeInterval"] = $reminder->get_value("reminderAdvNoticeInterval"); $TPL["reminderRecuringInterval"] = $reminder->get_value("reminderRecuringInterval"); $TPL["reminderID"] = $reminder->get_id(); list($d, $t) = explode(" ", $reminder->get_value("reminderTime")); $TPL["reminder_date"] = $d or $TPL["reminder_date"] = date("Y-m-d"); $TPL["reminder_hours"] = $reminder->get_hour_options();
function edit_reminder($commands) { $id = $commands["reminder"]; $options = $commands; $reminder = new reminder(); if ($id and $id != "new") { $reminder->set_id($id); $reminder->select(); } else { if ($id == "new") { // extra sanity checks, partially filled in reminder isn't much good if (!$options['date'] || !$options['subject'] || !$options['recipients']) { $status[] = "err"; $message[] = "Missing one of date, subject or recipients."; return array($status, $message); } if ($options['task']) { $reminder->set_value('reminderType', 'task'); $reminder->set_value('reminderLinkID', $options['task']); } else { if ($options['project']) { $reminder->set_value('reminderType', 'project'); $reminder->set_value('reminderLinkID', $options['project']); } else { if ($options['client']) { $reminder->set_value('reminderLinkID', $options['client']); $reminder->set_value('reminderType', 'client'); } } } } } // Tear apart the frequency bits if ($options['frequency']) { list($freq, $units) = sscanf($options['frequency'], "%d%c"); $freq_units = array('h' => 'Hour', 'd' => 'Day', 'w' => 'Week', 'm' => 'Month', 'y' => 'Year'); $options['frequency'] = $freq; $options['frequency_units'] = $freq_units[strtolower($units)]; } if ($options['notice']) { list($freq, $units) = sscanf($options['notice'], "%d%c"); $freq_units = array('h' => 'Hour', 'd' => 'Day', 'w' => 'Week', 'm' => 'Month', 'y' => 'Year'); $options['notice'] = $freq; $options['notice_units'] = $freq_units[strtolower($units)]; } $fields = $this->get_fields("reminder"); foreach ($fields as $s => $d) { if ($options[$s]) { $reminder->set_value($d[0], $options[$s]); } } if (!$reminder->get_value("reminderRecuringInterval")) { $reminder->set_value("reminderRecuringInterval", "No"); } if (!$reminder->get_value("reminderAdvNoticeInterval")) { $reminder->set_value("reminderAdvNoticeInterval", "No"); } $reminder->save(); // Deal with recipients if ($options['recipients']) { list($_x, $recipients) = $reminder->get_recipient_options(); if ($options['recipients']) { $recipients = array_unique(array_merge($recipients, $options['recipients'])); } if ($options['recipients_remove']) { $recipients = array_diff($recipients, $options['recipients_remove']); } $reminder->update_recipients($recipients); } if (is_object($reminder) && $reminder->get_id()) { $status[] = "yay"; $message[] = "Reminder " . $reminder->get_id() . " saved."; } else { $status[] = "err"; $message[] = "Reminder not saved."; } return array($status, $message); }