$TPL["parentTypeOptions"] = page::select_options($parent_types); include_template("templates/reminderSelectParentTypeM.tpl"); break; case 2: // Which project,task,client. (skip for general) // get personID $personID = $current_user->get_id(); $parent_names = array(); $db = new db_alloc(); if ($parentType == "client") { $query = "SELECT * FROM client WHERE clientStatus!='Archived' ORDER BY clientName"; $db->query($query); while ($db->next_record()) { $client = new client(); $client->read_db_record($db); $parent_names[$client->get_id()] = $client->get_value('clientName'); } } else { if ($parentType == "project") { if ($current_user->have_role("admin")) { $query = "SELECT * FROM project WHERE projectStatus != 'Archived' ORDER BY projectName"; } else { $query = prepare("SELECT * \n FROM project \n LEFT JOIN projectPerson ON project.projectID=projectPerson.projectID \n WHERE personID='%d' \n AND projectStatus != 'Archived'\n ORDER BY projectName", $personID); } $db->query($query); while ($db->next_record()) { $project = new project(); $project->read_db_record($db); $parent_names[$project->get_id()] = $project->get_value('projectName'); } } else {
} else { if ($_POST["delete"]) { $client->read_globals(); $client->delete(); alloc_redirect($TPL["url_alloc_clientList"]); } else { $client->set_id($clientID); $client->select(); } $client->set_values("client_"); } } } $m = new meta("clientStatus"); $clientStatus_array = $m->get_assoc_array("clientStatusID", "clientStatusID"); $TPL["clientStatusOptions"] = page::select_options($clientStatus_array, $client->get_value("clientStatus")); $clientCategories = config::get_config_item("clientCategories") or $clientCategories = array(); foreach ($clientCategories as $k => $v) { $cc[$v["value"]] = $v["label"]; } $TPL["clientCategoryOptions"] = page::select_options($cc, $client->get_value("clientCategory")); $client->get_value("clientCategory") and $TPL["client_clientCategoryLabel"] = $cc[$client->get_value("clientCategory")]; // client contacts if ($_POST["clientContact_save"] || $_POST["clientContact_delete"]) { $clientContact = new clientContact(); $clientContact->read_globals(); if ($_POST["clientContact_save"]) { #$clientContact->set_value('clientID', $_POST["clientID"]); $clientContact->save(); } if ($_POST["clientContact_delete"]) {
$query .= prepare(" AND projectID != %d", $project->get_id()); } $db->query($query); $db->next_record(); if ($db->f('count') > 0) { alloc_error("A project with that nickname already exists."); } if (!$TPL["message"]) { $project->set_value("projectComments", rtrim($project->get_value("projectComments"))); $project->save(); $projectID = $project->get_id(); interestedParty::make_interested_parties("project", $project->get_id(), $_POST["interestedParty"]); $client = new client(); $client->set_id($project->get_value("clientID")); $client->select(); if ($client->get_value("clientStatus") == 'Potential') { $client->set_value("clientStatus", "Current"); $client->save(); } if ($definitely_new_project) { $projectPerson = new projectPerson(); $projectPerson->currency = $project->get_value("currencyTypeID"); $projectPerson->set_value("projectID", $projectID); $projectPerson->set_value_role("isManager"); $projectPerson->set_value("personID", $current_user->get_id()); $projectPerson->save(); } alloc_redirect($TPL["url_alloc_project"] . "projectID=" . $project->get_id()); } } else { if ($_POST["delete"]) {
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); }
if (!$invoice->get_value("invoiceNum") || !is_numeric($invoice->get_value("invoiceNum"))) { #alloc_error("Please enter a unique Invoice Number."); $invoice->set_value("invoiceNum", invoice::get_next_invoiceNum()); } else { $invoiceID and $invoiceID_sql = prepare(" AND invoiceID != %d", $invoiceID); $q = prepare("SELECT * FROM invoice WHERE invoiceNum = '%s' " . $invoiceID_sql, $invoice->get_value("invoiceNum")); $db->query($q); if ($db->row()) { alloc_error("Please enter a unique Invoice Number (that number is already taken)."); } } if (!$invoice->get_value("invoiceName") && $invoice->get_value("clientID")) { $client = new client(); $client->set_id($invoice->get_value("clientID")); $client->select(); $invoice->set_value("invoiceName", $client->get_value("clientName")); } if ($_POST["save_and_MoveForward"]) { $direction = "forwards"; } else { if ($_POST["save_and_MoveBack"]) { $direction = "backwards"; } } if (!$TPL["message"]) { if (!$invoice->get_value("invoiceStatus")) { $invoice->set_value("invoiceStatus", "edit"); } // Save invoice Item approved/rejected info $invoiceItemIDs = $invoice->get_invoiceItems(); foreach ($invoiceItemIDs as $iiID) {
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; }