First of all I must congratulate the author of grocery CRUD for a wonderful piece of software. However, i am having a major problem over the past 3 days and has been unable to solve it. I am attaching the tables from the db that are to be used. What i want to do is when a particular officer logs in, i want to be able to show only projects belonging to that officer. What is happening currently is all the projects are being shown. To get a better picture of what i'm talking about please go to http://thepcguygy.com/go
username: gibson
password: gibson
As soon as you login you will notice a list of projects with various officers ID. Gibson's ID is 3, so only the first project should show up.
This is My Controller
function getMyProjects($userID){
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('project');
$crud->set_relation_n_n('Officer', 'projOfficer', 'user', 'projectID', 'userID', 'ID','ID');
//$crud->set_relation('subSectionID','subSection','subSectionName');
$crud->columns('projectName','description','subSectionID','sourceOfInvestment','status', 'Officer');
$crud->display_as('projectName','Project')
->display_as('subSectionID','SubSector')
->display_as('sourceOfInvestment','Investment Source')
->display_as('status','Status')
->display_as('typeOfInvestment','Investment Type')
->display_as('projectSize','Size of Project')
->display_as('projectArea','Project Area')
->display_as('investmentAgreement','Investment Agreement');
$crud->field_type('projectArea','multiselect',
array('1'=>'Region 1','2'=>'Region 2','3'=>'Region 3','4'=>'Region 4','5'=>'Region 5','6'=>'Region 6',
'7'=>'Region 7','8'=>'Region 8','9'=>'Region 9','10'=>'Region 10'));
$crud->field_type('sourceOfInvestment','dropdown',
array('1'=>'Foreign Direct Investment','2'=>'Joint Venture','3'=>'Overseas Guyanese','4'=>'Local'));
$crud->field_type('status','dropdown',
array('1'=>'Operating Project','2'=>'Pipeline Project','3'=>'Pre-Feasibility Stage','4'=>'Closed','5'=>'Not Operating'));
$crud->field_type('typeOfInvestment','dropdown',
array('1'=>'New Project','2'=>'Expansion Project','3'=>'Acquisition Project','4'=>'Upgraded Project'));
$crud->field_type('projectSize','dropdown',
array('1'=>'Micro Scale','2'=>'Small Scale','3'=>'Medium Scale','4'=>'Large Scale'));
$crud->field_type('investmentAgreement','dropdown',
array('0'=>'No IA ','1'=>'IA is Signed','2'=>'IA has been renewed by GRA','3'=>'IA at GRA','4'=>'IA has been Rejected','5'=>'IA at Go Invest'));
$crud->field_type('description','text');
$crud->set_relation('ID','projOfficer','projectID',array('Officer'=>3));
$crud->add_action('More', '', 'projects/getProject','ui-icon-plus');
$crud->unset_add();
$crud->unset_delete();
$output = $crud->render();
return $output;
}
catch(Exception $e)
{
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
I've tried putting in the where clause in the set_relation_n_n function, but it doesn't work.
$crud->set_relation_n_n('Officer', 'projOfficer', 'user', 'projectID', 'userID', 'ID','ID',array('userID'=>$userID));
What am i doing wrong?