DBObj($id); $this->id_individual = intval($id_individual); $this->tblIndividual = $this->db->tblMember; } function initFromForm(&$frm) { $files = array(); $data = $frm->exportValues(); $this->arrayParseUrl2Tag($data); $this->initFromArray($data, $files); return true; } function initFromDB() { $this->_data = $this->getFromDB($this->id); $this->_data['added'] = date('F j\t\h, Y - g:i a', strtotime($this->_data['added'])); $this->_data['changed'] = date('F j\t\h, Y - g:i a', strtotime($this->_data['changed'])); return true; } function setOldData($data) { $this->_oldData = $data; return $this; } function getOldData($field = false) { return Qs_Array::get($this->_oldData, $field); } function getIdsFromDB($tableName, $DTableName, $field_name, $id_parent) { $sql = " SELECT tblLink.{$field_name} as id, tblLink.{$field_name} as title FROM {$tableName} as tblLink JOIN {$DTableName} as Dictionary ON tblLink.{$field_name} = Dictionary.id WHERE tblLink.id_parent = ".$id_parent; $res = $this->db->queryAll($sql, 0, null, true); $this->_sqlError($res); return $res; } function _addDependenciesFromDb(&$data) { $data['ids_individual'] = $this->getIdsFromDB($this->tableNameDB . '2Individual', $this->tblIndividual, 'id_individual', $data['id']); $sql = " SELECT COUNT(*) FROM {$this->tblIndividual} as Individual JOIN {$this->db->tblLocation} as Location ON Location.id = Individual.id_location AND Location.id_company = {$data['id']} "; $data['individual_cnt'] = $this->db->queryOne($sql); $sql = " SELECT COUNT(*) FROM {$this->db->tblLocation} as Location WHERE Location.id_company = {$data['id']} "; $data['location_cnt'] = $this->db->queryOne($sql); return $this; } function _insertDependency() { $this->_saveDependency(); } function _updateDependency() { $this->_saveDependency(); } function _saveDependency() { $this->updateIds($this->tableNameDB . '2Individual', 'id_individual', $this->_data['ids_individual']); } function delete() { $this->deleteIds($this->tableNameDB.'2Individual'); parent::delete(); return true; } function getIndividuals4Select() { $sql = " SELECT Individual.id, CONCAT(Individual.first_name, ' ', Individual.middle_initial, IF (Individual.middle_initial = '' , '', '. '), Individual.last_name) as name FROM {$this->tblIndividual} as Individual JOIN {$this->db->tblLocation} as Location ON Location.id = Individual.id_location WHERE Location.id_company = ".$this->db->quote($this->id, 'integer')." "; $res = $this->db->queryAll($sql, 0, null, true); $this->_sqlError($res); return $res; } }