<?php

/*
Copyright (c) 2010, Till Brehm, projektfarm Gmbh
All rights reserved.
*/

/******************************************
* Begin Form configuration
******************************************/

$list_def_file = "list/proforma.list.php";
$tform_def_file = "form/invoice.tform.php";

/******************************************
* End Form configuration
******************************************/

require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');

//* Check permissions for module
$app->auth->check_module_permissions('billing');

$app->uses('tpl,tform');
$app->load('tform_actions');

class page_action extends tform_actions {
	
	function onBeforeDelete() {
		global $app, $conf;
		
		if($this->dataRecord['invoice_number'] != '') {
			$app->error($app->tform->lng('remove_finalized_invoice_denied_txt'));
		}
	}
	
	function onAfterDelete() {
		global $app, $conf;
		
		if($this->id > 0) {
			$app->db->query("DELETE FROM invoice_item WHERE invoice_id = ".$this->id);
		}
	}
}

$page = new page_action;
$page->onDelete()

?>