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; }
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"); }
function get_one_comment_array($v = array(), $all_parties = array()) { global $TPL; $current_user =& singleton("current_user"); $new = $v; $token = new token(); if ($token->select_token_by_entity_and_action("comment", $new["commentID"], "add_comment_from_email")) { if ($token->get_value("tokenHash")) { $new["hash"] = $token->get_value("tokenHash"); $new["hashKey"] = "{Key:" . $new["hash"] . "}"; $new["hashHTML"] = " <em class=\"faint\">" . $new["hashKey"] . "</em>"; } $ip = interestedParty::get_interested_parties("comment", $new["commentID"]); foreach ((array) $ip as $email => $info) { $all_parties += $ip; if ($info["selected"]) { $sel[] = $email; } } foreach ($all_parties as $email => $i) { in_array($email, (array) $sel) and $recipient_selected[] = $i["identifier"]; } if (interestedParty::is_external("comment", $new["commentID"])) { $new["external"] = " loud"; $label = "<em class='faint warn'>[ External Conversation ]</em>"; } else { $label = "<em class='faint'>[ Internal Conversation ]</em>"; } foreach ((array) $all_parties as $email => $info) { $recipient_ops[$info["identifier"]] = $info["name"] . " <" . $email . ">"; } $new["recipient_editor"] = "<span class='nobr' style='width:100%;display:inline;' class='recipient_editor'>"; $new["recipient_editor"] .= "<span class='noprint hidden' id='recipient_dropdown_" . $new["commentID"] . "'>\n <form action='" . $TPL["url_alloc_updateRecipients"] . "' method='post'>\n <select name='comment_recipients[]' multiple='true' data-callback='save_recipients'>\n " . page::select_options($recipient_ops, $recipient_selected) . "\n </select>\n <input type='hidden' name='commentID' value='" . $new["commentID"] . "'>\n <input type='submit' value='Go' style='display:none'>\n </form>\n </span>"; $new["recipient_editor"] .= "<a class='magic recipient_editor_link' id='r_e_" . $new["commentID"] . "' style='text-decoration:none' href='#x'>" . $label . "</a>"; $new["recipient_editor"] .= "</span>"; $new["reply"] = '<a href="" class="noprint commentreply">reply</a>'; } if ($v["timeSheetID"]) { $timeSheet = new timeSheet(); $timeSheet->set_id($v["timeSheetID"]); $v["ts_label"] = " (Time Sheet #" . $timeSheet->get_id() . ")"; } $new["attribution"] = comment::get_comment_attribution($v); $new["commentCreatedUserEmail"] = comment::get_comment_author_email($v); $s = commentTemplate::populate_string(config::get_config_item("emailSubject_taskComment"), $entity, $id); $new["commentEmailSubject"] = $s . " " . $new["hashKey"]; if (!$_GET["commentID"] || $_GET["commentID"] != $v["commentID"]) { if ($options["showEditButtons"] && $new["comment_buttons"]) { $new["form"] = '<form action="' . $TPL["url_alloc_comment"] . '" method="post">'; $new["form"] .= '<input type="hidden" name="entity" value="' . $v["commentType"] . '">'; $new["form"] .= '<input type="hidden" name="entityID" value="' . $v["commentLinkID"] . '">'; $new["form"] .= '<input type="hidden" name="commentID" value="' . $v["commentID"] . '">'; $new["form"] .= '<input type="hidden" name="comment_id" value="' . $v["commentID"] . '">'; $new["form"] .= $new["comment_buttons"]; $new["form"] .= '<input type="hidden" name="sessID" value="' . $TPL["sessID"] . '">'; $new["form"] .= '</form>'; } $v["commentMimeParts"] and $files = unserialize($v["commentMimeParts"]); if (is_array($files)) { foreach ($files as $file) { $new["files"] .= '<div align="center" style="float:left; display:inline; margin-right:14px;">'; $new["files"] .= "<a href=\"" . $TPL["url_alloc_getMimePart"] . "part=" . $file["part"] . "&entity=comment&id=" . $v["commentID"] . "\">"; $new["files"] .= get_file_type_image($file["name"]) . "<br>" . page::htmlentities($file["name"]); $new["files"] .= " (" . get_size_label($file["size"]) . ")</a>"; $new["files"] .= '</div>'; } } $v["commentEmailRecipients"] and $new["emailed"] = 'Emailed to ' . page::htmlentities($v["commentEmailRecipients"]); } return (array) $new; }
function get_all_parties($projectID = "") { $db = new db_alloc(); $interestedPartyOptions = array(); if ($_GET["projectID"]) { $projectID = $_GET["projectID"]; } else { if (!$projectID) { $projectID = $this->get_value("projectID"); } } if ($projectID) { $project = new project($projectID); $interestedPartyOptions = $project->get_all_parties(false, $this->get_id()); } $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array(); foreach ($extra_interested_parties as $name => $email) { $interestedPartyOptions[$email]["name"] = $name; } if ($this->get_value("creatorID")) { $p = new person(); $p->set_id($this->get_value("creatorID")); $p->select(); if ($p->get_value("emailAddress")) { $interestedPartyOptions[$p->get_value("emailAddress")]["name"] = $p->get_name(); $interestedPartyOptions[$p->get_value("emailAddress")]["role"] = "creator"; $interestedPartyOptions[$p->get_value("emailAddress")]["personID"] = $this->get_value("creatorID"); } } if ($this->get_value("personID")) { $p = new person(); $p->set_id($this->get_value("personID")); $p->select(); if ($p->get_value("emailAddress")) { $interestedPartyOptions[$p->get_value("emailAddress")]["name"] = $p->get_name(); $interestedPartyOptions[$p->get_value("emailAddress")]["role"] = "assignee"; $interestedPartyOptions[$p->get_value("emailAddress")]["personID"] = $this->get_value("personID"); $interestedPartyOptions[$p->get_value("emailAddress")]["selected"] = 1; } } if ($this->get_value("managerID")) { $p = new person(); $p->set_id($this->get_value("managerID")); $p->select(); if ($p->get_value("emailAddress")) { $interestedPartyOptions[$p->get_value("emailAddress")]["name"] = $p->get_name(); $interestedPartyOptions[$p->get_value("emailAddress")]["role"] = "manager"; $interestedPartyOptions[$p->get_value("emailAddress")]["personID"] = $this->get_value("managerID"); $interestedPartyOptions[$p->get_value("emailAddress")]["selected"] = 1; } } // return an aggregation of the current task/proj/client parties + the existing interested parties $interestedPartyOptions = interestedParty::get_interested_parties("task", $this->get_id(), $interestedPartyOptions); return $interestedPartyOptions; }
function is_external($entity, $entityID) { $ips = interestedParty::get_interested_parties($entity, $entityID); foreach ($ips as $email => $info) { if ($info["external"] && $info["selected"]) { return true; } } }
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; }
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; }
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"] = " "; $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"); }
function get_all_parties($projectID = false, $task_exists = false) { $current_user =& singleton("current_user"); if (!$projectID && is_object($this)) { $projectID = $this->get_id(); } if ($projectID) { $extra_interested_parties = config::get_config_item("defaultInterestedParties"); foreach ((array) $extra_interested_parties as $name => $email) { $interestedPartyOptions[$email]["name"] = $name; } // Get primary client contact from Project page $db = new db_alloc(); $q = prepare("SELECT projectClientName,projectClientEMail FROM project WHERE projectID = %d", $projectID); $db->query($q); $db->next_record(); $interestedPartyOptions[$db->f("projectClientEMail")]["name"] = $db->f("projectClientName"); $interestedPartyOptions[$db->f("projectClientEMail")]["external"] = "1"; // Get all other client contacts from the Client pages for this Project $q = prepare("SELECT clientID FROM project WHERE projectID = %d", $projectID); $db->query($q); $db->next_record(); $clientID = $db->f("clientID"); if ($clientID) { $client = new client($clientID); $interestedPartyOptions = array_merge((array) $interestedPartyOptions, (array) $client->get_all_parties()); } // Get all the project people for this tasks project $q = prepare("SELECT emailAddress, firstName, surname, person.personID, username\n FROM projectPerson \n LEFT JOIN person on projectPerson.personID = person.personID \n WHERE projectPerson.projectID = %d AND person.personActive = 1 ", $projectID); $db->query($q); while ($db->next_record()) { unset($name); $db->f("firstName") && $db->f("surname") and $name = $db->f("firstName") . " " . $db->f("surname"); $name or $name = $db->f("username"); $interestedPartyOptions[$db->f("emailAddress")]["name"] = $name; $interestedPartyOptions[$db->f("emailAddress")]["personID"] = $db->f("personID"); $interestedPartyOptions[$db->f("emailAddress")]["internal"] = true; } } if (is_object($current_user) && $current_user->get_id()) { $interestedPartyOptions[$current_user->get_value("emailAddress")]["name"] = $current_user->get_name(); $interestedPartyOptions[$current_user->get_value("emailAddress")]["personID"] = $current_user->get_id(); } // return an aggregation of the current task/proj/client parties + the existing interested parties $interestedPartyOptions = interestedParty::get_interested_parties("project", $projectID, $interestedPartyOptions, $task_exists); return (array) $interestedPartyOptions; }
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; }
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"] = " "; $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"); } }
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; }
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(); } }
#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()); } } }