function make_interested_parties($entity, $entityID, $encoded_parties = array()) { // Nuke entries from interestedParty $db = new db_alloc(); $db->start_transaction(); // Add entries to interestedParty if (is_array($encoded_parties)) { foreach ($encoded_parties as $encoded) { $info = interestedParty::get_decoded_interested_party_identifier($encoded); $info["entity"] = $entity; $info["entityID"] = $entityID; $info["emailAddress"] or $info["emailAddress"] = $info["email"]; $ipIDs[] = interestedParty::add_interested_party($info); } } $q = prepare("UPDATE interestedParty\n SET interestedPartyActive = 0\n WHERE entity = '%s'\n AND entityID = %d", $entity, $entityID); $ipIDs and $q .= " AND " . sprintf_implode(" AND ", "interestedPartyID != %d", $ipIDs); $db->query($q); $db->commit(); }
function get_list_filter($filter = array()) { $filter["tokenEntity"] and $sql[] = sprintf_implode("token.tokenEntity = '%s'", $filter["tokenEntity"]); $filter["tokenEntityID"] and $sql[] = sprintf_implode("token.tokenEntityID = %d", $filter["tokenEntityID"]); $filter["tokenHash"] and $sql[] = sprintf_implode("token.tokenHash = '%s'", $filter["tokenHash"]); return $sql; }
public static function get_list_filter($filter = array()) { $current_user =& singleton("current_user"); // If they want starred, load up the productSaleID filter element if ($filter["starred"]) { foreach ((array) $current_user->prefs["stars"]["productSale"] as $k => $v) { $filter["productSaleID"][] = $k; } is_array($filter["productSaleID"]) or $filter["productSaleID"][] = -1; } // Filter productSaleID $filter["productSaleID"] and $sql[] = sprintf_implode("productSale.productSaleID = %d", $filter["productSaleID"]); // No point continuing if primary key specified, so return if ($filter["productSaleID"] || $filter["starred"]) { return $sql; } $id_fields = array("clientID", "projectID", "personID", "tfID", "productSaleCreatedUser", "productSaleModifiedUser"); foreach ($id_fields as $f) { $filter[$f] and $sql[] = sprintf_implode("productSale." . $f . " = %d", $filter[$f]); } $filter["status"] and $sql[] = sprintf_implode("productSale.status = '%s'", $filter["status"]); return $sql; }
public static function get_list_filter($filter = array()) { $current_user =& singleton("current_user"); // If they want starred, load up the taskID filter element if ($filter["starred"]) { foreach ((array) $current_user->prefs["stars"]["task"] as $k => $v) { $filter["taskID"][] = $k; } is_array($filter["taskID"]) or $filter["taskID"][] = -1; } // Filter on taskID $filter["taskID"] and $sql[] = sprintf_implode("task.taskID = %d", $filter["taskID"]); // No point continuing if primary key specified, so return if ($filter["taskID"]) { return array($sql, ""); } // This takes care of projectID singular and plural has("project") and $projectIDs = project::get_projectID_sql($filter); $projectIDs and $sql["projectIDs"] = $projectIDs; // project name or project nick name or project id $filter["projectNameMatches"] and $sql[] = sprintf_implode("project.projectName LIKE '%%%s%%'\n OR project.projectShortName LIKE '%%%s%%'\n OR project.projectID = %d", $filter["projectNameMatches"], $filter["projectNameMatches"], $filter["projectNameMatches"]); list($ts_open, $ts_pending, $ts_closed) = task::get_task_status_in_set_sql(); // New Tasks if ($filter["taskDate"] == "new") { $past = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 2, date("Y"))) . " 00:00:00"; date("D") == "Mon" and $past = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 4, date("Y"))) . " 00:00:00"; $sql[] = prepare("(task.taskStatus NOT IN (" . $ts_closed . ") AND task.dateCreated >= '" . $past . "')"); // Due Today } else { if ($filter["taskDate"] == "due_today") { $sql[] = "(task.taskStatus NOT IN (" . $ts_closed . ") AND task.dateTargetCompletion = '" . date("Y-m-d") . "')"; // Overdue } else { if ($filter["taskDate"] == "overdue") { $sql[] = "(task.taskStatus NOT IN (" . $ts_closed . ")\n AND \n (task.dateTargetCompletion IS NOT NULL AND task.dateTargetCompletion != '' AND '" . date("Y-m-d") . "' > task.dateTargetCompletion))"; // Date Created } else { if ($filter["taskDate"] == "d_created") { $filter["dateOne"] and $sql[] = prepare("(task.dateCreated >= '%s')", $filter["dateOne"]); $filter["dateTwo"] and $sql[] = prepare("(task.dateCreated <= '%s 23:59:59')", $filter["dateTwo"]); // Date Assigned } else { if ($filter["taskDate"] == "d_assigned") { $filter["dateOne"] and $sql[] = prepare("(task.dateAssigned >= '%s')", $filter["dateOne"]); $filter["dateTwo"] and $sql[] = prepare("(task.dateAssigned <= '%s 23:59:59')", $filter["dateTwo"]); // Date Target Start } else { if ($filter["taskDate"] == "d_targetStart") { $filter["dateOne"] and $sql[] = prepare("(task.dateTargetStart >= '%s')", $filter["dateOne"]); $filter["dateTwo"] and $sql[] = prepare("(task.dateTargetStart <= '%s')", $filter["dateTwo"]); // Date Target Completion } else { if ($filter["taskDate"] == "d_targetCompletion") { $filter["dateOne"] and $sql[] = prepare("(task.dateTargetCompletion >= '%s')", $filter["dateOne"]); $filter["dateTwo"] and $sql[] = prepare("(task.dateTargetCompletion <= '%s')", $filter["dateTwo"]); // Date Actual Start } else { if ($filter["taskDate"] == "d_actualStart") { $filter["dateOne"] and $sql[] = prepare("(task.dateActualStart >= '%s')", $filter["dateOne"]); $filter["dateTwo"] and $sql[] = prepare("(task.dateActualStart <= '%s')", $filter["dateTwo"]); // Date Actual Completion } else { if ($filter["taskDate"] == "d_actualCompletion") { $filter["dateOne"] and $sql[] = prepare("(task.dateActualCompletion >= '%s')", $filter["dateOne"]); $filter["dateTwo"] and $sql[] = prepare("(task.dateActualCompletion <= '%s')", $filter["dateTwo"]); } } } } } } } } } // Task status filtering $filter["taskStatus"] and $sql[] = task::get_taskStatus_sql($filter["taskStatus"]); $filter["taskTypeID"] and $sql[] = sprintf_implode("task.taskTypeID = '%s'", $filter["taskTypeID"]); // Filter on %taskName% $filter["taskName"] and $sql[] = sprintf_implode("task.taskName LIKE '%%%s%%'", $filter["taskName"]); // If personID filter $filter["personID"] and $sql["personID"] = sprintf_implode("IFNULL(task.personID,0) = %d", $filter["personID"]); $filter["creatorID"] and $sql["creatorID"] = sprintf_implode("IFNULL(task.creatorID,0) = %d", $filter["creatorID"]); $filter["managerID"] and $sql["managerID"] = sprintf_implode("IFNULL(task.managerID,0) = %d", $filter["managerID"]); // If tags filter if ($filter["tags"] && is_array($filter["tags"])) { foreach ((array) $filter["tags"] as $k => $tag) { $tag and $tags[] = $tag; } $tags and $sql[] = sprintf_implode("seltag.name = '%s'", $tags); $having = prepare("HAVING count(DISTINCT seltag.name) = %d", count($tags)); } // These filters are for the time sheet dropdown list if ($filter["taskTimeSheetStatus"] == "open") { unset($sql["personID"]); $sql[] = prepare("(task.taskStatus NOT IN (" . $ts_closed . "))"); } else { if ($filter["taskTimeSheetStatus"] == "mine") { $current_user =& singleton("current_user"); unset($sql["personID"]); $sql[] = prepare("((task.taskStatus NOT IN (" . $ts_closed . ")) AND task.personID = %d)", $current_user->get_id()); } else { if ($filter["taskTimeSheetStatus"] == "not_assigned") { unset($sql["personID"]); $sql[] = prepare("((task.taskStatus NOT IN (" . $ts_closed . ")) AND task.personID != %d)", $filter["personID"]); } else { if ($filter["taskTimeSheetStatus"] == "recent_closed") { unset($sql["personID"]); $sql[] = prepare("(task.dateActualCompletion >= DATE_SUB(CURDATE(),INTERVAL 14 DAY))"); } else { if ($filter["taskTimeSheetStatus"] == "all") { } } } } } $filter["parentTaskID"] and $sql["parentTaskID"] = sprintf_implode("IFNULL(task.parentTaskID,0) = %d", $filter["parentTaskID"]); return array($sql, $having); }
public static function get_projectID_sql($filter, $table = "project") { if (!$filter["projectID"] && $filter["projectType"] && $filter["projectType"] != "all") { $db = new db_alloc(); $q = project::get_project_type_query($filter["projectType"], $filter["current_user"], "current"); $db->query($q); while ($db->next_record()) { $filter["projectIDs"][] = $db->f("projectID"); } // Oi! What a pickle. Need this flag for when someone doesn't have entries loaded in the above while loop. $firstOption = true; // If projectID is an array } else { if ($filter["projectID"] && is_array($filter["projectID"])) { $filter["projectIDs"] = $filter["projectID"]; // Else a project has been specified in the url } else { if ($filter["projectID"] && is_numeric($filter["projectID"])) { $filter["projectIDs"][] = $filter["projectID"]; } } } // If passed array projectIDs then join them up with commars and put them in an sql subset if (is_array($filter["projectIDs"]) && count($filter["projectIDs"])) { return sprintf_implode("(" . $table . ".projectID = %d)", $filter["projectIDs"]); // If there are no projects in $filter["projectIDs"][] and we're attempting the first option.. } else { if ($firstOption) { return "(" . $table . ".projectID = 0)"; } } }
public static function get_list_filter($filter = array()) { $current_user =& singleton("current_user"); // If they want starred, load up the timeSheetID filter element if ($filter["starred"]) { foreach ((array) $current_user->prefs["stars"]["timeSheet"] as $k => $v) { $filter["timeSheetID"][] = $k; } is_array($filter["timeSheetID"]) or $filter["timeSheetID"][] = -1; } // Filter timeSheetID $filter["timeSheetID"] and $sql[] = sprintf_implode("timeSheet.timeSheetID = %d", $filter["timeSheetID"]); // No point continuing if primary key specified, so return if ($filter["timeSheetID"] || $filter["starred"]) { return $sql; } $filter["tfID"] and $sql[] = sprintf_implode("timeSheet.recipient_tfID = %d", $filter["tfID"]); $filter["projectID"] and $sql[] = sprintf_implode("timeSheet.projectID = %d", $filter["projectID"]); $filter["taskID"] and $sql[] = sprintf_implode("timeSheetItem.taskID = %d", $filter["taskID"]); $filter["personID"] and $sql[] = sprintf_implode("timeSheet.personID = %d", $filter["personID"]); $filter["status"] and $sql[] = sprintf_implode("timeSheet.status = '%s'", $filter["status"]); if ($filter["dateFrom"]) { in_array($filter["dateFromComparator"], array("=", "!=", ">", ">=", "<", "<=")) or $filter["dateFromComparator"] = '='; $sql[] = prepare("(timeSheet.dateFrom " . $filter['dateFromComparator'] . " '%s')", $filter["dateFrom"]); } if ($filter["dateTo"]) { in_array($filter["dateToComparator"], array("=", "!=", ">", ">=", "<", "<=")) or $filter["dateToComparator"] = '='; $sql[] = prepare("(timeSheet.dateTo " . $filter['dateToComparator'] . " '%s')", $filter["dateTo"]); } return $sql; }
function get_list_filter($filter = array()) { $current_user =& singleton("current_user"); // If they want starred, load up the clientID filter element if ($filter["starred"]) { foreach ((array) $current_user->prefs["stars"]["client"] as $k => $v) { $filter["clientID"][] = $k; } is_array($filter["clientID"]) or $filter["clientID"][] = -1; } // Filter on clientID $filter["clientID"] and $sql[] = sprintf_implode("client.clientID = %d", $filter["clientID"]); // No point continuing if primary key specified, so return if ($filter["clientID"] || $filter["starred"]) { return $sql; } $filter["clientStatus"] and $sql[] = sprintf_implode("client.clientStatus = '%s'", $filter["clientStatus"]); $filter["clientCategory"] and $sql[] = sprintf_implode("IFNULL(client.clientCategory,'') = '%s'", $filter["clientCategory"]); $filter["clientName"] and $sql[] = sprintf_implode("IFNULL(clientName,'') LIKE '%%%s%%'", $filter["clientName"]); $filter["contactName"] and $sql[] = sprintf_implode("IFNULL(clientContactName,'') LIKE '%%%s%%'", $filter["contactName"]); if ($filter["clientLetter"] && $filter["clientLetter"] == "A") { $sql[] = "(clientName like 'A%' or clientName REGEXP '^[^[:alpha:]]')"; } else { if ($filter["clientLetter"] && $filter["clientLetter"] != "ALL") { $sql[] = sprintf_implode("clientName LIKE '%s%%'", $filter["clientLetter"]); } } return $sql; }
public static function get_list_filter($_FORM = array()) { $current_user =& singleton("current_user"); if (!$_FORM["tfIDs"] && !$current_user->have_role('admin')) { $_FORM["owner"] = true; } $_FORM["owner"] and $filter1[] = sprintf_implode("tfPerson.personID = %d", $current_user->get_id()); $tfIDs = tf::get_permitted_tfs($_FORM["tfIDs"]); $tfIDs and $filter1[] = sprintf_implode("tf.tfID = %d", $tfIDs); $tfIDs and $filter2[] = sprintf_implode("tf.tfID = %d", $tfIDs); $_FORM["showall"] or $filter1[] = "(tf.tfActive = 1)"; $_FORM["showall"] or $filter2[] = "(tf.tfActive = 1)"; return array($filter1, $filter2); }
function get_list_filter($filter = array()) { $current_user =& singleton("current_user"); $sql = array(); // If they want starred, load up the invoiceID filter element if ($filter["starred"]) { foreach ((array) $current_user->prefs["stars"]["invoice"] as $k => $v) { $filter["invoiceID"][] = $k; } is_array($filter["invoiceID"]) or $filter["invoiceID"][] = -1; } // Filter invoiceID $filter["invoiceID"] and $sql[] = sprintf_implode("invoice.invoiceID = %d", $filter["invoiceID"]); // No point continuing if primary key specified, so return if ($filter["invoiceID"] || $filter["starred"]) { return $sql; } if ($filter["personID"]) { $q = "SELECT DISTINCT project.clientID\n FROM projectPerson LEFT JOIN project ON projectPerson.projectID = project.projectID\n WHERE " . sprintf_implode("projectPerson.personID = %d", $filter["personID"]) . "\n AND project.clientID IS NOT NULL"; $db = new db_alloc(); $db->query($q); while ($row = $db->row()) { $valid_clientIDs[] = $row["clientID"]; } $filter["clientID"] && !is_array($filter["clientID"]) and $filter["clientID"] = array($filter["clientID"]); foreach ((array) $filter["clientID"] as $clientID) { if (in_array($clientID, (array) $valid_clientIDs)) { $approved_clientIDs[] = $clientID; } } $approved_clientIDs or $approved_clientIDs = (array) $valid_clientIDs; if ($approved_clientIDs) { $filter["clientID"] = $approved_clientIDs; } else { $filter["clientID"] = array(0); } } $filter["invoiceNum"] and $sql[] = sprintf_implode("invoice.invoiceNum = %d", $filter["invoiceNum"]); $filter["dateOne"] and $sql[] = sprintf_implode("invoice.invoiceDateFrom>='%s'", $filter["dateOne"]); $filter["dateTwo"] and $sql[] = sprintf_implode("invoice.invoiceDateTo<='%s'", $filter["dateTwo"]); $filter["invoiceName"] and $sql[] = sprintf_implode("invoice.invoiceName like '%%%s%%'", $filter["invoiceName"]); $filter["invoiceStatus"] and $sql[] = sprintf_implode("invoice.invoiceStatus = '%s'", $filter["invoiceStatus"]); $filter["clientID"] and $sql[] = sprintf_implode("invoice.clientID = %d", $filter["clientID"]); $filter["projectID"] and $sql[] = sprintf_implode("invoice.projectID = %d", $filter["projectID"]); return $sql; }
function get_list_filter($filter = array()) { $filter["username"] and $sql[] = sprintf_implode("username = '******'", $filter["username"]); $filter["personActive"] and $sql[] = sprintf_implode("personActive = %d", $filter["personActive"]); $filter["firstName"] and $sql[] = sprintf_implode("firstName = '%s'", $filter["firstName"]); $filter["surname"] and $sql[] = sprintf_implode("surname = '%s'", $filter["surname"]); $filter["personID"] and $sql[] = sprintf_implode("personID = %d", $filter["personID"]); $filter["skill"] and $sql["skill"] = sprintf_implode("skillID=%d", $filter["skill"]); if ($filter["skill_class"]) { $q = prepare("SELECT * FROM skill WHERE skillClass='%s'", $filter["skill_class"]); $db = new db_alloc(); $db->query($q); while ($db->next_record()) { $skill = new skill(); $skill->read_db_record($db); $sql2[] = prepare("(skillID=%d)", $skill->get_id()); } } $filter["expertise"] and $sql[] = sprintf_implode("skillProficiency='%s'", $filter["expertise"]); return array($sql, $sql2); }
function get_list_filter($_FORM) { $current_user =& singleton("current_user"); if (is_array($_FORM["tfIDs"]) && count($_FORM["tfIDs"])) { $sql["tfIDs"] = sprintf_implode("transaction.tfID = %d or transaction.fromTfID = %d", $_FORM["tfIDs"], $_FORM["tfIDs"]); } if ($_FORM["monthDate"]) { $_FORM["startDate"] = format_date("Y-m-", $_FORM["monthDate"]) . "01"; $t = format_date("U", $_FORM["monthDate"]); $_FORM["endDate"] = date("Y-m-d", mktime(1, 1, 1, date("m", $t) + 1, 1, date("Y", $t))); } $_FORM["sortTransactions"] or $_FORM["sortTransactions"] = "transactionDate"; if ($_FORM["sortTransactions"] == "transactionSortDate") { $_FORM["sortTransactions"] = "if(transactionModifiedTime,transactionModifiedTime,transactionCreatedTime)"; } $_FORM["startDate"] and $sql["startDate"] = prepare("(%s >= '%s')", $_FORM["sortTransactions"], $_FORM["startDate"]); $_FORM["startDate"] and $sql["prevBalance"] = prepare("(%s < '%s')", $_FORM["sortTransactions"], $_FORM["startDate"]); $_FORM["endDate"] and $sql["endDate"] = prepare("(%s < '%s')", $_FORM["sortTransactions"], $_FORM["endDate"]); $_FORM["status"] and $sql["status"] = prepare("(status = '%s')", $_FORM["status"]); $_FORM["transactionType"] and $sql["transactionType"] = prepare("(transactionType = '%s')", $_FORM["transactionType"]); $_FORM["fromTfID"] and $sql["fromTfID"] = prepare("(fromTfID=%d)", $_FORM["fromTfID"]); $_FORM["expenseFormID"] and $sql["expenseFormID"] = prepare("(expenseFormID=%d)", $_FORM["expenseFormID"]); $_FORM["transactionID"] and $sql["transactionID"] = prepare("(transactionID=%d)", $_FORM["transactionID"]); $_FORM["product"] and $sql["product"] = prepare("(product LIKE \"%%%s%%\")", $_FORM["product"]); $_FORM["amount"] and $sql["amount"] = prepare("(amount = '%s')", $_FORM["amount"]); return $sql; }