create custom menu & list view under module invoice

hi, I’m trying to customizing module invoice. I have project called invoice rule, on my idea, this is still part of invoice system, so I’m customizing module invoice instead of creating new module. i have table called invoice_rule and related (one to one) with the iid (table accounts). so the idea is, every account has one invoice rule, and i want to create list of accounts under url :

http://crm.dev/index.php?module=AOS_Invoices&action=rules_index&parentTab=All

that page will show list of accounts which has invoice rule.

my codes :


#custom/modules/AOS_Invoices/controller.php
require_once ('include/MVC/Controller/SugarController.php');

class AOS_InvoicesController extends SugarController
{

    public function action_rules_index() {
        #sample parsing data into view
        $this->view_object_map['mylist'] = array('name' => 'anarky');
        $this->view = 'rules_index';
    }

}

#custom/modules/AOS_Invoices/views/view.rules_index.php
require_once ('include/MVC/View/views/view.list.php');
require_once('custom/modules/Accounts/AccountsListViewSmarty.php');

class AOS_InvoicesViewRules_Index extends ViewList
{

    public function preDisplay() {
        parent::preDisplay();
        $this->lv = new AccountsListViewSmarty();
    }

    public function display() {
        if (!$this->bean || !$this->bean->ACLAccess('list')) {
            ACLController::displayNoAccess();
        } else {
            #get parsed data from controller
            echo var_export($this->view_object_map['mylist'], true);
        }
    }

    public function listViewPrepare() {
        
    }

    public function listViewProcess() {
        
    }

}

the page is showing properly, it display “array ( ‘name’ => ‘anarky’, )”

how to create list of accounts which has invoice rule and the search form?

Hey kelaskakap,

I’m not sure I’m entirely clear on what you’re trying to do, but I believe you are on the right track in extending view.list.php. Below is some code I have used in the past for the listViewProcess function to customize the query for the list view. The code looks a little ugly formatted on the site, but basically you’re customizing the SQL query in this function. Hopefully this will keep you going in the right direction:


