update join account
This commit is contained in:
parent
8680454db3
commit
56b8012e4a
@ -18,7 +18,8 @@ class Account extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$rows = $this->model->findAll();
|
//$rows = $this->model->findAll();
|
||||||
|
$rows = $this->model->getAccounts();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
@ -28,7 +29,8 @@ class Account extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function show($AccountID = null) {
|
public function show($AccountID = null) {
|
||||||
$rows = $this->model->where('AccountID', $AccountID)->findAll();
|
//$rows = $this->model->where('AccountID', $AccountID)->findAll();
|
||||||
|
$rows = $this->model->getAccount($AccountID);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
|
|||||||
@ -50,14 +50,18 @@ class Zones extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function synchronize() {
|
public function synchronize() {
|
||||||
$client = \Config\Services::curlrequest();
|
$client = \Config\Services::curlrequest([
|
||||||
|
'headers' => [
|
||||||
|
'User-Agent' => 'Mozilla/5.0 (CI4 cURL Request)',
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Ambil data dari API pusat (CRM)
|
// Ambil data dari API pusat (CRM)
|
||||||
$response = $client->get('http://services-summit.my.id/api/zones');
|
$response = $client->get('https://services-summit.my.id/api/zones');
|
||||||
// $response = $client->get('http://crmcomposer.local/api/zones');
|
|
||||||
$result = json_decode($response->getBody(), true);
|
$result = json_decode($response->getBody(), true);
|
||||||
|
|
||||||
if (!isset($result['data']) || !is_array($result['data'])) {
|
if (!isset($result['data']) || !is_array($result['data'])) {
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
|
|||||||
@ -98,7 +98,7 @@ class DummySeeder extends Seeder {
|
|||||||
// Organization
|
// Organization
|
||||||
$data = [
|
$data = [
|
||||||
[ 'AccountID' => 1, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'Siti', 'Province'=>'Prop',
|
[ 'AccountID' => 1, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'Siti', 'Province'=>'Prop',
|
||||||
'Zip'=>'505', 'Country'=>'Arab', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ]
|
'ZIP'=>'505', 'Country'=>'Arab', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ]
|
||||||
];
|
];
|
||||||
$this->db->table('account')->insertBatch($data);
|
$this->db->table('account')->insertBatch($data);
|
||||||
|
|
||||||
|
|||||||
@ -514,4 +514,4 @@ class ValueSetSeeder extends Seeder {
|
|||||||
];
|
];
|
||||||
$this->db->table('valuesetdef')->insertBatch($data);
|
$this->db->table('valuesetdef')->insertBatch($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,4 +15,23 @@ class AccountModel extends BaseModel {
|
|||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = 'EndDate';
|
protected $deletedField = 'EndDate';
|
||||||
|
|
||||||
|
public function getAccounts() {
|
||||||
|
$rows = $this->select('account.*, pa.AccountName as ParentName, zones.ZoneName as AreaName')
|
||||||
|
->join('account pa', 'pa.AccountID=account.Parent', 'left')
|
||||||
|
->join('zones', 'zones.zonecode=account.AreaCode', 'left')
|
||||||
|
->findAll();
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAccount($AccountID) {
|
||||||
|
$rows = $this->select('account.*, pa.AccountName as ParentName, zones.ZoneName as AreaName, city.ZoneName as CityName, prov.ZoneName as ProvName, country.VValue as CountryName')
|
||||||
|
->join('account pa', 'pa.AccountID=account.Parent', 'left')
|
||||||
|
->join('zones', 'zones.zonecode=account.AreaCode', 'left')
|
||||||
|
->join('zones city', 'city.zoneid=account.City', 'left')
|
||||||
|
->join('zones prov', 'prov.zoneid=account.Province', 'left')
|
||||||
|
->join('valueset country', 'country.VID=account.Country', 'left')
|
||||||
|
->where('account.AccountID', $AccountID)
|
||||||
|
->findAll();
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user