Copy OA details to invoices
This commit is contained in:
parent
6fe62ce71b
commit
ed08821e8e
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
Configure::write('debug', 0);
|
||||
|
||||
Configure::write('version', '0.98');
|
||||
Configure::write('version', '0.9.8');
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
|
||||
|
|
@ -68,9 +68,10 @@ if($host == 'cmc.lan' || $host == '192.168.0.7') {
|
|||
'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
|
||||
));
|
||||
|
||||
|
||||
}
|
||||
else { //Development config
|
||||
$basedir = '/home/karlcordes/CMC-Sales/app/';
|
||||
$basedir = '/home/karlcordes/Sites/CMC-Sales/app/';
|
||||
|
||||
Cache::config('default', array(
|
||||
'engine' => 'File', //[required]
|
||||
|
|
|
|||
|
|
@ -238,6 +238,27 @@ class DocumentsController extends AppController {
|
|||
|
||||
$this->data['Invoice']['currency_id'] = 2; //All new Invoices default to AUD.
|
||||
|
||||
|
||||
if(isset($source_document_id)) {
|
||||
//This is not ideal. But nothing else is either.
|
||||
$sourceDoc = $this->Document->find('first', array('conditions' => array('Document.id' => $source_document_id)));
|
||||
if($sourceDoc['Document']['type'] == 'orderAck') {
|
||||
$oa_attribues = array(
|
||||
'issue_date',
|
||||
'ship_via',
|
||||
'fob',
|
||||
'estimated_delivery'
|
||||
);
|
||||
|
||||
foreach($oa_attribues as $attr) {
|
||||
|
||||
$this->data['Invoice'][$attr] = $sourceDoc['OrderAcknowledgement'][$attr];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case "purchaseOrder":
|
||||
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid);
|
||||
|
|
@ -267,6 +288,18 @@ class DocumentsController extends AppController {
|
|||
|
||||
if(isset($source_document_id)) {
|
||||
$sourceDoc = $this->Document->find('first', array('conditions' => array('Document.id' => $source_document_id)));
|
||||
|
||||
|
||||
$copy_doc_attributes = array('cmc_reference', 'shipping_details', 'bill_to', 'ship_to');
|
||||
foreach($copy_doc_attributes as $attr) {
|
||||
$this->data['Document'][$attr] = $sourceDoc['Document'][$attr];
|
||||
}
|
||||
/*echo "<pre>";
|
||||
print_r($sourceDoc);
|
||||
echo "--<br>";
|
||||
print_r($this->data);
|
||||
echo "</pre>";
|
||||
die();*/
|
||||
if(!empty($sourceDoc['LineItem'])) {
|
||||
$this->data['LineItem'] = $sourceDoc['LineItem'];
|
||||
foreach($this->data['LineItem'] as $index => $li) {
|
||||
|
|
@ -471,7 +504,7 @@ class DocumentsController extends AppController {
|
|||
|
||||
if ($this->Document->saveAll($newDoc)) {
|
||||
$newid = $this->Document->id;
|
||||
if($job) {
|
||||
if(isset($job)) {
|
||||
$this->Session->setFlash(__("Job {$job['Job']['title']} and Order Acknowledgement created", true));
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ $(function() {
|
|||
});
|
||||
|
||||
$("#emailDocButton").click(function() {
|
||||
var confirmed = confirm("This will email this Quote and all Attachments to the Customer. Are you sure you want to do this?");
|
||||
var confirmed = confirm("This will email this Document and all Attachments to the Customer. Are you sure you want to do this?");
|
||||
if(confirmed) {
|
||||
window.location = $(this).data('url');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue