diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php
index d46179ba..060fdc3e 100755
--- a/controllers/jobs_controller.php
+++ b/controllers/jobs_controller.php
@@ -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() {
diff --git a/views/enquiries/view.ctp b/views/enquiries/view.ctp
index bf5fcdc5..820bbac5 100755
--- a/views/enquiries/view.ctp
+++ b/views/enquiries/view.ctp
@@ -208,8 +208,9 @@ $class = ' class="altrow"';?>
+ =$javascript->link('add_job');?>
- - link(__('New Job', true), array('controller'=>'jobs', 'action' => 'add/enquiryid:'.$enquiry['Enquiry']['id'])); ?>
+
diff --git a/views/jobs/ajax_add.ctp b/views/jobs/ajax_add.ctp
new file mode 100644
index 00000000..e69de29b
diff --git a/views/layouts/default.ctp b/views/layouts/default.ctp
index 6624dd7b..9a5608a6 100755
--- a/views/layouts/default.ctp
+++ b/views/layouts/default.ctp
@@ -64,7 +64,14 @@
link('Jobs', '/jobs/index'); ?>
+
+
+ if($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin' ):
+ ?>
+ - =$html->link('Reports','/jobs/reports');?>
+ endif;?>
- link('Job List', '/jobs/index'); ?>
+
diff --git a/webroot/js/add_job.js b/webroot/js/add_job.js
new file mode 100644
index 00000000..d1facb8b
--- /dev/null
+++ b/webroot/js/add_job.js
@@ -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';
+ });
+
+ }
+
+});
\ No newline at end of file
diff --git a/webroot/js/addjob.js b/webroot/js/addjob.js
deleted file mode 100755
index 21d3c402..00000000
--- a/webroot/js/addjob.js
+++ /dev/null
@@ -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'
-
- });
-
-
-
-
-
-
-
-});
\ No newline at end of file