You are here

function support_pm_load_projects in Support Ticketing System 6

Same name and namespace in other branches
  1. 7 support_pm/support_pm.module \support_pm_load_projects()

Load projects assigned to a given client.

3 calls to support_pm_load_projects()
support_pm_form_alter in support_pm/support_pm.module
support_pm_invoice_ui_form in support_pm/support_pm.module
Provide form for selecting projects.
support_pm_invoice_ui_form_submit in support_pm/support_pm.module
Add url filter when projects are selected.

File

support_pm/support_pm.module, line 1027
Support Project Management. @author Jeremy Andrews <jeremy@tag1consulting.com> @package Support

Code

function support_pm_load_projects($clid, $recursive = FALSE) {
  $projects = array();
  $result = db_query('SELECT sp.projid, sp.project FROM {support_project} sp LEFT JOIN {support_project_client} spc ON sp.projid = spc.projid WHERE (spc.clid = %d OR ISNULL(spc.clid)) AND disabled = 0', $clid);
  while ($project = db_fetch_object($result)) {
    $projects[$project->projid] = $project->project;
  }
  if ($recursive) {
    $result = db_query("SELECT clid, name FROM {support_client} WHERE parent = %d", $clid);
    while ($subclient = db_fetch_object($result)) {
      $result2 = db_query('SELECT sp.projid, sp.project FROM {support_project} sp LEFT JOIN {support_project_client} spc ON sp.projid = spc.projid WHERE (spc.clid = %d OR ISNULL(spc.clid)) AND disabled = 0', $subclient->clid);
      while ($subproject = db_fetch_object($result2)) {
        $projects["{$subproject->projid}:{$subclient->clid}"] = " -> {$subclient->name}: {$subproject->project}";
      }
    }
  }
  return $projects;
}