update
This commit is contained in:
@@ -107,6 +107,18 @@ class BudgetControlController extends Controller
|
|||||||
'status' => 'Assigned',
|
'status' => 'Assigned',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
BudgetControlLog::create([
|
||||||
|
'cabang_id' => $cabang_id,
|
||||||
|
'sender_id' => auth()->user()->id,
|
||||||
|
'receiver_id' => $validated['receiver_id'],
|
||||||
|
'periode_month' => $validated['periode_month'],
|
||||||
|
'periode_year' => $validated['periode_year'],
|
||||||
|
'amount' => $validated['amount'],
|
||||||
|
'remarks' => $validated['remarks'],
|
||||||
|
'closing_at' => null,
|
||||||
|
'status' => 'Assigned',
|
||||||
|
]);
|
||||||
|
|
||||||
session()->flash('success', 'Budget has been added or updated successfully');
|
session()->flash('success', 'Budget has been added or updated successfully');
|
||||||
return redirect()->route('budget_control');
|
return redirect()->route('budget_control');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -631,7 +631,9 @@ class ReportController extends Controller
|
|||||||
$year = $params['year'];
|
$year = $params['year'];
|
||||||
$month = $params['month'];
|
$month = $params['month'];
|
||||||
|
|
||||||
|
// get last data
|
||||||
$budget = BudgetControlLog::where('cabang_id', $cabang->id)->where('periode_year', $year)->where('periode_month', $month)->orderBy('created_at', 'desc')->first();
|
$budget = BudgetControlLog::where('cabang_id', $cabang->id)->where('periode_year', $year)->where('periode_month', $month)->orderBy('created_at', 'desc')->first();
|
||||||
|
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
|
|
||||||
// Fetch all relevant forms in one batch
|
// Fetch all relevant forms in one batch
|
||||||
|
|||||||
@@ -65,7 +65,10 @@
|
|||||||
<option value="">Pilih Receiver</option>
|
<option value="">Pilih Receiver</option>
|
||||||
@foreach ($users as $receiver)
|
@foreach ($users as $receiver)
|
||||||
<option value="{{ $receiver->id }}" {{ old('receiver_id') == $receiver->id ? 'selected' : '' }}>
|
<option value="{{ $receiver->id }}" {{ old('receiver_id') == $receiver->id ? 'selected' : '' }}>
|
||||||
{{ $receiver->name }} ({{ $receiver->cabang->cabang->name }})
|
{{ $receiver->name }}
|
||||||
|
@if($receiver->cabang && $receiver->cabang->cabang)
|
||||||
|
({{ $receiver->cabang->cabang->name }})
|
||||||
|
@endif
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -124,8 +124,8 @@
|
|||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" class="text-right"><strong>Total</strong></td>
|
<td colspan="3" class="text-right"><strong>Total</strong></td>
|
||||||
<td>{{ number_format($totalDr, 0, ',', ',') }}</td>
|
<td>{{ number_format($totalDr, 0, ',', '.') }}</td>
|
||||||
<td>{{ number_format($totalCr, 0, ',', ',') }}</td>
|
<td>{{ number_format($totalCr, 0, ',', '.') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
@@ -151,12 +151,24 @@
|
|||||||
text: 'Export Excel',
|
text: 'Export Excel',
|
||||||
customize: function (xlsx) {
|
customize: function (xlsx) {
|
||||||
var sheet = xlsx.xl.worksheets['sheet1.xml'];
|
var sheet = xlsx.xl.worksheets['sheet1.xml'];
|
||||||
|
var styles = xlsx.xl['styles.xml'];
|
||||||
|
var cellXfs = $(styles).find('cellXfs');
|
||||||
|
|
||||||
// Add a blank row for spacing
|
// Add number format style for thousands separator
|
||||||
var blankRow = `<row><c t="inlineStr"><is><t></t></is></c></row>`;
|
var numFmtId = 3; // Built-in ID for thousands separator
|
||||||
|
var xfCount = cellXfs.children().length;
|
||||||
|
cellXfs.append(`
|
||||||
|
<xf numFmtId="${numFmtId}" xfId="0" applyNumberFormat="1">
|
||||||
|
<alignment horizontal="right"/>
|
||||||
|
</xf>
|
||||||
|
`);
|
||||||
|
var xfIndex = xfCount; // Index of the new style
|
||||||
|
|
||||||
// Bold text using Excel XML structure
|
// Add additional info and blank row
|
||||||
var additionalInfo = `
|
var sheetData = $(sheet).find('sheetData');
|
||||||
|
var existingRows = sheetData.children();
|
||||||
|
existingRows.last().after(`
|
||||||
|
<row><c t="inlineStr"><is><t></t></is></c></row>
|
||||||
<row>
|
<row>
|
||||||
<c t="inlineStr" s="2"><is><t>Cabang: {{ $cabang->name }}</t></is></c>
|
<c t="inlineStr" s="2"><is><t>Cabang: {{ $cabang->name }}</t></is></c>
|
||||||
</row>
|
</row>
|
||||||
@@ -166,28 +178,23 @@
|
|||||||
<row>
|
<row>
|
||||||
<c t="inlineStr" s="2"><is><t>Cost Centre: {{ $cabang->cost->code }}</t></is></c>
|
<c t="inlineStr" s="2"><is><t>Cost Centre: {{ $cabang->cost->code }}</t></is></c>
|
||||||
</row>
|
</row>
|
||||||
`;
|
|
||||||
|
|
||||||
// Locate the sheet data and append the blank row and additional information
|
|
||||||
var sheetData = $(sheet).find('sheetData');
|
|
||||||
var existingRows = sheetData.children();
|
|
||||||
existingRows.last().after(blankRow + additionalInfo);
|
|
||||||
|
|
||||||
// Add bold style to the sheet
|
|
||||||
var styles = xlsx.xl['styles.xml'];
|
|
||||||
var cellXfs = $(styles).find('cellXfs');
|
|
||||||
cellXfs.append(`
|
|
||||||
<xf xfId="0" applyFont="1">
|
|
||||||
<alignment horizontal="left"/>
|
|
||||||
<font>
|
|
||||||
<b/>
|
|
||||||
<sz val="11"/>
|
|
||||||
<name val="Calibri"/>
|
|
||||||
<family val="2"/>
|
|
||||||
</font>
|
|
||||||
</xf>
|
|
||||||
`);
|
`);
|
||||||
}
|
|
||||||
|
// Update total row with number formatting
|
||||||
|
var totalRow = sheetData.find("row:last");
|
||||||
|
var totalDr = {{ $totalDr }};
|
||||||
|
var totalCr = {{ $totalCr }};
|
||||||
|
|
||||||
|
totalRow.find("c:nth-child(4)").attr({
|
||||||
|
't': 'n', // Set type to number
|
||||||
|
's': xfIndex // Apply the thousands separator style
|
||||||
|
}).html('<v>' + totalDr + '</v>');
|
||||||
|
|
||||||
|
totalRow.find("c:nth-child(5)").attr({
|
||||||
|
't': 'n',
|
||||||
|
's': xfIndex
|
||||||
|
}).html('<v>' + totalCr + '</v>');
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
extend: 'csv',
|
extend: 'csv',
|
||||||
|
|||||||
Reference in New Issue
Block a user