assets/js/custom (another copy).js
// if user is in add mode of promtion then it will on click of applied on value , other wise if user in edit mode then it will work on load according to selected applied on value
if user is in add mode of promtion then it will on click of applied on value , other wise if user in edit mode then it will work on load according to selected applied on value
if user is in add mode of promtion then it will on click of applied on value other wise if user in edit mode then it will work on load according to selected applied on value
function comman_select_restaurant_product_category_options(applied_on) {
        switch (true) {
          case applied_on ==1 || applied_on == 2 || applied_on == 8 : 
              $('#for_select_restaurant').removeClass('d-none');
              $('#select_restaurant #SelectRestaurantDropdown input').attr('type','checkbox');
              $('#for_select_prodcut').addClass('d-none');
              $('#for_select_category').addClass('d-none');
              var selected_restaurant_length = $('.selected_restaurant_id:checked').length;
              if(selected_restaurant_length == 0){
                $('#SelectRestaurantInput,#SelectRestaurantDropdown').css('border-color','red');
                $('#unselect_restaurant').text('Please Select Restaurant');
              }else{
                  $('#SelectRestaurantInput,#SelectRestaurantDropdown').css('border-color','#ccc');
                  $('#unselect_restaurant').text('');
              }
              $('#SelectRestaurantInput').trigger('click');
            break;
          case  applied_on == 3: 
              if(logged_in_restaurant_id != ""){
                $('#for_select_restaurant').addClass('d-none');
              }else{
                  $('#for_select_restaurant').removeClass('d-none');
              }
              $('#for_select_prodcut').removeClass('d-none');
              $('#for_select_category').addClass('d-none');
              $('#select_restaurant #SelectRestaurantDropdown input').attr('type','radio');
              if(logged_in_restaurant_id != ""){
                   var selected_restaurant_id = logged_in_restaurant_id;
               }else{
                  var selected_restaurant_id = $('.selected_restaurant_id:checked').val();
               }
             if(selected_restaurant_id == undefined || selected_restaurant_id == null){
                   $('#SelectProductDropdown').empty();
                   $('#SelectProductDropdown').append('<label class="enabled-label">Please select a restaurant id</label>');
               }else{
                   common_get_products_by_restaurant_id(selected_restaurant_id);
               }
              if(promotion_mode_type == 2 && edit_promotion_code_name != ""){
                    common_getting_restauant_product_or_category_id_by_promo_code_name(selected_restaurant_id,applied_on);
               }
               $('#SelectProductInput').trigger('click');
            break;
          case  applied_on == 4: 
              if(logged_in_restaurant_id != ""){
                $('#for_select_restaurant').addClass('d-none');
              }else{
                  $('#for_select_restaurant').removeClass('d-none');
              }
              $('#select_restaurant #SelectRestaurantDropdown input').attr('type','radio');
              $('#for_select_prodcut').addClass('d-none');
              $('#for_select_category').removeClass('d-none');
              if(logged_in_restaurant_id != ""){
                   var selected_restaurant_id = logged_in_restaurant_id;
               }else{
                   var selected_restaurant_id = $('.selected_restaurant_id:checked').val();
               }
               if(selected_restaurant_id == undefined || selected_restaurant_id == null){
                    $('#SelectCategoryDropdown').empty();
                    $('#SelectCategoryDropdown').append( '<label class="enabled-label">Please select a restaurant id</label>');
               }else{
                    common_get_categories_by_restaurant_id(selected_restaurant_id);
               }
                if(promotion_mode_type == 2 && edit_promotion_code_name != ""){
                    common_getting_restauant_product_or_category_id_by_promo_code_name(selected_restaurant_id,applied_on);
               }
              $('#SelectCategoryInput').trigger('click');
            break;
          default:
           $('#for_select_restaurant').addClass('d-none');
           $('#select_restaurant #SelectRestaurantDropdown input').attr('type','checkbox');
           $('#for_select_prodcut').addClass('d-none');
            $('#for_select_category').addClass('d-none');
        }
   }
