0){ $chargetype = $const['wtbreak']; } else{ $chargetype = $const['fxchg']; } //Select the rate corresponding to the retrieved chg_code in the RFFIXCHG table if ($chargetype == $const['fxchg']){ $query = "select cargo_rate, cargo_min_chg, cargo_max_chg from rffixchg where chg_code = '$chg_code' and cargo_class = '$sku' and end_validity > '$today' and whse_code = '$warehouse'"; $rs = mysql_query($query); $row_my_fix = mysql_fetch_assoc($rs); //if charge code is a Storage Fee if (in_array($chg_code, $storage_arr)){ $amt = $storagedays * $weight * $row_my_fix['cargo_rate']; $cargo_min_chg = $row_my_fix['cargo_min_chg']; $cargo_max_chg = $row_my_fix['cargo_max_chg']; //If the computed charge is less than the minimum charge the minimum charge will be considered if ($cargo_min_chg <> NULL && $cargo_min_chg <> '' && !empty($cargo_min_chg) && $cargo_min_chg > $amt){ $billdetails[$i]['amt'] = number_format($cargo_min_chg,2,'.',''); //assign amt to billdetails $total += $cargo_min_chg; //add computation to total } //at the same time if the computed charge is greater than the maximum charge the maximum charge will be considered elseif ($cargo_max_chg <> NULL && $cargo_max_chg <> '' && !empty($cargo_max_chg) && $cargo_max_chg <> 0 && $cargo_max_chg < $amt){ $billdetails[$i]['amt'] = $cargo_max_chg; //assign amt to billdetails $total += $cargo_max_chg; //add computation to total } //if it falls within the range, just use the computed charge else{ $billdetails[$i]['amt'] = $amt; //assign amt to billdetails $total += $amt; //add computation to total } } else{ $billdetails[$i]['amt'] = $row_my_fix['cargo_rate']; //assign amt to billdetails if ($chg_code <> $app_vat && $chg_code <> $app_ewt){ $total += $row_my_fix['cargo_rate']; //add computation to total } } } //Select the rate corresponding to the retrieved chg_code in the RFWTBREAK table else{ $query = "select wt_rate from rfwtbreak where chg_code = '$chg_code' and $weight between min_wt and max_wt and end_validity > '$today' and whse_code = '$warehouse'"; $rs = mysql_query($query); $row_my_wt = mysql_fetch_assoc($rs); $amt = $row_my_wt['wt_rate']; $subtotal = 0; //perform computations for weight break charges //if charge code = service charge if ($chg_code == $app_service){ $subtotal = $weight * $amt; } //if charge code = returned shipment fee elseif ($chg_code == $app_returned && $returns != 0 && $returns != NULL && !empty($returns) && $returns <> ''){ //this was added to accommodate change in biz rule in returned shipment fee //if weight is between min and max, fee is weight * returns * amt, otherwise, the fee is the amount itself if ($weight > $app_returned_wt_min && $weight < $app_returned_wt_max){ $subtotal = $returns * $weight * $amt; } else{ $subtotal = $amt; } } //if charge code = special or backdoor fee elseif ($backdoor == 1 && $chg_code == $app_backdoor){ //this was added to accommodate change in biz rule in backdoor fee //if weight is between min and max, fee is weight * amt, otherwise, the fee is the amount itself if ($weight > $app_backdoor_wt_min && $weight < $app_backdoor_wt_max){ $subtotal = $weight * $amt; } else{ $subtotal = $amt; } } else{ continue; } $billdetails[$i]['amt'] = $subtotal; //assign amt to billdetails $total += $subtotal; //add computation to total } $i++; //increment billdetails index } $detailsarr[$index]['cargoclass'] = $elcode." ".$eldesc; //assign cargoclass to detailsarr $detailsarr[$index]['sku'] = $elcode; //assign cargoclass to detailsarr $detailsarr[$index]['total'] = $total; //assign total to detailsarr $detailsarr[$index]['billdetails'] = $billdetails; //assign billdetails to detailsarr return $detailsarr; } ini_set("soap.wsdl_cache_enabled", "0"); $server = new SoapServer("ws_billing.wsdl"); $server->addFunction("GetBillingDetails"); $server->addFunction("GetCharges"); $server->handle(); ?>