Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sai Srinivas
GEN_ERP_2025
Commits
d006edb4
Commit
d006edb4
authored
Jun 18, 2025
by
Sai Srinivas
Browse files
18-06-2025 By Sai Srinivas
Pubspec, Order Module Add and Edit.
parent
b06467c3
Changes
27
Hide whitespace changes
Inline
Side-by-side
assets/svg/ic_edit.svg
0 → 100644
View file @
d006edb4
<svg
width=
"21"
height=
"21"
viewBox=
"0 0 21 21"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M17.9784 7.57059L15.5616 9.99559L7.80344 17.7456C7.54361 18.0033 7.20735 18.1699 6.84495 18.2206L3.99501 18.6289C3.91482 18.6389 3.83415 18.6445 3.75335 18.6456C3.5114 18.6435 3.27266 18.5899 3.05301 18.4885C2.83335 18.387 2.63781 18.24 2.47937 18.0571C2.32094 17.8742 2.20323 17.6597 2.13409 17.4278C2.06495 17.196 2.04594 16.952 2.07835 16.7123L2.48668 13.8623C2.53736 13.4999 2.70403 13.1637 2.96174 12.9039L10.7201 5.15393L13.1366 2.72893C13.6253 2.26351 14.2743 2.00391 14.9492 2.00391C15.624 2.00391 16.273 2.26351 16.7617 2.72893L17.9784 3.94559C18.4586 4.42655 18.7283 5.07843 18.7283 5.75809C18.7283 6.43776 18.4586 7.08964 17.9784 7.57059Z"
fill=
"#37D0EE"
/>
<path
d=
"M17.9785 7.57059L16.0827 9.47454L11.2412 4.63287L13.1367 2.72893C13.6254 2.26351 14.2744 2.00391 14.9493 2.00391C15.6241 2.00391 16.2731 2.26351 16.7618 2.72893L17.9785 3.94559C18.4587 4.42655 18.7284 5.07843 18.7284 5.75809C18.7284 6.43776 18.4587 7.08964 17.9785 7.57059Z"
fill=
"#FFCE29"
/>
</svg>
lib/Models/ordersModels/AddOrderViewResponse.dart
0 → 100644
View file @
d006edb4
class
AddOrderViewResponse
{
List
<
Employees
>?
employees
;
List
<
States
>?
states
;
List
<
SaleProducts
>?
saleProducts
;
List
<
String
>?
unloadingScope
;
List
<
String
>?
freightScope
;
List
<
String
>?
erectionScope
;
String
?
error
;
String
?
message
;
AddOrderViewResponse
(
{
this
.
employees
,
this
.
states
,
this
.
saleProducts
,
this
.
unloadingScope
,
this
.
freightScope
,
this
.
erectionScope
,
this
.
error
,
this
.
message
});
AddOrderViewResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'employees'
]
!=
null
)
{
employees
=
<
Employees
>[];
json
[
'employees'
].
forEach
((
v
)
{
employees
!.
add
(
new
Employees
.
fromJson
(
v
));
});
}
if
(
json
[
'states'
]
!=
null
)
{
states
=
<
States
>[];
json
[
'states'
].
forEach
((
v
)
{
states
!.
add
(
new
States
.
fromJson
(
v
));
});
}
if
(
json
[
'sale_products'
]
!=
null
)
{
saleProducts
=
<
SaleProducts
>[];
json
[
'sale_products'
].
forEach
((
v
)
{
saleProducts
!.
add
(
new
SaleProducts
.
fromJson
(
v
));
});
}
unloadingScope
=
json
[
'unloading_scope'
].
cast
<
String
>();
freightScope
=
json
[
'freight_scope'
].
cast
<
String
>();
erectionScope
=
json
[
'erection_scope'
].
cast
<
String
>();
error
=
json
[
'error'
];
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
employees
!=
null
)
{
data
[
'employees'
]
=
this
.
employees
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
if
(
this
.
states
!=
null
)
{
data
[
'states'
]
=
this
.
states
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
if
(
this
.
saleProducts
!=
null
)
{
data
[
'sale_products'
]
=
this
.
saleProducts
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
data
[
'unloading_scope'
]
=
this
.
unloadingScope
;
data
[
'freight_scope'
]
=
this
.
freightScope
;
data
[
'erection_scope'
]
=
this
.
erectionScope
;
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
Employees
{
String
?
id
;
String
?
name
;
Employees
({
this
.
id
,
this
.
name
});
Employees
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
return
data
;
}
}
class
SaleProducts
{
String
?
id
;
String
?
productCode
;
String
?
project
;
String
?
subGroup
;
String
?
vendor1
;
String
?
vendor2
;
String
?
vendorCode
;
String
?
prodName
;
String
?
brand
;
String
?
imageDirFilePath
;
String
?
imageViewFileName
;
String
?
prodDesc
;
String
?
hsnCode
;
String
?
units
;
String
?
unitsId
;
String
?
worksMsl
;
String
?
refType
;
String
?
refId
;
String
?
price
;
String
?
type
;
String
?
productionProcessId
;
String
?
createdBy
;
String
?
datetime
;
String
?
isExists
;
String
?
updatedDatetime
;
SaleProducts
(
{
this
.
id
,
this
.
productCode
,
this
.
project
,
this
.
subGroup
,
this
.
vendor1
,
this
.
vendor2
,
this
.
vendorCode
,
this
.
prodName
,
this
.
brand
,
this
.
imageDirFilePath
,
this
.
imageViewFileName
,
this
.
prodDesc
,
this
.
hsnCode
,
this
.
units
,
this
.
unitsId
,
this
.
worksMsl
,
this
.
refType
,
this
.
refId
,
this
.
price
,
this
.
type
,
this
.
productionProcessId
,
this
.
createdBy
,
this
.
datetime
,
this
.
isExists
,
this
.
updatedDatetime
});
SaleProducts
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
productCode
=
json
[
'product_code'
];
project
=
json
[
'project'
];
subGroup
=
json
[
'sub_group'
];
vendor1
=
json
[
'vendor_1'
];
vendor2
=
json
[
'vendor_2'
];
vendorCode
=
json
[
'vendor_code'
];
prodName
=
json
[
'prod_name'
];
brand
=
json
[
'brand'
];
imageDirFilePath
=
json
[
'image_dir_file_path'
];
imageViewFileName
=
json
[
'image_view_file_name'
];
prodDesc
=
json
[
'prod_desc'
];
hsnCode
=
json
[
'hsn_code'
];
units
=
json
[
'units'
];
unitsId
=
json
[
'units_id'
];
worksMsl
=
json
[
'works_msl'
];
refType
=
json
[
'ref_type'
];
refId
=
json
[
'ref_id'
];
price
=
json
[
'price'
];
type
=
json
[
'type'
];
productionProcessId
=
json
[
'production_process_id'
];
createdBy
=
json
[
'created_by'
];
datetime
=
json
[
'datetime'
];
isExists
=
json
[
'is_exists'
];
updatedDatetime
=
json
[
'updated_datetime'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'product_code'
]
=
this
.
productCode
;
data
[
'project'
]
=
this
.
project
;
data
[
'sub_group'
]
=
this
.
subGroup
;
data
[
'vendor_1'
]
=
this
.
vendor1
;
data
[
'vendor_2'
]
=
this
.
vendor2
;
data
[
'vendor_code'
]
=
this
.
vendorCode
;
data
[
'prod_name'
]
=
this
.
prodName
;
data
[
'brand'
]
=
this
.
brand
;
data
[
'image_dir_file_path'
]
=
this
.
imageDirFilePath
;
data
[
'image_view_file_name'
]
=
this
.
imageViewFileName
;
data
[
'prod_desc'
]
=
this
.
prodDesc
;
data
[
'hsn_code'
]
=
this
.
hsnCode
;
data
[
'units'
]
=
this
.
units
;
data
[
'units_id'
]
=
this
.
unitsId
;
data
[
'works_msl'
]
=
this
.
worksMsl
;
data
[
'ref_type'
]
=
this
.
refType
;
data
[
'ref_id'
]
=
this
.
refId
;
data
[
'price'
]
=
this
.
price
;
data
[
'type'
]
=
this
.
type
;
data
[
'production_process_id'
]
=
this
.
productionProcessId
;
data
[
'created_by'
]
=
this
.
createdBy
;
data
[
'datetime'
]
=
this
.
datetime
;
data
[
'is_exists'
]
=
this
.
isExists
;
data
[
'updated_datetime'
]
=
this
.
updatedDatetime
;
return
data
;
}
}
class
States
{
String
?
id
;
String
?
name
;
States
({
this
.
id
,
this
.
name
});
States
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
return
data
;
}
}
\ No newline at end of file
lib/Models/ordersModels/addOrderAccontDetailsResponse.dart
0 → 100644
View file @
d006edb4
class
addOrderAccontDetailsResponse
{
AccountDetails
?
accountDetails
;
String
?
error
;
String
?
message
;
addOrderAccontDetailsResponse
(
{
this
.
accountDetails
,
this
.
error
,
this
.
message
});
addOrderAccontDetailsResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
accountDetails
=
json
[
'account_details'
]
!=
null
?
new
AccountDetails
.
fromJson
(
json
[
'account_details'
])
:
null
;
error
=
json
[
'error'
];
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
accountDetails
!=
null
)
{
data
[
'account_details'
]
=
this
.
accountDetails
!.
toJson
();
}
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
AccountDetails
{
String
?
id
;
String
?
tempId
;
String
?
ownerId
;
String
?
accManagerId
;
String
?
name
;
String
?
salutationName
;
String
?
subLocality
;
String
?
district
;
String
?
state
;
String
?
pincode
;
String
?
address
;
String
?
date
;
String
?
source
;
String
?
reference
;
String
?
segment
;
String
?
team
;
String
?
gstNumber
;
String
?
isExists
;
String
?
createdDatetime
;
String
?
updatedDatetime
;
AccountDetails
(
{
this
.
id
,
this
.
tempId
,
this
.
ownerId
,
this
.
accManagerId
,
this
.
name
,
this
.
salutationName
,
this
.
subLocality
,
this
.
district
,
this
.
state
,
this
.
pincode
,
this
.
address
,
this
.
date
,
this
.
source
,
this
.
reference
,
this
.
segment
,
this
.
team
,
this
.
gstNumber
,
this
.
isExists
,
this
.
createdDatetime
,
this
.
updatedDatetime
});
AccountDetails
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
tempId
=
json
[
'temp_id'
];
ownerId
=
json
[
'owner_id'
];
accManagerId
=
json
[
'acc_manager_id'
];
name
=
json
[
'name'
];
salutationName
=
json
[
'salutation_name'
];
subLocality
=
json
[
'sub_locality'
];
district
=
json
[
'district'
];
state
=
json
[
'state'
];
pincode
=
json
[
'pincode'
];
address
=
json
[
'address'
];
date
=
json
[
'date'
];
source
=
json
[
'source'
];
reference
=
json
[
'reference'
];
segment
=
json
[
'segment'
];
team
=
json
[
'team'
];
gstNumber
=
json
[
'gst_number'
];
isExists
=
json
[
'is_exists'
];
createdDatetime
=
json
[
'created_datetime'
];
updatedDatetime
=
json
[
'updated_datetime'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'temp_id'
]
=
this
.
tempId
;
data
[
'owner_id'
]
=
this
.
ownerId
;
data
[
'acc_manager_id'
]
=
this
.
accManagerId
;
data
[
'name'
]
=
this
.
name
;
data
[
'salutation_name'
]
=
this
.
salutationName
;
data
[
'sub_locality'
]
=
this
.
subLocality
;
data
[
'district'
]
=
this
.
district
;
data
[
'state'
]
=
this
.
state
;
data
[
'pincode'
]
=
this
.
pincode
;
data
[
'address'
]
=
this
.
address
;
data
[
'date'
]
=
this
.
date
;
data
[
'source'
]
=
this
.
source
;
data
[
'reference'
]
=
this
.
reference
;
data
[
'segment'
]
=
this
.
segment
;
data
[
'team'
]
=
this
.
team
;
data
[
'gst_number'
]
=
this
.
gstNumber
;
data
[
'is_exists'
]
=
this
.
isExists
;
data
[
'created_datetime'
]
=
this
.
createdDatetime
;
data
[
'updated_datetime'
]
=
this
.
updatedDatetime
;
return
data
;
}
}
lib/Models/ordersModels/addOrderTpcAgentListResponse.dart
0 → 100644
View file @
d006edb4
class
addOrderTpcAgentListResponse
{
List
<
TpcList
>?
tpcList
;
String
?
error
;
String
?
message
;
addOrderTpcAgentListResponse
({
this
.
tpcList
,
this
.
error
,
this
.
message
});
addOrderTpcAgentListResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'tpc_list'
]
!=
null
)
{
tpcList
=
<
TpcList
>[];
json
[
'tpc_list'
].
forEach
((
v
)
{
tpcList
!.
add
(
new
TpcList
.
fromJson
(
v
));
});
}
error
=
json
[
'error'
];
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
tpcList
!=
null
)
{
data
[
'tpc_list'
]
=
this
.
tpcList
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
TpcList
{
String
?
id
;
String
?
text
;
TpcList
({
this
.
id
,
this
.
text
});
TpcList
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
text
=
json
[
'text'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'text'
]
=
this
.
text
;
return
data
;
}
}
lib/Notifiers/CheckInProvider.dart
View file @
d006edb4
...
@@ -192,6 +192,7 @@ class CheckInOutProvider with ChangeNotifier {
...
@@ -192,6 +192,7 @@ class CheckInOutProvider with ChangeNotifier {
if
(
data
.
error
==
0
)
{
if
(
data
.
error
==
0
)
{
toast
(
context
,
"CheckedIn Successfully"
);
toast
(
context
,
"CheckedIn Successfully"
);
await
BackgroundLocationService
.
startLocationService
(
context
);
await
BackgroundLocationService
.
startLocationService
(
context
);
locationController
.
clear
();
Navigator
.
pop
(
context
,
true
);
Navigator
.
pop
(
context
,
true
);
}
else
{
}
else
{
toast
(
context
,
"Check-In UnSuccessful"
);
toast
(
context
,
"Check-In UnSuccessful"
);
...
@@ -225,8 +226,9 @@ class CheckInOutProvider with ChangeNotifier {
...
@@ -225,8 +226,9 @@ class CheckInOutProvider with ChangeNotifier {
);
);
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
if
(
data
.
error
==
0
)
{
if
(
data
.
error
==
0
)
{
toast
(
context
,
"Check
ed
Out Successful
ly
"
);
toast
(
context
,
"Check
-
Out Successful"
);
await
BackgroundLocationService
.
stopLocationService
();
await
BackgroundLocationService
.
stopLocationService
();
locationController
.
clear
();
Navigator
.
pop
(
context
,
true
);
Navigator
.
pop
(
context
,
true
);
}
else
{
}
else
{
toast
(
context
,
"Check-Out UnSuccessful"
);
toast
(
context
,
"Check-Out UnSuccessful"
);
...
...
lib/Notifiers/PendingComplaintsProvider.dart
View file @
d006edb4
...
@@ -9,6 +9,7 @@ import 'package:generp/Notifiers/HomeScreenNotifier.dart';
...
@@ -9,6 +9,7 @@ import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import
'package:generp/Utils/SharedpreferencesService.dart'
;
import
'package:generp/Utils/SharedpreferencesService.dart'
;
import
'package:generp/screens/serviceEngineer/serviceEngineerDashboard.dart'
;
import
'package:generp/screens/serviceEngineer/serviceEngineerDashboard.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:get/utils.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:provider/provider.dart'
;
import
'package:provider/provider.dart'
;
...
@@ -31,7 +32,9 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
...
@@ -31,7 +32,9 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
File
?
_imageName
;
File
?
_imageName
;
var
_image_picked
=
0
;
var
_image_picked
=
0
;
bool
_submitLoading
=
false
;
bool
_submitLoading
=
false
;
String
?
statusError
;
String
?
fsrError
;
String
?
runningHoursError
;
List
<
TP_List
>
get
technician_complaint_list
=>
_technician_complaint_list
;
List
<
TP_List
>
get
technician_complaint_list
=>
_technician_complaint_list
;
bool
get
isLoading
=>
_isLoading
;
bool
get
isLoading
=>
_isLoading
;
bool
get
submitLoading
=>
_submitLoading
;
bool
get
submitLoading
=>
_submitLoading
;
...
@@ -42,7 +45,10 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
...
@@ -42,7 +45,10 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
int
get
imagePicked
=>
_image_picked
;
int
get
imagePicked
=>
_image_picked
;
File
?
get
imagePath
=>
_imageName
;
File
?
get
imagePath
=>
_imageName
;
File
?
get
imageFilePath
=>
_image
;
File
?
get
imageFilePath
=>
_image
;
final
List
<
Map
<
String
,
dynamic
>>
CompletedStatus
=
[
{
"id"
:
"1"
,
"name"
:
"Pending"
},
{
"id"
:
"2"
,
"name"
:
"Completed"
}
];
set
imagePicked
(
int
value
){
set
imagePicked
(
int
value
){
_image_picked
=
value
;
_image_picked
=
value
;
notifyListeners
();
notifyListeners
();
...
@@ -72,6 +78,15 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
...
@@ -72,6 +78,15 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
_submitLoading
=
false
;
_submitLoading
=
false
;
_statusId
=
""
;
_statusId
=
""
;
_image_picked
=
0
;
_image_picked
=
0
;
fsrNumberController
.
clear
();
runningHoursController
.
clear
();
feedbackController
.
clear
();
statusError
=
""
;
fsrError
=
""
;
runningHoursError
=
""
;
_image
=
null
;
_imageName
=
null
;
notifyListeners
();
}
}
Future
<
void
>
TechnicianPendingComplaints
(
BuildContext
context
)
async
{
Future
<
void
>
TechnicianPendingComplaints
(
BuildContext
context
)
async
{
...
@@ -151,7 +166,10 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
...
@@ -151,7 +166,10 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
runningHr
,
runningHr
,
statusId
,
statusId
,
)
async
{
)
async
{
if
(!
validatereceiptForm
(
context
))
{
return
;
}
var
HomeProvider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
var
HomeProvider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
try
{
try
{
final
data
=
await
ApiCalling
.
UpdateComplaintAPI
(
final
data
=
await
ApiCalling
.
UpdateComplaintAPI
(
...
@@ -171,7 +189,7 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
...
@@ -171,7 +189,7 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
if
(
data
.
sessionExists
==
1
)
{
if
(
data
.
sessionExists
==
1
)
{
if
(
data
.
error
==
0
)
{
if
(
data
.
error
==
0
)
{
toast
(
context
,
"Complaint Status Updated!"
);
toast
(
context
,
"Complaint Status Updated!"
);
resetAll
();
Navigator
.
pop
(
context
);
Navigator
.
pop
(
context
);
...
@@ -202,6 +220,35 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
...
@@ -202,6 +220,35 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
}
}
}
}
bool
validatereceiptForm
(
BuildContext
context
)
{
statusError
=
null
;
fsrError
=
null
;
runningHoursError
=
null
;
_submitLoading
=
false
;
bool
isValid
=
true
;
if
(
_statusId
==
null
||
_statusId
!.
isEmpty
)
{
statusError
=
"Please Select Status"
;
_submitLoading
=
false
;
isValid
=
false
;
}
if
(
_statusId
!=
"Pending"
){
if
(
fsrNumberController
.
text
.
trim
().
isEmpty
)
{
fsrError
=
"Please Enter FSR number"
;
_submitLoading
=
false
;
isValid
=
false
;
}
}
if
(
runningHoursController
.
text
.
trim
().
isEmpty
){
runningHoursError
=
"Enter Running Hours"
;
_submitLoading
=
false
;
isValid
=
false
;
}
notifyListeners
();
return
isValid
;
}
Future
SelectAttachmentDialogue
(
Future
SelectAttachmentDialogue
(
BuildContext
context
BuildContext
context
)
async
{
)
async
{
...
...
lib/Notifiers/VisitDetailsProvider.dart
View file @
d006edb4
...
@@ -66,7 +66,7 @@ class Visitdetailsprovider extends ChangeNotifier{
...
@@ -66,7 +66,7 @@ class Visitdetailsprovider extends ChangeNotifier{
if
(
data
.
error
==
0
)
{
if
(
data
.
error
==
0
)
{
// complaintdetails = data.complaintDetails!;
// complaintdetails = data.complaintDetails!;
_followupList
=
data
.
list
!
;
_followupList
=
data
.
list
??[]
;
_isLoading
=
false
;
_isLoading
=
false
;
notifyListeners
();
notifyListeners
();
}
else
{
}
else
{
...
...
lib/Notifiers/ordersProvider/addOrderProvider.dart
0 → 100644
View file @
d006edb4
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:generp/Models/ordersModels/addOrderAccontDetailsResponse.dart'
;
import
'package:generp/Utils/commonServices.dart'
;
import
'package:geolocator/geolocator.dart'
;
import
'package:geolocator/geolocator.dart'
as
geo_location
;
import
'package:google_maps_flutter/google_maps_flutter.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:intl/intl.dart'
;
import
'package:location/location.dart'
as
Location
;
import
'package:provider/provider.dart'
;
import
'../../Models/commonModels/DistrictsResponse.dart'
;
import
'../../Models/commonModels/SubLocationsResponse.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectAccountResponse.dart'
;
import
'../../Models/ordersModels/AddOrderViewResponse.dart'
;
import
'../../Models/ordersModels/addOrderTpcAgentListResponse.dart'
;
import
'../../services/api_calling.dart'
;
import
'../HomeScreenNotifier.dart'
;
class
Addorderprovider
extends
ChangeNotifier
{
TextEditingController
dropDownSearchController
=
TextEditingController
();
TextEditingController
dropDownTpcSearchController
=
TextEditingController
();
TextEditingController
billingNameController
=
TextEditingController
();
TextEditingController
billingAddressController
=
TextEditingController
();
TextEditingController
billingPincodeController
=
TextEditingController
();
TextEditingController
dispatchAddressController
=
TextEditingController
();
TextEditingController
dispatchPincodeController
=
TextEditingController
();
TextEditingController
gstController
=
TextEditingController
();
TextEditingController
orderReceivedDateController
=
TextEditingController
();
TextEditingController
tpcAmountController
=
TextEditingController
();
List
<
AccountList
>
_accountList
=
[];
List
<
Employees
>
_employees
=
[];
List
<
States
>
_billingStates
=
[];
List
<
States
>
_dispatchStates
=
[];
List
<
SaleProducts
>
_saleProducts
=
[];
List
<
Districts
>
_billingDistricts
=
[];
List
<
Districts
>
_dispatchDistricts
=
[];
List
<
SubLocations
>
_billingSubLocations
=
[];
List
<
SubLocations
>
_dispatchSubLocations
=
[];
List
<
String
>
_unloadingScope
=
[];
List
<
String
>
_freightScope
=
[];
List
<
String
>
_erectionScope
=
[];
List
<
String
>
_tpcApplicable
=
[];
List
<
TpcList
>
_tpcAgent
=
[];
AccountDetails
_accountDetails
=
AccountDetails
();
String
selectAccountError
=
""
;
String
billingNameError
=
""
;
String
billingAddressError
=
""
;
String
billingPincodeError
=
""
;
String
dispatchAddressError
=
""
;
String
dispatchPincodeError
=
""
;
String
tpcAmountError
=
""
;
String
gstError
=
""
;
AccountList
?
_selectedAccountList
;
String
?
_selectedAccountID
;
String
?
_selectedAccountName
;
Employees
?
_selectedEmployees
;
String
?
_selectedEmployeeID
;
String
?
_selectedEmployeeName
;
States
?
_selectedBillingStates
;
String
?
_selectedBillingStateID
;
String
?
_selectedBillingStateName
;
Districts
?
_selectedBillingDistricts
;
String
?
_selectedBillingDistrictID
;
String
?
_selectedBillingDistrictValue
;
SubLocations
?
_selectedBillingSubLocations
;
String
?
_selectedBillingSubLocID
;
String
?
_selectedBillingSubLocValue
;
States
?
_selectedDispatchStates
;
String
?
_selectedDispatchStateID
;
String
?
_selectedDispatchStateName
;
Districts
?
_selectedDispatchDistricts
;
String
?
_selectedDispatchDistrictID
;
String
?
_selectedDispatchDistrictValue
;
SubLocations
?
_selectedDispatchSubLocations
;
String
?
_selectedDispatchSubLocID
;
String
?
_selectedDispatchSubLocValue
;
SaleProducts
?
_selectedSaleProducts
;
List
<
String
?>
_selectedSaleProductID
=
[];
String
?
_selectedSaleProductName
;
String
?
_selectedUnloadingScope
;
String
?
_selectedFreightScope
;
String
?
_selectedErectionScope
;
String
?
_selectedTpcStatus
;
TpcList
?
_selectedTpcAgent
;
String
?
_selectedTpcAgentID
;
String
?
_selectedTpcAgentValue
;
List
<
TextEditingController
>
ProductControllers
=
[];
List
<
TextEditingController
>
PriceControllers
=
[];
List
<
TextEditingController
>
QuantityControllers
=
[];
List
<
TextEditingController
>
CGSTControllers
=
[];
List
<
TextEditingController
>
SGSTControllers
=
[];
List
<
TextEditingController
>
IGSTControllers
=
[];
List
<
TextEditingController
>
TotalPriceControllers
=
[];
List
<
TextEditingController
>
TaxableValueControllers
=
[];
TextEditingController
noteController
=
TextEditingController
();
LatLng
startLocation
=
const
LatLng
(
17.439112226708446
,
78.43292499146135
);
LatLng
?
currentLocationLatLng
;
String
latlongs
=
""
;
Set
<
Marker
>
markers
=
{};
Location
.
LocationData
?
currentLocation
;
bool
isLocationEnabled
=
false
;
bool
hasLocationPermission
=
false
;
String
?
FileError
;
String
?
dateError
;
bool
_isLoading
=
false
;
int
_imagePicked
=
0
;
File
?
_image
;
File
?
_imageName
;
final
ImagePicker
_picker
=
ImagePicker
();
DateTime
?
_date
;
String
?
_formattedDate
;
Timer
?
_debounce
;
List
<
Map
<
String
,
String
>>
_selectedOrders
=
[];
List
<
Map
<
String
,
String
>>
get
selectedOrders
=>
_selectedOrders
;
bool
_submitClicked
=
false
;
bool
get
submitClicked
=>
_submitClicked
;
set
submitClicked
(
bool
value
){
_submitClicked
=
value
;
notifyListeners
();
}
set
selectedOrders
(
value
)
{
_selectedOrders
=
selectedOrders
;
notifyListeners
();
}
bool
get
isLoading
=>
_isLoading
;
String
?
get
formattedDate
=>
_formattedDate
;
DateTime
?
get
dateNow
=>
_date
;
File
?
get
imagePath
=>
_imageName
;
File
?
get
imageFilePath
=>
_image
;
int
get
imagePicked
=>
_imagePicked
;
List
<
AccountList
>
get
accountList
=>
_accountList
;
List
<
Employees
>
get
employees
=>
_employees
;
List
<
SaleProducts
>
get
saleProducts
=>
_saleProducts
;
List
<
String
>
get
unloadingScope
=>
_unloadingScope
;
List
<
String
>
get
freightScope
=>
_freightScope
;
List
<
String
>
get
erectionScope
=>
_erectionScope
;
List
<
String
>
get
tpcApplicable
=>
_tpcApplicable
;
List
<
TpcList
>
get
tpcAgent
=>
_tpcAgent
;
AccountList
?
get
selectedAccountList
=>
_selectedAccountList
;
String
?
get
selectedAccountID
=>
_selectedAccountID
;
String
?
get
selectedAccountName
=>
_selectedAccountName
;
Employees
?
get
selectedEmployees
=>
_selectedEmployees
;
String
?
get
selectedEmployeeID
=>
_selectedEmployeeID
;
String
?
get
selectedEmployeeName
=>
_selectedEmployeeName
;
List
<
States
>
get
billingStates
=>
_billingStates
;
States
?
get
selecetdBillingStates
=>
_selectedBillingStates
;
String
?
get
selectedBillingStateID
=>
_selectedBillingStateID
;
String
?
get
selectedBillingStateName
=>
_selectedBillingStateName
;
List
<
Districts
>
get
billingDistricts
=>
_billingDistricts
;
List
<
SubLocations
>
get
billingSubLocations
=>
_billingSubLocations
;
Districts
?
get
selectedBillingDistricts
=>
_selectedBillingDistricts
;
String
?
get
selectedBillingDistrictId
=>
_selectedBillingDistrictID
;
String
?
get
selectedBillingDistrictValue
=>
_selectedBillingDistrictValue
;
SubLocations
?
get
selectedBillingSubLocations
=>
_selectedBillingSubLocations
;
String
?
get
selectedBillingSubLocID
=>
_selectedBillingSubLocID
;
String
?
get
selectedBillingSubLocValue
=>
_selectedBillingSubLocValue
;
List
<
States
>
get
dispatchStates
=>
_dispatchStates
;
States
?
get
selecetdDispatchStates
=>
_selectedDispatchStates
;
String
?
get
selectedDispatchStateID
=>
_selectedDispatchStateID
;
String
?
get
selectedDispatchStateName
=>
_selectedDispatchStateName
;
List
<
Districts
>
get
dispatchDistricts
=>
_dispatchDistricts
;
List
<
SubLocations
>
get
dispatchSubLocations
=>
_dispatchSubLocations
;
Districts
?
get
selectedDispatchDistricts
=>
_selectedDispatchDistricts
;
String
?
get
selectedDispatchDistrictId
=>
_selectedDispatchDistrictID
;
String
?
get
selectedDispatchDistrictValue
=>
_selectedDispatchDistrictValue
;
SubLocations
?
get
selectedDispatchSubLocations
=>
_selectedDispatchSubLocations
;
String
?
get
selectedDispatchSubLocID
=>
_selectedDispatchSubLocID
;
String
?
get
selectedDispatchSubLocValue
=>
_selectedDispatchSubLocValue
;
SaleProducts
?
get
selectedSaleProducts
=>
_selectedSaleProducts
;
List
<
String
?>
get
selectedSaleProductID
=>
_selectedSaleProductID
;
String
?
get
selectedSaleProductName
=>
_selectedSaleProductName
;
String
?
get
selectedUnloadingScope
=>
_selectedUnloadingScope
;
String
?
get
selectedFreightScope
=>
_selectedFreightScope
;
String
?
get
selectedErectionScope
=>
_selectedErectionScope
;
String
?
get
selectedTpcStatus
=>
_selectedTpcStatus
;
TpcList
?
get
selectedTpcAgent
=>
_selectedTpcAgent
;
String
?
get
selectedTpcAgentID
=>
_selectedTpcAgentID
;
String
?
get
selectedTpcAgentValue
=>
_selectedTpcAgentValue
;
AccountDetails
get
accountDetails
=>
_accountDetails
;
set
accountList
(
List
<
AccountList
>
value
)
{
_accountList
=
value
;
notifyListeners
();
}
set
selectedAccountList
(
AccountList
?
value
)
{
_selectedAccountList
=
value
;
_selectedAccountID
=
value
!.
id
;
_selectedAccountName
=
value
!.
text
!;
notifyListeners
();
}
set
selectedAccountID
(
String
?
value
)
{
_selectedAccountID
=
value
;
notifyListeners
();
}
set
selectedAccountName
(
String
?
value
)
{
_selectedAccountName
=
value
;
notifyListeners
();
}
set
selectedEmployees
(
Employees
?
value
)
{
_selectedEmployees
=
value
;
_selectedEmployeeID
=
value
!.
id
;
_selectedEmployeeName
=
value
!.
name
!;
notifyListeners
();
}
set
selectedEmployeeID
(
String
?
value
)
{
_selectedEmployeeID
=
value
;
notifyListeners
();
}
set
selectedEmployeeName
(
String
?
value
)
{
_selectedEmployeeName
=
value
;
notifyListeners
();
}
set
selecetdBillingStates
(
States
?
value
)
{
_selectedBillingStates
=
value
;
_selectedBillingStateID
=
value
!.
id
;
_selectedBillingStateName
=
value
!.
name
!;
notifyListeners
();
}
set
selectedBillingStateID
(
String
?
value
)
{
_selectedBillingStateID
=
value
;
notifyListeners
();
}
set
selectedBillingStateName
(
String
?
value
)
{
_selectedBillingStateName
=
value
;
notifyListeners
();
}
set
selectedBillingDistricts
(
Districts
?
value
)
{
_selectedBillingDistricts
=
value
;
_selectedBillingDistrictID
=
value
!.
id
;
_selectedBillingDistrictValue
=
value
!.
district
;
// districtError = null;
notifyListeners
();
}
set
selectedBillingSubLocations
(
SubLocations
?
value
)
{
_selectedBillingSubLocations
=
value
;
_selectedBillingSubLocID
=
value
!.
id
;
_selectedBillingSubLocValue
=
value
!.
subLocality
!;
// localityError = null;
notifyListeners
();
}
set
selectedBillingDistrictId
(
value
)
{
_selectedBillingDistrictID
=
value
;
notifyListeners
();
}
set
selectedBillingDistrictValue
(
value
)
{
_selectedBillingDistrictValue
=
value
;
notifyListeners
();
}
set
selectedBillingSubLocID
(
value
)
{
_selectedBillingSubLocID
=
value
;
notifyListeners
();
}
set
selectedBillingSubLocValue
(
value
)
{
_selectedBillingSubLocValue
=
value
;
notifyListeners
();
}
set
selecetdDispatchStates
(
States
?
value
)
{
_selectedDispatchStates
=
value
;
_selectedDispatchStateID
=
value
!.
id
;
_selectedDispatchStateName
=
value
!.
name
!;
notifyListeners
();
}
set
selectedDispatchStateID
(
String
?
value
)
{
_selectedDispatchStateID
=
value
;
notifyListeners
();
}
set
selectedDispatchStateName
(
String
?
value
)
{
_selectedDispatchStateName
=
value
;
notifyListeners
();
}
set
selectedDispatchDistricts
(
Districts
?
value
)
{
_selectedDispatchDistricts
=
value
;
_selectedDispatchDistrictID
=
value
!.
id
;
_selectedDispatchDistrictValue
=
value
!.
district
;
// districtError = null;
notifyListeners
();
}
set
selectedDispatchSubLocations
(
SubLocations
?
value
)
{
_selectedDispatchSubLocations
=
value
;
_selectedDispatchSubLocID
=
value
!.
id
;
_selectedDispatchSubLocValue
=
value
!.
subLocality
!;
// localityError = null;
notifyListeners
();
}
set
selectedDispatchDistrictId
(
value
)
{
_selectedDispatchDistrictID
=
value
;
notifyListeners
();
}
set
selectedDispatchDistrictValue
(
value
)
{
_selectedDispatchDistrictValue
=
value
;
notifyListeners
();
}
set
selectedDispatchSubLocID
(
value
)
{
_selectedDispatchSubLocID
=
value
;
notifyListeners
();
}
set
selectedDispatchSubLocValue
(
value
)
{
_selectedDispatchSubLocValue
=
value
;
notifyListeners
();
}
set
selectedSaleProducts
(
SaleProducts
?
value
)
{
_selectedSaleProducts
=
value
;
// _selectedSaleProductID = value!.id!;
// _selectedSaleProductName = value!.prodName;
notifyListeners
();
}
set
selectedSaleProductID
(
List
<
String
?>
value
)
{
_selectedSaleProductID
=
value
;
notifyListeners
();
}
set
selectedSaleProductName
(
String
?
value
)
{
_selectedSaleProductName
=
value
;
notifyListeners
();
}
set
selectedUnloadingScope
(
String
?
value
)
{
_selectedUnloadingScope
=
value
;
notifyListeners
();
}
set
selectedFreightScope
(
String
?
value
)
{
_selectedFreightScope
=
value
;
notifyListeners
();
}
set
selectedErectionScope
(
String
?
value
)
{
_selectedErectionScope
=
value
;
notifyListeners
();
}
set
selectedTpcStatus
(
String
?
value
)
{
_selectedTpcStatus
=
value
;
notifyListeners
();
}
set
selectedTpcAgent
(
TpcList
?
value
)
{
_selectedTpcAgent
=
value
;
_selectedTpcAgentID
=
value
!.
id
;
_selectedTpcAgentValue
=
value
!.
text
;
notifyListeners
();
}
set
selectedTpcAgentID
(
String
?
value
)
{
_selectedTpcAgentID
=
value
;
notifyListeners
();
}
set
selectedTpcAgentValue
(
String
?
value
)
{
_selectedTpcAgentValue
=
value
;
notifyListeners
();
}
set
accountDetails
(
AccountDetails
value
)
{
_accountDetails
=
value
;
notifyListeners
();
}
set
imagePath
(
File
?
value
)
{
_imageName
=
value
;
notifyListeners
();
}
set
imageFilePath
(
File
?
value
)
{
_image
=
value
;
notifyListeners
();
}
set
imagePicked
(
value
)
{
_imagePicked
=
value
;
notifyListeners
();
}
set
formattedDate
(
String
?
value
)
{
_formattedDate
=
value
;
orderReceivedDateController
.
text
=
_formattedDate
!;
dateError
=
null
;
notifyListeners
();
}
void
setDate
(
DateTime
newDate
)
{
_date
=
newDate
;
_formattedDate
=
DateFormat
(
'yyyy-MM-dd'
).
format
(
newDate
);
orderReceivedDateController
.
text
=
_formattedDate
!;
dateError
=
null
;
notifyListeners
();
}
double
get
basicAmount
{
double
total
=
0
;
for
(
var
controller
in
TaxableValueControllers
)
{
total
+=
double
.
tryParse
(
controller
.
text
)
??
0.0
;
}
return
total
;
}
double
get
cgstAmount
{
double
total
=
0
;
for
(
int
i
=
0
;
i
<
ProductControllers
.
length
;
i
++)
{
final
taxableValue
=
double
.
tryParse
(
TaxableValueControllers
[
i
].
text
)
??
0.0
;
final
cgst
=
double
.
tryParse
(
CGSTControllers
[
i
].
text
)
??
0.0
;
total
+=
(
taxableValue
*
cgst
)
/
100
;
}
return
total
;
}
double
get
sgstAmount
{
double
total
=
0
;
for
(
int
i
=
0
;
i
<
ProductControllers
.
length
;
i
++)
{
final
taxableValue
=
double
.
tryParse
(
TaxableValueControllers
[
i
].
text
)
??
0.0
;
final
sgst
=
double
.
tryParse
(
SGSTControllers
[
i
].
text
)
??
0.0
;
total
+=
(
taxableValue
*
sgst
)
/
100
;
}
return
total
;
}
double
get
igstAmount
{
double
total
=
0
;
for
(
int
i
=
0
;
i
<
ProductControllers
.
length
;
i
++)
{
final
taxableValue
=
double
.
tryParse
(
TaxableValueControllers
[
i
].
text
)
??
0.0
;
final
igst
=
double
.
tryParse
(
IGSTControllers
[
i
].
text
)
??
0.0
;
total
+=
(
taxableValue
*
igst
)
/
100
;
}
return
total
;
}
double
get
totalAmount
=>
basicAmount
+
cgstAmount
+
sgstAmount
+
igstAmount
;
void
addNewRow
()
{
ProductControllers
.
add
(
TextEditingController
());
PriceControllers
.
add
(
TextEditingController
());
QuantityControllers
.
add
(
TextEditingController
(
text:
'1'
));
CGSTControllers
.
add
(
TextEditingController
(
text:
'9'
));
SGSTControllers
.
add
(
TextEditingController
(
text:
'9'
));
IGSTControllers
.
add
(
TextEditingController
(
text:
'0'
));
TaxableValueControllers
.
add
(
TextEditingController
());
selectedSaleProductID
.
add
(
null
);
notifyListeners
();
}
void
removeRow
(
int
index
)
{
if
(
index
>=
0
&&
index
<
ProductControllers
.
length
)
{
ProductControllers
[
index
].
dispose
();
PriceControllers
[
index
].
dispose
();
QuantityControllers
[
index
].
dispose
();
CGSTControllers
[
index
].
dispose
();
SGSTControllers
[
index
].
dispose
();
IGSTControllers
[
index
].
dispose
();
TaxableValueControllers
[
index
].
dispose
();
ProductControllers
.
removeAt
(
index
);
PriceControllers
.
removeAt
(
index
);
QuantityControllers
.
removeAt
(
index
);
CGSTControllers
.
removeAt
(
index
);
SGSTControllers
.
removeAt
(
index
);
IGSTControllers
.
removeAt
(
index
);
TaxableValueControllers
.
removeAt
(
index
);
selectedSaleProductID
.
removeAt
(
index
);
notifyListeners
();
}
}
void
updateSelectedProduct
(
int
index
,
SaleProducts
?
product
)
{
if
(
index
>=
0
&&
index
<
_saleProducts
.
length
)
{
_selectedSaleProductID
[
index
]
=
product
!.
id
;
PriceControllers
[
index
].
text
=
product
!.
price
!;
updateRowCalculations
(
index
);
notifyListeners
();
}
}
void
updateRowCalculations
(
int
index
)
{
if
(
index
>=
0
&&
index
<
PriceControllers
.
length
)
{
final
inclusivePrice
=
double
.
tryParse
(
PriceControllers
[
index
].
text
)
??
0.0
;
final
quantity
=
double
.
tryParse
(
QuantityControllers
[
index
].
text
)
??
1.0
;
final
cgst
=
double
.
tryParse
(
CGSTControllers
[
index
].
text
)
??
0.0
;
final
sgst
=
double
.
tryParse
(
SGSTControllers
[
index
].
text
)
??
0.0
;
final
igst
=
double
.
tryParse
(
IGSTControllers
[
index
].
text
)
??
0.0
;
final
totalTaxRate
=
(
cgst
+
sgst
+
igst
)
/
100
;
// Calculate taxable value per unit
final
taxableValuePerUnit
=
inclusivePrice
/
(
1
+
totalTaxRate
);
// Total taxable value = taxable value per unit * quantity
final
totalTaxableValue
=
taxableValuePerUnit
*
quantity
;
TaxableValueControllers
[
index
].
text
=
totalTaxableValue
.
toStringAsFixed
(
0
,
);
notifyListeners
();
}
}
Map
<
String
,
dynamic
>
getFormData
()
{
final
List
<
Map
<
String
,
dynamic
>>
orders
=
[];
for
(
int
i
=
0
;
i
<
ProductControllers
.
length
;
i
++)
{
orders
.
add
({
'product_id'
:
selectedSaleProductID
[
i
],
'product_name'
:
ProductControllers
[
i
].
text
,
'inclusive_price'
:
PriceControllers
[
i
].
text
,
'quantity'
:
QuantityControllers
[
i
].
text
,
'cgst'
:
CGSTControllers
[
i
].
text
,
'sgst'
:
SGSTControllers
[
i
].
text
,
'igst'
:
IGSTControllers
[
i
].
text
,
'taxable_value'
:
TaxableValueControllers
[
i
].
text
,
});
}
return
{
'orders'
:
orders
,
'basic_amount'
:
basicAmount
.
toStringAsFixed
(
2
),
'cgst_amount'
:
cgstAmount
.
toStringAsFixed
(
2
),
'sgst_amount'
:
sgstAmount
.
toStringAsFixed
(
2
),
'igst_amount'
:
igstAmount
.
toStringAsFixed
(
2
),
'total_amount'
:
totalAmount
.
toStringAsFixed
(
2
),
'note'
:
noteController
.
text
,
};
}
//
//
// void updateSelectedOrderId(int index, SaleProducts? value) {
// if (index >= 0 && index < _selectedSaleProductID.length) {
// _selectedSaleProductID[index] = value!.id;
// ProductControllers[index].text = value!.prodName!;
// PriceControllers[index].text = value.price!;
// notifyListeners();
// } else {
// print("Invalid index: $index");
// }
// }
// void addNewRow() {
// // Create a unique TextEditingController for each field
// ProductControllers.add(TextEditingController());
// PriceControllers.add(TextEditingController());
// QuantityControllers.add(TextEditingController());
// CGSTControllers.add(TextEditingController(text: "9"));
// SGSTControllers.add(TextEditingController(text: "9"));
// IGSTControllers.add(TextEditingController());
// TotalPriceControllers.add(TextEditingController());
// _selectedSaleProductID.add(null); // Safe to add null since List<String?> allows nullable strings
// notifyListeners();
// }
//
// void removeRow(int index) {
// if (index >= 0 && index < ProductControllers.length) {
// ProductControllers[index].dispose();
// ProductControllers.removeAt(index);
// PriceControllers[index].dispose();
// PriceControllers.removeAt(index);
// QuantityControllers[index].dispose();
// QuantityControllers.removeAt(index);
// CGSTControllers[index].dispose();
// CGSTControllers.removeAt(index);
// SGSTControllers[index].dispose();
// SGSTControllers.removeAt(index);
// IGSTControllers[index].dispose();
// IGSTControllers.removeAt(index);
// TotalPriceControllers[index].dispose();
// TotalPriceControllers.removeAt(index);
// _selectedSaleProductID.removeAt(index);
// notifyListeners();
// } else {
// print("Invalid index: $index");
// }
// }
// double get basicAmount {
// double total = 0;
// for (int i = 0; i < TotalPriceControllers.length; i++) {
// total += double.tryParse(TotalPriceControllers[i].text) ?? 0.0;
// }
// return total;
// }
//
// double get cgstAmount {
// double total = 0;
// for (int i = 0; i < ProductControllers.length; i++) {
// final price = double.tryParse(PriceControllers[i].text) ?? 0.0;
// final quantity = double.tryParse(QuantityControllers[i].text) ?? 0.0;
// final cgst = double.tryParse(CGSTControllers[i].text) ?? 0.0;
// total += (price * quantity * cgst) / 100;
// }
// return total;
// }
//
// double get sgstAmount {
// double total = 0;
// for (int i = 0; i < ProductControllers.length; i++) {
// final price = double.tryParse(PriceControllers[i].text) ?? 0.0;
// final quantity = double.tryParse(QuantityControllers[i].text) ?? 0.0;
// final sgst = double.tryParse(SGSTControllers[i].text) ?? 0.0;
// total += (price * quantity * sgst) / 100;
// }
// return total;
// }
//
// double get igstAmount {
// double total = 0;
// for (int i = 0; i < ProductControllers.length; i++) {
// final price = double.tryParse(PriceControllers[i].text) ?? 0.0;
// final quantity = double.tryParse(QuantityControllers[i].text) ?? 0.0;
// final igst = double.tryParse(IGSTControllers[i].text) ?? 0.0;
// total += (price * quantity * igst) / 100;
// }
// return total;
// }
//
// double get totalAmount => basicAmount + cgstAmount + sgstAmount + igstAmount;
//
//
// // List<Map<String, String>> getFormData() {
// // _selectedOrders = [];
// //
// // // Iterate over rows
// // for (int i = 0; i < ProductControllers.length; i++) {
// // // Only include rows with a valid product ID
// // if (_selectedSaleProductID[i] != null &&
// // ProductControllers[i].text.isNotEmpty) {
// // // Create a map for the current row's data
// // final rowData = {
// // "product_id": _selectedSaleProductID[i]!,
// // "product_name": ProductControllers[i].text,
// // "price": PriceControllers[i].text.isNotEmpty ? PriceControllers[i].text : "0",
// // "qty": QuantityControllers[i].text.isNotEmpty ? QuantityControllers[i].text : "0",
// // "cgst_p": CGSTControllers[i].text.isNotEmpty ? CGSTControllers[i].text : "0",
// // "sgst_p": SGSTControllers[i].text.isNotEmpty ? SGSTControllers[i].text : "0",
// // "igst_p": IGSTControllers[i].text.isNotEmpty ? IGSTControllers[i].text : "0",
// // "total_price": TotalPriceControllers[i].text.isNotEmpty ? TotalPriceControllers[i].text : "0",
// // };
// // _selectedOrders.add(rowData);
// // }
// // }
// //
// // print("Form Data: $_selectedOrders");
// // notifyListeners();
// // return _selectedOrders;
// // }
//
// Map<String, dynamic> getFormData() {
// final List<Map<String, dynamic>> orders = [];
// for (int i = 0; i < ProductControllers.length; i++) {
// orders.add({
// 'product_id': selectedSaleProductID[i],
// 'product_name': ProductControllers[i].text,
// 'price': PriceControllers[i].text,
// 'quantity': QuantityControllers[i].text,
// 'cgst': CGSTControllers[i].text,
// 'sgst': SGSTControllers[i].text,
// 'igst': IGSTControllers[i].text,
// 'total_price': TotalPriceControllers[i].text,
// });
// }
// return {
// 'orders': orders,
// 'basic_amount': basicAmount.toStringAsFixed(2),
// 'cgst_amount': cgstAmount.toStringAsFixed(2),
// 'sgst_amount': sgstAmount.toStringAsFixed(2),
// 'igst_amount': igstAmount.toStringAsFixed(2),
// 'total_amount': totalAmount.toStringAsFixed(2),
// 'note': noteController.text,
// };
// }
Future
<
void
>
ordersAddOrderAPIViewFunction
(
context
,
mode
)
async
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
addOrderViewAPI
(
provider
.
empId
,
provider
.
session
,
mode
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_tpcApplicable
=
[
"Yes"
,
"No"
];
_erectionScope
=
data
.
erectionScope
!;
_unloadingScope
=
data
.
unloadingScope
!;
_freightScope
=
data
.
freightScope
!;
_employees
=
data
.
employees
!;
_billingStates
=
data
.
states
!;
_dispatchStates
=
data
.
states
!;
_saleProducts
=
data
.
saleProducts
!;
checkDropdownselected
();
notifyListeners
();
}
else
{}
}
else
{}
}
catch
(
e
,
s
)
{}
}
void
checkDropdownselected
()
{
if
(
_selectedAccountList
!=
null
&&
!
_accountList
.
contains
(
_selectedAccountList
))
{
_selectedAccountID
=
null
;
_selectedAccountName
=
""
;
}
if
(
_selectedEmployees
!=
null
&&
!
_employees
.
contains
(
_selectedEmployees
))
{
_selectedEmployeeID
=
null
;
_selectedEmployeeName
=
""
;
}
if
(
_selectedBillingStates
!=
null
&&
!
_billingStates
.
contains
(
_selectedBillingStates
))
{
_selectedBillingStateID
=
null
;
_selectedBillingStateName
=
""
;
}
if
(
_selectedBillingDistricts
!=
null
&&
!
_billingDistricts
.
contains
(
_selectedBillingDistricts
))
{
_selectedBillingDistrictID
=
null
;
_selectedBillingDistrictValue
=
""
;
}
if
(
_selectedBillingSubLocations
!=
null
&&
!
_billingSubLocations
.
contains
(
_selectedBillingSubLocations
))
{
_selectedBillingSubLocID
=
null
;
_selectedBillingSubLocValue
=
""
;
}
if
(
_selectedDispatchStates
!=
null
&&
!
_dispatchStates
.
contains
(
_selectedDispatchStates
))
{
_selectedDispatchStateID
=
null
;
_selectedDispatchStateName
=
""
;
}
if
(
_selectedDispatchDistricts
!=
null
&&
!
_dispatchDistricts
.
contains
(
_selectedDispatchDistricts
))
{
_selectedDispatchDistrictID
=
null
;
_selectedDispatchDistrictValue
=
""
;
}
if
(
_selectedDispatchSubLocations
!=
null
&&
!
_dispatchSubLocations
.
contains
(
_selectedDispatchSubLocations
))
{
_selectedDispatchSubLocID
=
null
;
_selectedDispatchSubLocValue
=
""
;
}
if
(
_selectedUnloadingScope
!=
null
&&
!
_unloadingScope
.
contains
(
_selectedUnloadingScope
))
{
_selectedUnloadingScope
=
null
;
}
if
(
_selectedFreightScope
!=
null
&&
!
_freightScope
.
contains
(
_selectedFreightScope
))
{
_selectedFreightScope
=
null
;
}
if
(
_selectedErectionScope
!=
null
&&
!
_erectionScope
.
contains
(
_selectedErectionScope
))
{
_selectedErectionScope
=
null
;
}
if
(
_selectedTpcStatus
!=
null
&&
!
_tpcApplicable
.
contains
(
_selectedTpcStatus
))
{
_selectedTpcStatus
=
null
;
}
if
(
_selectedTpcAgent
!=
null
&&
!
_tpcAgent
.
contains
(
_selectedTpcAgent
))
{
_selectedTpcAgentID
=
null
;
_selectedTpcAgentValue
=
""
;
}
notifyListeners
();
}
Future
<
void
>
ordersAddOrderAccountDetailsAPIFunction
(
context
,
account_id
,
)
async
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
addOrderAccountDetailsAPI
(
provider
.
empId
,
provider
.
session
,
account_id
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_accountDetails
=
data
.
accountDetails
!;
data
.
accountDetails
!.
accManagerId
!;
billingNameController
.
text
=
data
.
accountDetails
!.
name
!;
_selectedBillingSubLocID
=
data
.
accountDetails
!.
subLocality
!;
_selectedBillingDistrictID
=
data
.
accountDetails
!.
district
!;
_selectedBillingStateID
=
data
.
accountDetails
!.
state
!;
billingPincodeController
.
text
=
data
.
accountDetails
!.
pincode
!;
billingAddressController
.
text
=
data
.
accountDetails
!.
address
!;
orderReceivedDateController
.
text
=
data
.
accountDetails
!.
date
!;
gstController
.
text
=
data
.
accountDetails
!.
gstNumber
!;
notifyListeners
();
}
else
{}
}
else
{}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
getDistrictAPI
(
context
,
stateID
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
_billingDistricts
.
clear
();
notifyListeners
();
final
data
=
await
ApiCalling
.
commonAddAccountViewDistrictAPI
(
homeProv
.
empId
,
homeProv
.
session
,
stateID
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_billingDistricts
=
data
.
districts
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
getDispatchDistrictAPI
(
context
,
stateID
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
_dispatchDistricts
.
clear
();
notifyListeners
();
final
data
=
await
ApiCalling
.
commonAddAccountViewDistrictAPI
(
homeProv
.
empId
,
homeProv
.
session
,
stateID
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_dispatchDistricts
=
data
.
districts
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
getSubLocationAPI
(
context
,
districtID
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
_billingSubLocations
.
clear
();
notifyListeners
();
final
data
=
await
ApiCalling
.
commonAddAccountViewSubLocationAPI
(
homeProv
.
empId
,
homeProv
.
session
,
districtID
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_billingSubLocations
=
data
.
subLocations
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
getDispatchSubLocationAPI
(
context
,
districtID
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
_dispatchSubLocations
.
clear
();
notifyListeners
();
final
data
=
await
ApiCalling
.
commonAddAccountViewSubLocationAPI
(
homeProv
.
empId
,
homeProv
.
session
,
districtID
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_dispatchSubLocations
=
data
.
subLocations
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
ordersAddOrderTPCAgentFunction
(
context
,
mode
,
text
)
async
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
addOrderTPCAgentListAPI
(
provider
.
empId
,
provider
.
session
,
mode
,
text
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_tpcAgent
=
data
.
tpcList
!;
notifyListeners
();
}
else
{}
}
else
{}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
ordersAddOrderAPISubmitFunction
(
context
,
mode
,
selected_empid
,
selected_acid
,
selected_dis_stateId
,
selected_dis_districtId
,
selected_dis_subLocId
,
unloading_scope
,
frieght_scope
,
erection_scope
,
tpc_status
,
selected_bil_stateId
,
selected_bil_districtId
,
selected_bil_subLocId
,
tpc_agent_id
,
order_products
,
)
async
{
try
{
_submitClicked
=
true
;
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
addOrderSubmitAPI
(
provider
.
empId
,
provider
.
session
,
mode
,
selected_empid
,
selected_acid
,
selected_dis_stateId
,
selected_dis_districtId
,
selected_dis_subLocId
,
dispatchPincodeController
.
text
,
dispatchAddressController
.
text
,
basicAmount
,
cgstAmount
,
sgstAmount
,
igstAmount
,
totalAmount
,
formattedDate
,
noteController
.
text
,
unloading_scope
,
frieght_scope
,
erection_scope
,
tpc_status
,
billingNameController
.
text
,
gstController
.
text
,
billingPincodeController
.
text
,
billingAddressController
.
text
,
selected_bil_stateId
,
selected_bil_districtId
,
selected_bil_subLocId
,
order_products
,
""
,
""
,
""
,
currentLocationLatLng
,
tpcAmountController
.
text
,
tpc_agent_id
,
_image
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_submitClicked
=
false
;
resetForm
();
Navigator
.
pop
(
context
);
toast
(
context
,
data
.
message
);
notifyListeners
();
}
else
{
_submitClicked
=
false
;
notifyListeners
();
}
}
else
{
_submitClicked
=
false
;
notifyListeners
();
}
}
catch
(
e
,
s
)
{
_submitClicked
=
false
;
notifyListeners
();
}
}
Future
<
void
>
getCurrentLocation
()
async
{
try
{
Position
position
=
await
Geolocator
.
getCurrentPosition
(
desiredAccuracy:
geo_location
.
LocationAccuracy
.
high
,
);
currentLocationLatLng
=
LatLng
(
position
.
latitude
,
position
.
longitude
);
notifyListeners
();
}
catch
(
e
)
{
print
(
"Error getting current location:
$e
"
);
}
}
Future
<
void
>
getLocationPermission
(
BuildContext
context
)
async
{
isLocationEnabled
=
await
Geolocator
.
isLocationServiceEnabled
();
LocationPermission
permission
=
await
Geolocator
.
checkPermission
();
hasLocationPermission
=
permission
==
LocationPermission
.
always
||
permission
==
LocationPermission
.
whileInUse
;
final
Location
.
Location
location
=
Location
.
Location
();
bool
serviceEnabled
=
await
location
.
serviceEnabled
();
if
(!
serviceEnabled
)
{
serviceEnabled
=
await
location
.
requestService
();
if
(!
serviceEnabled
)
{
return
;
}
}
if
(!
isLocationEnabled
||
!
hasLocationPermission
)
{
permission
=
await
Geolocator
.
requestPermission
();
if
(
permission
!=
LocationPermission
.
always
&&
permission
!=
LocationPermission
.
whileInUse
)
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
Text
(
'Location Permission Required'
),
content:
Text
(
'Please allow the app to access your location for core functionality.'
,
),
actions:
<
Widget
>[
TextButton
(
style:
ButtonStyle
(
backgroundColor:
MaterialStateProperty
.
all
(
Colors
.
white
),
overlayColor:
MaterialStateProperty
.
all
(
Colors
.
white
),
),
onPressed:
()
async
{
// await openAppSettings();
// Navigator.of(context).pop();
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(builder: (context) => Attendance()),
// );
},
child:
Text
(
'OK'
),
),
],
);
},
);
return
;
}
}
final
Location
.
LocationData
locData
=
await
location
.
getLocation
();
if
(
locData
!=
null
)
{
currentLocation
=
locData
;
currentLocationLatLng
=
LatLng
(
locData
.
latitude
!,
locData
.
longitude
!);
markers
.
clear
();
markers
.
add
(
Marker
(
markerId:
MarkerId
(
'current_location'
),
position:
LatLng
(
locData
.
latitude
!,
locData
.
longitude
!),
infoWindow:
InfoWindow
(
title:
'Current Location'
),
icon:
BitmapDescriptor
.
defaultMarker
,
),
);
latlongs
=
'
${locData.latitude}
,
${locData.longitude}
'
;
notifyListeners
();
}
}
Future
<
void
>
ordersAddOrderSelectAccountAPIFunction
(
context
,
mode
,
accountId
,
search
,
)
async
{
print
(
search
);
try
{
if
(
search
.
isEmpty
)
{
_accountList
=
[];
_isLoading
=
false
;
notifyListeners
();
return
;
}
_isLoading
=
true
;
notifyListeners
();
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
AddOrderPaymentSelectAccountAPI
(
provider
.
empId
,
provider
.
session
,
mode
,
search
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_accountList
=
data
.
accountList
!;
if
(
_selectedAccountList
!=
null
&&
!
_accountList
.
contains
(
_selectedAccountList
))
{
_selectedAccountList
=
null
;
_selectedAccountID
=
null
;
_selectedAccountName
=
null
;
}
_isLoading
=
false
;
notifyListeners
();
}
else
{
selectAccountError
=
data
?.
message
??
"Failed to load accounts"
;
_isLoading
=
false
;
notifyListeners
();
}
}
else
{
selectAccountError
=
"No data received from server"
;
_isLoading
=
false
;
notifyListeners
();
}
}
catch
(
e
,
s
)
{
selectAccountError
=
"An error occurred while fetching accounts"
;
_isLoading
=
false
;
notifyListeners
();
}
}
imgFromCamera
(
context
)
async
{
// Capture a photo
try
{
final
XFile
?
galleryImage
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
camera
,
imageQuality:
50
,
);
debugPrint
(
"added"
);
_image
=
File
(
galleryImage
!.
path
);
_imageName
=
File
(
galleryImage
!.
name
);
_imagePicked
=
1
;
FileError
=
null
;
notifyListeners
();
}
catch
(
e
)
{
debugPrint
(
"mmmm:
${e.toString()}
"
);
}
}
imgFromGallery
(
context
)
async
{
// Pick an image
try
{
final
XFile
?
galleryImage
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
gallery
,
);
final
bytes
=
(
await
galleryImage
?.
readAsBytes
())?.
lengthInBytes
;
final
kb
=
bytes
!
/
1024
;
final
mb
=
kb
/
1024
;
debugPrint
(
"Jenny: bytes:
$bytes
, kb:
$kb
, mb:
$mb
"
);
_image
=
File
(
galleryImage
!.
path
);
_imageName
=
File
(
galleryImage
!.
name
);
_imagePicked
=
1
;
FileError
=
null
;
notifyListeners
();
// var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
}
catch
(
e
)
{
debugPrint
(
"mmmm:
${e.toString()}
"
);
}
}
void
onChangedBillingName
(
value
)
{
billingNameError
=
""
;
notifyListeners
();
}
void
onChangedBillingAddress
(
value
)
{
billingAddressError
=
""
;
notifyListeners
();
}
void
onChangedBillingPincode
(
value
)
{
billingPincodeError
=
""
;
notifyListeners
();
}
void
onChangedDispatchAddress
(
value
)
{
dispatchAddressError
=
""
;
notifyListeners
();
}
void
onChangedDispatchPincode
(
value
)
{
dispatchPincodeError
=
""
;
notifyListeners
();
}
void
onChangedGst
(
value
)
{
gstError
=
""
;
notifyListeners
();
}
void
onChangeTpcAmount
(
value
)
{
tpcAmountError
=
""
;
notifyListeners
();
}
void
resetForm
()
{
_submitClicked
=
false
;
dropDownSearchController
.
clear
();
dropDownTpcSearchController
.
clear
();
billingNameController
.
clear
();
billingAddressController
.
clear
();
billingPincodeController
.
clear
();
dispatchAddressController
.
clear
();
dispatchPincodeController
.
clear
();
gstController
.
clear
();
orderReceivedDateController
.
clear
();
tpcAmountController
.
clear
();
gstController
.
clear
();
orderReceivedDateController
.
clear
();
noteController
.
clear
();
ProductControllers
.
forEach
((
action
)
=>
action
.
dispose
());
ProductControllers
.
clear
();
PriceControllers
.
forEach
((
action
)
=>
action
.
dispose
());
PriceControllers
.
clear
();
QuantityControllers
.
forEach
((
action
)
=>
action
.
dispose
());
QuantityControllers
.
clear
();
CGSTControllers
.
forEach
((
action
)
=>
action
.
dispose
());
CGSTControllers
.
clear
();
SGSTControllers
.
forEach
((
action
)
=>
action
.
dispose
());
SGSTControllers
.
clear
();
IGSTControllers
.
forEach
((
action
)
=>
action
.
dispose
());
IGSTControllers
.
clear
();
TotalPriceControllers
.
forEach
((
action
)
=>
action
.
dispose
());
TotalPriceControllers
.
clear
();
TaxableValueControllers
.
forEach
((
action
)
=>
action
.
dispose
());
TaxableValueControllers
.
clear
();
_image
=
null
;
_imageName
=
null
;
_imagePicked
=
0
;
selectAccountError
=
""
;
billingNameError
=
""
;
billingAddressError
=
""
;
billingPincodeError
=
""
;
dispatchAddressError
=
""
;
dispatchPincodeError
=
""
;
_selectedAccountList
=
null
;
_selectedEmployees
=
null
;
_selectedBillingStates
=
null
;
_selectedBillingDistricts
=
null
;
_selectedBillingSubLocations
=
null
;
_selectedDispatchStates
=
null
;
_selectedDispatchDistricts
=
null
;
_selectedDispatchSubLocations
=
null
;
_selectedSaleProducts
=
null
;
_selectedTpcAgent
=
null
;
_selectedUnloadingScope
=
null
;
_selectedFreightScope
=
null
;
_selectedErectionScope
=
null
;
_selectedTpcStatus
=
null
;
_selectedAccountID
=
""
;
_selectedAccountName
=
""
;
_selectedEmployeeID
=
""
;
_selectedEmployeeName
=
""
;
_selectedBillingStateID
=
""
;
_selectedBillingStateName
=
""
;
_selectedBillingDistrictID
=
""
;
_selectedBillingDistrictValue
=
""
;
_selectedBillingSubLocID
=
""
;
_selectedBillingSubLocValue
=
""
;
_selectedDispatchStateID
=
""
;
_selectedDispatchStateName
=
""
;
_selectedDispatchDistrictID
=
""
;
_selectedDispatchDistrictValue
=
""
;
_selectedDispatchSubLocID
=
""
;
_selectedDispatchSubLocValue
=
""
;
_selectedSaleProductID
=
[];
_selectedSaleProductName
=
""
;
_selectedTpcStatus
=
""
;
_selectedTpcAgentID
=
""
;
_selectedTpcAgentValue
=
""
;
gstError
=
""
;
FileError
=
null
;
dateError
=
null
;
checkDropdownselected
();
notifyListeners
();
}
void
showDatePickerDialog
(
BuildContext
context
)
{
if
(
_date
==
null
)
{
setDate
(
DateTime
.
now
(),
);
// Ensure current date is set before opening the picker
}
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
Container
(
height:
216
,
padding:
const
EdgeInsets
.
only
(
top:
6.0
),
margin:
EdgeInsets
.
only
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
),
color:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
child:
SafeArea
(
top:
false
,
child:
Column
(
children:
[
Expanded
(
flex:
1
,
child:
SizedBox
(
height:
40
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
CupertinoButton
(
child:
Text
(
'Cancel'
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
),
),
onPressed:
()
{
Navigator
.
pop
(
context
);
},
),
CupertinoButton
(
child:
Text
(
'Done'
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
),
),
onPressed:
()
{
Navigator
.
pop
(
context
);
},
),
],
),
),
),
Expanded
(
flex:
3
,
child:
CupertinoDatePicker
(
initialDateTime:
_date
??
DateTime
.
now
(),
mode:
CupertinoDatePickerMode
.
date
,
use24hFormat:
true
,
showDayOfWeek:
true
,
onDateTimeChanged:
(
DateTime
newDate
)
{
setDate
(
newDate
);
},
),
),
],
),
),
),
);
}
}
lib/Notifiers/ordersProvider/addPaymentProvider.dart
0 → 100644
View file @
d006edb4
import
'dart:async'
;
import
'dart:io'
;
import
'package:camera/camera.dart'
;
import
'package:dropdown_button2/dropdown_button2.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:intl/intl.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectAccountResponse.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectOrderResponse.dart'
;
class
Addpaymentprovider
extends
ChangeNotifier
{
TextEditingController
dropDownSearchController
=
TextEditingController
();
TextEditingController
amountController
=
TextEditingController
();
TextEditingController
orderAdjustedAmountController
=
TextEditingController
();
TextEditingController
descriptionController
=
TextEditingController
();
TextEditingController
paymentReceivedDateController
=
TextEditingController
();
TextEditingController
paymentRefController
=
TextEditingController
();
String
selectAccountError
=
""
;
String
amountError
=
""
;
String
orderAdjustedAmountError
=
""
;
String
descriptionError
=
""
;
String
paymentModeError
=
""
;
String
paymentRefError
=
""
;
List
<
TextEditingController
>
orderAmountControllers
=
[];
String
?
FileError
;
String
?
dateError
;
bool
_isLoading
=
false
;
int
_imagePicked
=
0
;
File
?
_image
;
File
?
_imageName
;
final
ImagePicker
_picker
=
ImagePicker
();
DateTime
?
_date
;
String
?
_formattedDate
;
Timer
?
_debounce
;
List
<
String
>
_paymentMode
=
[];
List
<
String
>
_description
=
[];
List
<
AccountList
>
_accountList
=
[];
List
<
OrderList
>
_orderList
=
[];
List
<
Map
<
String
,
String
>>
_selectedOrders
=
[];
String
?
_selectedPaymentMode
;
String
?
_selectedDescription
;
AccountList
?
_selectedAccountList
;
String
?
_selectedAccountID
;
String
?
_selectedAccountName
;
OrderList
?
_selectedOrderLists
;
List
<
String
?>
_selectedOrderIds
=
[];
List
<
String
?>
_selectedOrderNumbers
=
[];
List
<
String
?>
_selectedTotalAmounts
=
[];
List
<
String
?>
_selectedBalanceAmounts
=
[];
List
<
String
?>
_selectedCreatedDatetimes
=
[];
List
<
String
>
get
paymentMode
=>
_paymentMode
;
List
<
String
>
get
description
=>
_description
;
bool
get
isLoading
=>
_isLoading
;
List
<
AccountList
>
get
accountList
=>
_accountList
;
List
<
OrderList
>
get
orderList
=>
_orderList
;
List
<
Map
<
String
,
String
>>
get
selectedOrders
=>
_selectedOrders
;
String
?
get
selectedPaymentMode
=>
_selectedPaymentMode
;
String
?
get
selectedDescription
=>
_selectedDescription
;
AccountList
?
get
selectedAccountList
=>
_selectedAccountList
;
String
?
get
selectedAccountID
=>
_selectedAccountID
;
String
?
get
selectedAccountName
=>
_selectedAccountName
;
OrderList
?
get
selectedOrderLists
=>
_selectedOrderLists
;
List
<
String
?>
get
selectedOrderIds
=>
_selectedOrderIds
;
List
<
String
?>
get
selectedOrderNumbers
=>
_selectedOrderNumbers
;
List
<
String
?>
get
selectedTotalAmounts
=>
_selectedTotalAmounts
;
List
<
String
?>
get
selectedBalanceAmounts
=>
_selectedBalanceAmounts
;
List
<
String
?>
get
selectedCreatedDatetimes
=>
_selectedCreatedDatetimes
;
String
?
get
formattedDate
=>
_formattedDate
;
DateTime
?
get
dateNow
=>
_date
;
File
?
get
imagePath
=>
_imageName
;
File
?
get
imageFilePath
=>
_image
;
int
get
imagePicked
=>
_imagePicked
;
set
accountList
(
List
<
AccountList
>
value
){
_accountList
=
value
;
notifyListeners
();
}
set
selectedPaymentMode
(
String
?
value
){
_selectedPaymentMode
=
value
;
paymentModeError
=
""
;
notifyListeners
();
}
set
selectedOrders
(
value
){
_selectedOrders
=
selectedOrders
;
notifyListeners
();
}
set
selectedDescription
(
String
?
value
){
_selectedDescription
=
value
;
notifyListeners
();
}
set
selectedAccountList
(
AccountList
?
value
){
_selectedAccountList
=
value
;
_selectedAccountID
=
value
?.
id
!;
_selectedAccountName
=
value
!.
text
!;
selectAccountError
=
""
;
notifyListeners
();
}
set
selectedAccountID
(
String
?
value
){
_selectedAccountID
=
value
;
notifyListeners
();
}
set
selectedAccountName
(
String
?
value
){
_selectedAccountName
=
value
;
notifyListeners
();
}
set
selectedOrderLists
(
OrderList
?
value
){
_selectedOrderLists
=
value
;
notifyListeners
();
}
void
updateSelectedOrderId
(
int
index
,
OrderList
?
value
)
{
_selectedOrderLists
=
value
!;
_selectedOrderIds
[
index
]
=
value
!.
orderId
;
print
(
_selectedOrderIds
[
index
]);
notifyListeners
();
}
set
selectedOrderNumbers
(
List
<
String
?>
value
)
{
_selectedOrderNumbers
=
value
;
notifyListeners
();
}
set
selectedTotalAmounts
(
List
<
String
?>
value
)
{
_selectedTotalAmounts
=
value
;
notifyListeners
();
}
set
selectedBalanceAmounts
(
List
<
String
?>
value
)
{
_selectedBalanceAmounts
=
value
;
notifyListeners
();
}
set
selectedCreatedDatetimes
(
List
<
String
?>
value
)
{
_selectedCreatedDatetimes
=
value
;
notifyListeners
();
}
set
imagePath
(
File
?
value
)
{
_imageName
=
value
;
notifyListeners
();
}
set
imageFilePath
(
File
?
value
)
{
_image
=
value
;
notifyListeners
();
}
set
imagePicked
(
value
)
{
_imagePicked
=
value
;
notifyListeners
();
}
set
formattedDate
(
String
?
value
)
{
_formattedDate
=
value
;
paymentReceivedDateController
.
text
=
_formattedDate
!;
dateError
=
null
;
notifyListeners
();
}
void
setDate
(
DateTime
newDate
)
{
_date
=
newDate
;
_formattedDate
=
DateFormat
(
'yyyy-MM-dd'
).
format
(
newDate
);
paymentReceivedDateController
.
text
=
_formattedDate
!;
dateError
=
null
;
notifyListeners
();
}
void
addNewRow
()
{
// if (_selectedOrderIds.length < _orderList.length ) {
final
controller
=
TextEditingController
();
// Add a listener to recalculate the total when the text changes
controller
.
addListener
(
_updateAdjustedAmount
);
orderAmountControllers
.
add
(
TextEditingController
());
_selectedOrderIds
.
add
(
null
);
notifyListeners
();
}
void
removeRow
(
int
index
)
{
orderAmountControllers
[
index
].
removeListener
(
_updateAdjustedAmount
);
orderAmountControllers
[
index
].
dispose
();
orderAmountControllers
.
removeAt
(
index
);
_selectedOrderIds
.
removeAt
(
index
);
_updateAdjustedAmount
();
notifyListeners
();
}
void
_updateAdjustedAmount
()
{
int
tempAdjustAmount
=
0
;
for
(
int
i
=
0
;
i
<
orderAmountControllers
.
length
;
i
++)
{
final
text
=
orderAmountControllers
[
i
].
text
;
if
(
_selectedOrderIds
[
i
]
!=
null
&&
text
.
isNotEmpty
)
{
tempAdjustAmount
+=
int
.
tryParse
(
text
)
??
0
;
}
}
orderAdjustedAmountController
.
text
=
tempAdjustAmount
.
toString
();
notifyListeners
();
}
List
<
Map
<
String
,
String
>>
getFormData
()
{
_selectedOrders
=
[];
Map
<
String
,
String
>
latestEntries
=
{};
var
tempAdjustAmount
=
0
;
for
(
int
i
=
0
;
i
<
orderAmountControllers
.
length
;
i
++)
{
if
(
_selectedOrderIds
[
i
]
!=
null
&&
orderAmountControllers
[
i
].
text
.
isNotEmpty
)
{
latestEntries
[
_selectedOrderIds
[
i
]!]
=
orderAmountControllers
[
i
].
text
;
tempAdjustAmount
=
tempAdjustAmount
+
int
.
parse
(
double
.
parse
(
orderAmountControllers
[
i
].
text
).
round
().
toString
());
}
}
_selectedOrders
=
latestEntries
.
entries
.
map
((
entry
)
=>
{
"order_id"
:
entry
.
key
,
"amount"
:
entry
.
value
,
})
.
toList
();
print
(
"Form Data:
$_selectedOrders
"
);
orderAdjustedAmountController
.
text
=
tempAdjustAmount
.
toString
();
print
(
tempAdjustAmount
);
notifyListeners
();
return
_selectedOrders
;
}
Future
<
void
>
ordersAddPaymentAPIViewFunction
(
context
)
async
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
addOrderpaymentListViewAPI
(
provider
.
empId
,
provider
.
session
);
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
_paymentMode
=
data
.
paymentMode
!;
_description
=
data
.
description
!;
checkDropdownselected
();
// if (_selectedAccountList != null &&
// !_accountList.contains(_selectedAccountList)) {
// dropDownSearchController.clear();
// _selectedAccountList = null;
// _selectedAccountID = "";
// _selectedAccountName = "";
// }
notifyListeners
();
}
else
{
}
}
else
{
}
}
catch
(
e
,
s
){
}
}
void
onSearchChanged
(
BuildContext
context
,
String
mode
,
String
?
accountId
,
String
search
)
{
if
(
_debounce
?.
isActive
??
false
)
_debounce
!.
cancel
();
_debounce
=
Timer
(
const
Duration
(
milliseconds:
300
),
()
{
// if (search.isNotEmpty) { // Only call API for non-empty search
ordersAddPaymentSelectAccountAPIFunction
(
context
,
mode
,
accountId
,
search
);
// } else {
// _accountList = []; // Clear list for empty search
// _isLoading = false;
// notifyListeners();
// }
});
}
Future
<
void
>
ordersAddPaymentSelectAccountAPIFunction
(
context
,
mode
,
accountId
,
search
)
async
{
print
(
search
);
try
{
if
(
search
.
isEmpty
)
{
_accountList
=
[];
_isLoading
=
false
;
notifyListeners
();
return
;
}
_isLoading
=
true
;
notifyListeners
();
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
AddOrderPaymentSelectAccountAPI
(
provider
.
empId
,
provider
.
session
,
mode
,
search
);
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
_accountList
=
data
.
accountList
!;
if
(
_selectedAccountList
!=
null
&&
!
_accountList
.
contains
(
_selectedAccountList
))
{
_selectedAccountList
=
null
;
_selectedAccountID
=
null
;
_selectedAccountName
=
null
;
}
_isLoading
=
false
;
notifyListeners
();
if
(
_accountList
.
isNotEmpty
&&
_selectedAccountID
!=
null
)
{
await
ordersAddPaymentSelectOrderAPIFunction
(
context
,
_selectedAccountID
);
}
}
else
{
selectAccountError
=
data
?.
message
??
"Failed to load accounts"
;
_isLoading
=
false
;
notifyListeners
();
}
}
else
{
selectAccountError
=
"No data received from server"
;
_isLoading
=
false
;
notifyListeners
();
}
}
catch
(
e
,
s
){
selectAccountError
=
"An error occurred while fetching accounts"
;
_isLoading
=
false
;
notifyListeners
();
}
}
Future
<
void
>
ordersAddPaymentSelectOrderAPIFunction
(
context
,
accountID
)
async
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
AddOrderPaymentSelectOrderAPI
(
provider
.
empId
,
provider
.
session
,
accountID
);
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
_orderList
=
data
.
orderList
!;
notifyListeners
();
}
else
{
}
}
else
{
}
}
catch
(
e
,
s
){
}
}
Future
<
void
>
ordersAddPaymentAPISubmitFunction
(
context
,
accountId
,
selDescription
,
selectedOrders
,
paymentMode
,)
async
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
addOrderpaymentListSubmitAPI
(
provider
.
empId
,
provider
.
session
,
accountId
,
selDescription
,
selectedOrders
,
amountController
.
text
,
paymentReceivedDateController
.
text
,
paymentMode
,
paymentRefController
.
text
,
_image
);
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
resetForm
();
Navigator
.
pop
(
context
);
}
else
{
}
}
else
{
}
}
catch
(
e
,
s
){
}
}
imgFromCamera
(
context
)
async
{
// Capture a photo
try
{
final
XFile
?
galleryImage
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
camera
,
imageQuality:
50
,
);
debugPrint
(
"added"
);
_image
=
File
(
galleryImage
!.
path
);
_imageName
=
File
(
galleryImage
!.
name
);
_imagePicked
=
1
;
FileError
=
null
;
notifyListeners
();
}
catch
(
e
)
{
debugPrint
(
"mmmm:
${e.toString()}
"
);
}
}
imgFromGallery
(
context
)
async
{
// Pick an image
try
{
final
XFile
?
galleryImage
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
gallery
,
);
final
bytes
=
(
await
galleryImage
?.
readAsBytes
())?.
lengthInBytes
;
final
kb
=
bytes
!
/
1024
;
final
mb
=
kb
/
1024
;
debugPrint
(
"Jenny: bytes:
$bytes
, kb:
$kb
, mb:
$mb
"
);
_image
=
File
(
galleryImage
!.
path
);
_imageName
=
File
(
galleryImage
!.
name
);
_imagePicked
=
1
;
FileError
=
null
;
notifyListeners
();
// var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
}
catch
(
e
)
{
debugPrint
(
"mmmm:
${e.toString()}
"
);
}
}
void
onChangeAmount
(
value
){
amountError
=
""
;
notifyListeners
();
}
void
onChangeorderAdjustedAmount
(
value
){
orderAdjustedAmountError
=
""
;
notifyListeners
();
}
void
onChangeDescription
(
value
){
descriptionError
=
""
;
notifyListeners
();
}
void
onChangepaymentRef
(
value
){
paymentRefError
=
""
;
notifyListeners
();
}
void
resetForm
()
{
dropDownSearchController
.
clear
();
amountController
.
clear
();
orderAdjustedAmountController
.
clear
();
descriptionController
.
clear
();
paymentReceivedDateController
.
clear
();
paymentRefController
.
clear
();
_selectedAccountList
=
null
;
_selectedAccountID
=
null
;
_selectedAccountName
=
null
;
_selectedOrderIds
.
clear
();
_selectedOrderNumbers
.
clear
();
_selectedTotalAmounts
.
clear
();
_selectedBalanceAmounts
.
clear
();
_selectedCreatedDatetimes
.
clear
();
_image
=
null
;
_imageName
=
null
;
_imagePicked
=
0
;
_selectedOrders
.
clear
();
orderAmountControllers
.
forEach
((
controller
)
=>
controller
.
dispose
());
orderAmountControllers
.
clear
();
selectAccountError
=
""
;
amountError
=
""
;
orderAdjustedAmountError
=
""
;
descriptionError
=
""
;
paymentModeError
=
""
;
paymentRefError
=
""
;
FileError
=
null
;
dateError
=
null
;
_accountList
=
[];
_selectedAccountID
=
""
;
_selectedAccountList
=
null
;
_selectedAccountName
=
""
;
checkDropdownselected
();
notifyListeners
();
}
void
checkDropdownselected
()
{
if
(
_selectedAccountList
!=
null
&&
!
_accountList
.
contains
(
_selectedAccountList
))
{
_selectedAccountID
=
null
;
_selectedAccountName
=
""
;
}
if
(
_selectedOrderLists
!=
null
&&
!
_orderList
.
contains
(
_selectedOrderLists
)){
_selectedOrderLists
=
null
;
_selectedOrderIds
.
clear
();
_selectedOrderIds
=
[];
_selectedOrderIds
.
clear
();
_selectedOrderNumbers
.
clear
();
_selectedTotalAmounts
.
clear
();
_selectedBalanceAmounts
.
clear
();
_selectedCreatedDatetimes
.
clear
();
}
notifyListeners
();
}
void
showDatePickerDialog
(
BuildContext
context
)
{
if
(
_date
==
null
)
{
setDate
(
DateTime
.
now
());
// Ensure current date is set before opening the picker
}
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
Container
(
height:
216
,
padding:
const
EdgeInsets
.
only
(
top:
6.0
),
margin:
EdgeInsets
.
only
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
),
color:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
child:
SafeArea
(
top:
false
,
child:
Column
(
children:
[
Expanded
(
flex:
1
,
child:
SizedBox
(
height:
40
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
CupertinoButton
(
child:
Text
(
'Cancel'
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
),
),
onPressed:
()
{
Navigator
.
pop
(
context
);
},
),
CupertinoButton
(
child:
Text
(
'Done'
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
),
),
onPressed:
()
{
Navigator
.
pop
(
context
);
},
),
],
),
),
),
Expanded
(
flex:
3
,
child:
CupertinoDatePicker
(
initialDateTime:
_date
??
DateTime
.
now
(),
mode:
CupertinoDatePickerMode
.
date
,
use24hFormat:
true
,
showDayOfWeek:
true
,
onDateTimeChanged:
(
DateTime
newDate
)
{
setDate
(
newDate
);
},
),
),
],
),
),
),
);
}
}
\ No newline at end of file
lib/Notifiers/ordersProvider/editPaymentProvider.dart
0 → 100644
View file @
d006edb4
import
'package:flutter/cupertino.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/Utils/commonServices.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectOrderResponse.dart'
;
import
'addPaymentProvider.dart'
;
class
Editpaymentprovider
extends
ChangeNotifier
{
bool
_submitLoading
=
false
;
bool
get
submitLoading
=>
_submitLoading
;
set
submitLoading
(
bool
value
){
_submitLoading
=
value
;
notifyListeners
();
}
List
<
OrderList
>
_orderList
=
[];
List
<
Map
<
String
,
String
>>
_selectedOrders
=
[];
OrderList
?
_selectedOrderLists
;
List
<
String
?>
_selectedOrderIds
=
[];
List
<
TextEditingController
>
orderAmountControllers
=
[];
TextEditingController
orderAdjustedAmountController
=
TextEditingController
();
List
<
Map
<
String
,
String
>?>
_rowMetadata
=
[];
List
<
OrderList
>
get
orderList
=>
_orderList
;
OrderList
?
get
selectedOrderLists
=>
_selectedOrderLists
;
set
selectedOrderLists
(
OrderList
?
value
){
_selectedOrderLists
=
value
;
notifyListeners
();
}
Future
<
void
>
ordersAddPaymentSelectOrderAPIFunction
(
context
,
accountID
)
async
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
AddOrderPaymentSelectOrderAPI
(
provider
.
empId
,
provider
.
session
,
accountID
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_orderList
=
data
.
orderList
!;
notifyListeners
();
}
else
{
print
(
"API Error:
${data.error}
"
);
}
}
else
{
print
(
"API returned null data"
);
}
}
catch
(
e
,
s
)
{
print
(
"Error:
$e
, Stack:
$s
"
);
}
}
void
addNewRow
()
{
final
controller
=
TextEditingController
();
controller
.
addListener
(
_updateAdjustedAmount
);
orderAmountControllers
.
add
(
controller
);
_selectedOrderIds
.
add
(
null
);
_rowMetadata
.
add
(
null
);
// New row, no metadata
notifyListeners
();
}
void
addRowWithMetadata
(
Map
<
String
,
String
>
metadata
)
{
final
controller
=
TextEditingController
();
controller
.
addListener
(
_updateAdjustedAmount
);
orderAmountControllers
.
add
(
controller
);
_selectedOrderIds
.
add
(
null
);
_rowMetadata
.
add
(
metadata
);
// Store metadata for existing order
notifyListeners
();
}
void
removeRow
(
int
index
)
{
orderAmountControllers
[
index
].
removeListener
(
_updateAdjustedAmount
);
orderAmountControllers
[
index
].
dispose
();
orderAmountControllers
.
removeAt
(
index
);
_selectedOrderIds
.
removeAt
(
index
);
_rowMetadata
.
removeAt
(
index
);
_updateAdjustedAmount
();
notifyListeners
();
}
void
_updateAdjustedAmount
()
{
int
tempAdjustAmount
=
0
;
for
(
int
i
=
0
;
i
<
orderAmountControllers
.
length
;
i
++)
{
final
text
=
orderAmountControllers
[
i
].
text
;
if
(
_selectedOrderIds
[
i
]
!=
null
&&
text
.
isNotEmpty
)
{
tempAdjustAmount
+=
int
.
tryParse
(
text
)
??
0
;
}
}
orderAdjustedAmountController
.
text
=
tempAdjustAmount
.
toString
();
notifyListeners
();
}
List
<
Map
<
String
,
String
>>
getFormData
()
{
_selectedOrders
=
[];
int
tempAdjustAmount
=
0
;
for
(
int
i
=
0
;
i
<
orderAmountControllers
.
length
;
i
++)
{
if
(
_selectedOrderIds
[
i
]
!=
null
&&
orderAmountControllers
[
i
].
text
.
isNotEmpty
)
{
final
amount
=
orderAmountControllers
[
i
].
text
;
tempAdjustAmount
+=
int
.
parse
(
double
.
parse
(
amount
).
round
().
toString
());
if
(
_rowMetadata
[
i
]
!=
null
)
{
// Existing order from widget.values
_selectedOrders
.
add
({
"order_id"
:
_rowMetadata
[
i
]![
"order_id"
]!,
"order_payment_id"
:
_rowMetadata
[
i
]![
"order_payment_id"
]!,
"selected_order_id"
:
_selectedOrderIds
[
i
]!,
"updateable_payment_amount"
:
amount
,
});
}
else
{
// New row added by user
_selectedOrders
.
add
({
"selected_order_id"
:
_selectedOrderIds
[
i
]!,
"insert_amount"
:
amount
,
});
}
}
}
print
(
"Form Data:
$_selectedOrders
"
);
orderAdjustedAmountController
.
text
=
tempAdjustAmount
.
toString
();
print
(
"Total Adjusted Amount:
$tempAdjustAmount
"
);
notifyListeners
();
return
_selectedOrders
;
}
Future
<
void
>
editPaymentDetailsAPIFunction
(
context
,
payment_id
,
description
,
payment_type
,
ref_no
,
payment_date
,
amount
)
async
{
try
{
_submitLoading
=
true
;
notifyListeners
();
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
addOrderProvider
=
Provider
.
of
<
Addpaymentprovider
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
ordersEditPaymentDetailsAPI
(
provider
.
empId
,
provider
.
session
,
payment_id
,
description
,
payment_type
,
ref_no
,
payment_date
,
amount
);
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
_submitLoading
=
false
;
addOrderProvider
.
resetForm
();
Navigator
.
pop
(
context
);
toast
(
context
,
data
.
message
);
notifyListeners
();
}
else
if
(
data
.
error
==
"1"
){
_submitLoading
=
false
;
notifyListeners
();
}
}
else
{
_submitLoading
=
false
;
notifyListeners
();
}
}
catch
(
e
,
s
){
_submitLoading
=
false
;
notifyListeners
();
}
}
void
updateSelectedOrderId
(
int
index
,
OrderList
?
value
)
{
if
(
value
!=
null
)
{
_selectedOrderLists
=
value
;
_selectedOrderIds
[
index
]
=
value
.
orderId
;
print
(
"Selected Order ID at index
$index
:
${_selectedOrderIds[index]}
"
);
notifyListeners
();
}
}
void
resetForm
()
{
for
(
var
controller
in
orderAmountControllers
)
{
controller
.
removeListener
(
_updateAdjustedAmount
);
controller
.
dispose
();
}
orderAmountControllers
.
clear
();
_selectedOrderIds
.
clear
();
_rowMetadata
.
clear
();
_selectedOrders
.
clear
();
orderAdjustedAmountController
.
clear
();
submitLoading
=
false
;
notifyListeners
();
}
}
lib/main.dart
View file @
d006edb4
...
@@ -198,6 +198,9 @@ class MyApp extends StatelessWidget {
...
@@ -198,6 +198,9 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider
(
create:
(
_
)
=>
Pagesdashboardprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Pagesdashboardprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Paymentsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Paymentsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Tpcagentsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Tpcagentsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Addpaymentprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Addorderprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Editpaymentprovider
(),),
],
],
child:
Builder
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
...
...
lib/screens/HomeScreen.dart
View file @
d006edb4
...
@@ -120,8 +120,8 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -120,8 +120,8 @@ class _MyHomePageState extends State<MyHomePage> {
"Whizzdom"
,
"Whizzdom"
,
"Common"
,
"Common"
,
"Finance"
,
"Finance"
,
"Orders"
,
//
"Orders",
"CRM"
,
//
"CRM",
];
];
final
icons
=
[
final
icons
=
[
"assets/svg/home_icons_1.svg"
,
"assets/svg/home_icons_1.svg"
,
...
@@ -133,8 +133,8 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -133,8 +133,8 @@ class _MyHomePageState extends State<MyHomePage> {
"assets/svg/home_icons_81.svg"
,
"assets/svg/home_icons_81.svg"
,
"assets/svg/home_icons_9.svg"
,
"assets/svg/home_icons_9.svg"
,
"assets/svg/home_icons_10.svg"
,
"assets/svg/home_icons_10.svg"
,
"assets/svg/home_icons_11.svg"
,
//
"assets/svg/home_icons_11.svg",
"assets/svg/home_icons_12.svg"
,
//
"assets/svg/home_icons_12.svg",
];
];
final
requiredRoles
=
[
final
requiredRoles
=
[
"430"
,
"430"
,
...
@@ -146,8 +146,8 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -146,8 +146,8 @@ class _MyHomePageState extends State<MyHomePage> {
"431"
,
"431"
,
"430"
,
"430"
,
"430"
,
"430"
,
"430"
,
//
"430",
"430"
,
//
"430",
];
];
final
filteredItems
=
<
Map
<
String
,
String
>>[];
final
filteredItems
=
<
Map
<
String
,
String
>>[];
...
...
lib/screens/notifierExports.dart
View file @
d006edb4
...
@@ -35,4 +35,7 @@ export 'package:generp/Notifiers/financeProvider/approveRejectPaymentRequestResp
...
@@ -35,4 +35,7 @@ export 'package:generp/Notifiers/financeProvider/approveRejectPaymentRequestResp
export
'package:generp/Notifiers/ordersProvider/pagesDashboardProvider.dart'
;
export
'package:generp/Notifiers/ordersProvider/pagesDashboardProvider.dart'
;
export
'package:generp/Notifiers/ordersProvider/paymentsProvider.dart'
;
export
'package:generp/Notifiers/ordersProvider/paymentsProvider.dart'
;
export
'package:generp/Notifiers/ordersProvider/tpcAgentsProvider.dart'
;
export
'package:generp/Notifiers/ordersProvider/tpcAgentsProvider.dart'
;
\ No newline at end of file
export
'package:generp/Notifiers/ordersProvider/addPaymentProvider.dart'
;
export
'package:generp/Notifiers/ordersProvider/addOrderProvider.dart'
;
export
'package:generp/Notifiers/ordersProvider/editPaymentProvider.dart'
;
lib/screens/order/addOrder.dart
0 → 100644
View file @
d006edb4
import
'package:dropdown_button2/dropdown_button2.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:generp/Models/commonModels/DistrictsResponse.dart'
;
import
'package:generp/Models/commonModels/SubLocationsResponse.dart'
;
import
'package:generp/screens/notifierExports.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/ordersModels/AddOrderViewResponse.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/commonWidgets.dart'
;
class
AddorderScreen
extends
StatefulWidget
{
final
pageTitleName
;
final
mode
;
const
AddorderScreen
({
super
.
key
,
this
.
pageTitleName
,
this
.
mode
});
@override
State
<
AddorderScreen
>
createState
()
=>
_AddorderScreenState
();
}
class
_AddorderScreenState
extends
State
<
AddorderScreen
>
{
FocusNode
focusNode
=
FocusNode
();
FocusNode
focusNodetpc
=
FocusNode
();
@override
void
initState
()
{
// TODO: implement initState
super
.
initState
();
WidgetsBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
var
provider
=
Provider
.
of
<
Addorderprovider
>(
context
,
listen:
false
);
if
(
provider
.
dateNow
==
null
)
{
provider
.
setDate
(
DateTime
.
now
());
}
provider
.
getLocationPermission
(
context
);
provider
.
getCurrentLocation
();
provider
.
ordersAddOrderAPIViewFunction
(
context
,
widget
.
mode
);
});
}
@override
void
dispose
()
{
super
.
dispose
();
}
Future
<
bool
>
_onBackPressed
(
BuildContext
context
)
async
{
Navigator
.
pop
(
context
,
true
);
return
true
;
}
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer
<
Addorderprovider
>(
builder:
(
context
,
provider
,
child
)
{
return
WillPopScope
(
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
backgroundColor:
AppColors
.
white
,
appBar:
appbar2
(
context
,
"
${widget.pageTitleName}
"
,
provider
.
resetForm
,
SizedBox
(
width:
0
,)),
body:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
20
),
),
child:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
TextWidget
(
context
,
"Account"
),
Container
(
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
ListTile
(
title:
TextFormField
(
focusNode:
focusNode
,
onTapUpOutside:
(
event
)
{
focusNode
.
unfocus
();
},
controller:
provider
.
dropDownSearchController
,
onChanged:
(
value
)
async
{
Future
.
delayed
(
Duration
(
milliseconds:
100
),
()
async
{
await
provider
.
ordersAddOrderSelectAccountAPIFunction
(
context
,
widget
.
mode
,
provider
.
selectedAccountID
,
value
,
);
});
},
decoration:
InputDecoration
(
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
isDense:
true
,
contentPadding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
8
,
),
hintText:
'Select Account Type'
,
hintStyle:
const
TextStyle
(
fontSize:
12
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
8
),
),
),
),
trailing:
InkResponse
(
onTap:
()
{
if
(
focusNode
.
hasFocus
)
{
focusNode
.
unfocus
();
}
else
{
FocusScope
.
of
(
context
).
requestFocus
(
focusNode
);
}
},
child:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
),
),
),
if
(
provider
.
accountList
.
isNotEmpty
&&
focusNode
.
hasFocus
)
...[
Card
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
0
),
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
height:
150
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
16
),
),
child:
Scrollbar
(
thickness:
2.5
,
radius:
Radius
.
circular
(
6
),
thumbVisibility:
true
,
child:
ListView
.
builder
(
itemCount:
provider
.
accountList
.
length
,
shrinkWrap:
true
,
physics:
AlwaysScrollableScrollPhysics
(),
itemBuilder:
(
context
,
index
)
{
return
InkResponse
(
onTap:
()
async
{
if
(
provider
.
accountList
.
isNotEmpty
)
{
provider
.
selectedAccountList
=
provider
.
accountList
[
index
];
print
(
"Selected Complaint Type:
${provider.accountList[index].text}
, ID:
${provider.accountList[index].id}
"
,
);
provider
.
selectedAccountID
=
provider
.
accountList
[
index
].
id
!;
provider
.
selectedAccountName
=
provider
.
accountList
[
index
].
text
!;
print
(
"hfjkshfg"
+
provider
.
selectedAccountID
.
toString
(),
);
provider
.
dropDownSearchController
.
text
=
provider
.
accountList
[
index
].
text
!;
provider
.
ordersAddOrderAccountDetailsAPIFunction
(
context
,
provider
.
selectedAccountID
);
}
// provider.ordersAddPaymentSelectOrderAPIFunction(context, provider.selectedAccountID);
provider
.
accountList
=
[];
},
child:
SizedBox
(
height:
45
,
child:
Align
(
alignment:
Alignment
.
centerLeft
,
child:
Text
(
provider
.
accountList
[
index
].
text
!,
),
),
),
);
},
),
),
),
),
],
ErrorWidget
(
context
,
provider
.
selectAccountError
),
if
(
widget
.
mode
==
"admin"
)
...[
TextWidget
(
context
,
"Sales Person"
),
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
Employees
>(
isExpanded:
true
,
hint:
Text
(
"Select Sales Person"
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
items:
provider
.
employees
.
map
(
(
e
)
=>
DropdownMenuItem
<
Employees
>(
value:
e
,
child:
Text
(
e
.
name
!,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedEmployees
,
onChanged:
(
Employees
?
value
)
{
if
(
provider
.
employees
.
isNotEmpty
)
{
provider
.
selectedEmployees
=
value
;
provider
.
selectedEmployeeID
=
value
!.
id
!;
provider
.
selectedEmployeeName
=
value
!.
name
!;
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
],
TextWidget
(
context
,
"Order Received Date"
),
GestureDetector
(
onTap:
()
{
provider
.
showDatePickerDialog
(
context
);
},
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Expanded
(
child:
Container
(
height:
50
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
10.0
,
0.0
,
10
,
0
,
),
child:
TextFormField
(
controller:
provider
.
orderReceivedDateController
,
keyboardType:
TextInputType
.
text
,
enabled:
false
,
maxLines:
1
,
readOnly:
true
,
onChanged:
(
value
)
{},
decoration:
InputDecoration
(
hintText:
"Enter Date"
,
hintStyle:
TextStyle
(
fontWeight:
FontWeight
.
w400
,
color:
Color
(
0xFFB4BEC0
),
fontSize:
14
,
),
enabledBorder:
InputBorder
.
none
,
disabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
),
),
),
),
),
],
),
),
ErrorWidget
(
context
,
provider
.
dateError
),
textControllerWidget
(
context
,
provider
.
billingNameController
,
"Billing Name"
,
provider
.
onChangedBillingName
,
),
ErrorWidget
(
context
,
provider
.
billingNameError
),
TextWidget
(
context
,
"Billing State"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
States
>(
isExpanded:
true
,
hint:
Text
(
"Select State"
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
items:
provider
.
billingStates
.
map
(
(
e
)
=>
DropdownMenuItem
<
States
>(
value:
e
,
child:
Text
(
e
.
name
!,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selecetdBillingStates
,
onChanged:
(
States
?
value
)
{
if
(
provider
.
billingStates
.
isNotEmpty
)
{
provider
.
selecetdBillingStates
=
value
;
provider
.
selectedBillingStateID
=
value
!.
id
!;
provider
.
selectedBillingStateName
=
value
!.
name
!;
if
(
provider
.
billingDistricts
.
isNotEmpty
){
provider
.
billingDistricts
.
clear
();
provider
.
selectedBillingDistricts
=
null
;
provider
.
selectedBillingDistrictId
=
null
;
provider
.
selectedBillingDistrictValue
=
""
;
}
provider
.
getDistrictAPI
(
context
,
provider
.
selectedBillingStateID
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
TextWidget
(
context
,
"Billing District"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
Districts
>(
isExpanded:
true
,
hint:
Text
(
"Select District"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
billingDistricts
.
map
(
(
e
)
=>
DropdownMenuItem
<
Districts
>(
value:
e
,
child:
Text
(
e
.
district
!,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedBillingDistricts
,
onChanged:
(
Districts
?
value
)
{
if
(
provider
.
billingDistricts
.
isNotEmpty
)
{
provider
.
selectedBillingDistricts
=
value
;
provider
.
selectedBillingDistrictId
=
value
!.
id
!;
provider
.
selectedBillingDistrictValue
=
value
!.
district
!;
if
(
provider
.
billingSubLocations
.
isNotEmpty
){
provider
.
billingSubLocations
.
clear
();
provider
.
selectedBillingSubLocations
=
null
;
provider
.
selectedBillingSubLocID
=
null
;
provider
.
selectedBillingSubLocValue
=
""
;
}
provider
.
getSubLocationAPI
(
context
,
provider
.
selectedBillingDistrictId
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
TextWidget
(
context
,
"Billing Sub Location"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
SubLocations
>(
hint:
Text
(
"Select Sub Locality"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
billingSubLocations
.
map
(
(
e
)
=>
DropdownMenuItem
<
SubLocations
>(
value:
e
,
child:
Text
(
e
.
subLocality
!,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedBillingSubLocations
,
onChanged:
(
SubLocations
?
value
)
{
if
(
provider
.
billingSubLocations
.
isNotEmpty
)
{
provider
.
selectedBillingSubLocations
=
value
;
provider
.
selectedBillingSubLocID
=
value
!.
id
!;
provider
.
selectedBillingSubLocValue
=
value
!.
subLocality
!;
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
textControllerWidget
(
context
,
provider
.
billingAddressController
,
"Billing Address"
,
provider
.
onChangedBillingAddress
,
),
ErrorWidget
(
context
,
provider
.
billingAddressError
),
textControllerWidget
(
context
,
provider
.
billingPincodeController
,
"Billing Pin code"
,
provider
.
onChangedBillingPincode
,
),
ErrorWidget
(
context
,
provider
.
billingPincodeError
),
TextWidget
(
context
,
"Dispatch State"
),
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
States
>(
isExpanded:
true
,
hint:
Text
(
"Select State"
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
items:
provider
.
dispatchStates
.
map
(
(
e
)
=>
DropdownMenuItem
<
States
>(
value:
e
,
child:
Text
(
e
.
name
!,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selecetdDispatchStates
,
onChanged:
(
States
?
value
)
{
if
(
provider
.
dispatchStates
.
isNotEmpty
)
{
provider
.
selecetdDispatchStates
=
value
;
provider
.
selectedDispatchStateID
=
value
!.
id
!;
provider
.
selectedDispatchStateName
=
value
!.
name
!;
if
(
provider
.
dispatchDistricts
.
isNotEmpty
){
provider
.
dispatchDistricts
.
clear
();
provider
.
selectedDispatchDistricts
=
null
;
provider
.
selectedDispatchDistrictId
=
null
;
provider
.
selectedDispatchDistrictValue
=
""
;
}
provider
.
getDispatchDistrictAPI
(
context
,
provider
.
selectedDispatchStateID
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
//dd
TextWidget
(
context
,
"Dispatch District"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
Districts
>(
isExpanded:
true
,
hint:
Text
(
"Select District"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
dispatchDistricts
.
map
(
(
e
)
=>
DropdownMenuItem
<
Districts
>(
value:
e
,
child:
Text
(
e
.
district
!,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedDispatchDistricts
,
onChanged:
(
Districts
?
value
)
{
if
(
provider
.
dispatchDistricts
.
isNotEmpty
)
{
provider
.
selectedDispatchDistricts
=
value
;
provider
.
selectedDispatchDistrictId
=
value
!.
id
!;
provider
.
selectedDispatchDistrictValue
=
value
!.
district
!;
if
(
provider
.
dispatchSubLocations
.
isNotEmpty
){
provider
.
dispatchSubLocations
.
clear
();
provider
.
selectedDispatchSubLocations
=
null
;
provider
.
selectedDispatchSubLocID
=
null
;
provider
.
selectedDispatchSubLocValue
=
""
;
}
provider
.
getDispatchSubLocationAPI
(
context
,
provider
.
selectedDispatchDistrictId
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
TextWidget
(
context
,
"Dispatch Sub Location"
),
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
SubLocations
>(
hint:
Text
(
"Select Sub Locality"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
dispatchSubLocations
.
map
(
(
e
)
=>
DropdownMenuItem
<
SubLocations
>(
value:
e
,
child:
Text
(
e
.
subLocality
!,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedDispatchSubLocations
,
onChanged:
(
SubLocations
?
value
)
{
if
(
provider
.
dispatchSubLocations
.
isNotEmpty
)
{
provider
.
selectedDispatchSubLocations
=
value
;
provider
.
selectedDispatchSubLocID
=
value
!.
id
!;
provider
.
selectedDispatchSubLocValue
=
value
!.
subLocality
!;
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
//dd
textControllerWidget
(
context
,
provider
.
dispatchAddressController
,
"Dispatch Address"
,
provider
.
onChangedDispatchAddress
,
),
ErrorWidget
(
context
,
provider
.
dispatchAddressError
),
textControllerWidget
(
context
,
provider
.
dispatchPincodeController
,
"Dispatch Pin code"
,
provider
.
onChangedDispatchPincode
,
),
ErrorWidget
(
context
,
provider
.
dispatchPincodeError
),
textControllerWidget
(
context
,
provider
.
gstController
,
"GST Number"
,
provider
.
onChangedGst
,
),
ErrorWidget
(
context
,
provider
.
gstError
),
InkResponse
(
onTap:
()
{
_showAttachmentSheet
(
context
);
},
child:
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
),
height:
45
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
decoration:
BoxDecoration
(
color:
Color
(
0xFFE6F6FF
),
borderRadius:
BorderRadius
.
circular
(
12
),
border:
Border
.
all
(
color:
AppColors
.
app_blue
,
width:
0.5
,
),
),
child:
Center
(
child:
Text
(
"Upload Purchase Order"
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
,
color:
AppColors
.
app_blue
,
),
),
),
),
),
if
(
provider
.
imagePicked
==
1
&&
provider
.
imagePath
!=
null
)
...[
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
4.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
"
${provider.imagePath}
"
,
style:
TextStyle
(
color:
AppColors
.
semi_black
,
fontSize:
11
,
fontWeight:
FontWeight
.
w600
,
),
),
InkResponse
(
onTap:
()
{
provider
.
imagePicked
=
0
;
provider
.
imagePath
=
null
;
provider
.
imageFilePath
=
null
;
},
child:
SvgPicture
.
asset
(
"assets/svg/ic_close.svg"
,
width:
15
,
height:
15
,
),
),
],
),
),
],
TextWidget
(
context
,
"Unloading Scope"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
hint:
Text
(
"Select Unloading Scope"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
unloadingScope
.
map
(
(
e
)
=>
DropdownMenuItem
<
String
>(
value:
e
!,
child:
Text
(
e
,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedUnloadingScope
,
onChanged:
(
String
?
value
)
{
if
(
provider
.
unloadingScope
.
isNotEmpty
)
{
provider
.
selectedUnloadingScope
=
value
;
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
TextWidget
(
context
,
"Freight Scope"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
hint:
Text
(
"Select Freight Scope"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
freightScope
.
map
(
(
e
)
=>
DropdownMenuItem
<
String
>(
value:
e
!,
child:
Text
(
e
,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedFreightScope
,
onChanged:
(
String
?
value
)
{
if
(
provider
.
freightScope
.
isNotEmpty
)
{
provider
.
selectedFreightScope
=
value
;
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
TextWidget
(
context
,
"Erection Scope"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
hint:
Text
(
"Select Erection Scope"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
erectionScope
.
map
(
(
e
)
=>
DropdownMenuItem
<
String
>(
value:
e
!,
child:
Text
(
e
,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedErectionScope
,
onChanged:
(
String
?
value
)
{
if
(
provider
.
erectionScope
.
isNotEmpty
)
{
provider
.
selectedErectionScope
=
value
;
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
TextWidget
(
context
,
"TPC Applicable"
),
//dd
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
hint:
Text
(
"TPC Applicable"
,
style:
const
TextStyle
(
fontSize:
14
),
),
items:
provider
.
tpcApplicable
.
map
(
(
e
)
=>
DropdownMenuItem
<
String
>(
value:
e
!,
child:
Text
(
e
,
style:
const
TextStyle
(
fontSize:
14
,
),
),
),
)
.
toList
(),
value:
provider
.
selectedTpcStatus
,
onChanged:
(
String
?
value
)
{
if
(
provider
.
tpcApplicable
.
isNotEmpty
)
{
provider
.
selectedTpcStatus
=
value
;
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
if
(
provider
.
selectedTpcStatus
==
"Yes"
)...[
TextWidget
(
context
,
"TPC Agent"
),
//dd
Container
(
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
ListTile
(
title:
TextFormField
(
focusNode:
focusNodetpc
,
onTapUpOutside:
(
event
)
{
focusNodetpc
.
unfocus
();
},
controller:
provider
.
dropDownTpcSearchController
,
onChanged:
(
value
)
async
{
Future
.
delayed
(
Duration
(
milliseconds:
100
),
()
async
{
await
provider
.
ordersAddOrderTPCAgentFunction
(
context
,
widget
.
mode
,
value
,
);
});
},
decoration:
InputDecoration
(
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
isDense:
true
,
contentPadding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
8
,
),
hintText:
'Select TPC Agent'
,
hintStyle:
const
TextStyle
(
fontSize:
12
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
8
),
),
),
),
trailing:
InkResponse
(
onTap:
()
{
if
(
focusNodetpc
.
hasFocus
)
{
focusNodetpc
.
unfocus
();
}
else
{
FocusScope
.
of
(
context
).
requestFocus
(
focusNodetpc
);
}
},
child:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
),
),
),
if
(
provider
.
tpcAgent
.
isNotEmpty
&&
focusNodetpc
.
hasFocus
)
...[
Card
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
0
),
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
height:
150
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
16
),
),
child:
Scrollbar
(
thickness:
2.5
,
radius:
Radius
.
circular
(
6
),
thumbVisibility:
true
,
child:
ListView
.
builder
(
itemCount:
provider
.
tpcAgent
.
length
,
shrinkWrap:
true
,
physics:
AlwaysScrollableScrollPhysics
(),
itemBuilder:
(
context
,
index
)
{
return
InkResponse
(
onTap:
()
async
{
if
(
provider
.
tpcAgent
.
isNotEmpty
)
{
provider
.
selectedTpcAgent
=
provider
.
tpcAgent
[
index
];
print
(
"Selected Complaint Type:
${provider.tpcAgent[index].text}
, ID:
${provider.tpcAgent[index].id}
"
,
);
provider
.
selectedTpcAgentID
=
provider
.
tpcAgent
[
index
].
id
!;
provider
.
selectedTpcAgentValue
=
provider
.
tpcAgent
[
index
].
text
!;
print
(
"hfjkshfg"
+
provider
.
selectedTpcAgentID
.
toString
(),
);
provider
.
dropDownSearchController
.
text
=
provider
.
accountList
[
index
].
text
!;
}
// provider.ordersAddPaymentSelectOrderAPIFunction(context, provider.selectedAccountID);
// provider.tpcAgent = [];
},
child:
SizedBox
(
height:
45
,
child:
Align
(
alignment:
Alignment
.
centerLeft
,
child:
Text
(
provider
.
tpcAgent
[
index
].
text
!,
),
),
),
);
},
),
),
),
),
],
textControllerWidget
(
context
,
provider
.
tpcAmountController
,
"TPC Amount"
,
provider
.
onChangeTpcAmount
,
),
ErrorWidget
(
context
,
provider
.
tpcAmountError
),
],
///Addorderbutton
OrderForm
()
//dd
],
),
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation
.
centerFloat
,
bottomNavigationBar:
InkResponse
(
onTap:
provider
.
submitClicked
?
null
:
()
{
provider
.
submitClicked
=
true
;
var
order_prod_data
=
provider
.
getFormData
();
print
(
order_prod_data
);
provider
.
getCurrentLocation
();
provider
.
ordersAddOrderAPISubmitFunction
(
context
,
widget
.
mode
,
provider
.
selectedEmployeeID
,
provider
.
selectedAccountID
,
provider
.
selectedDispatchDistrictId
,
provider
.
selectedDispatchSubLocID
,
provider
.
selectedUnloadingScope
,
provider
.
selectedFreightScope
,
provider
.
selectedErectionScope
,
provider
.
selectedTpcStatus
,
provider
.
selectedTpcStatus
,
provider
.
selectedBillingStateID
,
provider
.
selectedBillingDistrictId
,
provider
.
selectedBillingSubLocID
,
provider
.
selectedTpcAgentID
,
order_prod_data
);
},
child:
Container
(
height:
45
,
alignment:
Alignment
.
center
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
15
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
5
),
decoration:
BoxDecoration
(
color:
AppColors
.
app_blue
,
borderRadius:
BorderRadius
.
circular
(
15
),
),
child:
provider
.
submitClicked
?
CircularProgressIndicator
.
adaptive
(
valueColor:
AlwaysStoppedAnimation
<
Color
>(
AppColors
.
app_blue
),
):
Text
(
"Submit"
,
style:
TextStyle
(
fontSize:
15
,
fontFamily:
"JakartaMedium"
,
color:
Colors
.
white
,
),
),
),
),
),
onWillPop:
()
async
{
provider
.
resetForm
();
return
_onBackPressed
(
context
);
},
);
},
);
}
Widget
TextWidget
(
context
,
text
)
{
return
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
text
),
);
}
Widget
ErrorWidget
(
context
,
text
)
{
if
(
text
!=
null
)
return
Text
(
text
!,
style:
TextStyle
(
color:
Colors
.
red
,
fontSize:
12
));
else
return
SizedBox
(
height:
10
);
}
Widget
textControllerWidget
(
context
,
controller
,
hintText
,
Function
(
String
)?
onChanged
,
)
{
return
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
hintText
),
),
Container
(
height:
hintText
==
"Enter Description"
?
150
:
50
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
10.0
,
0.0
,
10
,
0
),
child:
TextFormField
(
controller:
controller
,
keyboardType:
TextInputType
.
text
,
maxLines:
hintText
==
"Enter Description"
?
60
:
1
,
onChanged:
onChanged
,
decoration:
InputDecoration
(
hintText:
hintText
,
hintStyle:
TextStyle
(
fontWeight:
FontWeight
.
w400
,
color:
Color
(
0xFFB4BEC0
),
fontSize:
14
,
),
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
),
),
),
),
],
);
}
Future
<
void
>
_showAttachmentSheet
(
BuildContext
context
)
{
return
showModalBottomSheet
(
useSafeArea:
true
,
isDismissible:
true
,
isScrollControlled:
true
,
showDragHandle:
true
,
backgroundColor:
Colors
.
white
,
enableDrag:
true
,
context:
context
,
builder:
(
context
)
{
return
StatefulBuilder
(
builder:
(
context
,
setState
)
{
return
SafeArea
(
child:
Consumer
<
Addorderprovider
>(
builder:
(
context
,
provider
,
child
)
{
return
Padding
(
padding:
EdgeInsets
.
only
(
bottom:
MediaQuery
.
of
(
context
,
).
viewInsets
.
bottom
,
// This handles keyboard
),
child:
Container
(
margin:
EdgeInsets
.
only
(
bottom:
15
,
left:
15
,
right:
15
,
top:
10
,
),
child:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
mainAxisSize:
MainAxisSize
.
min
,
children:
[
Align
(
alignment:
Alignment
.
center
,
child:
Text
(
"Select Source"
,
style:
TextStyle
(
color:
AppColors
.
app_blue
,
fontFamily:
"JakrtaMedium"
,
fontSize:
16
,
),
),
),
SizedBox
(
height:
15
),
InkWell
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
provider
.
imgFromGallery
(
context
);
},
child:
Container
(
height:
35
,
child:
Text
(
"Select photo from gallery"
),
),
),
SizedBox
(
height:
10
),
InkWell
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
provider
.
imgFromCamera
(
context
);
},
child:
Container
(
height:
35
,
child:
Text
(
"Capture photo from camera"
),
),
),
],
),
),
),
);
},
),
);
},
);
},
);
}
}
class
OrderForm
extends
StatelessWidget
{
const
OrderForm
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
final
provider
=
Provider
.
of
<
Addorderprovider
>(
context
);
return
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
20
),
),
child:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
SizedBox
(
height:
10
),
// Add Product Button
InkWell
(
onTap:
provider
.
addNewRow
,
child:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
vertical:
10
),
height:
45
,
width:
double
.
infinity
,
decoration:
BoxDecoration
(
color:
const
Color
(
0xFFE6F6FF
),
borderRadius:
BorderRadius
.
circular
(
12
),
border:
Border
.
all
(
color:
Colors
.
blue
,
width:
0.5
,
),
),
child:
const
Center
(
child:
Text
(
"+ Add Product"
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
,
color:
Colors
.
blue
,
fontSize:
16
,
),
),
),
),
),
// Product Rows (Horizontal ListView)
if
(
provider
.
ProductControllers
.
isNotEmpty
)
...[
ListView
.
builder
(
shrinkWrap:
true
,
itemCount:
provider
.
ProductControllers
.
length
,
itemBuilder:
(
context
,
index
)
{
return
Container
(
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.9
,
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
,
vertical:
8.0
,
),
padding:
const
EdgeInsets
.
all
(
8.0
),
decoration:
BoxDecoration
(
color:
const
Color
(
0xFFF5F5F5
),
borderRadius:
BorderRadius
.
circular
(
12
),
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
"Product
${index + 1}
"
,
style:
const
TextStyle
(
fontSize:
16
,
fontWeight:
FontWeight
.
bold
,
),
),
const
SizedBox
(
height:
8.0
),
// Product Dropdown
Row
(
children:
[
Expanded
(
child:
DropdownButtonHideUnderline
(
child:
DropdownButton2
<
SaleProducts
>(
isExpanded:
true
,
hint:
Text
(
'Select Product'
,
style:
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
items:
provider
.
saleProducts
.
map
(
(
ord
,
)
=>
DropdownMenuItem
<
SaleProducts
>(
value:
ord
,
child:
Text
(
"
${ord.prodName}
"
??
''
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
provider
.
selectedSaleProducts
,
onChanged:
(
SaleProducts
?
value
,
)
{
if
(
value
!=
null
)
{
if
(
provider
.
saleProducts
.
isNotEmpty
)
{
provider
.
selectedSaleProducts
=
value
;
provider
.
updateSelectedProduct
(
index
,
provider
.
selectedSaleProducts
,
);
// provider.selectedOrderIds = value!.orderId!;
// provider.selectedOrderNumbers = value!.orderNumber!;
}
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
,
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
,
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
,
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
,
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
),
),
),
),
],
),
const
SizedBox
(
height:
8.0
),
Row
(
children:
[
// Price TextField (Read-only)
Expanded
(
child:
TextField
(
controller:
provider
.
PriceControllers
[
index
],
decoration:
const
InputDecoration
(
labelText:
'Price'
,
border:
OutlineInputBorder
(),
isDense:
true
,
),
keyboardType:
TextInputType
.
number
,
readOnly:
true
,
),
),
const
SizedBox
(
width:
8.0
),
// Quantity TextField
Expanded
(
child:
TextField
(
controller:
provider
.
QuantityControllers
[
index
],
decoration:
const
InputDecoration
(
labelText:
'Quantity'
,
border:
OutlineInputBorder
(),
isDense:
true
,
),
keyboardType:
TextInputType
.
number
,
inputFormatters:
[
FilteringTextInputFormatter
.
digitsOnly
],
onChanged:
(
value
)
{
provider
.
updateRowCalculations
(
index
);
},
),
),
],
),
const
SizedBox
(
height:
8.0
),
Row
(
children:
[
// CGST TextField
Expanded
(
child:
TextField
(
controller:
provider
.
CGSTControllers
[
index
],
decoration:
const
InputDecoration
(
labelText:
'CGST %'
,
border:
OutlineInputBorder
(),
isDense:
true
,
),
keyboardType:
TextInputType
.
number
,
inputFormatters:
[
FilteringTextInputFormatter
.
digitsOnly
],
onChanged:
(
value
)
{
provider
.
updateRowCalculations
(
index
);
},
),
),
const
SizedBox
(
width:
8.0
),
// SGST TextField
Expanded
(
child:
TextField
(
controller:
provider
.
SGSTControllers
[
index
],
decoration:
const
InputDecoration
(
labelText:
'SGST %'
,
border:
OutlineInputBorder
(),
isDense:
true
,
),
keyboardType:
TextInputType
.
number
,
inputFormatters:
[
FilteringTextInputFormatter
.
digitsOnly
],
onChanged:
(
value
)
{
provider
.
updateRowCalculations
(
index
);
},
),
),
const
SizedBox
(
width:
8.0
),
// IGST TextField
Expanded
(
child:
TextField
(
controller:
provider
.
IGSTControllers
[
index
],
decoration:
const
InputDecoration
(
labelText:
'IGST %'
,
border:
OutlineInputBorder
(),
isDense:
true
,
),
keyboardType:
TextInputType
.
number
,
inputFormatters:
[
FilteringTextInputFormatter
.
digitsOnly
],
onChanged:
(
value
)
{
provider
.
updateRowCalculations
(
index
);
},
),
),
],
),
const
SizedBox
(
height:
8.0
),
Row
(
children:
[
// Total Price TextField (Read-only)
Expanded
(
child:
TextField
(
controller:
provider
.
TaxableValueControllers
[
index
],
decoration:
const
InputDecoration
(
labelText:
'Total Price'
,
border:
OutlineInputBorder
(),
isDense:
true
,
),
keyboardType:
TextInputType
.
number
,
readOnly:
true
,
),
),
const
SizedBox
(
width:
8.0
),
// Remove Row Button
IconButton
(
icon:
const
Icon
(
Icons
.
delete
,
color:
Colors
.
red
),
onPressed:
()
{
provider
.
removeRow
(
index
);
},
),
],
),
],
),
);
},
),
],
const
SizedBox
(
height:
20
),
// Summary Table
Table
(
border:
TableBorder
.
all
(
color:
Colors
.
grey
,
width:
1
),
columnWidths:
const
{
0
:
FlexColumnWidth
(
2
),
1
:
FlexColumnWidth
(
1
),
},
children:
[
_buildTableRow
(
'Basic Amount'
,
provider
.
basicAmount
.
toStringAsFixed
(
2
)),
_buildTableRow
(
'CGST Amount'
,
provider
.
cgstAmount
.
toStringAsFixed
(
2
)),
_buildTableRow
(
'SGST Amount'
,
provider
.
sgstAmount
.
toStringAsFixed
(
2
)),
_buildTableRow
(
'IGST Amount'
,
provider
.
igstAmount
.
toStringAsFixed
(
2
)),
_buildTableRow
(
'Total Amount'
,
provider
.
totalAmount
.
toStringAsFixed
(
2
)),
TableRow
(
children:
[
const
Padding
(
padding:
EdgeInsets
.
all
(
8.0
),
child:
Text
(
'Note'
,
style:
TextStyle
(
fontWeight:
FontWeight
.
bold
),
),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
TextField
(
controller:
provider
.
noteController
,
decoration:
const
InputDecoration
(
border:
InputBorder
.
none
,
hintText:
'Enter note'
,
),
maxLines:
null
,
),
),
],
),
],
),
const
SizedBox
(
height:
20
),
// Submit Button
],
),
),
);
}
TableRow
_buildTableRow
(
String
label
,
String
value
)
{
return
TableRow
(
children:
[
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Text
(
label
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
bold
),
),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Text
(
value
),
),
],
);
}
}
\ No newline at end of file
lib/screens/order/addPayment.dart
View file @
d006edb4
import
'dart:async'
;
import
'package:dropdown_button2/dropdown_button2.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:get/get.dart'
;
import
'package:provider/provider.dart'
;
import
'package:generp/screens/notifierExports.dart'
;
import
'package:tuple/tuple.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectAccountResponse.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectOrderResponse.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/commonWidgets.dart'
;
class
AddpaymentScreen
extends
StatefulWidget
{
class
AddpaymentScreen
extends
StatefulWidget
{
const
AddpaymentScreen
({
super
.
key
});
final
pageTitleName
;
final
mode
;
const
AddpaymentScreen
({
super
.
key
,
this
.
pageTitleName
,
this
.
mode
});
@override
@override
State
<
AddpaymentScreen
>
createState
()
=>
_AddpaymentScreenState
();
State
<
AddpaymentScreen
>
createState
()
=>
_AddpaymentScreenState
();
}
}
class
_AddpaymentScreenState
extends
State
<
AddpaymentScreen
>
{
class
_AddpaymentScreenState
extends
State
<
AddpaymentScreen
>
{
Timer
?
_debounce
;
FocusNode
focusNode
=
FocusNode
();
String
?
selectedValue
;
final
TextEditingController
textEditingController
=
TextEditingController
();
@override
void
initState
()
{
// TODO: implement initState
super
.
initState
();
WidgetsBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
var
provider
=
Provider
.
of
<
Addpaymentprovider
>(
context
,
listen:
false
,
);
if
(
provider
.
dateNow
==
null
)
{
provider
.
setDate
(
DateTime
.
now
());
}
provider
.
ordersAddPaymentAPIViewFunction
(
context
);
provider
.
ordersAddPaymentSelectAccountAPIFunction
(
context
,
widget
.
mode
,
provider
.
selectedAccountID
,
''
,
);
});
}
@override
void
dispose
()
{
super
.
dispose
();
}
Future
<
bool
>
_onBackPressed
(
BuildContext
context
)
async
{
Navigator
.
pop
(
context
,
true
);
return
true
;
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
const
Placeholder
();
return
Consumer
<
Addpaymentprovider
>(
builder:
(
context
,
provider
,
child
)
{
return
WillPopScope
(
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
backgroundColor:
AppColors
.
white
,
appBar:
appbar2
(
context
,
"
${widget.pageTitleName}
"
,
provider
.
resetForm
,
SizedBox
(
width:
0
,)),
body:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
20
),
),
child:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
TextWidget
(
context
,
"Account"
),
Container
(
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
ListTile
(
title:
TextFormField
(
focusNode:
focusNode
,
onTapUpOutside:
(
event
)
{
focusNode
.
unfocus
();
},
controller:
provider
.
dropDownSearchController
,
onChanged:
(
value
)
async
{
Future
.
delayed
(
Duration
(
milliseconds:
100
),()
async
{
await
provider
.
ordersAddPaymentSelectAccountAPIFunction
(
context
,
widget
.
mode
,
provider
.
selectedAccountID
,
value
,
);
},);
},
decoration:
InputDecoration
(
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
isDense:
true
,
contentPadding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
8
,
),
hintText:
'Select Account Type'
,
hintStyle:
const
TextStyle
(
fontSize:
12
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
8
),
),
),
),
trailing:
InkResponse
(
onTap:
()
{
if
(
focusNode
.
hasFocus
)
{
focusNode
.
unfocus
();
}
else
{
FocusScope
.
of
(
context
).
requestFocus
(
focusNode
);
}
},
child:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,
),
),
),
),
if
(
provider
.
accountList
.
isNotEmpty
&&
focusNode
.
hasFocus
)...[
Card
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
0
),
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
height:
150
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
16
),
),
child:
Scrollbar
(
thickness:
2.5
,
radius:
Radius
.
circular
(
6
),
thumbVisibility:
true
,
child:
ListView
.
builder
(
itemCount:
provider
.
accountList
.
length
,
shrinkWrap:
true
,
physics:
AlwaysScrollableScrollPhysics
(),
itemBuilder:
(
context
,
index
)
{
return
InkResponse
(
onTap:
()
async
{
if
(
provider
.
accountList
.
isNotEmpty
)
{
provider
.
selectedAccountList
=
provider
.
accountList
[
index
];
print
(
"Selected Complaint Type:
${provider.accountList[index].text}
, ID:
${provider.accountList[index].id}
"
);
provider
.
selectedAccountID
=
provider
.
accountList
[
index
].
id
!;
provider
.
selectedAccountName
=
provider
.
accountList
[
index
].
text
!;
print
(
"hfjkshfg"
+
provider
.
selectedAccountID
.
toString
());
provider
.
dropDownSearchController
.
text
=
provider
.
accountList
[
index
].
text
!;
}
provider
.
ordersAddPaymentSelectOrderAPIFunction
(
context
,
provider
.
selectedAccountID
);
provider
.
accountList
=
[];
},
child:
SizedBox
(
height:
45
,
child:
Align
(
alignment:
Alignment
.
centerLeft
,
child:
Text
(
provider
.
accountList
[
index
].
text
!))));
},),
),
),
)
],
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<AccountList>(
// isExpanded: true,
// hint: Text(
// 'Select Account Type',
// style: TextStyle(fontSize: 14),
// overflow: TextOverflow.ellipsis,
// ),
//
// items: provider.accountList.isEmpty
// ? [
// DropdownMenuItem(
// enabled: false,
// value: null,
// child: Text(
// 'Select Account Type',
// style: TextStyle(
// fontSize: 14,
// color: Colors.grey,
// ),
// ),
// ),
// ]
// :provider.accountList
// .map(
// (accs) => DropdownMenuItem(
// value: accs,
// child: Text(
// accs.text ?? '',
// style: const TextStyle(
// fontSize: 14,
// ),
// overflow: TextOverflow.ellipsis,
// ),
// ),
// )
// .toList(),
// value: provider.accountList.contains(provider.selectedAccountList)
// ? provider.selectedAccountList
// : null,
//
// onChanged: (AccountList? value) {
// if (value != null) {
// if (provider.accountList.isNotEmpty) {
// provider.selectedAccountList = value;
//
// print("Selected Complaint Type: ${value.text}, ID: ${value.id}");
// provider.selectedAccountID = value.id!;
// provider.selectedAccountName = value.text!;
// print("hfjkshfg" + provider.selectedAccountID.toString());
// }
// provider.ordersAddPaymentSelectOrderAPIFunction(context, provider.selectedAccountID);
// }
// },
// buttonStyleData: ButtonStyleData(
// height: 50,
// width: 160,
// padding: const EdgeInsets.only(
// left: 14,
// right: 14,
// ),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(14),
// color: AppColors.text_field_color,
// ),
// ),
// iconStyleData: IconStyleData(
// icon: SvgPicture.asset(
// "assets/svg/arrow_dropdown.svg",
// height: 25,
// width: 20,
// ),
// iconSize: 12,
// iconEnabledColor: Color(0xFF2D2D2D),
// iconDisabledColor: Colors.grey,
// ),
// dropdownStyleData: DropdownStyleData(
// maxHeight: 200,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(14),
// color: AppColors.text_field_color,
// ),
// scrollbarTheme: ScrollbarThemeData(
// radius: const Radius.circular(15),
// thickness: MaterialStateProperty.all<double>(6),
// thumbVisibility: MaterialStateProperty.all<bool>(true),
// ),
// ),
// menuItemStyleData: const MenuItemStyleData(
// height: 40,
// padding: EdgeInsets.only(left: 14, right: 14),
// ),
// dropdownSearchData: DropdownSearchData(
//
// searchController: provider.dropDownSearchController,
// searchInnerWidgetHeight: 50,
// searchInnerWidget: Container(
// height: 50,
// padding: const EdgeInsets.only(
// top: 8,
// bottom: 4,
// right: 8,
// left: 8,
// ),
// child: TextFormField(
// controller: provider.dropDownSearchController,
// onChanged: (value) async {
// Future.delayed(Durations.short2,() async {
// await provider.ordersAddPaymentSelectAccountAPIFunction(
// context,
// widget.mode,
// provider.selectedAccountID,
// value,
// );
// },);
//
//
//
// },
// decoration: InputDecoration(
// isDense: true,
// contentPadding: const EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 8,
// ),
// hintText: 'Search account type...',
// hintStyle: const TextStyle(fontSize: 12),
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(8),
// ),
// ),
// ),
// ),
// searchMatchFn: (item, searchValue) {
// if (item.value == null || searchValue.isEmpty) return false;
// return item.value!.text!
// .toLowerCase()
// .contains(searchValue.toLowerCase());
// },
// // searchMatchFn: (item, searchValue) {
// // if (item.value == null) return false; //
// // return item.value!.text!.toLowerCase().contains(searchValue.toLowerCase());
// // },
// ),
//
// onMenuStateChange: (isOpen) {
// print("isOpen:${isOpen}");
// if (isOpen) {
// provider.ordersAddPaymentSelectAccountAPIFunction(
// context,
// widget.mode,
// provider.selectedAccountID,
// provider.dropDownSearchController.text,
// );
//
// } else {
// provider.dropDownSearchController.clear();
// }
// },
// ),
// ),
// ],
// ),
// ),
///enwewe
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<AccountList>(
// isExpanded: true,
// hint: Text(
// 'Select Account Type',
// style: TextStyle(fontSize: 14),
// overflow: TextOverflow.ellipsis,
// ),
// items: provider.accountList
// .map(
// (accs) => DropdownMenuItem<AccountList>(
// value: accs,
// child: Text(
// accs.text ?? '',
// style: const TextStyle(
// fontSize: 14,
// ),
// overflow: TextOverflow.ellipsis,
// ),
// ),
// )
// .toList(),
// value: provider.selectedAccountList,
// onChanged: (AccountList? value) {
// if (value != null) {
// if (provider.accountList.isNotEmpty) {
// provider.selectedAccountList = value;
// print("Selected Complaint Type: ${value.text}, ID: ${value.id}");
// provider.selectedAccountID = value.id!;
// provider.selectedAccountName = value.text!;
// print("hfjkshfg" + provider.selectedAccountID.toString());
// }
// provider.ordersAddPaymentSelectOrderAPIFunction(context, provider.selectedAccountID);
// }
// },
// buttonStyleData: ButtonStyleData(
// height: 50,
// width: 160,
// padding: const EdgeInsets.only(
// left: 14,
// right: 14,
// ),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(14),
// color: AppColors.text_field_color,
// ),
// ),
// iconStyleData: IconStyleData(
// icon: SvgPicture.asset(
// "assets/svg/arrow_dropdown.svg",
// height: 25,
// width: 20,
// ),
// iconSize: 12,
// iconEnabledColor: Color(0xFF2D2D2D),
// iconDisabledColor: Colors.grey,
// ),
// dropdownStyleData: DropdownStyleData(
// maxHeight: 200,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(14),
// color: AppColors.text_field_color,
// ),
// scrollbarTheme: ScrollbarThemeData(
// radius: const Radius.circular(15),
// thickness: MaterialStateProperty.all<double>(6),
// thumbVisibility: MaterialStateProperty.all<bool>(true),
// ),
// ),
// menuItemStyleData: const MenuItemStyleData(
// height: 40,
// padding: EdgeInsets.only(left: 14, right: 14),
// ),
// dropdownSearchData: DropdownSearchData(
// searchController: provider.dropDownSearchController,
// searchInnerWidgetHeight: 50,
// searchInnerWidget: Container(
// height: 50,
// padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
// child: TextFormField(
// controller: provider.dropDownSearchController,
// onChanged: (searchTerm) {
// onSearchChanged(searchTerm);
// },
// decoration: InputDecoration(
// isDense: true,
// contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
// hintText: 'Search account type...',
// hintStyle: const TextStyle(fontSize: 12),
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(8),
// ),
// ),
// ),
// ),
// // You can omit or always return true since we're doing server-side filtering
// searchMatchFn: (item, searchValue) => true,
// ),
//
// onMenuStateChange: (isOpen) {
// if (!isOpen) {
// print("is called"); // Clear search when menu closes
// // Optionally reset accountList to initial state
// setState(() {
// provider.ordersAddPaymentSelectAccountAPIFunction(context, widget.mode,provider.selectedAccountID,provider.dropDownSearchController.text);
// });
// } else {
// print("is called2");
// // Fetch initial data when menu opens
// setState(() {
// provider.ordersAddPaymentSelectAccountAPIFunction(context, widget.mode,provider.selectedAccountID,provider.dropDownSearchController.text);
// });
// }
// },
// ),
// ),
// ],
// ),
// ),
ErrorWidget
(
context
,
provider
.
selectAccountError
),
textControllerWidget
(
context
,
provider
.
amountController
,
"Amount"
,
provider
.
onChangeAmount
,
),
ErrorWidget
(
context
,
provider
.
amountError
),
///Addorderbutton
if
(
provider
.
selectedAccountID
!.
isNotEmpty
)...[
InkResponse
(
onTap:
()
{
// if (provider.selectedOrderIds.length < provider.orderList.length) {
provider
.
addNewRow
();
// } else {
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text('No more unique order IDs or statuses available'),
// ),
// );
// }
},
child:
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
),
height:
45
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
decoration:
BoxDecoration
(
color:
Color
(
0xFFE6F6FF
),
borderRadius:
BorderRadius
.
circular
(
12
),
border:
Border
.
all
(
color:
AppColors
.
app_blue
,
width:
0.5
,
),
),
child:
Center
(
child:
Text
(
"+ Add Order"
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
,
color:
AppColors
.
app_blue
,
),
),
),
),
),
if
(
provider
.
orderAmountControllers
.
length
>
0
)...[
Row
(
children:
[
Expanded
(
child:
ListView
.
builder
(
itemCount:
provider
.
orderAmountControllers
.
length
,
physics:
NeverScrollableScrollPhysics
(),
shrinkWrap:
true
,
itemBuilder:
(
context
,
index
)
{
return
Row
(
children:
[
Expanded
(
flex:
3
,
child:
SizedBox
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
TextWidget
(
context
,
"Order"
),
Row
(
children:
[
Expanded
(
child:
DropdownButtonHideUnderline
(
child:
DropdownButton2
<
OrderList
>(
isExpanded:
true
,
hint:
Text
(
'Select Account Type'
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
items:
provider
.
orderList
.
map
(
(
ord
)
=>
DropdownMenuItem
<
OrderList
>(
value:
ord
,
child:
Text
(
"(Order Number:
${ord.orderNumber}
) + (Order Amount:
${ord.totalAmount}
) + (Balance Amount:
${ord.balanceAmount}
) + (Date Time:
${ord.createdDatetime}
)"
??
''
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
provider
.
selectedOrderLists
,
onChanged:
(
OrderList
?
value
)
{
if
(
value
!=
null
)
{
if
(
provider
.
orderList
.
isNotEmpty
)
{
provider
.
selectedOrderLists
=
value
;
print
(
"Selected Complaint Type:
${value.orderId}
, ID:
${value.orderNumber}
"
,
);
provider
.
updateSelectedOrderId
(
index
,
provider
.
selectedOrderLists
);
// provider.selectedOrderIds = value!.orderId!;
// provider.selectedOrderNumbers = value!.orderNumber!;
print
(
"hfjkshfg"
+
provider
.
selectedOrderIds
.
toString
(),
);
}
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
),
],
),
],
),
),
),
SizedBox
(
width:
10
),
Expanded
(
flex:
2
,
child:
textControllerWidget
(
context
,
provider
.
orderAmountControllers
[
index
],
"Enter Order Amount"
,
(
p0
)
{
},),
),
// SizedBox(width: 10),
//
// IconButton(
// icon: Icon(Icons.delete),
// onPressed: provider.orderAmountControllers.length > 1
// ? () => provider.removeRow(index)
// : null, // Prevent removing the last row
// ),
],
);
},
),
),
],
),
],
],
textControllerWidget
(
context
,
provider
.
orderAdjustedAmountController
,
"Order Adjusted Amount"
,
provider
.
onChangeorderAdjustedAmount
,
),
ErrorWidget
(
context
,
provider
.
orderAdjustedAmountError
),
TextWidget
(
context
,
"Description"
),
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
isExpanded:
true
,
hint:
const
Row
(
children:
[
Expanded
(
child:
Text
(
'Select Advance Payment'
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
),
],
),
items:
provider
.
description
.
map
(
(
pm
)
=>
DropdownMenuItem
<
String
>(
value:
pm
,
child:
Text
(
pm
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
provider
.
selectedDescription
,
onChanged:
(
value
)
{
if
(
value
!=
null
)
{
provider
.
selectedDescription
=
value
;
print
(
"statusId:
${provider.selectedDescription}
"
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,),
iconSize:
14
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
width:
350
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
ErrorWidget
(
context
,
provider
.
descriptionError
),
TextWidget
(
context
,
"Payment Received Date"
),
GestureDetector
(
onTap:
()
{
provider
.
showDatePickerDialog
(
context
);
},
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Expanded
(
child:
Container
(
height:
50
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
10.0
,
0.0
,
10
,
0
),
child:
TextFormField
(
controller:
provider
.
paymentReceivedDateController
,
keyboardType:
TextInputType
.
text
,
enabled:
false
,
maxLines:
1
,
readOnly:
true
,
onChanged:
(
value
)
{
},
decoration:
InputDecoration
(
hintText:
"Enter Date"
,
hintStyle:
TextStyle
(
fontWeight:
FontWeight
.
w400
,
color:
Color
(
0xFFB4BEC0
),
fontSize:
14
,
),
enabledBorder:
InputBorder
.
none
,
disabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
),
),
),
),
),
],
),
),
ErrorWidget
(
context
,
provider
.
dateError
),
TextWidget
(
context
,
"Select Payment Mode"
),
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
isExpanded:
true
,
hint:
const
Row
(
children:
[
Expanded
(
child:
Text
(
'Select Payment Mode'
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
),
],
),
items:
provider
.
paymentMode
.
map
(
(
pm
)
=>
DropdownMenuItem
<
String
>(
value:
pm
,
child:
Text
(
pm
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
provider
.
selectedPaymentMode
,
onChanged:
(
value
)
{
if
(
value
!=
null
)
{
provider
.
selectedPaymentMode
=
value
;
print
(
"statusId:
${provider.selectedPaymentMode}
"
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,),
iconSize:
14
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
width:
350
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
ErrorWidget
(
context
,
provider
.
paymentModeError
),
textControllerWidget
(
context
,
provider
.
paymentRefController
,
"Payment Reference No. / Cheque No. / UTR No. tf"
,
provider
.
onChangepaymentRef
,
),
ErrorWidget
(
context
,
provider
.
paymentRefError
),
InkResponse
(
onTap:
()
{
_showAttachmentSheet
(
context
);
},
child:
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
),
height:
45
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
decoration:
BoxDecoration
(
color:
Color
(
0xFFE6F6FF
),
borderRadius:
BorderRadius
.
circular
(
12
),
border:
Border
.
all
(
color:
AppColors
.
app_blue
,
width:
0.5
,
),
),
child:
Center
(
child:
Text
(
"Payment Attachment"
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
,
color:
AppColors
.
app_blue
,
),
),
),
),
),
if
(
provider
.
imagePicked
==
1
&&
provider
.
imagePath
!=
null
)...[
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
4.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
"
${provider.imagePath}
"
,
style:
TextStyle
(
color:
AppColors
.
semi_black
,
fontSize:
11
,
fontWeight:
FontWeight
.
w600
),),
InkResponse
(
onTap:
()
{
provider
.
imagePicked
=
0
;
provider
.
imagePath
=
null
;
provider
.
imageFilePath
=
null
;
},
child:
SvgPicture
.
asset
(
"assets/svg/ic_close.svg"
,
width:
15
,
height:
15
,))
],
),
)
],
],
),
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation
.
centerFloat
,
bottomNavigationBar:
InkResponse
(
onTap:
()
{
provider
.
selectedOrders
=
provider
.
getFormData
();
print
(
provider
.
selectedOrders
);
provider
.
ordersAddPaymentAPISubmitFunction
(
context
,
provider
.
selectedAccountID
,
provider
.
selectedDescription
,
provider
.
selectedOrders
,
provider
.
selectedPaymentMode
);
},
child:
Container
(
height:
45
,
alignment:
Alignment
.
center
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
15
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
5
),
decoration:
BoxDecoration
(
color:
AppColors
.
app_blue
,
borderRadius:
BorderRadius
.
circular
(
15
),
),
child:
Text
(
"Submit"
,
style:
TextStyle
(
fontSize:
15
,
fontFamily:
"JakartaMedium"
,
color:
Colors
.
white
,
),
),
),
),
),
onWillPop:
()
async
{
provider
.
resetForm
();
return
_onBackPressed
(
context
);
},
);
},
);
}
Widget
TextWidget
(
context
,
text
)
{
return
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
text
),
);
}
Widget
ErrorWidget
(
context
,
text
)
{
if
(
text
!=
null
)
return
Text
(
text
!,
style:
TextStyle
(
color:
Colors
.
red
,
fontSize:
12
));
else
return
SizedBox
(
height:
10
);
}
Widget
textControllerWidget
(
context
,
controller
,
hintText
,
Function
(
String
)?
onChanged
,
)
{
return
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
hintText
),
),
Container
(
height:
hintText
==
"Enter Description"
?
150
:
50
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
10.0
,
0.0
,
10
,
0
),
child:
TextFormField
(
controller:
controller
,
keyboardType:
TextInputType
.
text
,
maxLines:
hintText
==
"Enter Description"
?
60
:
1
,
onChanged:
onChanged
,
decoration:
InputDecoration
(
hintText:
hintText
,
hintStyle:
TextStyle
(
fontWeight:
FontWeight
.
w400
,
color:
Color
(
0xFFB4BEC0
),
fontSize:
14
,
),
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
),
),
),
),
],
);
}
Future
<
void
>
_showAttachmentSheet
(
BuildContext
context
)
{
return
showModalBottomSheet
(
useSafeArea:
true
,
isDismissible:
true
,
isScrollControlled:
true
,
showDragHandle:
true
,
backgroundColor:
Colors
.
white
,
enableDrag:
true
,
context:
context
,
builder:
(
context
)
{
return
StatefulBuilder
(
builder:
(
context
,
setState
)
{
return
SafeArea
(
child:
Consumer
<
Addpaymentprovider
>(
builder:
(
context
,
provider
,
child
)
{
return
Padding
(
padding:
EdgeInsets
.
only
(
bottom:
MediaQuery
.
of
(
context
,
).
viewInsets
.
bottom
,
// This handles keyboard
),
child:
Container
(
margin:
EdgeInsets
.
only
(
bottom:
15
,
left:
15
,
right:
15
,
top:
10
,
),
child:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
mainAxisSize:
MainAxisSize
.
min
,
children:
[
Align
(
alignment:
Alignment
.
center
,
child:
Text
(
"Select Source"
,
style:
TextStyle
(
color:
AppColors
.
app_blue
,
fontFamily:
"JakrtaMedium"
,
fontSize:
16
,
),
),
),
SizedBox
(
height:
15
),
InkWell
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
provider
.
imgFromGallery
(
context
);
},
child:
Container
(
height:
35
,
child:
Text
(
"Select photo from gallery"
),
),
),
SizedBox
(
height:
10
),
InkWell
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
provider
.
imgFromCamera
(
context
);
},
child:
Container
(
height:
35
,
child:
Text
(
"Capture photo from camera"
),
),
),
],
),
),
),
);
},
),
);
},
);
},
);
}
}
}
}
lib/screens/order/editAdjustedOrderList.dart
0 → 100644
View file @
d006edb4
import
'package:dropdown_button2/dropdown_button2.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectOrderResponse.dart'
;
import
'../../Notifiers/ordersProvider/addPaymentProvider.dart'
;
import
'../../Notifiers/ordersProvider/editPaymentProvider.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/commonWidgets.dart'
;
class
Editadjustedorderlist
extends
StatefulWidget
{
final
mode
;
final
pageTitleName
;
final
values
;
const
Editadjustedorderlist
({
super
.
key
,
this
.
mode
,
this
.
pageTitleName
,
this
.
values
});
@override
State
<
Editadjustedorderlist
>
createState
()
=>
_EditadjustedorderlistState
();
}
class
_EditadjustedorderlistState
extends
State
<
Editadjustedorderlist
>
{
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// var provider = Provider.of<Addpaymentprovider>(
// context,
// listen: false,
// );
// provider.checkDropdownselected();
// provider.ordersAddPaymentSelectOrderAPIFunction(context,widget.values["account_id"]);
// print(widget.values);
// if(widget.values!.isNotEmpty){
// var a = widget.values['orders'];
// for(int i=0;i<a.length;i++){
// provider.addNewRow();
// provider.orderAmountControllers[i].text = a[i]['amount'];
// final order = provider.orderList.firstWhere(
// (item) => item.orderNumber == a[i]['order_number']);
// print(provider.orderList[i].orderNumber);
// print(a[i]['order_number']);
// // provider.selectedOrderIds = order;
// provider.updateSelectedOrderId(i, order);
//
// }
//
// }
//
//
// });
// }
//
@override
void
initState
()
{
super
.
initState
();
WidgetsBinding
.
instance
.
addPostFrameCallback
((
_
)
async
{
final
provider
=
Provider
.
of
<
Editpaymentprovider
>(
context
,
listen:
false
);
// Fetch order list via API
await
provider
.
ordersAddPaymentSelectOrderAPIFunction
(
context
,
widget
.
values
[
"account_id"
],
);
// Populate rows from widget.values['orders']
if
(
widget
.
values
!=
null
&&
widget
.
values
[
'orders'
]
!=
null
)
{
final
ordersFromWidget
=
widget
.
values
[
'orders'
];
for
(
int
i
=
0
;
i
<
ordersFromWidget
.
length
;
i
++)
{
final
widgetOrderNumber
=
ordersFromWidget
[
i
][
'order_number'
];
final
widgetAmount
=
ordersFromWidget
[
i
][
'amount'
];
final
orderId
=
ordersFromWidget
[
i
][
'order_id'
];
final
orderPaymentId
=
ordersFromWidget
[
i
][
'order_payment_id'
];
// Create metadata for this row
final
metadata
=
{
"order_id"
:
orderId
.
toString
(),
"order_payment_id"
:
orderPaymentId
.
toString
(),
};
// Use addRowWithMetadata to add row with metadata
provider
.
addRowWithMetadata
(
metadata
);
// Find matching order in the fetched list
final
matchedOrder
=
provider
.
orderList
.
firstWhere
(
(
order
)
=>
order
.
orderNumber
==
widgetOrderNumber
,
orElse:
()
{
print
(
"⚠️ Order not found for:
$widgetOrderNumber
"
);
return
provider
.
orderList
[
0
];
// Fallback to first order
},
);
// Populate controller and selected order
provider
.
orderAmountControllers
[
i
].
text
=
widgetAmount
;
provider
.
updateSelectedOrderId
(
i
,
matchedOrder
);
print
(
"✅ Matched order:
${matchedOrder.orderNumber}
"
);
}
}
});
}
// @override
// void initState() {
// super.initState();
//
// WidgetsBinding.instance.addPostFrameCallback((_) async {
// final provider = Provider.of<Editpaymentprovider>(context, listen: false);
//
// // 1. Wait for the order list to be fetched via API
// await provider.ordersAddPaymentSelectOrderAPIFunction(
// context,
// widget.values["account_id"],
// );
//
// // 2. Now match orders and populate rows
// if (widget.values != null && widget.values['orders'] != null) {
// final ordersFromWidget = widget.values['orders'];
//
// for (int i = 0; i < ordersFromWidget.length; i++) {
// final widgetOrderNumber = ordersFromWidget[i]['order_number'];
// final widgetAmount = ordersFromWidget[i]['amount'];
//
// // 3. Try to find matching order in the fetched list
// final matchedOrder = provider.orderList.firstWhere(
// (order) => order.orderNumber == widgetOrderNumber,
// orElse: () {
// print("⚠️ Order not found for: $widgetOrderNumber");
// return provider.orderList[0]; // fallback if necessary
// },
// );
//
// provider.addNewRow(); // Adds controller + dropdown slot
// provider.orderAmountControllers[i].text = widgetAmount;
// provider.updateSelectedOrderId(i, matchedOrder);
//
// print("✅ Matched order: ${matchedOrder.orderNumber}");
// }
// }
// });
//
// }
@override
void
dispose
()
{
super
.
dispose
();
}
Future
<
bool
>
_onBackPressed
(
BuildContext
context
)
async
{
Navigator
.
pop
(
context
,
true
);
return
true
;
}
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer2
<
Addpaymentprovider
,
Editpaymentprovider
>(
builder:
(
context
,
provider
,
editProvider
,
child
)
{
return
WillPopScope
(
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
backgroundColor:
AppColors
.
scaffold_bg_color
,
appBar:
appbar2
(
context
,
"
${widget.pageTitleName}
"
,
provider
.
resetForm
,
SizedBox
(
width:
0
,)),
body:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(20),
// ),
child:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
if
(
widget
.
values
!.
isNotEmpty
)...[
InkResponse
(
onTap:
()
{
// if (provider.selectedOrderIds.length < provider.orderList.length) {
editProvider
.
addNewRow
();
// } else {
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text('No more unique order IDs or statuses available'),
// ),
// );
// }
},
child:
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
),
height:
45
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
decoration:
BoxDecoration
(
color:
Color
(
0xFFE6F6FF
),
borderRadius:
BorderRadius
.
circular
(
12
),
border:
Border
.
all
(
color:
AppColors
.
app_blue
,
width:
0.5
,
),
),
child:
Center
(
child:
Text
(
"+ Add Order"
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
,
color:
AppColors
.
app_blue
,
),
),
),
),
),
if
(
editProvider
.
orderAmountControllers
.
length
>
0
)...[
Row
(
children:
[
Expanded
(
child:
ListView
.
builder
(
itemCount:
editProvider
.
orderAmountControllers
.
length
,
physics:
NeverScrollableScrollPhysics
(),
shrinkWrap:
true
,
itemBuilder:
(
context
,
index
)
{
return
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
20
),
),
child:
Column
(
children:
[
Row
(
children:
[
Expanded
(
flex:
3
,
child:
SizedBox
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
TextWidget
(
context
,
"Order"
),
Row
(
children:
[
Expanded
(
child:
DropdownButtonHideUnderline
(
child:
DropdownButton2
<
OrderList
>(
isExpanded:
true
,
hint:
Text
(
'Select Account Type'
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
items:
editProvider
.
orderList
.
map
(
(
ord
)
=>
DropdownMenuItem
<
OrderList
>(
value:
ord
,
child:
Text
(
"(Order Number:
${ord.orderNumber}
) + (Order Amount:
${ord.totalAmount}
) + (Balance Amount:
${ord.balanceAmount}
) + (Date Time:
${ord.createdDatetime}
)"
??
''
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
editProvider
.
selectedOrderLists
,
onChanged:
(
OrderList
?
value
)
{
if
(
value
!=
null
)
{
if
(
editProvider
.
orderList
.
isNotEmpty
)
{
editProvider
.
selectedOrderLists
=
value
;
print
(
"Selected Complaint Type:
${value.orderId}
, ID:
${value.orderNumber}
"
,
);
editProvider
.
updateSelectedOrderId
(
index
,
editProvider
.
selectedOrderLists
);
// provider.selectedOrderIds = value!.orderId!;
// provider.selectedOrderNumbers = value!.orderNumber!;
// print(
// "hfjkshfg" +
// editProvider.selectedOrderIds.toString(),
// );
}
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,),
iconSize:
12
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
),
],
),
],
),
),
),
],
),
SizedBox
(
width:
10
),
Row
(
children:
[
Expanded
(
flex:
2
,
child:
textControllerWidget
(
context
,
editProvider
.
orderAmountControllers
[
index
],
"Enter Order Amount"
,
(
p0
)
{
},),
),
],
),
SizedBox
(
height:
10
),
// SizedBox(width: 10),
//
// IconButton(
// icon: Icon(Icons.delete),
// onPressed: provider.orderAmountControllers.length > 1
// ? () => provider.removeRow(index)
// : null, // Prevent removing the last row
// ),
],
),
);
},
),
),
],
),
],
],
]
),
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation
.
centerFloat
,
bottomNavigationBar:
InkResponse
(
onTap:
editProvider
.
submitLoading
?
null
:()
{
// editProvider.submitLoading = true;
final
data
=
editProvider
.
getFormData
();
print
(
data
);
},
child:
Container
(
height:
45
,
alignment:
Alignment
.
center
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
15
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
5
),
decoration:
BoxDecoration
(
color:
AppColors
.
app_blue
,
borderRadius:
BorderRadius
.
circular
(
15
),
),
child:
editProvider
.
submitLoading
?
CircularProgressIndicator
.
adaptive
(
valueColor:
AlwaysStoppedAnimation
<
Color
>(
AppColors
.
white
)):
Text
(
"Submit"
,
style:
TextStyle
(
fontSize:
15
,
fontFamily:
"JakartaMedium"
,
color:
Colors
.
white
,
),
),
),
),
),
onWillPop:
()
async
{
provider
.
resetForm
();
return
_onBackPressed
(
context
);
},
);
},
);
}
Widget
TextWidget
(
context
,
text
)
{
return
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
text
),
);
}
Widget
ErrorWidget
(
context
,
text
)
{
if
(
text
!=
null
)
return
Text
(
text
!,
style:
TextStyle
(
color:
Colors
.
red
,
fontSize:
12
));
else
return
SizedBox
(
height:
10
);
}
Widget
textControllerWidget
(
context
,
controller
,
hintText
,
Function
(
String
)?
onChanged
,
)
{
return
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
hintText
),
),
Container
(
height:
hintText
==
"Enter Description"
?
150
:
50
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
10.0
,
0.0
,
10
,
0
),
child:
TextFormField
(
controller:
controller
,
keyboardType:
TextInputType
.
text
,
maxLines:
hintText
==
"Enter Description"
?
60
:
1
,
onChanged:
onChanged
,
decoration:
InputDecoration
(
hintText:
hintText
,
hintStyle:
TextStyle
(
fontWeight:
FontWeight
.
w400
,
color:
Color
(
0xFFB4BEC0
),
fontSize:
14
,
),
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
),
),
),
),
],
);
}
}
lib/screens/order/editPaymentDetailsByMode.dart
0 → 100644
View file @
d006edb4
import
'dart:async'
;
import
'package:dropdown_button2/dropdown_button2.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/ordersModels/AddOrderPaymentSelectOrderResponse.dart'
;
import
'../../Notifiers/ordersProvider/addPaymentProvider.dart'
;
import
'../../Notifiers/ordersProvider/editPaymentProvider.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/commonWidgets.dart'
;
class
Editpaymentdetailsbymode
extends
StatefulWidget
{
final
mode
;
final
pageTitleName
;
final
values
;
const
Editpaymentdetailsbymode
({
super
.
key
,
this
.
mode
,
this
.
pageTitleName
,
this
.
values
});
@override
State
<
Editpaymentdetailsbymode
>
createState
()
=>
_EditpaymentdetailsbymodeState
();
}
class
_EditpaymentdetailsbymodeState
extends
State
<
Editpaymentdetailsbymode
>
{
Timer
?
_debounce
;
FocusNode
focusNode
=
FocusNode
();
String
?
selectedValue
;
final
TextEditingController
textEditingController
=
TextEditingController
();
@override
void
initState
()
{
// TODO: implement initState
super
.
initState
();
WidgetsBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
var
provider
=
Provider
.
of
<
Addpaymentprovider
>(
context
,
listen:
false
,
);
if
(
provider
.
dateNow
==
null
)
{
provider
.
setDate
(
DateTime
.
now
());
}
provider
.
ordersAddPaymentAPIViewFunction
(
context
);
provider
.
ordersAddPaymentSelectAccountAPIFunction
(
context
,
widget
.
mode
,
provider
.
selectedAccountID
,
''
,
);
// "description":provider.paymentDetails!.description,
// "amount":provider.paymentDetails!.amount,
// "payment_mode":provider.paymentDetails!.paymentType,
// "pay_ref":provider.paymentDetails!.refNo,
// "pay_received_date":provider.paymentDetails!.paymentDate,
provider
.
selectedDescription
=
widget
.
values
[
'description'
];
provider
.
amountController
.
text
=
widget
.
values
[
'amount'
];
provider
.
selectedPaymentMode
=
widget
.
values
[
'payment_mode'
];
provider
.
paymentRefController
.
text
=
widget
.
values
[
'pay_ref'
];
provider
.
paymentReceivedDateController
.
text
=
widget
.
values
[
'pay_received_date'
];
});
}
@override
void
dispose
()
{
super
.
dispose
();
}
Future
<
bool
>
_onBackPressed
(
BuildContext
context
)
async
{
Navigator
.
pop
(
context
,
true
);
return
true
;
}
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer2
<
Addpaymentprovider
,
Editpaymentprovider
>(
builder:
(
context
,
provider
,
editProvider
,
child
)
{
return
WillPopScope
(
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
backgroundColor:
AppColors
.
white
,
appBar:
appbar2
(
context
,
"
${widget.pageTitleName}
"
,
provider
.
resetForm
,
SizedBox
(
width:
0
,)),
body:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
20
),
),
child:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
TextWidget
(
context
,
"Description"
),
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
isExpanded:
true
,
hint:
const
Row
(
children:
[
Expanded
(
child:
Text
(
'Select Advance Payment'
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
),
],
),
items:
provider
.
description
.
map
(
(
pm
)
=>
DropdownMenuItem
<
String
>(
value:
pm
,
child:
Text
(
pm
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
provider
.
selectedDescription
,
onChanged:
(
value
)
{
if
(
value
!=
null
)
{
provider
.
selectedDescription
=
value
;
print
(
"statusId:
${provider.selectedDescription}
"
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,),
iconSize:
14
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
width:
350
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
ErrorWidget
(
context
,
provider
.
descriptionError
),
textControllerWidget
(
context
,
provider
.
amountController
,
"Amount"
,
provider
.
onChangeAmount
,
),
ErrorWidget
(
context
,
provider
.
amountError
),
TextWidget
(
context
,
"Select Payment Mode"
),
DropdownButtonHideUnderline
(
child:
Row
(
children:
[
Expanded
(
child:
DropdownButton2
<
String
>(
isExpanded:
true
,
hint:
const
Row
(
children:
[
Expanded
(
child:
Text
(
'Select Payment Mode'
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
),
],
),
items:
provider
.
paymentMode
.
map
(
(
pm
)
=>
DropdownMenuItem
<
String
>(
value:
pm
,
child:
Text
(
pm
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
provider
.
selectedPaymentMode
,
onChanged:
(
value
)
{
if
(
value
!=
null
)
{
provider
.
selectedPaymentMode
=
value
;
print
(
"statusId:
${provider.selectedPaymentMode}
"
,
);
}
},
buttonStyleData:
ButtonStyleData
(
height:
50
,
width:
160
,
padding:
const
EdgeInsets
.
only
(
left:
14
,
right:
14
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
),
iconStyleData:
IconStyleData
(
icon:
SvgPicture
.
asset
(
"assets/svg/arrow_dropdown.svg"
,
height:
25
,
width:
20
,),
iconSize:
14
,
iconEnabledColor:
Color
(
0xFF2D2D2D
),
iconDisabledColor:
Colors
.
grey
,
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
width:
350
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
AppColors
.
text_field_color
,
),
scrollbarTheme:
ScrollbarThemeData
(
radius:
const
Radius
.
circular
(
15
),
thickness:
MaterialStateProperty
.
all
<
double
>(
6
,
),
thumbVisibility:
MaterialStateProperty
.
all
<
bool
>(
true
),
),
),
menuItemStyleData:
const
MenuItemStyleData
(
height:
40
,
padding:
EdgeInsets
.
only
(
left:
14
,
right:
14
),
),
),
),
],
),
),
ErrorWidget
(
context
,
provider
.
paymentModeError
),
textControllerWidget
(
context
,
provider
.
paymentRefController
,
"Payment Reference No. / Cheque No. / UTR No. tf"
,
provider
.
onChangepaymentRef
,
),
ErrorWidget
(
context
,
provider
.
paymentRefError
),
TextWidget
(
context
,
"Payment Received Date"
),
GestureDetector
(
onTap:
()
{
provider
.
showDatePickerDialog
(
context
);
},
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Expanded
(
child:
Container
(
height:
50
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
10.0
,
0.0
,
10
,
0
),
child:
TextFormField
(
controller:
provider
.
paymentReceivedDateController
,
keyboardType:
TextInputType
.
text
,
enabled:
false
,
maxLines:
1
,
readOnly:
true
,
onChanged:
(
value
)
{
},
decoration:
InputDecoration
(
hintText:
"Enter Date"
,
hintStyle:
TextStyle
(
fontWeight:
FontWeight
.
w400
,
color:
Color
(
0xFFB4BEC0
),
fontSize:
14
,
),
enabledBorder:
InputBorder
.
none
,
disabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
),
),
),
),
),
],
),
),
ErrorWidget
(
context
,
provider
.
dateError
),
],
),
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation
.
centerFloat
,
bottomNavigationBar:
InkResponse
(
onTap:
editProvider
.
submitLoading
?
null
:()
{
editProvider
.
submitLoading
=
true
;
editProvider
.
editPaymentDetailsAPIFunction
(
context
,
widget
.
values
[
"payment_id"
],
provider
.
selectedDescription
,
provider
.
selectedPaymentMode
,
provider
.
paymentRefController
.
text
,
provider
.
paymentReceivedDateController
.
text
,
provider
.
amountController
.
text
);
},
child:
Container
(
height:
45
,
alignment:
Alignment
.
center
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
15
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
5
),
decoration:
BoxDecoration
(
color:
AppColors
.
app_blue
,
borderRadius:
BorderRadius
.
circular
(
15
),
),
child:
editProvider
.
submitLoading
?
CircularProgressIndicator
.
adaptive
(
valueColor:
AlwaysStoppedAnimation
<
Color
>(
AppColors
.
white
)):
Text
(
"Submit"
,
style:
TextStyle
(
fontSize:
15
,
fontFamily:
"JakartaMedium"
,
color:
Colors
.
white
,
),
),
),
),
),
onWillPop:
()
async
{
provider
.
resetForm
();
return
_onBackPressed
(
context
);
},
);
},
);
}
Widget
TextWidget
(
context
,
text
)
{
return
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
text
),
);
}
Widget
ErrorWidget
(
context
,
text
)
{
if
(
text
!=
null
)
return
Text
(
text
!,
style:
TextStyle
(
color:
Colors
.
red
,
fontSize:
12
));
else
return
SizedBox
(
height:
10
);
}
Widget
textControllerWidget
(
context
,
controller
,
hintText
,
Function
(
String
)?
onChanged
,
)
{
return
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
5.0
,
top:
8.0
),
child:
Text
(
hintText
),
),
Container
(
height:
hintText
==
"Enter Description"
?
150
:
50
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColors
.
text_field_color
,
borderRadius:
BorderRadius
.
circular
(
14
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
10.0
,
0.0
,
10
,
0
),
child:
TextFormField
(
controller:
controller
,
keyboardType:
TextInputType
.
text
,
maxLines:
hintText
==
"Enter Description"
?
60
:
1
,
onChanged:
onChanged
,
decoration:
InputDecoration
(
hintText:
hintText
,
hintStyle:
TextStyle
(
fontWeight:
FontWeight
.
w400
,
color:
Color
(
0xFFB4BEC0
),
fontSize:
14
,
),
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
),
),
),
),
],
);
}
}
lib/screens/order/orderModuleDashboard.dart
View file @
d006edb4
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:generp/screens/screensExports.dart'
;
import
'package:generp/screens/screensExports.dart'
;
import
'package:provider/provider.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Notifiers/ordersProvider/pagesDashboardProvider.dart'
;
import
'../../Notifiers/ordersProvider/pagesDashboardProvider.dart'
;
...
@@ -67,9 +68,20 @@ class _OrdermoduledashboardState extends State<Ordermoduledashboard> {
...
@@ -67,9 +68,20 @@ class _OrdermoduledashboardState extends State<Ordermoduledashboard> {
onTap:
()
async
{
onTap:
()
async
{
var
navigate
;
var
navigate
;
if
(
pages
[
index
].
pageName
!.
contains
(
"Add Order"
)
)
{
if
(
pages
[
index
].
pageName
!.
contains
(
"Add Order"
)
)
{
print
(
"navigate to Add Order"
);
navigate
=
AddorderScreen
(
mode:
pages
[
index
].
mode
!,
pageTitleName:
pages
[
index
]
.
pageName
!,
);
}
if
(
pages
[
index
].
pageName
!.
contains
(
"Add Payment"
)
)
{
}
if
(
pages
[
index
].
pageName
!.
contains
(
"Add Payment"
)
)
{
print
(
"navigate to Add Payment"
);
(
"navigate to Add Payment"
);
navigate
=
AddpaymentScreen
(
mode:
pages
[
index
].
mode
!,
pageTitleName:
pages
[
index
]
.
pageName
!,
);
}
}
else
if
(
pages
[
index
].
pageName
!.
contains
(
"Payments List"
))
{
else
if
(
pages
[
index
].
pageName
!.
contains
(
"Payments List"
))
{
navigate
=
Paymentlistsbymode
(
navigate
=
Paymentlistsbymode
(
...
...
lib/screens/order/paymentDetailsByMode.dart
View file @
d006edb4
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:generp/Notifiers/ordersProvider/paymentsProvider.dart'
;
import
'package:generp/Notifiers/ordersProvider/paymentsProvider.dart'
;
import
'package:generp/screens/order/editAdjustedOrderList.dart'
;
import
'package:provider/provider.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/commonWidgets.dart'
;
import
'../../Utils/commonWidgets.dart'
;
import
'../finance/FileViewer.dart'
;
import
'../finance/FileViewer.dart'
;
import
'editPaymentDetailsByMode.dart'
;
import
'ordersDetailsByModes.dart'
;
import
'ordersDetailsByModes.dart'
;
class
Paymentdetailsbymode
extends
StatefulWidget
{
class
Paymentdetailsbymode
extends
StatefulWidget
{
...
@@ -44,6 +46,14 @@ class _PaymentdetailsbymodeState extends State<Paymentdetailsbymode> {
...
@@ -44,6 +46,14 @@ class _PaymentdetailsbymodeState extends State<Paymentdetailsbymode> {
child:
Scaffold
(
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
resizeToAvoidBottomInset:
true
,
appBar:
appbar2
(
context
,
widget
.
pageTitleName
,
provider
.
resetAll
,
appBar:
appbar2
(
context
,
widget
.
pageTitleName
,
provider
.
resetAll
,
paymentDetails
.
status
==
"Registered"
?
InkResponse
(
onTap:
()
{
_showOptionsSheet
(
context
);
},
child:
SvgPicture
.
asset
(
"assets/svg/ic_more.svg"
,
height:
30
,),
):
SizedBox
(
width:
0
,),),
SizedBox
(
width:
0
,),),
backgroundColor:
AppColors
.
scaffold_bg_color
,
backgroundColor:
AppColors
.
scaffold_bg_color
,
body:
Container
(
body:
Container
(
...
@@ -496,6 +506,97 @@ class _PaymentdetailsbymodeState extends State<Paymentdetailsbymode> {
...
@@ -496,6 +506,97 @@ class _PaymentdetailsbymodeState extends State<Paymentdetailsbymode> {
);
);
}
}
Future
<
void
>
_showOptionsSheet
(
BuildContext
context
)
{
return
showModalBottomSheet
(
useSafeArea:
true
,
isDismissible:
true
,
isScrollControlled:
true
,
showDragHandle:
true
,
backgroundColor:
Colors
.
white
,
enableDrag:
true
,
context:
context
,
builder:
(
context
)
{
return
StatefulBuilder
(
builder:
(
context
,
setState
)
{
return
SafeArea
(
child:
Consumer
<
Paymentsprovider
>(
builder:
(
context
,
provider
,
child
)
{
return
Container
(
margin:
EdgeInsets
.
only
(
bottom:
15
,
left:
15
,
right:
15
,
top:
10
,
),
child:
SingleChildScrollView
(
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
[
SizedBox
(
height:
15
),
...
List
.
generate
(
2
,
(
index
)
{
final
assetnames
=
[
"ic_edit"
,
"ic_edit"
,
];
final
Headingnames
=
[
"Edit Payment Details"
,
"Edit Adjusted Order"
,
];
return
ListTile
(
onTap:
()
{
switch
(
index
)
{
case
0
:
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
Editpaymentdetailsbymode
(
pageTitleName:
"Edit Payment (
${widget.mode}
)"
,
mode:
widget
.
mode
,
values:
{
"payment_id"
:
provider
.
paymentDetails
.
paymentId
,
"description"
:
provider
.
paymentDetails
!.
description
,
"amount"
:
provider
.
paymentDetails
!.
amount
,
"payment_mode"
:
provider
.
paymentDetails
!.
paymentType
,
"pay_ref"
:
provider
.
paymentDetails
!.
refNo
,
"pay_received_date"
:
provider
.
paymentDetails
!.
paymentDate
,
}),
));
break
;
case
1
:
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
Editadjustedorderlist
(
mode:
widget
.
mode
,
pageTitleName:
"Edit Adjusted Order List (
${widget.mode}
)"
,
values:
{
"account_id"
:
provider
.
paymentDetails
.
accId
,
"orders"
:
provider
.
paidLists
.
map
((
order
)
=>
{
"order_number"
:
order
.
orderNumber
,
"amount"
:
order
.
adjustedAmount
,
}).
toList
(),
},),));
break
;
}
},
leading:
SvgPicture
.
asset
(
"assets/svg/
${assetnames[index]}
.svg"
,
),
title:
Text
(
Headingnames
[
index
],
style:
TextStyle
(
fontFamily:
"JakartaMedium"
),
),
trailing:
SvgPicture
.
asset
(
"assets/svg/arrow_right_new.svg"
,
),
);
}),
],
),
),
);
},
),
);
},
);
},
);
}
Future
<
void
>
_showLevelApprovalRejectionSheet
(
BuildContext
context
,
type
)
{
Future
<
void
>
_showLevelApprovalRejectionSheet
(
BuildContext
context
,
type
)
{
return
showModalBottomSheet
(
return
showModalBottomSheet
(
...
...
lib/screens/screensExports.dart
View file @
d006edb4
...
@@ -30,6 +30,8 @@ export 'package:generp/screens/finance/paymentListPaymentRequisition.dart';
...
@@ -30,6 +30,8 @@ export 'package:generp/screens/finance/paymentListPaymentRequisition.dart';
export
'package:generp/screens/finance/paymentreceiptList.dart'
;
export
'package:generp/screens/finance/paymentreceiptList.dart'
;
export
'package:generp/screens/finance/submitPaymentRequestionListsByMode.dart'
;
export
'package:generp/screens/finance/submitPaymentRequestionListsByMode.dart'
;
export
'package:generp/screens/order/addPayment.dart'
;
export
'package:generp/screens/order/addOrder.dart'
;
export
'package:generp/screens/order/ordersListByModes.dart'
;
export
'package:generp/screens/order/ordersListByModes.dart'
;
export
'package:generp/screens/order/paymentListsByMode.dart'
;
export
'package:generp/screens/order/paymentListsByMode.dart'
;
export
'package:generp/screens/order/tpcAgentIssueList.dart'
;
export
'package:generp/screens/order/tpcAgentIssueList.dart'
;
...
@@ -37,3 +39,4 @@ export 'package:generp/screens/order/tpcAgentListByMode.dart';
...
@@ -37,3 +39,4 @@ export 'package:generp/screens/order/tpcAgentListByMode.dart';
export
'package:generp/screens/order/orderDetailsFeedbackHistory.dart'
;
export
'package:generp/screens/order/orderDetailsFeedbackHistory.dart'
;
export
'package:generp/screens/order/orderDetailsPaymentHistory.dart'
;
export
'package:generp/screens/order/orderDetailsPaymentHistory.dart'
;
export
'package:generp/screens/order/orderDetailsProductsHistory.dart'
;
export
'package:generp/screens/order/orderDetailsProductsHistory.dart'
;
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment