Skip to content

Commit c936fb2

Browse files
committed
working onproject detail
1 parent f0079cc commit c936fb2

File tree

6 files changed

+157
-48
lines changed

6 files changed

+157
-48
lines changed

database/custom_sql/data.sql

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ INSERT INTO `realestate`.`prop_attrib_details`(`propAttributeDetail`) VALUES ('T
77

88
INSERT INTO `realestate`.`property_types`(`propertyType`) VALUES ('House'),('Villa'),('Land'),('Condo'),('Office');
99

10+
INSERT INTO `realestate`.`partner_types`(`partnerType`) VALUES ('Company');
11+
12+
INSERT INTO `realestate`.`partners`(`partner`, `address`, `phone`, `email`, `partnerTypeId`) VALUES ('Angkor Realty', 'Phnom Penh', '012112121', 'email@yahoo.com', 1)
13+
14+
INSERT INTO `realestate`.`prop_attributes`(`propAttribute`) VALUES ('Title:Hard,Bedroom:1,Bathroom:1,Face:North');
1015

1116

1217
-- INSERT INTO `companies`(`CompanyName`, `description`, `tel`, `address`, `email`, `logo`, `created_at`) VALUES ('SO1.7', 'Real Estate', '012606645', 'Phnom Penh', 'so17@gmail.com', 'logo.png', '2019-08-05 19:26:54');

public/admin/css/style.css

+16-4
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,23 @@ svg[class*="fa"] {
5050
color: #999; }
5151

5252
.summary {
53-
position: fixed;
54-
z-index: 1;
55-
top: 65px; }
53+
display: -webkit-inline-box;
54+
display: -ms-inline-flexbox;
55+
display: inline-flex;
56+
width: 70%; }
57+
.summary div {
58+
margin-right: 15%;
59+
display: block;
60+
font-weight: 600; }
61+
62+
.selected-row {
63+
background-color: #00C0EF;
64+
color: black; }
65+
66+
.detail-row {
67+
cursor: pointer; }
5668

57-
.my-pT-summary {
69+
.primary .my-pT-summary {
5870
padding-top: 105px; }
5971

6072
.form-control.select2 .select2-container--classic,

public/admin/js/script.js

+88-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ $(function() {
3737

3838
$('[data-toggle="tooltip"]').tooltip();
3939
const stringPattern = /^(\w+\s)*\w+$/;
40-
const numberPattern = /^[0-9]{1,}$/;
40+
const numberPattern = /^\d*\.?\d*$/;
41+
42+
let hasError = false;
4143

4244
$('form#detail').submit(e => {
4345
e.preventDefault();
@@ -54,10 +56,10 @@ $(function() {
5456
if (stringPattern.test(val.trim())) {
5557
$(parent).removeClass('has-error');
5658
nextElement.innerText = '';
57-
console.log('error');
5859
} else {
5960
nextElement.innerText = $(item).attr('alt');
6061
$(parent).addClass('has-error');
62+
hasError = true;
6163
}
6264
});
6365

@@ -66,7 +68,7 @@ $(function() {
6668
inputNumber.forEach(item => {
6769
const nextElement = item.nextElementSibling;
6870
const parent = item.parentElement;
69-
const itemId = `${$(inputText).attr('id')}`;
71+
const itemId = `${$(inputNumber).attr('id')}`;
7072

7173
const val = document.getElementById(itemId).value;
7274

@@ -76,12 +78,95 @@ $(function() {
7678
} else {
7779
nextElement.innerText = $(item).attr('alt');
7880
$(parent).addClass('has-error');
81+
hasError = true;
7982
}
8083
});
84+
85+
if (!hasError) {
86+
addProjectDetail();
87+
}
8188
});
8289

90+
let currentRowIndex = -1;
91+
92+
const tableProjectDetail = this.querySelector('#table-project-detail');
93+
94+
tableProjectDetail.addEventListener('click', e => {
95+
parentTag = $(e.target).parent();
96+
97+
console.log(parentTag);
98+
99+
if (
100+
parentTag.prop('tagName') == 'TR' &&
101+
!parentTag.hasClass('tr-heading')
102+
) {
103+
const lastRow = `#table-project-detail tr[alt=${currentRowIndex}]`;
104+
console.log(lastRow);
105+
106+
$(lastRow).removeClass('selected-row');
107+
108+
$(tableProjectDetail);
109+
110+
currentRowIndex = $(e.target)
111+
.parent()
112+
.attr('alt');
113+
$(e.target)
114+
.parent()
115+
.addClass('selected-row');
116+
}
117+
});
118+
119+
$('#table-project-detail').click(e => {});
120+
83121
$('.select2').select2({
84122
theme: 'classic',
85123
width: 'resolve',
86124
});
125+
126+
/* Add property detail to project */
87127
});
128+
129+
function addProjectDetail() {
130+
const type = document.querySelector('#propertyType');
131+
const code = document.querySelector('#code');
132+
const description = document.querySelector('#description');
133+
const no = document.querySelector('#no');
134+
const st = document.querySelector('#st');
135+
const propAttribute = $('#attribute').select2('data')[0].text;
136+
const cost = document.querySelector('#cost');
137+
const price = document.querySelector('#price');
138+
const free = document.querySelector('#free');
139+
const publish = document.querySelector('#publish');
140+
141+
const stType = document.querySelector(
142+
`#propertyType option[value="${type.value}"]`
143+
).innerText;
144+
const stPublish = document.querySelector(
145+
`#publish option[value="${type.value}"]`
146+
).innerText;
147+
148+
const rowCount = $('#table-project-detail td').closest('tr').length + 1;
149+
150+
const row = `<tr class="detail-row" alt=${rowCount - 1}><td>${rowCount}</td>
151+
<td><div alt='${type.value}'></div>${stType}</td>
152+
<td>${code.value}</td>
153+
<td>${description.value}</td>
154+
<td>${no.value}</td>
155+
<td>${st.value}</td>
156+
<td>${propAttribute}</td>
157+
<td>${cost.value}</td>
158+
<td>${price.value}</td>
159+
<td>${free.value}</td>
160+
<td><div alt='${publish.value}'></div>${stPublish}</td>
161+
`;
162+
163+
$('#project-detail-body').append(row);
164+
165+
const tCost = Number($('#tCost').text()) + Number(cost.value);
166+
167+
const tPrice = Number($('#tPrice').text()) + Number(price.value);
168+
169+
$('#tCount').text(rowCount);
170+
$('#tCost').text(tCost);
171+
$('#tPrice').text(tPrice);
172+
}

public/admin/scss/style.scss

+26-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
$primary-color:#00C0EF;
2+
13
/*datatable*/
24

35
table {
@@ -84,14 +86,34 @@ svg[class*="fa"] {
8486

8587
.summary {
8688

87-
position: fixed;
88-
z-index: 1;
89+
// position: fixed;
90+
// z-index: 1;
91+
92+
// top: 65px;
93+
94+
display: inline-flex;
95+
width: 70%;
8996

90-
top: 65px;
9197

98+
div {
99+
margin-right: 15%;
100+
display: block;
101+
font-weight: 600;
102+
}
92103
}
93104

94-
.my-pT-summary {
105+
.selected-row {
106+
background-color: $primary-color;
107+
108+
color: black;
109+
}
110+
111+
.detail-row {
112+
cursor: pointer;
113+
}
114+
115+
116+
.primary .my-pT-summary {
95117
padding-top: 105px
96118
}
97119

resources/views/admin/project/create.blade.php

+22-25
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242

4343

44-
<label>Type</label>
44+
<label>Partner</label>
4545
<select class="form-control select2" name="partner">
4646

4747
<?php
@@ -89,7 +89,7 @@
8989
{{-- Type --}}
9090

9191
<label>Type</label>
92-
<select class="form-control" name="type">
92+
<select class="form-control" name="type" id="propertyType">
9393

9494
<?php
9595
foreach ($propertyType as $item) {
@@ -143,14 +143,14 @@
143143
{{-- Props Attribute --}}
144144

145145
<div class="form-group w-50">
146-
<label>Type</label>
147-
<select class="form-control" name="Attribute" id="attribute">
146+
<label>Property Attribute</label>
147+
<select class="form-control select2" name="Attribute" id="attribute">
148148

149149
<?php
150-
foreach ($propAttribute as $item) {
151-
echo('<option value='.$item->propAttributeID.'>'.$item->propAttribute.'</option>');
152-
}
153-
?>
150+
foreach ($propAttribute as $item) {
151+
echo('<option value='.$item->propAttributeID.'>'.$item->propAttribute.'</option>');
152+
}
153+
?>
154154

155155
</select>
156156
</div>
@@ -214,39 +214,36 @@
214214

215215

216216

217+
<div class="callout callout-info summary">
218+
219+
<div>Count: <span id="tCount">0</span></div>
220+
<div>Cost: <span id="tCost">0</span></div>
221+
<div>Price: <span id="tPrice">0</span></div>
222+
</div>
223+
224+
217225

218226

219227
<div class="form-group">
220-
<table class="table table-hover">
228+
<table class="table table-hover" id="table-project-detail">
221229
<thead>
222-
<tr>
230+
<tr class="tr-heading">
223231
<th>#</th>
224232
<th>Type</th>
225233
<th>Code</th>
226234
<th>Description</th>
227235
<th>No</th>
228236
<th>St</th>
237+
<th>Property Attribute</th>
229238
<th>Cost</th>
230239
<th>Price</th>
231240
<th>Free</th>
232-
<th>Status</th>
233241
<th>Publish</th>
234242
</tr>
235243
</thead>
236-
<tbody>
237-
238-
239-
{{-- @foreach ($user as $u)
240-
<tr>
241-
<td>{{$loop->iteration}}</td>
242-
<td>{{$u->username}}</td>
243-
<td>{{$u->name}}</td>
244-
<td>{{$u->role}}</td>
245-
<td>{{$u->status}}</td>
246-
<td><a href="{{url('/system/editUser')}}"><i class="fa fa-edit"></i></a>
247-
<a href="{{url('/system/editUser')}}"><i class="fa fa-trash"></i></a></td>
248-
</tr>
249-
@endforeach --}}
244+
<tbody id="project-detail-body">
245+
246+
250247

251248

252249
</tbody>

resources/views/admin/project/index.blade.php

-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@section('content')
88

99

10-
1110
<table class="table table-hover dataTable">
1211

1312
<thead>
@@ -26,17 +25,6 @@
2625
<tbody>
2726

2827

29-
{{-- @foreach ($user as $u)
30-
<tr>
31-
<td>{{$loop->iteration}}</td>
32-
<td>{{$u->username}}</td>
33-
<td>{{$u->name}}</td>
34-
<td>{{$u->role}}</td>
35-
<td>{{$u->status}}</td>
36-
<td><a href="{{url('/system/editUser')}}"><i class="fa fa-edit"></i></a>
37-
<a href="{{url('/system/editUser')}}"><i class="fa fa-trash"></i></a></td>
38-
</tr>
39-
@endforeach --}}
4028

4129

4230
</tbody>

0 commit comments

Comments
 (0)