Example #1
0
 function get_all_parties($invoiceID)
 {
     if ($invoiceID) {
         $invoice = new invoice();
         $invoice->set_id($invoiceID);
         $invoice->select();
         $interestedPartyOptions = $invoice->get_all_partieS($invoice->get_value("projectID"), $invoice->get_value("clientID"));
     }
     if (is_object($this) && $this->get_id()) {
         $interestedPartyOptions = interestedParty::get_interested_parties("invoiceRepeat", $this->get_id(), $interestedPartyOptions);
     }
     return $interestedPartyOptions;
 }
Example #2
0
 function add_remove_ips($ip, $entity, $entityID, $projectID = null)
 {
     $parties = explode(",", $ip);
     foreach ($parties as $party) {
         $party = trim($party);
         // remove an ip
         if ($party[0] == "%") {
             list($personID, $name, $email) = interestedParty::expand_ip(implode("", array_slice(str_split($party), 1)), $projectID);
             interestedParty::delete_interested_party($entity, $entityID, $email);
             // add an ip
         } else {
             list($personID, $name, $email) = interestedParty::expand_ip($party, $projectID);
             if (!$email || strpos($email, "@") === false) {
                 alloc_error("Unable to add interested party: " . $party);
             } else {
                 interestedParty::add_interested_party(array("entity" => $entity, "entityID" => $entityID, "fullName" => $name, "emailAddress" => $email, "personID" => $personID));
             }
         }
     }
 }
Example #3
0
}
// If saving a record
if ($_POST["save"] || $_POST["save_and_back"] || $_POST["save_and_new"] || $_POST["save_and_summary"] || $_POST["timeSheet_save"] || $_POST["close_task"]) {
    $task->read_globals();
    if ($_POST["close_task"]) {
        $task->set_value("taskStatus", "closed_complete");
    }
    // If we're auto-nuking the pending tasks, we need to do that before the call to task->save()
    if ($task->get_id() && !$_POST["pendingTasksIDs"]) {
        $task->add_pending_tasks($_POST["pendingTasksIDs"]);
    }
    // Moved all validation over into task.inc.php save()
    $success = $task->save();
    count($msg) and $msg = "&message_good=" . urlencode(implode("<br>", $msg));
    if ($success) {
        interestedParty::make_interested_parties("task", $task->get_id(), $_POST["interestedParty"]);
        // A task can only have a pending task or pending reopen date - pending task is fixed up in JS, but check here too
        if ($task->get_value("taskStatus") != "pending_tasks") {
            $_POST['pendingTaskIDs'] = '';
        }
        $task->add_pending_tasks($_POST["pendingTasksIDs"]);
        $task->add_tags($_POST["tags"]);
        // This is only valid on pending_, but not on pending_task (because it has a different field)
        if (strpos($task->get_value("taskStatus"), "pending_") !== 0 || $task->get_value("taskStatus") == "pending_tasks") {
            $_POST['reopen_task'] = '';
        }
        $task->add_reopen_reminder($_POST["reopen_task"]);
        // Create reminders if necessary
        if ($_POST["createTaskReminder"] == true) {
            $task->create_task_reminder();
        }
Example #4
0
 function get_changes_list()
 {
     // This function returns HTML rows for the changes that have been made to this task
     $rows = array();
     $people_cache =& get_cached_table("person");
     $options = array("taskID" => $this->get_id());
     $changes = audit::get_list($options);
     foreach ($changes as $audit) {
         $changeDescription = "";
         $newValue = $audit['value'];
         switch ($audit['field']) {
             case 'created':
                 $changeDescription = $newValue;
                 break;
             case 'dip':
                 $changeDescription = "Default parties set to " . interestedParty::abbreviate($newValue);
                 break;
             case 'taskName':
                 $changeDescription = "Task name set to '{$newValue}'.";
                 break;
             case 'taskDescription':
                 $changeDescription = "Task description set to <a class=\"magic\" href=\"#x\" onclick=\"\$('#audit" . $audit["auditID"] . "').slideToggle('fast');\">Show</a> <div class=\"hidden\" id=\"audit" . $audit["auditID"] . "\"><div>" . $newValue . "</div></div>";
                 break;
             case 'priority':
                 $priorities = config::get_config_item("taskPriorities");
                 $changeDescription = sprintf('Task priority set to <span style="color: %s;">%s</span>.', $priorities[$newValue]["colour"], $priorities[$newValue]["label"]);
                 break;
             case 'projectID':
                 task::load_entity("project", $newValue, $newProject);
                 is_object($newProject) and $newProjectLink = $newProject->get_project_link();
                 $newProjectLink or $newProjectLink = "&lt;empty&gt;";
                 $changeDescription = "Project changed set to " . $newProjectLink . ".";
                 break;
             case 'parentTaskID':
                 task::load_entity("task", $newValue, $newTask);
                 if ($newValue) {
                     $changeDescription = sprintf("Task set to a child of %d %s.", $newTask->get_id(), $newTask->get_task_link());
                 } else {
                     $changeDescription = "Task no longer a child task.";
                 }
                 break;
             case 'duplicateTaskID':
                 task::load_entity("task", $newValue, $newTask);
                 if ($newValue) {
                     $changeDescription = "Task set to a duplicate of " . $newTask->get_task_link();
                 } else {
                     $changeDescription = "Task is no longer a duplicate.";
                 }
                 break;
             case 'personID':
                 $changeDescription = "Task assigned to " . $people_cache[$newValue]["name"] . ".";
                 break;
             case 'managerID':
                 $changeDescription = "Task manager set to " . $people_cache[$newValue]["name"] . ".";
                 break;
             case 'estimatorID':
                 $changeDescription = "Task estimator set to " . $people_cache[$newValue]["name"] . ".";
                 break;
             case 'taskTypeID':
                 $changeDescription = "Task type set to " . $newValue . ".";
                 break;
             case 'taskStatus':
                 $changeDescription = sprintf('Task status set to <span style="background-color:%s">%s</span>.', task::get_task_status_thing("colour", $newValue), task::get_task_status_thing("label", $newValue));
                 break;
             case 'dateActualCompletion':
             case 'dateActualStart':
             case 'dateTargetStart':
             case 'dateTargetCompletion':
             case 'timeLimit':
             case 'timeBest':
             case 'timeWorst':
             case 'timeExpected':
                 // these cases are more or less identical
                 switch ($audit['field']) {
                     case 'dateActualCompletion':
                         $fieldDesc = "actual completion date";
                         break;
                     case 'dateActualStart':
                         $fieldDesc = "actual start date";
                         break;
                     case 'dateTargetStart':
                         $fieldDesc = "estimate/target start date";
                         break;
                     case 'dateTargetCompletion':
                         $fieldDesc = "estimate/target completion date";
                         break;
                     case 'timeLimit':
                         $fieldDesc = "hours worked limit";
                         break;
                     case 'timeBest':
                         $fieldDesc = "best estimate";
                         break;
                     case 'timeWorst':
                         $fieldDesc = "worst estimate";
                         break;
                     case 'timeExpected':
                         $fieldDesc = "expected estimate";
                 }
                 if ($newValue) {
                     $changeDescription = "The {$fieldDesc} was set to {$newValue}.";
                 } else {
                     $changeDescription = "The {$fieldDesc} was removed.";
                 }
                 break;
         }
         $rows[] = "<tr><td class=\"nobr\">" . $audit["dateChanged"] . "</td><td>{$changeDescription}</td><td>" . page::htmlentities($people_cache[$audit["personID"]]["name"]) . "</td></tr>";
     }
     return implode("\n", $rows);
 }
Example #5
0
 function get_all_parties($projectID = "")
 {
     $db = new db_alloc();
     $interestedPartyOptions = array();
     if (!$projectID && is_object($this)) {
         $projectID = $this->get_value("projectID");
     }
     if ($projectID) {
         $project = new project($projectID);
         $interestedPartyOptions = $project->get_all_parties();
     }
     $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array();
     foreach ($extra_interested_parties as $name => $email) {
         $interestedPartyOptions[$email] = array("name" => $name);
     }
     if (is_object($this)) {
         if ($this->get_value("personID")) {
             $p = new person();
             $p->set_id($this->get_value("personID"));
             $p->select();
             $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_name(), "selected" => true, "personID" => $this->get_value("personID"));
         }
         if ($this->get_value("productSaleCreatedUser")) {
             $p = new person();
             $p->set_id($this->get_value("productSaleCreatedUser"));
             $p->select();
             $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_name(), "selected" => true, "personID" => $this->get_value("productSaleCreatedUser"));
         }
         $this_id = $this->get_id();
     }
     // return an aggregation of the current proj/client parties + the existing interested parties
     $interestedPartyOptions = interestedParty::get_interested_parties("productSale", $this_id, $interestedPartyOptions);
     return $interestedPartyOptions;
 }
