Muhammad Iqbal Afandi 3 лет назад
Родитель
Сommit
70f4081468

+ 7
- 0
app/Http/Controllers/SalesController.php Просмотреть файл

@@ -12,6 +12,7 @@ use Illuminate\Support\Facades\DB;
12 12
 use Illuminate\Database\QueryException;
13 13
 use App\Http\Requests\Sales\StoreSaleRequest;
14 14
 use App\Http\Requests\Sales\UpdateSaleRequest;
15
+use Barryvdh\DomPDF\Facade\Pdf;
15 16
 
16 17
 class SalesController extends Controller
17 18
 {
@@ -198,4 +199,10 @@ class SalesController extends Controller
198 199
     {
199 200
         //
200 201
     }
202
+
203
+    public function pdf(Sale $sale)
204
+    {
205
+        $pdf = Pdf::loadView("pdf.sales", compact("sale"));
206
+        return $pdf->stream();
207
+    }
201 208
 }

+ 1
- 0
composer.json Просмотреть файл

@@ -9,6 +9,7 @@
9 9
   "license": "MIT",
10 10
   "require": {
11 11
     "php": "^8.0.2",
12
+    "barryvdh/laravel-dompdf": "^2.0",
12 13
     "fruitcake/laravel-cors": "^2.0.5",
13 14
     "guzzlehttp/guzzle": "^7.2",
14 15
     "inertiajs/inertia-laravel": "^0.5.4",

+ 360
- 1
composer.lock Просмотреть файл

@@ -4,7 +4,7 @@
4 4
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 5
         "This file is @generated automatically"
6 6
     ],
7
-    "content-hash": "cf9797e5b5b20287f0213c45da310a85",
7
+    "content-hash": "ebf2992886e4a043d149352e65e14b36",
8 8
     "packages": [
9 9
         {
10 10
             "name": "asm89/stack-cors",
@@ -62,6 +62,83 @@
62 62
             },
63 63
             "time": "2022-01-18T09:12:03+00:00"
64 64
         },
65
+        {
66
+            "name": "barryvdh/laravel-dompdf",
67
+            "version": "v2.0.0",
68
+            "source": {
69
+                "type": "git",
70
+                "url": "https://github.com/barryvdh/laravel-dompdf.git",
71
+                "reference": "1d47648c6cef37f715ecb8bcc5f5a656ad372e27"
72
+            },
73
+            "dist": {
74
+                "type": "zip",
75
+                "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/1d47648c6cef37f715ecb8bcc5f5a656ad372e27",
76
+                "reference": "1d47648c6cef37f715ecb8bcc5f5a656ad372e27",
77
+                "shasum": ""
78
+            },
79
+            "require": {
80
+                "dompdf/dompdf": "^2",
81
+                "illuminate/support": "^6|^7|^8|^9",
82
+                "php": "^7.2 || ^8.0"
83
+            },
84
+            "require-dev": {
85
+                "nunomaduro/larastan": "^1|^2",
86
+                "orchestra/testbench": "^4|^5|^6|^7",
87
+                "phpro/grumphp": "^1",
88
+                "squizlabs/php_codesniffer": "^3.5"
89
+            },
90
+            "type": "library",
91
+            "extra": {
92
+                "branch-alias": {
93
+                    "dev-master": "2.0-dev"
94
+                },
95
+                "laravel": {
96
+                    "providers": [
97
+                        "Barryvdh\\DomPDF\\ServiceProvider"
98
+                    ],
99
+                    "aliases": {
100
+                        "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf",
101
+                        "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf"
102
+                    }
103
+                }
104
+            },
105
+            "autoload": {
106
+                "psr-4": {
107
+                    "Barryvdh\\DomPDF\\": "src"
108
+                }
109
+            },
110
+            "notification-url": "https://packagist.org/downloads/",
111
+            "license": [
112
+                "MIT"
113
+            ],
114
+            "authors": [
115
+                {
116
+                    "name": "Barry vd. Heuvel",
117
+                    "email": "barryvdh@gmail.com"
118
+                }
119
+            ],
120
+            "description": "A DOMPDF Wrapper for Laravel",
121
+            "keywords": [
122
+                "dompdf",
123
+                "laravel",
124
+                "pdf"
125
+            ],
126
+            "support": {
127
+                "issues": "https://github.com/barryvdh/laravel-dompdf/issues",
128
+                "source": "https://github.com/barryvdh/laravel-dompdf/tree/v2.0.0"
129
+            },
130
+            "funding": [
131
+                {
132
+                    "url": "https://fruitcake.nl",
133
+                    "type": "custom"
134
+                },
135
+                {
136
+                    "url": "https://github.com/barryvdh",
137
+                    "type": "github"
138
+                }
139
+            ],
140
+            "time": "2022-07-06T11:12:10+00:00"
141
+        },
65 142
         {
66 143
             "name": "brick/math",
67 144
             "version": "0.9.3",
@@ -364,6 +441,76 @@
364 441
             ],
