示例#1
0
 /**
  * @copydoc DBElement::check_values_validity()
  */
 public static function check_values_validity(&$database, &$current_user, &$log, &$values, $is_new, &$element = NULL)
 {
     // first, we let all parent classes to check the values
     parent::check_values_validity($database, $current_user, $log, $values, $is_new, $element);
     // set the datetype of the boolean attributes
     settype($values['obsolete'], 'boolean');
     // check "part_id"
     try {
         $part = new Part($database, $current_user, $log, $values['part_id']);
         $part->set_attributes(array());
         // save part attributes to update its "last_modified"
     } catch (Exception $e) {
         debug('error', 'Ungültige "part_id": "' . $values['part_id'] . '"' . "\n\nUrsprüngliche Fehlermeldung: " . $e->getMessage(), __FILE__, __LINE__, __METHOD__);
         throw new Exception('Das gewählte Bauteil existiert nicht!');
     }
     // check "id_supplier"
     try {
         if ($values['id_supplier'] < 1) {
             throw new Exception('id_supplier < 1');
         }
         $supplier = new Supplier($database, $current_user, $log, $values['id_supplier']);
     } catch (Exception $e) {
         debug('error', 'Ungültige "id_supplier": "' . $values['id_supplier'] . '"' . "\n\nUrsprüngliche Fehlermeldung: " . $e->getMessage(), __FILE__, __LINE__, __METHOD__);
         throw new Exception('Der gewählte Lieferant existiert nicht!');
     }
 }
 /**
  * @copydoc DBElement::check_values_validity()
  */
 public static function check_values_validity(&$database, &$current_user, &$log, &$values, $is_new, &$element = NULL)
 {
     // first, we let all parent classes to check the values
     parent::check_values_validity($database, $current_user, $log, $values, $is_new, $element);
     // we trim the name (spaces at the begin or at the end of a name are ugly, so we remove them)
     $values['name'] = trim($values['name']);
     if (empty($values['name'])) {
         // empty names are not allowed!
         throw new Exception('Der neue Name ist leer, das ist nicht erlaubt!');
     }
 }
示例#3
0
 /**
  * @copydoc DBElement::check_values_validity()
  */
 public static function check_values_validity(&$database, &$current_user, &$log, &$values, $is_new, &$element = NULL)
 {
     // first, we let all parent classes to check the values
     parent::check_values_validity($database, $current_user, $log, $values, $is_new, $element);
     // set the type of the boolean attributes
     settype($values['manual_input'], 'boolean');
     // check "orderdetails_id"
     try {
         $orderdetails = new Orderdetails($database, $current_user, $log, $values['orderdetails_id']);
         // save orderdetails attributes to update its "last_modified" and "last_modified" of the part
         $orderdetails->set_attributes(array());
     } catch (Exception $e) {
         debug('error', 'Ungültige "orderdetails_id": "' . $values['orderdetails_id'] . '"' . "\n\nUrsprüngliche Fehlermeldung: " . $e->getMessage(), __FILE__, __LINE__, __METHOD__);
         throw new Exception('Die gewählten Einkaufsinformationen existieren nicht!');
     }
     // check "price"
     if (!is_numeric($values['price']) || $values['price'] < 0) {
         debug('error', 'Ungültiger Preis: "' . $values['price'] . '"', __FILE__, __LINE__, __METHOD__);
         throw new Exception('Der neue Preis ist ungültig!');
     }
     // check "price_related_quantity"
     if (!is_int($values['price_related_quantity']) && !ctype_digit($values['price_related_quantity']) || $values['price_related_quantity'] < 1) {
         debug('error', '"price_related_quantity" = "' . $values['price_related_quantity'] . '"', __FILE__, __LINE__, __METHOD__);
         throw new Exception('Die Preisbezogene Menge ist ungültig!');
     }
     // check "min_discount_quantity"
     if (!is_int($values['min_discount_quantity']) && !ctype_digit($values['min_discount_quantity']) || $values['min_discount_quantity'] < 1) {
         debug('error', '"min_discount_quantity" = "' . $values['min_discount_quantity'] . '"', __FILE__, __LINE__, __METHOD__);
         throw new Exception('Die Mengenrabatt-Menge ist ungültig!');
     }
     // search for pricedetails with the same "min_discount_quantity"
     $same_min_discount_quantity_count = 0;
     $all_pricedetails = $orderdetails->get_pricedetails();
     foreach ($all_pricedetails as $pricedetails) {
         if ($pricedetails->get_min_discount_quantity() == $values['min_discount_quantity']) {
             $same_min_discount_quantity_count++;
         }
     }
     if ($is_new) {
         // first pricedetails, but "min_discount_quantity" != 1 ?
         if (count($all_pricedetails) == 0 && $values['min_discount_quantity'] != 1) {
             throw new Exception('Die Mengenrabatt-Menge muss bei der ersten Preisangabe "1" sein!');
         }
         // is there already a pricedetails with the same "min_discount_quantity" ?
         if ($same_min_discount_quantity_count > 0) {
             throw new Exception('Es existiert bereits eine Preisangabe für die selbe Mengenrabatt-Menge!');
         }
     } elseif ($values['min_discount_quantity'] != $element->get_min_discount_quantity()) {
         // does the user try to change the "min_discount_quantity", but it is "1" ?
         if ($element->get_min_discount_quantity() == 1) {
             throw new Exception('Die Mengenrabatt-Menge beim Preis für ein Bauteil kann nicht verändert werden!');
         }
         // change the "min_discount_quantity" to a already existing value?
         if ($same_min_discount_quantity_count > 0) {
             throw new Exception('Es existiert bereits eine Preisangabe mit der selben Mengenrabatt-Menge!');
         }
     }
 }
示例#4
0
 /**
  * @copydoc DBElement::check_values_validity()
  */
 public static function check_values_validity(&$database, &$current_user, &$log, &$values, $is_new, &$element = NULL)
 {
     // first, we let all parent classes to check the values
     parent::check_values_validity($database, $current_user, $log, $values, $is_new, $element);
     // check "id_device"
     try {
         if ($values['id_device'] == 0) {
             throw new Exception('Der obersten Ebene können keine Bauteile zugeordnet werden!');
         }
         $device = new Device($database, $current_user, $log, $values['id_device']);
     } catch (Exception $e) {
         debug('error', 'Ungültige "id_device": "' . $values['id_device'] . '"' . "\n\nUrsprüngliche Fehlermeldung: " . $e->getMessage(), __FILE__, __LINE__, __METHOD__);
         throw new Exception('Es existiert keine Baugruppe mit der ID "' . $values['id_device'] . '"!');
     }
     // check "id_part"
     try {
         $part = new Part($database, $current_user, $log, $values['id_part']);
     } catch (Exception $e) {
         debug('error', 'Ungültige "id_part": "' . $values['id_part'] . '"' . "\n\nUrsprüngliche Fehlermeldung: " . $e->getMessage(), __FILE__, __LINE__, __METHOD__);
         throw new Exception('Es existiert kein Bauteil mit der ID "' . $values['id_part'] . '"!');
     }
     // check "quantity"
     if (!is_int($values['quantity']) && !ctype_digit($values['quantity']) || $values['quantity'] < 0) {
         debug('error', 'quantity = "' . $values['quantity'] . '"', __FILE__, __LINE__, __METHOD__);
         throw new Exception('Die Bestückungs-Anzahl "' . $values['quantity'] . '" ist ungültig!');
     }
 }