Controller
$crud->set_table('transaction_receipt'); $crud->columns('receipt_code', 'receipt_status', 'transaction_type', 'user_id', 'price', 'create_date', 'artwork_list', 'artwork_count', 'last_update_date', 'last_update_admin'); $crud->fields('receipt_code', 'receipt_status', 'transaction_type', 'user_id', 'price', 'remark', 'create_date', 'artwork_list'); $crud->set_relation('user_id', 'auth_users', '({vip_id}) {name}', array('is_admin' => 'not_admin'), 'vip_id ASC'); $crud->set_relation('last_update_admin', 'auth_users', 'name'); $artwork_list_relation = '{(SELECT `inventory_assessments`.`name` FROM `inventory_assessments` WHERE `inventory_assessments`.`assessment_id` = "20")}'; $crud->set_relation_n_n('artwork_list', 'inventory_artworks_transaction', 'inventory_artworks', 'receipt_id', 'artwork_id', '{inventory_artworks.artwork_code} - ' . $artwork_list_relation, 'priority', 'inventory_artworks.artwork_id NOT IN (SELECT inventory_artworks_transaction.artwork_id FROM inventory_artworks_transaction)');
I can directly query the sql to printout the result. But can to run in Grocerycrud