function processView() { $this->_note =& $GLOBALS['system']->getDBObject($_REQUEST['note_type'] . '_note', (int) $_REQUEST['noteid']); if (!empty($_POST['delete_note']) && $this->_note->canBeDeleted()) { if ($this->_note->delete()) { add_message('Note deleted', 'success'); $this->redirectAfterEdit(); } else { add_message('Failed to delete note', 'failure'); } return; } $note_type = $_REQUEST['note_type'] == 'family' ? 'family_note' : 'person_note'; $this->_note =& $GLOBALS['system']->getDBObject($note_type, $_REQUEST['noteid']); if ($_REQUEST['note_type'] == 'family') { $this->_family =& $GLOBALS['system']->getDBObject('family', $this->_note->getValue('familyid')); } else { $this->_person =& $GLOBALS['system']->getDBObject('person', $this->_note->getValue('personid')); } if (!empty($_POST['update_note_submitted'])) { $GLOBALS['system']->doTransaction('begin'); $success = TRUE; if ($this->_note->haveLock()) { $fieldsToSave = array_keys($this->_note->fields); if (!$this->_note->canEditOriginal()) { $fieldsToSave = array_diff($fieldsToSave, array('subject', 'details')); } $this->_note->processForm('', $fieldsToSave); if (!$this->_note->save()) { $success = FALSE; } if ($success) { $GLOBALS['system']->includeDBClass('note_comment'); $comment = new Note_Comment(); $comment->processForm(); if (trim($comment->getValue('contents')) != '') { $comment->setValue('noteid', $this->_note->id); if (!$comment->create()) { $success = FALSE; } } } } else { add_message('Lock on note object not held', 'failure'); $success = FALSE; } if ($success) { $this->_note->releaseLock(); $GLOBALS['system']->doTransaction('commit'); add_message('Note Updated'); $this->redirectAfterEdit(); } else { add_message('Errors while processing, could not save changes', 'failure'); $GLOBALS['system']->doTransaction('rollback'); } } }
function printUpdateForm() { ?> <form method="post" id="update-note" class="form-horizontal"> <input type="hidden" name="update_note_submitted" value="1" /> <div class="control-group"> <label class="control-label">Comment</label> <div class="controls"> <?php $GLOBALS['system']->includeDBClass('note_comment'); $comment = new Note_Comment(); $comment->printFieldInterface('contents'); ?> </div> </div> <div class="control-group"> <label class="control-label">Status</label> <div class="controls"> <?php $this->printFieldInterface('status'); ?> </div> </div> <div class="control-group"> <label class="control-label">Assignee</label> <div class="controls"> <?php $this->printFieldInterface('assignee'); ?> </div> </div> <div class="control-group"> <label class="control-label">Action Date</label> <div class="controls"> <?php echo $this->printFieldInterface('action_date'); ?> <div class="help-inline"><?php echo ents($this->fields['action_date']['note']); ?> </div> </div> </div> <div class="control-group"> <div class="controls"> <input type="submit" class="btn" value="Save" /> <input type="button" value="Cancel" class="btn back" /> <?php if ($this->canBeDeleted()) { ?> <input type="submit" name="delete_note" data-confirm="Notes are designed to accumulate as a historical record, and should usually only be deleted to correct a mistake. Are you sure you want to delete this note?" class="pull-right btn" value="Delete this note" /> <?php } ?> </div> </div> </form> <script type="text/javascript"> setTimeout('showLockExpiryWarning()', <?php echo (strtotime('+' . LOCK_LENGTH, 0) - 60) * 1000; ?> ); setTimeout('showLockExpiredWarning()', <?php echo strtotime('+' . LOCK_LENGTH, 0) * 1000; ?> ); /*$(window).load(function() { setTimeout("$('[name=contents]').focus()", 100); });*/ </script> <?php }
function printUpdateForm() { ?> <form method="post" id="update-note" class="form-horizontal" data-lock-length="<?php echo LOCK_LENGTH; ?> "> <input type="hidden" name="update_note_submitted" value="1" /> <div class="control-group"> <label class="control-label">Comment</label> <div class="controls"> <?php $GLOBALS['system']->includeDBClass('note_comment'); $comment = new Note_Comment(); $comment->printFieldInterface('contents'); ?> </div> </div> <div class="control-group"> <label class="control-label">Status</label> <div class="controls"> <?php $this->printFieldInterface('status'); ?> </div> </div> <div class="control-group"> <label class="control-label">Assignee</label> <div class="controls"> <?php $this->printFieldInterface('assignee'); ?> </div> </div> <div class="control-group"> <label class="control-label">Action Date</label> <div class="controls"> <?php echo $this->printFieldInterface('action_date'); ?> <div class="help-inline"><?php echo ents($this->fields['action_date']['note']); ?> </div> </div> </div> <div class="control-group"> <div class="controls"> <input type="submit" class="btn" value="Save" /> <input type="button" value="Cancel" class="btn back" /> <?php if ($this->canBeDeleted()) { ?> <input type="submit" name="delete_note" data-confirm="Notes are designed to accumulate as a historical record, and should usually only be deleted to correct a mistake. Are you sure you want to delete this note?" class="pull-right btn" value="Delete this note" /> <?php } ?> </div> </div> </form> <?php }