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 @@ - link($customers[$job['Enquiry']['customer_id']], array('controller'=>'customers', - 'action'=>'view', $job['Enquiry']['customer_id'])); ?> + link($job['Customer']['name'], array('controller'=>'customers', + 'action'=>'view', $job['Job']['customer_id'])); ?> diff --git a/views/jobs/fix_jobs.ctp b/views/jobs/fix_jobs.ctp new file mode 100644 index 00000000..6e3bafdf --- /dev/null +++ b/views/jobs/fix_jobs.ctp @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
idcustomer_idEnq Cust IDstate_idEnq State IDcontact_idEnq Contact ID
+ + + \ No newline at end of file diff --git a/views/jobs/index.ctp b/views/jobs/index.ctp index 0ca9c89f..2428abd2 100755 --- a/views/jobs/index.ctp +++ b/views/jobs/index.ctp @@ -61,8 +61,8 @@ - link($customers[$job['Enquiry']['customer_id']], array('controller'=>'customers', - 'action'=>'view', $job['Enquiry']['customer_id'])); ?> + link($job['Customer']['name'], array('controller'=>'customers', + 'action'=>'view', $job['Job']['customer_id'])); ?>