Restored Invoice Editing to allow for them to be marked payment received

This commit is contained in:
Karl Cordes 2011-09-05 11:43:21 +10:00
parent c967490bd9
commit ef42c5e668
4 changed files with 74 additions and 49 deletions

View file

@ -275,8 +275,8 @@ class DocumentsController extends AppController {
$this->set('newDoc', $newDoc);
//
//print_r($newDoc);
//
//print_r($newDoc);
if ($this->Document->saveAll($newDoc)) {
$newid = $this->Document->id;
$this->Session->setFlash(__("Revision {$number_of_revisions} created", true));
@ -323,7 +323,7 @@ class DocumentsController extends AppController {
* @param <int> $id
*/
function convert_to_oa($id = null) {
//$this->layout = 'ajax';
//$this->layout = 'ajax';
if (!$id) {
echo 'Invalid Document ID';
}
@ -364,7 +364,7 @@ class DocumentsController extends AppController {
if ($this->Document->saveAll($newDoc)) {
$newid = $this->Document->id;
$this->Session->setFlash(__("Job {$job['Job']['title']} and Order Acknowledgement created", true));
$this->redirect(array('action'=>'view',$newid));
$this->redirect(array('action'=>'view',$newid));
} else {
$this->Session->setFlash(__('The Document could not be saved. Please, try again.', true));
}
@ -375,8 +375,28 @@ class DocumentsController extends AppController {
}
/**
* Convert an Order Acknowledgement to an Invoice.
*
* @TODO Finish this.
*
* @param <int> $id
*/
function convert_to_invoice($id = null) {
if (!$id) {
echo 'Invalid Document ID';
}
else {
}
}
function pdf($id = null) {
//Configure::write('debug',0);
//Configure::write('debug',0);
if(!$id) {
$this->Session->setFlash(__('Invalid Document', true));
$this->redirect(array('controller'=>'documents', 'action'=>'index'));
@ -435,8 +455,8 @@ class DocumentsController extends AppController {
$this->set('states', $this->Document->Invoice->Enquiry->State->find('list'));
//Set filename for the document.
//
//Set filename for the document.
//
switch($docType) {
case "quote":
$filename = $enquiry['Enquiry']['title'];
@ -492,10 +512,10 @@ class DocumentsController extends AppController {
$document['Document']['pdf_created_at'] = date('Y-m-d H:i:s');
$document['Document']['pdf_created_by_user_id'] = $this->getCurrentUserID();
if($this->Document->save($document)) {
//echo "Set pdf_filename attritbute to: ".$filename;
//echo "Set pdf_filename attritbute to: ".$filename;
}
else {
//echo 'Failed to set pdf_filename to: '.$filename;
//echo 'Failed to set pdf_filename to: '.$filename;
}

View file

@ -6,14 +6,14 @@ class InvoicesController extends AppController {
var $paginate = array(
'limit' => 300,
'contain' => array('Customer'),
'order'=>array('Invoice.id' => 'desc')
'limit' => 300,
'contain' => array('Customer'),
'order'=>array('Invoice.id' => 'desc')
);
function index() {
$this->Invoice->recursive = 0;
$this->set('invoices', $this->paginate());
$this->Invoice->recursive = 0;
$this->set('invoices', $this->paginate());
}
@ -21,16 +21,16 @@ class InvoicesController extends AppController {
function printView() {
$this->layout = 'minimal';
$this->Invoice->recursive = 0;
$this->set('invoices', $this->Invoice->find('all'));
$this->set('invoices', $this->Invoice->find('all'));
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Invoice.', true));
$this->redirect(array('action'=>'index'));
}
if (!$id) {
$this->Session->setFlash(__('Invalid Invoice.', true));
$this->redirect(array('action'=>'index'));
}
$invoice = $this->Invoice->read(null, $id);
$this->set('invoice', $invoice);
$this->set('invoice', $invoice);
$emailIDs = array();
foreach($invoice['Email'] as $email) {
@ -38,37 +38,45 @@ class InvoicesController extends AppController {
}
$emails = $this->Invoice->Email->find('all', array('conditions'=>array('Email.id'=>$emailIDs)));
$this->set('emails', $emails);
}
function payment_received($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Invoice.', true));
$this->redirect(array('action'=>'index'));
}
$invoice = $this->Invoice->read(null, $id);
$invoice['Invoice']['paid'] = 1;
$invoice['Invoice']['payment_received_date'] = date('Y-m-d');
$this->Invoice->save($invoice);
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Invoice', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Invoice->save($this->data)) {
$this->Session->setFlash(__('The Invoice has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Invoice could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$invoice = $this->Invoice->read(null, $id);
$this->data = $invoice;
}
/*function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Invoice', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Invoice->save($this->data)) {
$this->Session->setFlash(__('The Invoice has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Invoice could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$invoice = $this->Invoice->read(null, $id);
$this->data = $invoice;
}
$users = $this->Invoice->User->find('list');
$jobs = $this->Invoice->Job->find('list', array('conditions'=>array('Job.enquiry_id'=>$invoice['Invoice']['enquiry_id'])));
$this->set(compact('users', 'jobs'));
}*/
$jobs = $this->Invoice->Job->find('list', array('conditions'=>array('Job.enquiry_id'=>$invoice['Invoice']['enquiry_id'])));
$this->set(compact('users', 'jobs'));
}
/*function delete($id = null) {
if (!$id) {

View file

@ -11,7 +11,6 @@
echo $form->input('payment_received_date');
echo $form->input('enquiry_id', array('type'=>'hidden'));
echo $form->input('job_id');
echo $form->input('user_id');
?>
</fieldset>
<?php echo $form->end('Submit');?>

View file

@ -75,9 +75,7 @@
<td class="actions">
<?php echo $html->link(__('View', true), array('action' => 'view', $invoice['Invoice']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $invoice['Invoice']['id'])); ?>
<?=$html->link('Edit', '/invoices/edit/'.$invoice['Invoice']['id']);?>
</td>
</tr>
<?php endforeach; ?>