DataObjects/Ipshead.php
authorAlan Knowles <alan@roojs.com>
Mon, 30 Mar 2015 04:58:31 +0000 (12:58 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 30 Mar 2015 04:58:31 +0000 (12:58 +0800)
DataObjects/Ipshead.php

index e7e46a1..e3b6618 100644 (file)
@@ -74,7 +74,16 @@ class Pman_Xtuple_DataObjects_Ipshead extends DB_DataObject
     
     function beforeDelete($dependants_array, $roo)
     {
-        print_R($dependants_array);exit;
+        // check if assigned.
+        
+        $ass = DB_DataObject::factory('ipass');
+        $ass->ipsass_ipshead_id = $this->ipshead_id;
+        if ($ass->count()) {
+            $roo->jerr("This price list is assigned to a customer - please change that customer to another price list first");
+        }
+        $ass = DB_DataObject::factory('ipsiteminfo');
+        $ass->query("DELETE FROM ipsiteminfo WHERE ipsiteminfo_ipshead_id = {$this->id}");
+        return true;
     }