Hello, complete CI / GCrud newbie here.
I am trying to re-create my page which shows fields from 3 different tables.
The datagrid should allow search on all fields, and i want to have custom columns not from database with custom actions.
for example, one action is "send email" which just calls another php script with values from some of the fields in the datagrid.
The problem I have is that the field names in the different tables that have relationship are not the same name.
table structure:
New_Orders: id, member_id, order_date, location, location, is_active, is_delete
Members: id, company, email, phone, status, firstname, lastname
New_Orders_Services: id, locationid, service_id, is_delete
My current SQL statement looks like this:
SELECT new_orders.id, new_orders.member_id, new_orders.order_date, new_orders.location, new_orders.isactive, members.company, members.email, members.phone, members.status, CONCAT(members.first_name, " ", members.last_name) AS fullname, new_orders_services.locationid FROM new_orders JOIN members ON members.id = new_orders.member_id JOIN new_orders_services ON new_orders_services.order_id = new_orders.id WHERE new_orders_services.service_id = 0 AND new_orders_services.is_delete = 0 AND new_orders.is_delete = 0
My code looks like this:
$crud->set_table('new_orders'); $crud->set_subject('Orders'); $crud->required_fields('id','member_id','order_date','location','isactive'); $crud->set_relation('member_id','members','{company} {email} {phone} {status} {fullname} ( {first_name} {last_name} )');
My question is: how do i tell Grocery CRUD to set the relationship between Orders and Members based on orders.member_id and members.id
Many thanks in advance.