Exemplo n.º 1
0
 function __construct()
 {
     //-----------------------------------------------------------------------
     // constructor
     //-----------------------------------------------------------------------
     parent::__construct();
     $this->cUserRpts = $this->lNumUsers = $this->cRptDir = $this->lNumRptsInDir = null;
     $this->lNumReports = $this->reports = null;
     $this->strWhereExtra = $this->strOrder = '';
     $this->cRptTypes = loadCReportTypeArray();
 }
 public function moveSort($lReportID, $lFieldID, $enumMove)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lReportID, 'custom report ID');
     $lReportID = (int) $lReportID;
     $lFieldID = (int) $lFieldID;
     //------------------------------------------------
     // libraries and utilities
     //------------------------------------------------
     $this->load->helper('reports/search');
     $this->load->helper('dl_util/context');
     $this->load->helper('reports/creport_util');
     $this->load->helper('creports/creport_field');
     $this->load->model('admin/madmin_aco');
     $this->load->model('creports/mcreports', 'clsCReports');
     //------------------------------------------------
     // load report
     //------------------------------------------------
     $displayData['cRptTypes'] = loadCReportTypeArray();
     $this->clsCReports->loadReportViaID($lReportID, true);
     $report =& $this->clsCReports->reports[0];
     if (!$report->bUserHasWriteAccess) {
         vid_bTestFail($this, false, 'Custom Report', $lReportID);
         return;
     }
     $this->load->library('util/up_down_top_bottom', '', 'upDown');
     $this->upDown->enumMove = $enumMove;
     $this->upDown->enumRecType = 'creport fields';
     $this->upDown->strUfieldDDL = 'creport_fields';
     $this->upDown->strUfieldDDLKey = 'crf_lKeyID';
     $this->upDown->strUfieldDDLSort = 'crf_lSortIDX';
     $this->upDown->strUfieldDDLQual1 = 'crf_lReportID';
     $this->upDown->strUfieldDDLRetired = '';
     $this->upDown->lUfieldDDLQual1Val = $lReportID;
     $this->upDown->lKeyID = $lFieldID;
     $this->upDown->moveRecs();
     $this->session->set_flashdata('msg', 'The display fields were re-ordered');
     redirect('creports/display_order/addEditDisplayTermOrder/' . $lReportID);
 }
 function add_edit($lCRptID = 0)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $this->load->helper('dl_util/verify_id');
     verifyIDsViaType($this, CENUM_CONTEXT_CUSTOMREPORT, $lCRptID, false);
     $displayData = array();
     $displayData['bNew'] = $bNew = $lCRptID <= 0;
     $displayData['lReportID'] = (int) $lCRptID;
     $displayData['js'] = '';
     //-------------------------
     // models & helpers
     //-------------------------
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->model('admin/madmin_aco');
     $this->load->model('creports/mcreports', 'clsCReports');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('reports/creport_util');
     $cRptTypes = loadCReportTypeArray();
     $this->clsCReports->loadReportViaID($lCRptID, false);
     $report =& $this->clsCReports->reports[0];
     $this->load->helper('js/div_hide_show');
     $displayData['js'] .= showHideDiv();
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtName', 'Report Name', 'trim|required|callback_cRptNameDupTest[' . $lCRptID . ']');
     $this->form_validation->set_rules('txtNotes', 'Notes', 'trim');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         if (!$bNew) {
             $displayData['formData']->strRptType = $report->strXlatedRptType;
         }
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $displayData['formData']->strName = $report->strName;
             $displayData['formData']->strNotes = $report->strNotes;
             $displayData['formData']->bPrivate = $report->bPrivate;
             if ($bNew) {
                 $displayData['formData']->strCRptTypeDDL = strCRptTypesDDL($cRptTypes, false, $report->enumRptType);
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->strName = set_value('txtName');
             $displayData['formData']->strNotes = set_value('txtNotes');
             $displayData['formData']->bPrivate = @$_POST['chkPrivate'] == 'TRUE';
             if ($bNew) {
                 $displayData['formData']->strCRptTypeDDL = strCRptTypesDDL($cRptTypes, false, @$_POST['ddlCRpt']);
             }
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/reports', 'Reports', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add' : 'Edit') . ' Custom Report';
         $displayData['title'] = CS_PROGNAME . ' | Custom Reports';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'creports/add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $report->strName = trim($_POST['txtName']);
         $report->strNotes = trim($_POST['txtNotes']);
         $report->bPrivate = @$_POST['chkPrivate'] == 'TRUE';
         if ($bNew) {
             $report->enumRptType = trim($_POST['ddlCRpt']);
         }
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $lCRptID = $this->clsCReports->addNewCReport();
             $this->session->set_flashdata('msg', 'Custom report added');
             redirect('creports/view_fields/view/' . $lCRptID . '/true');
         } else {
             $this->clsCReports->updateCReport($lCRptID);
             $this->session->set_flashdata('msg', 'Custom report updated');
             redirect('creports/custom_directory/viewRec/' . $lCRptID);
         }
     }
 }
 function add_edit($lReportID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $glUserID;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lReportID, 'custom report ID');
     $displayData = array();
     $displayData['lReportID'] = $lReportID;
     $displayData['js'] = '';
     //------------------------------------------------
     // models, libraries and utilities
     //------------------------------------------------
     $this->load->helper('reports/creport_util');
     $params = array('enumStyle' => 'terse', 'clsRpt');
     $this->load->library('generic_rpt', $params);
     $this->load->library('generic_form');
     $this->load->helper('js/toggle_paren');
     $this->load->helper('reports/creport_util');
     $this->load->helper('reports/search');
     $this->load->helper('dl_util/special_ddl');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('creports/link_creports');
     $this->load->helper('creports/creport_field');
     $this->load->helper('dl_util/context');
     $this->load->model('admin/madmin_aco');
     $this->load->model('personalization/muser_fields');
     $this->load->model('creports/mcreports', 'clsCReports');
     $this->load->model('creports/mcrpt_search_terms', 'crptTerms');
     $this->load->model('creports/mcrpt_terms_display', 'crptTD');
     $this->load->library('util/up_down_top_bottom');
     $displayData['js'] .= strToggleParen();
     //------------------------------------------------
     // load report
     //------------------------------------------------
     $displayData['cRptTypes'] = loadCReportTypeArray();
     $this->clsCReports->loadReportViaID($lReportID, true);
     $displayData['report'] = $report =& $this->clsCReports->reports[0];
     if (!$report->bUserHasWriteAccess) {
         vid_bTestFail($this, false, 'Custom Report', $lReportID);
         return;
     }
     $displayData['lNumFields'] = $report->lNumFields;
     //$this->clsCReports->lFieldCount($lReportID);
     $displayData['contextSummary'] = $this->clsCReports->strCReportHTMLSummary();
     //------------------------------------------------
     // load formatted search expression
     //------------------------------------------------
     $attributes = new stdClass();
     $attributes->lReportID = $lReportID;
     $attributes->bShowParenEditLink = false;
     $attributes->bShowSortLink = false;
     $attributes->bParenAsTextInput = true;
     $displayData['strSearchExpression'] = $this->crptTD->strFormattedSearchExpression($lReportID, $attributes, $bBalanced);
     //--------------------------
     // breadcrumbs
     //--------------------------
     $displayData['pageTitle'] = anchor('main/menu/reports', 'Reports', 'class="breadcrumb"') . ' | ' . anchor('creports/custom_directory/view/' . $glUserID, 'Custom Report Directory', 'class="breadcrumb"') . ' | Custom Report: ' . $report->strSafeName;
     $displayData['title'] = CS_PROGNAME . ' | Reports';
     $displayData['nav'] = $this->mnav_brain_jar->navData();
     $displayData['mainTemplate'] = 'creports/paren_edit_view';
     $this->load->vars($displayData);
     $this->load->view('template');
 }
