⚠ 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

printing label on search



dhoni223

dhoni223
  • profile picture
  • Member

Posted 26 March 2018 - 06:04 AM

i have extended grocery crud library added another state called printtoword

 

 $this->states[23] = 'printtoword';

 

   public function render()
    {
        if( $this->labelprint_option == true ){
                $this->set_js('resources/js/rmcl_label.js');
                $this->set_js('resources/js/sample.js');
 
        }
        try {            
            $state_code = $this->getStateCode();
            switch( $state_code )
            {
                case 23:  
                        $this->pre_render();
                        $this->character_limiter = 1000000;
                        if($this->theme === null)
                                $this->set_theme($this->default_theme);
                        $state_info = $this->getStateInfo();
                        $this->set_ajax_list_queries($state_info);
                        $this->label($state_info);              
                        die();
            }
            $ret =  parent::render();
            return $ret;
        }
        catch(Exception $e)
        {
            echo '<div class="alert alert-danger">';
                echo $e->getMessage();
            echo '</div>';
            die();
        }
    }
    protected function label($state_info = null)
{
          $data = $this->get_common_data();
 
$data->order_by = $this->order_by;
$data->types = $this->get_field_types();
 
$data->list = $this->get_list();
$data->list = $this->change_list($data->list , $data->types);
$data->list = $this->change_list_add_actions($data->list);
 
$data->total_results = $this->get_total_results();
 
$data->columns = $this->get_columns();
$data->primary_key = $this->get_primary_key();
 
@ob_end_clean();
$this->_print($data);
}
 
protected function _print($data)
{
 
$string_to_export = "";
$string_to_export .= "\n";
 
foreach($data->list as $num_row => $row){
foreach($data->columns as $column){
$string_to_export .= $this->_trim_export_string($row->{$column->field_name})."\n";
}
$string_to_export .= "\n";
}
 
// Convert to UTF-16LE and Prepend BOM
$string_to_export = "\xFF\xFE" .mb_convert_encoding($string_to_export, 'UTF-16LE', 'UTF-8');
 
$filename = "export-".date("Y-m-d_H:i:s").".doc";
 
header('Content-type: application/vnd.ms-word;charset=UTF-16LE');
header('Content-Disposition: attachment; filename='.$filename);
header("Cache-Control: no-cache");
echo $string_to_export;
die();
}

 

this code displaying all the values instead of searched values

i was told that im missing \ jquery file