recipe_form.blade.php 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888
  1. @extends('layouts.app')
  2. @section('css')
  3. <link href="{!! env('APP_ASSETS') !!}vendor_components/dropzone/dist/dropzone.css" rel="stylesheet">
  4. <link href="{!! env('APP_ASSETS') !!}vendor_components/select2/dist/css/select2.min.css" rel="stylesheet">
  5. @endsection
  6. @php
  7. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  8. $lang = $resto->default_lang;
  9. app()->setLocale($lang);
  10. if(session('app_lang') !==null){
  11. $lang = session('app_lang');
  12. app()->setLocale($lang);
  13. }
  14. @endphp
  15. @section('content')
  16. <style>
  17. .alert{
  18. display: none;
  19. }
  20. .container-full,.content-wrapper{
  21. background-color: transparent !important;
  22. }
  23. .card-header{
  24. display: inline-block;
  25. }
  26. #image-preview {
  27. width: 768px;
  28. border-radius: 20px;
  29. /*height: 341px;*/
  30. position: relative;
  31. overflow: hidden;
  32. background-color: #f9f9f9;
  33. color: #ecf0f1;
  34. background-position: center !important;
  35. background-size: cover !important;
  36. }
  37. #image-preview input {
  38. line-height: 200px;
  39. font-size: 200px;
  40. position: absolute;
  41. opacity: 0;
  42. z-index: 10;
  43. }
  44. #add-variations .modal-dialog{
  45. max-width: 70%;
  46. }
  47. .dynamic-column{
  48. min-width: 200px;
  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. .form-control, .form-select {
  69. height: 46px ;
  70. border-color: #E4E6EB !important;
  71. border-radius: 7px !important;
  72. }
  73. .select2 {
  74. width: 100% !important;
  75. height: 46px;
  76. border-color: #E4E6EB !important;
  77. border-radius: 7px !important;
  78. /*padding: 0.375rem 0.75rem !important;
  79. font-size: 1rem !important;
  80. font-weight: 400;
  81. line-height: 1.5;
  82. color: #212529;*/
  83. }
  84. textarea{
  85. height: 80px !important;
  86. }
  87. .select2-container--default .select2-selection--multiple{
  88. padding:6px;
  89. }
  90. .select2-container--default .select2-selection--single{
  91. padding:12px 5px;
  92. height: 46px;
  93. }
  94. @media only screen and (max-width:428px){
  95. #image-preview{
  96. width:100%;
  97. }
  98. }
  99. .modal-header {
  100. border-bottom-color: #ffab00;
  101. background-color: #ffab00;
  102. color:white;
  103. }
  104. </style>
  105. @php
  106. $restuarant1 = $resto;
  107. $resto_meta = isset($restuarant1->resto_metas)?$restuarant1->resto_metas:null;
  108. $resto_metas = [];
  109. $billing = [];
  110. if(isset($resto_meta)){
  111. foreach($resto_meta as $meta){
  112. // dump($meta->resto_meta_defs);
  113. $index_name = isset($meta->resto_meta_defs->parents)?$meta->resto_meta_defs->parents->meta_def_name:$meta->resto_meta_defs->meta_def_name;
  114. if(isset($_GET['debug'])){
  115. // dump($index_name );
  116. }
  117. if($meta->resto_meta_defs->meta_def_name=="BILLING_GATEWAY"){
  118. // dump($meta->resto_meta_defs->meta_def_name);
  119. // $resto_metas['BILLING_GATEWAY'][] = $meta->meta_val;
  120. $billing[] = array('id'=>$meta->meta_id,'value'=>$meta->meta_val);
  121. }
  122. $resto_metas[$index_name] = $meta->meta_val;
  123. }
  124. }
  125. $resto_metas['BILLING_GATEWAY'] = $billing;
  126. $currency = isset($resto_metas['BUSSINESS_CCY'])?$resto_metas['BUSSINESS_CCY']:"IQD";
  127. $business_type = isset($resto_metas['BUSSINESS_TYPE'])?$resto_metas['BUSSINESS_TYPE']:"Restaurants";
  128. $allow_pre_order = isset($resto_metas['ALLOW_PRE_ORDERS'])?$resto_metas['ALLOW_PRE_ORDERS']:"No";
  129. $business_type = trim($business_type);
  130. @endphp
  131. <div class="content-wrapper">
  132. <div class="container-full">
  133. <section class="content">
  134. <h1 class="mt-4">{{__('label.recipe')}}</h1>
  135. <ol class="breadcrumb mb-4">
  136. <li class="breadcrumb-item"><a href="{!! env('APP_URL') !!}dashboard">{{__('label.dashboard')}}</a></li>
  137. <li class="breadcrumb-item active"> @if(isset($recipe)) {{__('label.edit_recipe')}} @else {{__('label.new_recipe')}} @endif</li>
  138. </ol>
  139. <div class="row">
  140. <div class="col-xl-12">
  141. <div class="card mb-4">
  142. <div class="card-header">
  143. <i class="fa fa-plus mr-1"></i>
  144. @if(isset($recipe))
  145. {{__('label.edit')}} {!! $recipe->name !!}
  146. @else
  147. {{__('label.new_item')}}
  148. @endif
  149. </div>
  150. <div class="card-body">
  151. <form id="restaurant-form" method="POST" action="{!! env('APP_URL') !!}recipe/save" enctype="multipart/form-data">
  152. @csrf
  153. <input type="hidden" name="id" value="{!! isset($recipe)?$recipe->id:'' !!}" />
  154. <input type="hidden" name="business_type" value="{!! $business_type !!}">
  155. <div class="row mb-4 main-cover-image">
  156. <div class="col-sm-12">
  157. <p style="font-size: 14px">{{__('label.cover_image')}}</p>
  158. <div id="image-preview" class="ratio ratio-16x9" @if(isset($recipe) && isset($recipe->main_images) && !empty($recipe->main_images->file_name)) style="background: url({!! $recipe->main_images->file_name !!})" @endif>
  159. <label for="image-upload" id="image-label">{{__('label.choose_file')}}</label>
  160. <input type="file" name="main_image" id="image-upload" />
  161. </div>
  162. @if(isset($recipe) && isset($recipe->main_images) && !empty($recipe->main_images->file_name))
  163. <a href="#!" class="text-center text-danger remove-image" data-recipe-id="{!! isset($recipe)?$recipe->id:'' !!}">{{__('label.remove_image')}}</a>
  164. @endif
  165. <p class="text-warning mt-2">* image size 1920 X 1280 pixels , size 2.4 Mb</p>
  166. </div>
  167. </div>
  168. <div class="row">
  169. <div class="col-sm-4 col-md-6">
  170. <div class="form-group">
  171. <label>{{__('label.english_name')}}</label>
  172. <input type="text" class="form-control" placeholder="" name="name" value="{!! isset($recipe)?$recipe->name:'' !!}" required>
  173. </div>
  174. </div>
  175. </div>
  176. <div class="row">
  177. <div class="col-sm-4 col-md-6">
  178. <div class="form-group">
  179. <label>{{__('label.arabic_name')}}</label>
  180. <input type="text" style="direction: rtl" class="form-control" placeholder="" name="arabic_name" value="{!! isset($recipe)?$recipe->arabic_name:'' !!}" required>
  181. </div>
  182. </div>
  183. </div>
  184. @php
  185. $c = [];
  186. if(isset($recipe)){
  187. $c = $recipe->categories->pluck('category_id')->toArray();
  188. // dump($c);
  189. }
  190. @endphp
  191. <div class="row">
  192. <div class="col-sm-4 col-md-6">
  193. <div class="form-group">
  194. <label>{{__('label.category')}}</label>
  195. <select class="custom-select" name="category[]" multiple>
  196. <option value="">{{__('label.select_category')}}</option>
  197. @if(isset($categories) && $categories->count() > 0)
  198. @foreach($categories as $category)
  199. <option value="{!! $category->id !!}" @if(isset($recipe) && in_array($category->id,$c)) selected @endif>{!! $category->name !!}</option>
  200. @endforeach
  201. @endif
  202. </select>
  203. </div>
  204. </div>
  205. </div>
  206. <div class="row">
  207. <div class="col-sm-4 col-md-4">
  208. <div class="form-group">
  209. <label>{{__('label.price')}}</label>
  210. <input type="number" class="form-control" placeholder="" name="price" value="{!! isset($recipe)?$recipe->price:'' !!}" required>
  211. </div>
  212. </div>
  213. <div class="col-sm-4 col-md-4" style="margin-top:2.2rem">
  214. <div class="form-group">
  215. <label style="visibility: hidden;">Price</label>
  216. @if(isset($recipe))
  217. <input type="checkbox" id="basic_checkbox_2" class="filled-in" name="show_recipe_main_price" @if($recipe->show_recipe_main_price==1) checked @endif>
  218. <label for="basic_checkbox_2">{{__('label.show_item_price')}}</label>
  219. @else
  220. <input type="checkbox" id="basic_checkbox_2" class="filled-in" name="show_recipe_main_price">
  221. <label for="basic_checkbox_2">{{__('label.show_item_price')}}</label>
  222. @endif
  223. </div>
  224. </div>
  225. </div>
  226. <div class="row">
  227. <div class="col-sm-4 col-md-6">
  228. <div class="form-group">
  229. <label>{{__('label.english_description')}}</label>
  230. <textarea class="form-control" placeholder="" name="short_description">{!! isset($recipe)?$recipe->short_description:'' !!}</textarea>
  231. </div>
  232. </div>
  233. </div>
  234. <div class="row">
  235. <div class="col-sm-4 col-md-6">
  236. <div class="form-group">
  237. <label>{{__('label.arabic_description')}}</label>
  238. <textarea class="form-control" style="direction: rtl" placeholder="" name="short_description_arabic">{!! isset($recipe)?$recipe->short_description_arabic:'' !!}</textarea>
  239. </div>
  240. </div>
  241. </div>
  242. @if($business_type=="ClothsStore")
  243. @php
  244. $sizes = [];
  245. $colors = [];
  246. $color_data = null;
  247. if(isset($recipe)){
  248. $colors = \App\Models\ClothOptions::where('product_id',$recipe->id)->where('type','color')->pluck('name')->whereNull('deleted_at')->toArray();
  249. //dump($colors);
  250. $sizes = \App\Models\ClothOptions::where('product_id',$recipe->id)->where('type','size')->pluck('name')->toArray();
  251. $color_data = \App\Models\ClothOptions::where('product_id',$recipe->id)->whereIn('type',['color','color_image'])->whereNull('deleted_at')->get();
  252. }
  253. @endphp
  254. @endif
  255. <div class="row">
  256. <div class="col-sm-4 col-md-6">
  257. <div class="form-group">
  258. <label>{{__('label.gallery')}}</label>
  259. </div>
  260. @if(isset($recipe) && isset($recipe->galleries))
  261. <div class="row mb-2">
  262. @foreach($recipe->galleries as $gallery)
  263. <div class="col-sm-2 gallery">
  264. <div class="mb-1" style="width: 100px; height: 100px; background-image: url({!! $gallery->file_name !!}); background-position: center; background-size: contain">
  265. </div>
  266. <div class="text-center">
  267. <a href="#!" class="delete-image text-danger" data-id="{!! $gallery->id !!}"><i class="glyphicon glyphicon-trash"></i> </a>
  268. </div>
  269. </div>
  270. @endforeach
  271. </div>
  272. @endif
  273. </div>
  274. </div>
  275. {{-- @if($business_type!="ClothsStore")--}}
  276. @if(1)
  277. @if(isset($recipe->extra_options) && $recipe->extra_options->count() > 0)
  278. <h3>{{__('label.extra_options')}}</h3>
  279. <hr />
  280. <div class="row">
  281. <div class="col-sm-6 col-md-8">
  282. <table class="table table-bordered">
  283. <thead>
  284. <tr>
  285. <th>{{__('label.option_name')}}</th>
  286. <th>{{__('label.price')}}Price</th>
  287. <th>{{__('label.items')}}</th>
  288. <th>{{__('label.is_mandatory')}}?</th>
  289. <th></th>
  290. </tr>
  291. </thead>
  292. <tbody>
  293. @foreach($recipe->extra_options as $option)
  294. <tr>
  295. <td>{!! $option->name !!} @if($option->name_arabic!="") ( {!! $option->name_arabic !!} ) @endif</td>
  296. <td>{!! $option->price !!}</td>
  297. <td>
  298. @if(isset($option->extra_option_items) && $option->extra_option_items->count() > 0)
  299. <a href="#!" class="badge badge-success view-items" data-id="{!! $option->id !!}" >{!! $option->extra_option_items->count() !!}</a>
  300. @endif
  301. <a href="#!" class="badge badge-danger add-new-items" data-id="{!! $option->id !!}"><i class="glyphicon glyphicon-plus"></i> </a>
  302. </td>
  303. <td>
  304. @if(isset($option->extra_option_items) && $option->extra_option_items->count() > 0)
  305. <!-- <input type="checkbox" class="is_mandatory" @if($option->is_mandatory==1) checked @endif value="" data-id="{!! $option->id !!}" /> -->
  306. <input type="checkbox" id="is_mandatory{!! $option->id !!}" class="filled-in is_mandatory" name="is_mandatory" @if($option->is_mandatory==1) checked @endif value="" data-id="{!! $option->id !!}">
  307. <label for="is_mandatory{!! $option->id !!}">Mandatory Items</label>
  308. @if($option->is_mandatory==1) User can select <span class="badge badge-success">{!! $option->mandatory_amount !!}</span> items must @endif
  309. @endif
  310. </td>
  311. <td>
  312. <a href="#!" class="btn btn-sm btn-primary edit-option" data-id="{!! $option->id !!}" data-toggle="tooltip" data-placement="top" title="Edit"><i class="glyphicon glyphicon-edit"></i> </a>
  313. <a href="javascript:;" data-id="{!! $option->id !!}" class="btn btn-sm btn-danger delete-option"><i class="glyphicon glyphicon-trash" data-toggle="tooltip" data-placement="top" title="Delete"></i></a>
  314. </td>
  315. </tr>
  316. @endforeach
  317. </tbody>
  318. </table>
  319. </div>
  320. </div>
  321. @endif
  322. @endif
  323. @if(isset($recipe))
  324. <div class="row mb-5">
  325. <div class="col-sm-8">
  326. <div class="card">
  327. <div class="card-header">
  328. <h3 class="pull-left">{{__('label.variations')}}</h3>
  329. </div>
  330. <div class="card-body table-responsive">
  331. @if(isset($recipe->variations) && $recipe->variations->count() > 0)
  332. @php
  333. $v = (json_decode($recipe->variations[0]->variations));
  334. $exclude_columns = ['variant_type'];
  335. $thead = [];
  336. if(isset($v)){
  337. foreach($v as $k=>$value){
  338. if(!in_array($k,$exclude_columns))
  339. $thead[$k] = ucwords(str_replace('_',' ',$k));
  340. }
  341. if(!in_array('image',$thead))
  342. $thead['image'] = 'Image';
  343. }
  344. @endphp
  345. <table class="table table-striped" id="accordionExample">
  346. <thead>
  347. <tr>
  348. @if(isset($thead))
  349. @foreach($thead as $k=>$value)
  350. <th>{!! $value !!}</th>
  351. @endforeach
  352. @endif
  353. <th></th>
  354. </tr>
  355. </thead>
  356. <tbody>
  357. @foreach($recipe->variations as $variant)
  358. <tr>
  359. @php
  360. $variants = (json_decode($variant->variations));
  361. $is_image = "No";
  362. @endphp
  363. @if(isset($variants))
  364. @foreach($variants as $k=>$value)
  365. @if(!in_array($k,$exclude_columns))
  366. @if($k=="image")
  367. @php
  368. $is_image = "Yes";
  369. @endphp
  370. <td><div style="width:50px; height: 50px; background-size: cover; background-position: center; background-image: url({!! $value !!})"></div></td>
  371. @else
  372. @if($k=="color")
  373. <td><div style="width: 20px; height: 20px; background-color: {!! $value !!}; float: left; border-radius: 20px;"></div> </td>
  374. @else
  375. <td>{!! $value !!}</td>
  376. @endif
  377. @endif
  378. @endif
  379. @endforeach
  380. @if($is_image=="No")
  381. <td></td>
  382. @endif
  383. <td>
  384. <a href="javascript:;" data-id="{!! $variant->id !!}" class="btn btn-sm btn-primary edit-variation"><i class="glyphicon glyphicon-pencil"></i></a>
  385. <a href="javascript:;" data-id="{!! $variant->id !!}" class="btn btn-sm btn-danger delete-variation"><i class="glyphicon glyphicon-trash"></i></a>
  386. </td>
  387. @endif
  388. </tr>
  389. @endforeach
  390. </tbody>
  391. </table>
  392. @endif
  393. </div>
  394. </div>
  395. </div>
  396. </div>
  397. @endif
  398. @if(isset($recipe))
  399. @if(isset($resto_metas['ENABLED_PRODUCT_FAQS']) && $resto_metas['ENABLED_PRODUCT_FAQS']=="Yes")
  400. <div class="row mb-5">
  401. <div class="col-sm-8">
  402. <div class="card">
  403. <div class="card-header">
  404. <h3 class="pull-left">{{__('label.product_faqs')}}</h3>
  405. <a href="#!" class="btn btn-sm btn-primary pull-right add-faq">{{__('label.add_faq')}}</a>
  406. </div>
  407. <div class="card-body">
  408. @if(isset($recipe->product_faqs) && $recipe->product_faqs->count() > 0)
  409. <div class="accordion" id="accordionExample">
  410. @foreach($recipe->product_faqs as $faq)
  411. <div class="accordion-item">
  412. <h2 class="accordion-header" id="heading{!! $faq->id !!}">
  413. <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse{!! $faq->id !!}" aria-expanded="true" aria-controls="collapse{!! $faq->id !!}">
  414. {!! $faq->question !!}
  415. </button>
  416. </h2>
  417. <div id="collapse{!! $faq->id !!}" class="accordion-collapse collapse" aria-labelledby="heading{!! $faq->id !!}" data-bs-parent="#accordionExample">
  418. <div class="accordion-body">
  419. <p>{!! nl2br($faq->answer) !!}</p>
  420. <div class="text-end">
  421. <a href="javascript:void(0)" data-id="{!! $faq->id !!}" class="edit-faq" style="margin: 0 3px 0 10px"><i class="glyphicon glyphicon-edit"></i></a>
  422. |
  423. <a href="javascript:void(0)" data-id="{!! $faq->id !!}" class="delete-faq" style="color:red"><i class="glyphicon glyphicon-trash"></i></a>
  424. </div>
  425. </div>
  426. </div>
  427. </div>
  428. @endforeach
  429. </div>
  430. @endif
  431. </div>
  432. </div>
  433. </div>
  434. </div>
  435. @endif
  436. @endif
  437. <div class="row">
  438. <div class="col-sm-4 col-md-6">
  439. {{-- @if($business_type!="ClothsStore")--}}
  440. @if(1)
  441. <div class="form-group">
  442. <div class="custom-control custom-checkbox">
  443. <input class="custom-control-input" id="is_customized" @if(isset($recipe) && $recipe->is_customized=="1") checked @endif name="is_customized" type="checkbox" />
  444. <label class="custom-control-label" for="is_customized">{{__('label.customizedable')}}</label>
  445. </div>
  446. </div>
  447. @endif
  448. <div class="form-group">
  449. <div class="custom-control custom-checkbox">
  450. <input class="custom-control-input" id="status" @if(isset($recipe) && $recipe->status=="1") checked @endif name="status" type="checkbox" />
  451. <label class="custom-control-label" for="status">{{__('label.active')}}?</label>
  452. </div>
  453. </div>
  454. @if($allow_pre_order=="Yes")
  455. <div class="form-group">
  456. <div class="custom-control custom-checkbox">
  457. <input class="custom-control-input" id="allow_pre_order" @if(isset($recipe) && $recipe->allow_pre_order=="Yes") checked @endif name="allow_pre_order" type="checkbox" />
  458. <label class="custom-control-label" for="allow_pre_order">{{__('label.allow_pre_order')}}?</label>
  459. </div>
  460. </div>
  461. @endif
  462. </div>
  463. </div>
  464. <div class="row">
  465. <div class="col-sm-12">
  466. <a href="#!" class="btn btn-primary save">{{__('label.save')}}</a>
  467. @if( isset($recipe))
  468. <a href="#!" class="btn btn-primary upload-gallery">{{__('label.upload_gallery')}}</a>
  469. @if($business_type!="ClothsStore" )
  470. <a href="#!" class="btn btn-primary add-options">{{__('label.add_extra_options')}}</a>
  471. @endif
  472. <a href="#!" class="btn btn-primary add-variations">{{__('label.add_variations')}}</a>
  473. @endif
  474. </div>
  475. </div>
  476. <div class="row mt-2">
  477. <div class="col-md-12">
  478. <div class="alert alert-success success"></div>
  479. <div class="alert alert-danger error"></div>
  480. </div>
  481. </div>
  482. </form>
  483. </div>
  484. </div>
  485. </div>
  486. </div>
  487. </section>
  488. </div>
  489. </div>
  490. @if( isset($recipe))
  491. <div class="modal" id="upload-gallery" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  492. <div class="modal-dialog">
  493. <div class="modal-content">
  494. <div class="modal-header">
  495. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.recipe_gallery')}}</h5>
  496. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  497. </div>
  498. <div class="modal-body">
  499. <div class="row">
  500. <div class="col-sm-12 col-md-12">
  501. <div class="form-group">
  502. <label>Gallery</label>
  503. <div class="dropzone dz-clickable" id="gallery">
  504. <div class="dz-default dz-message" data-dz-message="">
  505. <span>{{__('label.drop_files_here_to_upload')}} <br>
  506. <b>(accepted file formats .jpg,.png,.jpeg case sensitive)</b> </span>
  507. </div>
  508. </div>
  509. </div>
  510. </div>
  511. </div>
  512. </div>
  513. <div class="modal-footer">
  514. <button type="button" class="btn btn-primary upload">{{__('label.upload')}}</button>
  515. <button type="button" class="btn btn-secondary" data-dismiss="modal">{{__('label.close')}}</button>
  516. </div>
  517. </div>
  518. </div>
  519. </div>
  520. <div class="modal" id="extra-options" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  521. <div class="modal-dialog modal-lg">
  522. <div class="modal-content">
  523. <div class="modal-header">
  524. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.add_extra_options')}}</h5>
  525. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  526. </div>
  527. <div class="modal-body">
  528. <form id="extra-options-form" method="POST" action="{!! env('APP_URL') !!}save/extra/options">
  529. @csrf
  530. <input type="hidden" name="recipe_id" value="{!! $recipe->id !!}" />
  531. <input type="hidden" name="resto_id" value="{!! $recipe->resto_id !!}" />
  532. <div class="row">
  533. <div class="col-sm-4">
  534. <b>{{__('label.english_name')}}: </b>
  535. <input class="form-control" name="option" placeholder="Name of option" required />
  536. </div>
  537. <div class="col-sm-4">
  538. <b>{{__('label.name_arabic')}}: </b>
  539. <input class="form-control" name="arabic_option" placeholder="Name of option in arabic" required />
  540. </div>
  541. <div class="col-sm-3">
  542. <b>{{__('label.price')}} : </b>
  543. <input class="form-control" name="price" placeholder="Price if it has" />
  544. </div>
  545. </div>
  546. <div class="row">
  547. <div class="col-sm-12 text-right"><a href="#!" class="btn btn-sm btn-danger mt-1 add-extra-items">{{__('label.add_extra_item')}}</a> </div>
  548. </div>
  549. <div id="items-list">
  550. </div>
  551. </form>
  552. </div>
  553. <div class="modal-footer">
  554. <button type="button" class="btn btn-primary save-extra-options">{{__('label.add')}}</button>
  555. <button type="button" class="btn btn-secondary" data-dismiss="modal">{{__('label.close')}}</button>
  556. </div>
  557. </div>
  558. </div>
  559. </div>
  560. <div class="modal" id="edit-extra-option" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  561. <div class="modal-dialog modal-sm">
  562. <div class="modal-content">
  563. <div class="modal-header">
  564. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.edit_option')}}</h5>
  565. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  566. </div>
  567. <div class="modal-body">
  568. <form method="POST" action="{!! env('APP_URL') !!}update/option" id="edit-form">
  569. <input type="hidden" name="id" />
  570. @csrf
  571. <div class="row">
  572. <div class="col-sm-12">
  573. <b>{{__('label.english_name')}} </b>
  574. <input class="form-control" name="option" placeholder="Name of option" required />
  575. </div>
  576. </div>
  577. <div class="row">
  578. <div class="col-sm-12">
  579. <b>{{__('label.name_arabic')}}</b>
  580. <input class="form-control" name="arabic_option" placeholder="Name of option in arabic" />
  581. </div>
  582. </div>
  583. <div class="row">
  584. <div class="col-sm-12">
  585. <b>{{__('label.price')}} </b>
  586. <input class="form-control" name="price" placeholder="Price" />
  587. </div>
  588. </div>
  589. <div class="row">
  590. <div class="col-sm-12">
  591. <br>
  592. <b></b>
  593. <a href="#!" style="margin-top: 2px" class="btn btn-primary update-option">{{__('label.save')}} <i class="fa fa-save"></i> </a>
  594. </div>
  595. </div>
  596. <div class="row mt-2">
  597. <div class="col-md-12">
  598. <div class="alert alert-success success"></div>
  599. <div class="alert alert-danger error"></div>
  600. </div>
  601. </div>
  602. </form>
  603. </div>
  604. <!--
  605. <div class="modal-footer">
  606. <button type="button" class="btn btn-primary save-extra-options">Add</button>
  607. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  608. </div>
  609. -->
  610. </div>
  611. </div>
  612. </div>
  613. <div class="modal" id="extra-option-item" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  614. <div class="modal-dialog modal-lg">
  615. <div class="modal-content">
  616. <div class="modal-header">
  617. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.customized_items_list')}}</h5>
  618. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  619. </div>
  620. <div class="modal-body">
  621. <table class="table table-bordered" id="item-table">
  622. <thead>
  623. <tr>
  624. <th>{{__('label.name')}}</th>
  625. <th>{{__('label.name_arabic')}}</th>
  626. <th>{{__('label.price')}}</th>
  627. <th>{{__('label.iItem_type')}}</th>
  628. <th>{{__('label.customized_sub_items_list')}}</th>
  629. <th></th>
  630. </tr>
  631. </thead>
  632. <tbody>
  633. </tbody>
  634. </table>
  635. </div>
  636. </div>
  637. </div>
  638. </div>
  639. <div class="modal" id="edit-extra-item-option" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  640. <div class="modal-dialog modal-lg">
  641. <div class="modal-content">
  642. <div class="modal-header">
  643. <h5 class="modal-title" id="staticBackdropLabel"><b>{{__('label.edit_item')}}</b> </h5>
  644. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  645. </div>
  646. <div class="modal-body modal-lg">
  647. <form method="POST" action="{!! env('APP_URL') !!}update/item" id="edit-item-form">
  648. <input type="hidden" name="id" />
  649. @csrf
  650. <div class="row">
  651. <div class="col-sm-12">
  652. <b>{{__('label.english_name')}}: </b>
  653. <input class="form-control" name="option" placeholder="Name of Item" required />
  654. </div>
  655. </div>
  656. <div class="row">
  657. <div class="col-sm-12">
  658. <b><br>{{__('label.name_arabic')}}: </b>
  659. <input class="form-control" name="name_arabic" placeholder="Name of option in arabic" required />
  660. <br>
  661. </div>
  662. </div>
  663. <div class="row">
  664. <div class="col-sm-12">
  665. <b>{{__('label.price')}}: </b>
  666. <input class="form-control" name="price" placeholder="Price" />
  667. </div>
  668. </div>
  669. <div class="row">
  670. <div class="col-sm-12">
  671. <br><select class="form-control" name="item_type">
  672. <option value="">{{__('label.choose_button_type')}}</option>
  673. <option value="option">{{__('label.option_button')}}</option>
  674. <option value="check-box">{{__('label.checkbox')}}</option>
  675. </select>
  676. </div>
  677. <br>
  678. </div>
  679. <div class="row">
  680. <div class="col-sm-12">
  681. <br><a href="#!" style="margin-top: 2px" class="btn btn-primary update-item">{{__('label.save')}} <i class="fa fa-save"></i> </a>
  682. </div><br>
  683. </div>
  684. <div class="row mt-2">
  685. <div class="col-md-12">
  686. <div class="alert alert-success success"></div>
  687. <div class="alert alert-danger error"></div>
  688. </div>
  689. </div>
  690. </form>
  691. </div>
  692. </div>
  693. </div>
  694. </div>
  695. <div class="modal" id="mandatory-extra-item-option" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  696. <div class="modal-dialog">
  697. <div class="modal-content">
  698. <div class="modal-header">
  699. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.make_mandatory_options')}}</h5>
  700. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  701. </div>
  702. <div class="modal-body">
  703. <form method="POST" action="{!! env('APP_URL') !!}update/mandatory/item" id="mandatory-item-form">
  704. <input type="hidden" name="id" />
  705. @csrf
  706. <div class="row">
  707. <div class="col-sm-10">
  708. <input class="form-control" type="number" name="mandatory_amount" placeholder="Enter quantity of items" required />
  709. </div>
  710. <div class="col-sm-1">
  711. <a href="#!" style="margin-top: 2px" class="btn btn-sm btn-success make-mandatory-item"><i class="fa fa-save"></i> </a>
  712. </div>
  713. </div>
  714. <div class="row mt-2">
  715. <div class="col-md-12">
  716. <div class="alert alert-success success"></div>
  717. <div class="alert alert-danger error"></div>
  718. </div>
  719. </div>
  720. </form>
  721. </div>
  722. </div>
  723. </div>
  724. </div>
  725. <div class="modal" id="add-new-items" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  726. <div class="modal-dialog modal-lg">
  727. <div class="modal-content">
  728. <div class="modal-header">
  729. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.add_more_items')}}</h5>
  730. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  731. </div>
  732. <div class="modal-body">
  733. <form id="extra-items-form" method="POST" action="{!! env('APP_URL') !!}save/add/items">
  734. @csrf
  735. <input type="hidden" name="extra_option_id"/>
  736. <input type="hidden" name="parent_id" />
  737. <div class="row">
  738. <div class="col-sm-12 text-right"><a href="#!" class="btn btn-sm btn-danger mt-1 add-extra-items-2">{{__('label.add_extra_item')}}</a> </div>
  739. </div>
  740. <div id="items-list-2">
  741. <div class="row" style="margin-top: 10px">
  742. <div class="col-sm-3">
  743. <input class="form-control" name="item_name[]" placeholder="Name of item">
  744. </div>
  745. <div class="col-sm-3">
  746. <input class="form-control" name="item_name_arabic[]" placeholder="Name of item in Arabic">
  747. </div>
  748. <div class="col-sm-3">
  749. <select class="form-control" name="item_type[]"><option value="option">{{__('label.option_button')}}</option><option value="check-box">{{__('label.checkbox')}}</option> </select>
  750. </div>
  751. <div class="col-sm-2">
  752. <input class="form-control" name="item_price[]" placeholder="Price if it has">
  753. </div>
  754. </div>
  755. </div>
  756. </form>
  757. </div>
  758. <div class="modal-footer">
  759. <button type="button" class="btn btn-primary save-extra-items">{{__('label.add_items')}}</button>
  760. <button type="button" class="btn btn-secondary" data-dismiss="modal">{{__('label.close')}}</button>
  761. </div>
  762. </div>
  763. </div>
  764. </div>
  765. <div class="modal" id="add-new-faq" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  766. <div class="modal-dialog">
  767. <div class="modal-content">
  768. <div class="modal-header">
  769. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.add_faq')}}</h5>
  770. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  771. </div>
  772. <div class="modal-body">
  773. <form id="faq-form" method="POST" action="{!! env('APP_URL') !!}save/faq">
  774. @csrf
  775. <input type="hidden" name="id" />
  776. <input type="hidden" name="product_id" value="{!! $recipe->id !!}" />
  777. <div class="form-group">
  778. <label>{{__('label.question')}}</label>
  779. <!-- <input type="text" name="question" required class="form-control" />-->
  780. <textarea row="2" style="height: 200px !important" name="question" required class="form-control"></textarea>
  781. </div>
  782. <div class="form-group">
  783. <label>{{__('label.answer')}}</label>
  784. <textarea row="4" style="height: 200px !important" name="answer" required class="form-control"></textarea>
  785. </div>
  786. </form>
  787. </div>
  788. <div class="modal-footer">
  789. <button type="button" class="btn btn-primary save-faq">{{__('label.add')}}</button>
  790. <button type="button" class="btn btn-secondary" data-dismiss="modal">{{__('label.close')}}</button>
  791. </div>
  792. </div>
  793. </div>
  794. </div>
  795. <div class="modal" id="add-variations" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  796. <div class="modal-dialog">
  797. <div class="modal-content">
  798. <div class="modal-header">
  799. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.variations')}}</h5>
  800. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  801. </div>
  802. <div class="modal-body">
  803. <form id="variation-form" method="POST" action="{!! env('APP_URL') !!}save/variations">
  804. @csrf
  805. <input type="hidden" name="id" />
  806. <input type="hidden" name="product_id" value="{!! $recipe->id !!}" />
  807. <div class="row">
  808. <div class="col-sm-12">
  809. <div class="form-group">
  810. <label>Product Variations</label>
  811. <select id="variant_type" name="variant_type[]" multiple class="form-control">
  812. @if(isset($variant_types) && $variant_types->count() > 0)
  813. @foreach($variant_types as $variant_type)
  814. <option value="{!! $variant_type->id !!}">{!! $variant_type->name !!}</option>
  815. @endforeach
  816. @endif
  817. </select>
  818. </div>
  819. </div>
  820. <div class="col-sm-12 text-end">
  821. <a href="#!" class="btn btn-sm btn-primary add-more-variations">New Variation Type</a>
  822. </div>
  823. </div>
  824. <div class="row">
  825. <div class="col-sm-12" id="variation-table">
  826. </div>
  827. </div>
  828. </form>
  829. <div class="row mt-2">
  830. <div class="col-md-12">
  831. <div class="alert alert-success success"></div>
  832. <div class="alert alert-danger error"></div>
  833. </div>
  834. </div>
  835. </div>
  836. <div class="modal-footer text-end">
  837. <button type="button" class="btn btn-primary save-variations">{{__('label.save_variations')}}</button>
  838. <button type="button" class="btn btn-secondary" data-dismiss="modal">{{__('label.close')}}</button>
  839. </div>
  840. </div>
  841. </div>
  842. </div>
  843. @endif
  844. @endsection
  845. @section('js')
  846. <script src="{!! env('APP_ASSETS') !!}vendor_components/dropzone/dist/min/dropzone.min.js"></script>
  847. <script src="{!! env('APP_ASSETS') !!}vendor_components/select2/dist/js/select2.min.js"></script>
  848. <script src="{!! env('APP_ASSETS') !!}vendor_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
  849. <script>
  850. var spinner = '<span class="spinner-border" role="status" aria-hidden="true"></span>';
  851. Dropzone.autoDiscover = false;
  852. var extra_option_id = 0;
  853. var _image_is_required = "required";
  854. var color_option = "color";
  855. var _selectBoxes = [];
  856. color_option=$("select[name=color_option]").val();
  857. $(function () {
  858. $("body").on("click",".add-variations",function(){
  859. $("#add-variations").modal('show');
  860. });
  861. $("body").on("click",".edit-variation",function(){
  862. var _id = $(this).data('id');
  863. $("#variation-form input[name=id]").val(_id);
  864. $.ajax({
  865. url:"{!! env('APP_URL') !!}get/variation/"+_id,
  866. success:function(response){
  867. $("#variant_type").select2().val(response.variation_type).trigger('change');
  868. var variations = (response.variations);
  869. setTimeout(function(){
  870. $("#variation-table table tr td").each(function(i,v){
  871. console.log("td");
  872. var _select_name = ($(v).find("select").attr('name'));
  873. var _input_name = ($(v).find("input").attr('name'));
  874. if(_select_name){
  875. _select_name = _select_name.replace('[]','');
  876. $("."+_select_name).select2().val(variations[_select_name]).trigger('change');
  877. //console.log("data: "+variations[_select_name]);
  878. }
  879. if(_input_name){
  880. _input_name = _input_name.replace('[]','');
  881. $("."+_input_name).val(variations[_input_name]);
  882. //console.log("data: "+variations[_input_name]);
  883. }
  884. });
  885. $(".add-more-variant").hide();
  886. },500);
  887. }
  888. });
  889. $("#add-variations").modal('show');
  890. });
  891. $("body").on("click",".delete-variation",function(){
  892. var _id = $(this).data('id');
  893. var _this = $(this);
  894. swal({
  895. title: " Confirm?",
  896. text: "Do you want delete?",
  897. type: "error",
  898. showCancelButton: true,
  899. confirmButtonClass: "btn-danger",
  900. confirmButtonText: " Confirm, delete it!",
  901. cancelButtonText: "No, cancel please!",
  902. closeOnConfirm: true,
  903. closeOnCancel: true
  904. },
  905. function(isConfirm) {
  906. if (isConfirm) {
  907. $.ajax({
  908. url:"{!! env('APP_URL') !!}delete/variation/"+_id,
  909. success:function (response) {
  910. _this.parents('tr').remove();
  911. }
  912. });
  913. }
  914. });
  915. });
  916. $("body").on("click",".save-variations",function(){
  917. var _this = $(this);
  918. if($("#variation-form").valid()){
  919. _this.attr('disabled','disabled');
  920. _this.html(progress_img);
  921. _this.removeClass('btn-primary');
  922. _this.addClass('btn-muted');
  923. $("#variation-form").ajaxForm(function(response){
  924. if(response.type=="success"){
  925. $("#add-variations .success").html(response.message);
  926. $("#add-variations .success").show();
  927. setTimeout(function(){
  928. location.reload();
  929. },1500);
  930. }
  931. }).submit();
  932. }
  933. });
  934. $("body").on("click",".add-more-variant",function(){
  935. console.log(_selectBoxes.length);
  936. var _tr = "<tr>";
  937. $(_selectBoxes).each(function(i,v){
  938. if(v.attributes){
  939. _tr+="<td class='dynamic-column'>";
  940. var _className=v.name.toLowerCase().replaceAll(' ','_');
  941. var _select = "<select required class='form-control "+_className+"' name='"+v.name.toLowerCase().replaceAll(' ','_')+"[]'>";
  942. $(v.attributes).each(function(m,n){
  943. if(v.name=="Color")
  944. _select+="<option value='"+n.attribute_code+"'>"+n.attribute_name+"</option>";
  945. else
  946. _select+="<option value='"+n.attribute_name+"'>"+n.attribute_name+"</option>";
  947. });
  948. _select+="</select>";
  949. _tr+=_select;
  950. _tr+="</td>";
  951. }
  952. });
  953. _tr+="<td><input type='number' class='form-control variation_price' required name='variation_price[]'> </td>";
  954. _tr+="<td><input type='number' class='form-control variation_quantity' required name='variation_quantity[]'> </td>";
  955. _tr+="<td><input type='number' class='form-control stock_alert' name='stock_alert[]'> </td>";
  956. _tr+="<td><input type='file' class='form-control' name='image[]'> </td>";
  957. _tr+="</tr>";
  958. $("#variation-table table tbody").append(_tr);
  959. $("#variation-table select").select2();
  960. $(".color").select2({
  961. data: colors,
  962. dropdownAutoWidth : true,
  963. templateResult: color_template,
  964. escapeMarkup: function(m) {
  965. return m;
  966. }
  967. });
  968. });
  969. $("#variant_type").select2().on('change',function(){
  970. var _value = $(this).val();
  971. $.ajax({
  972. url:"{!! env('APP_URL') !!}get/variation/attributes",
  973. type:"POST",
  974. data:{
  975. variations:_value,
  976. "_token":"{!! csrf_token() !!}"
  977. },
  978. success:function(response){
  979. _selectBoxes = [];
  980. //#variation-table
  981. var _table = "<table class='table table-bordered'>";
  982. var _thead="<thead>";
  983. var _tr = "<tr>";
  984. var _tr_length = 1;
  985. $(response).each(function(i,v){
  986. _tr+="<th>"+v.name+"</th>";
  987. _tr_length++;
  988. });
  989. _tr+="<th>Price</th><th>Quantity</th><th>Stock Alert</th><th>Image</th>";
  990. _tr+="</tr>";
  991. _thead+=_tr;
  992. _thead+="</thead>";
  993. _tr_length = _tr_length+4;
  994. //DATA ROWS
  995. var _tbody = "<tbody>";
  996. var _tr = "<tr>";
  997. $(response).each(function(i,v){
  998. if(v.attributes){
  999. _selectBoxes.push(v);
  1000. _tr+="<td class='dynamic-column'>";
  1001. var _className=v.name.toLowerCase().replaceAll(' ','_');
  1002. var _select = "<select required class='form-control "+_className+"' name='"+v.name.toLowerCase().replaceAll(' ','_')+"[]'>";
  1003. $(v.attributes).each(function(m,n){
  1004. if(v.name=="Color")
  1005. _select+="<option value='"+n.attribute_code+"'>"+n.attribute_name+"</option>";
  1006. else
  1007. _select+="<option value='"+n.attribute_name+"'>"+n.attribute_name+"</option>";
  1008. });
  1009. _select+="</select>";
  1010. _tr+=_select;
  1011. _tr+="</td>";
  1012. }
  1013. });
  1014. _tr+="<td><input type='number' class='form-control variation_price' required name='variation_price[]'> </td>";
  1015. _tr+="<td><input type='number' class='form-control variation_quantity' required name='variation_quantity[]'> </td>";
  1016. _tr+="<td><input type='number' class='form-control stock_alert' name='stock_alert[]'> </td>";
  1017. _tr+="<td><input type='file' class='form-control' name='image[]'> </td>";
  1018. _tr+="</tr>";
  1019. _tbody+=_tr;
  1020. _tbody+="</tbody>";
  1021. _table+=_thead;
  1022. _table+=_tbody;
  1023. var _tfoot="<tfoot><tr><td style='text-align: right' colspan='"+_tr_length+"'>";
  1024. _tfoot+='<a href="#!" class="btn btn-sm btn-primary add-more-variant">Add More</a>';
  1025. _tfoot+="</td></tr></tfoot>"
  1026. _table+=_tfoot;
  1027. _table+="</table>";
  1028. $("#variation-table").html(_table);
  1029. $("#variation-table select").select2();
  1030. $(".color").select2({
  1031. data: colors,
  1032. dropdownAutoWidth : true,
  1033. templateResult: color_template,
  1034. escapeMarkup: function(m) {
  1035. return m;
  1036. }
  1037. });
  1038. }
  1039. });
  1040. });;
  1041. @if(isset($recipe))
  1042. $("body").on("change","select[name=color_option]",function(){
  1043. var _existing = "{!! $recipe->color_option !!}";
  1044. var _this_value = $(this).val();
  1045. if(_existing!=_this_value){
  1046. alert("{{__('label.color_setting_will_be_reset')}}");
  1047. }
  1048. color_option = _this_value;
  1049. if(_this_value=="color_image"){
  1050. _image_is_required = "required";
  1051. }else{
  1052. _image_is_required = "";
  1053. $(".color-image-file").remove();
  1054. }
  1055. });
  1056. @endif
  1057. $("body").on("click",".delete-color",function(){
  1058. var _id = $(this).data('id');
  1059. var _this = $(this);
  1060. if(confirm("Do you want to delete?")){
  1061. $.ajax({
  1062. type:"POST",
  1063. url:"{!! env('APP_URL') !!}delete/color-image",
  1064. data:{
  1065. "id":_id,
  1066. "_token":"{!! csrf_token() !!}"
  1067. },
  1068. success:function(){
  1069. _this.parents("tr").remove();
  1070. }
  1071. });
  1072. }
  1073. });
  1074. $("body").on("click",".delete-faq",function(){
  1075. var _id = $(this).data('id');
  1076. //alert(_id);
  1077. var _this = $(this);
  1078. if(confirm("Do you want to delete?")){
  1079. $.ajax({
  1080. type:"POST",
  1081. url:"{!! env('APP_URL') !!}delete/faq",
  1082. data:{
  1083. "id":_id,
  1084. "_token":"{!! csrf_token() !!}"
  1085. },
  1086. success:function(){
  1087. _this.parents(".accordion-item").remove();
  1088. }
  1089. });
  1090. }
  1091. });
  1092. $("body").on("click",".edit-faq",function(){
  1093. var _id = $(this).data('id');
  1094. $("#faq-form input[name=id]").val(_id);
  1095. var _content = $(this).parents(".accordion-body").find('p').text();
  1096. var _question = $(this).parents(".accordion-item").find('.accordion-button').text();
  1097. $("#faq-form textarea[name=question]").val($.trim(_question));
  1098. $("#faq-form textarea[name=answer]").val(_content);
  1099. $("#add-new-faq").modal('show');
  1100. });
  1101. $("body").on("click",".save-faq",function(){
  1102. if($("#faq-form").valid()){
  1103. $("#faq-form").ajaxForm(function(response){
  1104. location.reload();
  1105. }).submit();
  1106. }
  1107. });
  1108. $("body").on("click",".add-faq",function(){
  1109. $("#add-new-faq").modal('show');
  1110. });
  1111. @if($business_type=="ClothsStore")
  1112. var colors = [
  1113. @foreach(\App\Models\Colors::groupBy('color_code')->get() as $color)
  1114. {
  1115. id:"{!! $color->color_code !!}",
  1116. text:"{!! $color->color_name !!}",
  1117. html:'<div class="row" style="margin:0"><div style="width: 20px; height: 20px; background-color: {!! $color->color_code !!}; float: left; border-radius: 20px;"></div><div style="float: right; width: 200px">{!! addslashes($color->color_name) !!}</div></div>',
  1118. },
  1119. @endforeach
  1120. ];
  1121. function color_template(colors) {
  1122. return colors.html;
  1123. }
  1124. function return_color_row(value){
  1125. var str = "";
  1126. $(value).each(function(i,v){
  1127. str += '<tr>';
  1128. str+='<td><div style="width: 20px; height: 20px; background-color: '+v+'; float: left; border-radius: 20px;"></div></td>';
  1129. if(color_option=="color_image")
  1130. str+='<td><input name="color_image['+v+']" type="file" class="form-control color-image-file" required />';
  1131. str+='</tr>';
  1132. });
  1133. return str;
  1134. }
  1135. $("#color").select2({
  1136. data: colors,
  1137. templateResult: color_template,
  1138. escapeMarkup: function(m) {
  1139. return m;
  1140. }
  1141. }).on('change',function(){
  1142. var _value = $(this).val();
  1143. var rows = return_color_row(_value);
  1144. $("#color-table tbody").html(rows);
  1145. });;
  1146. $("#size").select2();
  1147. @endif
  1148. $("body").on("click",".remove-image",function(){
  1149. var id = $(this).data('recipe-id');
  1150. var _this = $(this);
  1151. $.ajax({
  1152. url:"{!! env('APP_URL') !!}remove/recipe/main-image",
  1153. type:"POST",
  1154. data:{
  1155. id:id,
  1156. '_token':"{!! csrf_token() !!}"
  1157. },
  1158. success:function(){
  1159. _this.parents('.main-cover-image').find("#image-preview").removeAttr('style');
  1160. }
  1161. });
  1162. });
  1163. $.uploadPreview({
  1164. input_field: "#image-upload", // Default: .image-upload
  1165. preview_box: "#image-preview", // Default: .image-preview
  1166. label_field: "#image-label", // Default: .image-label
  1167. label_default: "Choose File", // Default: Choose File
  1168. label_selected: "Change File", // Default: Change File
  1169. no_label: true ,
  1170. success_callback: function(e) {
  1171. }// Default: false
  1172. });
  1173. $("#image-upload").on("change",function(e){
  1174. var _current_file = (e.currentTarget.files[0]);
  1175. var filesize = ((_current_file.size/1024)/1024).toFixed(2);
  1176. if(filesize>2.4){
  1177. swal({title:"Image Size error",text:"You are exceeding from 2.4MB maximum size, your file size is "+filesize+" MB"},function(){
  1178. $("#image-preview").removeAttr('style');
  1179. $("#image-upload").val('');
  1180. });
  1181. return false;
  1182. }else{
  1183. var reader = new FileReader();
  1184. reader.readAsDataURL(_current_file);
  1185. reader.onload = function (e) {
  1186. //Initiate the JavaScript Image object.
  1187. var image = new Image();
  1188. //Set the Base64 string return from FileReader as source.
  1189. image.src = e.target.result;
  1190. //Validate the File Height and Width.
  1191. image.onload = function () {
  1192. var height = this.height;
  1193. var width = this.width;
  1194. if (height > 1280 || width > 1980) {
  1195. swal({title:"Image Dimensions error",text:"You are exceeding from dimension limit (1920 x 1280), your current dimensions are width: "+width+"px and height: "+height+"px"},function(){
  1196. $("#image-preview").removeAttr('style');
  1197. $("#image-upload").val('');
  1198. });
  1199. return false;
  1200. }
  1201. };
  1202. }
  1203. }
  1204. });
  1205. $(".custom-select").select2();
  1206. $("body").on("click",".make-mandatory-item",function () {
  1207. $(".alert").hide();
  1208. if($("#mandatory-item-form").valid()){
  1209. $("#mandatory-item-form").ajaxForm(function (response) {
  1210. response = $.parseJSON(response);
  1211. if(response){
  1212. if(response.type=="success"){
  1213. $('#mandatory-item-form .alert.success').html(response.message);
  1214. $('#mandatory-item-form .alert.success').show();
  1215. setTimeout(function(){
  1216. location.reload();
  1217. },2000)
  1218. }else{
  1219. $('#mandatory-item-form .alert.error').html(response.message);
  1220. $('#mandatory-item-form .alert.error').show();
  1221. }
  1222. }
  1223. }).submit();
  1224. }
  1225. });
  1226. $("body").on("click",".is_mandatory",function () {
  1227. var id = $(this).data('id');
  1228. if($(this).is(":checked")){
  1229. $("#mandatory-extra-item-option").modal('show');
  1230. $("#mandatory-extra-item-option input[name=id]").val(id);
  1231. }else{
  1232. if(confirm("Do you want disable this option?")){
  1233. $.ajax({
  1234. url:"{!! env('APP_URL') !!}remove/mandatory/"+id,
  1235. success:function () {
  1236. location.reload();
  1237. }
  1238. });
  1239. }else{
  1240. return false;
  1241. }
  1242. }
  1243. });
  1244. $("body").on('click','.save',function () {
  1245. var _this = $(this);
  1246. if($("#restaurant-form").valid()){
  1247. _this.removeClass('save');;
  1248. _this.html(spinner);
  1249. //return false;
  1250. $("#restaurant-form").ajaxForm(function (response) {
  1251. //_this.removeAttr('disabled');
  1252. response = $.parseJSON(response);
  1253. if(response){
  1254. if(response.type=="success"){
  1255. $('#restaurant-form .alert.success').html(response.message);
  1256. $('#restaurant-form .alert.success').show();
  1257. setTimeout(function(){
  1258. //window.location = '{!! env('APP_URL') !!}recipes';
  1259. location.reload();
  1260. },2000)
  1261. }else{
  1262. $('#restaurant-form .alert.error').html(response.message);
  1263. $('#restaurant-form .alert.error').show();
  1264. }
  1265. }
  1266. }).submit();
  1267. }
  1268. });
  1269. @if( isset($recipe))
  1270. $("body").on("click",".upload-gallery",function () {
  1271. $("#upload-gallery").modal('show');
  1272. });
  1273. $("body").on("click",".add-options",function () {
  1274. $("#extra-options").modal('show');
  1275. });
  1276. $("body").on("click",".add-new-items",function () {
  1277. var id = $(this).data('id');
  1278. $("input[name=extra_option_id]").val(id);
  1279. $("#add-new-items").modal('show');
  1280. });
  1281. $("body").on("click",".add-sub-item",function () {
  1282. var id = $(this).data('id');
  1283. var extra_option_id = $(this).data('extra-option-id');
  1284. $("input[name=parent_id]").val(id);
  1285. $("input[name=extra_option_id]").val(extra_option_id);
  1286. $("#add-new-items").modal('show');
  1287. });
  1288. $("body").on("click",".add-extra-items",function () {
  1289. var new_item = add_new_item();
  1290. $("#items-list").append(new_item);
  1291. });
  1292. $("body").on("click",".add-extra-items-2",function () {
  1293. var new_item = add_new_item();
  1294. $("#items-list-2").append(new_item);
  1295. });
  1296. $("body").on("click",".delete-item",function () {
  1297. var _this = $(this);
  1298. var id = $(this).data('id');
  1299. $.ajax({
  1300. url:"{!! env('APP_URL') !!}extra/item/delete/"+id,
  1301. success:function (response) {
  1302. _this.parent().parent().remove();
  1303. }
  1304. });
  1305. });
  1306. $("body").on("click",".delete-new-item",function () {
  1307. $(this).parent().parent().remove();
  1308. });
  1309. $("body").on("click",".delete-option",function () {
  1310. var _this = $(this);
  1311. var id = $(this).data('id');
  1312. $.ajax({
  1313. url:"{!! env('APP_URL') !!}extra/option/delete/"+id,
  1314. success:function (response) {
  1315. _this.parent().parent().remove();
  1316. }
  1317. });
  1318. //
  1319. });
  1320. $("body").on("click",".update-option",function () {
  1321. if($("#edit-form").valid()){
  1322. $("#edit-form").ajaxForm(function (response) {
  1323. location.reload();
  1324. }).submit();
  1325. }
  1326. });
  1327. $("body").on("click",".update-item",function () {
  1328. if($("#edit-item-form").valid()){
  1329. $("#edit-item-form").ajaxForm(function (response) {
  1330. var id = extra_option_id;
  1331. $.ajax({
  1332. url:"{!! env('APP_URL') !!}view/items/"+id,
  1333. success:function (response) {
  1334. response = response.data;
  1335. var row = "";
  1336. $.each(response,function (i,v) {
  1337. row+=show_item(v);
  1338. });
  1339. $("#item-table > tbody").html(row);
  1340. $("#edit-extra-item-option").modal('hide');
  1341. }
  1342. });
  1343. }).submit();
  1344. }
  1345. });
  1346. $("body").on("click",".edit-option",function () {
  1347. var id = $(this).data('id');
  1348. $.ajax({
  1349. url:"{!! env('APP_URL') !!}edit/option/"+id,
  1350. success:function (response) {
  1351. response = response.data;
  1352. $("#edit-form input[name=id]").val(response.id);
  1353. $("#edit-form input[name=option]").val(response.name);
  1354. $("#edit-form input[name=arabic_option]").val(response.name_arabic);
  1355. $("#edit-form input[name=price]").val(response.price);
  1356. $("#edit-extra-option").modal('show');
  1357. }
  1358. });
  1359. });
  1360. $("body").on("click",".edit-item",function () {
  1361. var id = $(this).data('id');
  1362. $.ajax({
  1363. url:"{!! env('APP_URL') !!}edit/item/"+id,
  1364. success:function (response) {
  1365. response = response.data;
  1366. $("#edit-item-form input[name=id]").val(response.id);
  1367. $("#edit-item-form input[name=item_type]").val(response.item_type);
  1368. $("#edit-item-form input[name=option]").val(response.name);
  1369. $("#edit-item-form input[name=name_arabic]").val(response.name_arabic);
  1370. $("#edit-item-form input[name=price]").val(response.price);
  1371. $("#edit-extra-item-option").modal('show');
  1372. }
  1373. });
  1374. });
  1375. $("body").on("click",".view-items",function () {
  1376. var id = $(this).data('id');
  1377. extra_option_id = id;
  1378. $.ajax({
  1379. url:"{!! env('APP_URL') !!}view/items/"+id,
  1380. success:function (response) {
  1381. response = response.data;
  1382. var row = "";
  1383. $.each(response,function (i,v) {
  1384. row+=show_item(v);
  1385. });
  1386. $("#item-table > tbody").html(row);
  1387. $("#extra-option-item").modal('show');
  1388. }
  1389. });
  1390. });
  1391. $("body").on("click",".save-extra-options",function () {
  1392. if($("#extra-options-form").valid()){
  1393. $("#extra-options-form").ajaxForm(function (response) {
  1394. response = $.parseJSON(response);
  1395. if(response){
  1396. if(response.type=="success"){
  1397. $('#extra-options .alert.success').html(response.message);
  1398. $('#extra-options .alert.success').show();
  1399. setTimeout(function(){
  1400. window.location.reload();
  1401. },2000)
  1402. }else{
  1403. $('#extra-options .alert.error').html(response.message);
  1404. $('#extra-options .alert.error').show();
  1405. }
  1406. }
  1407. }).submit();
  1408. }
  1409. });
  1410. $("body").on("click",".save-extra-items",function () {
  1411. if($("#extra-items-form").valid()){
  1412. $("#extra-items-form").ajaxForm(function (response) {
  1413. response = $.parseJSON(response);
  1414. if(response){
  1415. if(response.type=="success"){
  1416. $('#extra-items-form .alert.success').html(response.message);
  1417. $('#extra-items-form .alert.success').show();
  1418. setTimeout(function(){
  1419. window.location.reload();
  1420. },2000)
  1421. }else{
  1422. $('#extra-items-form .alert.error').html(response.message);
  1423. $('#extra-items-form .alert.error').show();
  1424. }
  1425. }
  1426. }).submit();
  1427. }
  1428. });
  1429. var gallery = new Dropzone("div#gallery",
  1430. {
  1431. paramName: "files", // The name that will be used to transfer the file
  1432. addRemoveLinks: true,
  1433. uploadMultiple: true,
  1434. autoProcessQueue: false,
  1435. parallelUploads: 50,
  1436. maxFilesize: 5, // MB
  1437. acceptedFiles: ".png, .jpeg, .jpg, .JPG, .JPEG, .PNG,",
  1438. url: "{!! env('APP_URL') !!}upload/gallery/recipe",
  1439. });
  1440. gallery.on("sending", function(file, xhr, formData) {
  1441. var filenames = [];
  1442. $('.dz-preview .dz-filename').each(function() {
  1443. filenames.push($(this).find('span').text());
  1444. });
  1445. formData.append('filenames', filenames);
  1446. formData.append('_token','{!! csrf_token() !!}');
  1447. formData.append('recipe_id',"{!! $recipe->id !!}");
  1448. });
  1449. /* Add Files Script*/
  1450. gallery.on("success", function(file, message){
  1451. $("#msg").html(message);
  1452. //setTimeout(function(){window.location.href="index.php"},200);
  1453. });
  1454. gallery.on("error", function (data) {
  1455. $("#msg").html('<div class="alert alert-danger">{{__("label.there_is_some_thing_wrong")}}</div>');
  1456. });
  1457. gallery.on("complete", function(file) {
  1458. gallery.removeFile(file);
  1459. location.reload();
  1460. });
  1461. $(".upload").on("click",function (e){
  1462. gallery.processQueue();
  1463. e.preventDefault();
  1464. });
  1465. $("body").on("click",".delete-image",function () {
  1466. var _this = $(this);
  1467. var id = $(this).data('id');
  1468. $.ajax({
  1469. url:"{!! env('APP_URL') !!}delete/image/"+id+"?type=recipe",
  1470. success:function (response) {
  1471. _this.parents(".gallery").remove();
  1472. }
  1473. });
  1474. });
  1475. $("body").on("click",".delete-image",function () {
  1476. var _this = $(this);
  1477. var id = $(this).data('id');
  1478. $.ajax({
  1479. url:"{!! env('APP_URL') !!}delete/image/"+id+"?type=recipe",
  1480. success:function (response) {
  1481. _this.parents(".gallery").remove();
  1482. }
  1483. });
  1484. });
  1485. @endif
  1486. });
  1487. function add_new_item() {
  1488. return '<div class="row" style="margin-top: 10px">\n' +
  1489. ' <div class="col-sm-3">\n' +
  1490. ' <input class="form-control" name="item_name[]" placeholder="Name of item">\n' +
  1491. ' </div>\n' +
  1492. ' <div class="col-sm-3">\n' +
  1493. ' <input class="form-control" name="item_name_arabic[]" placeholder="Name of item">\n' +
  1494. ' </div>\n' +
  1495. '<div class="col-sm-3">\n' +
  1496. ' <select class="form-control" name="item_type[]">' +
  1497. '<option value="option">Option Button</option>' +
  1498. '<option value="check-box">Checkbox</option> </select>\n' +
  1499. ' </div>\n' +
  1500. ' <div class="col-sm-2">\n' +
  1501. ' <input class="form-control" name="item_price[]" placeholder="Price if it has">\n' +
  1502. ' </div>\n' +
  1503. ' <div class="col-sm-1">\n' +
  1504. ' <a href="#!" class="delete-new-item btn btn-sm btn-danger" style="margin-top: 3px"><i class="glyphicon glyphicon-trash"></i> </a> \n' +
  1505. ' </div>\n' +
  1506. ' </div>'
  1507. }
  1508. function show_item(item) {
  1509. var str = "<tr>";
  1510. str+='<td>'+item.name+'</td>';
  1511. str+='<td>'+item.name_arabic+'</td>';
  1512. str+='<td>'+item.price+'</td>';
  1513. str+='<td>'+(item.item_type?item.item_type:"")+'</td>';
  1514. str+='<td>';
  1515. var list = "";
  1516. if(item.childern){
  1517. if(item.childern.length > 0){
  1518. list = '<ul class="list-group">';
  1519. $.each(item.childern,function (i,v) {
  1520. list += '<li class="list-group-item d-flex justify-content-between align-items-center"><a href="#!" class="edit-item" data-id="'+v.id+'"> '+v.name+'</a>' +
  1521. '<span class="badge badge-primary badge-pill">'+v.price+'</span>' +
  1522. '</li>';
  1523. });
  1524. list += "</ul>";
  1525. }
  1526. }
  1527. str+=list;
  1528. str+='</td>';
  1529. str+='<td>' +
  1530. '<a href="#!" class="btn btn-sm btn-primary edit-item" data-id="'+item.id+'" data-toggle="tooltip" data-placement="top" title="Edit"><i class="glyphicon glyphicon-edit"></i> </a>'+
  1531. ' <a href="javascript:;" data-id="'+item.id+'" class="btn btn-sm btn-danger delete-item"><i class="glyphicon glyphicon-trash" data-toggle="tooltip" data-placement="top" title="Delete"></i></a>'+
  1532. ' <a href="javascript:;" data-id="'+item.id+'" data-extra-option-id="'+item.extra_option_id+'" class="btn btn-sm btn-warning add-sub-item"><i class="glyphicon glyphicon-th-list" data-toggle="tooltip" data-placement="top" title="Add sub items"></i></a>'
  1533. '</td>';
  1534. str+='</tr>';
  1535. return str;
  1536. }
  1537. </script>
  1538. @endsection