Example #6
0
 function get_all_parties($projectID = "")
 {
     $db = new db_alloc();
     $interestedPartyOptions = array();
     if (!$projectID && is_object($this)) {
         $projectID = $this->get_value("projectID");
     }
     if ($projectID) {
         $project = new project($projectID);
         $interestedPartyOptions = $project->get_all_parties();
     }
     $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array();
     foreach ($extra_interested_parties as $name => $email) {
         $interestedPartyOptions[$email] = array("name" => $name);
     }
     if (is_object($this)) {
         if ($this->get_value("personID")) {
             $p = new person();
             $p->set_id($this->get_value("personID"));
             $p->select();
             $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_value("firstName") . " " . $p->get_value("surname"), "role" => "assignee", "selected" => false, "personID" => $this->get_value("personID"));
         }
         if ($this->get_value("approvedByManagerPersonID")) {
             $p = new person();
             $p->set_id($this->get_value("approvedByManagerPersonID"));
             $p->select();
             $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_value("firstName") . " " . $p->get_value("surname"), "role" => "manager", "selected" => true, "personID" => $this->get_value("approvedByManagerPersonID"));
         }
         $this_id = $this->get_id();
     }
     // return an aggregation of the current task/proj/client parties + the existing interested parties
     $interestedPartyOptions = interestedParty::get_interested_parties("timeSheet", $this_id, $interestedPartyOptions);
     return $interestedPartyOptions;
 }
Example #7
0
 function attach_email_to_existing_task($req = array())
 {
     global $TPL;
     $info = inbox::get_mail_info();
     $current_user =& singleton("current_user");
     $orig_current_user =& $current_user;
     $req["taskID"] = sprintf("%d", $req["taskID"]);
     $task = new task();
     $task->set_id($req["taskID"]);
     if ($task->select()) {
         $email_receive = new email_receive($info);
         $email_receive->open_mailbox($info["folder"]);
         $email_receive->set_msg($req["id"]);
         $email_receive->get_msg_header();
         $email_receive->save_email();
         $c = comment::add_comment_from_email($email_receive, $task);
         $commentID = $c->get_id();
         $commentID and $TPL["message_good_no_esc"][] = "Created comment " . $commentID . " on task " . $task->get_task_link(array("prefixTaskID" => true));
         // Possibly change the identity of current_user
         list($from_address, $from_name) = parse_email_address($email_receive->mail_headers["from"]);
         $person = new person();
         $personID = $person->find_by_email($from_address);
         $personID or $personID = $person->find_by_name($from_name);
         if ($personID) {
             $current_user = new person();
             $current_user->load_current_user($personID);
             singleton("current_user", $current_user);
         }
         // swap back to normal user
         $current_user =& $orig_current_user;
         singleton("current_user", $current_user);
         // manually add task manager and assignee to ip list
         $extraips = array();
         if ($task->get_value("personID")) {
             $p = new person($task->get_value("personID"));
             if ($p->get_value("emailAddress")) {
                 $extraips[$p->get_value("emailAddress")]["name"] = $p->get_name();
                 $extraips[$p->get_value("emailAddress")]["role"] = "assignee";
                 $extraips[$p->get_value("emailAddress")]["personID"] = $task->get_value("personID");
                 $extraips[$p->get_value("emailAddress")]["selected"] = 1;
             }
         }
         if ($task->get_value("managerID")) {
             $p = new person($task->get_value("managerID"));
             if ($p->get_value("emailAddress")) {
                 $extraips[$p->get_value("emailAddress")]["name"] = $p->get_name();
                 $extraips[$p->get_value("emailAddress")]["role"] = "manager";
                 $extraips[$p->get_value("emailAddress")]["personID"] = $task->get_value("managerID");
                 $extraips[$p->get_value("emailAddress")]["selected"] = 1;
             }
         }
         // add all the other interested parties
         $ips = interestedParty::get_interested_parties("task", $req["taskID"], $extraips);
         foreach ((array) $ips as $k => $inf) {
             $inf["entity"] = "comment";
             $inf["entityID"] = $commentID;
             $inf["email"] and $inf["emailAddress"] = $inf["email"];
             if ($req["emailto"] == "internal" && !$inf["external"] && !$inf["clientContactID"]) {
                 $id = interestedParty::add_interested_party($inf);
                 $recipients[] = $inf["name"] . " " . add_brackets($k);
             } else {
                 if ($req["emailto"] == "default") {
                     $id = interestedParty::add_interested_party($inf);
                     $recipients[] = $inf["name"] . " " . add_brackets($k);
                 }
             }
         }
         $recipients and $recipients = implode(", ", (array) $recipients);
         $recipients and $TPL["message_good"][] = "Sent email to " . $recipients;
         // Re-email the comment out
         comment::send_comment($commentID, array("interested"), $email_receive);
         // File email away in the task's mail folder
         $mailbox = "INBOX/task" . $task->get_id();
         $email_receive->create_mailbox($mailbox) and $TPL["message_good"][] = "Created mailbox: " . $mailbox;
         $email_receive->move_mail($req["id"], $mailbox) and $TPL["message_good"][] = "Moved email " . $req["id"] . " to " . $mailbox;
         $email_receive->close();
     }
 }
Example #8
0
 function add_interested_parties($commentID, $ip = array(), $op = array())
 {
     // We send this email to the default from address, so that a copy of the
     // original email is kept. The receiveEmail.php script will see that this
     // email is *from* the same address, and will then skip over it, when going
     // through the new emails.
     if (defined("ALLOC_DEFAULT_FROM_ADDRESS") && ALLOC_DEFAULT_FROM_ADDRESS) {
         list($from_address, $from_name) = parse_email_address(ALLOC_DEFAULT_FROM_ADDRESS);
         $emailRecipients[] = $from_address;
     }
     interestedParty::make_interested_parties("comment", $commentID, $ip);
     $emailRecipients[] = "interested";
     // Other parties that are added on-the-fly
     foreach ((array) $op as $email => $info) {
         if ($email && in_str("@", $email)) {
             unset($lt, $gt);
             // used above
             $str = $info["name"];
             $str and $str .= " ";
             $str and $lt = "<";
             $str and $gt = ">";
             $str .= $lt . str_replace(array("<", ">"), "", $email) . $gt;
             $emailRecipients[] = $str;
             // Add a new client contact
             if ($info["addContact"] && $info["clientID"]) {
                 $q = prepare("SELECT * FROM clientContact WHERE clientID = %d AND clientContactEmail = '%s'", $info["clientID"], trim($email));
                 $db = new db_alloc();
                 if (!$db->qr($q)) {
                     $cc = new clientContact();
                     $cc->set_value("clientContactName", trim($info["name"]));
                     $cc->set_value("clientContactEmail", trim($email));
                     $cc->set_value("clientID", sprintf("%d", $info["clientID"]));
                     $cc->save();
                 }
             }
             // Add the person to the interested parties list
             if ($info["addIP"] && !interestedParty::exists("comment", $commentID, trim($email))) {
                 $interestedParty = new interestedParty();
                 $interestedParty->set_value("fullName", trim($info["name"]));
                 $interestedParty->set_value("emailAddress", trim($email));
                 $interestedParty->set_value("entityID", $commentID);
                 $interestedParty->set_value("entity", "comment");
                 $interestedParty->set_value("external", $info["internal"] ? "0" : "1");
                 $interestedParty->set_value("interestedPartyActive", "1");
                 if (is_object($cc) && $cc->get_id()) {
                     $interestedParty->set_value("clientContactID", $cc->get_id());
                 }
                 $interestedParty->save();
             }
         }
     }
     return $emailRecipients;
 }
