/** * @group 61144 */ public function testDeleteRelateDocumentRevision() { $this->revision->mark_deleted($this->revision->id); $actual = $this->revision->get_document_revision_name($this->revision->id); $this->assertEmpty($actual, 'Deleted data is returned'); }
function oqc_cleanup_document_revision($id) { $contract = new $this->object_name(); if ($contract->retrieve($id)) { if (!empty($contract->document_id)) { $document = new Document(); if ($document->retrieve($contract->document_id)) { if (!empty($document->document_revision_id)) { $revision = new DocumentRevision(); if ($revision->retrieve($document->document_revision_id)) { if ($revision->revision == $contract->version) { $revision->mark_deleted($revision->id); } } $document->document_revision_id = ''; //$document->document_revision_id = null; $document->save(); } } } } }
* * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not * reasonably feasible for technical reasons, the Appropriate Legal Notices must * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". ********************************************************************************/ /********************************************************************************* * Description: Deletes an Account record and then redirects the browser to the * defined return URL. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ global $mod_strings; if (!isset($_REQUEST['record'])) { sugar_die($mod_strings['ERR_DELETE_RECORD']); } $focus = new Document(); $focus->retrieve($_REQUEST['record']); if (!$focus->ACLAccess('Delete')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } if (isset($_REQUEST['object']) && ($_REQUEST['object'] = "documentrevision")) { //delete document revision. $focus = new DocumentRevision(); UploadFile::unlink_file($_REQUEST['revision_id'], $_REQUEST['filename']); } $focus->mark_deleted($_REQUEST['record']); header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
function createPdf($contract) { //1.7.6 fix for document category global $timedate; global $app_list_strings; global $current_user; global $sugar_config; $beanname = get_class($contract); $document_category = substr(trim($beanname), 4); if ($document_category == 'Offering') { $document_category = 'Quote'; } $oqc_run = false; //Try to find if some version of contract had document_id created if ($contract->document_id == null) { $legacy_document_id = $contract->find_document_id($contract); $contract->document_id = $legacy_document_id; $GLOBALS['log']->error('OQC: Found contract_id! ' . $contract->document_id); if (!empty($contract->document_id)) { $oqc_run = true; } } //$conf = Configuration::getInstance(); if (DEBUG_PDF_CREATION) { $oqc_run = true; } $document = new Document(); if (!$document->retrieve($contract->document_id)) { //Creating document name for the first time $document->document_name = $document_category . 'Pdf-' . $contract->svnumber; $document->category_id = $document_category; $document->subcategory_id = 'Pdf'; $document->active_date = date($timedate->get_date_format()); $document->status_id = "Active"; $document->document_purpose_c = "Customer"; $document->assigned_user_id = $current_user->id; // create an id for this new document $document->save(); $document->new_with_id = false; //1.7.8 Since sugar 6.2 document saving generated error- this is fix for it $oqc_done = createNewRevision($contract, $document); } else { $revision = new DocumentRevision(); if (!$document->document_revision_id) { $oqc_run = true; } $revision->retrieve($document->document_revision_id); if ($contract->version == $revision->revision && $oqc_run == false) { //SET TO TRUE FOR PDF CREATION INDEPENDENT ON VERSION // do not create new revision since pdf file is already created for this revision. Normally, only one pdf // file can be created for each revision. $GLOBALS['log']->fatal('OQC: File already exist -skip file conversion to PDF!'); header("Location:index.php?entryPoint=download&id={$document->document_revision_id}&type=Documents"); exit; } else { if ($contract->version == $revision->revision && $oqc_run == true) { $revision->mark_deleted($revision->id); $GLOBALS['log']->error('OQC: Deleted inactive document revision!'); } $document->active_date = date($timedate->get_date_format()); $document->status_id = 'Active'; $document->assigned_user_id = $current_user->id; $document->save(); $document->new_with_id = false; $oqc_done = createNewRevision($contract, $document); } } if ($oqc_done) { $document->save(); $documents = 'documents'; $contract->load_relationship($documents); $contract->documents->add($document->id); $contract->document_id = $document->id; $contract->save(); header("Location: index.php?action=DetailView&module=DocumentRevisions&record={$document->document_revision_id}"); exit; } else { if (!$contract->document_id) { $document->mark_deleted($document->id); //This was new document, so delete it if pdf creation fails } echo "<html>\n\t\t\tPdf creation failed. Set debugPdfCreation=1 in config file and re-run creation of pdf file to get error log. </br>\n\t\t\t<a href=\"{$sugar_config['site_url']}/index.php?action=DetailView&module={$beanname}&record={$contract->id}\">Return to previuos page</a>\n\t\t\t</html>"; exit; } }