ajax_add Job added
This commit is contained in:
parent
0f4ec7d6a4
commit
3065fd1daa
|
|
@ -296,7 +296,7 @@ class JobsController extends AppController {
|
|||
|
||||
function ajax_edit() {
|
||||
if(!empty($this->data)) {
|
||||
print_r($this->data);
|
||||
//print_r($this->data);
|
||||
if ($this->Job->save($this->data)) {
|
||||
echo "SUCCESS";
|
||||
}
|
||||
|
|
@ -347,6 +347,43 @@ class JobsController extends AppController {
|
|||
|
||||
}
|
||||
|
||||
|
||||
function ajax_add($enquiryID) {
|
||||
$this->layout = 'ajax';
|
||||
|
||||
if(!isset($enquiryID)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
$this->Job->create();
|
||||
|
||||
$job_offset = 6141;
|
||||
|
||||
$number_of_jobs = $this->Job->findCount();
|
||||
$new_job_number = $job_offset + $number_of_jobs;
|
||||
|
||||
$enquiry = $this->Job->Enquiry->findById($enquiryID);
|
||||
$monthYearShort = strtoupper(date("My"));
|
||||
|
||||
$jobLetter = $enquiry['State']['enqform'];
|
||||
|
||||
$this->data['Job']['title'] = $monthYearShort.$jobLetter."J".$new_job_number;
|
||||
$this->data['Job']['state_id'] = $enquiry['Enquiry']['state_id'];
|
||||
$this->data['Job']['customer_id'] = $enquiry['Enquiry']['customer_id'];
|
||||
$this->data['Job']['contact_id'] = $enquiry['Enquiry']['contact_id'];
|
||||
$this->data['Job']['enquiry_id'] = $enquiry['Enquiry']['id'];
|
||||
|
||||
if ($this->Job->save($this->data)) {
|
||||
echo "SUCCESS";
|
||||
}
|
||||
else {
|
||||
echo "FAILURE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function add() {
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -208,8 +208,9 @@ $class = ' class="altrow"';?>
|
|||
|
||||
</div>
|
||||
<div class="actions">
|
||||
<?=$javascript->link('add_job');?>
|
||||
<ul>
|
||||
<li> <?php echo $html->link(__('New Job', true), array('controller'=>'jobs', 'action' => 'add/enquiryid:'.$enquiry['Enquiry']['id'])); ?></li>
|
||||
<li><button class="addJob" id="<?=$enquiry['Enquiry']['id'];?>">Add Job</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
0
views/jobs/ajax_add.ctp
Normal file
0
views/jobs/ajax_add.ctp
Normal file
|
|
@ -64,7 +64,14 @@
|
|||
|
||||
<li><?php echo $html->link('Jobs', '/jobs/index'); ?>
|
||||
<ul>
|
||||
|
||||
<?
|
||||
if($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin' ):
|
||||
?>
|
||||
<li><?=$html->link('Reports','/jobs/reports');?></li>
|
||||
<? endif;?>
|
||||
<li class="last"><?php echo $html->link('Job List', '/jobs/index'); ?></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
|
|
|||
20
webroot/js/add_job.js
Normal file
20
webroot/js/add_job.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
$(function() {
|
||||
$(".addJob").click(function() {
|
||||
$(".addJob").button('disable');
|
||||
addJob();
|
||||
});
|
||||
|
||||
// $(".addJob").dblclick(addJob);
|
||||
|
||||
|
||||
function addJob() {
|
||||
|
||||
var enquiryID = $(".addJob").attr("id");
|
||||
|
||||
$.post('/jobs/ajax_add/'+enquiryID, function(data) {
|
||||
window.location.href = '/jobs';
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/**
|
||||
* file: addjob.js
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
|
||||
|
||||
$('#JobDateOrderReceivedDisplay').datepicker({
|
||||
showButtonPanel: true,
|
||||
dateFormat: 'DD d MM yy',
|
||||
altFormat: 'yy-mm-dd',
|
||||
altField: '#JobDateOrderReceived'
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$('#JobDateOrderSentToCustomerDisplay').datepicker({
|
||||
showButtonPanel: true,
|
||||
dateFormat: 'DD d MM yy',
|
||||
altFormat: 'yy-mm-dd',
|
||||
altField: '#JobDateOrderSentToCustomer'
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue