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