application/controllers/Subscribe.php
/*
    * It Fetches the products data from the product table 
    * this function is called from the datatable ajax function
    */
It Fetches the products data from the product table
this function is called from the datatable ajax function
It Fetches the products data from the product table this function is called from the datatable ajax function
public function fetchSubscriptionData()
	{
        if(!in_array('viewSubscription', $this->permission)) {
            redirect('dashboard', 'refresh');
        }
		$result = array('data' => array());
		$data = $this->model_subscribe->getSubscriptionData();
		foreach ($data as $key => $value) {
            $user_data =  $this->model_users->getUserData($value['user_id']);
            $name = $user_data['firstname'].' '.$user_data['lastname'];
            $buttons = '';
            if(in_array('updateSubscription', $this->permission)) {
    			$buttons .= '<a href="'.base_url('subscribe/update/'.$value['id']).'" style="border: 2px solid #4CAF50" class="btn btn-default"><i class="fa fa-pencil" style="color:#4CAF50"></i></a>';
            }
            if(in_array('deleteSubscription', $this->permission)) {
    			$buttons .= ' <button type="button" style="border: 2px solid #f44336" class="btn btn-default" onclick="removeFunc('.$value['id'].')" data-toggle="modal" data-target="#removeModal"><i class="fa fa-trash" style="color:#f44336"></i></button>';
            }
            $store_id = $value['store_id'];
            $store_name =  $this->model_stores->getStoresData($store_id);
            $availability = ($value['active'] == 1) ? '<span class="label label-success">Active</span>' : '<span class="label label-warning">Inactive</span>';
			$result['data'][$key] = array(
                $name,
				$value['subscribe_no'],
                $store_name['name'],
                $value['net_amount'],
				$availability,
				$buttons
			);
		} 
		echo json_encode($result);
	}
public function fetchSubscriptionData ( ) { if ( ! in_array ( 'viewSubscription' , $ this -> permission ) ) { redirect ( 'dashboard' , 'refresh' ) ; } $ result = array ( 'data' => array ( ) ) ; $ data = $ this -> model_subscribe -> getSubscriptionData ( ) ; foreach ( $ data as $ key => $ value ) { $ user_data = $ this -> model_users -> getUserData ( $ value [ 'user_id' ] ) ; $ name = $ user_data [ 'firstname' ] . ' ' . $ user_data [ 'lastname' ] ; $ buttons = '' ; if ( in_array ( 'updateSubscription' , $ this -> permission ) ) { $ buttons .= '<a href="' . base_url ( 'subscribe/update/' . $ value [ 'id' ] ) . '" style="border: 2px solid #4CAF50" class="btn btn-default"><i class="fa fa-pencil" style="color:#4CAF50"></i></a>' ; } if ( in_array ( 'deleteSubscription' , $ this -> permission ) ) { $ buttons .= ' <button type="button" style="border: 2px solid #f44336" class="btn btn-default" onclick="removeFunc(' . $ value [ 'id' ] . ')" data-toggle="modal" data-target="#removeModal"><i class="fa fa-trash" style="color:#f44336"></i></button>' ; } $ store_id = $ value [ 'store_id' ] ; $ store_name = $ this -> model_stores -> getStoresData ( $ store_id ) ; $ availability = ( $ value [ 'active' ] == 1 ) ? '<span class="label label-success">Active</span>' : '<span class="label label-warning">Inactive</span>' ; $ result [ 'data' ] [ $ key ] = array ( $ name , $ value [ 'subscribe_no' ] , $ store_name [ 'name' ] , $ value [ 'net_amount' ] , $ availability , $ buttons ) ; } echo json_encode ( $ result ) ; }
It Fetches the products data from the product table
 this function is called from the datatable ajax function
It Fetches the products data from the product table this function is called from the datatable ajax function
// button // /foreach