View invoice works for services, periods, and products.

このコミットが含まれているのは:
テクニカル諏訪子 2018-06-06 06:15:22 +09:00
コミット e37936d9e4
1個のファイルの変更146行の追加16行の削除

ファイルの表示

@ -773,7 +773,9 @@ class InvoiceController extends Controller {
'year as year',
'inv_number as inv_number',
'revision as revision',
'make_date as make_date'
'make_date as make_date',
'invtype as invtype',
'tax_id as tax_id'
)
->where('id', $id)
->get();
@ -782,7 +784,9 @@ class InvoiceController extends Controller {
$cus = array();
$emp = array();
$com = array();
$des = array();
$desP = array();
$desR = array();
$desS = array();
$self = DB::table('inv_contacts')
->select('id', 'company_name', 'name', 'address', 'postcode', 'town', 'country', 'phone', 'website', 'email', 'custom')
@ -818,10 +822,69 @@ class InvoiceController extends Controller {
'invoice_year' => strftime('%Y', $invoice[0]->make_date),
'invoice_month' => strftime('%B', $invoice[0]->make_date),
'invoice_date' => strftime($format[0]->date_format, $invoice[0]->make_date),
'invoice' => $invoice[0]->year.$fin.($invoice[0]->revision > 0 ? '_R'.$invoice[0]->revision : '')
'invoice' => $invoice[0]->year.$fin.($invoice[0]->revision > 0 ? '_R'.$invoice[0]->revision : ''),
'invtype' => $invoice[0]->invtype
);
$items = DB::table('inv_invoice_items')
$itemsP = DB::table('inv_invoice_items')
->join('inv_periods', 'inv_periods.id', 'inv_invoice_items.period_id')
->where('inv_invoice_items.invoice_id', $id)
->where('inv_invoice_items.user_id', $u->user_id)
->get(array(
'inv_invoice_items.id as id',
'inv_periods.id as period_id',
'inv_periods.name',
'inv_periods.price',
'inv_invoice_items.from_time',
'inv_invoice_items.to_time'
));
foreach($itemsP as $j) {
$desP[] = array(
'id' => $j->id,
'period_id' => $j->period_id,
'name' => $j->name,
'price' => $j->price,
'work_date' => strftime($format[0]->date_format, $j->from_time),
'from_time' => strftime('%H:%M', $j->from_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
);
}
$itemsR = DB::table('inv_invoice_items')
->join('inv_products', 'inv_products.id', 'inv_invoice_items.product_id')
->where('inv_invoice_items.invoice_id', $id)
->where('inv_invoice_items.user_id', $u->user_id)
->get(array(
'inv_invoice_items.id as id',
'inv_products.id as product_id',
'inv_products.name',
'inv_products.price',
'inv_invoice_items.from_time',
'inv_invoice_items.to_time'
));
foreach($itemsR as $j) {
$desR[] = array(
'id' => $j->id,
'product_id' => $j->product_id,
'name' => $j->name,
'price' => $j->price,
'work_date' => strftime($format[0]->date_format, $j->from_time),
'from_time' => strftime('%H:%M', $j->from_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
);
}
$itemsS = 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', $u->user_id)
@ -834,8 +897,8 @@ class InvoiceController extends Controller {
'inv_invoice_items.to_time'
));
foreach($items as $j) {
$des[] = array(
foreach($itemsS as $j) {
$desS[] = array(
'id' => $j->id,
'service_id' => $j->service_id,
'name' => $j->name,
@ -856,7 +919,9 @@ class InvoiceController extends Controller {
'company' => $com,
'employer' => $emp,
'customer' => $cus,
'items' => $des
'periods' => $desP,
'products' => $desR,
'services' => $desS
);
}
else {
@ -874,7 +939,9 @@ class InvoiceController extends Controller {
'year as year',
'inv_number as inv_number',
'revision as revision',
'make_date as make_date'
'make_date as make_date',
'invtype as invtype',
'tax_id as tax_id'
)
->where('id', $id)
->where('user_id', $check)
@ -884,7 +951,9 @@ class InvoiceController extends Controller {
$cus = array();
$emp = array();
$com = array();
$des = array();
$desP = array();
$desR = array();
$desS = array();
$self = DB::table('inv_contacts')
->select('id', 'company_name', 'name', 'address', 'postcode', 'town', 'country', 'phone', 'website', 'email', 'custom')
@ -920,10 +989,69 @@ class InvoiceController extends Controller {
'invoice_year' => strftime('%Y', $invoice[0]->make_date),
'invoice_month' => strftime('%B', $invoice[0]->make_date),
'invoice_date' => strftime($format[0]->date_format, $invoice[0]->make_date),
'invoice' => $invoice[0]->year.$fin.($invoice[0]->revision > 0 ? '_R'.$invoice[0]->revision : '')
'invoice' => $invoice[0]->year.$fin.($invoice[0]->revision > 0 ? '_R'.$invoice[0]->revision : ''),
'invtype' => $invoice[0]->invtype
);
$items = DB::table('inv_invoice_items')
$itemsP = DB::table('inv_invoice_items')
->join('inv_periods', 'inv_periods.id', 'inv_invoice_items.period_id')
->where('inv_invoice_items.invoice_id', $id)
->where('inv_invoice_items.user_id', $check)
->get(array(
'inv_invoice_items.id as id',
'inv_periods.id as period_id',
'inv_periods.name',
'inv_periods.price',
'inv_invoice_items.from_time',
'inv_invoice_items.to_time'
));
foreach($itemsP as $j) {
$desP[] = array(
'id' => $j->id,
'period_id' => $j->period_id,
'name' => $j->name,
'price' => $j->price,
'work_date' => strftime($format[0]->date_format, $j->from_time),
'from_time' => strftime('%H:%M', $j->from_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
);
}
$itemsR = DB::table('inv_invoice_items')
->join('inv_products', 'inv_products.id', 'inv_invoice_items.product_id')
->where('inv_invoice_items.invoice_id', $id)
->where('inv_invoice_items.user_id', $check)
->get(array(
'inv_invoice_items.id as id',
'inv_products.id as product_id',
'inv_products.name',
'inv_products.price',
'inv_invoice_items.from_time',
'inv_invoice_items.to_time'
));
foreach($itemsR as $j) {
$desR[] = array(
'id' => $j->id,
'product_id' => $j->product_id,
'name' => $j->name,
'price' => $j->price,
'work_date' => strftime($format[0]->date_format, $j->from_time),
'from_time' => strftime('%H:%M', $j->from_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
);
}
$itemsS = 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)
@ -936,8 +1064,8 @@ class InvoiceController extends Controller {
'inv_invoice_items.to_time'
));
foreach($items as $j) {
$des[] = array(
foreach($itemsS as $j) {
$desS[] = array(
'id' => $j->id,
'service_id' => $j->service_id,
'name' => $j->name,
@ -947,8 +1075,8 @@ class InvoiceController extends Controller {
'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
'to_time_unix' => $j->to_time,
'to_time_js' => $j->to_time * 1000
);
}
@ -958,7 +1086,9 @@ class InvoiceController extends Controller {
'company' => $com,
'employer' => $emp,
'customer' => $cus,
'items' => $des
'periods' => $desP,
'products' => $desR,
'services' => $desS
);
}
}