Re-added comments to enq table and the little JS editor thing

This commit is contained in:
Karl Cordes 2011-03-16 15:26:51 +11:00
parent cde0312586
commit 00874d0495
3 changed files with 43 additions and 17 deletions

View file

@ -23,6 +23,7 @@ echo $paginator->counter(array(
<th><?php echo $paginator->sort('status_id');?></th>
<th>Comments</th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
@ -231,7 +232,15 @@ ENDJS;
echo $javascript->codeBlock($jsblock);
?>
</td>
<td class="comments"><?
if(strlen($enquiry['Enquiry']['comments']) > 150) {
echo substr($enquiry['Enquiry']['comments'], 0, 150);
echo $html->link('.....', array('controller'=>'enquiries','action'=>'view', $enquiry['Enquiry']['id']));
}
else {
echo $enquiry['Enquiry']['comments'];
}
;?></td>
<td class="viewedit">
<?php echo $html->link(__('View', true), array('controller'=>'enquiries','action'=>'view', $enquiry['Enquiry']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('controller'=>'enquiries','action'=>'edit', $enquiry['Enquiry']['id'])); ?>

View file

@ -34,11 +34,17 @@
*/
//echo $form->input('submitted');
echo $javascript->link('quotenik/add_datetime.js', true);
echo $form->input('comments', array('id'=>'comments', 'wrap'=>'hard'));
?>
<input type="BUTTON" onClick="datetime('<?php echo "$initials"; ?>');" value="Edit Comments" class="dateButton" id="datebutton"/>
<span id="userInitials" style="display: none;"><?=$initials?></span>
<button id ="dateButton">Edit Comments</button>
<?
echo $javascript->link('quotenik/add_datetime.js', true);
echo $form->input('posted', array('label' => 'This quote been sent hard copy via Post'));

View file

@ -1,23 +1,34 @@
/* Adds Date/Timestamp to a comments field when it's selected for modifiying. */
Event.observe(window, 'load', function() {
$('comments').disable();
$(function() {
$('#comments').attr('readonly', 'readonly');
var userinitials = $('#userInitials').html();
$('#dateButton').click(function() {
datetime(userinitials);
return false;
});
});
function datetime(userinitials) {
$('comments').enable();
$('datebutton').disable();
var currentTime = new Date();
month = currentTime.getMonth() + 1;
day = currentTime.getDate();
year = currentTime.getFullYear();
hour = currentTime.getHours();
minute = currentTime.getMinutes();
if(minute < 10) {
$('#comments').attr('readonly','');
$('#dateButton').button('disable');
var currentTime = new Date();
month = currentTime.getMonth() + 1;
day = currentTime.getDate();
year = currentTime.getFullYear();
hour = currentTime.getHours();
minute = currentTime.getMinutes();
if(minute < 10) {
minute = '0'+minute;
}
}
var newValue = '[' + day + '-' + month + '-' + year + ' @' + hour + ':' + minute +' '+ userinitials +']' + '\n' + $('#comments').val();
$('comments').value = '[' + day + '-' + month + '-' + year + ' @' + hour + ':' + minute +' '+ userinitials +']' + '\n' + $('comments').value;
$('#comments').val(newValue);
return false;
}