DataObjects/Core_domain.php
[Pman.Core] / DataObjects / Office.php
index 5d375ab..75d47c2 100644 (file)
@@ -53,17 +53,26 @@ class Pman_Core_DataObjects_Office extends DB_DataObject
     
     function beforeDelete($dependants_array, $roo)
     {
-        if (count($dependants_array != 1)) {
-            return false; // standard error message.
+        if (count($dependants_array) != 1) {
+            //$roo->jerr("more than one dependant type....");
+            return true; // standard error message.
         }
+        
         $p = DB_DAtaObject::Factory('Person');
+        
         if (!is_a($dependants_array[0], get_class($p))) {
-            return false;
+            $roo->jerr("dep is not a person..");
+            return true;
+        }
+        
+        $p->office_id = $this->id;
+        if ($p->count() > 1) {
+            return true; // default err..
         }
-        $p = $dependants_array[0];
-        $old = clone($p);
+        $p->find(true);
+        $pp = clone($p);
         $p->office_id = 0;
-        $p->update($old);
+        $p->update($pp);
         return true;
     }