[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Reports/models/ -> Module.php (source)

   1  <?php
   2  /* +***********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   * *********************************************************************************** */
  10  
  11  class Reports_Module_Model extends Vtiger_Module_Model {
  12  
  13      /**
  14       * Function deletes report
  15       * @param Reports_Record_Model $reportModel
  16       */
  17  	function deleteRecord($reportModel) {
  18          $currentUser = Users_Record_Model::getCurrentUserModel();
  19          $subOrdinateUsers = $currentUser->getSubordinateUsers();
  20  
  21          $subOrdinates = array();
  22          foreach($subOrdinateUsers as $id=>$name) {
  23              $subOrdinates[] = $id;
  24          }
  25  
  26          $owner = $reportModel->get('owner');
  27  
  28          if($currentUser->isAdminUser() || in_array($owner, $subOrdinates) || $owner == $currentUser->getId()) {
  29              $reportId = $reportModel->getId();
  30              $db = PearDatabase::getInstance();
  31  
  32              $db->pquery('DELETE FROM vtiger_selectquery WHERE queryid = ?', array($reportId));
  33  
  34              $db->pquery('DELETE FROM vtiger_report WHERE reportid = ?', array($reportId));
  35  
  36              $db->pquery('DELETE FROM vtiger_schedulereports WHERE reportid = ?', array($reportId));
  37  
  38              $db->pquery('DELETE FROM vtiger_reporttype WHERE reportid = ?', array($reportId));
  39  
  40              $result = $db->pquery('SELECT * FROM vtiger_homereportchart WHERE reportid = ?',array($reportId));
  41              $numOfRows = $db->num_rows($result);
  42              for ($i = 0; $i < $numOfRows; $i++) {
  43                  $homePageChartIdsList[] = $adb->query_result($result, $i, 'stuffid');
  44              }
  45              if ($homePageChartIdsList) {
  46                  $deleteQuery = 'DELETE FROM vtiger_homestuff WHERE stuffid IN (' . implode(",", $homePageChartIdsList) . ')';
  47                  $db->pquery($deleteQuery, array());
  48              }
  49              return true;
  50          }
  51          return false;
  52      }
  53  
  54      /**
  55       * Function returns quick links for the module
  56       * @return <Array of Vtiger_Link_Model>
  57       */
  58  	function getSideBarLinks($linkParams = '') {
  59          $quickLinks = array(
  60              array(
  61                  'linktype' => 'SIDEBARLINK',
  62                  'linklabel' => 'LBL_REPORTS',
  63                  'linkurl' => $this->getListViewUrl(),
  64                  'linkicon' => '',
  65              ),
  66          );
  67          foreach($quickLinks as $quickLink) {
  68              $links['SIDEBARLINK'][] = Vtiger_Link_Model::getInstanceFromValues($quickLink);
  69          }
  70  
  71          $quickWidgets = array(
  72              array(
  73                  'linktype' => 'SIDEBARWIDGET',
  74                  'linklabel' => 'LBL_RECENTLY_MODIFIED',
  75                  'linkurl' => 'module='.$this->get('name').'&view=IndexAjax&mode=showActiveRecords',
  76                  'linkicon' => ''
  77              ),
  78          );
  79          foreach($quickWidgets as $quickWidget) {
  80              $links['SIDEBARWIDGET'][] = Vtiger_Link_Model::getInstanceFromValues($quickWidget);
  81          }
  82  
  83          return $links;
  84      }
  85  
  86      /**
  87       * Function returns the recent created reports
  88       * @param <Number> $limit
  89       * @return <Array of Reports_Record_Model>
  90       */
  91  	function getRecentRecords($limit = 10) {
  92          $db = PearDatabase::getInstance();
  93  
  94          $result = $db->pquery('SELECT * FROM vtiger_report ORDER BY reportid DESC LIMIT ?', array($limit));
  95          $rows = $db->num_rows($result);
  96  
  97          $recentRecords = array();
  98          for($i=0; $i<$rows; ++$i) {
  99              $row = $db->query_result_rowdata($result, $i);
 100              $recentRecords[$row['reportid']] = $this->getRecordFromArray($row);
 101          }
 102          return $recentRecords;
 103      }
 104  
 105      /**
 106       * Function returns the report folders
 107       * @return <Array of Reports_Folder_Model>
 108       */
 109  	function getFolders() {
 110          return Reports_Folder_Model::getAll();
 111      }
 112  
 113      /**
 114       * Function to get the url for add folder from list view of the module
 115       * @return <string> - url
 116       */
 117  	function getAddFolderUrl() {
 118          return 'index.php?module='.$this->get('name').'&view=EditFolder';
 119      }
 120      
 121      /**
 122       * Function to check if the extension module is permitted for utility action
 123       * @return <boolean> true
 124       */
 125      public function isUtilityActionEnabled() {
 126          return true;
 127      }
 128  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1