X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FEvents.php;h=2e32b9f7a8c401a5ec64dc20133741c11b46a1d4;hb=1289ddfb4c25c9f4ee4d6975603c15989ab671e1;hp=6b54a7cddcda0fb9d99ecbe5a1c6a2817ed5549e;hpb=5534381b83b9f72c93ff97cd7b39849f4acdf982;p=Pman.Core diff --git a/DataObjects/Events.php b/DataObjects/Events.php index 6b54a7cd..2e32b9f7 100644 --- a/DataObjects/Events.php +++ b/DataObjects/Events.php @@ -25,7 +25,7 @@ class Pman_Core_DataObjects_Events extends DB_DataObject public $person_id; // int(11) public $remarks; // blob(65535) blob public $person_table; // string(64) - public $investor_id; // int(11) + public $dupe_id; // int(11) /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE @@ -38,14 +38,18 @@ class Pman_Core_DataObjects_Events extends DB_DataObject { $tn = $this->tableName(); // if not empty on_table + if(!empty($q['person_table'])){ $jt = DB_DataObject::factory($q['person_table']); + + if(!array_key_exists("{$jt->tableName()}_id", $this->tableColumns())){ // coz we have triiger on mysql... $keys = $jt->keys(); $this->_join = "LEFT JOIN {$jt->tableName()} AS join_person_id_id ON (join_person_id_id.{$keys[0]}=Events.person_id)"; + $this->selectAdd(); $this->selectAs(); @@ -70,12 +74,12 @@ class Pman_Core_DataObjects_Events extends DB_DataObject } $jt = DB_DataObject::factory($person); - $this->whereAdd(" - person_table = '{$jt->tableName()}' - OR - person_table = '' - OR person_table IS NULL" - ); // default to our standard.. - unless otherwise requested.. + //$this->whereAdd(" + // person_table = '{$jt->tableName()}' + // OR + // person_table = '' + // OR person_table IS NULL" + //); // default to our standard.. - unless otherwise requested.. } @@ -87,6 +91,11 @@ class Pman_Core_DataObjects_Events extends DB_DataObject $dt = date('Y-m-d' , strtotime($q['query']['to'])); $this->whereAdd(" {$tn}.event_when <= '$dt' "); } + + if(!empty($q['_with_dupe_count'])){ + $this->dupe_id = 0; + $this->selectAdd("(select count(*)+1 from Events ev_cnt where ev_cnt.dupe_id = {$tn}.id) as dupe_count"); + } /* if (!empty($q['query']['grouped']) && $q['query']['grouped'] == 'gr') { // grouped.. @@ -101,7 +110,8 @@ class Pman_Core_DataObjects_Events extends DB_DataObject if (!$au->hasPerm("Admin.Admin_Tab", 'S')) { //DB_DataObject::DebugLevel(1); // they can only view their changes.. - $this->person_id = $au->id; + $this->whereAdd("($tn.person_id = {$au->id} OR $tn.person_id = 0)"); +// $this->person_id = $au->id; } // _join = tablename,tablename... @@ -116,13 +126,7 @@ class Pman_Core_DataObjects_Events extends DB_DataObject // empty ontable queries.. these are valid.. $this->whereAdd("$tn.on_table = ''"); } - - if (!empty($q['coba_investor_id'])) { - $coba_investor_id = $this->escape($q['coba_investor_id']); - //$dt = date('Y-m-d' , strtotime($q['query']['to'])); - $this->whereAdd(" {$tn}.coba_investor_id <= '$coba_investor_id' "); - } - + if (isset($q['query']['person_sum'])) { //DB_DataObject::debugLevel(1); $this->_extra_cols = array('qty' ); @@ -213,6 +217,7 @@ class Pman_Core_DataObjects_Events extends DB_DataObject if (!$obj) { $roo->jerr("ontable is invalid"); } + /* if (!method_exists($obj,'relatedWhere')) { $roo->jerr( $q['_related_on_table'] . " Does not have method relatedWhere :" . implode(',', get_class_methods($obj))); @@ -236,12 +241,17 @@ class Pman_Core_DataObjects_Events extends DB_DataObject } $this->whereAdd(implode(' OR ' , $w)); + }*/ + if ($obj && method_exists($obj,'relatedEventsWhere')) { + $a = $obj->relatedEventsWhere($q,$roo); + if($a){ + $this->whereAdd($a); + } } - } // since roo does not support autojoin yet.. if (!isset($q['_distinct'])) { @@ -311,6 +321,7 @@ class Pman_Core_DataObjects_Events extends DB_DataObject } $this->person_name = $au && !empty($au->name) ? $au->name : ''; + $this->who = $au && !empty($au->name) ? $au->name : ''; if (empty($au) || (isset($au->id) && empty($au->id))) { // not authenticated - and a standard id based object $this->person_id = 0;