365 442
             "time": "2022-02-28T11:07:21+00:00"
366 443
         },
444
+        {
445
+            "name": "dompdf/dompdf",
446
+            "version": "v2.0.0",
447
+            "source": {
448
+                "type": "git",
449
+                "url": "https://github.com/dompdf/dompdf.git",
450
+                "reference": "79573d8b8a141ec8a17312515de8740eed014fa9"
451
+            },
452
+            "dist": {
453
+                "type": "zip",
454
+                "url": "https://api.github.com/repos/dompdf/dompdf/zipball/79573d8b8a141ec8a17312515de8740eed014fa9",
455
+                "reference": "79573d8b8a141ec8a17312515de8740eed014fa9",
456
+                "shasum": ""
457
+            },
458
+            "require": {
459
+                "ext-dom": "*",
460
+                "ext-mbstring": "*",
461
+                "masterminds/html5": "^2.0",
462
+                "phenx/php-font-lib": "^0.5.4",
463
+                "phenx/php-svg-lib": "^0.3.3 || ^0.4.0",
464
+                "php": "^7.1 || ^8.0"
465
+            },
466
+            "require-dev": {
467
+                "ext-json": "*",
468
+                "ext-zip": "*",
469
+                "mockery/mockery": "^1.3",
470
+                "phpunit/phpunit": "^7.5 || ^8 || ^9",
471
+                "squizlabs/php_codesniffer": "^3.5"
472
+            },
473
+            "suggest": {
474
+                "ext-gd": "Needed to process images",
475
+                "ext-gmagick": "Improves image processing performance",
476
+                "ext-imagick": "Improves image processing performance",
477
+                "ext-zlib": "Needed for pdf stream compression"
478
+            },
479
+            "type": "library",
480
+            "autoload": {
481
+                "psr-4": {
482
+                    "Dompdf\\": "src/"
483
+                },
484
+                "classmap": [
485
+                    "lib/"
486
+                ]
487
+            },
488
+            "notification-url": "https://packagist.org/downloads/",
489
+            "license": [
490
+                "LGPL-2.1"
491
+            ],
492
+            "authors": [
493
+                {
494
+                    "name": "Fabien Ménager",
495
+                    "email": "fabien.menager@gmail.com"
496
+                },
497
+                {
498
+                    "name": "Brian Sweeney",
499
+                    "email": "eclecticgeek@gmail.com"
500
+                },
501
+                {
502
+                    "name": "Gabriel Bull",
503
+                    "email": "me@gabrielbull.com"
504
+                }
505
+            ],
506
+            "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
507
+            "homepage": "https://github.com/dompdf/dompdf",
508
+            "support": {
509
+                "issues": "https://github.com/dompdf/dompdf/issues",
510
+                "source": "https://github.com/dompdf/dompdf/tree/v2.0.0"
511
+            },
512
+            "time": "2022-06-21T21:14:57+00:00"
513
+        },
367 514
         {
368 515
             "name": "dragonmantank/cron-expression",
369 516
             "version": "v3.3.1",
@@ -2111,6 +2258,75 @@
2111 2258
             },
2112 2259
             "time": "2021-07-01T19:01:15+00:00"
2113 2260
         },
2261
+        {
2262
+            "name": "masterminds/html5",
2263
+            "version": "2.7.5",
2264
+            "source": {
2265
+                "type": "git",
2266
+                "url": "https://github.com/Masterminds/html5-php.git",
2267
+                "reference": "f640ac1bdddff06ea333a920c95bbad8872429ab"
2268
+            },
2269
+            "dist": {
2270
+                "type": "zip",
2271
+                "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f640ac1bdddff06ea333a920c95bbad8872429ab",
2272
+                "reference": "f640ac1bdddff06ea333a920c95bbad8872429ab",
2273
+                "shasum": ""
2274
+            },
2275
+            "require": {
2276
+                "ext-ctype": "*",
2277
+                "ext-dom": "*",
2278
+                "ext-libxml": "*",
2279
+                "php": ">=5.3.0"
2280
+            },
2281
+            "require-dev": {
2282
+                "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7"
2283
+            },
2284
+            "type": "library",
2285
+            "extra": {
2286
+                "branch-alias": {
2287
+                    "dev-master": "2.7-dev"
2288
+                }
2289
+            },
2290
+            "autoload": {
2291
+                "psr-4": {
2292
+                    "Masterminds\\": "src"
2293
+                }
2294
+            },
2295
+            "notification-url": "https://packagist.org/downloads/",
2296
+            "license": [
2297
+                "MIT"
2298
+            ],
2299
+            "authors": [
2300
+                {
2301
+                    "name": "Matt Butcher",
2302
+                    "email": "technosophos@gmail.com"
2303
+                },
2304
+                {
2305
+                    "name": "Matt Farina",
2306
+                    "email": "matt@mattfarina.com"
2307
+                },
2308
+                {
2309
+                    "name": "Asmir Mustafic",
2310
+                    "email": "goetas@gmail.com"
2311
+                }
2312
+            ],
2313
+            "description": "An HTML5 parser and serializer.",
2314
+            "homepage": "http://masterminds.github.io/html5-php",
2315
+            "keywords": [
2316
+                "HTML5",
2317
+                "dom",
2318
+                "html",
2319
+                "parser",
2320
+                "querypath",
2321
+                "serializer",
2322
+                "xml"
2323
+            ],
2324
+            "support": {
2325
+                "issues": "https://github.com/Masterminds/html5-php/issues",
2326
+                "source": "https://github.com/Masterminds/html5-php/tree/2.7.5"
2327
+            },
2328
+            "time": "2021-07-01T14:25:37+00:00"
2329
+        },
2114 2330
         {
2115 2331
             "name": "monolog/monolog",
2116 2332
             "version": "2.7.0",
@@ -2580,6 +2796,96 @@
2580 2796
             },