Example #9
0
 function get_all_parties($clientID = false)
 {
     if (!$clientID && is_object($this)) {
         $clientID = $this->get_id();
     }
     if ($clientID) {
         // Get all client contacts
         $db = new db_alloc();
         $q = prepare("SELECT clientContactName, clientContactEmail, clientContactID \n                      FROM clientContact \n                     WHERE clientID = %d\n                       AND clientContactActive = 1\n                     ", $clientID);
         $db->query($q);
         while ($db->next_record()) {
             $interestedPartyOptions[$db->f("clientContactEmail")] = array("name" => $db->f("clientContactName"), "external" => "1", "clientContactID" => $db->f("clientContactID"));
         }
     }
     // return an aggregation of the current task/proj/client parties + the existing interested parties
     $interestedPartyOptions = interestedParty::get_interested_parties("client", $clientID, $interestedPartyOptions);
     return (array) $interestedPartyOptions;
 }
Example #10
0
function show_comments()
{
    global $invoiceID;
    global $TPL;
    global $invoice;
    if ($invoiceID) {
        $TPL["commentsR"] = comment::util_get_comments("invoice", $invoiceID);
        $TPL["class_new_comment"] = "hidden";
        if ($invoice->get_value("projectID")) {
            $project = $invoice->get_foreign_object("project");
            $interestedPartyOptions = $project->get_all_parties($invoice->get_value("projectID"));
            $client = $project->get_foreign_object("client");
            $clientID = $client->get_id();
        } else {
            if ($invoice->get_value("clientID")) {
                $client = $invoice->get_foreign_object("client");
                $interestedPartyOptions = $client->get_all_parties($invoice->get_value("clientID"));
                $clientID = $client->get_id();
            }
        }
        $interestedPartyOptions = interestedParty::get_interested_parties("invoice", $invoice->get_id(), $interestedPartyOptions);
        $TPL["allParties"] = $interestedPartyOptions or $TPL["allParties"] = array();
        $TPL["entity"] = "invoice";
        $TPL["entityID"] = $invoice->get_id();
        $TPL["clientID"] = $clientID;
        $commentTemplate = new commentTemplate();
        $ops = $commentTemplate->get_assoc_array("commentTemplateID", "commentTemplateName", "", array("commentTemplateType" => "invoice"));
        $TPL["commentTemplateOptions"] = "<option value=\"\">Comment Templates</option>" . page::select_options($ops);
        $ops = array("" => "Format as...", "generate_pdf" => "PDF Invoice", "generate_pdf_verbose" => "PDF Invoice - verbose");
        $TPL["attach_extra_files"] = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        $TPL["attach_extra_files"] .= "Attach Invoice ";
        $TPL["attach_extra_files"] .= '<select name="attach_invoice">' . page::select_options($ops) . '</select><br>';
        include_template("../comment/templates/commentM.tpl");
    }
}
Example #11
0
 function get_all_parties($projectID = "", $clientID = "")
 {
     $db = new db_alloc();
     $interestedPartyOptions = array();
     if (!$projectID && is_object($this)) {
         $projectID = $this->get_value("projectID");
     }
     if ($projectID) {
         $project = new project($projectID);
         $interestedPartyOptions = $project->get_all_parties();
     }
     if ($clientID) {
         $client = new client($clientID);
         $interestedPartyOptions = array_merge((array) $interestedPartyOptions, (array) $client->get_all_parties());
     }
     $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array();
     foreach ($extra_interested_parties as $name => $email) {
         $interestedPartyOptions[$email] = array("name" => $name);
     }
     // return an aggregation of the current task/proj/client parties + the existing interested parties
     $interestedPartyOptions = interestedParty::get_interested_parties("invoice", $this->get_id(), $interestedPartyOptions);
     return $interestedPartyOptions;
 }
