function save() { $rtn = parent::save(); $c = new client(); $c->set_id($this->get_value("clientID")); $c->select(); $c->save(); return $rtn; }
function show_client_contacts() { global $TPL; global $clientID; $TPL["clientContact_clientID"] = $clientID; if ($_POST["clientContact_delete"] && $_POST["clientContactID"]) { $clientContact = new clientContact(); $clientContact->set_id($_POST["clientContactID"]); $clientContact->delete(); } $client = new client(); $client->set_id($clientID); $client->select(); // other contacts $query = prepare("SELECT * \n FROM clientContact\n WHERE clientID=%d \n ORDER BY clientContactActive DESC, primaryContact DESC, clientContactName", $clientID); $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $clientContact = new clientContact(); $clientContact->read_db_record($db); if ($_POST["clientContact_edit"] && $_POST["clientContactID"] == $clientContact->get_id()) { continue; } $pc = ""; if ($clientContact->get_value("primaryContact")) { $pc = " [Primary]"; } $vcard_img = "icon_vcard.png"; $clientContact->get_value("clientContactActive") or $vcard_img = "icon_vcard_faded.png"; $vcard = '<a href="' . $TPL["url_alloc_client"] . 'clientContactID=' . $clientContact->get_id() . '&get_vcard=1"><img style="vertical-align:middle; padding:3px 6px 3px 3px;border: none" src="' . $TPL["url_alloc_images"] . $vcard_img . '" alt="Download VCard" ></a>'; $col1 = array(); $clientContact->get_value('clientContactName') and $col1[] = "<h2 style='margin:0px; display:inline;'>" . $vcard . $clientContact->get_value('clientContactName', DST_HTML_DISPLAY) . "</h2>" . $pc; $clientContact->get_value('clientContactStreetAddress') and $col1[] = $clientContact->get_value('clientContactStreetAddress', DST_HTML_DISPLAY); $clientContact->get_value('clientContactSuburb') || $clientContact->get_value('clientContactState') || $clientContact->get_value('clientContactPostcode') and $col1[] = $clientContact->get_value('clientContactSuburb', DST_HTML_DISPLAY) . ' ' . $clientContact->get_value('clientContactState', DST_HTML_DISPLAY) . " " . $clientContact->get_value('clientContactPostcode', DST_HTML_DISPLAY); $clientContact->get_value('clientContactCountry') and $col1[] = $clientContact->get_value('clientContactCountry', DST_HTML_DISPLAY); // find some gpl icons! #$ico_e = "<img src=\"".$TPL["url_alloc_images"]."/icon_email.gif\">"; #$ico_p = "<img src=\"".$TPL["url_alloc_images"]."/icon_phone.gif\">"; #$ico_m = "<img src=\"".$TPL["url_alloc_images"]."/icon_mobile.gif\">"; #$ico_f = "<img src=\"".$TPL["url_alloc_images"]."/icon_fax.gif\">"; $ico_e = "E: "; $ico_p = "P: "; $ico_m = "M: "; $ico_f = "F: "; $col2 = array(); $email = $clientContact->get_value("clientContactEmail", DST_HTML_DISPLAY); $email = str_replace("<", "", $email); $email = str_replace(">", "", $email); $email = str_replace("<", "", $email); $email = str_replace(">", "", $email); $userName = $clientContact->get_value('clientContactName', DST_HTML_DISPLAY); if ($userName) { $mailto = '"' . $userName . '" <' . $email . ">"; } else { $mailto = $email; } $email and $col2[] = $ico_e . "<a href='mailto:" . rawurlencode($mailto) . "'>" . $email . "</a>"; $phone = $clientContact->get_value('clientContactPhone', DST_HTML_DISPLAY); $phone and $col2[] = $ico_p . $phone; $mobile = $clientContact->get_value('clientContactMobile', DST_HTML_DISPLAY); $mobile and $col2[] = $ico_m . $mobile; $fax = $clientContact->get_value('clientContactFax', DST_HTML_DISPLAY); $fax and $col2[] = $ico_f . $fax; if ($clientContact->get_value("clientContactActive")) { $class_extra = " loud"; } else { $class_extra = " quiet"; } $buttons = '<nobr> <button type="submit" name="clientContact_delete" value="1" class="delete_button">Delete<i class="icon-trash"></i></button> <button type="submit" name="clientContact_edit" value="1"">Edit<i class="icon-edit"></i></button> </nobr>'; $rtn[] = '<form action="' . $TPL["url_alloc_client"] . '" method="post">'; $rtn[] = '<input type="hidden" name="clientContactID" value="' . $clientContact->get_id() . '">'; $rtn[] = '<input type="hidden" name="clientID" value="' . $clientID . '">'; $rtn[] = '<div class="panel' . $class_extra . ' corner">'; $rtn[] = '<table width="100%" cellspacing="0" border="0">'; $rtn[] = '<tr>'; $rtn[] = ' <td width="25%" valign="top"><span class="nobr">' . implode('</span><br><span class="nobr">', $col1) . '</span> </td>'; $rtn[] = ' <td width="20%" valign="top"><span class="nobr">' . implode('</span><br><span class="nobr">', $col2) . '</span> </td>'; $rtn[] = ' <td width="50%" align="left" valign="top">' . nl2br($clientContact->get_value('clientContactOther', DST_HTML_DISPLAY)) . ' </td>'; $rtn[] = ' <td align="right" class="right nobr">' . $buttons . '</td>'; $rtn[] = ' <td align="right" class="right nobr" width="1%">' . page::star("clientContact", $clientContact->get_id()) . '</td>'; $rtn[] = '</tr>'; $rtn[] = '</table>'; $rtn[] = '</div>'; $rtn[] = '<input type="hidden" name="sessID" value="' . $TPL["sessID"] . '">'; $rtn[] = '</form>'; } if (is_array($rtn)) { $TPL["clientContacts"] = implode("\n", $rtn); } if ($_POST["clientContact_edit"] && $_POST["clientContactID"]) { $clientContact = new clientContact(); $clientContact->set_id($_POST["clientContactID"]); $clientContact->select(); $clientContact->set_values("clientContact_"); if ($clientContact->get_value("primaryContact")) { $TPL["primaryContact_checked"] = " checked"; } if ($clientContact->get_value("clientContactActive")) { $TPL["clientContactActive_checked"] = " checked"; } } else { if ($rtn) { $TPL["class_new_client_contact"] = "hidden"; } } if (!$_POST["clientContactID"] || $_POST["clientContact_save"]) { $TPL["clientContactActive_checked"] = " checked"; } include_template("templates/clientContactM.tpl"); }
$br = "<br>"; } $TPL["paymentMethodOptions"] = $expenseForm->get_value("paymentMethod"); $TPL["reimbursementRequiredOption"] = $rr_label; $scr_label = "No"; if ($expenseForm->get_value("seekClientReimbursement")) { $scr_sel = " checked"; $scr_label = "Yes"; } $TPL["seekClientReimbursementLabel"] = $scr_label; $seekClientReimbursementOption = "<input type=\"checkbox\" value=\"1\" name=\"seekClientReimbursement\"" . $scr_sel . ">"; $scr_hidden = "<input type=\"hidden\" name=\"seekClientReimbursement\" value=\"" . $expenseForm->get_value("seekClientReimbursement") . "\">"; $TPL["seekClientReimbursementOption"] = $scr_label . $scr_hidden; $c = new client(); $c->set_id($expenseForm->get_value("clientID")); $c->select(); $clientName = page::htmlentities($c->get_name()); $clientName and $TPL["printer_clientID"] = $clientName; $TPL["field_expenseFormComment"] = $expenseForm->get_value("expenseFormComment", DST_HTML_DISPLAY); if (is_object($expenseForm) && $expenseForm->get_id() && check_optional_allow_edit()) { $TPL["expenseFormButtons"] .= ' <button type="submit" name="cancel" value="1" class="delete_button">Delete<i class="icon-trash"></i></button> <button type="submit" name="save" value="1" class="save_button">Save<i class="icon-ok-sign"></i></button> <button type="submit" name="finalise" value="1" class="save_button">To Admin<i class="icon-arrow-right"></i></button> '; $TPL["paymentMethodOptions"] = "<select name=\"paymentMethod\">" . $paymentOptions . "</select>"; $TPL["reimbursementRequiredOption"] = $reimbursementRequiredRadios; $TPL["seekClientReimbursementOption"] = $seekClientReimbursementOption; $options["clientStatus"] = "Current"; $ops = client::get_list($options); $ops = array_kv($ops, "clientID", "clientName");
$TPL["task_pendingTaskIDs"] = $row["pendingTaskIDs"]; $TPL["task_tags"] = implode(", ", $task->get_tags()); } else { $TPL["taskSelfLink"] = "New Task"; $TPL["main_alloc_title"] = "New Task - " . APPLICATION_NAME; } $TPL["tagOptions"] = page::select_options($task->get_tags(true), $task->get_tags(), 300); if (!$task->get_id()) { $TPL["message_help"][] = "Enter a Task Name and click the Save button to create a new Task."; $TPL["task_dateTargetStart"] or $TPL["task_dateTargetStart"] = date("Y-m-d"); } $TPL["task"] = $task; // Printer friendly view if ($_GET["media"] == "print") { if (has("client")) { $client = new client(); $client->set_id($project->get_value("clientID")); $client->select(); $client->set_values("client_"); } if (has("project") && has("client")) { $project = $task->get_foreign_object("project"); $clientContact = new clientContact(); $clientContact->set_id($project->get_value("clientContactID")); $clientContact->select(); $clientContact->set_values("clientContact_"); } include_template("templates/taskPrinterM.tpl"); } else { include_template("templates/taskM.tpl"); }
function update_search_index_doc(&$index) { $p =& get_cached_table("person"); $projectModifiedUser = $this->get_value("projectModifiedUser"); $projectModifiedUser_field = $projectModifiedUser . " " . $p[$projectModifiedUser]["username"] . " " . $p[$projectModifiedUser]["name"]; $projectName = $this->get_name(); $projectShortName = $this->get_name(array("showShortProjectLink" => true)); $projectShortName && $projectShortName != $projectName and $projectName .= " " . $projectShortName; if ($this->get_value("clientID")) { $c = new client(); $c->set_id($this->get_value("clientID")); $c->select(); $clientName = $c->get_name(); } $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->get_id())); $doc->addField(Zend_Search_Lucene_Field::Text('name', $projectName, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('desc', $this->get_value("projectComments"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('cid', $this->get_value("clientID"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('client', $clientName, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('modifier', $projectModifiedUser_field, "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('type', $this->get_value("projectType"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateTargetStart', str_replace("-", "", $this->get_value("dateTargetStart")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateTargetCompletion', str_replace("-", "", $this->get_value("dateTargetCompletion")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateStart', str_replace("-", "", $this->get_value("dateActualStart")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('dateCompletion', str_replace("-", "", $this->get_value("dateActualCompletion")), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('status', $this->get_value("projectStatus"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('priority', $this->get_value("projectPriority"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('tf', $this->get_value("cost_centre_tfID"), "utf-8")); $doc->addField(Zend_Search_Lucene_Field::Text('billed', $this->get_value("customerBilledDollars"), "utf-8")); $index->addDocument($doc); }
function populate_string($str, $entity, $entityID = false) { // Actually do the text substitution $current_user =& singleton("current_user"); is_object($current_user) and $swap["cu"] = person::get_fullname($current_user->get_id()); if ($entity == "timeSheet" && $entityID) { $timeSheet = new timeSheet(); $timeSheet->set_id($entityID); $timeSheet->select(); $timeSheet->load_pay_info(); foreach ($timeSheet->pay_info as $k => $v) { $swap[$k] = $v; } if ($timeSheet->get_value("approvedByManagerPersonID")) { $swap["tm"] = person::get_fullname($timeSheet->get_value("approvedByManagerPersonID")); } else { $project = $timeSheet->get_foreign_object("project"); $projectManagers = $project->get_timeSheetRecipients(); if (is_array($projectManagers) && count($projectManagers)) { $people =& get_cached_table("person"); foreach ($projectManagers as $pID) { $swap["tm"] .= $commar . $people[$pID]["name"]; $commar = ", "; } } } if ($timeSheet->get_value("approvedByAdminPersonID")) { $swap["tc"] = person::get_fullname($timeSheet->get_value("approvedByAdminPersonID")); } else { $people =& get_cached_table("person"); $timeSheetAdministrators = config::get_config_item('defaultTimeSheetAdminList'); if (count($timeSheetAdministrators)) { $swap["tc"] = ""; $comma = ""; foreach ($timeSheetAdministrators as $adminID) { $swap["tc"] .= $comma . $people[$adminID]["name"]; $comma = ", "; } } else { $swap["tc"] = 'no-one'; } } $swap["ti"] = $timeSheet->get_id(); $swap["to"] = person::get_fullname($timeSheet->get_value("personID")); $swap["ta"] = person::get_fullname($timeSheet->get_value("personID")); $swap["tf"] = $timeSheet->get_value("dateFrom"); $swap["tt"] = $timeSheet->get_value("dateTo"); $swap["ts"] = $timeSheet->get_timeSheet_status(); $swap["tu"] = config::get_config_item("allocURL") . "time/timeSheet.php?timeSheetID=" . $timeSheet->get_id(); $projectID = $timeSheet->get_value("projectID"); } if ($entity == "task" && $entityID) { $task = new task(); $task->set_id($entityID); $task->select(); $swap["ti"] = $task->get_id(); $swap["to"] = person::get_fullname($task->get_value("creatorID")); $swap["ta"] = person::get_fullname($task->get_value("personID")); $swap["tm"] = person::get_fullname($task->get_value("managerID")); $swap["tc"] = person::get_fullname($task->get_value("closerID")); $swap["tn"] = $task->get_value("taskName"); $swap["td"] = $task->get_value("taskDescription"); $swap["tu"] = config::get_config_item("allocURL") . "task/task.php?taskID=" . $task->get_id(); $swap["tp"] = $task->get_priority_label(); $swap["ts"] = $task->get_task_status("label"); $swap["teb"] = $task->get_value("timeBest"); $swap["tem"] = $task->get_value("timeExpected"); $swap["tew"] = $task->get_value("timeWorst"); $swap["tep"] = person::get_fullname($task->get_value("estimatorID")); //time estimate person, when it's implemented $projectID = $task->get_value("projectID"); } if ($entity == "project" && $entityID || $projectID) { $project = new project(); if ($projectID) { $project->set_id($projectID); } else { $project->set_id($entityID); } $project->select(); $swap["pn"] = $project->get_value("projectName"); $swap["pi"] = $project->get_id(); $clientID = $project->get_value("clientID"); } if ($entity == "client" && $entityID || $clientID) { $client = new client(); if ($clientID) { $client->set_id($clientID); } else { $client->set_id($entityID); } $client->select(); $swap["li"] = $client->get_id(); $swap["cc"] = $client->get_value("clientName"); } $swap["cd"] = config::get_config_item("companyContactAddress"); $swap["cd"] .= " " . config::get_config_item("companyContactAddress2"); $swap["cd"] .= " " . config::get_config_item("companyContactAddress3"); $swap["cd"] .= "\nP: " . config::get_config_item("companyContactPhone"); $swap["cd"] .= "\nF: " . config::get_config_item("companyContactFax"); $swap["cd"] .= "\nE: " . config::get_config_item("companyContactEmail"); $swap["cd"] .= "\nW: " . config::get_config_item("companyContactHomePage"); $swap["cn"] = config::get_config_item("companyName"); $swap["c1"] = config::get_config_item("companyContactAddress"); $swap["c2"] = config::get_config_item("companyContactAddress2"); $swap["c3"] = config::get_config_item("companyContactAddress3"); $swap["ce"] = config::get_config_item("companyContactEmail"); $swap["cp"] = config::get_config_item("companyContactPhone"); $swap["cf"] = config::get_config_item("companyContactFax"); $swap["cw"] = config::get_config_item("companyContactHomePage"); foreach ($swap as $k => $v) { $str = str_replace("%" . $k, $v, $str); } return $str; }
function get_client_and_project_dropdowns_and_links($clientID = false, $projectID = false, $onlymine = false) { // This function returns dropdown lists and links for both client and // project. The two dropdown lists are linked, in that if you change the // client, then the project dropdown dynamically updates global $TPL; $project = new project(); $project->set_id($projectID); $project->select(); if (!$clientID) { $clientID = $project->get_value("clientID"); } $client = new client(); $client->set_id($clientID); $client->select(); $options["clientStatus"] = "Current"; $ops = client::get_list($options); $ops = array_kv($ops, "clientID", "clientName"); $client->get_id() and $ops[$client->get_id()] = $client->get_value("clientName"); $client_select = "<select id=\"clientID\" name=\"clientID\" onChange=\"makeAjaxRequest('" . $TPL["url_alloc_updateProjectListByClient"] . "clientID='+\$('#clientID').attr('value')+'&onlymine=" . sprintf("%d", $onlymine) . "','projectDropdown')\"><option></option>"; $client_select .= page::select_options($ops, $clientID, 100) . "</select>"; $client_link = $client->get_link(); $project_select = '<div id="projectDropdown" style="display:inline">' . $project->get_dropdown_by_client($clientID, $onlymine) . '</div>'; $project_link = $project->get_link(); return array($client_select, $client_link, $project_select, $project_link); }
function is_alive() { $type = $this->get_value('reminderType'); if ($type == "project") { $project = new project(); $project->set_id($this->get_value('reminderLinkID')); if ($project->select() == false || $project->get_value('projectStatus') == "Archived") { return false; } } else { if ($type == "task") { $task = new task(); $task->set_id($this->get_value('reminderLinkID')); if ($task->select() == false || substr($task->get_value("taskStatus"), 0, 6) == 'closed') { return false; } } else { if ($type == "client") { $client = new client(); $client->set_id($this->get_value('reminderLinkID')); if ($client->select() == false || $client->get_value('clientStatus') == "Archived") { return false; } } } } return true; }