function comman_select_restaurant_product_category_options ( applied_on ) { switch ( true ) { case applied_on == 1 || applied_on == 2 || applied_on == 8 : $ ( '#for_select_restaurant' ) . removeClass ( 'd-none' ) ; $ ( '#select_restaurant #SelectRestaurantDropdown input' ) . attr ( 'type' , 'checkbox' ) ; $ ( '#for_select_prodcut' ) . addClass ( 'd-none' ) ; $ ( '#for_select_category' ) . addClass ( 'd-none' ) ; var selected_restaurant_length = $ ( '.selected_restaurant_id:checked' ) . length ; if ( selected_restaurant_length == 0 ) { $ ( '#SelectRestaurantInput,#SelectRestaurantDropdown' ) . css ( 'border-color' , 'red' ) ; $ ( '#unselect_restaurant' ) . text ( 'Please Select Restaurant' ) ; } else { $ ( '#SelectRestaurantInput,#SelectRestaurantDropdown' ) . css ( 'border-color' , '#ccc' ) ; $ ( '#unselect_restaurant' ) . text ( '' ) ; } $ ( '#SelectRestaurantInput' ) . trigger ( 'click' ) ; break ; case applied_on == 3 : if ( logged_in_restaurant_id != "" ) { $ ( '#for_select_restaurant' ) . addClass ( 'd-none' ) ; } else { $ ( '#for_select_restaurant' ) . removeClass ( 'd-none' ) ; } $ ( '#for_select_prodcut' ) . removeClass ( 'd-none' ) ; $ ( '#for_select_category' ) . addClass ( 'd-none' ) ; $ ( '#select_restaurant #SelectRestaurantDropdown input' ) . attr ( 'type' , 'radio' ) ; if ( logged_in_restaurant_id != "" ) { var selected_restaurant_id = logged_in_restaurant_id ; } else { var selected_restaurant_id = $ ( '.selected_restaurant_id:checked' ) . val ( ) ; } if ( selected_restaurant_id == undefined || selected_restaurant_id == null ) { $ ( '#SelectProductDropdown' ) . empty ( ) ; $ ( '#SelectProductDropdown' ) . append ( '<label class="enabled-label">Please select a restaurant id</label>' ) ; } else { common_get_products_by_restaurant_id ( selected_restaurant_id ) ; } if ( promotion_mode_type == 2 && edit_promotion_code_name != "" ) { common_getting_restauant_product_or_category_id_by_promo_code_name ( selected_restaurant_id , applied_on ) ; } $ ( '#SelectProductInput' ) . trigger ( 'click' ) ; break ; case applied_on == 4 : if ( logged_in_restaurant_id != "" ) { $ ( '#for_select_restaurant' ) . addClass ( 'd-none' ) ; } else { $ ( '#for_select_restaurant' ) . removeClass ( 'd-none' ) ; } $ ( '#select_restaurant #SelectRestaurantDropdown input' ) . attr ( 'type' , 'radio' ) ; $ ( '#for_select_prodcut' ) . addClass ( 'd-none' ) ; $ ( '#for_select_category' ) . removeClass ( 'd-none' ) ; if ( logged_in_restaurant_id != "" ) { var selected_restaurant_id = logged_in_restaurant_id ; } else { var selected_restaurant_id = $ ( '.selected_restaurant_id:checked' ) . val ( ) ; } if ( selected_restaurant_id == undefined || selected_restaurant_id == null ) { $ ( '#SelectCategoryDropdown' ) . empty ( ) ; $ ( '#SelectCategoryDropdown' ) . append ( '<label class="enabled-label">Please select a restaurant id</label>' ) ; } else { common_get_categories_by_restaurant_id ( selected_restaurant_id ) ; } if ( promotion_mode_type == 2 && edit_promotion_code_name != "" ) { common_getting_restauant_product_or_category_id_by_promo_code_name ( selected_restaurant_id , applied_on ) ; } $ ( '#SelectCategoryInput' ) . trigger ( 'click' ) ; break ; default : $ ( '#for_select_restaurant' ) . addClass ( 'd-none' ) ; $ ( '#select_restaurant #SelectRestaurantDropdown input' ) . attr ( 'type' , 'checkbox' ) ; $ ( '#for_select_prodcut' ) . addClass ( 'd-none' ) ; $ ( '#for_select_category' ) . addClass ( 'd-none' ) ; } }
if user is in add mode of promtion then it will on click of applied on value , other wise if user in edit mode then it will work on load according to selected applied on value
if user is in add mode of promtion then it will on click of applied on value other wise if user in edit mode then it will work on load according to selected applied on value
// delivery or resetaurant and self pickup // prodouct // merchant is logged in means they cant add more restaurant // super admin logged in //merchant is logged in //super admin is logged in //geting products list and show it in to drop down with search // edit mode only // category // merchant is logged in means they cant add more restaurant // super admin logged in //merchant is logged in //super admin is logged in //geting products list and show it in to drop down with search // edit mode only //switch case end