2581 2797
             "time": "2022-05-31T20:59:12+00:00"
2582 2798
         },
2799
+        {
2800
+            "name": "phenx/php-font-lib",
2801
+            "version": "0.5.4",
2802
+            "source": {
2803
+                "type": "git",
2804
+                "url": "https://github.com/dompdf/php-font-lib.git",
2805
+                "reference": "dd448ad1ce34c63d09baccd05415e361300c35b4"
2806
+            },
2807
+            "dist": {
2808
+                "type": "zip",
2809
+                "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/dd448ad1ce34c63d09baccd05415e361300c35b4",
2810
+                "reference": "dd448ad1ce34c63d09baccd05415e361300c35b4",
2811
+                "shasum": ""
2812
+            },
2813
+            "require": {
2814
+                "ext-mbstring": "*"
2815
+            },
2816
+            "require-dev": {
2817
+                "symfony/phpunit-bridge": "^3 || ^4 || ^5"
2818
+            },
2819
+            "type": "library",
2820
+            "autoload": {
2821
+                "psr-4": {
2822
+                    "FontLib\\": "src/FontLib"
2823
+                }
2824
+            },
2825
+            "notification-url": "https://packagist.org/downloads/",
2826
+            "license": [
2827
+                "LGPL-3.0"
2828
+            ],
2829
+            "authors": [
2830
+                {
2831
+                    "name": "Fabien Ménager",
2832
+                    "email": "fabien.menager@gmail.com"
2833
+                }
2834
+            ],
2835
+            "description": "A library to read, parse, export and make subsets of different types of font files.",
2836
+            "homepage": "https://github.com/PhenX/php-font-lib",
2837
+            "support": {
2838
+                "issues": "https://github.com/dompdf/php-font-lib/issues",
2839
+                "source": "https://github.com/dompdf/php-font-lib/tree/0.5.4"
2840
+            },
2841
+            "time": "2021-12-17T19:44:54+00:00"
2842
+        },
2843
+        {
2844
+            "name": "phenx/php-svg-lib",
2845
+            "version": "0.4.1",
2846
+            "source": {
2847
+                "type": "git",
2848
+                "url": "https://github.com/dompdf/php-svg-lib.git",
2849
+                "reference": "4498b5df7b08e8469f0f8279651ea5de9626ed02"
2850
+            },
2851
+            "dist": {
2852
+                "type": "zip",
2853
+                "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/4498b5df7b08e8469f0f8279651ea5de9626ed02",
2854
+                "reference": "4498b5df7b08e8469f0f8279651ea5de9626ed02",
2855
+                "shasum": ""
2856
+            },
2857
+            "require": {
2858
+                "ext-mbstring": "*",
2859
+                "php": "^7.1 || ^7.2 || ^7.3 || ^7.4 || ^8.0",
2860
+                "sabberworm/php-css-parser": "^8.4"
2861
+            },
2862
+            "require-dev": {
2863
+                "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5"
2864
+            },
2865
+            "type": "library",
2866
+            "autoload": {
2867
+                "psr-4": {
2868
+                    "Svg\\": "src/Svg"
2869
+                }
2870
+            },
2871
+            "notification-url": "https://packagist.org/downloads/",
2872
+            "license": [
2873
+                "LGPL-3.0"
2874
+            ],
2875
+            "authors": [
2876
+                {
2877
+                    "name": "Fabien Ménager",
2878
+                    "email": "fabien.menager@gmail.com"
2879
+                }
2880
+            ],
2881
+            "description": "A library to read, parse and export to PDF SVG files.",
2882
+            "homepage": "https://github.com/PhenX/php-svg-lib",
2883
+            "support": {
2884
+                "issues": "https://github.com/dompdf/php-svg-lib/issues",
2885
+                "source": "https://github.com/dompdf/php-svg-lib/tree/0.4.1"
2886
+            },
2887
+            "time": "2022-03-07T12:52:04+00:00"
2888
+        },
2583 2889
         {
2584 2890
             "name": "phpoffice/phpspreadsheet",
2585 2891
             "version": "1.23.0",
@@ -3412,6 +3718,59 @@
3412 3718
             ],
