示例#1
0
			}
			
			if(!empty($_POST['new_high']) || !empty($_POST['new_low']) || !empty($_POST['new_discount'])){
				if(empty($_POST['new_discount']) || (empty($_POST['new_low']) && empty($_POST['new_high']))){
					$error_msg .= "You must enter a value for high, low and discount to add a new structure line!\n";	
				}else{
					if(empty($_POST['new_low'])) $_POST['new_low'] = 0;
					if(empty($_POST['new_high']) || trim($_POST['new_high']) == '+') $_POST['new_high'] = 0;
					$_POST['new_discount'] = trim($_POST['new_discount']);
					if($_POST['new_discount'][0] != '-') $_POST['new_discount'] = '-'.$_POST['new_discount']; 
					$line = new SI_RateStructureLine();
					$line->high = (int)$_POST['new_high'];	
					$line->low = (int)$_POST['new_low'];	
					$line->discount = (float)$_POST['new_discount'];
					$line->rate_structure_id = $rate_structure->id;
					if($rate_structure->validateNewLine($line) === FALSE){
						$error_msg .= $rate_structure->getLastError();
					}else{
						if($line->add() === FALSE){
							$error_msg .= "Error adding new structure line!\n";
							debug_message($line->getLastError());	
						}
						$lines = $rate_structure->getLines();
					}
				}
			}
			
			if(empty($error_msg) && $_POST['save'] == 'Save'){
				goBack();
			}
		}else{