Shipments progress. Not finished yet
This commit is contained in:
parent
1bb9d77faf
commit
93c0b1ad78
|
|
@ -1,118 +0,0 @@
|
||||||
<?php
|
|
||||||
class ContactsController extends AppController {
|
|
||||||
|
|
||||||
var $name = 'Contacts';
|
|
||||||
var $helpers = array('Html', 'Form');
|
|
||||||
var $components = array('RequestHandler');
|
|
||||||
var $paginate = array(
|
|
||||||
'Contact' => array('order' => array('Contact.customer_id' => 'asc')),
|
|
||||||
'Enquiry' => array('order' => array('Enquiry.id' => 'asc'))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
function index() {
|
|
||||||
$this->Contact->recursive = 0;
|
|
||||||
$this->set('contacts', $this->paginate());
|
|
||||||
}
|
|
||||||
|
|
||||||
function view($id = null) {
|
|
||||||
if (!$id) {
|
|
||||||
$this->Session->setFlash(__('Invalid Contact.', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
$this->set('contact', $this->Contact->read(null, $id));
|
|
||||||
//$enquiries = $this->Contact->Enquiry->findAllByContactId($id);
|
|
||||||
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.contact_id' => $id)));
|
|
||||||
//$this->set('enquiries', $this->paginate($enquiries));
|
|
||||||
$statuses = $this->Contact->Enquiry->Status->find('all');
|
|
||||||
$status_list = array();
|
|
||||||
foreach ($statuses as $status) {
|
|
||||||
$status_list[] = array($status['Status']['id'], $status['Status']['name']);
|
|
||||||
}
|
|
||||||
$this->set('status_list', $status_list);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function add_to_customer($customerid = null) {
|
|
||||||
|
|
||||||
if(isset($this->params['named']['customerid'])) {
|
|
||||||
$customerid = $this->params['named']['customerid'];
|
|
||||||
}
|
|
||||||
if (!$customerid && empty($this->data)) {
|
|
||||||
$this->Session->setFlash(__('Invalid Customer ID', true));
|
|
||||||
$this->redirect(array('controller'=>'Enquiries', 'action'=>'index'));
|
|
||||||
}
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
|
|
||||||
$this->Contact->create();
|
|
||||||
if ($this->Contact->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Contact has been saved', true));
|
|
||||||
$this->redirect(array('controller' => 'Customers', 'action'=>'view/'.$this->data['Contact']['customer_id']));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Contact could not be saved. Please try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$contact_categories = $this->Contact->ContactCategory->find('list');
|
|
||||||
$customer = $this->Contact->Customer->findById($customerid);
|
|
||||||
$this->set(compact('customer', 'contact_categories'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_another($increment) {
|
|
||||||
$this->set('contact_categories', $this->Contact->ContactCategory->find('list'));
|
|
||||||
$this->set('increment', $increment);
|
|
||||||
|
|
||||||
}
|
|
||||||
function remove_another($increment) {
|
|
||||||
$this->set('increment', $increment);
|
|
||||||
}
|
|
||||||
function add_one($customerid) {
|
|
||||||
$contact_categories = $this->Contact->ContactCategory->find('list');
|
|
||||||
$this->set('customerid', $customerid);
|
|
||||||
$this->set('contact_categories', $contact_categories);
|
|
||||||
}
|
|
||||||
function remove_one($customerid) {
|
|
||||||
$contacts = $this->Contact->find('all', array('conditions' => array('Contact.customer_id' => $customerid)));
|
|
||||||
$contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name'));
|
|
||||||
$this->set('contacts', $contacts);
|
|
||||||
$this->set('customerid', $customerid);
|
|
||||||
}
|
|
||||||
|
|
||||||
function edit($id = null) {
|
|
||||||
if (!$id && empty($this->data)) {
|
|
||||||
$this->Session->setFlash(__('Invalid Contact', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
$this->data['Contact']['name'] = $this->data['Contact']['first_name'].' '.$this->data['Contact']['last_name'];
|
|
||||||
if ($this->Contact->save($this->data)) {
|
|
||||||
$customerid = $this->data['Contact']['customer_id'];
|
|
||||||
|
|
||||||
$this->Session->setFlash(__('The Contact has been saved', true));
|
|
||||||
$this->redirect(array('controller' => 'Customers', 'action'=>'view/'.$customerid));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Contact could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($this->data)) {
|
|
||||||
$this->data = $this->Contact->read(null, $id);
|
|
||||||
}
|
|
||||||
$customers = $this->Contact->Customer->find('list');
|
|
||||||
$contact_categories = $this->Contact->ContactCategory->find('list');
|
|
||||||
$this->set(compact('customers', 'contact_categories'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete($id = null) {
|
|
||||||
if (!$id) {
|
|
||||||
$this->Session->setFlash(__('Invalid id for Contact', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
if ($this->Contact->del($id)) {
|
|
||||||
$this->Session->setFlash(__('Contact deleted', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
@ -84,7 +84,8 @@ class CustomersController extends AppController {
|
||||||
if ($this->Customer->saveAll($this->data)) {
|
if ($this->Customer->saveAll($this->data)) {
|
||||||
$this->Session->setFlash(__('The Customer has been saved', true));
|
$this->Session->setFlash(__('The Customer has been saved', true));
|
||||||
$id = $this->Customer->id;
|
$id = $this->Customer->id;
|
||||||
$this->redirect(array('action'=>'view/'.$id));
|
debug($this->data);
|
||||||
|
//$this->redirect(array('action'=>'view/'.$id));
|
||||||
} else {
|
} else {
|
||||||
$this->Session->setFlash(__('The Customer could not be saved. Please, try again.', true));
|
$this->Session->setFlash(__('The Customer could not be saved. Please, try again.', true));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,44 @@ class JobsController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to fix the customer_id which hasn't been set for these 500odd records.
|
* Need to fix the customer_id which hasn't been set for these 500odd records.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,76 +1,75 @@
|
||||||
<?php
|
<?php
|
||||||
class PrinciplesController extends AppController {
|
class PrinciplesController extends AppController {
|
||||||
|
|
||||||
var $name = 'Principles';
|
var $name = 'Principles';
|
||||||
var $helpers = array('Html', 'Form');
|
var $helpers = array('Html', 'Form');
|
||||||
|
|
||||||
var $paginate = array(
|
var $paginate = array(
|
||||||
'Principle' => array('limit' => 50, 'order' => array('Principle.name' => 'asc')),
|
'Principle' => array('limit' => 50, 'order' => array('Principle.name' => 'asc')),
|
||||||
'Enquiry' => array('limit' => 150, 'order' => array('Enquiry.id' => 'desc'))
|
'Enquiry' => array('limit' => 150, 'order' => array('Enquiry.id' => 'desc'))
|
||||||
);
|
);
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
$this->Principle->recursive = 0;
|
$this->Principle->recursive = 0;
|
||||||
$this->set('principles', $this->paginate());
|
$this->set('principles', $this->paginate());
|
||||||
$this->set('enquiries', $this->paginate());
|
$this->set('enquiries', $this->paginate());
|
||||||
|
}
|
||||||
|
|
||||||
|
function view($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid Principle.', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
|
$this->set('principle', $this->Principle->read(null, $id));
|
||||||
function view($id = null) {
|
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id)));
|
||||||
if (!$id) {
|
$this->set('addresses', $this->Principle->PrincipleAddress->findAllByPrincipleId($id));
|
||||||
$this->Session->setFlash(__('Invalid Principle.', true));
|
$this->set('principleContacts', $this->Principle->PrincipleContact->find('all', array('conditions'=>array('PrincipleContact.principle_id'=>$id))));
|
||||||
$this->redirect(array('action'=>'index'));
|
$statuses = $this->Principle->Enquiry->Status->find('all');
|
||||||
}
|
$status_list = array();
|
||||||
$this->set('principle', $this->Principle->read(null, $id));
|
foreach ($statuses as $status) {
|
||||||
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id)));
|
$status_list[] = array($status['Status']['id'], $status['Status']['name']);
|
||||||
$this->set('addresses', $this->Principle->PrincipleAddress->findAllByPrincipleId($id));
|
|
||||||
$this->set('principleContacts', $this->Principle->PrincipleContact->find('all', array('conditions'=>array('PrincipleContact.principle_id'=>$id))));
|
|
||||||
$statuses = $this->Principle->Enquiry->Status->find('all');
|
|
||||||
$status_list = array();
|
|
||||||
foreach ($statuses as $status) {
|
|
||||||
$status_list[] = array($status['Status']['id'], $status['Status']['name']);
|
|
||||||
}
|
|
||||||
$this->set('status_list', $status_list);
|
|
||||||
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$this->set('status_list', $status_list);
|
||||||
|
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id)));
|
||||||
|
|
||||||
function add() {
|
}
|
||||||
if (!empty($this->data)) {
|
|
||||||
$this->Principle->create();
|
function add() {
|
||||||
if ($this->Principle->save($this->data)) {
|
if (!empty($this->data)) {
|
||||||
$this->Session->setFlash(__('The Principle has been saved', true));
|
$this->Principle->create();
|
||||||
$this->redirect(array('action'=>'index'));
|
if ($this->Principle->save($this->data)) {
|
||||||
} else {
|
$this->Session->setFlash(__('The Principle has been saved', true));
|
||||||
$this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
} else {
|
||||||
}
|
$this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true));
|
||||||
$countries = $this->Principle->Country->find('list');
|
}
|
||||||
$currencies = $this->Principle->Currency->find('list');
|
|
||||||
$this->set(compact('countries', 'currencies'));
|
|
||||||
}
|
}
|
||||||
|
$countries = $this->Principle->Country->find('list');
|
||||||
|
$currencies = $this->Principle->Currency->find('list');
|
||||||
|
$this->set(compact('countries', 'currencies'));
|
||||||
|
}
|
||||||
|
|
||||||
function edit($id = null) {
|
function edit($id = null) {
|
||||||
if (!$id && empty($this->data)) {
|
if (!$id && empty($this->data)) {
|
||||||
$this->Session->setFlash(__('Invalid Principle', true));
|
$this->Session->setFlash(__('Invalid Principle', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
if ($this->Principle->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Principle has been saved', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($this->data)) {
|
|
||||||
$this->data = $this->Principle->read(null, $id);
|
|
||||||
}
|
|
||||||
$countries = $this->Principle->Country->find('list');
|
|
||||||
$currencies = $this->Principle->Currency->find('list');
|
|
||||||
$this->set(compact('countries','currencies'));
|
|
||||||
}
|
}
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
if ($this->Principle->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The Principle has been saved', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($this->data)) {
|
||||||
|
$this->data = $this->Principle->read(null, $id);
|
||||||
|
}
|
||||||
|
$countries = $this->Principle->Country->find('list');
|
||||||
|
$currencies = $this->Principle->Currency->find('list');
|
||||||
|
$this->set(compact('countries','currencies'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,84 +1,125 @@
|
||||||
<?php
|
<?php
|
||||||
class PurchaseOrdersController extends AppController {
|
class PurchaseOrdersController extends AppController {
|
||||||
|
|
||||||
var $name = 'PurchaseOrders';
|
var $name = 'PurchaseOrders';
|
||||||
var $helpers = array('Html', 'Form', 'Javascript');
|
var $helpers = array('Html', 'Form', 'Javascript');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var $paginate = array(
|
var $paginate = array(
|
||||||
|
|
||||||
'contain' => false,
|
'contain' => false,
|
||||||
'limit' => 100,
|
'limit' => 100,
|
||||||
'order'=>array('PurchaseOrder.id' => 'desc')
|
'order'=>array('PurchaseOrder.id' => 'desc')
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
$this->PurchaseOrder->recursive = 1;
|
$this->PurchaseOrder->recursive = 1;
|
||||||
$this->set('purchaseOrders', $this->paginate());
|
$this->set('purchaseOrders', $this->paginate());
|
||||||
|
}
|
||||||
|
|
||||||
|
function view($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid PurchaseOrder.', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
$this->set('purchaseOrder', $this->PurchaseOrder->read(null, $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
$this->PurchaseOrder->create();
|
||||||
|
|
||||||
|
$count = $this->PurchaseOrder->findCount();
|
||||||
|
$count++;
|
||||||
|
|
||||||
|
$offset = 2060;
|
||||||
|
|
||||||
|
$count += $offset;
|
||||||
|
|
||||||
|
$newPOnumber = "CMCPO".$count;
|
||||||
|
|
||||||
|
$this->data['PurchaseOrder']['title'] = $newPOnumber;
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->PurchaseOrder->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The PurchaseOrder has been saved', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$jobs = $this->PurchaseOrder->Job->find('list');
|
||||||
|
$principles = $this->PurchaseOrder->Principle->find('list');
|
||||||
|
$documents = $this->PurchaseOrder->Document->find('list');
|
||||||
|
$this->set(compact('jobs', 'principles', 'documents'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit($id = null) {
|
||||||
|
if (!$id && empty($this->data)) {
|
||||||
|
$this->Session->setFlash(__('Invalid PurchaseOrder', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
if ($this->PurchaseOrder->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The PurchaseOrder has been saved', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($this->data)) {
|
||||||
|
$this->data = $this->PurchaseOrder->read(null, $id);
|
||||||
|
}
|
||||||
|
$jobs = $this->PurchaseOrder->Job->find('list');
|
||||||
|
$principles = $this->PurchaseOrder->Principle->find('list');
|
||||||
|
$documents = $this->PurchaseOrder->Document->find('list');
|
||||||
|
$this->set(compact('jobs','principles','documents'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function autocomplete() {
|
||||||
|
$this->layout = 'ajax';
|
||||||
|
|
||||||
|
$query = strtolower($_GET["term"]);
|
||||||
|
|
||||||
|
//$this->set('customers_json', print_r($this->data));
|
||||||
|
|
||||||
|
if($query == null) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function view($id = null) {
|
App::import('Core', 'Sanitize');
|
||||||
if (!$id) {
|
|
||||||
$this->Session->setFlash(__('Invalid PurchaseOrder.', true));
|
$query = Sanitize::clean($query);
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
$POs = $this->PurchaseOrder->find('list', array(
|
||||||
$this->set('purchaseOrder', $this->PurchaseOrder->read(null, $id));
|
'conditions' => array(
|
||||||
|
'PurchaseOrder.title LIKE' => '%'.$query.'%'
|
||||||
|
),'fields' => array('PurchaseOrder.title'),
|
||||||
|
'order' => array('PurchaseOrder.title ASC')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
));
|
||||||
|
|
||||||
|
//print_r($POs);
|
||||||
|
|
||||||
|
foreach ($POs as $id => $po) {
|
||||||
|
$po_list[] = array('id'=> $id, 'label' => $po);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add() {
|
$POs_json = json_encode($po_list);
|
||||||
if (!empty($this->data)) {
|
|
||||||
$this->PurchaseOrder->create();
|
|
||||||
|
|
||||||
$count = $this->PurchaseOrder->findCount();
|
$this->set('POs_json', $POs_json);
|
||||||
$count++;
|
|
||||||
|
|
||||||
$offset = 2060;
|
}
|
||||||
|
|
||||||
$count += $offset;
|
|
||||||
|
|
||||||
$newPOnumber = "CMCPO".$count;
|
|
||||||
|
|
||||||
$this->data['PurchaseOrder']['title'] = $newPOnumber;
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->PurchaseOrder->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The PurchaseOrder has been saved', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$jobs = $this->PurchaseOrder->Job->find('list');
|
|
||||||
$principles = $this->PurchaseOrder->Principle->find('list');
|
|
||||||
$documents = $this->PurchaseOrder->Document->find('list');
|
|
||||||
$this->set(compact('jobs', 'principles', 'documents'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function edit($id = null) {
|
|
||||||
if (!$id && empty($this->data)) {
|
|
||||||
$this->Session->setFlash(__('Invalid PurchaseOrder', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
if ($this->PurchaseOrder->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The PurchaseOrder has been saved', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($this->data)) {
|
|
||||||
$this->data = $this->PurchaseOrder->read(null, $id);
|
|
||||||
}
|
|
||||||
$jobs = $this->PurchaseOrder->Job->find('list');
|
|
||||||
$principles = $this->PurchaseOrder->Principle->find('list');
|
|
||||||
$documents = $this->PurchaseOrder->Document->find('list');
|
|
||||||
$this->set(compact('jobs','principles','documents'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*function delete($id = null) {
|
/*function delete($id = null) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->Session->setFlash(__('Invalid id for PurchaseOrder', true));
|
$this->Session->setFlash(__('Invalid id for PurchaseOrder', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,13 @@ class ShipmentsController extends AppController {
|
||||||
function index() {
|
function index() {
|
||||||
$this->Shipment->recursive = 0;
|
$this->Shipment->recursive = 0;
|
||||||
$this->set('shipments', $this->paginate());
|
$this->set('shipments', $this->paginate());
|
||||||
|
|
||||||
|
$principles = $this->Shipment->Principle->find('list');
|
||||||
|
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
||||||
|
$shipmentType = $this->typeOptions(false);
|
||||||
|
$shipmentTypeShort = $this->typeOptions(true);
|
||||||
|
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function view($id = null) {
|
function view($id = null) {
|
||||||
|
|
@ -27,27 +34,46 @@ class ShipmentsController extends AppController {
|
||||||
$this->set('shipment', $this->Shipment->read(null, $id));
|
$this->set('shipment', $this->Shipment->read(null, $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ajax_edit() {
|
||||||
|
$this->layout = 'ajax';
|
||||||
|
|
||||||
|
if(!empty($this->data)) {
|
||||||
function add($action = 'add') {
|
if ($this->Shipment->saveAll($this->data)) {
|
||||||
|
echo "SUCCESS";
|
||||||
$jobs = $this->Shipment->Job->find('list');
|
}
|
||||||
$principles = $this->Shipment->Principle->find('list');
|
else {
|
||||||
$purchaseOrders = $this->Shipment->PurchaseOrder->find('list');
|
echo "FAILURE";
|
||||||
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
}
|
||||||
$shipmentType = $this->typeOptions();
|
|
||||||
|
|
||||||
$this->set(compact('jobs', 'principles', 'purchaseOrders', 'freightForwarders', 'shipmentType'));
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function typeOptions() {
|
|
||||||
$options = array('','Import to CMC','Direct: Principle to Customer','Export','Local');
|
/* Moved the Views for Adding/Editing to elements. Called from the Index.
|
||||||
|
*
|
||||||
|
* function add($action = 'add') {
|
||||||
|
|
||||||
|
$principles = $this->Shipment->Principle->find('list');
|
||||||
|
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
||||||
|
$shipmentType = $this->typeOptions();
|
||||||
|
$this->set(compact('principles', 'freightForwarders', 'shipmentType'));
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
function typeOptions($short = false) {
|
||||||
|
if($short == false) {
|
||||||
|
$options = array('','Import: Principle to CMC','Direct: Principle to Customer','Export','Local');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$options = array('','Import','Direct','Export','Local');
|
||||||
|
}
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,13 @@ class Shipment extends AppModel {
|
||||||
'FreightService' => array(
|
'FreightService' => array(
|
||||||
'className' => 'FreightService',
|
'className' => 'FreightService',
|
||||||
'foreignKey' => 'freight_service_id'
|
'foreignKey' => 'freight_service_id'
|
||||||
|
),
|
||||||
|
'User' => array(
|
||||||
|
'className' => 'User',
|
||||||
|
'foreignKey' => 'user_id',
|
||||||
|
'conditions' => array('User.type' => 'user')
|
||||||
)
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
var $hasMany = array(
|
var $hasMany = array(
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@
|
||||||
<li><?php echo $html->link('Shipments','/shipments/index');?>
|
<li><?php echo $html->link('Shipments','/shipments/index');?>
|
||||||
<ul>
|
<ul>
|
||||||
<li class=""><?php echo $html->link('Shipments List', '/shipments/index');?></li>
|
<li class=""><?php echo $html->link('Shipments List', '/shipments/index');?></li>
|
||||||
<li class="last"><?php echo $html->link('New Shipment', '/shipments/add');?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
|
|
||||||
<?php echo $form->create('Shipment');?>
|
<?php echo $form->create('Shipment');?>
|
||||||
<fieldset>
|
|
||||||
<legend><?php __('New Shipment');?></legend>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
echo $form->input('shipmentType', array('options'=>$shipmentType, 'id'=>'shipmentType'));
|
echo $form->input('shipmentType', array('options'=>$shipmentType, 'id'=>'shipmentType'));
|
||||||
|
|
||||||
|
|
@ -13,13 +10,19 @@
|
||||||
<?
|
<?
|
||||||
echo $form->input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display'));
|
echo $form->input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display'));
|
||||||
echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived'));
|
echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived'));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<?
|
|
||||||
|
|
||||||
|
<div id="principle">
|
||||||
|
<? echo $form->input('Principle', array('type'=>'select', 'multiple'=>true)); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?
|
||||||
echo $form->input('PurchaseOrder');
|
echo $form->input('PurchaseOrder');
|
||||||
echo $form->input('Job');
|
echo $form->input('Job');
|
||||||
echo $form->input('Principle');
|
|
||||||
|
|
||||||
|
|
||||||
echo $form->input('freight_forwarder_id');
|
echo $form->input('freight_forwarder_id');
|
||||||
|
|
@ -30,5 +33,4 @@
|
||||||
echo $form->input('comments');
|
echo $form->input('comments');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</fieldset>
|
|
||||||
<?php echo $form->end();?>
|
<?php echo $form->end();?>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
?></p>
|
?></p>
|
||||||
<table cellpadding="0" cellspacing="0" class="shipments">
|
<table cellpadding="0" cellspacing="0" class="shipments">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th><?php echo $paginator->sort('user_id');?></th>
|
||||||
<th><?php echo $paginator->sort('date_arrived');?></th>
|
<th><?php echo $paginator->sort('date_arrived');?></th>
|
||||||
<th><?php echo $paginator->sort('date_dispatched');?></th>
|
<th><?php echo $paginator->sort('date_dispatched');?></th>
|
||||||
<th><?php echo $paginator->sort('type');?></th>
|
<th><?php echo $paginator->sort('type');?></th>
|
||||||
|
|
@ -28,16 +29,26 @@
|
||||||
foreach ($shipments as $shipment):
|
foreach ($shipments as $shipment):
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>
|
||||||
|
<?
|
||||||
|
$initials = $shipment['User']['first_name'][0].$shipment['User']['last_name'][0];
|
||||||
|
|
||||||
<td>
|
echo $html->link($initials, array('controller'=> 'users', 'action'=>'view', $shipment['User']['id'])); ?>
|
||||||
<?php echo $shipment['Shipment']['date_arrived']; ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php echo $shipment['Shipment']['date_dispatched']; ?>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?php echo $shipment['Shipment']['type']; ?>
|
<?php
|
||||||
|
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived']));
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched']));
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<?php echo $shipmentTypeShort[$shipment['Shipment']['type']]; ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
@ -83,9 +94,7 @@
|
||||||
<?php echo $shipment['Shipment']['comments']; ?>
|
<?php echo $shipment['Shipment']['comments']; ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<?php echo $html->link(__('View', true), array('action' => 'view', $shipment['Shipment']['id'])); ?>
|
|
||||||
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $shipment['Shipment']['id'])); ?>
|
|
||||||
<?php echo $html->link(__('Delete', true), array('action' => 'delete', $shipment['Shipment']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $shipment['Shipment']['id'])); ?>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
@ -104,7 +113,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div id="dialog-form" title="New Shipment">
|
<div id="dialog-form" title="New Shipment">
|
||||||
|
<?=$this->element('add_shipment');?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php debug($shipments); ?>
|
<?php debug($shipments); ?>
|
||||||
|
|
@ -1437,4 +1437,22 @@ tr.cancelled td {
|
||||||
|
|
||||||
table.shipments tr td {
|
table.shipments tr td {
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
|
border: 1px solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.shipments {
|
||||||
|
border: 1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.habtmList {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.habtmList li {
|
||||||
|
padding-top: 0.5em;
|
||||||
|
padding-left: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
42
webroot/js/shipment_add.js
Normal file
42
webroot/js/shipment_add.js
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
$(function() {
|
||||||
|
|
||||||
|
|
||||||
|
$('#date_arrived_display').datepicker({
|
||||||
|
showButtonPanel: true,
|
||||||
|
dateFormat: 'd M yy',
|
||||||
|
altFormat: 'yy-mm-dd',
|
||||||
|
altField: '#date_arrived'
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#importFields").hide();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$("#shipmentType").change(function() {
|
||||||
|
|
||||||
|
var shipmentTypeID = getShipmentTypeID();
|
||||||
|
|
||||||
|
if(shipmentTypeID == 1) {
|
||||||
|
$("#importFields").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function getShipmentTypeID() {
|
||||||
|
var id;
|
||||||
|
$("#shipmentType :selected").each(function(i, selected) {
|
||||||
|
id = this.value;
|
||||||
|
});
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
@ -1,32 +1,174 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
resetForm();
|
||||||
|
|
||||||
|
|
||||||
$( "#dialog-form" ).dialog({
|
$( "#dialog-form" ).dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
height: 600,
|
height: 900,
|
||||||
width: 350,
|
width: 600,
|
||||||
modal: true,
|
modal: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
"New Shipment": function() {
|
"New Shipment": function() {
|
||||||
|
var thisShipmentInputs = $('#ShipmentAddForm').find('input,select');
|
||||||
|
|
||||||
|
$.post('/shipments/ajax_edit', thisShipmentInputs, function(data) {
|
||||||
|
$( "#dialog-form" ).dialog('close');
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
Cancel: function() {
|
Cancel: function() {
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
|
$("#ShipmentAddForm")[0].reset();
|
||||||
|
$("#principlesList").empty();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
|
|
||||||
|
$("#importFields").hide();
|
||||||
|
$("#principle").hide();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$( "#newShipment" ).button().click(function() {
|
$( "#newShipment" ).button().click(function() {
|
||||||
|
|
||||||
$.get('/shipments/add', function(data) {
|
|
||||||
$("#dialog-form").html(data);
|
|
||||||
$( "#dialog-form" ).dialog( "open" );
|
$( "#dialog-form" ).dialog( "open" );
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#date_arrived_display').datepicker({
|
||||||
|
showButtonPanel: true,
|
||||||
|
dateFormat: 'd M yy',
|
||||||
|
altFormat: 'yy-mm-dd',
|
||||||
|
altField: '#date_arrived'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$("#shipmentType").change(function() {
|
||||||
|
|
||||||
|
var shipmentTypeID = getSelectedID('#shipmentType');
|
||||||
|
|
||||||
|
if(shipmentTypeID == 1) { //Import
|
||||||
|
$("#importFields").show();
|
||||||
|
$("#principle").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
//Remove X button clicked.
|
||||||
|
$('.removeFromList').live('click', function() {
|
||||||
|
$(this).parent().remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#addPrinciple').button().click(function() {
|
||||||
|
|
||||||
|
var principleID = getSelectedID('#PrinciplePrinciple');
|
||||||
|
|
||||||
|
if($('#PrincipleID_'+principleID).length > 0) { //This Principle is already in the List. Don't do anything.'
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var principleName =getSelectedText('#PrinciplePrinciple');
|
||||||
|
|
||||||
|
//addPrincipleToList(principleID);
|
||||||
|
addToList('Principle', principleID, principleName, $('#principlesList') );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$( "#purchase_order_autocomplete" ).autocomplete({
|
||||||
|
source: "/purchase_orders/autocomplete",
|
||||||
|
minLength: 2,
|
||||||
|
select: function( event, ui ) {
|
||||||
|
//alert(ui.item.value + ":" + ui.item.id);
|
||||||
|
//alert($('#PurchaseOrderID_'+ui.item.id).length);
|
||||||
|
|
||||||
|
|
||||||
|
if($('#PurchaseOrderID_'+ui.item.id).length == 0) { //This Principle is already in the List. Don't do anything.'
|
||||||
|
addToList('PurchaseOrder', ui.item.id, ui.item.value, $('#purchaseOrdersList'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$( "#job_autocomplete" ).autocomplete({
|
||||||
|
source: "/jobs/autocomplete",
|
||||||
|
minLength: 2,
|
||||||
|
select: function( event, ui ) {
|
||||||
|
//alert(ui.item.value + ":" + ui.item.id);
|
||||||
|
|
||||||
|
if($('#JobID_'+ui.item.id).length == 0) { //This Principle is already in the List. Don't do anything.'
|
||||||
|
addToList('Job', ui.item.id, ui.item.value, $('#jobsList'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the Form to its default site
|
||||||
|
*/
|
||||||
|
|
||||||
|
function resetForm() {
|
||||||
|
|
||||||
|
$(".hiddenDefault").hide();
|
||||||
|
$("#principle").hide();
|
||||||
|
$("#ShipmentAddForm")[0].reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A more generic way of handling the HABTM <ul> <li>[REMOVE BUTTON] NAME [HIDDEN INPUT]</li> </ul>
|
||||||
|
*/
|
||||||
|
function addToList(modelName, id, value, ULelement) {
|
||||||
|
var thisLI = $('<li></li>');
|
||||||
|
var thisButton = $('<button>X</button>');
|
||||||
|
thisButton.addClass('removeFromList');
|
||||||
|
thisButton.button();
|
||||||
|
|
||||||
|
var thisHiddenInput = $('<input type="hidden">');
|
||||||
|
|
||||||
|
var modelString = '['+modelName+']';
|
||||||
|
thisHiddenInput.attr('name', 'data'+modelString+modelString+'[]');
|
||||||
|
thisHiddenInput.attr('value', id);
|
||||||
|
|
||||||
|
thisLI.attr('id', modelName+'ID_'+id);
|
||||||
|
thisLI.html(value);
|
||||||
|
thisLI.prepend(thisButton);
|
||||||
|
thisLI.append(thisHiddenInput);
|
||||||
|
ULelement.append(thisLI);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getSelectedID(elementID) {
|
||||||
|
var id;
|
||||||
|
$(elementID+" :selected").each(function(i, selected) {
|
||||||
|
id = this.value;
|
||||||
|
});
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelectedText(elementID) {
|
||||||
|
var text;
|
||||||
|
$(elementID+" :selected").each(function(i, selected) {
|
||||||
|
text = $(selected).text();
|
||||||
|
});
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue