Edit invoice among other stuff.
このコミットが含まれているのは:
コミット
7433413701
|
@ -231,24 +231,51 @@ class InvoiceController extends Controller {
|
|||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_mancontact'] == 1) {
|
||||
$data = array(
|
||||
'inv_contacts.id',
|
||||
'inv_contacts.user_id',
|
||||
'inv_contacts.company_name',
|
||||
'inv_contacts.name',
|
||||
'inv_contacts.address',
|
||||
'inv_contacts.postcode',
|
||||
'inv_contacts.town',
|
||||
'inv_contacts.country',
|
||||
'inv_contacts.phone',
|
||||
'inv_contacts.email'
|
||||
);
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
return DB::table('inv_contacts')
|
||||
->select(
|
||||
'id',
|
||||
'user_id',
|
||||
'company_name',
|
||||
'name',
|
||||
'address',
|
||||
'postcode',
|
||||
'town',
|
||||
'country',
|
||||
'phone',
|
||||
'email'
|
||||
)
|
||||
->get();
|
||||
|
||||
if (isset($request->emp)) {
|
||||
$get = DB::table('inv_contacts')
|
||||
->join('inv_employers', 'inv_employers.contact_id', 'inv_contacts.id')
|
||||
->get($data);
|
||||
}
|
||||
else if (isset($request->cus)) {
|
||||
$get = DB::table('inv_contacts')
|
||||
->join('inv_clients', 'inv_clients.contact_id', 'inv_contacts.id')
|
||||
->get($data);
|
||||
}
|
||||
else {
|
||||
$get = DB::table('inv_contacts')
|
||||
->select(
|
||||
'id',
|
||||
'user_id',
|
||||
'company_name',
|
||||
'name',
|
||||
'address',
|
||||
'postcode',
|
||||
'town',
|
||||
'country',
|
||||
'phone',
|
||||
'email'
|
||||
)
|
||||
->get();
|
||||
}
|
||||
|
||||
return $get;
|
||||
}
|
||||
else {
|
||||
return DB::table('inv_contacts')
|
||||
$get = DB::table('inv_contacts')
|
||||
->select(
|
||||
'id',
|
||||
'company_name',
|
||||
|
@ -262,6 +289,8 @@ class InvoiceController extends Controller {
|
|||
)
|
||||
->where('user_id', $check)
|
||||
->get();
|
||||
|
||||
return $get;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -765,10 +794,10 @@ class InvoiceController extends Controller {
|
|||
->where('inv_invoice_items.invoice_id', $id)
|
||||
->where('inv_invoice_items.user_id', $u->user_id)
|
||||
->get(array(
|
||||
'inv_services.id',
|
||||
'inv_invoice_items.id as id',
|
||||
'inv_services.id as service_id',
|
||||
'inv_services.name',
|
||||
'inv_services.rate',
|
||||
'inv_invoice_items.work_date',
|
||||
'inv_invoice_items.from_time',
|
||||
'inv_invoice_items.to_time'
|
||||
));
|
||||
|
@ -776,11 +805,16 @@ class InvoiceController extends Controller {
|
|||
foreach($items as $j) {
|
||||
$des[] = array(
|
||||
'id' => $j->id,
|
||||
'service_id' => $j->service_id,
|
||||
'name' => $j->name,
|
||||
'rate' => $j->rate,
|
||||
'work_date' => strftime($format[0]->date_format, $j->work_date),
|
||||
'work_date' => strftime($format[0]->date_format, $j->from_time),
|
||||
'from_time' => strftime('%H:%M', $j->from_time),
|
||||
'to_time' => strftime('%H:%M', $j->to_time)
|
||||
'from_time_unix' => $j->from_time,
|
||||
'from_time_js' => $j->from_time * 1000,
|
||||
'to_time' => strftime('%H:%M', $j->to_time),
|
||||
'to_time_unix' => $j->to_time,
|
||||
'to_time_js' => $j->to_time * 1000
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -853,10 +887,10 @@ class InvoiceController extends Controller {
|
|||
->where('inv_invoice_items.invoice_id', $id)
|
||||
->where('inv_invoice_items.user_id', $check)
|
||||
->get(array(
|
||||
'inv_services.id',
|
||||
'inv_invoice_items.id as id',
|
||||
'inv_services.id as service_id',
|
||||
'inv_services.name',
|
||||
'inv_services.rate',
|
||||
'inv_invoice_items.work_date',
|
||||
'inv_invoice_items.from_time',
|
||||
'inv_invoice_items.to_time'
|
||||
));
|
||||
|
@ -864,11 +898,16 @@ class InvoiceController extends Controller {
|
|||
foreach($items as $j) {
|
||||
$des[] = array(
|
||||
'id' => $j->id,
|
||||
'service_id' => $j->service_id,
|
||||
'name' => $j->name,
|
||||
'rate' => $j->rate,
|
||||
'work_date' => strftime($format[0]->date_format, $j->work_date),
|
||||
'work_date' => strftime($format[0]->date_format, $j->from_time),
|
||||
'from_time' => strftime('%H:%M', $j->from_time),
|
||||
'to_time' => strftime('%H:%M', $j->to_time)
|
||||
'from_time_unix' => $j->from_time,
|
||||
'from_time_js' => $j->from_time * 1000,
|
||||
'to_time' => strftime('%H:%M', $j->to_time),
|
||||
'to_time_js' => $j->to_time * 1000,
|
||||
'to_time_unix' => $j->to_time
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -918,7 +957,6 @@ class InvoiceController extends Controller {
|
|||
'user_id' => $request->user_id,
|
||||
'invoice_id' => $add,
|
||||
'service_id' => $request->service_id,
|
||||
'work_date' => $request->work_date,
|
||||
'from_time' => $request->from_time,
|
||||
'to_time' => $request->to_time
|
||||
]);
|
||||
|
@ -944,7 +982,6 @@ class InvoiceController extends Controller {
|
|||
'user_id' => $check,
|
||||
'invoice_id' => $add,
|
||||
'service_id' => $request->service_id,
|
||||
'work_date' => $request->work_date,
|
||||
'from_time' => $request->from_time,
|
||||
'to_time' => $request->to_time
|
||||
]);
|
||||
|
@ -958,6 +995,44 @@ class InvoiceController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function editInvoiceItem(Request $request) { // /api/rpc/invoice/invoices/edititem
|
||||
$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_makeinvoice'] == 1) {
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
DB::table('inv_invoice_items')
|
||||
->where('id', $request->id)
|
||||
->where('invoice_id', $request->inv)
|
||||
->update([
|
||||
'service_id' => $request->service_id,
|
||||
'from_time' => $request->from_time,
|
||||
'to_time' => $request->to_time
|
||||
]);
|
||||
}
|
||||
else {
|
||||
DB::table('inv_invoice_items')
|
||||
->where('id', $request->id)
|
||||
->where('user_id', $check)
|
||||
->where('invoice_id', $request->inv)
|
||||
->update([
|
||||
'service_id' => $request->service_id,
|
||||
'from_time' => $request->from_time,
|
||||
'to_time' => $request->to_time
|
||||
]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function editInvoice(Request $request) { // /api/rpc/invoice/invoices/edit
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
|
@ -970,7 +1045,7 @@ class InvoiceController extends Controller {
|
|||
if ($valid['inv_makeinvoice'] == 1) {
|
||||
$rev = DB::table('inv_invoices')
|
||||
->select('revision')
|
||||
->where('id', $id)
|
||||
->where('id', $request->id)
|
||||
->get();
|
||||
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
|
@ -982,15 +1057,6 @@ class InvoiceController extends Controller {
|
|||
'employer' => $request->employer,
|
||||
'revision' => $rev[0]->revision + 1
|
||||
]);
|
||||
|
||||
DB::table('inv_invoice_items')
|
||||
->where('id', $request->id)
|
||||
->update([
|
||||
'service_id' => $request->service_id,
|
||||
'work_date' => $request->work_date,
|
||||
'from_time' => $request->from_time,
|
||||
'to_time' => $request->to_time
|
||||
]);
|
||||
}
|
||||
else {
|
||||
DB::table('inv_invoices')
|
||||
|
@ -1001,16 +1067,6 @@ class InvoiceController extends Controller {
|
|||
'employer' => $request->employer,
|
||||
'revision' => $rev[0]->revision + 1
|
||||
]);
|
||||
|
||||
DB::table('inv_invoice_items')
|
||||
->where('id', $request->id)
|
||||
->where('user_id', $check)
|
||||
->update([
|
||||
'service_id' => $request->service_id,
|
||||
'work_date' => $request->work_date,
|
||||
'from_time' => $request->from_time,
|
||||
'to_time' => $request->to_time
|
||||
]);
|
||||
}
|
||||
|
||||
return 'Success!';
|
||||
|
|
|
@ -31,9 +31,12 @@ Route::get('/api/rpc/invoice/invoices/getinvoice/{id}', 'InvoiceController@getIn
|
|||
Route::get('/api/rpc/invoice/services/getservices', 'InvoiceController@getServices');
|
||||
Route::get('/api/rpc/invoice/services/getservice/{id}', 'InvoiceController@getService');
|
||||
|
||||
Route::post('/api/rpc/invoice/invoices/deleteitem', 'InvoiceController@deleteInvoiceItem');
|
||||
Route::post('/api/rpc/invoice/invoices/delete', 'InvoiceController@deleteInvoice');
|
||||
Route::post('/api/rpc/invoice/services/delete', 'InvoiceController@deleteService');
|
||||
Route::post('/api/rpc/invoice/invoices/edititem', 'InvoiceController@editInvoiceItem');
|
||||
Route::post('/api/rpc/invoice/invoices/edit', 'InvoiceController@editInvoice');
|
||||
Route::post('/api/rpc/invoice/services/edit', 'InvoiceController@editService');
|
||||
Route::post('/api/rpc/invoice/invoices/newitem', 'InvoiceController@newInvoiceItem');
|
||||
Route::post('/api/rpc/invoice/invoices/new', 'InvoiceController@newInvoice');
|
||||
Route::post('/api/rpc/invoice/services/new', 'InvoiceController@newService');
|
||||
|
|
新しいイシューから参照