function dbmap() { global $g_oSec; commonHeader(); if (!$g_oSec->HasPerm(DCL_ENTITY_ATTRIBUTESETS, DCL_PERM_MODIFY)) { return PrintPermissionDenied(); } if (($iSetID = @DCL_Sanitize::ToInt($_REQUEST['setid'])) === null) { trigger_error('Data sanitize failed.'); return; } if (($iTypeID = @DCL_Sanitize::ToInt($_REQUEST['typeid'])) === null) { trigger_error('Data sanitize failed.'); return; } $obj =& CreateObject('dcl.dbAttributesetsmap'); $obj->setid = $iSetID; $obj->typeid = $iTypeID; $obj->BeginTransaction(); $obj->DeleteBySetType($iSetID, $iTypeID); if (($aKeyID = @DCL_Sanitize::ToIntArray($_REQUEST['keyidset'])) !== null) { $i = 1; foreach ($aKeyID as $id) { $obj->weight = $i; $obj->keyid = $id; $obj->Add(); $i++; } } $obj->EndTransaction(); $objA =& CreateObject('dcl.dbAttributesets'); $objA->Load($obj->setid); $objH =& CreateObject('dcl.htmlAttributesetdetail'); $objH->Show($objA); }
function ListSelected($id) { if (($id = @DCL_Sanitize::ToIntArray($id)) === null) { trigger_error('Data sanitize failed.'); return; } $sSQL = 'SELECT org_id, name FROM dcl_org WHERE org_id IN (' . join(',', $id) . ') ORDER BY name'; return $this->oDB->Query($sSQL); }
function updateOrgs($contact_id, &$aOrgID) { if (($contact_id = DCL_Sanitize::ToInt($contact_id)) === null) { return PrintPermissionDenied(); } $aOrgID = DCL_Sanitize::ToIntArray($aOrgID); if ($aOrgID === null || count($aOrgID) == 0) { $aOrgID = array("-1"); } $sOrgID = join(',', $aOrgID); $this->Execute("DELETE FROM dcl_org_contact WHERE contact_id = {$contact_id} AND org_id NOT IN ({$sOrgID})"); $this->Execute("INSERT INTO dcl_org_contact (org_id, contact_id, created_on, created_by) SELECT org_id, {$contact_id}, " . $this->GetDateSQL() . ", " . $GLOBALS['DCLID'] . " FROM dcl_org WHERE org_id IN ({$sOrgID}) AND org_id NOT IN (SELECT org_id FROM dcl_org_contact WHERE contact_id = {$contact_id})"); }
function updateProducts($org_id, &$aProductID) { if (($org_id = DCL_Sanitize::ToInt($org_id)) === null) { return PrintPermissionDenied(); } $aProductID = DCL_Sanitize::ToIntArray($aProductID); if ($aProductID === null || count($aProductID) == 0) { $aProductID = array("-1"); } $sProductID = join(',', $aProductID); $this->Execute("DELETE FROM dcl_org_product_xref WHERE org_id = {$org_id} AND product_id NOT IN ({$sProductID})"); $this->Execute("INSERT INTO dcl_org_product_xref (org_id, product_id) SELECT {$org_id}, id FROM products WHERE id IN ({$sProductID}) AND id NOT IN (SELECT product_id FROM dcl_org_product_xref WHERE org_id = {$org_id})"); }
function submitModify() { global $g_oSec; commonHeader(); if (($id = DCL_Sanitize::ToInt($_REQUEST['contact_id'])) === null) { trigger_error('Data sanitize failed.'); return; } if (!$g_oSec->HasPerm(DCL_ENTITY_CONTACT, DCL_PERM_MODIFY, $id)) { return PrintPermissionDenied(); } CleanArray($_REQUEST); $aOrgs = @DCL_Sanitize::ToIntArray($_REQUEST['org_id']); $oDbContact = CreateObject('dcl.dbOrgContact'); $oDbContact->updateOrgs($id, $aOrgs); $oContact = CreateObject('dcl.htmlContactDetail'); $oContact->show(); }
function GetProductArray($aOrgID) { if (($aOrgID = DCL_Sanitize::ToIntArray($aOrgID)) === null) { trigger_error('Data sanitize failed.'); return -1; } $aRetVal = array(); $sOrgID = '-1'; if (count($aOrgID) > 0) { $sOrgID = join(',', $aOrgID); } $sSQL = "SELECT DISTINCT product_id FROM dcl_org_product_xref WHERE org_id IN ({$sOrgID})"; if ($this->Query($sSQL) != -1) { while ($this->next_record()) { $aRetVal[] = $this->f(0); } } return $aRetVal; }
function savePriority() { global $g_oSec; commonHeader(); if (!$g_oSec->HasPerm(DCL_ENTITY_HOTLIST, DCL_PERM_MODIFY)) { return PrintPermissionDenied(); } $hotlistId = @DCL_Sanitize::ToInt($_POST['hotlist_id']); if ($hotlistId === null || $hotlistId < 1) { return PrintPermissionDenied(); } $dbHotlist = CreateObject('dcl.dbHotlist'); if ($dbHotlist->Load($hotlistId) === -1) { return PrintPermissionDenied(); } $aEntities = array(); foreach ($_REQUEST['item'] as $entity) { $aEntity = @DCL_Sanitize::ToIntArray(split('_', $entity)); if (count($aEntity) === 3) { $aEntities[] = $aEntity; } } $db = CreateObject('dcl.dbEntityHotlist'); $db->setPriority($hotlistId, $aEntities); }
function ShowUserVsProductStatus() { global $dcl_info, $g_oSec; commonHeader(); if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_VIEW)) { return PrintPermissionDenied(); } $objProduct = CreateObject('dcl.dbProducts'); $objPersonnel = CreateObject('dcl.dbPersonnel'); $objStatuses = CreateObject('dcl.dbStatuses'); $objWorkorders = CreateObject('dcl.dbWorkorders'); $products = @DCL_Sanitize::ToIntArray($_REQUEST['products']); $people = @DCL_Sanitize::ToIntArray($_REQUEST['people']); $begindate = @DCL_Sanitize::ToDate($_REQUEST['begindate']); $enddate = @DCL_Sanitize::ToDate($_REQUEST['enddate']); if (count($products) < 1) { $query = 'SELECT id FROM products ORDER BY name'; $objProduct->Query($query); $products = array(); while ($objProduct->next_record()) { $products[count($products)] = $objProduct->f(0); } $objProduct->FreeResult(); } $doingClosed = FALSE; if ($begindate !== null) { $doingClosed = TRUE; } if ($enddate !== null) { $doingClosed = TRUE; } $query = 'SELECT id FROM statuses WHERE dcl_status_type '; if ($doingClosed) { $query .= '= 2'; } else { $query .= '!= 2'; } $objStatuses->Query($query); $statii = array(); while ($objStatuses->next_record()) { $statii[count($statii)] = $objStatuses->f(0); } $objStatuses->FreeResult(); if (count($people) < 1) { $idWhere = 'id > 1'; } else { $idWhere = 'id in ('; for ($i = 0; $i < count($people); $i++) { if ($i > 0) { $idWhere .= ','; } $idWhere .= $people[$i]; } $idWhere .= ')'; } $query = 'select distinct p.id, p.short from personnel p join dcl_user_role ur on p.id = ur.personnel_id '; $query .= 'join dcl_role_perm rp on ur.role_id = rp.role_id where ((entity_id = '; $query .= DCL_ENTITY_WORKORDER . ' and perm_id = ' . DCL_PERM_ACTION . ') or (entity_id = '; $query .= DCL_ENTITY_GLOBAL . ' and perm_id = ' . DCL_PERM_ADMIN . ')) ORDER BY short'; $objPersonnel->Query($query); $person = array(); while ($objPersonnel->next_record()) { $person[count($person)] = $objPersonnel->f(0); } $objPersonnel->FreeResult(); $query = 'SELECT product,status,responsible,'; if ($doingClosed) { $query .= 'totalhours'; } else { $query .= 'esthours'; } $query .= ' FROM workorders, statuses WHERE workorders.status = statuses.id AND statuses.dcl_status_type '; if ($doingClosed) { $query .= '= 2'; if ($begindate != '' && $enddate != '') { $query .= ' AND closedon between ' . $objWorkorders->DisplayToSQL($begindate . ' 00:00:00') . ' AND ' . $objWorkorders->DisplayToSQL($enddate . ' 23:59:59'); } else { if ($begindate != '') { $query .= ' AND closedon >=' . $objWorkorders->DisplayToSQL($begindate . ' 00:00:00'); } else { if ($enddate != '') { $query .= ' AND closedon <=' . $objWorkorders->DisplayToSQL($enddate . ' 23:59:59'); } } } } else { $query .= '!= 2'; } $objWorkorders->Query($query); for ($i = 0; $i < count($products) * count($statii) + count($statii) + 1; $i++) { for ($j = 0; $j < count($person) + 2; $j++) { $myArrayHours[$i][$j] = 0.0; $myArrayUnits[$i][$j] = 0; } } while ($objWorkorders->next_record()) { $thisProduct = -1; $thisStatus = -1; $thisPerson = -1; $bFound = false; for ($j = 0; $j < count($products); $j++) { if ($products[$j] == $objWorkorders->f(0)) { $bFound = true; break; } } if ($bFound) { $thisProduct = $j; } $bFound = false; for ($j = 0; $j < count($statii); $j++) { if ($statii[$j] == $objWorkorders->f(1)) { $bFound = true; break; } } if ($bFound) { $thisStatus = $j; } $bFound = false; for ($j = 0; $j < count($person); $j++) { if ($person[$j] == $objWorkorders->f(2)) { $bFound = true; break; } } if ($bFound) { $thisPerson = $j; } if ($thisProduct > -1 && $thisStatus > -1 && $thisPerson > -1) { $hours = $objWorkorders->f(3); $myArrayHours[$thisProduct * count($statii) + $thisStatus][$thisPerson] += $hours; $myArrayHours[count($products) * count($statii) + $thisStatus][$thisPerson] += $hours; $myArrayHours[count($products) * count($statii) + count($statii)][$thisPerson] += $hours; $myArrayHours[$thisProduct * count($statii) + $thisStatus][count($person)] += $hours; $myArrayHours[$thisProduct * count($statii)][count($person) + 1] += $hours; $myArrayHours[count($products) * count($statii) + $thisStatus][count($person)] += $hours; $myArrayHours[count($products) * count($statii) + count($statii)][count($person)] += $hours; $myArrayUnits[$thisProduct * count($statii) + $thisStatus][$thisPerson]++; $myArrayUnits[count($products) * count($statii) + $thisStatus][$thisPerson]++; $myArrayUnits[count($products) * count($statii) + count($statii)][$thisPerson]++; $myArrayUnits[$thisProduct * count($statii) + $thisStatus][count($person)]++; $myArrayUnits[$thisProduct * count($statii)][count($person) + 1]++; $myArrayUnits[count($products) * count($statii) + $thisStatus][count($person)]++; $myArrayUnits[count($products) * count($statii) + count($statii)][count($person)]++; } } $objWorkorders->FreeResult(); print '<table border="0" cellspacing="0" cellpadding="1">'; print '<tr><td>'; print '<table border="0" cellspacing="2" cellpadding="1">'; print '<tr>'; print '<th rowspan="2">'; print STR_CMMN_LOGIN; print '</th>'; for ($i = 0; $i < count($products); $i++) { print '<th colspan=' . count($statii); print '>'; $objProduct->Load($products[$i]); print $objProduct->name; print '</th>'; } print '<th colspan=' . (count($statii) + 1); print '>'; print STR_CMMN_TOTALS; print '</th></tr><tr>'; $statusCol = ''; for ($j = 0; $j < count($statii); $j++) { $statusCol .= '<th>'; $objStatuses->Load($statii[$j]); $statusCol .= $objStatuses->short; $statusCol .= '</th>'; } for ($i = 0; $i < count($products); $i++) { print $statusCol; } // For the totals, dontcha know? print $statusCol; printf('<th>%s</th>', STR_WOST_ALL); print '</tr>'; for ($i = 0; $i < count($person) + 2; $i++) { if ($i < count($person) && $myArrayUnits[count($products) * count($statii) + count($statii)][$i] == 0) { continue; } if ($i < count($person)) { $objPersonnel->Load($person[$i]); print '<tr><td>' . $objPersonnel->short . '</td>'; } else { if ($i == count($person)) { print '<tr><td>' . STR_WO_STATUS . '</td>'; } else { print '<tr><td>' . STR_WO_PRODUCT . '</td>'; } } for ($j = 0; $j < count($products) + 1; $j++) { for ($k = 0; $k < count($statii) + 1; $k++) { if ($i < count($person) + 1 && ($j < count($products) && $k < count($statii) || $j == count($products)) || $i == count($person) + 1 && $k == 0 && $j < count($products)) { $units = $myArrayUnits[$j * count($statii) + $k][$i]; print '<td'; if ($i == count($person) + 1) { print ' align="center" colspan=' . count($statii); } print '>'; if ($units > 0) { $menuAction = 'menuAction=htmlWOStatistics.SearchFromStat'; if ($k < count($statii) && $i < count($person) + 1) { $menuAction .= '&status=' . $statii[$k]; } if ($j < count($products)) { $menuAction .= '&product=' . $products[$j]; } if ($i < count($person)) { $menuAction .= '&responsible=' . $person[$i]; } if ($begindate != '') { $menuAction .= '&begindate=' . $begindate; } if ($enddate != '') { $menuAction .= '&enddate=' . $enddate; } printf('<a class="adark" href="%s">', menuLink('', $menuAction)); print $units . '(' . $myArrayHours[$j * count($statii) + $k][$i] . STR_WOST_HOURSABBREV . ')</a>'; } else { print ' '; } print '</td>'; } } } print '</tr>'; } print '</table></td></tr></table>'; }
function dbsearch() { global $g_oSec, $g_oSession; commonHeader(); $personnel = isset($_REQUEST['personnel']) && is_array($_REQUEST['personnel']) ? $_REQUEST['personnel'] : array(); $status = @$_REQUEST['status']; $is_public = @$_REQUEST['is_public']; $createdon = @$_REQUEST['createdon']; $closedon = @$_REQUEST['closedon']; $statuson = @$_REQUEST['statuson']; $lastactionon = @$_REQUEST['lastactionon']; $deadlineon = @$_REQUEST['deadlineon']; $eststarton = @$_REQUEST['eststarton']; $estendon = @$_REQUEST['estendon']; $starton = @$_REQUEST['starton']; $module_id = isset($_REQUEST['module_id']) && is_array($_REQUEST['module_id']) ? $_REQUEST['module_id'] : array(); $searchText = $_REQUEST['searchText']; $tags = $_REQUEST['tags']; $hotlist = $_REQUEST['hotlist']; $columns = $_REQUEST['columns']; $groups = $_REQUEST['groups']; $order = $_REQUEST['order']; $columnhdrs = $_REQUEST['columnhdrs']; $account = @DCL_Sanitize::ToIntArray($_REQUEST['account']); $entity_source_id = @DCL_Sanitize::ToIntArray($_REQUEST['entity_source_id']); $severity = @DCL_Sanitize::ToIntArray($_REQUEST['severity']); $priority = @DCL_Sanitize::ToIntArray($_REQUEST['priority']); $dcl_status_type = @DCL_Sanitize::ToIntArray($_REQUEST['dcl_status_type']); $product = @DCL_Sanitize::ToIntArray($_REQUEST['product']); $department = @DCL_Sanitize::ToIntArray($_REQUEST['department']); $project = @DCL_Sanitize::ToIntArray($_REQUEST['project']); $wo_type_id = @DCL_Sanitize::ToIntArray($_REQUEST['wo_type_id']); $dateFrom = DCL_Sanitize::ToDate($_REQUEST['dateFrom']); $dateTo = DCL_Sanitize::ToDate($_REQUEST['dateTo']); if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_SEARCH)) { return PrintPermissionDenied(); } $objView = CreateObject('dcl.boView'); $objView->table = 'workorders'; if (strlen($columnhdrs) > 0) { $columnhdrs = explode(',', $columnhdrs); } else { $columnhdrs = array(); } if (strlen($columns) > 0) { $columns = explode(',', $columns); } else { $columns = array(); } if (strlen($groups) > 0) { $groups = explode(',', $groups); } else { $groups = array(); } if (strlen($order) > 0) { $order = explode(',', $order); } else { $order = array(); } if (count($personnel) > 0 || count($department) > 0) { $fieldList = array('responsible', 'createby', 'closedby'); $bStrippedDepartments = false; $pers_sel = array(); foreach ($fieldList as $field) { if (!isset($_REQUEST[$field]) || $_REQUEST[$field] != '1') { continue; } if (count($personnel) > 0) { if (!$bStrippedDepartments) { $bStrippedDepartments = true; // Have actual personnel? If so, only set personnel for their associated departments instead of the department // then unset the department from the array foreach ($personnel as $encoded_pers) { list($dpt_id, $pers_id) = explode(',', $encoded_pers); $pers_sel[count($pers_sel)] = $pers_id; if (count($department) > 0 && in_array($dpt_id, $department)) { foreach ($department as $key => $department_id) { if ($department_id == $dpt_id) { unset($department[$key]); break; } } } } } $pers_sel = DCL_Sanitize::ToIntArray($pers_sel); if (count($pers_sel) > 0) { $objView->AddDef('filter', $field, $pers_sel); } } if (count($department) > 0) { $objView->AddDef('filter', $field . '.department', $department); } } } $fieldList = array('priority', 'severity', 'wo_type_id', 'entity_source_id'); foreach ($fieldList as $field) { if (count(${$field}) > 0) { $objView->AddDef('filter', $field, ${$field}); } } if (trim($tags) != '') { $objView->AddDef('filter', 'dcl_tag.tag_desc', $tags); } if (trim($hotlist) != '') { $objView->AddDef('filter', 'dcl_hotlist.hotlist_tag', $hotlist); } if (count($is_public) > 0) { foreach ($is_public as $publicValue) { if ($publicValue == 'Y' || $publicValue == 'N') { $objView->AddDef('filter', 'is_public', "'" . $publicValue . "'"); } } } if (count($module_id) > 0) { // Have modules? If so, only set module IDs for their associated products instead of the product ID // then unset the product id from the array $module = array(); foreach ($module_id as $encoded_mod) { list($mod_prod_id, $mod_id) = explode(',', $encoded_mod); $module[count($module)] = $mod_id; if (count($product) > 0 && in_array($mod_prod_id, $product)) { foreach ($product as $key => $product_id) { if ($product_id == $mod_prod_id) { unset($product[$key]); break; } } } } $objView->AddDef('filter', 'module_id', $module); } $g_oSession->Unregister('showBM'); if (count($product) > 0) { $objView->AddDef('filter', 'product', $product); // Adds BuildManager to drop down menu only if user selects a product if (count($product) == 1) { $g_oSession->Register('showBM', 1); } } $g_oSession->Edit(); if (($dcl_status_type = DCL_Sanitize::ToIntArray($dcl_status_type)) === null) { $dcl_status_type = array(); } if (count($status) > 0) { // Have statuses? If so, only set status IDs for their associated types instead of the status type ID // then unset the status type id from the array $statuses = array(); foreach ($status as $encoded_status) { list($type_id, $status_id) = explode(',', $encoded_status); if (($type_id = DCL_Sanitize::ToInt($type_id)) !== null && ($status_id = DCL_Sanitize::ToInt($status_id)) !== null) { $statuses[count($statuses)] = $status_id; if (count($dcl_status_type) > 0 && in_array($type_id, $dcl_status_type)) { foreach ($dcl_status_type as $key => $status_type_id) { if ($status_type_id == $type_id) { unset($dcl_status_type[$key]); break; } } } } } $objView->AddDef('filter', 'status', $statuses); } if (count($account) > 0) { $objView->AddDef('filter', 'dcl_wo_account.account_id', $account); } // already sanitized this one above if (count($dcl_status_type) > 0) { $objView->AddDef('filter', 'statuses.dcl_status_type', $dcl_status_type); } if (count($project) > 0) { $objView->AddDef('filter', 'dcl_projects.projectid', $project); } if ($dateFrom != '' || $dateTo != '') { $fieldList = array('createdon', 'closedon', 'statuson', 'lastactionon', 'deadlineon', 'eststarton', 'estendon', 'starton'); foreach ($fieldList as $field) { if (${$field} == '1') { $objView->AddDef('filterdate', $field, array($dateFrom, $dateTo)); } } } if ($searchText != '') { $fieldList = array('summary', 'notes', 'description'); foreach ($fieldList as $field) { if ($_REQUEST[$field] == '1') { $objView->AddDef('filterlike', $field, $searchText); } } } if (count($columns) > 0) { $objView->AddDef('columns', '', $columns); } if (count($groups) > 0) { foreach ($groups as $groupField) { if ($groupField == 'priorities.name') { $groups[$key] = 'priorities.weight'; } else { if ($groupField == 'severities.name') { $groups[$key] = 'severities.weight'; } } } $objView->AddDef('groups', '', $groups); } if (count($columnhdrs) > 0) { $objView->AddDef('columnhdrs', '', $columnhdrs); } if (count($order) > 0) { foreach ($order as $orderField) { if ($orderField == 'priorities.name') { $order[$key] = 'priorities.weight'; } else { if ($orderField == 'severities.name') { $order[$key] = 'severities.weight'; } } } $objView->AddDef('order', '', $order); } else { $objView->AddDef('order', '', array('jcn', 'seq')); } $objView->style = 'report'; if ($_REQUEST['title'] != '') { $objView->title = GPCStripSlashes($_REQUEST['title']); } else { $objView->title = STR_WO_RESULTSTITLE; } $obj =& CreateObject('dcl.htmlWorkOrderResults'); $obj->Render($objView); }
function dbsearch() { commonHeader(); $personnel = isset($_REQUEST['personnel']) && is_array($_REQUEST['personnel']) ? $_REQUEST['personnel'] : array(); $type = @DCL_Sanitize::ToIntArray($_REQUEST['type']); $priority = @DCL_Sanitize::ToIntArray($_REQUEST['priority']); $status = @$_REQUEST['status']; $account = @DCL_Sanitize::ToIntArray($_REQUEST['account']); $is_public = @$_REQUEST['is_public']; $entity_source_id = @DCL_Sanitize::ToIntArray($_REQUEST['entity_source_id']); $createdon = @$_REQUEST['createdon']; $closedon = @$_REQUEST['closedon']; $statuson = @$_REQUEST['statuson']; $lastactionon = @$_REQUEST['lastactionon']; $module_id = isset($_REQUEST['module_id']) && is_array($_REQUEST['module_id']) ? $_REQUEST['module_id'] : array(); $tags = $_REQUEST['tags']; $searchText = $_REQUEST['searchText']; $columns = $_REQUEST['columns']; $groups = $_REQUEST['groups']; $order = $_REQUEST['order']; $columnhdrs = $_REQUEST['columnhdrs']; $dcl_status_type = @DCL_Sanitize::ToIntArray($_REQUEST['dcl_status_type']); $product = @DCL_Sanitize::ToIntArray($_REQUEST['product']); $department = @DCL_Sanitize::ToIntArray($_REQUEST['department']); $dateFrom = DCL_Sanitize::ToDate($_REQUEST['dateFrom']); $dateTo = DCL_Sanitize::ToDate($_REQUEST['dateTo']); $oDB = new dclDB(); if (strlen($columnhdrs) > 0) { $columnhdrs = explode(',', $columnhdrs); } else { $columnhdrs = array(); } if (strlen($columns) > 0) { $columns = explode(',', $columns); } else { $columns = array(); } if (strlen($groups) > 0) { $groups = explode(',', $groups); } else { $groups = array(); } if (strlen($order) > 0) { $order = explode(',', $order); } else { $order = array(); } $objView =& CreateObject('dcl.boView'); $objView->table = 'tickets'; if (count($personnel) > 0 || count($department) > 0) { $fieldList = array('responsible', 'createdby', 'closedby'); $bStrippedDepartments = false; $pers_sel = array(); foreach ($fieldList as $field) { if (!isset($_REQUEST[$field]) || $_REQUEST[$field] != '1') { continue; } if (count($personnel) > 0) { if (!$bStrippedDepartments) { $bStrippedDepartments = true; // Have actual personnel? If so, only set personnel for their associated departments instead of the department // then unset the department from the array foreach ($personnel as $encoded_pers) { list($dpt_id, $pers_id) = explode(',', $encoded_pers); $pers_sel[count($pers_sel)] = $pers_id; if (count($department) > 0 && in_array($dpt_id, $department)) { foreach ($department as $key => $department_id) { if ($department_id == $dpt_id) { unset($department[$key]); break; } } } } } $pers_sel = DCL_Sanitize::ToIntArray($pers_sel); if (count($pers_sel) > 0) { $objView->AddDef('filter', $field, $pers_sel); } } if (count($department) > 0) { $objView->AddDef('filter', $field . '.department', $department); } } } $fieldList = array('priority', 'type', 'account', 'entity_source_id'); while (list($key, $field) = each($fieldList)) { ${$field} = DCL_Sanitize::ToIntArray(${$field}); if (count(${$field}) > 0) { $objView->AddDef('filter', $field, ${$field}); } } if (trim($tags) != '') { $objView->AddDef('filter', 'dcl_tag.tag_desc', $tags); } if (count($is_public) > 0) { foreach ($is_public as $publicValue) { $objView->AddDef('filter', 'is_public', $oDB->Quote(DCL_Sanitize::ToYN($publicValue))); } } if (count($module_id) > 0) { // Have modules? If so, only set module IDs for their associated products instead of the product ID // then unset the product id from the array $module = array(); foreach ($module_id as $encoded_mod) { list($mod_prod_id, $mod_id) = explode(',', $encoded_mod); $module[count($module)] = $mod_id; if (count($product) > 0 && in_array($mod_prod_id, $product)) { foreach ($product as $key => $product_id) { if ($product_id == $mod_prod_id) { unset($product[$key]); break; } } } } $module = DCL_Sanitize::ToIntArray($module); if (count($module) > 0) { $objView->AddDef('filter', 'module_id', $module); } } if (count($product) > 0) { $objView->AddDef('filter', 'product', $product); } if (count($status) > 0) { // Have statuses? If so, only set status IDs for their associated types instead of the status type ID // then unset the status type id from the array $statuses = array(); foreach ($status as $encoded_status) { list($type_id, $status_id) = explode(',', $encoded_status); if (($type_id = DCL_Sanitize::ToInt($type_id)) !== null && ($status_id = DCL_Sanitize::ToInt($status_id)) !== null) { $statuses[count($statuses)] = $status_id; if (count($dcl_status_type) > 0 && in_array($type_id, $dcl_status_type)) { foreach ($dcl_status_type as $key => $status_type_id) { if ($status_type_id == $type_id) { unset($dcl_status_type[$key]); break; } } } } } $objView->AddDef('filter', 'status', $statuses); } if (count($dcl_status_type) > 0) { $objView->AddDef('filter', 'statuses.dcl_status_type', $dcl_status_type); } if ($dateFrom !== null || $dateTo !== null) { if ($dateFrom !== null) { $dateFrom .= ' 00:00:00'; } else { $dateFrom = ''; } if ($dateTo !== null) { $dateTo .= ' 23:59:59'; } else { $dateTo = ''; } $fieldList = array('createdon', 'closedon', 'statuson', 'lastactionon'); foreach ($fieldList as $field) { if (${$field} == '1') { $objView->AddDef('filterdate', $field, array($dateFrom, $dateTo)); } } } if ($searchText != '') { $objView->AddDef('filterlike', 'issue', $searchText); $objView->AddDef('filterlike', 'summary', $searchText); } if (count($columns) > 0) { $objView->AddDef('columns', '', $columns); } else { $objView->AddDef('columns', '', array('ticketid', 'responsible', 'product', 'account', 'status', 'contact', 'contactphone', 'summary')); } if (count($groups) > 0) { foreach ($groups as $key => $groupField) { if ($groupField == 'priorities.name') { $groups[$key] = 'priorities.weight'; } else { if ($groupField == 'severities.name') { $groups[$key] = 'severities.weight'; } } } $objView->AddDef('groups', '', $groups); } if (count($columnhdrs) > 0) { $objView->AddDef('columnhdrs', '', $columnhdrs); } if (count($order) > 0) { foreach ($order as $key => $orderField) { if ($orderField == 'priorities.name') { $order[$key] = 'priorities.weight'; } else { if ($orderField == 'severities.name') { $order[$key] = 'severities.weight'; } } } $objView->AddDef('order', '', $order); } else { $objView->AddDef('order', '', array('ticketid')); } $objView->style = 'report'; if (isset($_REQUEST['title']) && $_REQUEST['title'] != '') { $objView->title = $oDB->GPCStripSlashes($_REQUEST['title']); } else { $objView->title = STR_TCK_TICKETSEARCHRESULTS; } $obj =& CreateObject('dcl.htmlTicketResults'); $obj->Render($objView); }
function doMerge() { global $g_oSec; commonHeader(); if (($iContactID = DCL_Sanitize::ToInt($_REQUEST['contact_id'])) === null || ($aMergeContacts = DCL_Sanitize::ToIntArray($_REQUEST['merge_contact_id'])) === null) { trigger_error('Data sanitize failed.'); return; } if (!$g_oSec->HasPerm(DCL_ENTITY_CONTACT, DCL_PERM_MODIFY)) { return PrintPermissionDenied(); } foreach ($aMergeContacts as $key => $value) { $aMergeContacts[$key] = (int) $value; if ($aMergeContacts[$key] == $iContactID) { unset($aMergeContacts[$key]); } } if (count($aMergeContacts) > 0) { $sMergeContacts = join($aMergeContacts, ','); // Merge orgs $sSQL = 'SELECT org_id FROM dcl_org_contact WHERE contact_id IN (' . $sMergeContacts . ')'; $oDB =& CreateObject('dcl.dbOrgContact'); $oDB2 =& CreateObject('dcl.dbOrgContact'); $oDB->BeginTransaction(); if ($oDB->Query($sSQL) == -1) { $oDB->RollbackTransaction(); return; } while ($oDB->next_record()) { $sSQL = 'SELECT 1 FROM dcl_org_contact WHERE contact_id = ' . $iContactID . ' AND org_id = ' . $oDB->f(0); if ($oDB2->Query($sSQL) == -1) { $oDB->RollbackTransaction(); return; } if (!$oDB2->next_record()) { $oDB2->contact_id = $iContactID; $oDB2->org_id = $oDB->f(0); $oDB2->created_on = DCL_NOW; $oDB2->created_by = $GLOBALS['DCLID']; $oDB2->Add(); } } if ($oDB2->Execute('DELETE FROM dcl_org_contact WHERE contact_id IN (' . $sMergeContacts . ')') == -1) { $oDB->RollbackTransaction(); return; } // Merge phone numbers if ($oDB2->Execute("UPDATE dcl_contact_phone SET contact_id = {$iContactID}, preferred = 'N' WHERE contact_id IN ({$sMergeContacts})") == -1) { $oDB->RollbackTransaction(); return; } // Merge email addresses if ($oDB2->Execute("UPDATE dcl_contact_email SET contact_id = {$iContactID}, preferred = 'N' WHERE contact_id IN ({$sMergeContacts})") == -1) { $oDB->RollbackTransaction(); return; } // Merge addresses if ($oDB2->Execute("UPDATE dcl_contact_addr SET contact_id = {$iContactID}, preferred = 'N' WHERE contact_id IN ({$sMergeContacts})") == -1) { $oDB->RollbackTransaction(); return; } // Merge URLs if ($oDB2->Execute("UPDATE dcl_contact_url SET contact_id = {$iContactID}, preferred = 'N' WHERE contact_id IN ({$sMergeContacts})") == -1) { $oDB->RollbackTransaction(); return; } // Merge notes //$oDB2->Execute('UPDATE dcl_contact_notes SET contact_id = ' . $iContactID . ' WHERE contact_id IN (' . $sMergeContacts . ')'); // Merge work orders if ($oDB2->Execute('UPDATE workorders SET contact_id = ' . $iContactID . ' WHERE contact_id IN (' . $sMergeContacts . ')') == -1) { $oDB->RollbackTransaction(); return; } // Merge tickets if ($oDB2->Execute('UPDATE tickets SET contact_id = ' . $iContactID . ' WHERE contact_id IN (' . $sMergeContacts . ')') == -1) { $oDB->RollbackTransaction(); return; } // Merge users if ($oDB2->Execute('UPDATE personnel SET contact_id = ' . $iContactID . ' WHERE contact_id IN (' . $sMergeContacts . ')') == -1) { $oDB->RollbackTransaction(); return; } if ($oDB2->Execute('DELETE FROM dcl_contact WHERE contact_id IN (' . $sMergeContacts . ')') == -1) { $oDB->RollbackTransaction(); return; } $oDB->EndTransaction(); } if (isset($_REQUEST['chainMenuAction']) && $_REQUEST['chainMenuAction'] == 'htmlContactBrowse.Page') { $oCD =& CreateObject('dcl.htmlContactBrowse'); $oCD->Page(); } else { $oDetail =& CreateObject('dcl.htmlContactDetail'); $oDetail->show(); } }
function Render(&$oView) { global $dcl_info, $g_oSec, $g_oSession; if (!is_object($oView)) { trigger_error('[htmlWorkOrderResults::Render] ' . STR_VW_VIEWOBJECTNOTPASSED); return; } if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_SEARCH)) { return PrintPermissionDenied(); } $oTable = CreateObject('dcl.htmlTable'); $bIsExplicitView = is_a($oView, 'boExplicitView'); if (!$bIsExplicitView) { $oTable->assign('VAL_VIEWSETTINGS', $oView->GetForm()); } $aProducts = isset($_REQUEST['product']) ? DCL_Sanitize::ToIntArray($_REQUEST['product']) : array(); if ($aProducts !== null && count($aProducts) > 0) { $oTable->assign('HID_PRODUCT', join(',', $aProducts)); } else { $oTable->assign('HID_PRODUCT', ''); } for ($iColumn = 0; $iColumn < count($oView->groups); $iColumn++) { $oTable->addGroup($iColumn); $oTable->addColumn('', 'string'); } $iColumn = 0; foreach ($oView->columnhdrs as $sColumn) { if ($iColumn++ < count($oView->groups)) { continue; } $oTable->addColumn($sColumn, 'string'); } $aOptions = array(STR_CMMN_SAVE => array('menuAction' => 'boViews.add', 'hasPermission' => !$bIsExplicitView && $g_oSec->HasPerm(DCL_ENTITY_SAVEDSEARCH, DCL_PERM_ADD)), 'Refine' => array('menuAction' => 'htmlWOSearches.ShowRequest', 'hasPermission' => !$bIsExplicitView && $g_oSec->HasPerm(DCL_ENTITY_SAVEDSEARCH, DCL_PERM_VIEW)), 'Export' => array('menuAction' => 'boViews.export', 'hasPermission' => true), 'Detail' => array('menuAction' => 'boWorkorders.batchdetail', 'hasPermission' => $g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ADD)), 'Time Card' => array('menuAction' => 'boTimecards.batchadd', 'hasPermission' => $g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ACTION)), 'Assign' => array('menuAction' => 'boWorkorders.batchassign', 'hasPermission' => $g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ASSIGN)), 'Project' => array('menuAction' => 'htmlProjectmap.batchmove', 'hasPermission' => $g_oSec->HasAllPerm(array(DCL_ENTITY_PROJECT => array($g_oSec->PermArray(DCL_PERM_ADDTASK), $g_oSec->PermArray(DCL_PERM_REMOVETASK)))))); $showBM = $g_oSession->Value('showBM'); if (isset($showBM) && (int) $showBM == 1) { $aOptions_BM = array('Version' => array('menuAction' => 'boBuildManager.SubmitWO', 'hasPermission' => $g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ACTION))); $aOptions = array_merge($aOptions, $aOptions_BM); $g_oSession->Unregister('showBM'); $g_oSession->Edit(); } foreach ($aOptions as $sDisplay => $aOption) { if ($aOption['hasPermission']) { $oTable->addToolbar($aOption['menuAction'], $sDisplay); } } $oDB = new dclDB(); $sSQL = $oView->GetSQL(); if ($oDB->Query($sSQL) == -1) { return; } $iOffset = 0; for ($iColumn = count($oView->groups); $iColumn < $oDB->NumFields(); $iColumn++) { $sFieldName = $oDB->GetFieldName($iColumn); if ($sFieldName == 'jcn') { $oTable->assign('wo_id_ordinal', $iColumn); } else { if ($sFieldName == 'seq') { $oTable->assign('seq_ordinal', $iColumn); } else { if ($sFieldName == '_num_accounts_') { $iOffset--; $oTable->assign('num_accounts_ordinal', $iColumn); } else { if ($sFieldName == '_num_tags_') { $iOffset--; $oTable->assign('num_tags_ordinal', $iColumn); } else { if ($sFieldName == 'tag_desc') { $oTable->assign('tag_ordinal', $iColumn); } else { if ($sFieldName == '_num_hotlist_') { $iOffset--; $oTable->assign('num_hotlist_ordinal', $iColumn); } else { if ($sFieldName == 'hotlist_tag') { $oTable->assign('hotlist_ordinal', $iColumn); } else { if ($oView->columns[$iColumn - count($oView->groups)] == 'dcl_org.name') { $oTable->assign('org_ordinal', $iColumn); } } } } } } } } } $oTable->setData($oDB->FetchAllRows()); $oTable->assign('VAL_ENDOFFSET', $iOffset); if (!$bIsExplicitView) { $oTable->assign('VAL_VIEWSETTINGS', $oView->GetForm()); } $oTable->setCaption($oView->title); $oTable->setShowChecks(true); $oDB->FreeResult(); $oTable->sTemplate = 'htmlTableWorkOrderResults.tpl'; $oTable->render(); }
function dbmodify() { global $g_oSec; commonHeader(); if (!$g_oSec->HasPerm(DCL_ENTITY_PERSONNEL, DCL_PERM_MODIFY)) { return PrintPermissionDenied(); } $obj =& CreateObject('dcl.dbPersonnel'); $obj->InitFromGlobals(); if (isset($_REQUEST['active'])) { $obj->active = 'Y'; } else { $obj->active = 'N'; } $obj->Edit(); $oUserRole =& CreateObject('dcl.dbUserRole'); $oUserRole->DeleteGlobalRolesNotIn($obj->id); $aRoles = @DCL_Sanitize::ToIntArray($_REQUEST['roles']); if (count($aRoles) > 0) { // Set up global user roles $oUserRole->personnel_id = $obj->id; $oUserRole->entity_type_id = DCL_ENTITY_GLOBAL; $oUserRole->entity_id1 = 0; $oUserRole->entity_id2 = 0; foreach ($aRoles as $oUserRole->role_id) { $oUserRole->add(); } } $oBrowse =& CreateObject('dcl.htmlPersonnelBrowse'); $oBrowse->show(); }
function Render(&$oView) { global $dcl_info, $g_oSec; if (!is_object($oView)) { trigger_error('[htmlTicketResults::Render] ' . STR_VW_VIEWOBJECTNOTPASSED); return; } if (!$g_oSec->HasPerm(DCL_ENTITY_TICKET, DCL_PERM_SEARCH)) { return PrintPermissionDenied(); } $oTable = CreateObject('dcl.htmlTable'); $oTable->assign('VAL_VIEWSETTINGS', $oView->GetForm()); $aProducts = isset($_REQUEST['product']) ? DCL_Sanitize::ToIntArray($_REQUEST['product']) : array(); if ($aProducts !== null && count($aProducts) > 0) { $oTable->assign('HID_PRODUCT', join(',', $aProducts)); } else { $oTable->assign('HID_PRODUCT', ''); } for ($iColumn = 0; $iColumn < count($oView->groups); $iColumn++) { $oTable->addGroup($iColumn); $oTable->addColumn('', 'string'); } $iColumn = 0; foreach ($oView->columnhdrs as $sColumn) { if ($iColumn++ < count($oView->groups)) { continue; } $oTable->addColumn($sColumn, 'string'); } $aOptions = array(STR_CMMN_SAVE => array('menuAction' => 'boViews.add', 'hasPermission' => $g_oSec->HasPerm(DCL_ENTITY_SAVEDSEARCH, DCL_PERM_ADD)), 'Refine' => array('menuAction' => 'htmlTicketSearches.ShowRequest', 'hasPermission' => $g_oSec->HasPerm(DCL_ENTITY_SAVEDSEARCH, DCL_PERM_VIEW)), 'Export' => array('menuAction' => 'boViews.export', 'hasPermission' => true)); foreach ($aOptions as $sDisplay => $aOption) { if ($aOption['hasPermission']) { $oTable->addToolbar($aOption['menuAction'], $sDisplay); } } $oDB = new dclDB(); $sSQL = $oView->GetSQL(); if ($oDB->Query($sSQL) == -1) { return; } for ($iColumn = count($oView->groups); $iColumn < count($oView->columns) + count($oView->groups); $iColumn++) { if ($oDB->GetFieldName($iColumn) == 'ticketid') { $oTable->assign('ticket_id_ordinal', $iColumn); break; } } $iOffset = 0; for ($iColumn = count($oView->groups); $iColumn < $oDB->NumFields(); $iColumn++) { $sFieldName = $oDB->GetFieldName($iColumn); if ($sFieldName == '_num_tags_') { $iOffset--; $oTable->assign('num_tags_ordinal', $iColumn); } else { if ($sFieldName == 'tag_desc') { $oTable->assign('tag_ordinal', $iColumn); } } } $oTable->assign('VAL_ENDOFFSET', $iOffset); $oTable->setData($oDB->FetchAllRows()); $oDB->FreeResult(); $oTable->assign('VAL_VIEWSETTINGS', $oView->GetForm()); $oTable->setCaption($oView->title); $oTable->setShowChecks(false); $oTable->sTemplate = 'htmlTableTicketResults.tpl'; $oTable->render(); }
function listById($sID, $includeClosed = true) { global $g_oSec, $g_oSession; if ($g_oSec->IsPublicUser() || $sID == '-1') { PrintPermissionDenied(); return -1; } $aHotlists = @DCL_Sanitize::ToIntArray($sID); $iHotlistCount = count($aHotlists); if ($iHotlistCount === 0) { return PrintPermissionDenied(); } $sID = join(',', $aHotlists); $bMultiHotlist = $iHotlistCount > 1; $sSQL = ''; $bDoneDidWhere = false; if ($g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_SEARCH)) { $sSQL = 'SELECT ' . DCL_ENTITY_WORKORDER . ' as entity_id, workorders.jcn, workorders.seq, workorders.summary, statuses.name, R.short AS responsible, personnel.short, timecards.summary, dcl_entity_hotlist.sort FROM '; if ($bMultiHotlist) { $sSQL .= '(SELECT entity_key_id, entity_key_id2 FROM dcl_entity_hotlist WHERE entity_id = ' . DCL_ENTITY_WORKORDER . " AND hotlist_id IN ({$sID}) GROUP BY entity_key_id, entity_key_id2 HAVING COUNT(*) = {$iHotlistCount}) hotlist_matches "; $sSQL .= $this->JoinKeyword . ' workorders ON hotlist_matches.entity_key_id = workorders.jcn AND hotlist_matches.entity_key_id2 = workorders.seq '; $sSQL .= $this->JoinKeyword . ' statuses ON workorders.status = statuses.id '; $sSQL .= $this->JoinKeyword . ' personnel R ON workorders.responsible = R.id '; $sSQL .= 'LEFT JOIN timecards ON workorders.jcn = timecards.jcn AND workorders.seq = timecards.seq AND timecards.id = (select max(id) from timecards where jcn = workorders.jcn AND seq = workorders.seq) '; $sSQL .= 'LEFT JOIN personnel ON timecards.actionby = personnel.id '; if (!$includeClosed) { $sSQL .= "WHERE statuses.dcl_status_type != 2"; $bDoneDidWhere = true; } if ($g_oSec->IsPublicUser()) { if ($bDoneDidWhere) { $sSQL .= ' AND '; } else { $sSQL .= ' WHERE '; $bDoneDidWhere = true; } $sSQL .= "workorders.is_public = 'Y'"; } } else { $sSQL .= 'dcl_entity_hotlist JOIN workorders ON dcl_entity_hotlist.entity_id = ' . DCL_ENTITY_WORKORDER . ' AND dcl_entity_hotlist.entity_key_id = workorders.jcn AND dcl_entity_hotlist.entity_key_id2 = workorders.seq '; $sSQL .= $this->JoinKeyword . ' statuses ON workorders.status = statuses.id '; $sSQL .= $this->JoinKeyword . ' personnel R ON workorders.responsible = R.id '; $sSQL .= 'LEFT JOIN timecards ON workorders.jcn = timecards.jcn AND workorders.seq = timecards.seq AND timecards.id = (select max(id) from timecards where jcn = workorders.jcn AND seq = workorders.seq) '; $sSQL .= 'LEFT JOIN personnel ON timecards.actionby = personnel.id '; $sSQL .= "WHERE dcl_entity_hotlist.hotlist_id = {$sID}"; $bDoneDidWhere = true; if (!$includeClosed) { $sSQL .= " AND statuses.dcl_status_type != 2"; $bDoneDidWhere = true; } if ($g_oSec->IsPublicUser()) { $sSQL .= " AND workorders.is_public = 'Y'"; } } $sAccountSQL = ''; if ($g_oSec->IsOrgUser()) { $sOrgs = $g_oSession->Value('member_of_orgs'); if ($sOrgs == '') { $sOrgs = '-1'; } $sAccountSQL = "((workorders.jcn in (select wo_id from dcl_wo_account where account_id in ({$sOrgs})))"; $sAccountSQL .= " AND (workorders.seq in (select seq from dcl_wo_account where workorders.jcn = wo_id And account_id in ({$sOrgs}))"; $sAccountSQL .= '))'; } if ($g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_VIEWSUBMITTED)) { if ($bDoneDidWhere == false) { $bDoneDidWhere = true; $sSQL .= ' WHERE '; } else { $sSQL .= ' AND '; } $sSQL .= '(workorders.createby = ' . $GLOBALS['DCLID']; $sSQL .= ' OR workorders.contact_id = ' . $g_oSession->Value('contact_id'); if ($sAccountSQL != '') { $sSQL .= ' OR ' . $sAccountSQL; } $sSQL .= ')'; } else { if ($sAccountSQL != '') { if ($bDoneDidWhere == false) { $bDoneDidWhere = true; $sSQL .= ' WHERE '; } else { $sSQL .= ' AND '; } $sSQL .= $sAccountSQL; } } } if ($g_oSec->HasPerm(DCL_ENTITY_TICKET, DCL_PERM_SEARCH)) { if ($sSQL != '') { $sSQL .= ' UNION ALL '; } $sSQL .= 'SELECT ' . DCL_ENTITY_TICKET . ' as entity_id, tickets.ticketid, 0, tickets.summary, R.short AS responsible, NULL, NULL, NULL, dcl_entity_hotlist.sort FROM '; if ($bMultiHotlist) { $sSQL .= '(SELECT entity_key_id, entity_key_id2 FROM dcl_entity_hotlist WHERE entity_id = ' . DCL_ENTITY_TICKET . " AND hotlist_id IN ({$sID}) GROUP BY entity_key_id, entity_key_id2 HAVING COUNT(*) = {$iHotlistCount}) hotlist_matches "; $sSQL .= $this->JoinKeyword . ' tickets ON hotlist_matches.entity_key_id = tickets.ticketid '; $sSQL .= $this->JoinKeyword . ' statuses ON tickets.status = statuses.id '; $sSQL .= $this->JoinKeyword . ' personnel R ON tickets.responsible = R.id '; if (!$includeClosed) { $sSQL .= "WHERE statuses.dcl_status_type != 2"; $bDoneDidWhere = true; } if ($g_oSec->IsPublicUser()) { if ($bDoneDidWhere) { $sSQL .= ' AND '; } else { $sSQL .= ' WHERE '; $bDoneDidWhere = true; } $sSQL .= "workorders.is_public = 'Y'"; } } else { $sSQL .= 'dcl_entity_hotlist JOIN tickets ON dcl_entity_hotlist.entity_id = ' . DCL_ENTITY_TICKET . ' AND dcl_entity_hotlist.entity_key_id = tickets.ticketid '; $sSQL .= $this->JoinKeyword . ' statuses ON tickets.status = statuses.id '; $sSQL .= $this->JoinKeyword . ' personnel R ON tickets.responsible = R.id '; $sSQL .= "WHERE dcl_entity_hotlist.hotlist_id = {$sID}"; $bDoneDidWhere = true; if (!$includeClosed) { $sSQL .= " AND statuses.dcl_status_type != 2"; $bDoneDidWhere = true; } if ($g_oSec->IsPublicUser()) { $sSQL .= " AND tickets.is_public = 'Y'"; } } $sAccountSQL = ''; if ($g_oSec->IsOrgUser()) { $sOrgs = $g_oSession->Value('member_of_orgs'); if ($sOrgs == '') { $sOrgs = '-1'; } $sAccountSQL = "account IN ({$sOrgs})"; } if ($g_oSec->HasPerm(DCL_ENTITY_TICKET, DCL_PERM_VIEWSUBMITTED)) { if ($bDoneDidWhere == false) { $bDoneDidWhere = true; $sSQL .= ' WHERE '; } else { $sSQL .= ' AND '; } $sSQL .= '(tickets.createdby = ' . $GLOBALS['DCLID']; $sSQL .= ' OR tickets.contact_id = ' . $g_oSession->Value('contact_id'); if ($sAccountSQL != '') { $sSQL .= ' OR ' . $sAccountSQL; } $sSQL .= ')'; } else { if ($sAccountSQL != '') { if ($bDoneDidWhere == false) { $bDoneDidWhere = true; $sSQL .= ' WHERE '; } else { $sSQL .= ' AND '; } $sSQL .= $sAccountSQL; } } } if ($sSQL == '') { PrintPermissionDenied(); return -1; } return $this->Query($sSQL . ' ORDER BY 9, 1, 2, 3'); }
function executeWorked() { commonHeader(); $sSQL = 'SELECT s.id, s.name, count(*) FROM workorders w, statuses s'; if (count($this->aProjects) > 0) { $sSQL .= ', projectmap pm'; } $sSQL .= ' WHERE w.status = s.id '; if (isset($_REQUEST['products'])) { $aProducts = DCL_Sanitize::ToIntArray($_REQUEST['products']); if (count($aProducts) > 0) { $sSQL .= ' AND w.product IN (' . join(',', $aProducts) . ')'; } } if (count($this->aProjects) > 0) { $sSQL .= ' AND w.jcn = pm.jcn AND pm.seq IN (0, w.seq) AND pm.projectid in (' . implode(',', $this->aProjects) . ')'; } $oDB = CreateObject('dcl.dbWorkorders'); $beginDate = DCL_Sanitize::ToDate($_REQUEST['begindate']); $endDate = DCL_Sanitize::ToDate($_REQUEST['enddate']); if ($beginDate !== null && $endDate !== null) { $sSQL .= ' AND w.lastactionon BETWEEN ' . $oDB->DisplayToSQL($beginDate . ' 00:00:00') . ' AND ' . $oDB->DisplayToSQL($endDate . ' 23:59:59'); } else { if ($beginDate !== null) { $sSQL .= ' AND w.lastactionon >= ' . $oDB->DisplayToSQL($beginDate . ' 00:00:00'); } else { if ($endDate !== null) { $sSQL .= ' AND w.lastactionon <= ' . $oDB->DisplayToSQL($endDate . ' 23:59:59'); } else { $sSQL .= ' AND w.lastactionon IS NOT NULL'; } } } $sSQL .= ' GROUP BY s.id, s.name ORDER BY 2 DESC'; $this->executeItem($sSQL, 'Work Orders Touched', STR_WO_STATUS); }
function dbadd() { global $dcl_info, $g_oSec; commonHeader(); if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ACTION)) { return PrintPermissionDenied(); } $objTimecard =& CreateObject('dcl.dbTimeCards'); $objWorkorder =& CreateObject('dcl.dbWorkorders'); $oStatus =& CreateObject('dcl.dbStatuses'); $objTimecard->InitFromGlobals(); $objTimecard->actionby = $GLOBALS['DCLID']; if ($g_oSec->IsPublicUser()) { $objTimecard->is_public = 'Y'; } else { $objTimecard->is_public = @DCL_Sanitize::ToYN($_REQUEST['is_public']); } $objTimecard->inputon = DCL_NOW; if ($objWorkorder->Load($objTimecard->jcn, $objTimecard->seq) == -1) { return; } if (($targeted_version_id = @DCL_Sanitize::ToInt($_REQUEST['targeted_version_id'])) === null) { $targeted_version_id = 0; } if (($fixed_version_id = @DCL_Sanitize::ToInt($_REQUEST['fixed_version_id'])) === null) { $fixed_version_id = 0; } $status = $objWorkorder->status; $objTimecard->Add($targeted_version_id, $fixed_version_id); $notify = '4'; if ($status != $objTimecard->status) { $notify .= ',3'; if ($oStatus->GetStatusType($objTimecard->status) == 2) { $notify .= ',2'; // also need to close all incomplete tasks and warn user if it happens $this->closeIncompleteTasks($objTimecard->jcn, $objTimecard->seq); } elseif ($oStatus->GetStatusType($objTimecard->status) == 1 && $oStatus->GetStatusType($status) != 1) { $notify .= ',1'; } } // See if we modified some work order items // * Tags if (isset($_REQUEST['tags']) && $g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_MODIFY)) { $oTag =& CreateObject('dcl.dbEntityTag'); $oTag->serialize(DCL_ENTITY_WORKORDER, $objWorkorder->jcn, $objWorkorder->seq, $_REQUEST['tags']); } // * Hotlists if (isset($_REQUEST['hotlist']) && $g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_MODIFY)) { $oTag =& CreateObject('dcl.dbEntityHotlist'); $oTag->serialize(DCL_ENTITY_WORKORDER, $objWorkorder->jcn, $objWorkorder->seq, $_REQUEST['hotlist']); } // * Organizations - only if multiple are allowed to improve workflow if ($g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_MODIFY) && $dcl_info['DCL_WO_SECONDARY_ACCOUNTS_ENABLED'] == 'Y') { $oWOA =& CreateObject('dcl.dbWorkOrderAccount'); if (isset($_REQUEST['secaccounts'])) { $aAccounts = @DCL_Sanitize::ToIntArray($_REQUEST['secaccounts']); if ($aAccounts === null) { $aAccounts = array(); } $oWOA->DeleteByWorkOrder($objWorkorder->jcn, $objWorkorder->seq, join(',', $aAccounts)); // Add the new ones if (count($aAccounts) > 0) { $oWOA->wo_id = $objWorkorder->jcn; $oWOA->seq = $objWorkorder->seq; for ($i = 0; $i < count($aAccounts); $i++) { if ($aAccounts[$i] > 0) { $oWOA->account_id = $aAccounts[$i]; $oWOA->Add(); } } } } else { $oWOA->DeleteByWorkOrder($objWorkorder->jcn, $objWorkorder->seq); } } // * Project if ($g_oSec->HasPerm(DCL_ENTITY_PROJECT, DCL_PERM_ADDTASK)) { if (($iProjID = @DCL_Sanitize::ToInt($_REQUEST['projectid'])) !== null && $iProjID > 0) { $oProjectMap =& CreateObject('dcl.dbProjectmap'); if ($oProjectMap->LoadByWO($objWorkorder->jcn, $objWorkorder->seq) == -1 || $oProjectMap->projectid != $iProjID) { $oProject = CreateObject('dcl.boProjects'); $aSource = array(); $aSource['selected'] = array($objWorkorder->jcn . '.' . $objWorkorder->seq); $aSource['projectid'] = $iProjID; $oProject->batchMove($aSource); } } } // * File attachment if (($sFileName = DCL_Sanitize::ToFileName('userfile')) !== null && $g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ATTACHFILE)) { $o =& CreateObject('dcl.boFile'); $o->iType = DCL_ENTITY_WORKORDER; $o->iKey1 = $objWorkorder->jcn; $o->iKey2 = $objWorkorder->seq; $o->sFileName = DCL_Sanitize::ToActualFileName('userfile'); $o->sTempFileName = $sFileName; $o->sRoot = $dcl_info['DCL_FILE_PATH'] . '/attachments'; $o->Upload(); } $objWtch =& CreateObject('dcl.boWatches'); // Reload before sending since time card modifies the work order $objWorkorder->Load($objTimecard->jcn, $objTimecard->seq); $objWtch->sendNotification($objWorkorder, $notify); // if BuildManager is used, find info on who submitted the WO if ($dcl_info['DCL_BUILD_MANAGER_ENABLED'] == 'Y') { // $oBM = CreateObject('dcl.dbBuildManager'); // $oBM->CheckDepartmentSubmit($objTimecard->jcn, $objTimecard->seq, $objWorkorder->product); } $objWO =& CreateObject('dcl.htmlWorkOrderDetail'); $objWO->Show($objTimecard->jcn, $objTimecard->seq); }
function submitModify() { global $g_oSec; commonHeader(); if (!$g_oSec->HasPerm(DCL_ENTITY_ORG, DCL_PERM_MODIFY)) { return PrintPermissionDenied(); } $obj = CreateObject('dcl.boOrg'); CleanArray($_REQUEST); $aValues = array('org_id' => DCL_Sanitize::ToInt($_REQUEST['org_id']), 'name' => $_REQUEST['name'], 'org_type_id' => @DCL_Sanitize::ToIntArray($_REQUEST['org_type_id']), 'active' => 'Y'); if (!isset($_REQUEST['active']) || $_REQUEST['active'] != 'Y') { $aValues['active'] = 'N'; } $obj->modify($aValues); $oOrg =& CreateObject('dcl.htmlOrgDetail'); $oOrg->show(); }
function submitModify() { global $g_oSec; commonHeader(); if (($id = DCL_Sanitize::ToInt($_REQUEST['contact_id'])) === null) { trigger_error('Data sanitize failed.'); return; } if (!$g_oSec->HasPerm(DCL_ENTITY_CONTACT, DCL_PERM_MODIFY, $id)) { return PrintPermissionDenied(); } $obj = CreateObject('dcl.boContact'); CleanArray($_REQUEST); $aValues = array('contact_id' => DCL_Sanitize::ToInt($_REQUEST['contact_id']), 'first_name' => $_REQUEST['first_name'], 'middle_name' => $_REQUEST['middle_name'], 'last_name' => $_REQUEST['last_name'], 'contact_type_id' => DCL_Sanitize::ToIntArray($_REQUEST['contact_type_id']), 'active' => 'Y'); if (!isset($_REQUEST['active']) || $_REQUEST['active'] != 'Y') { $aValues['active'] = 'N'; } $obj->modify($aValues); $oContact = CreateObject('dcl.htmlContactDetail'); $oContact->show(); }
function htmlSelector() { $this->vDefault = DCL_Sanitize::ToIntArray($_REQUEST['initSelected']); $this->oDB = null; }
function submitReorder() { global $g_oSec; // this is done as a XMLHTTP request if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ACTION)) { return PrintPermissionDenied(); } if (($wo_id = DCL_Sanitize::ToInt($_REQUEST['wo_id'])) === null) { trigger_error('Data sanitize failed.'); return; } if (($seq = DCL_Sanitize::ToInt($_REQUEST['seq'])) === null) { trigger_error('Data sanitize failed.'); return; } $aTaskList = @DCL_Sanitize::ToIntArray($_REQUEST['task']); $oDB =& CreateObject('dcl.dbWorkOrderTask'); $iOrder = 1; for ($i = 0; $i < count($aTaskList); $i++) { $iID = $aTaskList[$i]; $oDB->Execute("UPDATE dcl_wo_task SET task_order = {$iOrder} WHERE wo_task_id = {$iID} AND wo_id = {$wo_id} AND seq = {$seq}"); $iOrder++; } exit; }