<?

$countString = $paginator->counter(array('format' => '%page% %pages% %current% %count%'));

$numbers = explode(" ",$countString);

$page = $numbers[0];
$totalPages = $numbers[1];
$currentNoRecord = $numbers[2];

$totalNoRecords = $numbers[3];


$recordObj->total = $totalPages;
$recordObj->page = $page;
$recordObj->records = $totalNoRecords;




?>

<?
$i=0;
foreach($jobs as $job) {


    $poString = '';
    foreach($job['PurchaseOrder'] as $po) {
	$poString .= ' '.$html->link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));
    }


    $cellArray = array(

	    $job['Job']['job_status'],
	    $job['Job']['sale_category1'],
	    $job['Job']['sale_category'],
	    $job['Job']['shipment_category'],
	    $html->link($job['Job']['title'], array('controller'=>'jobs','action'=>'view', $job['Job']['id'])),
	    $poString,


	    $html->link($customers[$job['Enquiry']['customer_id']], array('controller'=>'customers','action'=>'view', $job['Enquiry']['customer_id'])),
	    $job['Job']['comments'],
	    $job['Job']['customer_order_number'],
	    $job['Job']['date_order_received'],

	    $job['Job']['supplier_reference'],
	    $job['Job']['date_order_placed_on_principle'],

	    $job['Job']['date_scheduled_ex_works'],
	    $job['Job']['date_order_sent_to_customer'],
	    $job['Job']['domestic_freight_paid_by'],


	    $job['Job']['company_gross_sales_aud'],
	    $job['Job']['net_sales_aud'],
	    $job['Job']['gross_profit_aud'],
	    $job['Job']['ato_exchange_rate'],
	    $job['Job']['gst'],
	    $job['Job']['currency_id'],
	    $job['Job']['gst_amount'],
	    $job['Job']['gross_commisions'],
	    $job['Job']['invoiced_amount_inc_gst'],
	    $job['Job']['net_export_sales_aud'],
	    $job['Job']['gross_profit_exports_aud'],
	    $job['Job']['gp_percent'],
	    $job['Job']['gross_australian_sales_foreign_currency'],
	    $job['Job']['net_australian_sales_foreign_currency'],
	    $job['Job']['gross_profit_value_australian_sales_foreign_currency'],
	    $job['Job']['gross_export_sales_foreign_currency'],
	    $job['Job']['net_export_sales_foreign_currency'],
	    $job['Job']['gross_profit_value_after_discount_exports_foreign_currency'],
	    $job['Job']['gross_commissions'],
	    $job['Job']['net_commissions']
    );




    $recordObj->rows[$i]['id'] = $job['Job']['id'];
    //$rows[$i] = $job;
    $recordObj->rows[$i]['cell'] = $cellArray;
    //$recordObj->rows[$i]['cell'] = $job['Job'];
    $i++;
};



$jsonObj = json_encode($recordObj);
echo $jsonObj;
?>
