fix organization
This commit is contained in:
parent
6b9261f853
commit
1cab4d6578
@ -95,6 +95,18 @@ $routes->patch('/api/containerdef', 'Specimen\ContainerDef::update');
|
|||||||
$routes->delete('/api/containerdef', 'Specimen\ContainerDef::delete');
|
$routes->delete('/api/containerdef', 'Specimen\ContainerDef::delete');
|
||||||
|
|
||||||
//organization
|
//organization
|
||||||
|
// account
|
||||||
|
$routes->get('/api/organization/account/', 'Organization\Account::index');
|
||||||
|
$routes->get('/api/organization/account/(:num)', 'Organization\Account::show/$1');
|
||||||
|
$routes->post('/api/organization/account', 'Organization\Account::create');
|
||||||
|
$routes->patch('/api/organization/account', 'Organization\Account::update');
|
||||||
|
$routes->delete('/api/organization/account', 'Organization\Account::delete');
|
||||||
|
// site
|
||||||
|
$routes->get('/api/organization/site/', 'Organization\Site::index');
|
||||||
|
$routes->get('/api/organization/site/(:num)', 'Organization\Site::show/$1');
|
||||||
|
$routes->post('/api/organization/site', 'Organization\Site::create');
|
||||||
|
$routes->patch('/api/organization/site', 'Organization\Site::update');
|
||||||
|
$routes->delete('/api/organization/site', 'Organization\Site::delete');
|
||||||
// discipline
|
// discipline
|
||||||
$routes->get('/api/organization/discipline/', 'Organization\Discipline::index');
|
$routes->get('/api/organization/discipline/', 'Organization\Discipline::index');
|
||||||
$routes->get('/api/organization/discipline/(:num)', 'Organization\Discipline::show/$1');
|
$routes->get('/api/organization/discipline/(:num)', 'Organization\Discipline::show/$1');
|
||||||
@ -113,12 +125,6 @@ $routes->get('/api/organization/workstation/(:num)', 'Organization\Workstation::
|
|||||||
$routes->post('/api/organization/workstation', 'Organization\Workstation::create');
|
$routes->post('/api/organization/workstation', 'Organization\Workstation::create');
|
||||||
$routes->patch('/api/organization/workstation', 'Organization\Workstation::update');
|
$routes->patch('/api/organization/workstation', 'Organization\Workstation::update');
|
||||||
$routes->delete('/api/organization/workstation', 'Organization\Workstation::delete');
|
$routes->delete('/api/organization/workstation', 'Organization\Workstation::delete');
|
||||||
// workbench
|
|
||||||
$routes->get('/api/organization/workbench/', 'Organization\Workbench::index');
|
|
||||||
$routes->get('/api/organization/workbench/(:num)', 'Organization\Workbench::show/$1');
|
|
||||||
$routes->post('/api/organization/workbench', 'Organization\Workbench::create');
|
|
||||||
$routes->patch('/api/organization/workbench', 'Organization\Workbench::update');
|
|
||||||
$routes->delete('/api/organization/workbench', 'Organization\Workbench::delete');
|
|
||||||
|
|
||||||
// Khusus
|
// Khusus
|
||||||
$routes->get('/api/zones', 'Zones::index');
|
$routes->get('/api/zones', 'Zones::index');
|
||||||
|
|||||||
73
app/Controllers/Organization/Account.php
Normal file
73
app/Controllers/Organization/Account.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Controllers\Organization;
|
||||||
|
|
||||||
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
|
use App\Models\Organization\AccountModel;
|
||||||
|
|
||||||
|
class Account extends BaseController {
|
||||||
|
use ResponseTrait;
|
||||||
|
|
||||||
|
protected $db;
|
||||||
|
protected $model;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->db = \Config\Database::connect();
|
||||||
|
$this->model = new AccountModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index() {
|
||||||
|
$rows = $this->model->findAll();
|
||||||
|
|
||||||
|
if (empty($rows)) {
|
||||||
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($AccountID = null) {
|
||||||
|
$rows = $this->model->where('AccountID', $AccountID)->findAll();
|
||||||
|
|
||||||
|
if (empty($rows)) {
|
||||||
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete() {
|
||||||
|
try {
|
||||||
|
$input = $this->request->getJSON(true);
|
||||||
|
$id = $input["AccountID"];
|
||||||
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
|
$this->model->delete($id);
|
||||||
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create() {
|
||||||
|
$input = $this->request->getJSON(true);
|
||||||
|
try {
|
||||||
|
$id = $this->model->insert($input,true);
|
||||||
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update() {
|
||||||
|
$input = $this->request->getJSON(true);
|
||||||
|
try {
|
||||||
|
$id = $input['AccountID'];
|
||||||
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
|
$this->model->update($id, $input);
|
||||||
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,9 +4,9 @@ namespace App\Controllers\Organization;
|
|||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
use App\Models\Organization\WorkbenchModel;
|
use App\Models\Organization\SiteModel;
|
||||||
|
|
||||||
class Workbench extends BaseController {
|
class Site extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
@ -14,7 +14,7 @@ class Workbench extends BaseController {
|
|||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new WorkbenchModel();
|
$this->model = new SiteModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
@ -27,8 +27,8 @@ class Workbench extends BaseController {
|
|||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($WorkbenchID = null) {
|
public function show($SiteID = null) {
|
||||||
$rows = $this->model->where('WorkbenchID', $WorkbenchID)->findAll();
|
$rows = $this->model->where('SiteID', $SiteID)->findAll();
|
||||||
|
|
||||||
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);
|
||||||
@ -40,7 +40,7 @@ class Workbench extends BaseController {
|
|||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["WorkbenchID"];
|
$id = $input["SiteID"];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->delete($id);
|
$this->model->delete($id);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||||
@ -62,7 +62,8 @@ class Workbench extends BaseController {
|
|||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $input['WorkbenchID'];
|
$id = $input['SiteID'];
|
||||||
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->update($id, $input);
|
$this->model->update($id, $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
@ -8,30 +8,46 @@ class CreateCRMOrgTable extends Migration {
|
|||||||
public function up() {
|
public function up() {
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'accountid' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
'AccountID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
||||||
'parrentaccount' => ['type' => 'INT', 'null' => true],
|
'ParentAccount' => ['type' => 'INT', 'null' => true],
|
||||||
'accountname' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
'AccountName' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
||||||
'accountnpwp' => ['type' => 'VARCHAR', 'constraint' => 5, 'null' => false],
|
'Inital' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
||||||
'inital' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
'Street_1' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
||||||
'street_1' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
'Street_2' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
||||||
'street_2' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
'Street_3' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
||||||
'street_3' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
'City' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
||||||
'zoneid' => ['type' => 'int', 'null' => true],
|
'Province' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
||||||
'zip' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'Zip' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'country' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'Country' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'email_1' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'AreaCode' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'email_2' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'EmailAddress1' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'phone' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'EmailAddress2' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'fax' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'Phone' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'createdate' => ['type' => 'datetime', 'null'=> true],
|
'Fax' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'enddate' => ['type' => 'datetime', 'null'=> true]
|
'CreateDate' => ['type' => 'datetime', 'null'=> true],
|
||||||
|
'EndDate' => ['type' => 'datetime', 'null'=> true]
|
||||||
]);
|
]);
|
||||||
|
$this->forge->addKey('AccountID', true);
|
||||||
|
$this->forge->createTable('account');
|
||||||
|
|
||||||
$this->forge->addKey('accountid', true);
|
$this->forge->addField([
|
||||||
$this->forge->createTable('accounts');
|
'SiteID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
||||||
|
'SiteCode' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
||||||
|
'SiteName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
||||||
|
'AccountID' => ['type' => 'int', 'null' => true],
|
||||||
|
'SiteTypeID' => ['type' => 'int', 'null' => true],
|
||||||
|
'Parent' => ['type' => 'int', 'null' => true],
|
||||||
|
'SiteClassID' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
|
'ME' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
|
'CreateDate' => ['type' => 'datetime', 'null'=> true],
|
||||||
|
'EndDate' => ['type' => 'datetime', 'null'=> true]
|
||||||
|
]);
|
||||||
|
$this->forge->addKey('SiteID', true);
|
||||||
|
$this->forge->createTable('site');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down() {
|
public function down() {
|
||||||
$this->forge->dropTable('accounts');
|
$this->forge->dropTable('accounts');
|
||||||
|
$this->forge->dropTable('sites');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,22 +43,11 @@ class Organization extends Migration {
|
|||||||
$this->forge->addKey('WorkstationID', true);
|
$this->forge->addKey('WorkstationID', true);
|
||||||
$this->forge->createTable('workstation');
|
$this->forge->createTable('workstation');
|
||||||
|
|
||||||
$this->forge->addField([
|
|
||||||
'WorkbenchID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
|
||||||
'DepartmentID' => ['type' => 'int', 'null'=> false],
|
|
||||||
'WorkbenchCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
|
|
||||||
'WorkbenchName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
|
||||||
]);
|
|
||||||
$this->forge->addKey('WorkbenchID', true);
|
|
||||||
$this->forge->createTable('workbench');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down() {
|
public function down() {
|
||||||
$this->forge->dropTable('discipline', true);
|
$this->forge->dropTable('discipline', true);
|
||||||
$this->forge->dropTable('department', true);
|
$this->forge->dropTable('department', true);
|
||||||
$this->forge->dropTable('workstation', true);
|
$this->forge->dropTable('workstation', true);
|
||||||
$this->forge->dropTable('workbench', true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/Models/Organization/AccountModel.php
Normal file
18
app/Models/Organization/AccountModel.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Models\Organization;
|
||||||
|
use App\Models\BaseModel;
|
||||||
|
|
||||||
|
class AccountModel extends BaseModel {
|
||||||
|
protected $table = 'account';
|
||||||
|
protected $primaryKey = 'AccountID';
|
||||||
|
protected $allowedFields = ['ParentAccount', 'AccountName', 'Initial', 'Street_1', 'Street_2', 'Street_3',
|
||||||
|
'City', 'Province', 'Zip', 'Country', 'AreaCode', 'EmailAddress1', 'EmailAddress2',
|
||||||
|
'Phone', 'Fax', 'CreateDate', 'EndDate'];
|
||||||
|
|
||||||
|
protected $useTimestamps = true;
|
||||||
|
protected $createdField = 'CreateDate';
|
||||||
|
protected $updatedField = '';
|
||||||
|
protected $useSoftDeletes = true;
|
||||||
|
protected $deletedField = 'EndDate';
|
||||||
|
|
||||||
|
}
|
||||||
@ -2,10 +2,11 @@
|
|||||||
namespace App\Models\Organization;
|
namespace App\Models\Organization;
|
||||||
use App\Models\BaseModel;
|
use App\Models\BaseModel;
|
||||||
|
|
||||||
class WorkbenchModel extends BaseModel {
|
class SiteModel extends BaseModel {
|
||||||
protected $table = 'workbench';
|
protected $table = 'site';
|
||||||
protected $primaryKey = 'WorkbenchID';
|
protected $primaryKey = 'SiteID';
|
||||||
protected $allowedFields = ['DepartmentID', 'WorkbenchCode', 'WorkbenchName', 'EndDate'];
|
protected $allowedFields = ['SiteCode', 'SiteName', 'AccountID', 'SiteTypeID', 'Parent', 'SiteClassID', 'ME',
|
||||||
|
'CreateDate', 'EndDate'];
|
||||||
|
|
||||||
protected $useTimestamps = true;
|
protected $useTimestamps = true;
|
||||||
protected $createdField = 'CreateDate';
|
protected $createdField = 'CreateDate';
|
||||||
Loading…
x
Reference in New Issue
Block a user