recipe_form.blade.php_bkp_2_dec_2023 82 KB

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