hello ,
i'm experimenting with codeigniter and grocery crud as well as with diffrent codeigniter admin templates. I am trying to use grocery crud in an admin area (I have used the template .ark AdminPanel for Codigniter Bootstrap : Devzone.co.in) and specifically in one of the navigation links(tables) to handle deleting and editing clients. The problem is that when I am trying to add the content of the example.php(views) file into another view file(I called it vwManageUser.php) I am getting the following errors:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: css_files
Filename: admin/vwManageUser.php
Line Number: 9
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: admin/vwManageUser.php
Line Number: 9
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: js_files
Filename: admin/vwManageUser.php
Line Number: 12
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: admin/vwManageUser.php
Line Number: 12
Users Manage Users Module
- Users
-
- Users
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: output
Filename: admin/vwManageUser.php
Line Number: 58
I can send you the code to have a viewpoint of the project.
I have added the examples.php in application\controllers\admin\examples.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Examples extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->helper('url');
$this->load->library('grocery_CRUD');
}
public function _example_output($output = null)
{
$this->load->view('/views/admin/vwManageUser.php',$output);
}
public function offices()
{
$output = $this->grocery_crud->render();
$this->_example_output($output);
}
public function index()
{
echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
die();
}
public function employees()
{
$this->grocery_crud->set_table('employees');
$output = $this->grocery_crud->render();
$this->_example_output($output);
}
public function offices_management()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('offices');
$crud->set_subject('Office');
$crud->required_fields('city');
$crud->columns('city','country','phone','addressLine1','postalCode');
$output = $crud->render();
$this->_example_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
public function employees_management()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_subject('Employee');
$crud->required_fields('lastName');
$crud->set_field_upload('file_url','assets/uploads/files');
$output = $crud->render();
$this->_example_output($output);
}
public function customers_management()
{
$crud = new grocery_CRUD();
$crud->set_table('customers');
$crud->columns('customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit');
$crud->display_as('salesRepEmployeeNumber','from Employeer')
->display_as('customerName','Name')
->display_as('contactLastName','Last Name');
$crud->set_subject('Customer');
$crud->set_relation('salesRepEmployeeNumber','employees','lastName');
$output = $crud->render();
$this->_example_output($output);
}
public function orders_management()
{
$crud = new grocery_CRUD();
$crud->set_relation('customerNumber','customers','{contactLastName} {contactFirstName}');
$crud->display_as('customerNumber','Customer');
$crud->set_table('orders');
$crud->set_subject('Order');
$crud->unset_add();
$crud->unset_delete();
$output = $crud->render();
$this->_example_output($output);
}
public function products_management()
{
$crud = new grocery_CRUD();
$crud->set_table('products');
$crud->set_subject('Product');
$crud->unset_columns('productDescription');
$crud->callback_column('buyPrice',array($this,'valueToEuro'));
$output = $crud->render();
$this->_example_output($output);
}
public function valueToEuro($value, $row)
{
return $value.' €';
}
public function film_management()
{
$crud = new grocery_CRUD();
$crud->set_table('film');
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority');
$crud->set_relation_n_n('category', 'film_category', 'category', 'film_id', 'category_id', 'name');
$crud->unset_columns('special_features','description','actors');
$crud->fields('title', 'description', 'actors' , 'category' ,'release_year', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features');
$output = $crud->render();
$this->_example_output($output);
}
public function film_management_twitter_bootstrap()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('twitter-bootstrap');
$crud->set_table('film');
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority');
$crud->set_relation_n_n('category', 'film_category', 'category', 'film_id', 'category_id', 'name');
$crud->unset_columns('special_features','description','actors');
$crud->fields('title', 'description', 'actors' , 'category' ,'release_year', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features');
$output = $crud->render();
$this->_example_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function multigrids()
{
$this->config->load('grocery_crud');
$this->config->set_item('grocery_crud_dialog_forms',true);
$this->config->set_item('grocery_crud_default_per_page',10);
$output1 = $this->offices_management2();
$output2 = $this->employees_management2();
$output3 = $this->customers_management2();
$js_files = $output1->js_files + $output2->js_files + $output3->js_files;
$css_files = $output1->css_files + $output2->css_files + $output3->css_files;
$output = "<h1>List 1</h1>".$output1->output."<h1>List 2</h1>".$output2->output."<h1>List 3</h1>".$output3->output;
$this->_example_output((object)array(
'js_files' => $js_files,
'css_files' => $css_files,
'output' => $output
));
}
public function offices_management2()
{
$crud = new grocery_CRUD();
$crud->set_table('offices');
$crud->set_subject('Office');
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids")));
$output = $crud->render();
if($crud->getState() != 'list') {
$this->_example_output($output);
} else {
return $output;
}
}
public function employees_management2()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_subject('Employee');
$crud->required_fields('lastName');
$crud->set_field_upload('file_url','assets/uploads/files');
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids")));
$output = $crud->render();
if($crud->getState() != 'list') {
$this->_example_output($output);
} else {
return $output;
}
}
public function customers_management2()
{
$crud = new grocery_CRUD();
$crud->set_table('customers');
$crud->columns('customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit');
$crud->display_as('salesRepEmployeeNumber','from Employeer')
->display_as('customerName','Name')
->display_as('contactLastName','Last Name');
$crud->set_subject('Customer');
$crud->set_relation('salesRepEmployeeNumber','employees','lastName');
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids")));
$output = $crud->render();
if($crud->getState() != 'list') {
$this->_example_output($output);
} else {
return $output;
}
}
}
and the view file vwManageUser.php ( application\views\admin\vwManageUser.php)
<?php
$this->load->view('admin/vwHeader');
?>
<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<style type='text/css'>
body
{
font-family: Arial;
font-size: 14px;
}
a {
color: blue;
text-decoration: none;
font-size: 14px;
}
a:hover
{
text-decoration: underline;
}
</style>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1>Users <small>Manage Users Module</small></h1>
<ol class="breadcrumb">
<li><a href="Users"><i class="icon-dashboard"></i> Users</a></li>
<li class="active"><i class="icon-file-alt"></i> Users</li>
</ol>
</div>
</div><!-- /.row -->
<div>
<a href='<?php echo site_url('admin/examples/customers_management')?>'>Customers</a> |
<a href='<?php echo site_url('admin/examples/orders_management')?>'>Orders</a> |
<a href='<?php echo site_url('admin/examples/products_management')?>'>Products</a> |
<a href='<?php echo site_url('admin/examples/offices_management')?>'>Offices</a> |
<a href='<?php echo site_url('admin/examples/employees_management')?>'>Employees</a> |
<a href='<?php echo site_url('admin/examples/film_management')?>'>Films</a> |
</div>
<div style='height:20px;'></div>
<div>
<?php echo $output; ?>
</div>
</div><!-- /#page-wrapper -->
<?php
$this->load->view('admin/vwFooter');
?>
in the config\autoload.php I have changed libraries to:
$autoload['libraries'] = array('database', 'session', 'grocery_CRUD','image_moo');
I have created separately another project for testing grocery crud only and it was working perfect. I don't really understand how to solve the issues.
Moreover, In the new project by pressing any of the following links Customers | Orders | Products | Offices | Employees | Films |
i am getting the following error
An Error Was Encountered
The configuration file grocery_crud.php does not exist.
I will really appreciate if you could help me. Thank you for your time.