function show_expenseFormList($template_name) { global $db; global $TPL; global $transactionRepeat; $current_user =& singleton("current_user"); $db = new db_alloc(); $transactionRepeat = new transactionRepeat(); if (!$_GET["tfID"] && !$current_user->have_role("admin")) { $tfIDs = $current_user->get_tfIDs(); $tfIDs and $sql = prepare("WHERE tfID in (%s)", $tfIDs); } else { if ($_GET["tfID"]) { $sql = prepare("WHERE tfID = %d", $_GET["tfID"]); } } $db->query("select * FROM transactionRepeat " . $sql); while ($db->next_record()) { $i++; $transactionRepeat->read_db_record($db); $transactionRepeat->set_values(); $TPL["tfName"] = tf::get_name($transactionRepeat->get_value("tfID")); $TPL["fromTfName"] = tf::get_name($transactionRepeat->get_value("fromTfID")); include_template($template_name); } $TPL["tfID"] = $tfID; }
function set_value_role($roleHandle) { $db = new db_alloc(); $db->query(prepare("SELECT * FROM role WHERE roleHandle = '%s' AND roleLevel = 'project'", $roleHandle)); $db->next_record(); $this->set_value("roleID", $db->f("roleID")); }
public static function get_list($_FORM) { /* * * Get a list of task history items with sophisticated filtering and somewhat sophisticated output * * (n.b., the output from this generally needs to be post-processed to handle the semantic meaning of changes in various fields) * */ $filter = audit::get_list_filter($_FORM); if (is_array($filter) && count($filter)) { $where_clause = " WHERE " . implode(" AND ", $filter); } if ($_FORM["projectID"]) { $entity = new project(); $entity->set_id($_FORM["projectID"]); $entity->select(); } else { if ($_FORM["taskID"]) { $entity = new task(); $entity->set_id($_FORM["taskID"]); $entity->select(); } } $q = "SELECT *\n FROM audit\n {$where_clause}\n ORDER BY dateChanged"; $db = new db_alloc(); $db->query($q); $items = array(); while ($row = $db->next_record()) { $audit = new audit(); $audit->read_db_record($db); $rows[] = $row; } return $rows; }
function show_overdue($template_name) { global $db; global $TPL; $current_user =& singleton("current_user"); $db = new db_alloc(); $temp = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $today = date("Y", $temp) . "-" . date("m", $temp) . "-" . date("d", $temp); $q = prepare("SELECT itemName,itemType,item.itemID,dateBorrowed,dateToBeReturned,loan.personID \n FROM loan,item \n WHERE dateToBeReturned < '%s' \n\t\t\t\t\t AND dateReturned = '0000-00-00' \n\t\t\t\t\t AND item.itemID = loan.itemID\n ", $today); if (!have_entity_perm("loan", PERM_READ, $current_user, false)) { $q .= prepare("AND loan.personID = %d", $current_user->get_id()); } $db->query($q); while ($db->next_record()) { $i++; $item = new item(); $loan = new loan(); $item->read_db_record($db); $loan->read_db_record($db); $item->set_values(); $loan->set_values(); $person = new person(); $person->set_id($loan->get_value("personID")); $person->select(); $TPL["person"] = $person->get_name(); $TPL["overdue"] = "<a href=\"" . $TPL["url_alloc_item"] . "itemID=" . $item->get_id() . "&return=true\">Overdue!</a>"; include_template($template_name); } }
function show_timeSheetItems($template_name) { global $date_to_view; $current_user =& singleton("current_user"); global $TPL; $query = prepare("SELECT * \n FROM timeSheetItem \n LEFT JOIN timeSheet ON timeSheetItem.timeSheetID = timeSheet.timeSheetID\n LEFT JOIN project ON timeSheet.projectID = project.projectID\n WHERE dateTimeSheetItem='%s'\n AND timeSheet.personID=%d", date("Y-m-d", $date_to_view), $current_user->get_id()); $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $timeSheetItem = new timeSheetItem(); $timeSheetItem->read_db_record($db); $timeSheetItem->set_values(); if ($timeSheetItem->get_value("unit") == "Hour") { $TPL["daily_hours_total"] += $timeSheetItem->get_value("timeSheetItemDuration"); } $project = new project(); $project->read_db_record($db); $project->set_values(); if ($project->get_value("projectShortName")) { $TPL["item_description"] = $project->get_value("projectShortName"); } else { $TPL["item_description"] = $project->get_value("projectName"); } include_template($template_name); } }
public static function get_config_item_id($name = '') { $db = new db_alloc(); $db->query(prepare("SELECT configID FROM config WHERE name = '%s'", $name)); $db->next_record(); return $db->f('configID'); }
function seconds_to_display_time_unit($seconds) { $q = "SELECT * FROM timeUnit"; $db = new db_alloc(); $db->query($q); while ($db->next_record()) { //blag someother time } }
function show_items($template_name) { global $TPL; global $db; global $db2; $current_user =& singleton("current_user"); $today = date("Y") . "-" . date("m") . "-" . date("d"); $dbUsername = new db_alloc(); $db = new db_alloc(); $db2 = new db_alloc(); $db->query("select * from item order by itemName"); while ($db->next_record()) { $i++; $item = new item(); $item->read_db_record($db); $db2->query("select * from loan where itemID=" . $item->get_id() . " and dateReturned='0000-00-00'"); $db2->next_record(); $loan = new loan(); $loan->read_db_record($db2); $item->set_values(); // you need to have this repeated here for the a href bit below. if ($loan->get_value("dateReturned") == "0000-00-00") { if ($loan->have_perm(PERM_READ_WRITE)) { // if item is overdue if ($loan->get_value("dateToBeReturned") < $today) { $ret = "Return Now!"; } else { $ret = "Return"; } $TPL["itemAction"] = "<td><a href=\"" . $TPL["url_alloc_item"] . "itemID=" . $TPL["itemID"] . "&return=true\">{$ret}</a></td>"; } else { // if you don't have permission to borrow or return item. $TPL["itemAction"] = "<td> </td>"; } $TPL["status"] = "Due " . $loan->get_value("dateToBeReturned"); $dbUsername->query("select username from person where personID=" . $loan->get_value("personID")); $dbUsername->next_record(); $TPL["person"] = "from " . $dbUsername->f("username"); } else { // if the item is available $TPL["status"] = "Available"; $TPL["person"] = ""; $TPL["itemAction"] = "<td><a href=\"" . $TPL["url_alloc_item"] . "itemID=" . $TPL["itemID"] . "&borrow=true\">Borrow</a></td>"; $TPL["dueBack"] = ""; } $loan->set_values(); $item->set_values(); include_template($template_name); } }
function get_parent_taskIDs($taskID) { $q = prepare("SELECT taskID,taskName,parentTaskID \n FROM task \n WHERE taskID = %d \n AND (taskID != parentTaskID OR parentTaskID IS NULL)", $taskID); $db = new db_alloc(); $db->query($q); while ($db->next_record()) { $rtn[$db->f("taskName")] = $db->f("taskID"); $arr = get_parent_taskIDs($db->f("parentTaskID")); if (is_array($arr)) { $rtn = array_merge($rtn, $arr); } } return $rtn; }
function show_people($template_name) { global $person_query; global $project; global $TPL; $db = new db_alloc(); $db->query($person_query); while ($db->next_record()) { $person = new person(); $person->read_db_record($db); $person->set_values("person_"); $TPL["graphTitle"] = urlencode($person->get_name()); include_template($template_name); } }
function show_reminder_filter($template) { $current_user =& singleton("current_user"); global $TPL; if ($current_user->have_role("admin") || $current_user->have_role("manage")) { $TPL["reminderActiveOptions"] = page::select_options(array("1" => "Active", "0" => "Inactive"), $_REQUEST["filter_reminderActive"]); $db = new db_alloc(); $db->query("SELECT username,personID FROM person WHERE personActive = 1 ORDER BY username"); while ($db->next_record()) { $recipientOptions[$db->f("personID")] = $db->f("username"); } $TPL["recipientOptions"] = page::select_options($recipientOptions, $_REQUEST["filter_recipient"]); include_template($template); } }
function show_commentTemplate($template_name) { global $TPL; // Run query and loop through the records $db = new db_alloc(); $query = "SELECT * FROM commentTemplate ORDER BY commentTemplateType, commentTemplateName"; $db->query($query); while ($db->next_record()) { $commentTemplate = new commentTemplate(); $commentTemplate->read_db_record($db); $commentTemplate->set_values(); $TPL["odd_even"] = $TPL["odd_even"] == "even" ? "odd" : "even"; include_template($template_name); } }
function show_tasks() { $current_user =& singleton("current_user"); global $tasks_date; list($ts_open, $ts_pending, $ts_closed) = task::get_task_status_in_set_sql(); $q = prepare("SELECT * \n FROM task \n WHERE (task.taskStatus NOT IN (" . $ts_closed . ") AND task.taskTypeID = 'Message') \n AND (personID = %d) \n ORDER BY priority\n ", $current_user->get_id()); $db = new db_alloc(); $db->query($q); while ($db->next_record()) { $task = new task(); $task->read_db_record($db); echo $br . $task->get_task_image() . $task->get_task_link(array("return" => "html")); $br = "<br>"; } }
function show_announcements($template_name) { global $TPL; $people =& get_cached_table("person"); $query = "SELECT announcement.* \n FROM announcement \n ORDER BY displayFromDate DESC"; $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $announcement = new announcement(); $announcement->read_db_record($db); $announcement->set_values(); $TPL["personName"] = $people[$announcement->get_value("personID")]["name"]; $TPL["odd_even"] = $TPL["odd_even"] == "odd" ? "even" : "odd"; include_template($template_name); } }
function show_announcements($template_name) { $current_user =& singleton("current_user"); global $TPL; $query = "SELECT *\n FROM announcement \n WHERE displayFromDate <= CURDATE() AND displayToDate >= CURDATE()\n ORDER BY displayFromDate desc"; $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $announcement = new announcement(); $announcement->read_db_record($db); $announcement->set_tpl_values(); $person = $announcement->get_foreign_object("person"); $TPL["personName"] = $person->get_name(); include_template($this->get_template_dir() . $template_name); } }
function save() { // Just ensure multiple 0 entries cannot be saved. if ($this->get_value("commissionPercent") == 0) { $q = prepare("SELECT * FROM projectCommissionPerson WHERE projectID = %d AND commissionPercent = 0 AND projectCommissionPersonID != %d", $this->get_value("projectID"), $this->get_id()); $db = new db_alloc(); $db->query($q); if ($db->next_record()) { $fail = true; alloc_error("Only one Time Sheet Commission is allowed to be set to 0%"); } } if (!$fail) { parent::save(); } }
function get_skills() { global $TPL; global $skill_class; $skills = array("" => "Any Skill"); $query = "SELECT * FROM skill"; if ($skill_class != "") { $query .= prepare(" WHERE skillClass='%s'", $skill_class); } $query .= " ORDER BY skillClass,skillName"; $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $skill = new skill(); $skill->read_db_record($db); $skills[$skill->get_id()] = sprintf("%s - %s", $skill->get_value('skillClass'), $skill->get_value('skillName')); } return $skills; }
function show_permission_list($template_name) { global $TPL; $roles = permission::get_roles(); if ($_REQUEST["submit"] || $_REQUEST["filter"] != "") { $where = " where tableName like '%" . db_esc($_REQUEST["filter"]) . "%' "; // TODO: Add filtering to permission list } $db = new db_alloc(); $db->query("SELECT * FROM permission {$where} ORDER BY tableName, sortKey"); while ($db->next_record()) { $permission = new permission(); $permission->read_db_record($db); $permission->set_values(); $TPL["actions"] = $permission->describe_actions(); $TPL["odd_even"] = $TPL["odd_even"] == "odd" ? "even" : "odd"; $TPL["roleName"] = $roles[$TPL["roleName"]]; include_template($template_name); } }
function is_owner($person = "") { $current_user =& singleton("current_user"); if ($person == "") { $person = $current_user; } $db = new db_alloc(); $q = prepare("SELECT * FROM transaction WHERE invoiceItemID = %d OR transactionID = %d", $this->get_id(), $this->get_value("transactionID")); $db->query($q); while ($db->next_record()) { $transaction = new transaction(); $transaction->read_db_record($db); if ($transaction->is_owner($person)) { return true; } } if ($this->get_value("timeSheetID")) { $q = prepare("SELECT * FROM timeSheet WHERE timeSheetID = %d", $this->get_value("timeSheetID")); $db->query($q); while ($db->next_record()) { $timeSheet = new timeSheet(); $timeSheet->read_db_record($db); if ($timeSheet->is_owner($person)) { return true; } } } if ($this->get_value("expenseFormID")) { $q = prepare("SELECT * FROM expenseForm WHERE expenseFormID = %d", $this->get_value("expenseFormID")); $db->query($q); while ($db->next_record()) { $expenseForm = new expenseForm(); $expenseForm->read_db_record($db); if ($expenseForm->is_owner($person)) { return true; } } } return false; }
function show_person_list($template) { global $TPL; global $tf; $db = new db_alloc(); $TPL["person_buttons"] = ' <button type="submit" name="person_delete" value="1" class="delete_button">Delete<i class="icon-trash"></i></button> <button type="submit" name="person_save" value="1" class="save_button">Save<i class="icon-ok-sign"></i></button>'; $tfID = $tf->get_id(); if ($tfID) { $query = prepare("SELECT * from tfPerson WHERE tfID=%d", $tfID); $db->query($query); while ($db->next_record()) { $tfPerson = new tfPerson(); $tfPerson->read_db_record($db); $tfPerson->set_values("person_"); $person = $tfPerson->get_foreign_object("person"); $TPL["person_username"] = $person->get_value("username"); include_template($template); } } }
function show_productCost_list($productID, $template, $percent = false) { global $TPL; unset($TPL["display"], $TPL["taxOptions"]); // otherwise the commissions don't display. if ($productID) { $t = new meta("currencyType"); $currency_array = $t->get_assoc_array("currencyTypeID", "currencyTypeID"); $db = new db_alloc(); $query = prepare("SELECT * \n FROM productCost \n WHERE productID = %d \n AND isPercentage = %d\n AND productCostActive = true\n ORDER BY productCostID", $productID, $percent); $db->query($query); while ($db->next_record()) { $productCost = new productCost(); $productCost->read_db_record($db); $productCost->set_tpl_values(); $TPL["currencyOptions"] = page::select_options($currency_array, $productCost->get_value("currencyTypeID")); $TPL["taxOptions"] = page::select_options(array("" => "Exempt", 1 => "Included", 0 => "Excluded"), $productCost->get_value("tax")); // Hardcoded AUD because productCost table uses percent and dollars in same field $percent and $TPL["amount"] = page::money("AUD", $productCost->get_value("amount"), "%mo"); include_template($template); } } }
public static function get_list($_FORM = array()) { $filter = product::get_list_filter($_FORM); $debug = $_FORM["debug"]; $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>"; $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>"; if (is_array($filter) && count($filter)) { $f = " WHERE " . implode(" AND ", $filter); } // Put the inactive ones down the bottom. $f .= " ORDER BY productActive DESC, productName"; $taxName = config::get_config_item("taxName"); $query = prepare("SELECT * FROM product " . $f); $db = new db_alloc(); $db->query($query); while ($row = $db->next_record()) { $product = new product(); $product->read_db_record($db); $row["taxName"] = $taxName; $rows[] = $row; } return $rows; }
function show_productSale_list($productSaleID, $template) { global $TPL; global $productSaleItemsDoExist; $productSale = new productSale(); $productSale->set_id($productSaleID); $productSale->select(); $productSale->set_tpl_values(); $taxName = config::get_config_item("taxName"); $product = new product(); $ops = $product->get_assoc_array("productID", "productName"); $query = prepare("SELECT *\n FROM productSaleItem \n WHERE productSaleID = %d", $productSaleID); $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $productSaleItemsDoExist = true; $productSaleItem = new productSaleItem(); $productSaleItem->read_db_record($db); $productSaleItem->set_tpl_values(); $TPL["itemSellPrice"] = $productSaleItem->get_value("sellPrice"); $TPL["itemMargin"] = $productSaleItem->get_amount_margin(); $TPL["itemSpent"] = $productSaleItem->get_amount_spent(); $TPL["itemEarnt"] = $productSaleItem->get_amount_earnt(); $TPL["itemOther"] = $productSaleItem->get_amount_other(); $TPL["itemCosts"] = page::money(config::get_config_item("currency"), product::get_buy_cost($productSaleItem->get_value("productID")) * $productSaleItem->get_value("quantity"), "%s%mo %c"); $TPL["itemTotalUnallocated"] = $productSaleItem->get_amount_unallocated(); $TPL["productList_dropdown"] = page::select_options($ops, $productSaleItem->get_value("productID")); $TPL["productLink"] = "<a href=\"" . $TPL["url_alloc_product"] . "productID=" . $productSaleItem->get_value("productID") . "\">" . page::htmlentities($ops[$productSaleItem->get_value("productID")]) . "</a>"; $TPL["transactions"] = $productSale->get_transactions($productSaleItem->get_id()); if ($taxName) { $TPL["sellPriceTax_check"] = sprintf(" <input type='checkbox' name='sellPriceIncTax[]' value='%d'%s> inc %s", $productSaleItem->get_id(), $productSaleItem->get_value("sellPriceIncTax") ? ' checked' : '', $taxName); $TPL["sellPriceTax_label"] = $productSaleItem->get_value("sellPriceIncTax") ? " inc " . $taxName : " ex " . $taxName; } include_template($template); } }
$info["port"] = config::get_config_item("allocEmailPort"); $info["username"] = config::get_config_item("allocEmailUsername"); $info["password"] = config::get_config_item("allocEmailPassword"); $info["protocol"] = config::get_config_item("allocEmailProtocol"); if (!$info["host"]) { alloc_error("Email mailbox host not defined, assuming email receive function is inactive."); } else { $mail = new email_receive($info, $lockfile); $mail->open_mailbox(config::get_config_item("allocEmailFolder")); $mail->check_mail(); $TPL["message_good"][] = "Connection succeeded!"; } } $db = new db_alloc(); $db->query("SELECT name,value,type FROM config"); while ($db->next_record()) { $fields_to_save[] = $db->f("name"); $types[$db->f("name")] = $db->f("type"); if ($db->f("type") == "text") { $TPL[$db->f("name")] = page::htmlentities($db->f("value")); } else { if ($db->f("type") == "array") { $TPL[$db->f("name")] = unserialize($db->f("value")); } } } #echo "<pre>".print_r($_POST,1)."</pre>"; if ($_POST["update_currencyless_transactions"] && $_POST["currency"]) { $db = new db_alloc(); $q = prepare("UPDATE transaction SET currencyTypeID = '%s' WHERE currencyTypeID IS NULL", $_POST["currency"]); $db->query($q);
$_POST["companyDetails"] or alloc_error("Please provide Company Details"); $_POST["transactionType"] or alloc_error("Please select a Transaction Type"); $_POST["transactionStartDate"] or alloc_error("You must enter the Start date in the format yyyy-mm-dd"); $_POST["transactionFinishDate"] or alloc_error("You must enter the Finish date in the format yyyy-mm-dd"); if (!$TPL["message"]) { !$transactionRepeat->get_value("status") && $transactionRepeat->set_value("status", "pending"); $transactionRepeat->set_value("companyDetails", rtrim($transactionRepeat->get_value("companyDetails"))); $transactionRepeat->save(); alloc_redirect($TPL["url_alloc_transactionRepeat"] . "transactionRepeatID=" . $transactionRepeat->get_id()); } $transactionRepeat->set_values(); } $TPL["reimbursementRequired_checked"] = $transactionRepeat->get_value("reimbursementRequired") ? " checked" : ""; if ($transactionRepeat->get_value("transactionRepeatModifiedUser")) { $db->query("select username from person where personID=%d", $transactionRepeat->get_value("transactionRepeatModifiedUser")); $db->next_record(); $TPL["user"] = $db->f("username"); } if (have_entity_perm("tf", PERM_READ, $current_user, false)) { // Person can access all TF records $q = prepare("SELECT tfID AS value, tfName AS label \n FROM tf \n WHERE tfActive = 1 \n OR tf.tfID = %d \n OR tf.tfID = %d \n ORDER BY tfName", $transactionRepeat->get_value("tfID"), $transactionRepeat->get_value("fromTfID")); } else { if (have_entity_perm("tf", PERM_READ, $current_user, true)) { // Person can only read TF records that they own $q = prepare("SELECT tf.tfID AS value, tf.tfName AS label\n FROM tf, tfPerson \n WHERE tfPerson.personID=%d \n AND tf.tfID=tfPerson.tfID \n AND (tf.tfActive = 1 OR tf.tfID = %d OR tf.tfID = %d)\n ORDER BY tfName", $current_user->get_id(), $transactionRepeat->get_value("tfID"), $transactionRepeat->get_value("fromTfID")); } else { alloc_error("No permissions to generate TF list"); } } //special case for disabled TF. Include it in the list, but also add a warning message. $tf = new tf();
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"); }
function get_foreign_objects($class_name, $key_name = "") { if ($key_name == "") { $key_name = $this->key_field->get_name(); } $foreign_objects = array(); $query = prepare("SELECT * FROM %s WHERE %s = %d", $class_name, $key_name, $this->get_id()); $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $o = new $class_name(); $o->read_db_record($db); $foreign_objects[$o->get_id()] = $o; } return $foreign_objects; }
public static function get_list($_FORM) { $filter = token::get_list_filter($_FORM); if (is_array($filter) && count($filter)) { $filter = " WHERE " . implode(" AND ", $filter); } $q = "SELECT * FROM token " . $filter; $db = new db_alloc(); $db->query($q); while ($row = $db->next_record()) { $rows[$row["tokenID"]] = $row; } return (array) $rows; }
// Strip $ and , from amount $amount = str_replace(array('$', ','), array(), $amount); if (!preg_match("/^-?[0-9]+(\\.[0-9]+)?\$/", $amount)) { $msg .= "<b>Warning: Could not convert amount '{$amount}'</b><br>"; continue; } // Ignore positive amounts if ($amount > 0) { $msg .= "<b>Warning: Ignored positive '{$amount}' for {$memo} on {$date}</b><br>"; continue; } // Find the TF ID for the expense $query = prepare("SELECT * FROM tf WHERE tfActive = 1 AND quickenAccount='%s'", $account); echo $query; $db->query($query); if ($db->next_record()) { $fromTfID = $db->f("tfID"); } else { $msg .= "<b>Warning: Could not find active TF for account '{$account}'</b><br>"; continue; } // Check for an existing transaction $query = prepare("SELECT * FROM transaction WHERE transactionType='expense' AND transactionDate='%s' AND product='%s' AND amount > %0.3f and amount < %0.3f", $date, $memo, $amount - 0.004, $amount + 0.004); $db->query($query); if ($db->next_record()) { $msg .= "Warning: Expense '{$memo}' on {$date} already exixsts.<br>"; continue; } // Create a transaction object and then save it $transaction = new transaction(); $transaction->set_value("companyDetails", $description);
public static function get_list($_FORM = array()) { // Two modes, 1: get all comments for an entity, eg a task if ($_FORM["entity"] && in_array($_FORM["entity"], array("project", "client", "task", "timeSheet")) && $_FORM["entityID"]) { $e = new $_FORM["entity"](); $e->set_id($_FORM["entityID"]); if ($e->select()) { // this ensures that the user can read the entity return comment::util_get_comments_array($_FORM["entity"], $_FORM["entityID"], $_FORM); } // Or 2: get all starred comments } else { if ($_FORM["starred"]) { $filter = comment::get_list_filter($_FORM); if (is_array($filter) && count($filter)) { $filter = " WHERE " . implode(" AND ", $filter); } $q = "SELECT comment.*, commentCreatedUser as personID, clientContact.clientContactName\n FROM comment \n LEFT JOIN clientContact on comment.commentCreatedUserClientContactID = clientContact.clientContactID\n " . $filter . " \n ORDER BY commentCreatedTime"; $db = new db_alloc(); $db->query($q); $people =& get_cached_table("person"); while ($row = $db->next_record()) { $e = new $row["commentMaster"](); $e->set_id($row["commentMasterID"]); $e->select(); $row["entity_link"] = $e->get_link(); $row["personID"] and $row["person"] = $people[$row["personID"]]["name"]; $row["clientContactName"] and $row["person"] = $row["clientContactName"]; $rows[] = $row; } has("timeSheetItem") and $tsi_rows = timeSheetItem::get_timeSheetItemComments(null, true); foreach ((array) $tsi_rows as $row) { $t = new task(); $t->set_id($row["taskID"]); $t->select(); $row["entity_link"] = $t->get_link(); $row["commentMaster"] = "Task"; $row["commentMasterID"] = $row["taskID"]; $row["commentCreatedTime"] = $row["date"]; $row["personID"] and $row["person"] = $people[$row["personID"]]["name"]; $rows[] = $row; } return (array) $rows; } } }