bio-links.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. @extends('layouts.app')
  2. @section('css')
  3. @endsection
  4. @php
  5. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  6. $lang = $resto->default_lang;
  7. app()->setLocale($lang);
  8. if(session('app_lang') !==null){
  9. $lang = session('app_lang');
  10. app()->setLocale($lang);
  11. }
  12. @endphp
  13. @section('content')
  14. <link href="{!! env('APP_ASSETS') !!}vendor_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css" rel="stylesheet"/>
  15. <link href="{!! env('APP_ASSETS') !!}vendor_components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css" rel="stylesheet"/>
  16. <link href="{!! env('APP_ASSETS') !!}/css/jquery.timepicker.min.css" rel="stylesheet"/>
  17. <link href="{!! env('APP_ASSETS') !!}vendor_components/select2/dist/css/select2.min.css" rel="stylesheet">
  18. <style>
  19. .datepicker-days{
  20. display: block !important;
  21. }
  22. .alert {
  23. display: none;
  24. }
  25. .border-red {
  26. border: 1px solid #F00 !important;
  27. }
  28. .tab-pane{}
  29. .container-full,.content-wrapper{
  30. background-color: transparent !important;
  31. }
  32. #image-preview {
  33. width: 700px;
  34. border-radius: 20px;
  35. height: 341px;
  36. position: relative;
  37. overflow: hidden;
  38. background-color: #f9f9f9;
  39. color: #ecf0f1;
  40. background-position: center !important;
  41. background-size: cover !important;
  42. }
  43. #image-preview input {
  44. line-height: 200px;
  45. font-size: 200px;
  46. position: absolute;
  47. opacity: 0;
  48. z-index: 10;
  49. }
  50. #image-preview label {
  51. position: absolute;
  52. z-index: 5;
  53. opacity: 0.8;
  54. cursor: pointer;
  55. background-color: #bdc3c7;
  56. width: 200px;
  57. height: 50px;
  58. font-size: 20px;
  59. line-height: 50px;
  60. text-transform: uppercase;
  61. top: 0;
  62. left: 0;
  63. right: 0;
  64. bottom: 0;
  65. margin: auto;
  66. text-align: center;
  67. }
  68. .select2-container .select2-selection--multiple{
  69. min-height: 46px;
  70. }
  71. .form-control, .form-select {
  72. height: 46px !important;
  73. border-color: #E4E6EB !important;
  74. border-radius: 7px !important;
  75. }
  76. .select2-container--default .select2-selection--single{
  77. height: 40px !important;
  78. border-color: #E4E6EB !important;
  79. border-radius: 7px !important;
  80. padding: 9px 12px;
  81. }
  82. .outlet-section,.item-section{
  83. display: none;
  84. }
  85. .outlets.selected .outlet-section, .items.selected .item-section{
  86. display: inline-flex;
  87. }
  88. .select2 {width: 100% !important;}
  89. html[dir="rtl"] .ar-m-0{
  90. margin: 0 !important;
  91. }
  92. </style>
  93. <div class="content-wrapper">
  94. @php
  95. $selectSocialMedia = [];
  96. $social_media_array = ['facebook','youtube','instagram','twitter','tiktok','weChat','linkedIn'];
  97. if(isset($businessLinks)){
  98. $businessSocialLinks = ($businessLinks->business_links);
  99. $selectSocialMedia = $businessSocialLinks->pluck('social_type')->toArray();
  100. }
  101. $remaining_social_media = array_diff($social_media_array,$selectSocialMedia);
  102. @endphp
  103. <div class="container-full">
  104. <section class="content pt-3">
  105. <form id="bio-form" method="POST" action="{!! env('APP_URL') !!}bio/link/save"
  106. enctype="multipart/form-data">
  107. @csrf
  108. <input type="hidden" name="id" value="{!! isset($bioLink)?$bioLink->id:'' !!}"/>
  109. <div class="row ar-m-0">
  110. <div class="col-xl-8 col-sm-8">
  111. <div class="card mb-4">
  112. <div class="card-body">
  113. <h4>{{__('label.add_bio_link')}}</h4>
  114. <p>Enable and manage bio links for social media
  115. </p>
  116. <div class="row">
  117. <div class="form-group">
  118. <label>Page Background (optional)</label>
  119. <input type="file" name="background_image" class="form-control" />
  120. </div>
  121. </div>
  122. @if(isset($businessLinks))
  123. <div class="row">
  124. <div class="col-md-12">
  125. <img src="{!! $businessLinks->background_image !!}" width="200px" />
  126. </div>
  127. </div>
  128. @endif
  129. </div>
  130. </div>
  131. <div class="card">
  132. <div class="card-header">Social Links</div>
  133. <div class="card-body">
  134. <div class="table-responsive">
  135. <table class="table table-stripped table-borderless">
  136. <thead>
  137. <tr>
  138. <th width="20%">Social Media Type</th>
  139. <th width="30%">Label</th>
  140. <th >Social Media Link</th>
  141. <th></th>
  142. </tr>
  143. </thead>
  144. <tbody>
  145. @if(isset($businessSocialLinks) && $businessSocialLinks->count() > 0)
  146. @foreach($businessSocialLinks as $link)
  147. <tr>
  148. <td>
  149. @php
  150. @endphp
  151. <select class="form-control social_media_type form-control-sm" name="social_media_type[]" required>
  152. <option value="">Choose Social Media Type</option>
  153. @foreach($social_media_array as $media)
  154. <option @if($link->social_type==$media) selected @endif value="{!! ($media) !!}">{!! ucwords($media) !!}</option>
  155. @endforeach
  156. </select>
  157. </td>
  158. <td width="30%">
  159. <input type="text" value="{!! $link->social_label !!}" name="social_label[]" class="form-control form-control-sm" required />
  160. </td>
  161. <td >
  162. <input type="url" value="{!! $link->social_link !!}" name="social_media_link[]" class="form-control form-control-sm" required />
  163. </td>
  164. <td>
  165. <a href="#!" class="text-danger delete-social"><i class="glyphicon glyphicon-trash"></i> </a>
  166. </td>
  167. </tr>
  168. @endforeach
  169. @endif
  170. <tr class="for-clone">
  171. <td width="20%">
  172. <select class="form-control social_media_type form-control-sm" name="social_media_type[]" required>
  173. <option value="">Choose Social Media Type</option>
  174. @foreach($remaining_social_media as $media)
  175. <option value="{!! ($media) !!}">{!! ucwords($media) !!}</option>
  176. @endforeach
  177. </select>
  178. </td>
  179. <td width="30%">
  180. <input type="text" name="social_label[]" class="form-control form-control-sm" required />
  181. </td>
  182. <td >
  183. <input type="url" name="social_media_link[]" class="form-control form-control-sm" required />
  184. </td>
  185. <td>
  186. <a href="#!" class="text-danger delete-social"><i class="glyphicon glyphicon-trash"></i> </a>
  187. </td>
  188. </tr>
  189. </tbody>
  190. <tfoot>
  191. <tr>
  192. <td colspan="3" class="text-end">
  193. <a href="#!" class="btn btn-primary btn-sm add-more"> Add More </a>
  194. </td>
  195. </tr>
  196. </tfoot>
  197. </table>
  198. </div>
  199. </div>
  200. </div>
  201. <div class="card card-body">
  202. <div class="row">
  203. <div class="col-md-3">
  204. <a href="#!" class="btn btn-primary save-bio-link">{{__('label.save_bio_link')}}</a>
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. <div class="col-xl-4 col-sm-4">
  210. <div class="card">
  211. <div class="card-header">QR Code</div>
  212. <div class="card-body">
  213. <div id="output" class="qr-output"></div>
  214. <a style="width: 100%; margin: 10px 0" class="btn btn-primary download-image ">{{__('label.download')}}</a>
  215. <input type="text" class="form-control" readonly name="" value="{!! env('SHARE_LINK_URL').$resto->resto_unique_name !!}">
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. </form>
  221. </section>
  222. </div>
  223. </div>
  224. <div id="download" style="display: none"></div
  225. @endsection
  226. @section('js')
  227. <script src="{!! env('APP_ASSETS') !!}vendor_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
  228. <script src="{!! env('APP_ASSETS') !!}vendor_components/select2/dist/js/select2.min.js"></script>
  229. <script src="{!! env('APP_ASSETS') !!}js/jquery.timepicker.min.js"></script>
  230. <script src="{!! env('APP_ASSETS') !!}js/jquery.qrcode.min.js"></script>
  231. <script type="text/javascript">
  232. $(function(){
  233. $('#output').qrcode({
  234. render: "canvas",
  235. text: "{!! env('SHARE_LINK_URL').$resto->resto_unique_name !!}",
  236. width: 250,
  237. height: 250,
  238. background: "#ffffff",
  239. foreground: "#000000",
  240. imgWidth: 50,
  241. imgHeight: 50
  242. });
  243. $('#download').qrcode({
  244. render: "canvas",
  245. text: "{!! env('SHARE_LINK_URL').$resto->resto_unique_name !!}",
  246. width: 2000,
  247. height: 2000,
  248. background: "#ffffff",
  249. foreground: "#000000",
  250. imgWidth: 500,
  251. imgHeight: 500
  252. });
  253. $(".download-image").click(function () {
  254. var canvas = $('#download canvas')[0];
  255. var _this = $(this);
  256. console.log(canvas.toDataURL());
  257. // Change here
  258. $.ajax({
  259. url: "{!! env('APP_URL') !!}download/qrcode",
  260. type: "POST",
  261. data: {
  262. resto:"bio-link-{!! $resto->resto_unique_name !!}-bio-link",
  263. data: canvas.toDataURL(),
  264. '_token': "{!! csrf_token() !!}"
  265. },
  266. success: function (response) {
  267. console.log(response);
  268. var link = document.createElement('a');
  269. link.href = response;
  270. link.download = "bio-link-{!! $resto->resto_unique_name !!}-qrcode.png";
  271. link.click();
  272. }
  273. });
  274. });
  275. $("body").on("click",".save-bio-link",function(){
  276. if($("#bio-form").valid()){
  277. $("#bio-form").ajaxForm(function(response){
  278. if(response.type=="success"){
  279. $.toast({
  280. heading: 'Bio Links.',
  281. text: response.message,
  282. position: 'top-right',
  283. loaderBg: '#ff6849',
  284. icon: 'success',
  285. hideAfter: 3000,
  286. stack: 1
  287. });
  288. setTimeout(function () {
  289. location.reload();
  290. },2000);
  291. }else{
  292. $.toast({
  293. heading: 'Bio Links.',
  294. text: response.message,
  295. position: 'top-right',
  296. loaderBg: '#ff6849',
  297. icon: 'error',
  298. hideAfter: 3000,
  299. stack: 1
  300. });
  301. }
  302. }).submit();
  303. }
  304. });
  305. $("body").on("click",".add-more",function(){
  306. var _lastRow = $('table tbody').find("tr:last");
  307. var _newRow = _lastRow.clone();
  308. _newRow.find('input').val('');
  309. $('table tbody').find("tr:last").after(_newRow);
  310. });
  311. $("body").on("click",".delete-social",function(e){
  312. e.preventDefault();
  313. var _this = $(this);
  314. var _tr = $("table tbody tr").length;
  315. // alert(_tr);
  316. if(_tr ==1){
  317. alert('cannot delete all social media link');
  318. return false;
  319. }
  320. _this.parents('tr').remove();
  321. });
  322. })
  323. </script>
  324. @endsection