Skip to content

Commit 84a531d

Browse files
authored
Merge pull request #18 from qodrorid/develop
Develop
2 parents 2d46fce + 4acfb18 commit 84a531d

File tree

6 files changed

+69
-3
lines changed

6 files changed

+69
-3
lines changed

app/Http/Controllers/RabController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function index(Request $request)
3434
$view = $request->ajax() ? 'list' : 'index';
3535
$disable = ($parent && $parent->month !== date('F') and $parent->month !== now()->addMonth('1')->format('F')) ? true : false;
3636

37-
return view('pages.rab.' . $view, compact('rab', 'disable'));
37+
return view('pages.rab.' . $view, compact('rab', 'disable', 'parent'));
3838
}
3939

4040
/**
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
5+
class CreateTriggerCountAfterInsert extends Migration
6+
{
7+
/**
8+
* Run the migrations.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
DB::unprepared('CREATE TRIGGER `count_after_insert` AFTER INSERT ON `rab_details` FOR EACH ROW BEGIN set @total =(SELECT SUM(`total`) FROM `rab_details` WHERE `rab_id` = new.rab_id); UPDATE `rabs` SET `total` = @total WHERE `id` = new.rab_id; END');
15+
}
16+
17+
/**
18+
* Reverse the migrations.
19+
*
20+
* @return void
21+
*/
22+
public function down()
23+
{
24+
DB::unprepared('DROP TRIGGER `count_after_insert`');
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
5+
class CreateTriggerCountAfterUpdate extends Migration
6+
{
7+
/**
8+
* Run the migrations.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
DB::unprepared('CREATE TRIGGER `count_after_update` AFTER UPDATE ON `rab_details` FOR EACH ROW BEGIN set @total =(SELECT SUM(`total`) FROM `rab_details` WHERE `rab_id` = old.rab_id); UPDATE `rabs` SET `total` = @total WHERE `id` = old.rab_id; END');
15+
}
16+
17+
/**
18+
* Reverse the migrations.
19+
*
20+
* @return void
21+
*/
22+
public function down()
23+
{
24+
DB::unprepared('DROP TRIGGER `count_after_update`');
25+
}
26+
}

public/js/pages/rab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function addRow() {
4343
}
4444

4545
if (typeof $('#listitem > tr.add-row, #listitem > tr.edit-row, #listitem > tr.disabled-row').html() === 'undefined') {
46-
$('tbody#listitem').append(row)
46+
$('tbody#listitem > tr:last').before(row)
4747
$('#listitem #for').focus()
4848
$('#listitem #price').autoNumeric({
4949
anDefault: 0,

resources/views/pages/rab/index.blade.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@
8181
</td>
8282
</tr>
8383
@endforeach
84+
<tr>
85+
<td colspan="4" align="center">
86+
<b>TOTAL</b>
87+
</td>
88+
<td align="right"><b>{!! !empty($parent->total) ? HelperView::currency($parent->total) : HelperView::currency(0) !!}</b></td>
89+
<td></td>
90+
</tr>
8491
</tbody>
8592
</table>
8693
</div>

resources/views/pages/rab/list.blade.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,11 @@
1616
@endif
1717
</td>
1818
</tr>
19-
@endforeach
19+
@endforeach
20+
<tr>
21+
<td colspan="4" align="center">
22+
<b>TOTAL</b>
23+
</td>
24+
<td align="right"><b>{!! !empty($parent->total) ? HelperView::currency($parent->total) : HelperView::currency(0) !!}</b></td>
25+
<td></td>
26+
</tr>

0 commit comments

Comments
 (0)