@@ 114-148 (lines=35) @@ | ||
111 | ||
112 | if ($constraint->getMinDays() && $new_constraint->getMinDays() || |
|
113 | ($constraint->getMaxDays() && $new_constraint->getMaxDays())) { |
|
114 | if ($start_date >= $new_start_date && $start_date <= $new_end_date) { |
|
115 | $new_end_date_clone = clone($new_end_date); |
|
116 | $constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); |
|
117 | } |
|
118 | elseif ($end_date >= $new_start_date && $end_date <= $new_end_date) { |
|
119 | $new_start_date_clone = clone($new_start_date); |
|
120 | $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
|
121 | } |
|
122 | elseif ($start_date < $new_start_date && $end_date > $new_end_date) { |
|
123 | if ($constraint->getEndDate() > $new_start_date) { |
|
124 | $new_start_date_clone = clone($new_start_date); |
|
125 | $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
|
126 | } |
|
127 | ||
128 | if ($split_constraint == NULL) { |
|
129 | $split_start_date = clone($new_end_date); |
|
130 | $split_start_date->add(new \DateInterval('P1D')); |
|
131 | $split_end_date = $end_date; |
|
132 | ||
133 | $split_constraint = new MinMaxDaysConstraint($constraint->getUnits(), $constraint->getMinDays(), $constraint->getMaxDays(), $split_start_date, $split_end_date, $constraint->getCheckinDay()); |
|
134 | } |
|
135 | else { |
|
136 | $split_start_date = $split_constraint->getStartDate(); |
|
137 | $split_end_date = $split_constraint->getEndDate(); |
|
138 | ||
139 | if ($split_start_date < $new_end_date) { |
|
140 | $new_end_date_clone = clone($new_end_date); |
|
141 | $split_constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); |
|
142 | } |
|
143 | if ($split_end_date < $new_start_date) { |
|
144 | $new_start_date_clone = clone($new_start_date); |
|
145 | $split_constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
|
146 | } |
|
147 | } |
|
148 | } |
|
149 | } |
|
150 | } |
|
151 | ||
@@ 188-224 (lines=37) @@ | ||
185 | $new_start_date = $new_constraint->getStartDate(); |
|
186 | $new_end_date = $new_constraint->getEndDate(); |
|
187 | ||
188 | if ($constraint->getCheckinDay() && $new_constraint->getCheckinDay()) { |
|
189 | if ($start_date >= $new_start_date && $start_date <= $new_end_date) { |
|
190 | $new_end_date_clone = clone($new_end_date); |
|
191 | $constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); |
|
192 | } |
|
193 | elseif ($end_date >= $new_start_date && $end_date <= $new_end_date) { |
|
194 | $new_start_date_clone = clone($new_start_date); |
|
195 | $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
|
196 | } |
|
197 | elseif ($start_date < $new_start_date && $end_date > $new_end_date) { |
|
198 | if ($constraint->getEndDate() > $new_start_date) { |
|
199 | $new_start_date_clone = clone($new_start_date); |
|
200 | $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
|
201 | } |
|
202 | ||
203 | if ($split_constraint == NULL) { |
|
204 | $split_start_date = clone($new_end_date); |
|
205 | $split_start_date->add(new \DateInterval('P1D')); |
|
206 | $split_end_date = $end_date; |
|
207 | ||
208 | $split_constraint = new CheckInDayConstraint($constraint->getUnits(), $constraint->getCheckinDay(), $split_start_date, $split_end_date); |
|
209 | } |
|
210 | else { |
|
211 | $split_start_date = $split_constraint->getStartDate(); |
|
212 | $split_end_date = $split_constraint->getEndDate(); |
|
213 | ||
214 | if ($split_start_date < $new_end_date) { |
|
215 | $new_end_date_clone = clone($new_end_date); |
|
216 | $split_constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); |
|
217 | } |
|
218 | if ($split_end_date < $new_start_date) { |
|
219 | $new_start_date_clone = clone($new_start_date); |
|
220 | $split_constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
|
221 | } |
|
222 | } |
|
223 | } |
|
224 | } |
|
225 | } |
|
226 | ||
227 | if ($split_constraint != NULL) { |