Exemplo n.º 5
0
 function creportReviewUtility(&$lReportID, &$displayData, &$bFail, &$fails, &$bFieldsOK, &$bTablePermissionOK, &$lNumTablePermFails, &$failTablePerms, &$lNumDDLJoins)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     //------------------------------------------------
     // load report
     //------------------------------------------------
     $displayData['cRptTypes'] = loadCReportTypeArray();
     $this->crptRun->loadReportViaID($lReportID, true);
     $report =& $this->crptRun->reports[0];
     if (!$report->bUserHasReadAccess) {
         vid_bTestFail($this, false, 'Custom Report', $lReportID);
         die;
     }
     $bFail = false;
     $fails = array();
     if ($report->lNumFields == 0) {
         $bFail = true;
         $fails[] = 'Please define one or more fields to display.';
     }
     // load search terms
     $this->crptRun->loadSearchTermViaReportID($lReportID);
     // load sort terms
     $this->crptRun->loadSortFieldsViaReportID($lReportID, $lNumSortTerms, $sortTerms);
     // max of 61 joins - mysql limit
     $lNumDDLJoins = $this->lCountDDLJoins($report->fields);
     // verify personalized terms still exist
     $this->crptRun->verifyTerms_Init();
     $bFieldsOK_Display = $this->crptRun->bVerifyTerms_Display($report, $displayData['lNumBad_Display'], $displayData['badFields_Display']);
     $bFieldsOK_Search = $this->crptRun->bVerifyTerms_Search($displayData['lNumBad_Search'], $displayData['badFields_Search']);
     $bFieldsOK_Sort = $this->crptRun->bVerifyTerms_Sort($lNumSortTerms, $sortTerms, $displayData['lNumBad_Sort'], $displayData['badFields_Sort']);
     $bFieldsOK = $bFieldsOK_Display && $bFieldsOK_Search && $bFieldsOK_Sort;
     // verify user has access to all tables referenced in report
     $bTablePermissionOK = $this->bVerifyUserAccessToReport($report, $lNumTablePermFails, $failTablePerms);
 }
