/** * Public function for deleting a document. Deletes the document from * the database and the virtual file system (vfs). * * @param HTTP::id the document id * @return true if successful, false if error, permission denied message on * not enough privileges */ public function delete() { $document_id = intval(phpgw::get_var('id')); $document = rental_sodocument::get_instance()->get_single($document_id); $document_properties = $this->get_type_and_id($document); if (!$this->check_permissions($document, $document_properties)) { $this->render('permission_denied.php'); return; } $result = rental_sodocument::get_instance()->delete_document_from_vfs($document_properties['document_type'], $document_properties['id'], $document->get_name()); if ($result) { return rental_sodocument::get_instance()->delete_document($document_id); } // TODO: communicate error/message to user return false; }
echo lang('filters'); ?> </h3> <label class="toolbar_element_label" for="<?php echo $list_id; ?> _ctrl_toggle_document_type"><?php echo lang('document_type'); ?> </label> <select name="document_type" id="<?php echo $list_id; ?> _ctrl_toggle_document_type"> <?php $types = rental_sodocument::get_instance()->get_document_types(); foreach ($types as $id => $label) { ?> <option value="<?php echo $id; ?> "><?php echo lang($label); ?> </option><?php } ?> <option value="all" selected="selected"><?php echo lang('all'); ?> </option>
public function savePDFToContract($file, $contract_id, $title) { //Create a document object $document = new rental_document(); $document->set_title($title); $document->set_name("Kontrakt_" . strtotime(date('Y-m-d')) . ".pdf"); $document->set_type_id(1); $document->set_contract_id($contract_id); $document->set_party_id(NULL); //Retrieve the document properties $document_properties = $this->get_type_and_id($document); // Move file from temporary storage to vfs $result = rental_sodocument::get_instance()->write_document_to_vfs($document_properties['document_type'], $file, $document_properties['id'], "Kontrakt_" . strtotime(date('Y-m-d')) . ".pdf"); if ($result) { if (rental_sodocument::get_instance()->store($document)) { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'rental.uicontract.edit', 'id' => $contract_id, 'tab' => 'documents')); } else { // Handle failure on storing document $this->redirect($document, $document_properties, '', ''); } } else { //Handle vfs failure to store document $this->redirect($document, $document_properties, '', ''); } return false; }