示例#1
0
 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $folderId = $request->get('folderid');
     if ($folderId) {
         $folderModel = Reports_Folder_Model::getInstanceById($folderId);
     } else {
         $folderModel = Reports_Folder_Model::getInstance();
     }
     $viewer->assign('FOLDER_MODEL', $folderModel);
     $viewer->assign('MODULE', $moduleName);
     $viewer->view('EditFolder.tpl', $moduleName);
 }
示例#2
0
 /**
  * Function that deletes the Folder
  * @param Vtiger_Request $request
  */
 function delete(Vtiger_Request $request)
 {
     $folderId = $request->get('folderid');
     $moduleName = $request->getModule();
     if ($folderId) {
         $folderModel = Reports_Folder_Model::getInstanceById($folderId);
         if ($folderModel->isDefault()) {
             throw new AppException(vtranslate('LBL_FOLDER_CAN_NOT_BE_DELETED', $moduleName));
         } else {
             if ($folderModel->hasReports()) {
                 throw new AppException(vtranslate('LBL_FOLDER_NOT_EMPTY', $moduleName));
             }
         }
         $folderModel->delete();
         $result = array('success' => true, 'message' => vtranslate('LBL_FOLDER_DELETED', $moduleName));
         $response = new Vtiger_Response();
         $response->setResult($result);
         $response->emit();
     }
 }
示例#3
0
 /**
  * Function returns the instance of Folder model
  * @return <Reports_Folder_Model>
  */
 public static function getAll()
 {
     $db = PearDatabase::getInstance();
     $folders = Vtiger_Cache::get('reports', 'folders');
     if (!$folders) {
         $folders = array();
         $result = $db->pquery("SELECT * FROM vtiger_reportfolder ORDER BY foldername ASC", array());
         $noOfFolders = $db->num_rows($result);
         if ($noOfFolders > 0) {
             for ($i = 0; $i < $noOfFolders; $i++) {
                 $folderModel = Reports_Folder_Model::getInstance();
                 $values = $db->query_result_rowdata($result, $i);
                 $folders[$values['folderid']] = $folderModel->setData($values);
                 Vtiger_Cache::set('reportsFolder', $values['folderid'], $folderModel);
             }
         }
         Vtiger_Cache::set('reports', 'folders', $folders);
     }
     return $folders;
 }
示例#4
0
 public function getRecordsListFromRequest(Vtiger_Request $request)
 {
     $folderId = $request->get('viewname');
     $module = $request->get('module');
     $selectedIds = $request->get('selected_ids');
     $excludedIds = $request->get('excluded_ids');
     if (!empty($selectedIds) && $selectedIds != 'all') {
         if (!empty($selectedIds) && count($selectedIds) > 0) {
             return $selectedIds;
         }
     }
     $reportFolderModel = Reports_Folder_Model::getInstance();
     $reportFolderModel->set('folderid', $folderId);
     if ($reportFolderModel) {
         return $reportFolderModel->getRecordIds($excludedIds, $module);
     }
 }
示例#5
0
 /**
  * Function to get the list view entries count
  * @return <Integer>
  */
 public function getListViewCount()
 {
     $reportFolderModel = Reports_Folder_Model::getInstance();
     $reportFolderModel->set('folderid', $this->get('folderid'));
     return $reportFolderModel->getReportsCount();
 }
示例#6
0
 /**
  * Function returns the report folders
  * @return <Array of Reports_Folder_Model>
  */
 function getFolders()
 {
     return Reports_Folder_Model::getAll();
 }
示例#7
0
 /**
  * Function returns the instance of Folder model
  * @param FolderId
  * @return <Reports_Folder_Model>
  */
 public static function getInstanceById($folderId)
 {
     $folderModel = Vtiger_Cache::get('reportsFolder', $folderId);
     if (!$folderModel) {
         $db = PearDatabase::getInstance();
         $folderModel = Reports_Folder_Model::getInstance();
         $result = $db->pquery("SELECT * FROM its4you_reports4you_folder WHERE folderid = ?", array($folderId));
         if ($db->num_rows($result) > 0) {
             $values = $db->query_result_rowdata($result, 0);
             $folderModel->setData($values);
         }
         Vtiger_Cache::set('reportsFolder', $folderId, $folderModel);
     }
     return $folderModel;
 }