示例#1
0
	}

	$_REQUEST['mode'] = 'edit';
}elseif($_REQUEST['mode'] == 'add_ex_link'){
	if(intval($_REQUEST['ex_id']) == 0){
		fatal_error("You must provide a expense id to add a link!");
	}

	$ill = new SI_InvoiceLineLink();
	$ill->expense_id = $_REQUEST['ex_id'];
	$ill->invoice_line_id = $line->id;
	if($line->unit_price > 0 && $ill->getUnitPrice() != $line->unit_price){
		fatal_error("You can not add this expense to this line because it has a different unit price!");	
	}else{
		if($line->unit_price <= 0) $line->unit_price = $ill->getUnitPrice();
		if($line->description == '') $line->description = $ill->getDescription();
	}
	
	if($ill->add() === FALSE){
		$error_msg .= "Could not add expense to invoice!";
		debug_message($ill->getLastError());	
	}else{
		$line->quantity += $ill->getQuantity();
		$line->addTax();
		if($line->update() === FALSE){
			$error_msg .= "Could not update quantity on line item!";
			debug_message($line->getLastError());	
		}else{
			$ct = new SI_CompanyTransaction();
			if($ct->get($invoice->trans_id) === FALSE){
				$error_msg .= "Error getting transaction for invoice!";