Example #12
0
 /**
  * Deactivate (not delete) an interested party
  * @param array $options see shared/lib/interestedParty.inc.php [add|delete]_interested_party()
  */
 public function delete_interestedParty($options)
 {
     // Python will submit None instead of ''
     foreach ($options as $k => $v) {
         strtolower($v) != 'none' and $data[$k] = $v;
     }
     // Delete existing entries
     if ($data["entity"] && $data["entityID"] && $data["emailAddress"]) {
         interestedParty::delete_interested_party($data["entity"], $data["entityID"], $data["emailAddress"]);
     }
 }
Example #13
0
 function add_comment($commands)
 {
     $commentID = comment::add_comment($commands["entity"], $commands["entityID"], $commands["comment_text"]);
     // add interested parties
     foreach ((array) $commands["ip"] as $k => $info) {
         $info["entity"] = "comment";
         $info["entityID"] = $commentID;
         interestedParty::add_interested_party($info);
     }
     $emailRecipients = array();
     $emailRecipients[] = "interested";
     if (defined("ALLOC_DEFAULT_FROM_ADDRESS") && ALLOC_DEFAULT_FROM_ADDRESS) {
         list($from_address, $from_name) = parse_email_address(ALLOC_DEFAULT_FROM_ADDRESS);
         $emailRecipients[] = $from_address;
     }
     // Re-email the comment out
     comment::send_comment($commentID, $emailRecipients);
     return array($status, $message);
 }
Example #14
0
 * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions
 * Pty. Ltd.
 * 
 * This file is part of the allocPSA application <*****@*****.**>.
 * 
 * allocPSA is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "../alloc.php";
$current_user =& singleton("current_user");
$db = new db_alloc();
$invoiceRepeat = new invoiceRepeat($_REQUEST["invoiceRepeatID"]);
if ($_POST["save"]) {
    $invoiceRepeat->set_value("invoiceID", $_POST["invoiceID"]);
    $invoiceRepeat->set_value("message", $_POST["message"]);
    $invoiceRepeat->set_value("active", 1);
    $invoiceRepeat->set_value("personID", $current_user->get_id());
    $invoiceRepeat->save($_POST["frequency"]);
    interestedParty::make_interested_parties("invoiceRepeat", $invoiceRepeat->get_id(), $_POST["commentEmailRecipients"]);
}
alloc_redirect($TPL["url_alloc_invoice"] . "invoiceID=" . $_POST["invoiceID"]);
Example #15
0
function show_comments()
{
    global $projectID;
    global $TPL;
    global $project;
    $TPL["commentsR"] = comment::util_get_comments("project", $projectID);
    $TPL["commentsR"] and $TPL["class_new_comment"] = "hidden";
    $interestedPartyOptions = $project->get_all_parties();
    $interestedPartyOptions = interestedParty::get_interested_parties("project", $project->get_id(), $interestedPartyOptions);
    $TPL["allParties"] = $interestedPartyOptions or $TPL["allParties"] = array();
    $TPL["entity"] = "project";
    $TPL["entityID"] = $project->get_id();
    $TPL["clientID"] = $project->get_value("clientID");
    $commentTemplate = new commentTemplate();
    $ops = $commentTemplate->get_assoc_array("commentTemplateID", "commentTemplateName", "", array("commentTemplateType" => "project"));
    $TPL["commentTemplateOptions"] = "<option value=\"\">Comment Templates</option>" . page::select_options($ops);
    $ops = array("" => "Format as...", "pdf" => "PDF", "pdf_plus" => "PDF+", "html" => "HTML", "html_plus" => "HTML+");
    $TPL["attach_extra_files"] = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    $TPL["attach_extra_files"] .= "Attach Task Report ";
    $TPL["attach_extra_files"] .= '<select name="attach_tasks">' . page::select_options($ops) . '</select><br>';
    include_template("../comment/templates/commentM.tpl");
}
Example #16
0
<?php

/*
 * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions
 * Pty. Ltd.
 * 
 * This file is part of the allocPSA application <*****@*****.**>.
 * 
 * allocPSA is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
define("NO_REDIRECT", 1);
require_once "../alloc.php";
interestedParty::make_interested_parties('comment', $_POST['commentID'], $_POST['comment_recipients']);
if (interestedParty::is_external('comment', $_POST['commentID'])) {
    echo 'external';
} else {
    echo 'internal';
}
Example #17
0
 function get_changes_list()
 {
     // This function returns HTML rows for the changes that have been made to this project
     $rows = array();
     $people_cache =& get_cached_table("person");
     $timeUnit = new timeUnit();
     $timeUnits = array_reverse($timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelA"), true);
     $options = array("projectID" => $this->get_id());
     $changes = audit::get_list($options);
     foreach ((array) $changes as $audit) {
         $changeDescription = "";
         $newValue = $audit['value'];
         switch ($audit['field']) {
             case 'created':
                 $changeDescription = $newValue;
                 break;
             case 'dip':
                 $changeDescription = "Default parties set to " . interestedParty::abbreviate($newValue);
                 break;
             case 'projectShortName':
                 $changeDescription = "Project nickname set to '{$newValue}'.";
                 break;
             case 'projectComments':
                 $changeDescription = "Project description set to <a class=\"magic\" href=\"#x\" onclick=\"\$('#audit" . $audit["auditID"] . "').slideToggle('fast');\">Show</a> <div class=\"hidden\" id=\"audit" . $audit["auditID"] . "\"><div>" . $newValue . "</div></div>";
                 break;
             case 'clientID':
                 $newClient = new client($newValue);
                 is_object($newClient) and $newClientLink = $newClient->get_link();
                 $newClientLink or $newClientLink = "&lt;empty&gt;";
                 $changeDescription = "Client set to " . $newClientLink . ".";
                 break;
             case 'clientContactID':
                 $newClientContact = new clientContact($newValue);
                 is_object($newClientContact) and $newClientContactLink = $newClientContact->get_link();
                 $newClientContactLink or $newClientContactLink = "&lt;empty&gt;";
                 $changeDescription = "Client contact set to " . $newClientContactLink . ".";
                 break;
             case 'projectType':
                 $changeDescription = "Project type set to " . $newValue . ".";
                 break;
             case 'projectBudget':
                 $changeDescription = "Project budget set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'currencyTypeID':
                 $changeDescription = "Project currency set to " . $newValue . ".";
                 break;
             case 'projectStatus':
                 $changeDescription = "Project status set to " . $newValue . ".";
                 break;
             case 'projectName':
                 $changeDescription = "Project name set to '{$newValue}'.";
                 break;
             case 'cost_centre_tfID':
                 $newCostCentre = new tf($newValue);
                 is_object($newCostCentre) and $newCostCentreLink = $newCostCentre->get_link();
                 $newCostCentreLink or $newCostCentreLink = "&lt;empty&gt;";
                 $changeDescription = "Cost centre TF set to " . $newCostCentreLink . ".";
                 break;
             case 'customerBilledDollars':
                 $changeDescription = "Client billing set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'defaultTaskLimit':
                 $changeDescription = "Default task limit set to " . $newValue . ".";
                 break;
             case 'defaultTimeSheetRate':
                 $changeDescription = "Default time sheet rate set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'defaultTimeSheetRateUnitID':
                 $changeDescription = "Default time sheet rate unit set to '" . $timeUnits[$newValue] . "'.";
                 break;
             case 'projectPriority':
                 $priorities = config::get_config_item("projectPriorities");
                 $changeDescription = sprintf('Project priority set to <span style="color: %s;">%s</span>.', $priorities[$newValue]["colour"], $priorities[$newValue]["label"]);
                 break;
             case 'dateActualCompletion':
             case 'dateActualStart':
             case 'dateTargetStart':
             case 'dateTargetCompletion':
                 // these cases are more or less identical
                 switch ($audit['field']) {
                     case 'dateActualCompletion':
                         $fieldDesc = "actual completion date";
                         break;
                     case 'dateActualStart':
                         $fieldDesc = "actual start date";
                         break;
                     case 'dateTargetStart':
                         $fieldDesc = "estimate/target start date";
                         break;
                     case 'dateTargetCompletion':
                         $fieldDesc = "estimate/target completion date";
                         break;
                 }
                 if (!$newValue) {
                     $changeDescription = "The {$fieldDesc} was removed.";
                 } else {
                     $changeDescription = "The {$fieldDesc} set to {$newValue}.";
                 }
                 break;
         }
         $rows[] = "<tr><td class=\"nobr\">" . $audit["dateChanged"] . "</td><td>{$changeDescription}</td><td>" . page::htmlentities($people_cache[$audit["personID"]]["name"]) . "</td></tr>";
     }
     return implode("\n", $rows);
 }
Example #18
0
function show_comments()
{
    global $clientID;
    global $TPL;
    global $client;
    $TPL["commentsR"] = comment::util_get_comments("client", $clientID);
    $TPL["commentsR"] and $TPL["class_new_comment"] = "hidden";
    $interestedPartyOptions = $client->get_all_parties();
    $interestedPartyOptions = interestedParty::get_interested_parties("client", $client->get_id(), $interestedPartyOptions);
    $TPL["allParties"] = $interestedPartyOptions or $TPL["allParties"] = array();
    $TPL["entity"] = "client";
    $TPL["entityID"] = $client->get_id();
    $TPL["clientID"] = $client->get_id();
    $commentTemplate = new commentTemplate();
    $ops = $commentTemplate->get_assoc_array("commentTemplateID", "commentTemplateName", "", array("commentTemplateType" => "client"));
    $TPL["commentTemplateOptions"] = "<option value=\"\">Comment Templates</option>" . page::select_options($ops);
    include_template("../comment/templates/commentM.tpl");
}
Example #19
0
 #echo "<br>Created invoice: ".$i->get_id();
 $q = prepare("SELECT * FROM invoiceItem WHERE invoiceID = %d", $invoice->get_id());
 $id2 = $db->query($q);
 while ($item = $db->row($id2)) {
     $ii = new invoiceItem();
     $ii->currency = $i->get_value("currencyTypeID");
     $ii->set_value("invoiceID", $i->get_id());
     $ii->set_value("iiMemo", $item["iiMemo"]);
     $ii->set_value("iiUnitPrice", page::money($ii->currency, $item["iiUnitPrice"], "%mo"));
     $ii->set_value("iiAmount", page::money($ii->currency, $item["iiAmount"], "%mo"));
     $ii->set_value("iiQuantity", $item["iiQuantity"]);
     $ii->save();
     #echo "<br>Created invoice item: ".$ii->get_id();
 }
 if ($row["message"]) {
     $ips = interestedParty::get_interested_parties("invoiceRepeat", $row["invoiceRepeatID"]);
     $recipients = array();
     foreach ($ips as $email => $info) {
         $recipients[$email] = $info;
         $recipients[$email]["addIP"] = true;
     }
     $commentID = comment::add_comment("invoice", $i->get_id(), $row["message"], "invoice", $i->get_id());
     if ($recipients) {
         $emailRecipients = comment::add_interested_parties($commentID, null, $recipients);
         comment::attach_invoice($commentID, $i->get_id(), $verbose = true);
         // Re-email the comment out, including any attachments
         if (!comment::send_comment($commentID, $emailRecipients)) {
             alloc_error("Failed to email invoice: " . $i->get_id());
         }
     }
 }