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
|
* Make a new Document (orderack) with the same LineItems as Quote with Document ID #$id
|
||||||
*
|
*
|
||||||
* @param <int> $id
|
*
|
||||||
*/
|
*/
|
||||||
function convert_to_oa($id = null) {
|
function convert_to_oa() {
|
||||||
//$this->layout = 'ajax';
|
$this->layout = 'ajax';
|
||||||
if (!$id) {
|
if (empty($this->data)) {
|
||||||
echo 'Invalid Document ID';
|
echo 'FAILURE';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$id = $this->data['Document']['id'];
|
||||||
|
|
||||||
$originalDoc = $this->Document->find('first', array('conditions' => array('Document.id' => $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);
|
$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) {
|
if($job == false) {
|
||||||
echo 'Error: Unable to create Job';
|
echo 'Error: Unable to create Job';
|
||||||
|
|
@ -350,7 +351,7 @@ class DocumentsController extends AppController {
|
||||||
$newDoc['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
$newDoc['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
||||||
$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';
|
||||||
|
|
||||||
if(isset($enquiry['BillingAddress']['id'])) {
|
if(isset($enquiry['BillingAddress']['id'])) {
|
||||||
$newDoc['Document']['bill_to'] = '<b>'.$customer['Customer']['name'].'</b><br/>';
|
$newDoc['Document']['bill_to'] = '<b>'.$customer['Customer']['name'].'</b><br/>';
|
||||||
$newDoc['Document']['bill_to'] .= $this->Document->OrderAcknowledgement->Enquiry->formatAddress($enquiry['BillingAddress']['id'], 'BillingAddress');
|
$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);
|
$this->set('enquiry', $enquiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class Job extends AppModel {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
function newJob($enquiry) {
|
function newJob($enquiry, $customerOrderNumber = null) {
|
||||||
|
|
||||||
$this->create();
|
$this->create();
|
||||||
|
|
||||||
|
|
@ -89,6 +89,10 @@ class Job extends AppModel {
|
||||||
$newJob['Job']['enquiry_id'] = $enquiry['Enquiry']['id'];
|
$newJob['Job']['enquiry_id'] = $enquiry['Enquiry']['id'];
|
||||||
$newJob['Job']['date_order_received'] = date('Y-m-d');
|
$newJob['Job']['date_order_received'] = date('Y-m-d');
|
||||||
|
|
||||||
|
if(!empty($customerOrderNumber)) {
|
||||||
|
$newJob['Job']['customer_order_number'] = $customerOrderNumber;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->save($newJob)) {
|
if ($this->save($newJob)) {
|
||||||
|
|
||||||
return $this->find('first',array('conditions'=>array('Job.id'=>$this->id)));
|
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">
|
<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 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>
|
<span>The Enquiry will also be marked as "Job Won - Order Placed"</span><br><br>
|
||||||
Continue?
|
|
||||||
|
<? 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>
|
</div>
|
||||||
|
|
||||||
<? //debug($this->data);?>
|
<? //debug($this->data);?>
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ $(function() {
|
||||||
|
|
||||||
$( "#addJobConfirmation" ).dialog({
|
$( "#addJobConfirmation" ).dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
height: 200,
|
height: 400,
|
||||||
width: 400,
|
width: 400,
|
||||||
modal: true,
|
modal: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
|
@ -138,7 +138,28 @@ $(function() {
|
||||||
|
|
||||||
var documentID = $("#documentID").html();
|
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() {
|
Cancel: function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue