예제 #1
0
 function download()
 {
     $info = $this->model->makeInfo($this->module);
     // Take param master detail if any
     $results = $this->model->getRows(array());
     $fields = $info['config']['grid'];
     $rows = $results['rows'];
     $content = $this->data['pageTitle'];
     $content .= '<table border="1">';
     $content .= '<tr>';
     foreach ($fields as $f) {
         if ($f['download'] == '1') {
             $content .= '<th style="background:#f9f9f9;">' . $f['label'] . '</th>';
         }
     }
     $content .= '</tr>';
     foreach ($rows as $row) {
         $content .= '<tr>';
         foreach ($fields as $f) {
             if ($f['download'] == '1') {
                 $conn = isset($f['conn']) ? $f['conn'] : array();
                 $content .= '<td>' . SiteHelpers::gridDisplay($row->{$f}['field'], $f['field'], $conn) . '</td>';
             }
         }
         $content .= '</tr>';
     }
     $content .= '</table>';
     @header('Content-Type: application/ms-excel');
     @header('Content-Length: ' . strlen($content));
     @header('Content-disposition: inline; filename="' . $title . ' ' . date("d/m/Y") . '.xls"');
     echo $content;
     exit;
 }
예제 #2
0
 public function index(Request $request)
 {
     $check = self::authentication($request);
     if (is_array($check)) {
         return \Response::json($check);
     } else {
         $class = ucwords($request->input('module'));
         $config = $this->model->makeInfo($class);
         $tables = $config['config']['grid'];
         $page = (!is_null($request->input('page')) or $request->input('page') != 0) ? $request->input('page') : 1;
         $param = array('page' => $page, 'sort' => '', 'order' => 'asc', 'limit' => '');
         if (!is_null($request->input('limit')) or $request->input('limit') != 0) {
             $param['limit'] = $request->input('limit');
         }
         if (!is_null($request->input('order'))) {
             $param['order'] = $request->input('order');
         }
         if (!is_null($request->input('sort'))) {
             $param['sort'] = $request->input('sort');
         }
         $results = $this->model->getRows($param);
         $json = array();
         foreach ($results['rows'] as $row) {
             $rows = array();
             foreach ($tables as $table) {
                 $conn = isset($table['conn']) ? $table['conn'] : array();
                 $rows[$table['field']] = \SiteHelpers::gridDisplay($row->{$table}['field'], $table['field'], $conn);
                 //$rows[$table['field']] = '';
             }
             $json[] = $rows;
         }
         $jsonData = array('total' => $results['total'], 'rows' => $json, 'control' => $param, 'key' => $config['key']);
         if (!is_null($request->input('option')) && $request->input('option') == 'true') {
             $label = array();
             foreach ($tables as $table) {
                 $label[] = $table['label'];
             }
             $field = array();
             foreach ($tables as $table) {
                 $field[] = $table['field'];
             }
             $jsonData['option'] = array('label' => $label, 'field' => $field);
         }
         return \Response::json($jsonData, 200);
     }
 }
예제 #3
0
 function getDownload()
 {
     if ($this->access['is_excel'] == 0) {
         return Redirect::to('')->with('message', SiteHelpers::alert('error', Lang::get('core.note_restric')));
     }
     $info = $this->model->makeInfo($this->module);
     // Take param master detail if any
     $filter = !is_null(Input::get('search')) ? $this->buildSearch() : '';
     $master = $this->buildMasterDetail();
     $filter .= $master['masterFilter'];
     $masterParam = $this->masterDetailParam();
     $params = array('params' => $filter);
     $results = $this->model->getRows($params);
     $fields = $info['config']['grid'];
     $rows = $results['rows'];
     $content = $this->data['pageTitle'];
     $content .= '<table border="1">';
     $content .= '<tr>';
     foreach ($fields as $f) {
         if ($f['download'] == '1') {
             $content .= '<th style="background:#f9f9f9;">' . $f['label'] . '</th>';
         }
     }
     $content .= '</tr>';
     foreach ($rows as $row) {
         $content .= '<tr>';
         foreach ($fields as $f) {
             if ($f['download'] == '1') {
                 $conn = isset($f['conn']) ? $f['conn'] : array();
                 $content .= '<td>' . SiteHelpers::gridDisplay($row->{$f}['field'], $f['field'], $conn) . '</td>';
             }
         }
         $content .= '</tr>';
     }
     $content .= '</table>';
     @header('Content-Type: application/ms-excel');
     @header('Content-Length: ' . strlen($content));
     @header('Content-disposition: inline; filename="' . $title . ' ' . date("d/m/Y") . '.xls"');
     echo $content;
     exit;
     //return View::make('excel',$this->data);
 }
예제 #4
0
					@endif
				@endforeach
				<th width="75">{{ Lang::get('core.btn_action') }}</th>
			  </tr>
        </thead>
		 <tbody>
		   @foreach ($rowData as $r)
                <tr>
					<td width="50">  {{ ++$i}}</td>									
				 	@foreach ($tableGrid as $field)
					 @if($field['view'] =='1')
					 <td>					 
						<?php 
$conn = isset($field['conn']) ? $field['conn'] : array();
//echo SiteHelpers::gridDisplay($r->$field['field'], $r , $field['attribute'],$conn);
echo SiteHelpers::gridDisplay($r->{$field}['field'], $field['field'], $conn);
?>
						 
					 </td>
					 @endif					 
					 @endforeach
				 <td>
				 	{{--*/ $id = $r->$key /*--}}
					<a href="?task=view&id={{ $id }}"  class="tips btn btn-xs btn-primary"  title="{{ Lang::get('core.btn_view') }}"><i class="fa  fa-search"></i> </a>
				
					
				</td>
			</tr>
			 @endforeach
		</tbody>		 	 
		
예제 #5
0
파일: csv.php 프로젝트: vtvmd2015/symtec
<?php

// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $title . ' ' . date("d/m/Y") . '.csv');
// create a file pointer connected to the output stream
$fp = fopen('php://output', 'w');
// loop over the rows, outputting them
foreach ($rows as $row) {
    $content = array();
    foreach ($fields as $f) {
        if ($f['download'] == '1') {
            $conn = isset($f['conn']) ? $f['conn'] : array();
            $content[] = SiteHelpers::gridDisplay($row->{$f}['field'], $f['field'], $conn);
        }
    }
    fputcsv($fp, $content);
}
fclose($fp);
exit;