Mikescher

Untitled

Nov 29th, 2021
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.61 KB | None | 0 0
  1. www-data@blackforestbytes:~/plantmytree$
  2. www-data@blackforestbytes:~/plantmytree$ cat resources/views/control/show.blade.php
  3. <x-app-layout>
  4. <x-slot name="header">
  5. <h2 class="font-semibold text-xl text-gray-800 leading-tight">
  6. {{ __('Flächen-Kontrollprotokoll') }}
  7. </h2>
  8. </x-slot>
  9.  
  10. <div class="py-12">
  11. <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
  12. <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
  13. <div class="p-6 bg-white border-b border-gray-200">
  14. Neues Kontroll Protokoll anlegen
  15. </div>
  16. </div>
  17. </div>
  18.  
  19. <div class="max-w-7xl mx-auto sm:px-6 lg:px-8 mt-6">
  20. <div class="bg-white p-6">
  21.  
  22. <div class="mb-3">
  23. <x-alert-wrapper></x-alert-wrapper>
  24. </div>
  25.  
  26. <form class="" action="{{ route('protocol.control.store') }}" method="POST">
  27. @csrf
  28. <div class="space-y-8 divide-y divide-gray-200">
  29.  
  30. <div class="">
  31. <div>
  32. <h3 class="text-lg leading-6 font-medium text-gray-900">
  33. Daten
  34. </h3>
  35. </div>
  36. <div class="mt-6 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6">
  37. <div class="sm:col-span-12">
  38. <x-label for="jsDataSearch">Suche Fläche</x-label>
  39. <select id="jsDataSearch" class="w-96"></select>
  40. </div>
  41.  
  42. <div class="sm:col-span-3">
  43. <x-label for="area">
  44. Fläche
  45. </x-label>
  46. <div class="mt-1">
  47. <x-input type="text" name="area" id="area" required />
  48. </div>
  49. </div>
  50.  
  51. <div class="sm:col-span-3">
  52. <x-label for="articleNumber">
  53. Artikel-Nummer
  54. </x-label>
  55. <div class="mt-1">
  56. <x-input type="text" name="article_number" id="articleNumber" required />
  57. </div>
  58. </div>
  59.  
  60. <div class="sm:col-span-12">
  61. <x-label for="controller">
  62. Kontrolleur
  63. </x-label>
  64. <div class="mt-1">
  65. <x-input id="controller" name="controller" type="text" required />
  66. </div>
  67. <div class="mt-1">
  68. <x-checkbox id="controller_external" name="controller_external" autocomplete="off">Extern</x-checkbox>
  69. </div>
  70. </div>
  71.  
  72. <div class="sm:col-span-12 mt-1">
  73. <x-textarea id="deficit" name="deficit">Festgestellte Mängel/Beschädigungen/nicht angewachsene Setzlinge</x-textarea>
  74. </div>
  75.  
  76. <div class="sm:col-span-12">
  77. <div class="">
  78. <x-checkbox id="replacementNecessary" name="replacement_necessary" autocomplete="off">Ersatzpflanzung erforderlich</x-checkbox>
  79. </div>
  80. </div>
  81.  
  82. <div id="replacementWrapper" class="grid grid-cols-12 sm:col-span-12 gap-x-4" style="display:none;">
  83. <div class="sm:col-span-5">
  84. <x-label for="reason">
  85. Begründung
  86. </x-label>
  87. <div class="mt-1">
  88. <x-input type="text" name="reason" id="reason" />
  89. </div>
  90. </div>
  91.  
  92. <div class="sm:col-span-12 md:col-span-2">
  93. <x-label>Datum der Pflanzung</x-label>
  94. <div class="relative">
  95. <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
  96. <svg class="w-5 h-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"></path></svg>
  97. </div>
  98. <input id="datepicker" datepicker name="date_of_plantation" type="text" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5" placeholder="Select date" value="{{ now()->format('d.m.Y') }}">
  99. </div>
  100. </div>
  101.  
  102. <div class="sm:col-span-5">
  103. <x-label for="through">
  104. Durch
  105. </x-label>
  106. <div class="mt-1">
  107. <x-input type="text" name="through" id="through" />
  108. </div>
  109. <div class="mt-1">
  110. <x-checkbox id="through_external" name="through_external" autocomplete="off">Extern</x-checkbox>
  111. </div>
  112. </div>
  113. </div>
  114.  
  115. <div class="grid grid-cols-12 sm:col-span-12">
  116. <div class="sm:col-span-12 md:col-span-2">
  117. <x-label>Datum</x-label>
  118. <div class="relative">
  119. <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
  120. <svg class="w-5 h-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"></path></svg>
  121. </div>
  122. <input id="datepicker" datepicker name="date" required type="text" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5" placeholder="Select date" value="{{ now()->format('d.m.Y') }}">
  123. </div>
  124. </div>
  125. </div>
  126.  
  127. <div class="sm:col-span-12">
  128. <label for="signature">Unterschrift</label>
  129. <div class="h-20 my-2 w-20">
  130. <img src="data:," alt="" id="signature_signature_img" style="height: inherit; width: auto" class="">
  131. <input type="hidden" name="signature" id="signature_signature">
  132. </div>
  133. <div class="">
  134. <x-button type="button" class="add-signature" data-type="signature">Unterschrift hinzufügen</x-button>
  135. <x-button type="button" class="remove-signature" data-type="signature">Unterschrift entfernen</x-button>
  136. </div>
  137. </div>
  138.  
  139.  
  140. </div>
  141. </div>
  142.  
  143. </div>
  144.  
  145. <div class="pt-5">
  146. <div class="flex justify-end">
  147. <button type="button" class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
  148. Cancel
  149. </button>
  150. <button type="submit" class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
  151. Save
  152. </button>
  153. </div>
  154. </div>
  155. </form>
  156.  
  157.  
  158. </div>
  159.  
  160. </div>
  161. </div>
  162.  
  163. <div id="signatureWrapper" class="signature-wrapper" style="display: none">
  164. <div id="signature-pad" class="signature-pad">
  165. <div class="signature-pad--body">
  166. <canvas id="signaturePad"></canvas>
  167. </div>
  168. <div class="signature-pad--footer">
  169. <div class="description">Sign above</div>
  170.  
  171. <div class="signature-pad--actions">
  172. <div>
  173. <x-button type="button" data-action="close" size="small">
  174. <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  175. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
  176. </svg>
  177. </x-button>
  178. <x-button type="button" data-action="clear" size="small">
  179. <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  180. <path stroke-linecap="round" stroke-linejoin="round" stroke-width={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
  181. </svg>
  182. </x-button>
  183. <button type="button" class="btn btn-sm btn-outline-dark px-3" data-action="undo" title="Rückgängig machen"><i class="fas fa-undo"></i></button>
  184. </div>
  185. <div>
  186. <x-button type="button" data-action="add-signature" class="bg-indigo-600" size="small">
  187. <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  188. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
  189. </svg>
  190. </x-button>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196.  
  197.  
  198. <x-slot name="afterStyles">
  199. <style>
  200.  
  201. .signature-wrapper{
  202. position: fixed;
  203. top: 0;
  204. left: 0;
  205. right: 0;
  206. bottom: 0;
  207. z-index: 2000;
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. background-color: rgba(0,0,0,0.5);
  212. }
  213. .signature-pad {
  214. position: relative;
  215. display: -webkit-box;
  216. display: -ms-flexbox;
  217. display: flex;
  218. -webkit-box-orient: vertical;
  219. -webkit-box-direction: normal;
  220. -ms-flex-direction: column;
  221. flex-direction: column;
  222. font-size: 10px;
  223. width: 100%;
  224. height: 100%;
  225. max-width: 700px;
  226. max-height: 300px;
  227. border: 1px solid #e8e8e8;
  228. background-color: #E6E6E6;
  229. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.08) inset;
  230. border-radius: 4px;
  231. padding: 16px;
  232. }
  233.  
  234. .signature-pad::before,
  235. .signature-pad::after {
  236. position: absolute;
  237. z-index: -1;
  238. content: "";
  239. width: 40%;
  240. height: 10px;
  241. bottom: 10px;
  242. background: transparent;
  243. box-shadow: 0 8px 12px rgba(0, 0, 0, 0.4);
  244. }
  245.  
  246. .signature-pad::before {
  247. left: 20px;
  248. -webkit-transform: skew(-3deg) rotate(-3deg);
  249. transform: skew(-3deg) rotate(-3deg);
  250. }
  251.  
  252. .signature-pad::after {
  253. right: 20px;
  254. -webkit-transform: skew(3deg) rotate(3deg);
  255. transform: skew(3deg) rotate(3deg);
  256. }
  257.  
  258. .signature-pad--body {
  259. position: relative;
  260. -webkit-box-flex: 1;
  261. -ms-flex: 1;
  262. flex: 1;
  263. border: 1px solid #f4f4f4;
  264. }
  265.  
  266. .signature-pad--body canvas {
  267. position: absolute;
  268. left: 0;
  269. top: 0;
  270. width: 100%;
  271. height: 100%;
  272. border-radius: 4px;
  273. box-shadow: 0 0 5px rgba(0, 0, 0, 0.02) inset;
  274. }
  275.  
  276. .signature-pad--footer {
  277. color: #5B5B5B;
  278. text-align: center;
  279. font-size: 1.2em;
  280. margin-top: 8px;
  281. }
  282.  
  283. .signature-pad--actions {
  284. display: -webkit-box;
  285. display: -ms-flexbox;
  286. display: flex;
  287. -webkit-box-pack: justify;
  288. -ms-flex-pack: justify;
  289. justify-content: space-between;
  290. margin-top: 8px;
  291. }
  292. </style>
  293. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  294. </x-slot>
  295.  
  296. <x-slot name="afterScripts">
  297. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  298. <script src="https://cdn.jsdelivr.net/npm/signature_pad@2.3.2/dist/signature_pad.min.js"></script>
  299. <script>
  300. $(document).ready(function (){
  301.  
  302. $('#replacementNecessary').change(function (){
  303. $('#replacementWrapper').fadeToggle();
  304. })
  305.  
  306. fetchData();
  307.  
  308. let data = [];
  309.  
  310. function fetchData(){
  311.  
  312. $.ajax({
  313. url: '{{ route('articles.search') }}',
  314. })
  315. .done(function( response ) {
  316. data = response.data.map((element) => {
  317. return {
  318. id: element.id,
  319. text: element.name,
  320. articleNumber: element.articleNumber,
  321. customAttributes: element.customAttributes,
  322. }
  323. })
  324.  
  325. $('#jsDataSearch').select2({
  326. data: data,
  327. });
  328. })
  329. .fail(function (error){
  330. alert('Konnte article nicht laden');
  331. })
  332. ;
  333.  
  334. }
  335.  
  336. $('#jsDataSearch').on('select2:select', function (e){
  337. const data = e.params.data;
  338. console.log(data)
  339.  
  340. $('#articleNumber').val(data.id);
  341.  
  342. data.customAttributes.forEach((item) => {
  343. if(item.labelText == 'Ort'){
  344. $('#area').val(item.value);
  345. }
  346. })
  347. });
  348.  
  349.  
  350. var signatureType;
  351. $('.add-signature').click(function (){
  352. signatureType = $(this).data('type');
  353. $('#signatureWrapper').fadeIn();
  354.  
  355. resizeCanvas();
  356. });
  357.  
  358. $('[data-action=close]').click(function (){
  359. closeSignaturePad();
  360. });
  361.  
  362. $('.remove-signature').click(function (){
  363. let type = $(this).data('type');
  364. $('#signature_'+type+'_img').attr('src', '');
  365. $('#signature_'+type).val('');
  366. $('#remove_'+type+'_signature').fadeOut(0);
  367. });
  368.  
  369. var wrapper = document.getElementById("signature-pad");
  370. var clearButton = wrapper.querySelector("[data-action=clear]");
  371. var undoButton = wrapper.querySelector("[data-action=undo]");
  372. var addSignatureButton = wrapper.querySelector("[data-action=add-signature]");
  373. var canvas = wrapper.querySelector("canvas");
  374. var signaturePad = new SignaturePad(canvas, {
  375. backgroundColor: 'rgb(255, 255, 255)'
  376. });
  377.  
  378. function resizeCanvas() {
  379. var ratio = Math.max(window.devicePixelRatio || 1, 1);
  380.  
  381. canvas.width = canvas.offsetWidth * ratio;
  382. canvas.height = canvas.offsetHeight * ratio;
  383. canvas.getContext("2d").scale(ratio, ratio);
  384.  
  385. signaturePad.clear();
  386. }
  387.  
  388. window.onresize = resizeCanvas;
  389. resizeCanvas();
  390.  
  391. function dataURLToBlob(dataURL) {
  392. // Code taken from https://github.com/ebidel/filer.js
  393. var parts = dataURL.split(';base64,');
  394. var contentType = parts[0].split(":")[1];
  395. var raw = window.atob(parts[1]);
  396. var rawLength = raw.length;
  397. var uInt8Array = new Uint8Array(rawLength);
  398.  
  399. for (var i = 0; i < rawLength; ++i) {
  400. uInt8Array[i] = raw.charCodeAt(i);
  401. }
  402.  
  403. return new Blob([uInt8Array], { type: contentType });
  404. }
  405.  
  406. clearButton.addEventListener("click", function (event) {
  407. signaturePad.clear();
  408. });
  409.  
  410. undoButton.addEventListener("click", function (event) {
  411. var data = signaturePad.toData();
  412.  
  413. if (data) {
  414. data.pop(); // remove the last dot or line
  415. signaturePad.fromData(data);
  416. }
  417. });
  418.  
  419. function closeSignaturePad(){
  420. signaturePad.clear();
  421. $('#signatureWrapper').fadeOut();
  422. }
  423.  
  424. addSignatureButton.addEventListener("click", function (event) {
  425. if (signaturePad.isEmpty()) {
  426. alert("Please provide a signature first.");
  427. } else {
  428. var dataURL = signaturePad.toDataURL();
  429. console.log(dataURL);
  430. $('#signature_'+signatureType+'_img').attr('src', dataURL);
  431. $('#signature_'+signatureType).val(dataURL);
  432. $('#remove_'+signatureType+'_signature').fadeIn();
  433. closeSignaturePad();
  434. }
  435. });
  436. });
  437. </script>
  438. </x-slot>
  439.  
  440. </x-app-layout>
  441.  
  442. www-data@blackforestbytes:~/plantmytree$
  443.  
Add Comment
Please, Sign In to add comment