]> git.agnieray.net Git - galette.git/commitdiff
Minor fixes
authorJohan Cwiklinski <johan@x-tnd.be>
Sat, 17 Jun 2017 05:29:31 +0000 (07:29 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Sat, 17 Jun 2017 05:29:31 +0000 (07:29 +0200)
galette/lib/Galette/Entity/Contribution.php
galette/lib/Galette/Entity/Entitled.php

index 8fdd1c1a0e82d2ba01f6b3d6f1b47358bed21083..a3ec4a7245badb076a17e5d34a3255db2053e273 100644 (file)
@@ -394,7 +394,7 @@ class Contribution
                     case 'montant_cotis':
                         $this->_amount = $value;
                         $value = strtr($value, ',', '.');
-                        if (!is_numeric($value)) {
+                        if (!is_numeric($value) && $value !== '') {
                             $this->errors[] = _T("- The amount must be an integer!");
                         }
                         break;
@@ -1257,7 +1257,7 @@ class Contribution
                         $this->_begin_date = $d->format('Y-m-d');
                     } catch (\Exception $e) {
                         Analog::log(
-                            'Wrong date format. field: ' . $key .
+                            'Wrong date format. field: ' . $name .
                             ', value: ' . $value . ', expected fmt: ' .
                             __("Y-m-d") . ' | ' . $e->getMessage(),
                             Analog::INFO
@@ -1269,7 +1269,7 @@ class Contribution
                             ),
                             array(
                                 __("Y-m-d"),
-                                $this->_fields[$key]['label']
+                                $this->_fields['date_debut_cotis']['label']
                             ),
                             _T("- Wrong date format (%date_format) for %field!")
                         );
index 217abc52a24a2ed4a8503179add06f33c2a1ec6a..1ec84396041e7e0d53b82c9364c71a9be6b3f3fc 100644 (file)
@@ -119,10 +119,16 @@ abstract class Entitled
             $select->where($this->fpk . ' = ' . $id);
 
             $results = $this->zdb->execute($select);
-            $result = $results->current();
-            $this->loadFromRS($result);
+            if ($results->count() > 0) {
+                $result = $results->current();
+                $this->loadFromRS($result);
 
-            return true;
+                return true;
+            } else {
+                throw new \RuntimeException(
+                    'Unknown ID ' . $id . '!'
+                );
+            }
         } catch (\Exception $e) {
             Analog::log(
                 'Cannot load ' . $this->getType()  . ' from id `' . $id . '` | ' .