function listViewProcess()
    {
        $this->processSearchForm();
        global $current_user;
       // If other search parameters are entered, add the custom SQL query to the existing parameters
        if ($this->where != "") {
            $this->where .= " AND (tasks_cstm.skill_level_c IS NULL OR tasks_cstm.skill_level_c = '' OR tasks_cstm.skill_level_c = 1 OR 
            	tasks_cstm.matter_type_c = '' OR tasks_cstm.matter_type_c IS NULL OR tasks_cstm.matter_type_c = 'id_matter' OR tasks_cstm.matter_type_c = 'project' OR 
             	(tasks_cstm.matter_type_c = 'civil_gen' AND tasks_cstm.skill_level_c <= {$current_user->civil_gen_c}) OR 
            	(tasks_cstm.matter_type_c = 'corporate' AND tasks_cstm.skill_level_c <= {$current_user->corporate_c}) OR 
            	(tasks_cstm.matter_type_c = 'dmvfraud' AND tasks_cstm.skill_level_c <= {$current_user->dmvfraud_c}) OR 
            	(tasks_cstm.matter_type_c = 'domestic' AND tasks_cstm.skill_level_c <= {$current_user->domestic_c}) OR 
            	(tasks_cstm.matter_type_c = 'estate_planning' AND tasks_cstm.skill_level_c <= {$current_user->estate_planning_c}) OR 
            	(tasks_cstm.matter_type_c = 'federal_crime' AND tasks_cstm.skill_level_c <= {$current_user->federal_crime_c}) OR 
            	(tasks_cstm.matter_type_c = 'felony' AND tasks_cstm.skill_level_c <= {$current_user->felony_c}) OR 
            	(tasks_cstm.matter_type_c = 'ice' AND tasks_cstm.skill_level_c <= {$current_user->ice_c}) OR 
            	(tasks_cstm.matter_type_c = 'immigration' AND tasks_cstm.skill_level_c <= {$current_user->immigration_c}) OR 
            	(tasks_cstm.matter_type_c = 'miscellaneous' AND tasks_cstm.skill_level_c <= {$current_user->miscellaneous_c}) OR 
            	(tasks_cstm.matter_type_c = 'misdemeanor' AND tasks_cstm.skill_level_c <= {$current_user->misdemeanor_c}) OR 
            	(tasks_cstm.matter_type_c = 'personal_injury' AND tasks_cstm.skill_level_c <= {$current_user->personal_injury_c}) OR 
            	(tasks_cstm.matter_type_c = 'property_damage' AND tasks_cstm.skill_level_c <= {$current_user->property_damage_c}) OR 
            	(tasks_cstm.matter_type_c = 'real_estate' AND tasks_cstm.skill_level_c <= {$current_user->real_estate_c}) OR 
            	(tasks_cstm.matter_type_c = 'traffic_general' AND tasks_cstm.skill_level_c <= {$current_user->traffic_general_c}) OR 
            	(tasks_cstm.matter_type_c = 'worker_compensation' AND tasks_cstm.skill_level_c <= {$current_user->worker_compensation_c}))";
        } else {
           // if no search parameters present, do a new query
            $this->where .= "(tasks_cstm.skill_level_c IS NULL OR tasks_cstm.skill_level_c = '' OR tasks_cstm.skill_level_c = 1 OR 
            	tasks_cstm.matter_type_c = '' OR tasks_cstm.matter_type_c IS NULL OR tasks_cstm.matter_type_c = 'id_matter' OR tasks_cstm.matter_type_c = 'project' OR 
            	(tasks_cstm.matter_type_c = 'civil_gen' AND tasks_cstm.skill_level_c <= {$current_user->civil_gen_c}) OR 
            	(tasks_cstm.matter_type_c = 'corporate' AND tasks_cstm.skill_level_c <= {$current_user->corporate_c}) OR 
            	(tasks_cstm.matter_type_c = 'dmvfraud' AND tasks_cstm.skill_level_c <= {$current_user->dmvfraud_c}) OR 
            	(tasks_cstm.matter_type_c = 'domestic' AND tasks_cstm.skill_level_c <= {$current_user->domestic_c}) OR 
            	(tasks_cstm.matter_type_c = 'estate_planning' AND tasks_cstm.skill_level_c <= {$current_user->estate_planning_c}) OR 
            	(tasks_cstm.matter_type_c = 'federal_crime' AND tasks_cstm.skill_level_c <= {$current_user->federal_crime_c}) OR 
            	(tasks_cstm.matter_type_c = 'felony' AND tasks_cstm.skill_level_c <= {$current_user->felony_c}) OR 
            	(tasks_cstm.matter_type_c = 'ice' AND tasks_cstm.skill_level_c <= {$current_user->ice_c}) OR 
            	(tasks_cstm.matter_type_c = 'immigration' AND tasks_cstm.skill_level_c <= {$current_user->immigration_c}) OR 
            	(tasks_cstm.matter_type_c = 'miscellaneous' AND tasks_cstm.skill_level_c <= {$current_user->miscellaneous_c}) OR 
            	(tasks_cstm.matter_type_c = 'misdemeanor' AND tasks_cstm.skill_level_c <= {$current_user->misdemeanor_c}) OR 
            	(tasks_cstm.matter_type_c = 'personal_injury' AND tasks_cstm.skill_level_c <= {$current_user->personal_injury_c}) OR 
            	(tasks_cstm.matter_type_c = 'property_damage' AND tasks_cstm.skill_level_c <= {$current_user->property_damage_c}) OR 
            	(tasks_cstm.matter_type_c = 'real_estate' AND tasks_cstm.skill_level_c <= {$current_user->real_estate_c}) OR 
            	(tasks_cstm.matter_type_c = 'traffic_general' AND tasks_cstm.skill_level_c <= {$current_user->traffic_general_c}) OR 
            	(tasks_cstm.matter_type_c = 'worker_compensation' AND tasks_cstm.skill_level_c <= {$current_user->worker_compensation_c}))";
		}
        
        $this->lv->searchColumns = $this->searchForm->searchColumns;
        
        if(!$this->headers)
            return;
            
        if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false)
        {
            $this->lv->setup($this->seed, 'include/ListView/ListViewGeneric.tpl', $this->where, $this->params);
            $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
            echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
            echo $this->lv->display();
        }
    }
1 Like