wilded
8/8/2017 - 3:03 PM

Javascript Functions on Multiple Edit

Javascript Functions on Multiple Edit

$('#ryyproSalePrice_' + rids_parts[i]).keyup(function() {
                                var ryyproSalePrice = $(this).val();
                                var ryyproSalePrice_id = $(this).attr('id');
                                var rid_part_i = ryyproSalePrice_id.replace(/[^0-9]/gi, ''); // Replace everything that is not a number with nothing
                                var ryyproTaxID_Var2 = '#ryyproTaxID_' + rid_part_i + ' option:selected';
                                var ryyproTaxID2 = $( ryyproTaxID_Var2 ).text().replace(/[^0-9]/gi, '');
                                var TaxIdValue2 = parseInt(ryyproTaxID2, 10); 
                                if(TaxIdValue2 > 1){
                                TaxIdValue2 = 1 + (TaxIdValue2 / 100);
                                } else {
                                    TaxIdValue2 = 1 + TaxIdValue2;
                                }
                                ryyproSalePrice2 = ryyproSalePrice.replace(',', '');
                                netPrice2 = ryyproSalePrice2 * TaxIdValue2;
                                $(\"#span_ryyproSalePrice_\" + rid_part_i).text('$proSaleNetPrice2 = $' + netPrice2.toFixed(2) );
                            });
 //** Verify Promotion discount  value END
    $size_of_rids = count($rids_parts);
    $rid = (isset($_REQUEST['proDG_rid'])) ? $_REQUEST['proDG_rid'] : "";
    if ($size_of_rids >= 1){
        //echo "<script>alert('$rid')</script>";
        //if($mode == 'edit'){
            echo "
            <script type='text/javascript'>
            function proDG_onSubmitMyCheck(){               
                var rids = document.getElementById('proDG_rid').value;
                var mode = document.getElementById('proDG_mode').value;
                var error = '';
                var rids_parts = rids.split('-');
                
                for (i = 0; i < rids_parts.length; i++) {
                    if(rids_parts.length == 1 || rids_parts[i] ==''){
                        var promoDiscount = document.getElementById('syyproPromoDiscount').value;
                        var promoExpirationDate = document.getElementById('syyproPromoExpirationDate').value;
                        
                        if(promoDiscount == '' && promoExpirationDate == ''){
                            return true;
                        }
                        
                        if(promoDiscount >= 1){
                            alert('$alertProductDecimals');
                            $('#syyproPromoDiscount').css({'background-color': 'orange'});
                            $('#syyproPromoDiscount').focus();
                            return false;
                            error = 1;
                        }
                        
                        if((promoDiscount > 0 && promoExpirationDate == '0000-00-00 00:00:00') || (promoDiscount == 0 && promoExpirationDate != '0000-00-00 00:00:00')){
                            alert('$alertProductDiscountFields');
                            $('#syyproPromoDiscount').css({'background-color': 'orange'});
                            $('#syyproPromoExpirationDate').css({'background-color': 'orange'});
                            $('#syyproPromoExpirationDate').focus();
                            return false;
                            error = 2;
                        }  
                       
                        if(error == ''){
                            return true;
                        }
                        
                        
                    } 
                    
                    if(rids_parts.length > 1 && rids_parts[i] !=''){
                        var promoDiscount = document.getElementById('syyproPromoDiscount_' + rids_parts[i]).value;
                        var promoExpirationDate = document.getElementById('syyproPromoExpirationDate_' + rids_parts[i]).value;
                                        
                        if(promoDiscount >= 1){
                            alert('$alertProductDecimals');
                            $('#syyproPromoDiscount_' + rids_parts[i]).css({'background-color': 'orange'});
                            $('#syyproPromoDiscount_' + rids_parts[i]).focus();
                            return false;
                        }
                    
                        if((promoDiscount > 0 && promoExpirationDate == '0000-00-00 00:00:00') || (promoDiscount == 0 && promoExpirationDate != '0000-00-00 00:00:00')){
                            alert('$alertProductDiscountFields');
                            $('#syyproPromoDiscount_' + rids_parts[i]).css({'background-color': 'orange'});
                            $('#syyproPromoExpirationDate_' + rids_parts[i]).css({'background-color': 'orange'});
                            $('#syyproPromoExpirationDate_' + rids_parts[i]).focus();
                            return false;
                        }     
                    }
                }    
                return true;
            }	
            </script> 
        ";
        }
        
    // }
     //** Verify Promotion discount value END