Added address selection to POs.
This commit is contained in:
parent
52bc47658b
commit
9485f80428
|
|
@ -37,7 +37,30 @@ class DocumentsController extends AppController {
|
|||
$this->set('users', $this->Document->User->getUsersList());
|
||||
|
||||
$this->set('currency', $this->Document->getCurrency($document));
|
||||
$this->set('enquiry', $this->Document->getEnquiry($document));
|
||||
$enquiry = $this->Document->getEnquiry($document);
|
||||
$this->set('enquiry', $enquiry);
|
||||
$this->set('jobs', $this->Document->OrderAcknowledgement->Job->find('list',
|
||||
array('conditions'=> array('Job.customer_id'
|
||||
=> $enquiry['Enquiry']['customer_id']), 'recursive' =>0, 'order'=>'id DESC')));
|
||||
|
||||
|
||||
|
||||
$customerAddresses = $this->Document->User->Enquiry->BillingAddress->find('all', array('conditions'=>array('BillingAddress.customer_id' => $enquiry['Enquiry']['customer_id'])));
|
||||
|
||||
|
||||
/* (2013). This STILL feels like an ugly hack. But it gets the desired effect and it will do for now. Screw it. */
|
||||
if(isset($customerAddresses[0]['BillingAddress'])) {
|
||||
foreach ($customerAddresses as $address) {
|
||||
$i = $address['BillingAddress']['id'];
|
||||
$billing_address_list[$i] = $address['BillingAddress']['address'].'<br>'.$address['BillingAddress']['city'].' '.$address['State']['name'].' '.$address['BillingAddress']['postcode'].'<br>'.up($address['Country']['name']).'<br><br>';
|
||||
}
|
||||
$this->set('billing_addresses_list', $billing_address_list);
|
||||
$this->set('shipping_addresses_list', $billing_address_list);
|
||||
}
|
||||
else {
|
||||
$this->set('billing_addresses_list', 'No Addresses exist for this Customer. Please add one');
|
||||
$this->set('shipping_addresses_list', 'No Addresses exist for this Customer. Please add one');
|
||||
}
|
||||
|
||||
$this->set('attachments', $this->Document->DocumentAttachment->find('all', array('conditions'=>array('document_id'=> $id))));
|
||||
$this->set('principles', $this->Document->LineItem->Product->Principle->find('list'));
|
||||
|
|
@ -397,17 +420,14 @@ class DocumentsController extends AppController {
|
|||
|
||||
$this->Document->OrderAcknowledgement->Enquiry->Customer->save($customer);
|
||||
|
||||
$job = $this->Document->OrderAcknowledgement->Job->newJob($enquiry, $this->data['Job']['customer_order_number']); //Only way to know Enquiry ID is if it's a Quote.
|
||||
|
||||
|
||||
|
||||
if($job == false) {
|
||||
echo 'Error: Unable to create Job';
|
||||
}
|
||||
else {
|
||||
$newDoc = array();
|
||||
$newDoc['Document']['type'] = 'orderAck';
|
||||
if($this->data['Job']['create_new_job']) {
|
||||
$job = $this->Document->OrderAcknowledgement->Job->newJob($enquiry, $this->data['Job']['customer_order_number']); //Only way to know Enquiry ID is if it's a Quote.
|
||||
$newDoc['OrderAcknowledgement']['job_id'] = $job['Job']['id'];
|
||||
|
||||
}
|
||||
|
||||
$newDoc['Document']['type'] = 'orderAck';
|
||||
$newDoc['OrderAcknowledgement']['enquiry_id'] = $enquiry['Enquiry']['id'];
|
||||
$newDoc['OrderAcknowledgement']['currency_id'] = 2; //Default to AUD.
|
||||
$newDoc['OrderAcknowledgement']['issue_date'] = date('Y-m-d');
|
||||
|
|
@ -440,7 +460,12 @@ class DocumentsController extends AppController {
|
|||
|
||||
if ($this->Document->saveAll($newDoc)) {
|
||||
$newid = $this->Document->id;
|
||||
if($job) {
|
||||
$this->Session->setFlash(__("Job {$job['Job']['title']} and Order Acknowledgement created", true));
|
||||
}
|
||||
else {
|
||||
$this->Session->setFlash(__("Order Acknowledgement created", true));
|
||||
}
|
||||
$this->redirect(array('action'=>'view',$newid));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The Document could not be saved. Please, try again.', true));
|
||||
|
|
@ -449,8 +474,6 @@ class DocumentsController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an Order Acknowledgement to an Invoice.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
<h2>Order Acknowledgement: <?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2>
|
||||
<h2>Order Acknowledgement: <span class="job-title"><?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?></span> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2>
|
||||
|
||||
<div id="flashMessage" class="message">
|
||||
</div>
|
||||
|
||||
<div class="docButtons">
|
||||
<?=$html->link('Generate PDF of this Order Acknowledgement', '/documents/pdf/'.$document['Document']['id']);?>
|
||||
<?=$html->link('Email PDF to Customer', '/documents/email_pdf/'.$document['Document']['id']);?>
|
||||
</div>
|
||||
|
||||
<div class="docOperations" style="display: none;">
|
||||
<div class="docOperations">
|
||||
<h3>Create an Invoice from this OA</h3>
|
||||
<?=$html->link('Create an Invoice based on this OA', '/documents/convert_to_invoice/'.$document['Document']['id'], array('class'=>'actionLink'));?>
|
||||
</div>
|
||||
|
|
@ -18,10 +19,15 @@
|
|||
<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
echo $form->input('Document.id');
|
||||
echo $form->input('OrderAcknowledgement.id');
|
||||
echo $form->input('OrderAcknowledgement.job_id');
|
||||
echo $form->input('OrderAcknowledgement.currency_id');
|
||||
echo $form->input('OrderAcknowledgement.issue_date');
|
||||
|
||||
echo $form->input('billing_address_id', array('div' => 'addressradio', 'legend' => 'Select Billing Address', 'options' => $billing_addresses_list, 'type' => 'radio', 'class'=>'billing_address'));
|
||||
echo $form->input('Document.bill_to');
|
||||
|
||||
|
||||
echo $form->input('shipping_address_id', array('div' => 'addressradio','legend' => 'Select Shipping Address', 'options' => $shipping_addresses_list, 'type' => 'radio', 'class' => 'shipping_address'));
|
||||
echo $form->input('Document.ship_to');
|
||||
|
||||
|
||||
|
|
@ -36,7 +42,6 @@
|
|||
|
||||
|
||||
<span id="orderAckID" style="display: none;"><?=$document['OrderAcknowledgement']['id']?></span>
|
||||
|
||||
<? //debug($this->data);?>
|
||||
<? //debug($enquiry);?>
|
||||
<?php // debug($job);?>
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ echo $form->input('Document.id');
|
|||
|
||||
<div class="docOperations">
|
||||
<h3>Has <?=$html->link($enquiry['Customer']['name'], array('controller'=>'customers','action'=>'view',$enquiry['Customer']['id']));?> placed an order for this Quote?</h3>
|
||||
<? //$html->link('Convert this Enquiry to a new Job and Generate an Order Acknowledgement', '/documents/convert_to_oa/'.$document['Document']['id'], array('class'=>'actionLink'));?>
|
||||
<button id="createJobAndOA">Create a New Job and Order Acknowledgement</button>
|
||||
<button id="createOA">Create Order Acknowledgement</button>
|
||||
</div>
|
||||
|
||||
<div class="pages">
|
||||
|
|
@ -76,17 +75,19 @@ echo $form->input('Document.id');
|
|||
|
||||
|
||||
<div id="addJobConfirmation" title="Create New Job and Order Acknowledgment">
|
||||
<span>This will create a new job and an Order Acknowledgement based on this Quote</span><br>
|
||||
<span>This will create an Order Acknowledgement based on this Quote</span><br>
|
||||
<span>The Enquiry will also be marked as "Job Won - Order Placed"</span><br><br>
|
||||
<span>You can create a new Job now, or add it to an existing Job later</span><br>
|
||||
|
||||
<? echo $form->create('Document',array('type'=>'post','action'=>'convert_to_oa'));
|
||||
echo $form->input('Document.id');
|
||||
echo $form->input('Job.create_new_job', array('type'=>'select', 'options'=> array('No', 'Yes')));
|
||||
echo $form->input('Job.customer_order_number');
|
||||
echo $form->end();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<? //debug($this->data);?>
|
||||
<? //debug($enquiry);?>
|
||||
<? //print_r($enquiry);?>
|
||||
<?php //debug($document);?>
|
||||
<?php //debug($docType);?>
|
||||
|
|
|
|||
|
|
@ -337,13 +337,8 @@ $(function() {
|
|||
});
|
||||
|
||||
$.get('/quotes/edit/'+quoteID, function(data) {
|
||||
|
||||
|
||||
|
||||
$("#QuoteDetails").html(data);
|
||||
|
||||
$('#QuoteCommercialComments').ckeditor(config);
|
||||
|
||||
$("#QuoteDetails").dialog('open');
|
||||
});
|
||||
});
|
||||
|
|
@ -416,11 +411,11 @@ $(function() {
|
|||
|
||||
updateTextFields(); //Update the CKEditor instances.
|
||||
|
||||
var invoiceDetails = $('#DocumentEditForm').find('input,select,textarea');
|
||||
var oaDetails = $('#DocumentEditForm').find('input,select,textarea');
|
||||
|
||||
|
||||
|
||||
$.post('/documents/ajax_edit', invoiceDetails, function(data) {
|
||||
$.post('/documents/ajax_edit', oaDetails, function(data) {
|
||||
if(data =='SUCCESS') {
|
||||
$("#flashMessage").html("Order Acknowledgement Saved Successfully");
|
||||
}
|
||||
|
|
@ -428,6 +423,7 @@ $(function() {
|
|||
$("#flashMessage").html("Unable to Save Order Acknowledgement");
|
||||
}
|
||||
|
||||
$('.job-title').html($("#OrderAcknowledgementJobId :selected").text());
|
||||
$("#flashMessage").show();
|
||||
|
||||
|
||||
|
|
@ -438,10 +434,29 @@ $(function() {
|
|||
|
||||
|
||||
|
||||
$("#createJobAndOA").click(function() {
|
||||
$("#createOA").click(function() {
|
||||
$("#addJobConfirmation").dialog('open');
|
||||
});
|
||||
|
||||
$(".billing_address").click(function() {
|
||||
if($(this).val() > 0 ) {
|
||||
var address = $(this).next().html();
|
||||
var c = confirm("Set the 'Bill To' field to this address?");
|
||||
if(c) {
|
||||
$("#DocumentBillTo").val(address);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".shipping_address").click(function() {
|
||||
if($(this).val() > 0 ) {
|
||||
var address = $(this).next().html();
|
||||
var c = confirm("Set the 'Ship To' field to this address?");
|
||||
if(c) {
|
||||
$("#DocumentShipTo").val(address);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue