And for the not admin users.
このコミットが含まれているのは:
コミット
2e75242d8f
|
@ -758,78 +758,86 @@ class InvoiceController extends Controller {
|
|||
->get();
|
||||
|
||||
$invoice = DB::table('inv_invoices')
|
||||
->join('inv_invoice_items', 'inv_invoice_items.invoice_id', 'inv_invoices.id')
|
||||
->where('inv_invoices.id', $id)
|
||||
->select(
|
||||
'id as id',
|
||||
'user_id as user_id',
|
||||
'employer as employer',
|
||||
'customer as customer',
|
||||
'year as year',
|
||||
'inv_number as inv_number',
|
||||
'revision as revision',
|
||||
'make_date as make_date'
|
||||
)
|
||||
->where('id', $id)
|
||||
->where('user_id', $check)
|
||||
->get(array(
|
||||
'inv_invoices.id as id',
|
||||
'inv_invoices.user_id as user_id',
|
||||
'inv_invoices.employer as employer',
|
||||
'inv_invoices.customer as customer',
|
||||
'inv_invoices.year as year',
|
||||
'inv_invoices.inv_number as inv_number',
|
||||
'inv_invoices.revision as revision',
|
||||
'inv_invoices.make_date as make_date'
|
||||
));
|
||||
->get();
|
||||
|
||||
$res = array();
|
||||
$inv = array();
|
||||
$cus = array();
|
||||
$emp = array();
|
||||
$com = array();
|
||||
$des = array();
|
||||
|
||||
foreach($invoice as $i) {
|
||||
$customer = DB::table('inv_contacts')
|
||||
->select('id', 'company_name', 'name', 'address', 'postcode', 'town', 'country', 'phone', 'email')
|
||||
->where('id', $i->customer)
|
||||
->where('inv_invoice_items.user_id', $check)
|
||||
->get();
|
||||
$cus = DB::table('inv_contacts')
|
||||
->select('id', 'company_name', 'name', 'address', 'postcode', 'town', 'country', 'phone', 'email')
|
||||
->where('id', $invoice[0]->customer)
|
||||
->where('user_id', $check)
|
||||
->get();
|
||||
|
||||
$employer = DB::table('inv_contacts')
|
||||
->select('id', 'company_name', 'name', 'address', 'postcode', 'town', 'country', 'phone', 'email')
|
||||
->where('id', $i->employer)
|
||||
->where('inv_invoice_items.user_id', $check)
|
||||
->get();
|
||||
$emp = DB::table('inv_contacts')
|
||||
->select('id', 'company_name', 'name', 'address', 'postcode', 'town', 'country', 'phone', 'email')
|
||||
->where('id', $invoice[0]->employer)
|
||||
->where('user_id', $check)
|
||||
->get();
|
||||
|
||||
$items = DB::table('inv_invoice_items')
|
||||
->join('inv_services', 'inv_services.id', 'inv_invoice_items.service_id')
|
||||
->where('inv_invoice_items.invoice_id', $id)
|
||||
->where('inv_invoice_items.user_id', $check)
|
||||
->get(
|
||||
'inv_services.id',
|
||||
'inv_services.name',
|
||||
'inv_services.rate',
|
||||
'inv_invoice_items.work_date',
|
||||
'inv_invoice_items.from_time',
|
||||
'inv_invoice_items.to_time'
|
||||
);
|
||||
$com = DB::table('inv_company')
|
||||
->select('id', 'name', 'compreg', 'taxnr', 'bank_number', 'bank_name', 'bank_recipient', 'logo', 'payterm')
|
||||
->where('user_id', $check)
|
||||
->get();
|
||||
|
||||
$company = DB::table('inv_company')
|
||||
->select('id', 'name', 'compreg', 'taxnr', 'bank_number', 'bank_name', 'bank_recipient', 'logo', 'payterm')
|
||||
->where('user_id', $check)
|
||||
->get();
|
||||
$zero = '0000';
|
||||
$len = strlen($invoice[0]->inv_number);
|
||||
$num = substr($zero, $len);
|
||||
$fin = $num.$invoice[0]->inv_number;
|
||||
|
||||
foreach($items as $j) {
|
||||
$des[] = array(
|
||||
'id' => $j->id,
|
||||
'name' => $j->name,
|
||||
'rate' => $j->rate,
|
||||
'work_date' => $j->work_date,
|
||||
'from_time' => $j->from_time,
|
||||
'to_time' => $j->to_time
|
||||
);
|
||||
}
|
||||
$inv[] = array(
|
||||
'id' => $id,
|
||||
'user_id' => $u->user_id,
|
||||
'invoice_date' => strftime($format[0]->date_format, $invoice[0]->make_date),
|
||||
'invoice' => $invoice[0]->year.$fin.($invoice[0]->revision > 0 ? '_R'.$invoice[0]->revision : '')
|
||||
);
|
||||
|
||||
$res[] = array(
|
||||
'id' => $id,
|
||||
'user_id' => $check,
|
||||
'employer' => $employer,
|
||||
'customer' => $customer,
|
||||
'company' => $company,
|
||||
'invoice_date' => $i->make_date,
|
||||
'invoice' => $i->year.$i->inv_number.($i->revision > 0 ? '_R'.$i->revision : ''),
|
||||
'items' => $des,
|
||||
$items = DB::table('inv_invoice_items')
|
||||
->join('inv_services', 'inv_services.id', 'inv_invoice_items.service_id')
|
||||
->where('inv_invoice_items.invoice_id', $id)
|
||||
->where('inv_invoice_items.user_id', $check)
|
||||
->get(array(
|
||||
'inv_services.id',
|
||||
'inv_services.name',
|
||||
'inv_services.rate',
|
||||
'inv_invoice_items.work_date',
|
||||
'inv_invoice_items.from_time',
|
||||
'inv_invoice_items.to_time'
|
||||
));
|
||||
|
||||
foreach($items as $j) {
|
||||
$des[] = array(
|
||||
'id' => $j->id,
|
||||
'name' => $j->name,
|
||||
'rate' => $j->rate,
|
||||
'work_date' => strftime($format[0]->date_format, $j->work_date),
|
||||
'from_time' => strftime('%H:%M', $j->from_time),
|
||||
'to_time' => strftime('%H:%M', $j->to_time)
|
||||
);
|
||||
}
|
||||
|
||||
return $res;
|
||||
return array(
|
||||
'invoice' => $inv,
|
||||
'company' => $com,
|
||||
'employer' => $emp,
|
||||
'customer' => $cus,
|
||||
'items' => $des
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
新しいイシューから参照