Exemplo n.º 6
0
 function debugSQLGen($lReportID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $glUserID;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lReportID, 'custom report ID');
     $displayData = array();
     $displayData['lReportID'] = $lReportID;
     $displayData['js'] = '';
     //------------------------------------------------
     // models, libraries and utilities
     //------------------------------------------------
     $this->load->helper('reports/creport_util');
     $this->load->helper('creports/link_creports');
     $this->load->helper('creports/creport_field');
     $this->load->helper('creports/creport_special_ddl');
     $this->load->helper('creports/creport_tables');
     $this->load->helper('reports/search');
     $this->load->helper('dl_util/special_ddl');
     $this->load->helper('dl_util/context');
     $this->load->helper('dl_util/time_date');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->model('admin/madmin_aco');
     $this->load->model('personalization/muser_fields');
     $this->load->model('creports/mcreports', 'clsCReports');
     $this->load->model('creports/mcrpt_search_terms', 'crptTerms');
     $this->load->model('creports/mcrpt_run', 'crptRun');
     $this->load->model('creports/mcrpt_terms_display', 'crptTD');
     $params = array('enumStyle' => 'terse', 'clsRpt');
     $this->load->library('generic_rpt', $params);
     //------------------------------------------------
     // load report
     //------------------------------------------------
     $displayData['cRptTypes'] = loadCReportTypeArray();
     $this->clsCReports->loadReportViaID($lReportID, true);
     $displayData['report'] = $report =& $this->clsCReports->reports[0];
     // verify user has access to all tables referenced in report
     if (!$this->crptRun->bVerifyUserAccessToReport($report, $displayData['lNumFails'], $displayData['failTables'])) {
         $displayData['pageTitle'] = anchor('main/menu/reports', 'Reports', 'class="breadcrumb"') . ' | ' . anchor('creports/custom_directory/view/' . $glUserID, 'Custom Report Directory', 'class="breadcrumb"') . ' | ' . anchor('creports/custom_directory/viewRec/' . $lReportID, 'Report Record', 'class="breadcrumb"') . ' | Custom Report SQL: ' . $report->strSafeName;
         $displayData['title'] = CS_PROGNAME . ' | Reports';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'creports/report_notableaccess_view';
         $this->load->vars($displayData);
         $this->load->view('template');
         return;
     }
     $displayData['lNumFields'] = $report->lNumFields;
     //$this->clsCReports->lFieldCount($lReportID);
     $displayData['contextSummary'] = $this->clsCReports->strCReportHTMLSummary();
     //------------------------------------------------
     // load formatted search expression
     //------------------------------------------------
     $attributes = new stdClass();
     $attributes->lReportID = $lReportID;
     $attributes->bShowParenEditLink = false;
     $attributes->bShowSortLink = false;
     $attributes->bParenAsTextInput = false;
     $attributes->showEditDelete = false;
     $displayData['strSearchExpression'] = $this->crptTD->strFormattedSearchExpression($lReportID, $attributes, $bBalanced);
     $this->crptRun->strBuildCReportSQL($report);
     $displayData['sqlFrom'] = $this->crptRun->strJoins;
     $displayData['sqlWhere'] = $this->crptRun->strWhere;
     $displayData['sqlSelect'] = $this->crptRun->strSelect;
     $displayData['sqlSQL'] = $this->crptRun->strSQL;
     //--------------------------
     // breadcrumbs
     //--------------------------
     $displayData['pageTitle'] = anchor('main/menu/reports', 'Reports', 'class="breadcrumb"') . ' | ' . anchor('creports/custom_directory/view/' . $glUserID, 'Custom Report Directory', 'class="breadcrumb"') . ' | ' . anchor('creports/custom_directory/viewRec/' . $lReportID, 'Report Record', 'class="breadcrumb"') . ' | Custom Report SQL: ' . $report->strSafeName;
     $displayData['title'] = CS_PROGNAME . ' | Reports';
     $displayData['nav'] = $this->mnav_brain_jar->navData();
     $displayData['mainTemplate'] = 'creports/debug_sql_view';
     $this->load->vars($displayData);
     $this->load->view('template');
 }
 function remove($lReportID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $glUserID;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lReportID, 'custom report ID');
     $lReportID = (int) $lReportID;
     //------------------------------------------------
     // libraries and utilities
     //------------------------------------------------
     $this->load->helper('reports/search');
     $this->load->helper('dl_util/context');
     $this->load->helper('creports/creport_field');
     $this->load->helper('reports/creport_util');
     $this->load->model('admin/madmin_aco');
     $this->load->model('creports/mcreports', 'clsCReports');
     //------------------------------------------------
     // load report
     //------------------------------------------------
     $displayData['cRptTypes'] = loadCReportTypeArray();
     $this->clsCReports->loadReportViaID($lReportID, true);
     $displayData['report'] = $report =& $this->clsCReports->reports[0];
     if (!$report->bUserHasWriteAccess) {
         vid_bTestFail($this, false, 'Custom Report', $lReportID);
         return;
     }
     $this->clsCReports->removeCReport($lReportID);
     redirect('creports/custom_directory/view/' . $glUserID);
 }