X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FEvents.php;h=5b002e9675458c3ee5f44ff02af18faaa49b5b28;hb=a7d65bd1e9177ef0f432534feebb66454500f939;hp=6b54a7cddcda0fb9d99ecbe5a1c6a2817ed5549e;hpb=5534381b83b9f72c93ff97cd7b39849f4acdf982;p=Pman.Core diff --git a/DataObjects/Events.php b/DataObjects/Events.php index 6b54a7cd..5b002e96 100644 --- a/DataObjects/Events.php +++ b/DataObjects/Events.php @@ -25,7 +25,6 @@ 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) /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE @@ -38,14 +37,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(); @@ -87,6 +90,15 @@ 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['dup_check'])){ + $et = DB_DataObject::factory($tn); + $this->_join .= "LEFT JOIN {$et->tableName()} AS evet ON (evet.id=Events.id)"; + $this->selectAdd("(select count(*)+1 from Events where Events.dup_id = evet.id) as cnt "); + //$this->selectAs($et,'%s','evet'); + $this->having('Events.dup_id = 0 '); + + } /* if (!empty($q['query']['grouped']) && $q['query']['grouped'] == 'gr') { // grouped.. @@ -101,7 +113,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 +129,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' );