function show() { global $dcl_info, $g_oSec; if (!$g_oSec->HasPerm(DCL_ENTITY_ADMIN, DCL_PERM_MODIFY)) { return PrintPermissionDenied(); } $objPersonnel = CreateObject('dcl.htmlPersonnel'); $oDBPersonnel = CreateObject('dcl.dbPersonnel'); if ($oDBPersonnel->Load($GLOBALS['DCLID']) == -1) { return; } $t =& CreateSmarty(); $oSelect = CreateObject('dcl.htmlSelect'); $t->assign('CMB_USERS', $objPersonnel->GetCombo(0, 'responsible', 'lastfirst', 0, false)); $begindate = @DCL_Sanitize::ToDate($_REQUEST['begindate']); if ($begindate !== null) { $t->assign('VAL_BEGINDATE', $begindate); } else { $t->assign('VAL_BEGINDATE', ''); } $enddate = @DCL_Sanitize::ToDate($_REQUEST['enddate']); if ($enddate !== null) { $t->assign('VAL_ENDDATE', $enddate); } else { $t->assign('VAL_ENDDATE', ''); } SmartyDisplay($t, 'htmlSecAuditBrowse.tpl'); }
function submitModify() { global $g_oSec; commonHeader(); if (($id = DCL_Sanitize::ToInt($_REQUEST['contact_license_id'])) === null || ($contact_id = DCL_Sanitize::ToInt($_REQUEST['contact_id'])) === null || ($product_id = DCL_Sanitize::ToInt($_REQUEST['product_id'])) === null || ($registered_on = DCL_Sanitize::ToDate($_REQUEST['registered_on'])) === null || ($expires_on = DCL_Sanitize::ToDate($_REQUEST['expires_on'])) === null) { trigger_error('Data sanitize failed.'); return; } if (!$g_oSec->HasPerm(DCL_ENTITY_CONTACT, DCL_PERM_MODIFY)) { return PrintPermissionDenied(); } CleanArray($_REQUEST); $obj =& CreateObject('dcl.boContactLicense'); $obj->modify(array('contact_license_id' => $id, 'contact_id' => $contact_id, 'product_id' => $product_id, 'product_version' => $_REQUEST['product_version'], 'license_id' => $_REQUEST['license_id'], 'registered_on' => $registered_on, 'expires_on' => $expires_on, 'license_notes' => $_REQUEST['license_notes'], 'modified_on' => DCL_NOW, 'modified_by' => $GLOBALS['DCLID'])); $this->ShowContactDetail(); }
function _GetSQL() { $aItems = $this->_aTypeInfo[$this->group][$this->sub]; $orderby = isset($_REQUEST['order']) && $_REQUEST['order'] == 'count' ? 'count(*)' : $aItems[3]; $sql = sprintf('select count(*), %s, %s, t.dcl_status_type_id, t.dcl_status_type_name from ', $aItems[2], $aItems[3]); $sql .= sprintf('%s a, %s w, dcl_status_type t, statuses s', $aItems[0], $this->group); if ($this->group == 'workorders' && $this->sub == 'account') { $sql .= ', dcl_org ac'; } $sql .= sprintf(' where %s = %s ', $aItems[4], $aItems[2]); if ($this->group == 'workorders' && $this->sub == 'account') { $sql .= ' AND w.jcn = a.wo_id AND w.seq = a.seq '; } $sql .= 'and w.status = s.id and s.dcl_status_type = t.dcl_status_type_id and '; if (isset($_REQUEST['chkLimitByDate']) && $_REQUEST['chkLimitByDate'] == 1) { $dateFrom = DCL_Sanitize::ToDate($_REQUEST['dateFrom']); $dateTo = DCL_Sanitize::ToDate($_REQUEST['dateTo']); $oDB = new dclDB(); // for sql side date formatting $sql .= '((t.dcl_status_type_id = 1 and w.createdon between ' . $oDB->DisplayToSQL($dateFrom) . ' and ' . $oDB->DisplayToSQL($dateTo) . ') or '; $sql .= '(t.dcl_status_type_id = 2 and w.closedon between ' . $oDB->DisplayToSQL($dateFrom) . ' and ' . $oDB->DisplayToSQL($dateTo) . ')) '; } else { $sql .= 't.dcl_status_type_id != 3 '; } if ($aItems[5] != '') { $sql .= ' and (' . $aItems[5] . ') '; } $sql .= sprintf('group by %s, %s, t.dcl_status_type_id, t.dcl_status_type_name order by %s', $aItems[2], $aItems[3], $orderby); return $sql; }
function ShowReport($query, $iGroupColumn) { $bExport = isset($_REQUEST['export']) && $_REQUEST['export'] == '1'; $objS = CreateObject('dcl.dbStatuses'); $objPr = CreateObject('dcl.dbPriorities'); $objSe = CreateObject('dcl.dbSeverities'); $objW = CreateObject('dcl.dbWorkorders'); $oPM = CreateObject('dcl.dbProjectmap'); $objDB = new dclDB(); $aGroupOptions = array('1' => 'Project', '2' => 'Action', '3' => 'Date', '4' => 'Product', '5' => 'by'); $groupBy = $_REQUEST['groupby']; if (!array_key_exists($groupBy, $aGroupOptions)) { $groupBy = '0'; } $oMeta =& CreateObject('dcl.DCL_MetadataDisplay'); $responsible = 0; $department = 0; if ($_REQUEST['bytype'] == '1') { if (($responsible = DCL_Sanitize::ToInt($_REQUEST['responsible'])) === null) { trigger_error('Data sanitize failed.'); return; } $sReportFor = $oMeta->GetPersonnel($responsible); } else { if (($department = DCL_Sanitize::ToInt($_REQUEST['department'])) === null) { trigger_error('Data sanitize failed.'); return; } $sReportFor = $oMeta->GetDepartment($department); } if (($begindate = DCL_Sanitize::ToDate($_REQUEST['begindate'])) === null || ($enddate = DCL_Sanitize::ToDate($_REQUEST['enddate'])) === null) { trigger_error('Data sanitize failed.'); return; } if ($objDB->Query($query) != -1) { if ($objDB->next_record()) { $lastJCN = 0; $lastSeq = 0; $lastGroup = $thisGroup = '<< undefined >>'; $arrayIndex = -1; $count = 0; $subEstHours = 0.0; $subAppliedHours = 0.0; $subEtcHours = 0.0; $subTimeHours = 0.0; $totalEstHours = 0.0; $totalAppliedHours = 0.0; $totalEtcHours = 0.0; $totalTimeHours = 0.0; $oDate = new DCLDate(); $aByDate = array(); do { $thisJCN = $objDB->f('jcn'); $thisSeq = $objDB->f('seq'); if ($groupBy == '3') { $oDate->SetFromDB($objDB->f('actionon')); $thisGroup = $oDate->ToDisplay(); } else { if ($groupBy == '5') { $thisGroup = $objDB->f('short'); } else { if ($groupBy != '0') { if ($objDB->IsFieldNull('name')) { $thisGroup = ' '; } else { $thisGroup = $objDB->f('name'); } } } } // Skip multiple time cards if ($thisJCN != $lastJCN || $thisSeq != $lastSeq || $thisGroup != $lastGroup) { if ($groupBy != '0' && $thisGroup != $lastGroup && $lastGroup != '<< undefined >>') { // Subtotals $arrayIndex++; if ($bExport) { $reportArray[$arrayIndex][0] = 'Subtotal for ' . $lastGroup; } else { $reportArray[$arrayIndex][0] = '<b>Subtotal for ' . $lastGroup . '</b>'; } if ($groupBy != '1') { $reportArray[$arrayIndex][] = ''; } if ($_REQUEST['bytype'] == '2') { if ($groupBy == '5') { $reportArray[$arrayIndex][] = $lastGroup; } else { $reportArray[$arrayIndex][] = ''; } } $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = $subEstHours; $reportArray[$arrayIndex][] = $subEtcHours; $reportArray[$arrayIndex][] = $subAppliedHours; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = $subTimeHours; $ouHours = -($subEstHours - $subAppliedHours); $diffHours = $ouHours; if ($diffHours < 0) { $diffHours = -$diffHours; } $ouPct = 0.0; $sign = ''; if ($subEstHours > 0) { $ouPct = $diffHours / $subEstHours * 100; if ($subEstHours > $subAppliedHours && $subEstHours > 0) { $sign = '-'; } else { if ($subAppliedHours > $subEstHours && $subAppliedHours > 0) { $sign = '+'; } } } if ($bExport) { $reportArray[$arrayIndex][] = sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct)); } else { $reportArray[$arrayIndex][] = sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct)); } if ($groupBy != '0' && ($_REQUEST['bytype'] != '2' || $groupBy != '5')) { $reportArray[$arrayIndex][] = $lastGroup; } $subEstHours = 0.0; $subAppliedHours = 0.0; $subEtcHours = 0.0; $subTimeHours = 0.0; } $arrayIndex++; $objW->Load($thisJCN, $thisSeq); $objS->Load($objW->status); $objPr->Load($objW->priority); $objSe->Load($objW->severity); if ($bExport) { $reportArray[$arrayIndex][0] = '[' . $thisJCN . '-' . $thisSeq . '] ' . $objW->summary; } else { $reportArray[$arrayIndex][0] = '[<a href="main.php?menuAction=boWorkorders.viewjcn&jcn=' . $thisJCN . '&seq=' . $thisSeq . '">' . $thisJCN . '-' . $thisSeq . '</a>] ' . htmlentities($objW->summary); } if ($groupBy != '1') { if ($oPM->LoadByWO($thisJCN, $thisSeq) != -1) { if ($bExport) { $reportArray[$arrayIndex][] = '[' . $oPM->projectid . '] ' . $oMeta->GetProject($oPM->projectid); } else { $reportArray[$arrayIndex][] = '[<a href="main.php?menuAction=boProjects.viewproject&project=' . $oPM->projectid . '">' . $oPM->projectid . '</a>] ' . htmlentities($oMeta->GetProject($oPM->projectid)); } } else { $reportArray[$arrayIndex][] = ''; } } if ($_REQUEST['bytype'] == '2') { $reportArray[$arrayIndex][] = $objDB->f('short'); } $reportArray[$arrayIndex][] = $objS->name; $reportArray[$arrayIndex][] = $objPr->name; $reportArray[$arrayIndex][] = $objSe->name; $reportArray[$arrayIndex][] = (double) $objW->esthours; $reportArray[$arrayIndex][] = (double) $objW->etchours; $reportArray[$arrayIndex][] = (double) $objW->totalhours; $reportArray[$arrayIndex][] = $objW->eststarton; $reportArray[$arrayIndex][] = $objW->estendon; $reportArray[$arrayIndex][] = $objW->starton; $reportArray[$arrayIndex][] = $objW->closedon; $reportArray[$arrayIndex][] = (double) $objDB->f('hours'); $ouHours = -($objW->esthours - $objW->totalhours); $diffHours = $ouHours; if ($diffHours < 0) { $diffHours = -$diffHours; } $ouPct = 0.0; $sign = ''; if ($objW->esthours > 0) { $ouPct = $diffHours / $objW->esthours * 100; if ($objW->esthours > $objW->totalhours && $objW->esthours > 0) { $sign = '-'; } else { if ($objW->totalhours > $objW->esthours && $objW->totalhours > 0) { $sign = '+'; } } } $reportArray[$arrayIndex][] = sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct)); if ($groupBy != '0' && ($_REQUEST['bytype'] != '2' || $groupBy != '5')) { $reportArray[$arrayIndex][] = $thisGroup; } $sKey = sprintf('%d-%d', $thisJCN, $thisSeq); if ($groupBy != '3' || !isset($aByDate[$sKey])) { $subEstHours += (double) $objW->esthours; $subAppliedHours += (double) $objW->totalhours; $subEtcHours += (double) $objW->etchours; $totalEstHours += (double) $objW->esthours; $totalAppliedHours += (double) $objW->totalhours; $totalEtcHours += (double) $objW->etchours; $aByDate[$sKey] = true; } $lastJCN = $thisJCN; $lastSeq = $thisSeq; $lastGroup = $thisGroup; } else { $iOrdinal = 11; if ($groupBy != '1') { $iOrdinal++; } if ($_REQUEST['bytype'] == '2') { $iOrdinal++; } $reportArray[$arrayIndex][$iOrdinal] += (double) $objDB->f('hours'); } $subTimeHours += $objDB->f('hours'); $totalTimeHours += $objDB->f('hours'); $count++; } while ($objDB->next_record()); // Subtotals $arrayIndex++; if ($bExport) { $reportArray[$arrayIndex][0] = 'Subtotal for ' . $lastGroup; } else { $reportArray[$arrayIndex][0] = '<b>Subtotal for ' . $lastGroup . '</b>'; } if ($groupBy != '1') { $reportArray[$arrayIndex][] = ''; } if ($_REQUEST['bytype'] == '2') { if ($groupBy == '5') { $reportArray[$arrayIndex][] = $lastGroup; } else { $reportArray[$arrayIndex][] = ''; } } $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = $subEstHours; $reportArray[$arrayIndex][] = $subEtcHours; $reportArray[$arrayIndex][] = $subAppliedHours; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = $subTimeHours; $ouHours = -($subEstHours - $subAppliedHours); $diffHours = $ouHours; if ($diffHours < 0) { $diffHours = -$diffHours; } $ouPct = 0.0; $sign = ''; if ($subEstHours > 0) { $ouPct = $diffHours / $subEstHours * 100; if ($subEstHours > $subAppliedHours && $subEstHours > 0) { $sign = '-'; } else { if ($subAppliedHours > $subEstHours && $subAppliedHours > 0) { $sign = '+'; } } } if ($bExport) { $reportArray[$arrayIndex][] = sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct)); } else { $reportArray[$arrayIndex][] = sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct)); } if ($groupBy != '0' && ($_REQUEST['bytype'] != '2' || $groupBy != '5')) { $reportArray[$arrayIndex][] = $lastGroup; } $subEstHours = 0.0; $subAppliedHours = 0.0; $subEtcHours = 0.0; $subTimeHours = 0.0; if ($bExport) { $arrayIndex++; $reportArray[$arrayIndex][0] = 'Totals'; if ($groupBy != '1') { $reportArray[$arrayIndex][] = ''; } if ($_REQUEST['bytype'] == '2') { $reportArray[$arrayIndex][] = ''; } $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = $totalEstHours; $reportArray[$arrayIndex][] = $totalEtcHours; $reportArray[$arrayIndex][] = $totalAppliedHours; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = ''; $reportArray[$arrayIndex][] = $totalTimeHours; $ouHours = -($totalEstHours - $totalAppliedHours); $diffHours = $ouHours; if ($diffHours < 0) { $diffHours = -$diffHours; } $ouPct = 0.0; $sign = ''; if ($totalEstHours > 0) { $ouPct = $diffHours / $totalEstHours * 100; if ($totalEstHours > $totalAppliedHours && $totalEstHours > 0) { $sign = '-'; } else { if ($totalAppliedHours > $totalEstHours && $totalAppliedHours > 0) { $sign = '+'; } } } if ($bExport) { $reportArray[$arrayIndex][] = sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct)); } else { $reportArray[$arrayIndex][] = sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct)); } if ($groupBy != '0') { $reportArray[$arrayIndex][] = ''; } $nameArray = array(); $nameArray[] = STR_WOST_SUMMARY; if ($groupBy != '1') { $nameArray[] = STR_WO_PROJECT; } if ($_REQUEST['bytype'] == '2') { $nameArray[] = STR_CMMN_BY; } $nameArray[] = STR_WO_STATUS; $nameArray[] = STR_WO_PRIORITY; $nameArray[] = STR_WO_SEVERITY; $nameArray[] = STR_WOST_BUDGET; $nameArray[] = STR_WOST_ETC; $nameArray[] = STR_WOST_TODATE; $nameArray[] = STR_WOST_ESTSTART; $nameArray[] = STR_WOST_ESTEND; $nameArray[] = STR_WOST_START; $nameArray[] = STR_WOST_END; $nameArray[] = STR_WOST_TIME; $nameArray[] = '+ / -'; if ($groupBy != '0' && ($_REQUEST['bytype'] != '2' || $groupBy != '5')) { $nameArray[] = ''; } ExportArray($nameArray, $reportArray); } else { $oTable = CreateObject('dcl.htmlTable'); $oTable->addFooter('Totals'); if ($groupBy != '1') { $oTable->addFooter(''); } if ($_REQUEST['bytype'] == '2') { $oTable->addFooter(''); } $oTable->addFooter(''); $oTable->addFooter(''); $oTable->addFooter(''); $oTable->addFooter($totalEstHours); $oTable->addFooter($totalEtcHours); $oTable->addFooter($totalAppliedHours); $oTable->addFooter(''); $oTable->addFooter(''); $oTable->addFooter(''); $oTable->addFooter(''); $oTable->addFooter($totalTimeHours); $ouHours = -($totalEstHours - $totalAppliedHours); $diffHours = $ouHours; if ($diffHours < 0) { $diffHours = -$diffHours; } $ouPct = 0.0; $sign = ''; if ($totalEstHours > 0) { $ouPct = $diffHours / $totalEstHours * 100; if ($totalEstHours > $totalAppliedHours && $totalEstHours > 0) { $sign = '-'; } else { if ($totalAppliedHours > $totalEstHours && $totalAppliedHours > 0) { $sign = '+'; } } } $oTable->addFooter(sprintf('%s%0.2f (%s%0.2f%%)', $sign, abs($ouHours), $sign, abs($ouPct))); if ($groupBy != '0' && ($_REQUEST['bytype'] != '2' || $groupBy != '5')) { $oTable->addFooter(''); } $oTable->addColumn(STR_WOST_SUMMARY, 'html'); if ($groupBy != '1') { $oTable->addColumn(STR_WO_PROJECT, 'html'); } if ($_REQUEST['bytype'] == '2') { $oTable->addColumn(STR_CMMN_BY, 'string'); } $oTable->addColumn(STR_WO_STATUS, 'string'); $oTable->addColumn(STR_WO_PRIORITY, 'string'); $oTable->addColumn(STR_WO_SEVERITY, 'string'); $oTable->addColumn(STR_WOST_BUDGET, 'numeric'); $oTable->addColumn(STR_WOST_ETC, 'numeric'); $oTable->addColumn(STR_WOST_TODATE, 'numeric'); $oTable->addColumn(STR_WOST_ESTSTART, 'string'); $oTable->addColumn(STR_WOST_ESTEND, 'string'); $oTable->addColumn(STR_WOST_START, 'string'); $oTable->addColumn(STR_WOST_END, 'string'); $oTable->addColumn(STR_WOST_TIME, 'numeric'); $oTable->addColumn('+ / -', 'html'); if (array_key_exists($groupBy, $aGroupOptions) && ($_REQUEST['bytype'] != '2' || $groupBy != '5')) { $oTable->addColumn($aGroupOptions[$groupBy], 'string'); } $oTable->setData($reportArray); $oTable->setCaption(sprintf(STR_WOST_ACTIVITYTITLE, $sReportFor, $_REQUEST['begindate'], $_REQUEST['enddate'])); $oTable->addToolbar(menuLink('', sprintf('menuAction=reportPersonnelActivity.execute&export=1&responsible=%s&begindate=%s&enddate=%s&bytype=%d&groupby=%d&department=%d', $responsible, $begindate, $enddate, $_REQUEST['bytype'], $groupBy, $department)), STR_VW_EXPORTRESULTS); $oTable->addGroup($iGroupColumn); $oTable->setShowRownum(true); $oTable->render(); } } else { if ($bExport) { commonHeader(); } trigger_error(STR_WOST_NOACTIVITY, E_USER_NOTICE); $this->getparameters(false); } } else { if ($bExport) { commonHeader(); } trigger_error(STR_WOST_QUERYERR, E_USER_ERROR); } }
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 SearchFromStat() { global $dcl_domain_info, $dcl_domain, $g_oSec; commonHeader(); if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_VIEW)) { return PrintPermissionDenied(); } $responsible = DCL_Sanitize::ToInt($_REQUEST['responsible']); $product = DCL_Sanitize::ToInt($_REQUEST['product']); $status = DCL_Sanitize::ToInt($_REQUEST['status']); $begindate = DCL_Sanitize::ToDate($_REQUEST['begindate']); $enddate = DCL_Sanitize::ToDate($_REQUEST['enddate']); $obj = new dclDB(); $objView = CreateObject('dcl.boView'); $objView->style = 'report'; $objView->title = STR_WOST_SEARCHRESULTS; $objView->AddDef('columns', '', array('jcn', 'seq', 'responsible.short', 'products.name', 'statuses.name', 'eststarton', 'deadlineon', 'etchours', 'totalhours', 'summary')); $objView->AddDef('columnhdrs', '', array(STR_WO_JCN, STR_WO_SEQ, STR_WO_RESPONSIBLE, STR_WO_PRODUCT, STR_WO_STATUS, STR_WO_ESTSTART, STR_WO_DEADLINE, STR_WO_ETCHOURS, STR_WO_ACTHOURS, STR_WO_SUMMARY)); $objView->AddDef('order', '', array('priorities.weight', 'severities.weight', 'jcn', 'seq')); if ($begindate !== null || $enddate !== null) { $objView->AddDef('filter', 'statuses.dcl_status_type', '2'); $objView->AddDef('filterdate', 'closedon', array($obj->DisplayToSQL($begindate), $obj->DisplayToSQL($enddate))); } else { if ($status !== null) { $objView->AddDef('filter', 'status', $status); } else { $objView->AddDef('filternot', 'statuses.dcl_status_type', '2'); } } if ($responsible !== null) { $objView->AddDef('filter', 'responsible', $responsible); } if ($product !== null) { $objView->AddDef('filter', 'product', $product); } $obj = CreateViewObject($objView->table); $obj->Render($objView); }
function dbreassign() { global $dcl_info, $g_oSec; commonHeader(); if (($iID = @DCL_Sanitize::ToInt($_REQUEST['jcn'])) === null || ($iSeq = @DCL_Sanitize::ToInt($_REQUEST['seq'])) === null || ($iResponsible = @DCL_Sanitize::ToInt($_REQUEST['responsible'])) === null || ($fEstHours = @DCL_Sanitize::ToDecimal($_REQUEST['esthours'])) === null || ($fEtcHours = @DCL_Sanitize::ToDecimal($_REQUEST['etchours'])) === null || ($iSeverity = @DCL_Sanitize::ToInt($_REQUEST['severity'])) === null || ($iPriority = @DCL_Sanitize::ToInt($_REQUEST['priority'])) === null || ($deadlineon = @DCL_Sanitize::ToDate($_REQUEST['deadlineon'])) === null || ($eststarton = @DCL_Sanitize::ToDate($_REQUEST['eststarton'])) === null || ($estendon = @DCL_Sanitize::ToDate($_REQUEST['estendon'])) === null) { trigger_error('Data sanitize failed.'); return; } if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ASSIGN, $iID, $iSeq)) { return PrintPermissionDenied(); } $objWO =& CreateObject('dcl.dbWorkorders'); if ($objWO->Load($iID, $iSeq) == -1) { return; } if ($objWO->responsible != $iResponsible || $objWO->deadlineon != $deadlineon || $objWO->eststarton != $eststarton || $objWO->estendon != $estendon || $objWO->esthours != $fEstHours || $objWO->etchours != $fEtcHours || $objWO->priority != $iPriority || $objWO->status == $dcl_info['DCL_DEF_STATUS_UNASSIGN_WO'] || $objWO->severity != $iSeverity) { $objWO->responsible = $iResponsible; $objWO->deadlineon = $deadlineon; $objWO->eststarton = $eststarton; $objWO->estendon = $estendon; $objWO->esthours = $fEstHours; $oStatus =& CreateObject("dcl.dbStatuses"); if ($oStatus->GetStatusType($objWO->status) != 2) { $objWO->etchours = $fEtcHours; if ($objWO->status == $dcl_info['DCL_DEF_STATUS_UNASSIGN_WO']) { $objWO->status = $dcl_info['DCL_DEF_STATUS_ASSIGN_WO']; $objWO->statuson = $objWO->GetDateSQL(); } } else { $objWO->etchours = 0.0; } $objWO->priority = $iPriority; $objWO->severity = $iSeverity; $objWO->Edit(); $objWtch =& CreateObject('dcl.boWatches'); $objWtch->sendNotification($objWO, '4'); } $objHTMLWO =& CreateObject('dcl.htmlWorkOrderDetail'); $objHTMLWO->Show($iID, $iSeq); }
function Render() { commonHeader(); if (($id = DCL_Sanitize::ToInt($_REQUEST['projectid'])) === null) { return PrintPermissionDenied(); } if (($days = DCL_Sanitize::ToInt($_REQUEST['days'])) === null) { return PrintPermissionDenied(); } if (($endon = DCL_Sanitize::ToDate($_REQUEST['endon'])) === null) { return PrintPermissionDenied(); } $oDate = new DCLDate(); $oDate->SetFromDisplay($endon); $endon = $oDate->ToDB(); $oDate->time = mktime(0, 0, 0, date('m', $oDate->time), date('d', $oDate->time) - $days, date('Y', $oDate->time)); $beginon = $oDate->ToDB(); $sSQL = ''; if (isset($_REQUEST['scope'])) { $sSQL = $this->GetScopeSQL($id, $beginon, $endon); } if (isset($_REQUEST['timecards'])) { if ($sSQL != '') { $sSQL .= ' UNION ALL '; } $sSQL .= $this->GetTimeCardSQL($id, $beginon, $endon); } if (isset($_REQUEST['code'])) { if ($sSQL != '') { $sSQL .= ' UNION ALL '; } $sSQL .= $this->GetWorkOrderCodeSQL($id, $beginon, $endon); $sSQL .= ' UNION ALL '; $sSQL .= $this->GetProjectCodeSQL($id, $beginon, $endon); } if ($sSQL == '') { ShowError('No options selected.', __FILE__, __LINE__, null); return; } $sSQL .= ' ORDER BY 2 DESC'; $oDB = new dclDB(); if ($oDB->Query($sSQL) !== -1) { $aResults = array(); while ($oDB->next_record()) { $aRecord = array(); $aRecord[] = $oDB->FormatDateForDisplay($oDB->f(1)); $oDB->objTimestamp->SetFromDB($oDB->f(1)); $aRecord[] = $oDB->objTimestamp->ToTimeOnly(); if ($oDB->f(0) == 4) { $aRecord[] = '<a href="' . menuLink('', 'menuAction=boProjects.viewproject&project=' . $id) . '">[' . $id . '] ' . htmlspecialchars($oDB->f(5)) . '</a>'; } else { $aRecord[] = '<a href="' . menuLink('', 'menuAction=boWorkorders.viewjcn&jcn=' . $oDB->f(2) . '&seq=' . $oDB->f(3)) . '">[' . $oDB->f(2) . '-' . $oDB->f(3) . '] ' . htmlspecialchars($oDB->f(6)) . '</a>'; } $aRecord[] = $oDB->f(7); $aRecord[] = $oDB->f(8); $aRecord[] = $oDB->f(9); $aResults[] = $aRecord; } $oTable =& CreateObject('dcl.htmlTable'); $oTable->setCaption('Project Timeline'); $oTable->addColumn('Date', 'string'); $oTable->addColumn('Time', 'string'); $oTable->addColumn('Item', 'html'); $oTable->addColumn('Current Status', 'string'); $oTable->addColumn('Action By', 'string'); $oTable->addColumn('Action Description', 'string'); $oTable->addGroup(0); $oTable->setData($aResults); $oTable->setShowRownum(true); $oTable->render(); } }
function execute() { commonHeader(); if (($begindate = DCL_Sanitize::ToDate($_REQUEST['begindate'])) === null || ($enddate = DCL_Sanitize::ToDate($_REQUEST['enddate'])) === null || ($responsible = DCL_Sanitize::ToInt($_REQUEST['responsible'])) === null) { trigger_error('All fields are required.'); $this->GetParameters(false); return; } $oMeta =& CreateObject('dcl.DCL_MetadataDisplay'); $obj = CreateObject('dcl.dbTickets'); $objT = CreateObject('dcl.dbTicketresolutions'); $sColumns = $obj->SelectAllColumns('a.'); $query = 'select ' . $sColumns . ' from tickets a, ticketresolutions b where a.ticketid=b.ticketid and b.loggedby=' . $responsible; $query .= ' and b.loggedon between ' . $obj->DisplayToSQL($begindate . ' 00:00:00') . ' and ' . $obj->DisplayToSQL($enddate . ' 23:59:59'); $query .= ' order by a.ticketid'; if ($obj->Query($query) != -1) { if ($obj->next_record()) { $arrayIndex = -1; $count = 0; $prevTicketID = -1; do { $obj->GetRow(); if ($obj->ticketid != $prevTicketID) { $prevTicketID = $obj->ticketid; $arrayIndex++; $reportArray[$arrayIndex][0] = $oMeta->GetProduct($obj->product); $aOrg = $oMeta->GetOrganization($obj->account); $reportArray[$arrayIndex][1] = $aOrg['name']; $reportArray[$arrayIndex][2] = $oMeta->GetStatus($obj->status); $reportArray[$arrayIndex][3] = $oMeta->GetPriority($obj->priority); $reportArray[$arrayIndex][4] = $oMeta->GetSeverity($obj->type); $reportArray[$arrayIndex][5] = $obj->createdon; $reportArray[$arrayIndex][6] = $obj->closedon; $reportArray[$arrayIndex][7] = 1; $reportArray[$arrayIndex][8] = '<a href="' . menuLink('', 'menuAction=boTickets.view&ticketid=' . $obj->f('ticketid')) . '">[' . $obj->f('ticketid') . '] ' . htmlentities($obj->summary) . '</a>'; } else { $reportArray[$arrayIndex][7]++; } $count++; } while ($obj->next_record()); $oTable = CreateObject('dcl.htmlTable'); $oTable->addColumn(STR_TCK_PRODUCT, 'string'); $oTable->addColumn(STR_TCK_ACCOUNT, 'string'); $oTable->addColumn(STR_TCK_STATUS, 'string'); $oTable->addColumn(STR_TCK_PRIORITY, 'string'); $oTable->addColumn(STR_TCK_TYPE, 'string'); $oTable->addColumn(STR_TCK_CREATED, 'string'); $oTable->addColumn(STR_TCK_CLOSED, 'string'); $oTable->addColumn('Calls', 'string'); $oTable->addColumn(STR_TCK_SUMMARY, 'html'); $oTable->setCaption(sprintf(STR_WOST_ACTIVITYTITLE, $oMeta->GetPersonnel($responsible), $begindate, $enddate)); $oTable->setData($reportArray); $oTable->setShowRownum(true); $oTable->render(); } else { trigger_error(STR_WOST_NOACTIVITY, E_USER_NOTICE); } } else { trigger_error(STR_WOST_QUERYERR, E_USER_ERROR); } }
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); }