Example #1
0
        }
    }
}
if (is_object($expenseForm) && $expenseForm->get_id()) {
    $db = new db_alloc();
    $db->query(prepare("SELECT SUM(amount * pow(10,-currencyType.numberToBasic)) AS amount, \n                             transaction.currencyTypeID as currency\n                        FROM transaction\n                   LEFT JOIN currencyType on transaction.currencyTypeID = currencyType.currencyTypeID\n                       WHERE expenseFormID = %d\n                    GROUP BY transaction.currencyTypeID\n                  ", $expenseForm->get_id()));
    while ($row = $db->row()) {
        $rows[] = $row;
    }
    $TPL["formTotal"] = page::money_print($rows);
}
if (is_object($expenseForm) && $current_user->have_role("admin") && !$expenseForm->get_invoice_link() && $expenseForm->get_value("expenseFormFinalised") && $expenseForm->get_value("seekClientReimbursement")) {
    $ops["invoiceStatus"] = "edit";
    $ops["clientID"] = $expenseForm->get_value("clientID");
    $invoice_list = invoice::get_list($ops);
    $invoice_list = array_kv($invoice_list, "invoiceID", array("invoiceNum", "invoiceName"));
    $q = prepare("SELECT * FROM invoiceItem WHERE expenseFormID = %d", $expenseForm->get_id());
    $db = new db_alloc();
    $db->query($q);
    $row = $db->row();
    $sel_invoice = $row["invoiceID"];
    $TPL["attach_to_invoice_button"] = "<select name=\"attach_to_invoiceID\">";
    $TPL["attach_to_invoice_button"] .= "<option value=\"create_new\">Create New Invoice</option>";
    $TPL["attach_to_invoice_button"] .= page::select_options($invoice_list, $sel_invoice) . "</select>";
    $TPL["attach_to_invoice_button"] .= "<input type=\"submit\" name=\"attach_transactions_to_invoice\" value=\"Add to Invoice\"> ";
    $TPL["invoice_label"] = "Invoice:";
}
if (is_object($expenseForm)) {
    $invoice_link = $expenseForm->get_invoice_link();
    if ($invoice_link) {
        $TPL["invoice_label"] = "Invoice:";
Example #2
0
 function set_option_tpl_values()
 {
     // Set template values to provide options for edit selects
     global $TPL;
     $current_user =& singleton("current_user");
     global $isMessage;
     $db = new db_alloc();
     $projectID = $_GET["projectID"] or $projectID = $this->get_value("projectID");
     $TPL["personOptions"] = "<select name=\"personID\"><option value=\"\">" . $this->get_personList_dropdown($projectID, "personID") . "</select>";
     $TPL["managerPersonOptions"] = "<select name=\"managerID\"><option value=\"\">" . $this->get_personList_dropdown($projectID, "managerID") . "</select>";
     $TPL["estimatorPersonOptions"] = "<select name=\"estimatorID\"><option value=\"\">" . $this->get_personList_dropdown($projectID, "estimatorID") . "</select>";
     // TaskType Options
     $taskType = new meta("taskType");
     $taskType_array = $taskType->get_assoc_array("taskTypeID", "taskTypeID");
     $TPL["taskTypeOptions"] = page::select_options($taskType_array, $this->get_value("taskTypeID"));
     // Project dropdown
     $TPL["projectOptions"] = task::get_project_options($projectID);
     // We're building these two with the <select> tags because they will be
     // replaced by an AJAX created dropdown when the projectID changes.
     $TPL["parentTaskOptions"] = $this->get_parent_task_select();
     $TPL["interestedPartyOptions"] = $this->get_task_cc_list_select();
     $db->query(prepare("SELECT fullName, emailAddress, clientContactPhone, clientContactMobile\n                          FROM interestedParty\n                     LEFT JOIN clientContact ON interestedParty.clientContactID = clientContact.clientContactID\n                         WHERE entity='task' \n                           AND entityID = %d\n                           AND interestedPartyActive = 1\n                      ORDER BY fullName", $this->get_id()));
     while ($db->next_record()) {
         $value = interestedParty::get_encoded_interested_party_identifier($db->f("fullName"), $db->f("emailAddress"));
         $phone = array("p" => $db->f('clientContactPhone'), "m" => $db->f('clientContactMobile'));
         $TPL["interestedParties"][] = array('key' => $value, 'name' => $db->f("fullName"), 'email' => $db->f("emailAddress"), 'phone' => $phone);
     }
     $TPL["task_taskStatusLabel"] = $this->get_task_status("label");
     $TPL["task_taskStatusColour"] = $this->get_task_status("colour");
     $TPL["task_taskStatusValue"] = $this->get_value("taskStatus");
     $TPL["task_taskStatusOptions"] = page::select_options(task::get_task_statii_array(true), $this->get_value("taskStatus"));
     // Project label
     if (has("project")) {
         $p = new project();
         $p->set_id($this->get_value("projectID"));
         $p->select();
         $TPL["projectName"] = $p->get_display_value();
     }
     $taskPriorities = config::get_config_item("taskPriorities") or $taskPriorities = array();
     $projectPriorities = config::get_config_item("projectPriorities") or $projectPriorities = array();
     $priority = $this->get_value("priority") or $priority = 3;
     $TPL["priorityOptions"] = page::select_options(array_kv($taskPriorities, null, "label"), $priority);
     $TPL["priorityLabel"] = " <div style=\"display:inline; color:" . $taskPriorities[$priority]["colour"] . "\">[";
     if (is_object($p)) {
         list($priorityFactor, $daysUntilDue) = $this->get_overall_priority($p->get_value("projectPriority"), $this->get_value("priority"), $this->get_value("dateTargetCompletion"));
         $str = "Task priority: " . $taskPriorities[$this->get_value("priority")]["label"] . "<br>";
         $str .= "Project priority: " . $projectPriorities[$p->get_value("projectPriority")]["label"] . "<br>";
         $str .= "Days until due: " . $daysUntilDue . "<br>";
         $str .= "Calculated priority: " . $priorityFactor;
         $TPL["priorityLabel"] .= page::help($str, $this->get_priority_label());
     } else {
         $TPL["priorityLabel"] .= $this->get_priority_label();
     }
     $TPL["priorityLabel"] .= "]</div>";
     // If we're viewing the printer friendly view
     if ($_GET["media"] == "print") {
         // Parent Task label
         $t = new task();
         $t->set_id($this->get_value("parentTaskID"));
         $t->select();
         $TPL["parentTask"] = $t->get_display_value();
         // Task Type label
         $TPL["taskType"] = $this->get_value("taskTypeID");
         // Priority
         $TPL["priority"] = $this->get_value("priority");
         // Assignee label
         $p = new person();
         $p->set_id($this->get_value("personID"));
         $p->select();
         $TPL["person"] = $p->get_display_value();
     }
 }
Example #3
0
 function load_productSale_filter($_FORM)
 {
     $current_user =& singleton("current_user");
     // display the list of project name.
     $db = new db_alloc();
     if (!$_FORM['showAllProjects']) {
         $filter = "WHERE projectStatus = 'Current' ";
     }
     $query = prepare("SELECT projectID AS value, projectName AS label FROM project {$filter} ORDER by projectName");
     $rtn["show_project_options"] = page::select_options($query, $_FORM["projectID"], 70);
     // display the list of user name.
     if (have_entity_perm("productSale", PERM_READ, $current_user, false)) {
         $rtn["show_userID_options"] = page::select_options(person::get_username_list(), $_FORM["personID"]);
     } else {
         $person = new person();
         $person->set_id($current_user->get_id());
         $person->select();
         $person_array = array($current_user->get_id() => $person->get_name());
         $rtn["show_userID_options"] = page::select_options($person_array, $_FORM["personID"]);
     }
     // display a list of status
     $status_array = productSale::get_statii();
     unset($status_array["create"]);
     $rtn["show_status_options"] = page::select_options($status_array, $_FORM["status"]);
     // display the date from filter value
     $rtn["showAllProjects"] = $_FORM["showAllProjects"];
     $options["clientStatus"] = array("Current");
     $options["return"] = "dropdown_options";
     $ops = client::get_list($options);
     $ops = array_kv($ops, "clientID", "clientName");
     $rtn["clientOptions"] = page::select_options($ops, $_FORM["clientID"]);
     // Get
     $rtn["FORM"] = "FORM=" . urlencode(serialize($_FORM));
     return $rtn;
 }
Example #4
0
 function get_list_by_client($clientID = false, $onlymine = false)
 {
     $current_user =& singleton("current_user");
     $clientID and $options["clientID"] = $clientID;
     $options["projectStatus"] = "Current";
     $options["showProjectType"] = true;
     if ($onlymine) {
         $options["personID"] = $current_user->get_id();
     }
     $ops = project::get_list($options);
     return array_kv($ops, "projectID", "label");
 }
Example #5
0
 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);
 }
