Issues (323)

src/views/export.blade.php (3 issues)

1
@if(Request::input('fileformat') == 'pdf')
2
    <h3>{{Request::input('filename')}}</h3>
3
@endif
4
<table border='1' width='100%' cellpadding='3' cellspacing="0" style='border-collapse: collapse;font-size:12px'>
5
    <thead>
6
    <tr>
7
        <?php
8
        foreach ($columns as $col) {
9
10
            if (Request::get('columns')) {
11
                if (! in_array($col['name'], Request::get('columns'))) {
0 ignored issues
show
It seems like Request::get('columns') can also be of type null; however, parameter $haystack of in_array() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

11
                if (! in_array($col['name'], /** @scrutinizer ignore-type */ Request::get('columns'))) {
Loading history...
12
                    continue;
13
                }
14
            }
15
            $colname = $col['label'];
16
            echo "<th style='background:#eeeeee'>$colname</th>";
17
        }
18
        ?>
19
    </tr>
20
    </thead>
21
    <tbody>
22
    @if(count($result)==0)
23
        <tr class='warning'>
24
            <td colspan='{{count($columns)+1}}' align="center">No Data Avaliable</td>
25
        </tr>
26
    @else
27
        @foreach($result as $row)
28
            <tr>
29
                <?php
30
                foreach ($columns as $col) {
31
32
                    if (Request::get('columns')) {
33
                        if (! in_array($col['name'], Request::get('columns'))) {
34
                            continue;
35
                        }
36
                    }
37
38
                    $value = @$row->{$col['field']};
39
                    $title = @$row->{$title_field};
40
41
                    if (@$col['image']) {
42
                        if ($value == '') {
43
                            $value = "http://placehold.it/50x50&text=NO+IMAGE";
44
                        }
45
                        $pic = (strpos($value, 'http://') !== FALSE) ? $value : asset($value);
46
                        $pic_small = $pic;
47
                        if (Request::input('fileformat') == 'pdf') {
48
                            echo "<td><a data-lightbox='roadtrip' rel='group_{{$table}}' title='$col[label]: $title' href='".$pic."'><img class='img-circle' width='40px' height='40px' src='".$pic_small."'/></a></td>";
49
                        } else {
50
                            echo "<td>$pic</td>";
51
                        }
52
                    } elseif (@$col['download']) {
53
                        $url = (strpos($value, 'http://') !== FALSE) ? $value : asset($value);
54
                        echo "<td><a class='btn btn-sm btn-primary' href='$url' target='_blank' title='Download File'>Download</a></td>";
55
                    } else {
56
57
                        //limit character
58
                        if ($col['str_limit']) {
59
                            $value = trim(strip_tags($value));
60
                            $value = str_limit($value, $col['str_limit']);
0 ignored issues
show
Deprecated Code introduced by
The function str_limit() has been deprecated: Str::limit() should be used directly instead. Will be removed in Laravel 6.0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

60
                            $value = /** @scrutinizer ignore-deprecated */ str_limit($value, $col['str_limit']);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
61
                        }
62
63
                        if ($col['nl2br']) {
64
                            $value = nl2br($value);
65
                        }
66
67
                        if (Request::input('fileformat') == 'pdf') {
68
                            if (! empty($col['callback_php'])) {
69
70
                                foreach ($row as $k => $v) {
71
                                    $col['callback_php'] = str_replace("[".$k."]", $v, $col['callback_php']);
72
                                }
73
                                @eval("\$value = ".$col['callback_php'].";");
0 ignored issues
show
The use of eval() is discouraged.
Loading history...
74
                            }
75
76
                            //New method for callback
77
                            if (isset($col['callback'])) {
78
                                $value = call_user_func($col['callback'], $row);
79
                            }
80
                        }
81
82
                        echo "<td>".$value."</td>";
83
                    }
84
                }
85
                ?>
86
            </tr>
87
        @endforeach
88
    @endif
89
    </tbody>
90
</table>
91
<script type="text/php">
92
    if ( isset($pdf) ) {
93
        $font = Font_Metrics::get_font("helvetica", "bold");
94
        $pdf->page_text(36, 18, "Page {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));
95
    }
96
97
</script>