2024-03-19 07:59:34 +08:00
< ? php
/**
* PHP Mikrotik Billing ( https :// github . com / hotspotbilling / phpnuxbill / )
* by https :// t . me / ibnux
**/
2024-03-19 11:22:54 +08:00
_admin ();
2024-03-19 07:59:34 +08:00
$ui -> assign ( '_system_menu' , 'map' );
$action = $routes [ '1' ];
$ui -> assign ( '_admin' , $admin );
if ( empty ( $action )) {
$action = 'customer' ;
}
switch ( $action ) {
case 'customer' :
2024-04-29 14:44:59 +08:00
if ( ! empty ( _req ( 'search' ))){
$search = _req ( 'search' );
$query = ORM :: for_table ( 'tbl_customers' ) -> whereRaw ( " coordinates != '' AND fullname LIKE '% $search %' OR username LIKE '% $search %' OR email LIKE '% $search %' OR phonenumber LIKE '% $search %' " ) -> order_by_desc ( 'fullname' );
$c = Paginator :: findMany ( $query , [ 'search' => $search ], 50 );
} else {
$query = ORM :: for_table ( 'tbl_customers' ) -> where_not_equal ( 'coordinates' , '' );
$c = Paginator :: findMany ( $query , [ 'search' => '' ], 50 );
}
2024-03-19 07:59:34 +08:00
$customerData = [];
foreach ( $c as $customer ) {
2024-03-19 11:22:54 +08:00
if ( ! empty ( $customer -> coordinates )) {
$customerData [] = [
'id' => $customer -> id ,
'name' => $customer -> fullname ,
'balance' => $customer -> balance ,
'address' => $customer -> address ,
2024-03-23 13:38:23 +08:00
'direction' => $customer -> coordinates ,
2024-03-19 11:22:54 +08:00
'info' => Lang :: T ( " Username " ) . " : " . $customer -> username . " - " . Lang :: T ( " Full Name " ) . " : " . $customer -> fullname . " - " . Lang :: T ( " Email " ) . " : " . $customer -> email . " - " . Lang :: T ( " Phone " ) . " : " . $customer -> phonenumber . " - " . Lang :: T ( " Service Type " ) . " : " . $customer -> service_type ,
'coordinates' => '[' . $customer -> coordinates . ']' ,
];
}
2024-03-19 07:59:34 +08:00
}
2024-04-29 14:44:59 +08:00
$ui -> assign ( 'search' , $search );
2024-03-19 07:59:34 +08:00
$ui -> assign ( 'customers' , $customerData );
$ui -> assign ( 'xheader' , '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css">' );
$ui -> assign ( '_title' , Lang :: T ( 'Customer Geo Location Information' ));
$ui -> assign ( 'xfooter' , '<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>' );
2024-03-24 14:35:31 +08:00
$ui -> display ( 'customers-map.tpl' );
2024-03-19 07:59:34 +08:00
break ;
default :
r2 ( U . 'map/customer' , 'e' , 'action not defined' );
break ;
}