Ejemplo n.º 1
0
 public function delete($request)
 {
     $moduleName = $request->getModule();
     $folderId = $request->get('folderid');
     $result = array();
     if (!empty($folderId)) {
         $folderModel = Documents_Folder_Model::getInstanceById($folderId);
         if (!$folderModel->hasDocuments()) {
             $folderModel->delete();
             $result = array('success' => true, 'message' => vtranslate('LBL_FOLDER_DELETED', $moduleName));
         } else {
             $result = array('success' => false, 'message' => vtranslate('LBL_FOLDER_HAS_DOCUMENTS', $moduleName));
         }
     }
     $response = new Vtiger_Response();
     $response->setResult($result);
     $response->emit();
 }
Ejemplo n.º 2
0
 public function getListDocForModule($moduleName, $forCheck = false)
 {
     $db = PearDatabase::getInstance();
     // $this->createFunctionName('is not');
     $sql = "SELECT " . "vtiger_ossdocumentcontrol.ossdocumentcontrolid as id, " . "vtiger_ossdocumentcontrol.doc_name as doc_name, " . "vtiger_ossdocumentcontrol.doc_request as doc_request, " . "vtiger_ossdocumentcontrol.doc_folder as doc_folder " . "FROM vtiger_ossdocumentcontrol " . "WHERE module_name = ? ";
     if ($forCheck) {
         $sql .= " AND vtiger_ossdocumentcontrol.doc_request = '1'";
     }
     $sql .= " ORDER BY vtiger_ossdocumentcontrol.doc_order ASC";
     $result = $db->pquery($sql, array($moduleName), TRUE);
     $output = array();
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $output[$i]['doc_id'] = $db->query_result($result, $i, 'id');
         $output[$i]['doc_name'] = $db->query_result($result, $i, 'doc_name');
         $output[$i]['doc_request'] = $db->query_result($result, $i, 'doc_request');
         $folderId = $db->query_result($result, $i, 'doc_folder');
         $folderModel = Documents_Folder_Model::getInstanceById($folderId);
         $output[$i]['doc_folder'] = $folderId;
         $output[$i]['folder_name'] = $folderModel->getName();
     }
     return $output;
 }