Added Convert Quote to OA Button
This commit is contained in:
parent
044310acee
commit
c967490bd9
|
|
@ -329,35 +329,21 @@ class DocumentsController extends AppController {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
|
||||||
$originalDoc = $this->Document->find('first', array('conditions' => array('Document.id' => $id)));
|
$originalDoc = $this->Document->find('first', array('conditions' => array('Document.id' => $id)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->find('first', array('conditions'=>array('Enquiry.id'=>$originalDoc['Quote']['enquiry_id'])));
|
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->find('first', array('conditions'=>array('Enquiry.id'=>$originalDoc['Quote']['enquiry_id'])));
|
||||||
|
|
||||||
$enquiry['Enquiry']['status_id'] = 3; //Job Won, Order Placed
|
$enquiry['Enquiry']['status_id'] = 3; //Job Won, Order Placed
|
||||||
|
|
||||||
$this->Document->OrderAcknowledgement->Enquiry->save($enquiry);
|
$this->Document->OrderAcknowledgement->Enquiry->save($enquiry);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$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); //Only way to know Enquiry ID is if it's a Quote.
|
||||||
|
|
||||||
|
|
||||||
if($job == false) {
|
if($job == false) {
|
||||||
echo 'Error: Unable to create Job';
|
echo 'Error: Unable to create Job';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$newDoc = array();
|
$newDoc = array();
|
||||||
|
|
||||||
$newDoc['Document']['type'] = 'orderAck';
|
$newDoc['Document']['type'] = 'orderAck';
|
||||||
|
|
||||||
$newDoc['OrderAcknowledgement']['job_id'] = $job['Job']['id'];
|
$newDoc['OrderAcknowledgement']['job_id'] = $job['Job']['id'];
|
||||||
|
|
||||||
$newDoc['OrderAcknowledgement']['enquiry_id'] = $enquiry['Enquiry']['id'];
|
$newDoc['OrderAcknowledgement']['enquiry_id'] = $enquiry['Enquiry']['id'];
|
||||||
$newDoc['OrderAcknowledgement']['currency_id'] = 2; //Default to AUD.
|
$newDoc['OrderAcknowledgement']['currency_id'] = 2; //Default to AUD.
|
||||||
$newDoc['OrderAcknowledgement']['issue_date'] = date('Y-m-d');
|
$newDoc['OrderAcknowledgement']['issue_date'] = date('Y-m-d');
|
||||||
|
|
@ -365,8 +351,6 @@ class DocumentsController extends AppController {
|
||||||
$newDoc['Document']['revision'] = 0; //No revisions for Order Acks. I have decreed it!
|
$newDoc['Document']['revision'] = 0; //No revisions for Order Acks. I have decreed it!
|
||||||
$newDoc['Document']['type'] = 'orderAck';
|
$newDoc['Document']['type'] = 'orderAck';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Copy the LineItems from this Document. Applies to all of the Document Types */
|
/** Copy the LineItems from this Document. Applies to all of the Document Types */
|
||||||
if(!empty($originalDoc['LineItem'])) {
|
if(!empty($originalDoc['LineItem'])) {
|
||||||
$newDoc['LineItem'] = $originalDoc['LineItem'];
|
$newDoc['LineItem'] = $originalDoc['LineItem'];
|
||||||
|
|
@ -386,14 +370,6 @@ class DocumentsController extends AppController {
|
||||||
}
|
}
|
||||||
$this->Document->saveAll($newDoc);
|
$this->Document->saveAll($newDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,13 @@
|
||||||
<div class="docButtons">
|
<div class="docButtons">
|
||||||
<?=$html->link('Generate PDF of this Order Acknowledgement', '/documents/pdf/'.$document['Document']['id']);?>
|
<?=$html->link('Generate PDF of this Order Acknowledgement', '/documents/pdf/'.$document['Document']['id']);?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="docOperations" style="display: none;">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
<div id="invoiceDetails" class="documentDetails">
|
<div id="invoiceDetails" class="documentDetails">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ echo $form->input('Document.id');
|
||||||
|
|
||||||
<div class="docOperations">
|
<div class="docOperations">
|
||||||
<h3>Customer placed an order for this Quote?</h3>
|
<h3>Customer 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'));?>
|
<? //$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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pages">
|
<div class="pages">
|
||||||
|
|
|
||||||
|
|
@ -134,13 +134,11 @@ $(function() {
|
||||||
width: 400,
|
width: 400,
|
||||||
modal: true,
|
modal: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
"Continue": function() {
|
"Create New Job and Order Acknowledgement": function() {
|
||||||
|
|
||||||
var documentID = $("#documentID").html();
|
var documentID = $("#documentID").html();
|
||||||
|
|
||||||
$.get('/documents/convert_to_oa/'+documentID, null, function(data) {
|
window.location.href = "/documents/convert_to_oa/"+documentID;
|
||||||
$( "#QuoteDetails" ).dialog('close');
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
Cancel: function() {
|
Cancel: function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue