Jump to content


Member Since 30 Sep 2013
Offline Last Active Oct 22 2013 09:47 PM

Topics I've Started

Auto-calculated amount in Sales Transaction

10 October 2013 - 04:31 PM

I have the following tables:


1. Sales

with fields (item_id, item_type_id, quantity_sold, amount_buying_price, amount_selling_price)


2. Item_details

with fields (item_id, item_type_id, buying_price, selling_price)


Attached File  sales.png   36.58K   270 downloads


The amounts must load in the respective fields after the item and item type are selected.

Users will select item and item type, then enter quantity sold, while they enter the quantity, I want the amounts for buying price and selling price to display.


Amount - Buying Price is calculated as:

Amount_buying_price = Quantity Sold x Buying Price

Amount - Selling Price is calculated as:

Amount_selling_price = Quantity Sold x Selling Price

The buying and selling price values can be retrieved from item_details table.


Finally, the user will click save and the record will be saved in the Sales Table

Using Custom Template

05 October 2013 - 10:19 AM

I'm using the latest Grocery CRUD (version 1.4.1).

I want to integrate a custom template and I have configured my files as follows:


I created an includes directory in views, which contains the following files:

  • header.php - contains header files like js,css...
  • footer.php - contains footer files
  • template.php - loads header, content and footer

My template.php looks like this:


This is how I call them from the controller:

public function index()
     $data['content'] = 'index';
     $this->load->view('includes/template', $data);

After using Grocery CRUD, my controller looks like this:

class Users extends CI_Controller {

    public function __construct() 


    public function output($output = null)

    public function index()
        $this->output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));

    public function view()
        try {
            $crud = new grocery_CRUD();



            $output = $crud->render();

        } catch(Exception $e){
            show_error($e->getMessage().' --- '.$e->getTraceAsString());

I went through one of the threads (Template controller to grocery CRUD). It didn't seem to work.

How do I integrate my custom template with Grocery CRUD?



Concatenate fields after retrieving them from different tables

30 September 2013 - 04:43 PM

I'm facing difficulties with concatenating two fields after joining tables. I went through a post about concatenating two fields into one (http://www.grocerycr...into-one-field/), it wasn't a great help.



Table items has fields item_name and item_type_id, which stores the id of item_type.

Table item_type has field item_type, which stores the item_type


I need to display a dropdown list that loads item_name + item_type



1. item_name = BEER, item_type = BOTTLE

2. item_name = BEER, item_type = CAN


So, dropdown should display: