2024-03-19 00:59:34 +01:00
< ? php
/**
* PHP Mikrotik Billing ( https :// github . com / hotspotbilling / phpnuxbill / )
* by https :// t . me / ibnux
**/
2024-03-19 10:22:54 +07:00
_admin ();
2024-03-19 00:59:34 +01:00
$ui -> assign ( '_system_menu' , 'map' );
$action = $routes [ '1' ];
$ui -> assign ( '_admin' , $admin );
if ( empty ( $action )) {
$action = 'customer' ;
}
2025-02-04 13:50:43 +07:00
$ui -> assign ( 'xheader' , '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css">' );
$ui -> assign ( 'xfooter' , '<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>' );
2024-03-19 00:59:34 +01:00
switch ( $action ) {
case 'customer' :
2024-04-29 13:44:59 +07: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 00:59:34 +01:00
$customerData = [];
foreach ( $c as $customer ) {
2024-03-19 10:22:54 +07:00
if ( ! empty ( $customer -> coordinates )) {
$customerData [] = [
'id' => $customer -> id ,
'name' => $customer -> fullname ,
'balance' => $customer -> balance ,
'address' => $customer -> address ,
2024-03-23 12:38:23 +07:00
'direction' => $customer -> coordinates ,
2024-03-19 10:22:54 +07: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 00:59:34 +01:00
}
2024-04-29 13:44:59 +07:00
$ui -> assign ( 'search' , $search );
2024-03-19 00:59:34 +01:00
$ui -> assign ( 'customers' , $customerData );
$ui -> assign ( '_title' , Lang :: T ( 'Customer Geo Location Information' ));
2025-02-04 13:50:43 +07:00
$ui -> display ( 'admin/maps/customers.tpl' );
2024-03-19 00:59:34 +01:00
break ;
2025-02-04 13:50:43 +07:00
case 'routers' :
$name = _post ( 'name' );
$query = ORM :: for_table ( 'tbl_routers' ) -> where_not_equal ( 'coordinates' , '' ) -> order_by_desc ( 'id' );
$query -> selects ([ 'id' , 'name' , 'coordinates' , 'description' , 'coverage' , 'enabled' ]);
if ( $name != '' ) {
$query -> where_like ( 'name' , '%' . $name . '%' );
}
$d = Paginator :: findMany ( $query , [ 'name' => $name ], '20' , '' , true );
$ui -> assign ( 'name' , $name );
$ui -> assign ( 'd' , $d );
$ui -> assign ( '_title' , Lang :: T ( 'Routers Geo Location Information' ));
$ui -> display ( 'admin/maps/routers.tpl' );
break ;
2024-03-19 00:59:34 +01:00
default :
2025-01-31 16:22:58 +07:00
r2 ( getUrl ( 'map/customer' ), 'e' , 'action not defined' );
2024-03-19 00:59:34 +01:00
break ;
}