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