3413 3719
             "time": "2022-03-27T21:42:02+00:00"
3414 3720
         },
3721
+        {
3722
+            "name": "sabberworm/php-css-parser",
3723
+            "version": "8.4.0",
3724
+            "source": {
3725
+                "type": "git",
3726
+                "url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
3727
+                "reference": "e41d2140031d533348b2192a83f02d8dd8a71d30"
3728
+            },
3729
+            "dist": {
3730
+                "type": "zip",
3731
+                "url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/e41d2140031d533348b2192a83f02d8dd8a71d30",
3732
+                "reference": "e41d2140031d533348b2192a83f02d8dd8a71d30",
3733
+                "shasum": ""
3734
+            },
3735
+            "require": {
3736
+                "ext-iconv": "*",
3737
+                "php": ">=5.6.20"
3738
+            },
3739
+            "require-dev": {
3740
+                "codacy/coverage": "^1.4",
3741
+                "phpunit/phpunit": "^4.8.36"
3742
+            },
3743
+            "suggest": {
3744
+                "ext-mbstring": "for parsing UTF-8 CSS"
3745
+            },
3746
+            "type": "library",
3747
+            "autoload": {
3748
+                "psr-4": {
3749
+                    "Sabberworm\\CSS\\": "src/"
3750
+                }
3751
+            },
3752
+            "notification-url": "https://packagist.org/downloads/",
3753
+            "license": [
3754
+                "MIT"
3755
+            ],
3756
+            "authors": [
3757
+                {
3758
+                    "name": "Raphael Schweikert"
3759
+                }
3760
+            ],
3761
+            "description": "Parser for CSS Files written in PHP",
3762
+            "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
3763
+            "keywords": [
3764
+                "css",
3765
+                "parser",
3766
+                "stylesheet"
3767
+            ],
3768
+            "support": {
3769
+                "issues": "https://github.com/sabberworm/PHP-CSS-Parser/issues",
3770
+                "source": "https://github.com/sabberworm/PHP-CSS-Parser/tree/8.4.0"
3771
+            },
3772
+            "time": "2021-12-11T13:40:54+00:00"
3773
+        },
3415 3774
         {
3416 3775
             "name": "symfony/console",
3417 3776
             "version": "v6.1.2",

+ 284
- 0
config/dompdf.php Просмотреть файл

@@ -0,0 +1,284 @@
1
+<?php
2
+
3
+return array(
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Settings
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | Set some default values. It is possible to add all defines that can be set
11
+    | in dompdf_config.inc.php. You can also override the entire config file.
12
+    |
13
+    */
14
+    'show_warnings' => false,   // Throw an Exception on warnings from dompdf
15
+
16
+    'public_path' => null,  // Override the public path if needed
17
+
18
+    /*
19
+     * Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £.
20
+     */
21
+    'convert_entities' => true,
22
+
23
+    'options' => array(
24
+        /**
25
+         * The location of the DOMPDF font directory
26
+         *
27
+         * The location of the directory where DOMPDF will store fonts and font metrics
28
+         * Note: This directory must exist and be writable by the webserver process.
29
+         * *Please note the trailing slash.*
30
+         *
31
+         * Notes regarding fonts:
32
+         * Additional .afm font metrics can be added by executing load_font.php from command line.
33
+         *
34
+         * Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must
35
+         * be embedded in the pdf file or the PDF may not display correctly. This can significantly
36
+         * increase file size unless font subsetting is enabled. Before embedding a font please
37
+         * review your rights under the font license.
38
+         *
39
+         * Any font specification in the source HTML is translated to the closest font available
40
+         * in the font directory.
41
+         *
42
+         * The pdf standard "Base 14 fonts" are:
43
+         * Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
44
+         * Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
45
+         * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
46
+         * Symbol, ZapfDingbats.
47
+         */
48
+        "font_dir" => storage_path('fonts'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
49
+
50
+        /**
51
+         * The location of the DOMPDF font cache directory
52
+         *
53
+         * This directory contains the cached font metrics for the fonts used by DOMPDF.
54
+         * This directory can be the same as DOMPDF_FONT_DIR
55
+         *
56
+         * Note: This directory must exist and be writable by the webserver process.
57
+         */
58
+        "font_cache" => storage_path('fonts'),
59
+
60
+        /**
61
+         * The location of a temporary directory.
62
+         *
63
+         * The directory specified must be writeable by the webserver process.
64
+         * The temporary directory is required to download remote images and when
65
+         * using the PFDLib back end.
66
+         */
67
+        "temp_dir" => sys_get_temp_dir(),
68
+
69
+        /**
70
+         * ==== IMPORTANT ====
71
+         *
72
+         * dompdf's "chroot": Prevents dompdf from accessing system files or other
73
+         * files on the webserver.  All local files opened by dompdf must be in a
74
+         * subdirectory of this directory.  DO NOT set it to '/' since this could
75
+         * allow an attacker to use dompdf to read any files on the server.  This
76
+         * should be an absolute path.
77
+         * This is only checked on command line call by dompdf.php, but not by
78
+         * direct class use like:
79
+         * $dompdf = new DOMPDF();  $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
80
+         */
81
+        "chroot" => realpath(base_path()),
82
+
83
+        /**
84
+         * Protocol whitelist
85
+         *
86
+         * Protocols and PHP wrappers allowed in URIs, and the validation rules
87
+         * that determine if a resouce may be loaded. Full support is not guaranteed
88
+         * for the protocols/wrappers specified
89
+         * by this array.
90
+         *
91
+         * @var array
92
+         */
93
+        'allowed_protocols' => [
94
+            "file://" => ["rules" => []],
95
+            "http://" => ["rules" => []],
96
+            "https://" => ["rules" => []]
97
+        ],
98
+
99
+         /**
100
+          * @var string
101
+          */
102
+        'log_output_file' => null,
103
+
104
+        /**
105
+         * Whether to enable font subsetting or not.
106
+         */
107
+        "enable_font_subsetting" => false,
108
+
109
+        /**
110
+         * The PDF rendering backend to use
111
+         *
112
+         * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
113
+         * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
114
+         * fall back on CPDF. 'GD' renders PDFs to graphic files. {@link
115
+         * Canvas_Factory} ultimately determines which rendering class to instantiate
116
+         * based on this setting.
117
+         *
118
+         * Both PDFLib & CPDF rendering backends provide sufficient rendering
119
+         * capabilities for dompdf, however additional features (e.g. object,
120
+         * image and font support, etc.) differ between backends.  Please see
121
+         * {@link PDFLib_Adapter} for more information on the PDFLib backend
122
+         * and {@link CPDF_Adapter} and lib/class.pdf.php for more information
123
+         * on CPDF. Also see the documentation for each backend at the links
124
+         * below.
125
+         *
126
+         * The GD rendering backend is a little different than PDFLib and
127
+         * CPDF. Several features of CPDF and PDFLib are not supported or do
128
+         * not make any sense when creating image files.  For example,
129
+         * multiple pages are not supported, nor are PDF 'objects'.  Have a
130
+         * look at {@link GD_Adapter} for more information.  GD support is
131
+         * experimental, so use it at your own risk.
132
+         *
133
+         * @link http://www.pdflib.com
134
+         * @link http://www.ros.co.nz/pdf
135
+         * @link http://www.php.net/image
136
+         */
137
+        "pdf_backend" => "CPDF",
138
+
139
+        /**
140
+         * PDFlib license key
141
+         *
142
+         * If you are using a licensed, commercial version of PDFlib, specify
143
+         * your license key here.  If you are using PDFlib-Lite or are evaluating
144
+         * the commercial version of PDFlib, comment out this setting.
145
+         *
146
+         * @link http://www.pdflib.com
147
+         *
148
+         * If pdflib present in web server and auto or selected explicitely above,
149
+         * a real license code must exist!
150
+         */
151
+        //"DOMPDF_PDFLIB_LICENSE" => "your license key here",
152
+
153
+        /**
154
+         * html target media view which should be rendered into pdf.
155
+         * List of types and parsing rules for future extensions:
156
+         * http://www.w3.org/TR/REC-html40/types.html
157
+         *   screen, tty, tv, projection, handheld, print, braille, aural, all
158
+         * Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
159
+         * Note, even though the generated pdf file is intended for print output,
160
+         * the desired content might be different (e.g. screen or projection view of html file).
161
+         * Therefore allow specification of content here.
162
+         */
163
+        "default_media_type" => "screen",
164
+
165
+        /**
166
+         * The default paper size.
167
+         *
168
+         * North America standard is "letter"; other countries generally "a4"
169
+         *
170
+         * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
171
+         */
172
+        "default_paper_size" => "a4",
173
+
174
+         /**
175
+          * The default paper orientation.
176
+          *
177
+          * The orientation of the page (portrait or landscape).
178
+          *
179
+          * @var string
180
+          */
181
+        'default_paper_orientation' => "portrait",
182
+
183
+        /**
184
+         * The default font family
185
+         *
186
+         * Used if no suitable fonts can be found. This must exist in the font folder.
187
+         * @var string
188
+         */
189
+        "default_font" => "serif",
190
+
191
+        /**
192
+         * Image DPI setting
193
+         *
194
+         * This setting determines the default DPI setting for images and fonts.  The
195
+         * DPI may be overridden for inline images by explictly setting the
196
+         * image's width & height style attributes (i.e. if the image's native
197
+         * width is 600 pixels and you specify the image's width as 72 points,
198
+         * the image will have a DPI of 600 in the rendered PDF.  The DPI of
199
+         * background images can not be overridden and is controlled entirely
200
+         * via this parameter.
201
+         *
202
+         * For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
203
+         * If a size in html is given as px (or without unit as image size),
204
+         * this tells the corresponding size in pt.
205
+         * This adjusts the relative sizes to be similar to the rendering of the
206
+         * html page in a reference browser.
207
+         *
208
+         * In pdf, always 1 pt = 1/72 inch
209
+         *
210
+         * Rendering resolution of various browsers in px per inch:
211
+         * Windows Firefox and Internet Explorer:
212
+         *   SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
213
+         * Linux Firefox:
214
+         *   about:config *resolution: Default:96
215
+         *   (xorg screen dimension in mm and Desktop font dpi settings are ignored)
216
+         *
217
+         * Take care about extra font/image zoom factor of browser.
218
+         *
219
+         * In images, <img> size in pixel attribute, img css style, are overriding
220
+         * the real image dimension in px for rendering.
221
+         *
222
+         * @var int
223
+         */
224
+        "dpi" => 96,
225
+
226
+        /**
227
+         * Enable inline PHP
228
+         *
229
+         * If this setting is set to true then DOMPDF will automatically evaluate
230
+         * inline PHP contained within <script type="text/php"> ... </script> tags.
231
+         *
232
+         * Enabling this for documents you do not trust (e.g. arbitrary remote html
233
+         * pages) is a security risk.  Set this option to false if you wish to process
234
+         * untrusted documents.
235
+         *
236
+         * @var bool
237
+         */
238
+        "enable_php" => false,
239
+
240
+        /**
241
+         * Enable inline Javascript
242
+         *
243
+         * If this setting is set to true then DOMPDF will automatically insert
244
+         * JavaScript code contained within <script type="text/javascript"> ... </script> tags.
245
+         *
246
+         * @var bool
247
+         */
248
+        "enable_javascript" => true,
249
+
250
+        /**
251
+         * Enable remote file access
252
+         *
253
+         * If this setting is set to true, DOMPDF will access remote sites for
254
+         * images and CSS files as required.
255
+         * This is required for part of test case www/test/image_variants.html through www/examples.php
256
+         *
257
+         * Attention!
258
+         * This can be a security risk, in particular in combination with DOMPDF_ENABLE_PHP and
259
+         * allowing remote access to dompdf.php or on allowing remote html code to be passed to
260
+         * $dompdf = new DOMPDF(, $dompdf->load_html(...,
261
+         * This allows anonymous users to download legally doubtful internet content which on
262
+         * tracing back appears to being downloaded by your server, or allows malicious php code
263
+         * in remote html pages to be executed by your server with your account privileges.
264
+         *
265
+         * @var bool
266
+         */
267
+        "enable_remote" => true,
268
+
269
+        /**
270
+         * A ratio applied to the fonts height to be more like browsers' line height
271
+         */
272
+        "font_height_ratio" => 1.1,
273
+
274
+        /**
275
+         * Use the HTML5 Lib parser
276
+         *
277
+         * @deprecated This feature is now always on in dompdf 2.x
278
+         * @var bool
279
+         */
280
+        "enable_html5_parser" => true,
281
+    ),
282
+
283
+
284
+);

+ 13
- 0
resources/js/pages/Sales/Show.vue Просмотреть файл

@@ -1,12 +1,15 @@
1 1
 <script setup>
2
+import { Inertia } from '@inertiajs/inertia'
2 3
 import { useForm } from '@/composables/useForm'
3 4
 import { IDRCurrencyFormat } from '@/utils/helpers'
4 5
 import { cartTable } from './config'
5 6
 import Cart from './Components/Cart.vue'
6 7
 import { useCart } from './Composables/useCart'
8
+import AppButtonLink from '@/components/AppButtonLink.vue'
7 9
 import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
8 10
 
9 11
 const props = defineProps({
12
+  id: Number,
10 13
   number: String,
11 14
   ppn: Number,
12 15
   status: String,
@@ -93,6 +96,16 @@ const { cart, totalCartPrice } = useCart(form, props.saleDetail)
93 96
           </div>
94 97
         </div>
95 98
       </div>
99
+
100
+      <div class="col-12 md:col-8 flex justify-content-end">
101
+        <AppButtonLink
102
+          label="Cetak"
103
+          icon="pi pi-print"
104
+          target="_blank"
105
+          :inertia-link="false"
106
+          :href="route('sales.pdf', id)"
107
+        />
108
+      </div>
96 109
     </div>
97 110
   </DashboardLayout>
98 111
 </template>

+ 208
- 0
resources/views/pdf/sales.blade.php Просмотреть файл

@@ -0,0 +1,208 @@
1
+<html>
2
+
3
+<head>
4
+    <style>
5
+        * {
6
+            font-family: Verdana, Arial, sans-serif;
7
+        }
8
+
9
+        table {
10
+            font-size: x-small;
11
+            border-collapse: collapse;
12
+            border-spacing: 0;
13
+            width: 100%;
14
+        }
15
+
16
+        tfoot tr td {
17
+            font-weight: bold;
18
+            font-size: x-small;
19
+        }
20
+
21
+        @page {
22
+            margin: 180px 50px;
23
+        }
24
+
25
+        #header {
26
+            position: fixed;
27
+            left: 0px;
28
+            top: -180px;
29
+            right: 0px;
30
+            height: 110px;
31
+            text-align: center;
32
+            padding-top: 40px;
33
+        }
34
+
35
+        #footer {
36
+            position: fixed;
37
+            left: 0px;
38
+            bottom: -180px;
39
+            right: 0px;
40
+            height: 150px;
41
+        }
42
+
43
+        .page:after {
44
+            content: counter(page, numeric);
45
+        }
46
+    </style>
47
+
48
+<body>
49
+    <div id="header">
50
+        <table>
51
+            <tr>
52
+                <td style="width: 65%;">
53
+                    <table>
54
+                        <tr>
55
+                            <td style="vertical-align: super;"><strong>To</strong></td>
56
+                            <td style="vertical-align: super;">:</td>
57
+                            <td style="padding: 0;">
58
+                                <table style="border-spacing: 0;">
59
+                                    <tr>
60
+                                        <td>Cahaya Agung</td>
61
+                                    </tr>
62
+                                    <tr>
63
+                                        <td>Anonym</td>
64
+                                    </tr>
65
+                                </table>
66
+                            </td>
67
+                        </tr>
68
+                        <tr>
69
+                            <td style="vertical-align: super"><strong>NPWP</strong></td>
70
+                            <td style="vertical-align: super">:</td>
71
+                            <td style="padding: 0">
72
+                                <table style="border-spacing: 0">
73
+                                    <tr>
74
+                                        <td>XXXXXXXXXXXXXXX</td>
75
+                                    </tr>
76
+                                </table>
77
+                            </td>
78
+                        </tr>
79
+                    </table>
80
+                </td>
81
+                <td style="width: 35%;">
82
+                    <table>
83
+                        <tr style="text-align: center">
84
+                            <td> <strong style="text-transform: uppercase; font-size: medium">Pembeli</strong></td>
85
+                        </tr>
86
+                        <tr>
87
+                            <td>
88
+                                <table>
89
+                                    <tr>
90
+                                        <td>Nama</td>
91
+                                        <td>:</td>
92
+                                        <td>Anonym</td>
93
+                                    </tr>
94
+                                    <tr>
95
+                                        <td>No HP</td>
96
+                                        <td>:</td>
97
+                                        <td>08XXXXXXXXXX</td>
98
+                                    </tr>
99
+                                    <tr>
100
+                                        <td>Alamat</td>
101
+                                        <td>:</td>
102
+                                        <td>Anonym</td>
103
+                                    </tr>
104
+                                    <tr>
105
+                                        <td>Tanggal</td>
106
+                                        <td>:</td>
107
+                                        <td>Anonym</td>
108
+                                    </tr>
109
+                                    <tr>
110
+                                        <td>Nomor Pembelian</td>
111
+                                        <td>:</td>
112
+                                        <td>Anonym</td>
113
+                                    </tr>
114
+                                    <tr>
115
+                                        <td>Halaman</td>
116
+                                        <td>:</td>
117
+                                        <td class="page"></td>
118
+                                    </tr>
119
+                                </table>
120
+                            </td>
121
+                        </tr>
122
+                    </table>
123
+                </td>
124
+            </tr>
125
+        </table>
126
+    </div>
127
+
128
+    <div id="footer">
129
+    </div>
130
+
131
+    <div id="content">
132
+        <table>
133
+            <thead style="border-top: 1px solid black; border-bottom: 1px solid black;">
134
+                <tr>
135
+                    <th>No</th>
136
+                    <th>Keterangan</th>
137
+                    <th>QTY</th>
138
+                    <th>Satuan</th>
139
+                    <th>Harga Satuan</th>
140
+                    <th>Jumlah</th>
141
+                </tr>
142
+            </thead>
143
+            <tbody style="text-align: center;">
144
+                @for ($i = 0; $i < 150; $i++)
145
+                    <tr>
146
+                        <th>1</th>
147
+                        <td style="text-align: left;">Playstation IV - Black</td>
148
+                        <td>1</td>
149
+                        <td>pc</td>
150
+                        <td style="text-align: right;">1400.00</td>
151
+                        <td style="text-align: right;">1400.00</td>
152
+                    </tr>
153
+                @endfor
154
+            </tbody>
155
+            <tfoot style="border-top: 1px solid black; border-bottom: 1px solid black; text-align: right;">
156
+                <tr>
157
+                    <td colspan="4"></td>
158
+                    <td>Subtotal Rp</td>
159
+                    <td>1635.00</td>
160
+                </tr>
161
+                <tr>
162
+                    <td colspan="4"></td>
163
+                    <td>PPN 11%</td>
164
+                    <td>1929.3</td>
165
+                </tr>
166
+                <tr>
167
+                    <td colspan="4"></td>
168
+                    <td>Total Rp</td>
169
+                    <td>1929.3</td>
170
+                </tr>
171
+            </tfoot>
172
+        </table>
173
+
174
+        <table>
175
+            <tbody>
176
+                <tr>
177
+                    <td style="width: 40%;"></td>
178
+                    <td style="width: 60%;">
179
+                        <table style="width: 100%; text-align: right;">
180
+                            <thead style="margin-bottom: 20px;">
181
+                                <tr>
182
+                                    <td></td>
183
+                                    <td colspan="1">
184
+                                        <p style="margin-bottom: 75px; margin-top: 70px;">Cahaya Agung</p>
185
+                                    </td>
186
+                                </tr>
187
+                            </thead>
188
+                            <tbody>
189
+                                <tr>
190
+                                    <td>
191
+                                        <span
192
+                                            style="border-top: 1px solid black; width: 150px;display: inline-block; text-align: left;">Diterima</span>
193
+                                    </td>
194
+                                    <td>
195
+                                        <span
196
+                                            style="border-top: 1px solid black; width: 120px;display: inline-block; text-align: center;">Penjual</span>
197
+                                    </td>
198
+                                </tr>
199
+                            </tbody>
200
+                        </table>
201
+                    </td>
202
+                </tr>
203
+            </tbody>
204
+        </table>
205
+    </div>
206
+</body>
207
+
208
+</html>

+ 29
- 18
routes/web.php Просмотреть файл

@@ -9,6 +9,7 @@ use App\Http\Controllers\SalesController;
9 9
 use App\Http\Controllers\StockProductController;
10 10
 use App\Http\Controllers\SupplierController;
11 11
 use App\Http\Controllers\UserController;
12
+use App\Models\Sale;
12 13
 use Illuminate\Support\Facades\Route;
13 14
 
14 15
 /*
@@ -22,35 +23,45 @@ use Illuminate\Support\Facades\Route;
22 23
 |
23 24
  */
24 25
 
25
-Route::middleware(['auth', 'verified'])->group(function () {
26
-    Route::get('/', DashboardController::class);
26
+Route::middleware(["auth", "verified"])->group(function () {
27
+    Route::get("/", DashboardController::class);
27 28
 
28
-    Route::get('/dashboards', DashboardController::class);
29
+    Route::get("/dashboards", DashboardController::class);
29 30
 
30
-    Route::put('/users/reset-password/{user}', [UserController::class, 'resetPassword'])
31
-        ->name('users.reset-password');
31
+    Route::put("/users/reset-password/{user}", [
32
+        UserController::class,
33
+        "resetPassword",
34
+    ])->name("users.reset-password");
32 35
 
33
-    Route::delete('/users/block/{user}', [UserController::class, 'block'])
34
-        ->name('users.block');
36
+    Route::delete("/users/block/{user}", [
37
+        UserController::class,
38
+        "block",
39
+    ])->name("users.block");
35 40
 
36
-    Route::post('/users/change-password/{user}', [UserController::class, 'changePassword'])
37
-        ->name('users.change-password');
41
+    Route::post("/users/change-password/{user}", [
42
+        UserController::class,
43
+        "changePassword",
44
+    ])->name("users.change-password");
38 45
 
39
-    Route::resource('/users', UserController::class);
46
+    Route::resource("/users", UserController::class);
40 47
 
41
-    Route::resource('/ppn', PpnController::class);
48
+    Route::resource("/ppn", PpnController::class);
42 49
 
43
-    Route::resource('/customers', CustomerController::class);
50
+    Route::resource("/customers", CustomerController::class);
44 51
 
45
-    Route::resource('/purchases', PurchaseController::class);
52
+    Route::resource("/purchases", PurchaseController::class);
46 53
 
47
-    Route::resource('/sales', SalesController::class);
54
+    Route::resource("/sales", SalesController::class);
48 55
 
49
-    Route::resource('/suppliers', SupplierController::class);
56
+    Route::get("/sales/pdf/{sale}", [SalesController::class, "pdf"])->name(
57
+        "sales.pdf"
58
+    );
50 59
 
51
-    Route::resource('/stock-products', StockProductController::class);
60
+    Route::resource("/suppliers", SupplierController::class);
52 61
 
53
-    Route::resource('/products', ProductController::class);
62
+    Route::resource("/stock-products", StockProductController::class);
63
+
64
+    Route::resource("/products", ProductController::class);
54 65
 });
55 66
 
56
-require __DIR__ . '/auth.php';
67
+require __DIR__ . "/auth.php";