Jobs deleting implented

This commit is contained in:
Karl Cordes 2011-06-17 10:54:09 +10:00
parent 7a9e1ef5d6
commit 20020655c0
7 changed files with 133 additions and 13 deletions

View file

@ -615,6 +615,44 @@ class JobsController extends AppController {
}
function markDeleted($id) {
$this->layout = 'ajax';
if(!$id) {
echo "FAILURE";
}
else {
$this->Job->read(null, $id);
$this->Job->set('deleted', true);
if($this->Job->save()) {
echo "SUCCESS";
}
else {
echo "FAILURE";
}
}
}
function markUndeleted($id) {
$this->layout = 'ajax';
if(!$id) {
echo "FAILURE";
}
else {
$this->Job->read(null, $id);
$this->Job->set('deleted', false);
if($this->Job->save()) {
echo "SUCCESS";
}
else {
echo "FAILURE";
}
}
}
/**
* Need to fix the customer_id which hasn't been set for these 500odd records.
*

View file

@ -1,5 +1,22 @@
<tr id="<?=$job['Job']['id']?>">
<td><button class="editButton">Edit</button></td>
<?
if($job['Job']['deleted'] == 1) {
$rowClass = 'deleted';
$button = '<button class="undeleteButton">Undelete</button>';
}
else {
$rowClass = '';
$button = '<button class="deleteButton">X</button>';
}
?>
<tr id="<?=$job['Job']['id']?>" class="<?=$rowClass?>">
<td>
<button class="editButton">Edit</button>
<?=$button?>
</td>
<td><?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?></td>
<td>
@ -23,15 +40,15 @@
<td><?
$poString = '';
foreach($job['PurchaseOrder'] as $po) {
$poString .= ' '.$html->link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));
$poString .= ' '.$html->link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));
}
echo $poString;
?>
</td>
<td class="nowrap"><?
foreach($job['PurchaseOrder'] as $po) {
echo $this->element('isEmptyDate', array('date'=>$po['issue_date']));
echo "<br>";
echo $this->element('isEmptyDate', array('date'=>$po['issue_date']));
echo "<br>";
}
?>
</td>
@ -42,8 +59,8 @@
<td> <?
foreach($job['PurchaseOrder'] as $po) {
echo $po['principle_reference'];
echo "<br>";
echo $po['principle_reference'];
echo "<br>";
}
?>
</td>
@ -100,5 +117,8 @@
</td>
<td> <?=$job['Job']['net_commissions'];?>
</td>
<td><button class="editButton">Edit</button></td>
<td>
<button class="editButton">Edit</button>
<?=$button?>
</td>
</tr>

View file

@ -12,6 +12,8 @@ echo $javascript->link('job_index');
<li><?=$html->link('Show only Unpaid', array('action'=>'index/1'));?></li>
<li><?=$html->link('Show only Unsent', array('action'=>'index/0/1'));?></li>
<li><?=$html->link('Show only Unpaid & Unsent', array('action'=>'index/1/1'));?></li>
<li><button id="showDeleted">Show Deleted Jobs</button>
<button id="hideDeleted">Hide Deleted Jobs</button></li>
</ul>
</div>
@ -75,13 +77,26 @@ echo $paginator->counter(array(
<? //echo $form->create('Job', array('action'=>'ajax_edit', 'class'=>'job_table_form', 'default'=>false));
?>
<? foreach($jobs as $job):?>
<? foreach($jobs as $job):
if($job['Job']['deleted'] == 1) {
$rowClass = 'deleted';
$button = '<button class="undeleteButton">Undelete</button>';
}
else {
$rowClass = '';
$button = '<button class="deleteButton">X</button>';
}
?>
<tr id="<?=$job['Job']['id']?>">
<td><button class="editButton">Edit</button></td>
<tr id="<?=$job['Job']['id']?>" class="<?=$rowClass?>">
<td>
<?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?></td>
<button class="editButton">Edit</button>
<?=$button?>
</td>
<td>
<?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?>
</td>
<td>
<?=$this->element('booleanTick', array('bool'=>$job['Job']['all_paid'])); ?>
</td>
@ -176,7 +191,10 @@ echo $paginator->counter(array(
</td>
<td> <?=$job['Job']['net_commissions'];?>
</td>
<td><button class="editButton">Edit</button></td>
<td>
<button class="editButton">Edit</button>
<?=$button?>
</td>
</tr>
<? endforeach;?>

View file

View file

View file

@ -1420,6 +1420,10 @@ tr.cancelled td {
text-decoration: line-through;
}
tr.deleted td {
text-decoration: line-through;
}
#reports h3 {
padding-top:0.5em;
}

View file

@ -4,6 +4,8 @@ $(function() {
// $(".editButton").show();
$(".deleted").hide();
$("#hideDeleted").hide();
$(".editButton").live('click',function() {
@ -24,6 +26,19 @@ $(function() {
});
$("#showDeleted").click(function() {
$(".deleted").show();
$(this).hide();
$("#hideDeleted").show();
});
$("#hideDeleted").click(function() {
$(".deleted").hide();
$(this).hide();
$("#showDeleted").show();
});
$(".saveButton").live('click',function() {
var id = $(this).parents('tr').attr('id');
var thisJobInputs = $('#'+id).find('input,select');
@ -57,6 +72,18 @@ $(function() {
});
$(".deleteButton").live('click', function() {
var id = $(this).parents('tr').attr('id');
markDeleted(id);
});
$(".undeleteButton").live('click', function() {
var id = $(this).parents('tr').attr('id');
markUndeleted(id);
})
//console.profileEnd();
});
@ -91,6 +118,19 @@ function cancelEditable(id) {
}
function markDeleted(id) {
$.get('/jobs/markDeleted/'+id,false, function(data) {
getViewable(id);
});
}
function markUndeleted(id) {
$.get('/jobs/markUndeleted/'+id,false, function(data) {
getViewable(id);
});
}
function getParent() {
}