Exemple #1
0
	function export_csv()
	{
		$startTime = date('Y-m-d');
		$startTime = strtotime($startTime);
		$endTime = time();

		$filter_date_from       = $this->input->get('filter_date_from');
		$filter_date_to         = $this->input->get('filter_date_to');
		$filter_phonenum        = $this->input->get('filter_phonenum');
		$filter_caller_ip       = $this->input->get('filter_caller_ip');
		$filter_customers       = $this->input->get('filter_customers');
		$filter_groups          = $this->input->get('filter_groups');
		$filter_gateways        = $this->input->get('filter_gateways');
		$filter_call_type       = $this->input->get('filter_call_type');
		$filter_quick           = $this->input->get('filter_quick');
		$duration_from          = $this->input->get('duration_from');
		$duration_to            = $this->input->get('duration_to');
		$filter_display_results = $this->input->get('filter_display_results');
        $filter_sort            = $this->input->get('filter_sort');

		if($filter_date_from == '')
		{
			$filter_date_from   = date('Y-m-d H:i:s', $startTime);
		}
		else
		{
			if (!checkdateTime($filter_date_from))
			{
				$filter_date_from   = date('Y-m-d H:i:s', $startTime);
			}
		}

		if($filter_date_to == '')
		{
			$filter_date_to     = date('Y-m-d H:i:s', $endTime);
		}
		else
		{
			if (!checkdateTime($filter_date_to))
			{
				$filter_date_to   = date('Y-m-d H:i:s', $endTime);
			}
		}

		$data_cdr   =   $this->cdr_model->export_cdr_data_csv($filter_date_from, $filter_date_to, $filter_phonenum, $filter_caller_ip, $filter_customers, $filter_groups, $filter_gateways, $filter_call_type, $duration_from, $duration_to, $filter_sort);

		if($data_cdr->num_rows() > 0)
		{
			$headers = array('Date/Time', 'Destination', 'Bill Duration', 'Hangup Cause', 'IP Address', 'Username', 'Sell Rate', 'Sell Init Block', 'Cost Rate','Buy Init Block', 'Total Charges', 'Total Cost', 'Margin', 'Markup');

			$fp = fopen('php://output', 'w');
			if ($fp) {
				header('Content-Type: text/csv');
				header('Content-Disposition: attachment; filename="export.csv"');
				header('Pragma: no-cache');
				header('Expires: 0');
				fputcsv($fp, $headers);

				foreach ($data_cdr->result_array() as $row)
				{
					print '"' . stripslashes(implode('","',$row)) . "\"\n";
				}
				die;
			}
		}
		else
		{
			redirect('cdr/');
		}
	}
Exemple #2
0
    function invoices($customer_id)
    {
        $data['customer_id']    =   $customer_id;
        
        //for filter & search
        $filter_date_from       = '';
        $filter_date_to         = '';
        $filter_customers       = $customer_id;
        $filter_status          = '';
        $filter_sort            = '';
        $search                 = '';

        $msg_records_found = "Records Found";

        if($this->input->get('searchFilter'))
        {
            $filter_date_from       = $this->input->get('filter_date_from');
            $filter_date_to         = $this->input->get('filter_date_to');
            $filter_status          = $this->input->get('filter_status');
            $filter_sort            = $this->input->get('filter_sort');
            $search                 = $this->input->get('searchFilter');
            $msg_records_found      = "Records Found Based On Search Criteria";
        }

        if($filter_date_from != '')
        {
            if (!checkdateTime($filter_date_from))
            {
                //$filter_date_from   = '';
            }
        }

        if($filter_date_to != '')
        {
            if (!checkdateTime($filter_date_to))
            {
                //$filter_date_to   = '';
            }
        }

        $data['filter_date_from']           = $filter_date_from;
        $data['filter_date_to']             = $filter_date_to;
        $data['filter_status']              = $filter_status;
        $data['filter_sort']                = $filter_sort;
        
        //for pagging set information
        $this->load->library('pagination');
        $config['per_page'] = '20';
        $config['base_url'] = base_url().'reseller/customers/invoices/'.$customer_id.'/?searchFilter='.$search.'&filter_date_from='.$filter_date_from.'&filter_date_to='.$filter_date_to.'&filter_status='.$filter_status.'&filter_sort='.$filter_sort.'';
        $config['page_query_string'] = TRUE;

        $config['num_links'] = 6;

        $config['cur_tag_open'] = '<span class="current">';
        $config['cur_tag_close'] = '</span> ';

        $config['next_link'] = 'next';
        $config['next_tag_open'] = '<span class="next-site">';
        $config['next_tag_close'] = '</span>';

        $config['prev_link'] = 'previous';
        $config['prev_tag_open'] = '<span class="prev-site">';
        $config['prev_tag_close'] = '</span>';

        $config['first_link'] = 'first';
        $config['last_link'] = 'last';

        $data['count'] = $this->customer_model->get_invoices_count($filter_date_from, $filter_date_to, $filter_customers, $filter_billing_type = '', $filter_status);
        $config['total_rows'] = $data['count'];

        if(isset($_GET['per_page']))
        {
            if(is_numeric($_GET['per_page']))
            {
                $config['uri_segment'] = $_GET['per_page'];
            }
            else
            {
                $config['uri_segment'] = '';
            }
        }
        else
        {
            $config['uri_segment'] = '';
        }

        $this->pagination->initialize($config);

        $data['msg_records_found'] = "".$data['count']."&nbsp;".$msg_records_found."";

        $data['invoices']       =   $this->customer_model->get_invoices($config['per_page'],$config['uri_segment'],$filter_date_from, $filter_date_to, $filter_customers, $filter_billing_type = '', $filter_status, $filter_sort);
        
        $data['page_name']		=	'customer_invoices';
        $data['selected']		=	'billing';
        $data['sub_selected']   =   '';
        $data['page_title']		=	'INVOICES';
        $data['main_menu']	    =	'';
        $data['sub_menu']	    =	'';
        $data['main_content']	=	'reseller/customers/invoices_view';
        $data['dont_show_this'] = 1;
        $this->load->view('default/template',$data);
    }
