$fix_id = $_POST['fix_discounts'];
$result = DB::select('name')->from('discounts')->where('id', $fix_id)->execute();
$fix_name = $result[0]['name'];
unset($result);
$eb_start = $this->mycf['eb_start'];
$eb_end = $this->mycf['eb_end'];
$val->add('fix_discounts', $fix_name)
->add_rule('valid_string', 'numeric')
->add_rule(
array(
'fix_discount_course' => function () use ($course, $fix_id, $grp) {
if (!preg_match('/[2-4]/', $fix_id)) {
return true;
}
$result = DB::select('min')->from('services')
->where('sid', $course)->execute();
return $result[0]['min'] >= 60;
}
)
)->add_rule(
array(
'fix_discount_eb' => function () use ($sh, $fix_id, $eb_start, $eb_end, $holiday) {
if (!preg_match('/[3-4]/', $fix_id)) return true;
return ($eb_start <= $sh and $sh < $eb_end and !$holiday);
}
)
)->add_rule(
array(
'fix_discount_free' => function() use ($fix_id, $desg) {
if ($fix_id == 3) return ($desg == 4);
}
)
)->add_rule(
array(
'fix_discount_pic' => function() use ($fix_id, $desg) {
if ($fix_id == 4) return ($desg == 5);
}
)
);