2010-05-03 23:49:57 -07:00
|
|
|
<?php
|
|
|
|
|
class JobsController extends AppController {
|
|
|
|
|
|
|
|
|
|
var $name = 'Jobs';
|
2011-04-07 03:21:46 -07:00
|
|
|
var $helpers = array('Html', 'Form', 'Text', 'Javascript', 'Number');
|
2010-05-03 23:49:57 -07:00
|
|
|
|
2010-09-06 20:57:28 -07:00
|
|
|
var $components = array('RequestHandler');
|
2010-07-07 23:25:55 -07:00
|
|
|
|
2011-03-13 17:21:56 -07:00
|
|
|
var $paginate = array(
|
|
|
|
|
|
|
|
|
|
'contain' => false,
|
|
|
|
|
'limit' => 100,
|
|
|
|
|
'order'=>array('Job.id' => 'desc')
|
2010-07-07 23:25:55 -07:00
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
2011-04-12 18:26:38 -07:00
|
|
|
function index($showUnpaid = null, $showUnsent = null) {
|
2011-04-04 01:48:58 -07:00
|
|
|
$this->Job->recursive = 1;
|
2011-04-12 18:26:38 -07:00
|
|
|
|
2011-04-15 00:34:51 -07:00
|
|
|
|
2011-04-12 18:26:38 -07:00
|
|
|
|
2011-04-12 18:28:45 -07:00
|
|
|
if(!empty($showUnpaid) && !empty($showUnsent)) {
|
2011-04-12 18:26:38 -07:00
|
|
|
|
|
|
|
|
$conditions = array(
|
|
|
|
|
'Job.all_paid' => 0,
|
|
|
|
|
'Job.all_sent' => 0,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 18:28:45 -07:00
|
|
|
else if(!empty($showUnpaid)) {
|
2011-04-12 18:26:38 -07:00
|
|
|
$conditions = array(
|
|
|
|
|
'Job.all_paid' => 0,
|
2011-04-15 00:34:51 -07:00
|
|
|
|
2011-04-12 18:26:38 -07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 18:28:45 -07:00
|
|
|
else if(!empty($showUnsent)) {
|
2011-04-12 18:26:38 -07:00
|
|
|
$conditions = array(
|
|
|
|
|
'Job.all_sent' => 0,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$conditions = array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->set('jobs', $this->paginate($conditions));
|
|
|
|
|
|
2011-03-13 17:21:56 -07:00
|
|
|
$this->set('customers', $this->Job->Enquiry->Customer->find('list'));
|
2011-04-04 01:48:58 -07:00
|
|
|
$this->set('currencies', $this->Job->Currency->find('list'));
|
2011-04-19 01:07:27 -07:00
|
|
|
$this->set('principleList',$this->Job->Enquiry->Principle->find('list'));
|
|
|
|
|
|
2011-03-22 00:05:56 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
$this->set('sale_category_options', $this->sale_category_options());
|
|
|
|
|
$this->set('sale_category_array', $this->sale_category_array());
|
|
|
|
|
$this->set('job_type_options', $this->job_type_options());
|
2011-04-14 17:49:42 -07:00
|
|
|
$this->set('shipment_category_options', $this->shipment_category_options());
|
2011-04-05 00:38:18 -07:00
|
|
|
$this->set('freight_paid_by_options',$this->freight_paid_options());
|
|
|
|
|
$this->set('gst_options', $this->gst_options());
|
2011-03-28 18:47:50 -07:00
|
|
|
|
2011-03-28 21:19:59 -07:00
|
|
|
}
|
2011-03-28 18:47:50 -07:00
|
|
|
|
2011-04-05 17:22:45 -07:00
|
|
|
/** Called via AJAX to get an editable row */
|
|
|
|
|
function getEditableRow($id) {
|
|
|
|
|
$this->layout = 'ajax';
|
2011-04-12 18:26:38 -07:00
|
|
|
|
2011-04-11 21:54:06 -07:00
|
|
|
$job = $this->Job->find('first', array('conditions'=>array('Job.id'=>$id)));
|
|
|
|
|
|
|
|
|
|
$this->set('job', $job);
|
|
|
|
|
|
|
|
|
|
$this->data = $job;
|
|
|
|
|
|
2011-04-14 17:49:42 -07:00
|
|
|
$this->set('shipment_category_options', $this->shipment_category_options());
|
2011-04-11 21:54:06 -07:00
|
|
|
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
2011-04-05 22:58:43 -07:00
|
|
|
$this->set('currencies', $this->Job->Currency->find('list'));
|
2011-04-05 17:22:45 -07:00
|
|
|
$this->set('sale_category_options', $this->sale_category_options());
|
|
|
|
|
$this->set('sale_category_array', $this->sale_category_array());
|
|
|
|
|
$this->set('job_type_options', $this->job_type_options());
|
|
|
|
|
$this->set('freight_paid_by_options',$this->freight_paid_options());
|
|
|
|
|
$this->set('gst_options', $this->gst_options());
|
2011-04-05 22:58:43 -07:00
|
|
|
$this->set('job_status_options', $this->job_status_options());
|
2011-04-19 01:15:26 -07:00
|
|
|
$this->set('principleList',$this->Job->Enquiry->Principle->find('list'));
|
2011-04-05 17:22:45 -07:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Called via AJAX to get an viewable row */
|
|
|
|
|
function getViewableRow($id) {
|
|
|
|
|
$this->layout = 'ajax';
|
|
|
|
|
$this->set('job', $this->Job->find('first', array('conditions'=>array('Job.id'=>$id))));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->set('sale_category_options', $this->sale_category_options());
|
|
|
|
|
$this->set('sale_category_array', $this->sale_category_array());
|
|
|
|
|
$this->set('job_type_options', $this->job_type_options());
|
2011-04-14 17:49:42 -07:00
|
|
|
$this->set('shipment_category_options', $this->shipment_category_options());
|
2011-04-05 17:22:45 -07:00
|
|
|
$this->set('freight_paid_by_options',$this->freight_paid_options());
|
|
|
|
|
$this->set('gst_options', $this->gst_options());
|
2011-04-19 01:15:26 -07:00
|
|
|
$this->set('principleList',$this->Job->Enquiry->Principle->find('list'));
|
2011-04-06 19:26:26 -07:00
|
|
|
|
2011-04-05 17:22:45 -07:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-04-06 00:03:07 -07:00
|
|
|
function reports() {
|
2011-04-06 19:26:26 -07:00
|
|
|
$this->Job->recursive = 0;
|
|
|
|
|
|
|
|
|
|
$jobs = $this->Job->find('all', array('fields'=>array('Job.date_order_received'), 'order'=>array('Job.date_order_received'=>'asc')));
|
|
|
|
|
|
|
|
|
|
$monthList = $this->getYearMonths($jobs);
|
|
|
|
|
|
|
|
|
|
$this->set('monthList', $monthList);
|
|
|
|
|
/* $this->set('jobs', $jobs);
|
2011-04-06 00:03:07 -07:00
|
|
|
$this->set('customers', $this->Job->Enquiry->Customer->find('list'));
|
2011-04-06 19:26:26 -07:00
|
|
|
$this->set('currencies', $this->Job->Currency->find('list'));*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 00:03:07 -07:00
|
|
|
|
2011-04-06 19:26:26 -07:00
|
|
|
|
|
|
|
|
function viewReport($year, $month) {
|
|
|
|
|
$this->layout = 'ajax';
|
|
|
|
|
|
|
|
|
|
$this->set('year', $year);
|
|
|
|
|
$this->set('month', $month);
|
|
|
|
|
|
2011-04-07 01:52:01 -07:00
|
|
|
|
|
|
|
|
if(isset($month) && isset($year)) { //After a Specific Month for a Year
|
|
|
|
|
|
|
|
|
|
$nMonth = date('m',strtotime($month));
|
|
|
|
|
|
|
|
|
|
$startDate = $year.'-'.$nMonth.'-01';
|
|
|
|
|
|
|
|
|
|
$startDateTime = strtotime($startDate);
|
|
|
|
|
|
|
|
|
|
$numberOfDaysInMonth = date('t', $startDateTime);
|
|
|
|
|
|
2011-04-11 21:54:06 -07:00
|
|
|
$endDate = $year.'-'.$nMonth.'-'.$numberOfDaysInMonth;
|
2011-04-07 01:52:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-11 21:54:06 -07:00
|
|
|
$jobs = $this->Job->find('all', array('conditions'=>
|
|
|
|
|
array('Job.date_order_received BETWEEN ? AND ?'=>array($startDate, $endDate))));
|
2011-04-07 01:52:01 -07:00
|
|
|
|
2011-04-11 21:54:06 -07:00
|
|
|
$this->set('jobs', $jobs);
|
2011-04-07 01:52:01 -07:00
|
|
|
|
2011-04-11 21:54:06 -07:00
|
|
|
$this->set('principleList',$this->Job->Enquiry->Principle->find('list'));
|
2011-04-07 01:52:01 -07:00
|
|
|
|
2011-04-11 21:54:06 -07:00
|
|
|
$this->set('startDate',$startDate);
|
|
|
|
|
$this->set('endDate',$endDate);
|
2011-04-07 01:52:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elseif(isset($year) && !isset($month)) { //After a whole Years Stats.
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
echo "Failure";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//$this->set('jobs', )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-06 19:26:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build an array of Years/Months with Jobs.
|
|
|
|
|
*
|
|
|
|
|
* Currently used in reports.ctp to build the Navigation list.
|
|
|
|
|
*
|
|
|
|
|
* @param Array $jobs
|
|
|
|
|
* @return Array
|
|
|
|
|
*/
|
|
|
|
|
function getYearMonths($jobs) {
|
|
|
|
|
$weekList = array();
|
|
|
|
|
foreach($jobs as $job) {
|
|
|
|
|
$time = strtotime($job['Job']['date_order_received']);
|
|
|
|
|
$year = date('Y', $time); //ISO-8601 year number
|
|
|
|
|
$month = date('F', $time);
|
2011-04-07 01:52:01 -07:00
|
|
|
//$monthList[$year][$month][] = $job;
|
|
|
|
|
|
|
|
|
|
if(!isset($monthList[$year][$month])) {
|
|
|
|
|
$monthList[$year][$month] = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$monthList[$year][$month]++;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 19:26:26 -07:00
|
|
|
}
|
|
|
|
|
krsort($monthList);
|
|
|
|
|
|
|
|
|
|
return $monthList;
|
2011-04-06 00:03:07 -07:00
|
|
|
}
|
|
|
|
|
|
2011-04-05 17:22:45 -07:00
|
|
|
|
2011-04-05 22:58:43 -07:00
|
|
|
function job_status_options() {
|
|
|
|
|
$options = array('ORDER RECEIVED FROM CUSTOMER',
|
2011-04-06 19:26:26 -07:00
|
|
|
'ORDER PLACED ON PRINCIPLE - WAITING ON DELIVERY',
|
2011-04-11 21:54:06 -07:00
|
|
|
'GOODS SHIPPED TO CUSTOMER',
|
|
|
|
|
'WAITING ON DELIVERY',
|
|
|
|
|
'MULTIPLE SHIPMENTS CMC WAITING ON ANOTHER DELIVERY',
|
|
|
|
|
'GOODS DELIVERED TO CUSTOMER',
|
2011-04-06 19:26:26 -07:00
|
|
|
'JOB CANCELLED',
|
|
|
|
|
'JOB ON HOLD',
|
2011-04-11 21:54:06 -07:00
|
|
|
'CUSTOMER TO PAY 100% WITH ORDER'
|
|
|
|
|
);
|
2011-04-06 19:26:26 -07:00
|
|
|
$options = $this->buildEnumOpts($options);
|
|
|
|
|
return $options;
|
2011-04-05 22:58:43 -07:00
|
|
|
}
|
|
|
|
|
|
2011-03-22 00:05:56 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
/**
|
|
|
|
|
* For the 'sale_category' column.
|
|
|
|
|
*/
|
|
|
|
|
function sale_category_options() {
|
2011-03-28 18:47:50 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
$options['Australian Sale'] = array(
|
2011-04-14 17:49:42 -07:00
|
|
|
0 => "AS: Australian Customer & Australian Destination (GST Applies)",
|
|
|
|
|
1 => "AS: Overseas Customer & Australian Destination (GST Applies)",
|
|
|
|
|
2 => "AS: Commission from Australian Company or Supplier (GST Applies)",
|
2011-03-28 18:47:50 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
);
|
2011-03-28 18:47:50 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
$options['Exports'] = array(
|
2011-04-14 17:49:42 -07:00
|
|
|
3 => "EX: Overseas Customer & Overseas Destination (no GST)",
|
|
|
|
|
4 => "EX: Australian Customer & Overseas Destination (no GST)",
|
|
|
|
|
5 => "EX: Commission from Overseas Company (no GST)"
|
2011-04-05 00:38:18 -07:00
|
|
|
);
|
2011-03-28 18:47:50 -07:00
|
|
|
|
|
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
return $options;
|
|
|
|
|
}
|
2011-03-28 21:19:59 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
/** For viewing the sale Cat */
|
|
|
|
|
function sale_category_array() {
|
|
|
|
|
$options = array(
|
2011-04-14 17:49:42 -07:00
|
|
|
0 => "AS: Australian Customer & Australian Destination (GST Applies)",
|
|
|
|
|
1 => "AS: Overseas Customer & Australian Destination (GST Applies)",
|
|
|
|
|
2 => "AS: Commission from Australian Company or Supplier (GST Applies)",
|
|
|
|
|
3 => "EX: Overseas Customer & Overseas Destination (no GST)",
|
|
|
|
|
4 => "EX: Australian Customer & Overseas Destination (no GST)",
|
|
|
|
|
5 => "EX: Commission from Overseas Company (no GST)"
|
2011-04-05 00:38:18 -07:00
|
|
|
);
|
2011-03-28 18:47:50 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
return $options;
|
2011-03-28 18:47:50 -07:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 17:49:42 -07:00
|
|
|
|
2011-04-15 00:34:51 -07:00
|
|
|
|
2011-04-14 17:49:42 -07:00
|
|
|
|
|
|
|
|
|
2011-04-04 01:48:58 -07:00
|
|
|
/**
|
2011-04-05 00:38:18 -07:00
|
|
|
* Build the Array for 'job_type'
|
2011-04-04 01:48:58 -07:00
|
|
|
*/
|
2011-04-05 00:38:18 -07:00
|
|
|
function job_type_options() {
|
2011-04-04 01:48:58 -07:00
|
|
|
|
2011-04-14 17:49:42 -07:00
|
|
|
//$options = array('INDENT','STOCK','COMMISSION','SERVICE');
|
|
|
|
|
$options = array('GOODS','SERVICES');
|
2011-04-05 00:38:18 -07:00
|
|
|
$enumOpts = $this->buildEnumOpts($options);
|
|
|
|
|
return $enumOpts;
|
2011-04-04 01:48:58 -07:00
|
|
|
}
|
|
|
|
|
|
2011-04-15 00:34:51 -07:00
|
|
|
function shipment_category_options() {
|
2011-04-14 17:49:42 -07:00
|
|
|
$options = array(
|
2011-04-15 00:34:51 -07:00
|
|
|
0 => '',
|
|
|
|
|
1 => 'Indent - via CMC',
|
|
|
|
|
2 => 'Direct - Principle to final',
|
|
|
|
|
3 => 'Stock',
|
|
|
|
|
4 => 'No Shipment'
|
2011-04-14 17:49:42 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return $options;
|
2011-04-05 00:38:18 -07:00
|
|
|
}
|
2011-04-04 01:48:58 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
function freight_paid_options() {
|
|
|
|
|
$options = array('CMC', 'CUSTOMER');
|
|
|
|
|
return $this->buildEnumOpts($options);
|
|
|
|
|
}
|
2011-04-04 01:48:58 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
function gst_options() {
|
|
|
|
|
$options = array(1=>'YES', 0=>'NO');
|
2011-04-04 01:48:58 -07:00
|
|
|
return $options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
function buildEnumOpts($options) {
|
2011-03-31 22:23:52 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
$enumOpts = array();
|
|
|
|
|
foreach($options as $opt) {
|
|
|
|
|
$enumOpts[$opt] = $opt;
|
|
|
|
|
}
|
|
|
|
|
return $enumOpts;
|
|
|
|
|
}
|
2011-03-31 22:23:52 -07:00
|
|
|
|
2011-03-31 20:29:57 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
function ajax_edit() {
|
|
|
|
|
if(!empty($this->data)) {
|
|
|
|
|
if ($this->Job->save($this->data)) {
|
2011-03-28 18:47:50 -07:00
|
|
|
echo "SUCCESS";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "FAILURE";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
|
2011-03-22 00:05:56 -07:00
|
|
|
|
2010-05-03 23:49:57 -07:00
|
|
|
function view($id = null) {
|
2011-03-13 17:21:56 -07:00
|
|
|
if (!$id) {
|
|
|
|
|
$this->flash(__('Invalid Job', true), array('action'=>'index'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$job = $this->Job->read(null, $id);
|
|
|
|
|
|
|
|
|
|
$emailIDs = array();
|
|
|
|
|
foreach($job['Email'] as $email) {
|
|
|
|
|
$emailIDs[] = $email['id'];
|
|
|
|
|
}
|
|
|
|
|
$emails = $this->Job->Email->find('all', array('conditions'=>array('Email.id'=>$emailIDs)));
|
|
|
|
|
$this->set('emails', $emails);
|
2010-05-17 23:45:38 -07:00
|
|
|
|
2011-03-13 17:21:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->set('job', $job);
|
|
|
|
|
$this->set('customer', $this->Job->Enquiry->Customer->findById($job['Enquiry']['customer_id']));
|
2010-09-06 20:57:28 -07:00
|
|
|
$this->set('principles', $this->Job->PurchaseOrder->Principle->find('list'));
|
2011-03-13 17:21:56 -07:00
|
|
|
$this->pageTitle = $job['Job']['title'];
|
2010-05-17 23:45:38 -07:00
|
|
|
|
2010-05-03 23:49:57 -07:00
|
|
|
}
|
|
|
|
|
|
2011-03-24 01:21:26 -07:00
|
|
|
function save_jobs() {
|
|
|
|
|
if(isset($this->data)) {
|
|
|
|
|
//$data = json_decode($this->data);
|
|
|
|
|
|
|
|
|
|
print_r($this->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-18 23:04:40 -07:00
|
|
|
|
|
|
|
|
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'];
|
2011-04-19 01:07:27 -07:00
|
|
|
|
|
|
|
|
if ($this->Job->save($this->data)) {
|
2011-04-18 23:04:40 -07:00
|
|
|
echo "SUCCESS";
|
2011-04-19 01:07:27 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "FAILURE";
|
|
|
|
|
}
|
2011-04-18 23:04:40 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-07 21:11:06 -07:00
|
|
|
function __isNotEmptyDate($date) {
|
2011-03-13 17:21:56 -07:00
|
|
|
if($date == "0000-00-00") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-07 21:11:06 -07:00
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
function autocomplete() {
|
|
|
|
|
$this->layout = 'ajax';
|
|
|
|
|
|
|
|
|
|
$query = strtolower($_GET["term"]);
|
|
|
|
|
|
|
|
|
|
//$this->set('customers_json', print_r($this->data));
|
|
|
|
|
|
|
|
|
|
if($query == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
App::import('Core', 'Sanitize');
|
|
|
|
|
|
|
|
|
|
$query = Sanitize::clean($query);
|
|
|
|
|
|
|
|
|
|
$jobs = $this->Job->find('list', array(
|
|
|
|
|
'conditions' => array(
|
|
|
|
|
'Job.title LIKE' => '%'.$query.'%'
|
|
|
|
|
),'fields' => array('Job.title'),
|
|
|
|
|
'order' => array('Job.title ASC')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
//print_r($POs);
|
|
|
|
|
|
|
|
|
|
foreach ($jobs as $id => $job) {
|
|
|
|
|
$job_list[] = array('id'=> $id, 'label' => $job);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$jobs_json = json_encode($job_list);
|
|
|
|
|
|
|
|
|
|
$this->set('jobs_json', $jobs_json);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-03-13 17:21:56 -07:00
|
|
|
/**
|
|
|
|
|
* Need to fix the customer_id which hasn't been set for these 500odd records.
|
|
|
|
|
*
|
|
|
|
|
* Will fetch the right ID the same way the Index does, then update each record.
|
|
|
|
|
*/
|
2011-03-14 20:22:09 -07:00
|
|
|
/*function fixJobs() {
|
2011-03-13 18:30:03 -07:00
|
|
|
|
|
|
|
|
$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'));
|
|
|
|
|
|
2010-06-07 21:11:06 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
|
|
|
|
|
|
2011-03-14 20:22:09 -07:00
|
|
|
}*/
|
|
|
|
|
|
2011-03-22 00:05:56 -07:00
|
|
|
|
2011-04-05 00:38:18 -07:00
|
|
|
|
|
|
|
|
|
2010-05-03 23:49:57 -07:00
|
|
|
}
|
|
|
|
|
?>
|