Prompt for customer Order Number when converting a Quote to Job+OA closes #57
This commit is contained in:
parent
212f6bdcff
commit
7989dd24ac
|
|
@ -314,14 +314,15 @@ class DocumentsController extends AppController {
|
|||
*
|
||||
* Make a new Document (orderack) with the same LineItems as Quote with Document ID #$id
|
||||
*
|
||||
* @param <int> $id
|
||||
*
|
||||
*/
|
||||
function convert_to_oa($id = null) {
|
||||
//$this->layout = 'ajax';
|
||||
if (!$id) {
|
||||
echo 'Invalid Document ID';
|
||||
function convert_to_oa() {
|
||||
$this->layout = 'ajax';
|
||||
if (empty($this->data)) {
|
||||
echo 'FAILURE';
|
||||
}
|
||||
else {
|
||||
$id = $this->data['Document']['id'];
|
||||
|
||||
$originalDoc = $this->Document->find('first', array('conditions' => array('Document.id' => $id)));
|
||||
|
||||
|
|
@ -335,7 +336,7 @@ class DocumentsController extends AppController {
|
|||
|
||||
$this->Document->OrderAcknowledgement->Enquiry->Customer->save($customer);
|
||||
|
||||
$job = $this->Document->OrderAcknowledgement->Job->newJob($enquiry); //Only way to know Enquiry ID is if it's a Quote.
|
||||
$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';
|
||||
|
|
@ -350,7 +351,7 @@ class DocumentsController extends AppController {
|
|||
$newDoc['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
||||
$newDoc['Document']['revision'] = 0; //No revisions for Order Acks. I have decreed it!
|
||||
$newDoc['Document']['type'] = 'orderAck';
|
||||
|
||||
|
||||
if(isset($enquiry['BillingAddress']['id'])) {
|
||||
$newDoc['Document']['bill_to'] = '<b>'.$customer['Customer']['name'].'</b><br/>';
|
||||
$newDoc['Document']['bill_to'] .= $this->Document->OrderAcknowledgement->Enquiry->formatAddress($enquiry['BillingAddress']['id'], 'BillingAddress');
|
||||
|
|
@ -560,7 +561,7 @@ class DocumentsController extends AppController {
|
|||
$this->set('enquiry', $enquiry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class Job extends AppModel {
|
|||
);
|
||||
|
||||
|
||||
function newJob($enquiry) {
|
||||
function newJob($enquiry, $customerOrderNumber = null) {
|
||||
|
||||
$this->create();
|
||||
|
||||
|
|
@ -89,6 +89,10 @@ class Job extends AppModel {
|
|||
$newJob['Job']['enquiry_id'] = $enquiry['Enquiry']['id'];
|
||||
$newJob['Job']['date_order_received'] = date('Y-m-d');
|
||||
|
||||
if(!empty($customerOrderNumber)) {
|
||||
$newJob['Job']['customer_order_number'] = $customerOrderNumber;
|
||||
}
|
||||
|
||||
if ($this->save($newJob)) {
|
||||
|
||||
return $this->find('first',array('conditions'=>array('Job.id'=>$this->id)));
|
||||
|
|
|
|||
0
views/documents/convert_to_oa.ctp
Normal file
0
views/documents/convert_to_oa.ctp
Normal file
|
|
@ -76,8 +76,14 @@ 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>The Enquiry will also be marked as "Job Won - Order Placed"</span><br>
|
||||
Continue?
|
||||
<span>The Enquiry will also be marked as "Job Won - Order Placed"</span><br><br>
|
||||
|
||||
<? echo $form->create('Document',array('type'=>'post','action'=>'convert_to_oa'));
|
||||
echo $form->input('Document.id');
|
||||
echo $form->input('Job.customer_order_number');
|
||||
echo $form->end();
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<? //debug($this->data);?>
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ $(function() {
|
|||
|
||||
$( "#addJobConfirmation" ).dialog({
|
||||
autoOpen: false,
|
||||
height: 200,
|
||||
height: 400,
|
||||
width: 400,
|
||||
modal: true,
|
||||
buttons: {
|
||||
|
|
@ -138,7 +138,28 @@ $(function() {
|
|||
|
||||
var documentID = $("#documentID").html();
|
||||
|
||||
window.location.href = "/documents/convert_to_oa/"+documentID;
|
||||
//window.location.href = "/documents/convert_to_oa/"+documentID;
|
||||
//var newOAform = $('#DocumentConvertToOaForm').find('input');
|
||||
var newOAform = $('#DocumentConvertToOaForm');
|
||||
newOAform.submit();
|
||||
|
||||
|
||||
|
||||
/*$.post('/documents/convert_to_oa', newOAform, function(data) {
|
||||
if(data =='SUCCESS') {
|
||||
$("#flashMessage").html("Invoice Saved Successfully");
|
||||
}
|
||||
else {
|
||||
$("#flashMessage").html("Unable to Save Invoice");
|
||||
}
|
||||
|
||||
$("#flashMessage").show();
|
||||
|
||||
|
||||
loadLineItems();
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
},
|
||||
Cancel: function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue