public $__table = 'core_company'; // table name
public $code; // string(32) not_null
public $name; // string(128)
- public $remarks; // blob(65535) blob
+ public $remarks; // blob(65535) blobeforeDeleteb
public $owner_id; // int(11) not_null
public $address; // blob(65535) blob
public $tel; // string(32)
function applyFilters($q, $au)
{
- $tn = $this->tableName();
+
+ $tn = $this->tableName();
$this->selectAdd("i18n_translate('c' , {$tn}.country, 'en') as country_display_name ");
$tn = $this->tableName();
$x = DB_DataObject::factory('core_company');
$x->comptype= 'OWNER';
$x->find(true);
-
+
if (!empty($q['query']['company_project_id'])) {
$add = '';
if (!empty($q['query']['company_include_self'])) {
if (!empty($q['query']['company_not_self'])) {
$add = " AND {$tn}.id != {$x->id}";
}
+
$pids = array();
$pid = $q['query']['company_project_id'];
if (strpos($pid, ',')) {
) as comptype_display_name
");
- if(!empty($q['search']['name'])){
- $s = $this->escape($q['search']['name']);
+ if(!empty($q['query']['name']) || !empty($q['search']['name'])){
+
+ $s = (!empty($q['query']['name'])) ? $this->escape($q['query']['name']) : $this->escape($q['search']['name']);
+
$this->whereAdd("
{$tn}.name LIKE '%$s%'
");
}
- if(!empty($q['search']['name_starts'])){
- $s = $this->escape($q['search']['name_starts']);
+
+ if(!empty($q['query']['name_starts']) || !empty($q['search']['name_starts'])){
+
+ $s = (!empty($q['query']['name_starts'])) ? $this->escape($q['query']['name_starts']) : $this->escape($q['search']['name_starts']);
+
$this->whereAdd("
{$tn}.name LIKE '$s%'
");
}
// ---------- AUTHENTICATION
- function isAuth()
+ // not sure where authetnication via company is used?? posibly media-outreach
+
+ function isAuth()
{
$db = $this->getDatabaseConnection();
$sesPrefix = $db->dsn['database'];
function beforeInsert($q, $roo)
{
+ // we still use comptype in some old systems...
+
+ if (!empty($q['comptype_id'])) {
+ $en = DB_DataObject::Factory('core_enum');
+ $en->get($q['comptype_id']);
+ $this->comptype = $en->name;
+ }
+
if(!empty($q['_check_name'])){
if($this->checkName()){
$roo->jok('OK');
function beforeUpdate($old, $q,$roo)
{
+ // we still use comptype in some old systems...
+
+ if (!empty($q['comptype_id'])) {
+ $en = DB_DataObject::Factory('core_enum');
+ $en->get($q['comptype_id']);
+ $this->comptype = $en->name;
+ }
+
+
+ if(!empty($q['_flag_delete'])){
+ $this->deleted_dt = $this->sqlValue("NOW()");
+ $this->deleted_by = $roo->getAuthUser()->id;
+ }
+
+ if(!empty($q['_flag_undelete'])){
+ $this->deleted_dt = "";
+ $this->deleted_by = 0;
+ }
if(!empty($q['_check_name'])){
if($this->checkName()){
$roo->jok('OK');
function beforeDelete($req, $roo)
{
+
// should check for members....
if(!empty($this->is_system) &&
($old->code != $this->code || $old->name != $this->name)
){
$roo->jerr('This company is not allow to delete');
}
+
+
+ }
+ function onDelete($req, $roo)
+ {
$img = DB_DataObject::factory('Images');
$img->ontable = $this->tableName();
$img->onid = $this->id;
$img->find();
while ($img->fetch()) {
- $img->beforeDelete();
+ $img->beforeDelete(array(), $roo);
$img->delete();
}
return true;
{
$affects = array();
- $all_links = $GLOBALS['_DB_DATAOBJECT']['LINKS'][$this->_database];
+ $all_links = $this->databaseLinks();
foreach($all_links as $tbl => $links) {
foreach($links as $col => $totbl_col) {