Make clean, not war.
このコミットが含まれているのは:
コミット
ba91d7dfce
|
@ -6,55 +6,55 @@ use Illuminate\Support\Facades\DB;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\PermissionController; // Remove permission controller soon.
|
||||
|
||||
class InvoiceController extends Controller {
|
||||
private $objAuth;
|
||||
private $objUser;
|
||||
private $objPermission;
|
||||
|
||||
// Constructor
|
||||
public function __construct() {
|
||||
$this->objAuth = new AuthController();
|
||||
$this->objUser = new UserController();
|
||||
$this->objPermission = new PermissionController();
|
||||
}
|
||||
|
||||
// Clients
|
||||
public function getClients() { // /api/rpc/invoice/clients/getclients
|
||||
return DB::table('inv_clients')
|
||||
->join('inv_contacts', 'inv_contacts.id', 'inv_clients.contact_id')
|
||||
->get(array(
|
||||
'inv_clients.id as id',
|
||||
'inv_contacts.id as cid',
|
||||
'inv_contacts.name',
|
||||
'inv_contacts.address',
|
||||
'inv_contacts.postcode',
|
||||
'inv_contacts.town',
|
||||
'inv_contacts.country',
|
||||
'inv_contacts.phone',
|
||||
'inv_contacts.email'
|
||||
));
|
||||
}
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
public function getClient($id) { // /api/rpc/invoice/clients/getclient/id
|
||||
return DB::table('inv_clients')
|
||||
->join('inv_contacts', 'inv_contacts.id', 'inv_clients.contact_id')
|
||||
->where('inv_clients.id', $id)
|
||||
->get(array(
|
||||
'inv_clients.id as id',
|
||||
'inv_contacts.id as cid',
|
||||
'inv_contacts.name',
|
||||
'inv_contacts.address',
|
||||
'inv_contacts.postcode',
|
||||
'inv_contacts.town',
|
||||
'inv_contacts.country',
|
||||
'inv_contacts.phone',
|
||||
'inv_contacts.email'
|
||||
));
|
||||
}
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
public function newClient(Request $request) { // /api/rpc/invoice/clients/new
|
||||
return '';
|
||||
}
|
||||
|
||||
public function editClient(Request $request) { // /api/rpc/invoice/clients/edit
|
||||
return '';
|
||||
}
|
||||
|
||||
public function deleteClient(Request $request) { // /api/rpc/invoice/clients/delete
|
||||
return '';
|
||||
if ($valid['inv_mancontact'] == 1) {
|
||||
return DB::table('inv_clients')
|
||||
->join('inv_contacts', 'inv_contacts.id', 'inv_clients.contact_id')
|
||||
->get(array(
|
||||
'inv_clients.id as id',
|
||||
'inv_contacts.id as cid',
|
||||
'inv_contacts.name',
|
||||
'inv_contacts.address',
|
||||
'inv_contacts.postcode',
|
||||
'inv_contacts.town',
|
||||
'inv_contacts.country',
|
||||
'inv_contacts.phone',
|
||||
'inv_contacts.email'
|
||||
));
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Company
|
||||
public function getCompany() { // /api/rpc/invoice/company/getcompany
|
||||
public function getCompany() {
|
||||
return DB::table('inv_company')
|
||||
->select(
|
||||
'contact_id as cid',
|
||||
|
@ -71,17 +71,45 @@ class InvoiceController extends Controller {
|
|||
}
|
||||
|
||||
public function editCompany(Request $request) { // /api/rpc/invoice/company/edit
|
||||
return '';
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_mancompany'] == 1) {
|
||||
return '';
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Contacts
|
||||
public function getContacts() { // /api/rpc/invoice/contacts/getcontacts
|
||||
return DB::table('inv_contacts')
|
||||
->select('*')
|
||||
->get();
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_mancontact'] == 1) {
|
||||
return DB::table('inv_contacts')
|
||||
->select('*')
|
||||
->get();
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getContact($id) { // /api/rpc/invoice/contacts/getcontact/id
|
||||
public function getContact($id) {
|
||||
return DB::table('inv_contacts')
|
||||
->select('*')
|
||||
->where('id', $id)
|
||||
|
@ -89,7 +117,46 @@ class InvoiceController extends Controller {
|
|||
}
|
||||
|
||||
public function newContact(Request $request) { // /api/rpc/invoice/contacts/new
|
||||
return '';
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_mancontact'] == 1) {
|
||||
$add = DB::table('inv_contacts')
|
||||
->insertGetId([
|
||||
'name' => $request->name,
|
||||
'address' => $request->address,
|
||||
'postcode' => $request->postcode,
|
||||
'town' => $request->town,
|
||||
'country' => $request->country,
|
||||
'phone' => $request->phone,
|
||||
'email' => $request->email
|
||||
]);
|
||||
|
||||
if ($request->isClient) {
|
||||
DB::table('inv_clients')
|
||||
->insert([
|
||||
'contact_id' => $add
|
||||
])
|
||||
}
|
||||
|
||||
if ($request->isEmployer) {
|
||||
DB::table('inv_employers')
|
||||
->insert([
|
||||
'contact_id' => $add
|
||||
])
|
||||
}
|
||||
|
||||
return 'Success!';
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function editContact(Request $request) { // /api/rpc/invoice/contacts/edit
|
||||
|
@ -102,48 +169,33 @@ class InvoiceController extends Controller {
|
|||
|
||||
// Employers
|
||||
public function getEmployers() { // /api/rpc/invoice/employees/getemployers
|
||||
return DB::table('inv_employers')
|
||||
->join('inv_contacts', 'inv_employers.contact_id', 'inv_contacts.id')
|
||||
->get(array(
|
||||
'inv_employers.id as id',
|
||||
'inv_contacts.id as cid',
|
||||
'inv_contacts.name',
|
||||
'inv_contacts.address',
|
||||
'inv_contacts.postcode',
|
||||
'inv_contacts.town',
|
||||
'inv_contacts.country',
|
||||
'inv_contacts.phone',
|
||||
'inv_contacts.email'
|
||||
));
|
||||
}
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
public function getEmployer($id) { // /api/rpc/invoice/employees/getemployer/id
|
||||
return DB::table('inv_employers')
|
||||
->join('inv_contacts', 'inv_employers.contact_id', 'inv_contacts.id')
|
||||
->where('inv_employers.id', $id)
|
||||
->get(array(
|
||||
'inv_employers.id as id',
|
||||
'inv_contacts.id as cid',
|
||||
'inv_contacts.name',
|
||||
'inv_contacts.address',
|
||||
'inv_contacts.postcode',
|
||||
'inv_contacts.town',
|
||||
'inv_contacts.country',
|
||||
'inv_contacts.phone',
|
||||
'inv_contacts.email'
|
||||
));
|
||||
}
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
public function newEmployer(Request $request) { // /api/rpc/invoice/employers/new
|
||||
return '';
|
||||
}
|
||||
|
||||
public function editEmployer(Request $request) { // /api/rpc/invoice/employers/edit
|
||||
return '';
|
||||
}
|
||||
|
||||
public function deleteEmployer(Request $request) { // /api/rpc/invoice/employers/delete
|
||||
return '';
|
||||
if ($valid['inv_mancontact'] == 1) {
|
||||
return DB::table('inv_employers')
|
||||
->join('inv_contacts', 'inv_employers.contact_id', 'inv_contacts.id')
|
||||
->get(array(
|
||||
'inv_employers.id as id',
|
||||
'inv_contacts.id as cid',
|
||||
'inv_contacts.name',
|
||||
'inv_contacts.address',
|
||||
'inv_contacts.postcode',
|
||||
'inv_contacts.town',
|
||||
'inv_contacts.country',
|
||||
'inv_contacts.phone',
|
||||
'inv_contacts.email'
|
||||
));
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Invoices
|
||||
|
|
|
@ -9,41 +9,26 @@
|
|||
|
|
||||
*/
|
||||
|
||||
// Clients
|
||||
Route::get('/api/rpc/invoice/clients/getclients', 'InvoiceController@getClients');
|
||||
Route::get('/api/rpc/invoice/clients/getclient/{id}', 'InvoiceController@getClient');
|
||||
Route::post('/api/rpc/invoice/clients/new', 'InvoiceController@newClient');
|
||||
Route::post('/api/rpc/invoice/clients/edit', 'InvoiceController@editClient');
|
||||
Route::post('/api/rpc/invoice/clients/delete', 'InvoiceController@deleteClient');
|
||||
|
||||
// Company
|
||||
Route::get('/api/rpc/invoice/company/getcompany', 'InvoiceController@getCompany');
|
||||
// Management
|
||||
Route::post('/api/rpc/invoice/company/edit', 'InvoiceController@editCompany');
|
||||
|
||||
// Contacts
|
||||
// Relations
|
||||
Route::get('/api/rpc/invoice/clients/getclients', 'InvoiceController@getClients');
|
||||
Route::get('/api/rpc/invoice/contacts/getcontacts', 'InvoiceController@getContacts');
|
||||
Route::get('/api/rpc/invoice/contacts/getcontact/{id}', 'InvoiceController@getContact');
|
||||
Route::get('/api/rpc/invoice/employers/getemployers', 'InvoiceController@getEmployers');
|
||||
|
||||
Route::post('/api/rpc/invoice/contacts/new', 'InvoiceController@newContact');
|
||||
Route::post('/api/rpc/invoice/contacts/edit', 'InvoiceController@editContact');
|
||||
Route::post('/api/rpc/invoice/contacts/delete', 'InvoiceController@deleteContact');
|
||||
|
||||
// Employers
|
||||
Route::get('/api/rpc/invoice/employers/getemployers', 'InvoiceController@getEmployers');
|
||||
Route::get('/api/rpc/invoice/employers/getemployer/{id}', 'InvoiceController@getEmployer');
|
||||
Route::post('/api/rpc/invoice/employers/new', 'InvoiceController@newEmployer');
|
||||
Route::post('/api/rpc/invoice/employers/edit', 'InvoiceController@editEmployer');
|
||||
Route::post('/api/rpc/invoice/employers/delete', 'InvoiceController@deleteEmployer');
|
||||
|
||||
// Invoices
|
||||
Route::get('/api/rpc/invoice/invoices/getinvoices', 'InvoiceController@getInvoices');
|
||||
Route::get('/api/rpc/invoice/invoices/getinvoice/{id}', 'InvoiceController@getInvoice');
|
||||
Route::post('/api/rpc/invoice/invoices/new', 'InvoiceController@newInvoice');
|
||||
Route::post('/api/rpc/invoice/invoices/edit', 'InvoiceController@editInvoice');
|
||||
Route::post('/api/rpc/invoice/invoices/delete', 'InvoiceController@deleteInvoice');
|
||||
|
||||
// Services
|
||||
Route::get('/api/rpc/invoice/services/getservices', 'InvoiceController@getServices');
|
||||
Route::get('/api/rpc/invoice/services/getservice/{id}', 'InvoiceController@getService');
|
||||
Route::post('/api/rpc/invoice/services/new', 'InvoiceController@newService');
|
||||
Route::post('/api/rpc/invoice/services/edit', 'InvoiceController@editService');
|
||||
|
||||
Route::post('/api/rpc/invoice/invoices/delete', 'InvoiceController@deleteInvoice');
|
||||
Route::post('/api/rpc/invoice/services/delete', 'InvoiceController@deleteService');
|
||||
Route::post('/api/rpc/invoice/invoices/edit', 'InvoiceController@editInvoice');
|
||||
Route::post('/api/rpc/invoice/services/edit', 'InvoiceController@editService');
|
||||
Route::post('/api/rpc/invoice/invoices/new', 'InvoiceController@newInvoice');
|
||||
Route::post('/api/rpc/invoice/services/new', 'InvoiceController@newService');
|
||||
|
|
新しいイシューから参照