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 export()
 {
     // Silent function to export tab delimited file and force browser to
     // force the user to save the file.
     header('Content-Type: application/binary; name=dclexport.txt');
     header('Content-Disposition: attachment; filename=dclexport.txt');
     $objView =& CreateObject('dcl.boView');
     $objView->SetFromURL();
     // Make object, run query, and (for now) blindly dump data.  The first
     // record will contain column headings.  Any tabs within data will be replaced
     // by spaces since our fields our tab delimited.
     $obj = new dclDB();
     $obj->Query($objView->GetSQL());
     $record = '';
     if (count($objView->columnhdrs) > 0) {
         foreach ($objView->columnhdrs as $val) {
             $val = str_replace(phpTab, ' ', $val);
             if ($record != '') {
                 $record .= phpTab;
             }
             $record .= $val;
         }
     }
     // Output field headings
     echo $record . phpCrLf;
     // Now for the records
     while ($obj->next_record()) {
         $record = '';
         for ($i = 0; $i < $obj->NumFields(); $i++) {
             if ($i > 0) {
                 $record .= phpTab;
             }
             if ($objView->table == 'tickets' && $obj->GetFieldName($i) == 'seconds') {
                 $record .= str_replace(phpTab, ' ', $obj->GetHoursText());
             } else {
                 $sData = str_replace(phpTab, ' ', $obj->f($i));
                 $sData = str_replace("\r", ' ', $sData);
                 $sData = str_replace("\n", ' ', $sData);
                 $record .= $sData;
             }
         }
         echo $record . phpCrLf;
     }
     exit;
     // Don't output footer
 }
 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();
 }