Example #6
0
 function load_invoice_filter($_FORM)
 {
     global $TPL;
     // Load up the forms action url
     $rtn["url_form_action"] = $_FORM["url_form_action"];
     $statii = invoice::get_invoice_statii();
     unset($statii["create"]);
     $rtn["statusOptions"] = page::select_options($statii, $_FORM["invoiceStatus"]);
     $statii_payment = invoice::get_invoice_statii_payment();
     $rtn["statusPaymentOptions"] = page::select_options($statii_payment, $_FORM["invoiceStatusPayment"]);
     $rtn["status"] = $_FORM["status"];
     $rtn["dateOne"] = $_FORM["dateOne"];
     $rtn["dateTwo"] = $_FORM["dateTwo"];
     $rtn["invoiceID"] = $_FORM["invoiceID"];
     $rtn["invoiceName"] = $_FORM["invoiceName"];
     $rtn["invoiceNum"] = $_FORM["invoiceNum"];
     $rtn["invoiceItemID"] = $_FORM["invoiceItemID"];
     $options["clientStatus"] = "Current";
     $options["return"] = "dropdown_options";
     $ops = client::get_list($options);
     $ops = array_kv($ops, "clientID", "clientName");
     $rtn["clientOptions"] = page::select_options($ops, $_FORM["clientID"]);
     // Get
     $rtn["FORM"] = "FORM=" . urlencode(serialize($_FORM));
     return $rtn;
 }