<?php defined('SYSPATH') or die('No direct access allowed.');

/**
 * This class provides OSB invoice task capabilities.
 *
 * @package    Invoice
 * @category   Controllers
 * @author     Deon George
 * @copyright  (c) 2009-2013 Open Source Billing
 * @license    http://dev.osbill.net/license.html
 */
class Controller_Task_Invoice extends Controller_Task {
	public $auto_render = FALSE;

	public function action_audit_invoice_items() {
		$output = '';

		foreach (ORM::factory('Invoice_Item')->find_all() as $iio) {
			if ($iio->product_name AND $iio->product_id) {
				if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->title()))) {
					$iio->product_name = NULL;
					$iio->save();
				} else {
					print_r(array("DIFF",'id'=>$iio->id,'pn'=>serialize($iio->product_name),'ppn'=>serialize($iio->product->title()),'pid'=>$iio->product_id,'test'=>strcasecmp($iio->product_name,$iio->product->title())));
				}
			}
		}

		$this->response->body($output);
	}
}
?>
