diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index 20bada3e..5a9ff4da 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -66,7 +66,9 @@ class JobsController extends AppController { $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']; @@ -189,9 +191,24 @@ class JobsController extends AppController { * * Will fetch the right ID the same way the Index does, then update each record. */ - function fixCustomerIDs() { + function fixJobs() { + + $jobs = $this->Job->find('all'); + + foreach($jobs as $job) { + $this->Job->id = $job['Job']['id']; + $this->data = $job; + + $this->data['Job']['customer_id'] = $job['Enquiry']['customer_id']; + $this->data['Job']['state_id'] = $job['Enquiry']['state_id']; + $this->data['Job']['contact_id'] = $job['Enquiry']['contact_id']; + $this->Job->save($this->data); + + } + + $this->set('jobs', $this->Job->find('all')); + - } } ?> \ No newline at end of file diff --git a/models/job.php b/models/job.php index ca106f8e..f0faf131 100755 --- a/models/job.php +++ b/models/job.php @@ -29,7 +29,15 @@ class Job extends AppModel { 'counterCache' => true ), - 'Currency' + 'Currency' => array( + 'className' => 'Currency', + 'foreignKey' => 'currency_id' + ), + + 'Customer' => array( + 'className' => 'Customer', + 'foreignKey' => 'customer_id' + ) ); var $hasAndBelongsToMany = array( diff --git a/views/elements/job_table.ctp b/views/elements/job_table.ctp index c416dad1..e87305cf 100644 --- a/views/elements/job_table.ctp +++ b/views/elements/job_table.ctp @@ -58,8 +58,8 @@
| id | + +customer_id | +Enq Cust ID | + +state_id | +Enq State ID | +contact_id | +Enq Contact ID | +
|---|---|---|---|---|---|---|
| =$job['Job']['id'];?> | + +=$job['Job']['customer_id'];?> | +=$job['Enquiry']['customer_id'];?> | + +=$job['Job']['state_id']?> | +=$job['Enquiry']['state_id']?> | + +=$job['Job']['contact_id']?> | +=$job['Enquiry']['contact_id']?> | +