Exemple #3
0
	function invoices()
	{
		if($this->session->userdata('user_type') == 'sub_admin')
        {
            if(sub_admin_access_any_cell($this->session->userdata('user_id'), 'view_invoices') == 0)
            {
                redirect ('billing/');
            }
        }
        
        //for filter & search
		$filter_date_from       = '';
		$filter_date_to         = '';
		$filter_customers       = '';
		$filter_billing_type    = '';
		$filter_status          = '';
        $filter_sort            = '';
        $filter_contents        = 'all';
		$search                 = '';

		$msg_records_found = "Records Found";

		if($this->input->get('searchFilter'))
		{
			$filter_date_from       = $this->input->get('filter_date_from');
			$filter_date_to         = $this->input->get('filter_date_to');
			$filter_customers       = $this->input->get('filter_customers');
			$filter_billing_type    = $this->input->get('filter_billing_type');
			$filter_status          = $this->input->get('filter_status');
            $filter_sort            = $this->input->get('filter_sort');
			$search                 = $this->input->get('searchFilter');
            $filter_contents        = $this->input->get('filter_contents');
			$msg_records_found      = "Records Found Based On Search Criteria";
		}

		if($filter_date_from != '')
		{
			if (!checkdateTime($filter_date_from))
			{
				//$filter_date_from   = '';
			}
		}

		if($filter_date_to != '')
		{
			if (!checkdateTime($filter_date_to))
			{
				//$filter_date_to   = '';
			}
		}
        
        if($filter_contents == '' || ($filter_contents != 'all' && $filter_contents != 'my'))
        {
            $filter_contents = "all";
        }

		$data['filter_date_from']           = $filter_date_from;
		$data['filter_date_to']             = $filter_date_to;
		$data['filter_customers']           = $filter_customers;
		$data['filter_billing_type']        = $filter_billing_type;
		$data['filter_status']              = $filter_status;
        $data['filter_sort']                = $filter_sort;
        $data['filter_contents']            = $filter_contents;

		//for pagging set information
		$this->load->library('pagination');
		$config['per_page'] = '20';
		$config['base_url'] = base_url().'billing/invoices/?searchFilter='.$search.'&filter_date_from='.$filter_date_from.'&filter_date_to='.$filter_date_to.'&filter_customers='.$filter_customers.'&filter_billing_type='.$filter_billing_type.'&filter_status='.$filter_status.'&filter_sort='.$filter_sort.'&filter_contents='.$filter_contents.'';
		$config['page_query_string'] = TRUE;

		$config['num_links'] = 6;

		$config['cur_tag_open'] = '<span class="current">';
		$config['cur_tag_close'] = '</span> ';

		$config['next_link'] = 'next';
		$config['next_tag_open'] = '<span class="next-site">';
		$config['next_tag_close'] = '</span>';

		$config['prev_link'] = 'previous';
		$config['prev_tag_open'] = '<span class="prev-site">';
		$config['prev_tag_close'] = '</span>';

		$config['first_link'] = 'first';
		$config['last_link'] = 'last';

		$data['count'] = $this->billing_model->get_invoices_count($filter_date_from, $filter_date_to, $filter_customers, $filter_billing_type, $filter_status, $filter_contents);
		$config['total_rows'] = $data['count'];

		if(isset($_GET['per_page']))
		{
			if(is_numeric($_GET['per_page']))
			{
				$config['uri_segment'] = $_GET['per_page'];
			}
			else
			{
				$config['uri_segment'] = '';
			}
		}
		else
		{
			$config['uri_segment'] = '';
		}

		$this->pagination->initialize($config);

		$data['msg_records_found'] = "".$data['count']."&nbsp;".$msg_records_found."";

		$data['invoices']       =   $this->billing_model->get_invoices($config['per_page'],$config['uri_segment'],$filter_date_from, $filter_date_to, $filter_customers, $filter_billing_type, $filter_status, $filter_sort, $filter_contents);

		$data['page_name']		=	'invoices_list';
		$data['selected']		=	'billing';
		$data['sub_selected']   =   'list_invoices';
		$data['page_title']		=	'INVOICES';
		$data['main_menu']	    =	'default/main_menu/main_menu';
		$data['sub_menu']	    =	'default/sub_menu/billing_sub_menu';
		$data['main_content']	=	'billing/invoices_view';
		$this->load->view('default/template',$data);
	}