Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]500 Internal Server Error
#8

[eluser]kikz4life[/eluser]
Part 2
This is salesorder module., one of the module that encounter this Server internal error. I'll post most of it codes here for better understanding. I added the second param false the select query in the salesorder_model.php

salesorder_controller.php
Code:
class AR_salesorder extends Controller {

    function AR_salesorder()
    {
        parent::Controller();
        $user = $this->session->userdata('user');
        if (!$user) redirect('sec_users/login');      
        $this->load->model('Dataset_db');
        $this->load->model('AR_salesorder_db');        
        $lang_select = $this->session->userdata('lang_select');
        $this->config->set_item('language', $lang_select);      
        $this->lang->load('language');
    }  
    function index()
    {    
        $data['showtoolbar'] = true;
        $data['so_ptitle'] = lang('so_ptitle');
        $data['navs'] = $this->Dataset_db->buildNav(0);
        //tab management
        $tabs = $this->session->userdata('tabs');
        if (!$tabs) $tabs = array();
        $tabs['ar_salesorder'] = $this->Dataset_db->getModule('ar_salesorder');
        $this->session->set_userdata('tabs',$tabs);        
        $data['current_tab'] = $tabs['ar_salesorder']['link'];        
        //access level
        $user = $this->session->userdata('user');
        $company = $this->session->userdata('company');
        $acess = $this->Dataset_db->getAccess($user['role_id'],$tabs['ar_salesorder']['module_id'],$company['company_id']);
        $data['access_level'] = $acess['access_level'];
        
        if (substr($acess['access_level'], 0,1)==0)
        {
            $data['showtoolbar'] = false;
            $data['content'] = "<div class='content'><h1>Restricted Access</h1><div>This module is restricted from <b>".$user['role_desc']."</b> users.</div></div>";
            $this->load->vars($data);
            $this->load->view('default_view');
            return true;
        }              
        $data['order_type'] = $this->Dataset_db->getTypes('CUST_TYPE');
        $data['internal_terms'] = $this->Dataset_db->getTypes('TERMS');
        $data['operator'] = $this->Dataset_db->getSearchTypes('OPERATOR');        
        $data['content'] = $this->load->view('home',$data,true);
        $this->load->vars($data);
        $this->load->view('default_view');
    }
    
    function listview()
    {
        $data = $this->AR_salesorder_db->getList();    
        $this->load->view('template/table',$data);
    }
    
    
}

salesorder_model.php
Code:
class AR_salesorder_db extends Model {

    function AR_salesorder_db()
    {
        // Call the Model constructor
         parent::Model();
    }
    
    function getList()
    {
        $sortname = $this->input->post('sortname');
        $sortorder = $this->input->post('sortorder');
        $page = $this->input->post('page');        
        $rp = $this->input->post('rp');        
        
        $query = $this->input->post('query');
        $qtype = $this->input->post('qtype');
        
        $stype = $this->input->post('s_type');
        $otype = $this->input->post('o_type');
        $skey = $this->input->post('s_key');
        if (!$sortname) $sortname = 'so_id';
        if (!$sortorder) $sortorder = 'DESC';
        
        if (!$page) $page = 1;        
        if (!$rp) $rp = 25;
                
        $start = (($page-1) * $rp);
        
        $this->db->start_cache();
        
        if ($stype)
        {
            foreach ($stype as $key => $value)
            {
                if ($skey[$key])
                {
                    if ($stype[$key]=='so_date')  $match = convertDate($skey[$key]);
                    else $match = $skey[$key];
                    
                    switch ($otype[$key])
                    {
                        case "=":
                            $this->db->where($stype[$key],$match);
                            break;
                        case "!=":
                            $this->db->where($stype[$key]." !=",$match);
                            break;
                        case "like":
                            $this->db->like($stype[$key],$match);
                            break;
                        case ">":
                            $this->db->where($stype[$key]." >",$match);
                            break;
                        case "<":
                            $this->db->where($stype[$key]." <",$match);
                            break;
                    }
                }
            }
            
        }
        
        $this->db->join('maint_customers erp_b','ar_so.client_id=b.cust_id','left');
        $this->db->join('maint_customers erp_c','ar_so.del_client_id=c.cust_id','left');
        $this->db->join('maint_employee erp_d','ar_so.salesman_id=d.emp_id','left');
        $this->db->join('sec_dataset erp_e','ar_so.type_id=e.data_id','left');
        $this->db->from('ar_so');
        $this->db->where('ar_so.is_deleted','0');
        $num = $this->db->count_all_results();        
    
        $this->db->join('sec_dataset erp_k','ar_so.status=k.data_value AND k.data_code = "TRAN_STATUS"','left');
        $this->db->select("so_id as pkey, so_no, DATE_FORMAT(so_date,'%b %d, %Y'), e.data_display, b.customer_name, emp_name, net, ar_so.contact, k.data_display", FALSE);
        $this->db->order_by($sortname,$sortorder);
        $this->db->limit($rp, $start);
        $query = $this->db->get('ar_so');
        
        $this->db->flush_cache();

        $data['db'] = $query;        
        $data['page'] = $page;
        $data['num'] = $num;
        return $data;            
        
    }
    
}


Messages In This Thread
[SOLVED]500 Internal Server Error - by El Forum - 10-22-2009, 08:39 PM
[SOLVED]500 Internal Server Error - by El Forum - 10-23-2009, 03:22 AM
[SOLVED]500 Internal Server Error - by El Forum - 10-23-2009, 05:10 AM
[SOLVED]500 Internal Server Error - by El Forum - 10-23-2009, 05:42 AM
[SOLVED]500 Internal Server Error - by El Forum - 10-23-2009, 07:18 AM
[SOLVED]500 Internal Server Error - by El Forum - 10-23-2009, 07:42 AM
[SOLVED]500 Internal Server Error - by El Forum - 10-25-2009, 08:41 PM
[SOLVED]500 Internal Server Error - by El Forum - 10-25-2009, 09:01 PM
[SOLVED]500 Internal Server Error - by El Forum - 10-26-2009, 12:52 AM
[SOLVED]500 Internal Server Error - by El Forum - 10-26-2009, 01:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB