⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Error Export Data



rdroguett
  • profile picture
  • Member

Posted 02 January 2019 - 05:42 AM

Hi guys i have a little problem when i try export data using custom query...
not exporting nothing

   

  public function payment_received_date(){
         
        $date_start =  $this->input->post('in', TRUE);
        $date_end   =  $this->input->post('out', TRUE);
          
        $crud = new grocery_CRUD();
        $crud->set_theme('bootstrap-v4');
        $crud->set_model('custom_query_model');
        $crud->set_table('e_invoice');
        $crud->basic_model->set_query_str("
        SELECT  
        a.ide_invoice, 
        a.assigned_folio as Factura,  
        CONCAT('$', format(a.mount,0,'de_DE')) as Valor, 
        CASE WHEN NAME= 'EF' THEN CONCAT('$', format(SUM(b.mount),0,'de_DE')) ELSE 0 END EF, 
        CASE WHEN NAME= 'CH' THEN CONCAT('$', format(SUM(b.mount),0,'de_DE')) ELSE 0 END CH, 
        CASE WHEN NAME= 'CR' THEN CONCAT('$', format(SUM(b.mount),0,'de_DE')) ELSE 0 END CR, 
        CASE WHEN NAME= 'TC' THEN CONCAT('$', format(SUM(b.mount),0,'de_DE')) ELSE 0 END TC, 
        CASE WHEN NAME= 'NT' THEN CONCAT('$', format(SUM(b.mount),0,'de_DE')) ELSE 0 END NT, 
        a.date 
        FROM e_invoice a, e_invoice_traking b, e_payment_methods c                 
        WHERE b.assigned_folio = a.assigned_folio 
        AND b.ide_payment_methods = c.ide_payment_methods                 
        AND a.ide_company = 1
        AND DATE_FORMAT(a.date,'%Y-%m-%d') BETWEEN '$date_start' AND '$date_end' 
        GROUP BY a.ide_invoice, name


        UNION ALL


        SELECT
        tmp.ide_invoice,
        'TOTAL',
        CONCAT('$', format(sum(tmp.monto),0,'de_DE')),
        CONCAT('$', format(sum(tmp.EF),0,'de_DE')),
        CONCAT('$', format(sum(tmp.CH),0,'de_DE')),
        CONCAT('$', format(sum(tmp.CR),0,'de_DE')),
        CONCAT('$', format(sum(tmp.TC),0,'de_DE')),
        CONCAT('$', format(sum(tmp.NT),0,'de_DE')),
        tmp.date
        FROM
        (
        SELECT 
        a.ide_invoice, 
        a.assigned_folio, 
        a.mount monto, 
        CASE WHEN NAME= 'EF' THEN SUM(b.mount) ELSE 0 END EF,
        CASE WHEN NAME= 'CH' THEN SUM(b.mount) ELSE 0 END CH,
        CASE WHEN NAME= 'CR' THEN SUM(b.mount) ELSE 0 END CR,
        CASE WHEN NAME= 'TC' THEN SUM(b.mount) ELSE 0 END TC,
        CASE WHEN NAME= 'NT' THEN SUM(b.mount) ELSE 0 END NT,
        a.date
        FROM e_invoice a, e_invoice_traking b, e_payment_methods c WHERE b.assigned_folio = a.assigned_folio
        AND b.ide_payment_methods = c.ide_payment_methods 
        AND a.ide_company = '1'
        AND DATE_FORMAT(a.date,'%Y-%m-%d') BETWEEN '$date_start' AND '$date_end'
        GROUP BY a.ide_invoice, name
        ) tmp
        ");     


        $crud->set_subject('Reporte de pagos recibidos');
        $crud->display_as('assigned_folio','Factura');
        $crud->display_as('date','Fecha');
        $crud->columns('Factura','Valor','EF','CH','CR','TC','NT');
        $crud->unset_add();
        $crud->unset_delete();
        $crud->unset_edit();
        $crud->unset_read();
        $output = $crud->render();
        $this->_appservice_output($output);
    }

 

 

Display perfect but no export nothing... only i see a white page


rdroguett
  • profile picture
  • Member

Posted 03 January 2019 - 14:43 PM

anyone can help me?


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 10 January 2019 - 19:35 PM

Hello @rdroguett,

 

The problem that you are describing is a bit more complex as you are using a completely custom model. Can you please add the below lines in order to give us more information about the error?

ini_set('display_errors', 'on');
error_reporting(E_ALL);

Regards

Johnny


rdroguett
  • profile picture
  • Member

Posted 24 January 2019 - 18:30 PM

Where insert this

 

ini_set('display_errors', 'on');
error_reporting(E_ALL);

 

I put in index.php on the root folder but not work!


rdroguett
  • profile picture
  • Member

Posted 25 January 2019 - 08:19 AM

the only way work export data in my controller is use a hard value example

 

NOT WORK

    public function report_sales_for_code(){

        $ide_company    =   $this->session->userdata['logged_in']['ide_company'];
        $ide_user       =   $this->session->userdata['logged_in']['ide_user'];

        //$date_start     =   $this->input->post('rvc_date_in', TRUE);
        //$date_end       =   $this->input->post('rvc_date_out', TRUE);

        $this->session->set_flashdata('in',$this->input->post('rvc_date_in', TRUE)); 
        $this->session->set_flashdata('out',$this->input->post('rvc_date_out', TRUE));         
        
        $date_start = $this->session->flashdata('in');
        $date_end   = $this->session->flashdata('out');
        
        $crud = new grocery_CRUD();   
        $crud->set_theme('bootstrap-v4');
        $crud->set_model('custom_query_model');
        $crud->set_table('e_order');
        //$crud->set_primary_key('CODE');  

        $crud->basic_model->set_query_str("
            SELECT
            a.ide_order,
            b.code as code,
            b.name as name,
            sum(b.qty) as qty
            FROM e_order a,  e_product b, e_invoice_order e, e_invoice f
            WHERE a.ide_order = b.ide_order
            AND e.ide_order = a.ide_order
            and f.ide_invoice = e.ide_invoice
            and a.ide_order_status = 2
            and DATE_FORMAT(a.date,'%Y-%m-%d') BETWEEN '$date_start' AND '$date_end'
            and a.ide_company = $ide_company
            and f.status = 'Habilitado'
            group by code
            order by b.code asc");

        $crud->set_subject('Reporte de ventas por codigo: '.date("d/m/Y", strtotime($date_start)).' hasta '.date("d/m/Y", strtotime($date_end)).'');
        $crud->display_as('name','Producto');
        $crud->display_as('code','Codigo');
        $crud->display_as('qty','Cantidad');     
        $crud->columns('code','name','qty');
        //$crud->unset_operations();
        $crud->unset_add(); $crud->unset_edit(); $crud->unset_delete(); $crud->unset_read();
        $output = $crud->render();
        $this->_appservice_output($output);
    }

WORK

    public function report_sales_for_code(){

        $ide_company    =   $this->session->userdata['logged_in']['ide_company'];
        $ide_user       =   $this->session->userdata['logged_in']['ide_user'];   
        
        $date_start = '2019-01-01';
        $date_end   = '2019-01-01';
        
        $crud = new grocery_CRUD();   
        $crud->set_theme('bootstrap-v4');
        $crud->set_model('custom_query_model');
        $crud->set_table('e_order');
        //$crud->set_primary_key('CODE');  

        $crud->basic_model->set_query_str("
            SELECT
            a.ide_order,
            b.code as code,
            b.name as name,
            sum(b.qty) as qty
            FROM e_order a,  e_product b, e_invoice_order e, e_invoice f
            WHERE a.ide_order = b.ide_order
            AND e.ide_order = a.ide_order
            and f.ide_invoice = e.ide_invoice
            and a.ide_order_status = 2
            and DATE_FORMAT(a.date,'%Y-%m-%d') BETWEEN '$date_start' AND '$date_end'
            and a.ide_company = $ide_company
            and f.status = 'Habilitado'
            group by code
            order by b.code asc");

        $crud->set_subject('Reporte de ventas por codigo: '.date("d/m/Y", strtotime($date_start)).' hasta '.date("d/m/Y", strtotime($date_end)).'');
        $crud->display_as('name','Producto');
        $crud->display_as('code','Codigo');
        $crud->display_as('qty','Cantidad');     
        $crud->columns('code','name','qty');
        //$crud->unset_operations();
        $crud->unset_add(); $crud->unset_edit(); $crud->unset_delete(); $crud->unset_read();
        $output = $crud->render();
        $this->_appservice_output($output);
    }

rdroguett
  • profile picture
  • Member

Posted 25 January 2019 - 14:55 PM

Similar conflict

/topic/2502-issue-whith-export-and-print-buttons/?p=148979#entry148979