@@ 228-265 (lines=38) @@ | ||
225 | $validator = new Intraface_Validator($this->error); |
|
226 | ||
227 | settype($input["product_id"], 'integer'); |
|
228 | if ($validator->isNumeric($input["product_id"], "Du skal v�lge et produkt", "greater_than_zero")) { |
|
229 | if (!isset($input['product_detail_id'])) { |
|
230 | $input['product_detail_id'] = 0; |
|
231 | } |
|
232 | ||
233 | require_once 'Intraface/modules/product/Product.php'; |
|
234 | $product = new Product($this->procurement->kernel, $input["product_id"], $input['product_detail_id']); |
|
235 | ||
236 | if (!is_object($product) || $product->get('id') == 0) { |
|
237 | $this->error->set("Ugyldigt produkt"); |
|
238 | } else { |
|
239 | $product_detail_id = $product->get("detail_id"); |
|
240 | } |
|
241 | ||
242 | if (!isset($input['product_variation_id'])) { |
|
243 | $input['product_variation_id'] = 0; |
|
244 | } |
|
245 | if (intval($input['product_variation_id']) != 0) { |
|
246 | $variation = $product->getVariation(intval($input['product_variation_id'])); |
|
247 | if (!$variation->getId()) { |
|
248 | $this->error->set("Invalid product variation"); |
|
249 | } |
|
250 | ||
251 | if (!isset($input['product_variation_detail_id'])) { |
|
252 | $input['product_variation_detail_id'] = 0; |
|
253 | } |
|
254 | $detail = $variation->getDetail(intval($input['product_variation_detail_id'])); |
|
255 | if (!$detail->getId()) { |
|
256 | $this->error->set("Invalid product variation detail"); |
|
257 | } |
|
258 | ||
259 | $variation_id = $variation->getId(); |
|
260 | $variation_detail_id = $detail->getId(); |
|
261 | } else { |
|
262 | $variation_id = 0; |
|
263 | $variation_detail_id = 0; |
|
264 | } |
|
265 | } |
|
266 | ||
267 | $validator->isNumeric($input["quantity"], "Du skal angive et antal", "greater_than_zero,integer"); |
|
268 |
@@ 275-310 (lines=36) @@ | ||
272 | $validator = new Intraface_Validator($this->error); |
|
273 | ||
274 | settype($input["product_id"], 'integer'); |
|
275 | if ($validator->isNumeric($input["product_id"], "Du skal v�lge et produkt", "greater_than_zero")) { |
|
276 | if (!isset($input['product_detail_id'])) { |
|
277 | $input['product_detail_id'] = 0; |
|
278 | } |
|
279 | ||
280 | require_once 'Intraface/modules/product/Product.php'; |
|
281 | $product = new Product($this->debtor->kernel, $input["product_id"], $input['product_detail_id']); |
|
282 | ||
283 | if (!is_object($product) || $product->get('id') == 0) { |
|
284 | $this->error->set("Ugyldigt produkt"); |
|
285 | } else { |
|
286 | $product_detail_id = $product->get("detail_id"); |
|
287 | } |
|
288 | ||
289 | if (!isset($input['product_variation_id'])) { |
|
290 | $input['product_variation_id'] = 0; |
|
291 | } |
|
292 | if (intval($input['product_variation_id']) != 0) { |
|
293 | $variation = $product->getVariation(intval($input['product_variation_id'])); |
|
294 | if (!$variation->getId()) { |
|
295 | $this->error->set("Invalid product variation"); |
|
296 | } |
|
297 | ||
298 | if (!isset($input['product_variation_detail_id'])) { |
|
299 | $input['product_variation_detail_id'] = 0; |
|
300 | } |
|
301 | $detail = $variation->getDetail(intval($input['product_variation_detail_id'])); |
|
302 | if (!$detail->getId()) { |
|
303 | $this->error->set("Invalid product variation detail"); |
|
304 | } |
|
305 | ||
306 | $variation_id = $variation->getId(); |
|
307 | $variation_detail_id = $detail->getId(); |
|
308 | } else { |
|
309 | $variation_id = 0; |
|
310 | $variation_detail_id = 0; |
|
311 | } |
|
312 | } |
|
313 |