2022-09-04 08:49:58 +02:00
< ? php if ( ! defined ( 'BASEPATH' )) exit ( 'No direct script access allowed' );
/*
Handles Displaying of band information
*/
class Band extends CI_Controller {
function __construct ()
{
parent :: __construct ();
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> model ( 'user_model' );
2025-01-02 10:22:23 +01:00
if ( ! $this -> user_model -> authorize ( 2 ) || ! clubaccess_check ( 9 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2022-09-04 08:49:58 +02:00
}
public function index ()
{
$this -> load -> model ( 'bands' );
2022-09-04 18:26:21 +02:00
$data [ 'bands' ] = $this -> bands -> get_all_bands_for_user ();
2024-03-03 08:58:56 +01:00
2022-09-04 08:49:58 +02:00
// Render Page
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Bands " );
2022-09-04 08:49:58 +02:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'bands/index' );
$this -> load -> view ( 'interface_assets/footer' );
}
2022-09-05 20:26:08 +02:00
2024-03-03 08:58:56 +01:00
public function create ()
2022-09-05 20:26:08 +02:00
{
$this -> load -> model ( 'bands' );
$this -> load -> library ( 'form_validation' );
2022-09-06 19:35:27 +02:00
$this -> form_validation -> set_rules ( 'band' , 'Band' , 'required' );
2022-09-05 20:26:08 +02:00
2024-10-12 06:29:40 +00:00
if ( $this -> form_validation -> run () == FALSE ) {
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Create Mode " );
2022-09-06 19:35:27 +02:00
$this -> load -> view ( 'bands/create' , $data );
2024-10-12 06:29:40 +00:00
} else {
$band_data = array (
'band' => $this -> input -> post ( 'band' , true ),
'bandgroup' => $this -> input -> post ( 'bandgroup' , true ),
'ssb' => $this -> input -> post ( 'ssbqrg' , true ),
'data' => $this -> input -> post ( 'dataqrg' , true ),
'cw' => $this -> input -> post ( 'cwqrg' , true ),
);
$this -> bands -> add ( $band_data );
2022-09-05 20:26:08 +02:00
}
}
2022-09-06 20:18:17 +02:00
public function edit ()
2022-09-05 20:26:08 +02:00
{
$this -> load -> model ( 'bands' );
2022-09-06 20:18:17 +02:00
$item_id_clean = $this -> security -> xss_clean ( $this -> input -> post ( 'id' ));
2022-09-05 20:26:08 +02:00
2022-09-06 20:18:17 +02:00
$band_query = $this -> bands -> getband ( $item_id_clean );
2022-09-05 20:26:08 +02:00
2022-09-06 20:18:17 +02:00
$data [ 'my_band' ] = $band_query -> row ();
2024-03-03 08:58:56 +01:00
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Edit Band " );
2022-09-05 20:26:08 +02:00
2022-09-06 20:18:17 +02:00
$this -> load -> view ( 'bands/edit' , $data );
}
public function saveupdatedband () {
$this -> load -> model ( 'bands' );
$id = $this -> security -> xss_clean ( $this -> input -> post ( 'id' , true ));
2022-09-09 18:52:57 +02:00
$band [ 'band' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'band' , true ));
$band [ 'bandgroup' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'bandgroup' , true ));
$band [ 'ssbqrg' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'ssbqrg' , true ));
$band [ 'dataqrg' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'dataqrg' , true ));
$band [ 'cwqrg' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'cwqrg' , true ));
2022-09-06 20:18:17 +02:00
$this -> bands -> saveupdatedband ( $id , $band );
echo json_encode ( array ( 'message' => 'OK' ));
return ;
2022-09-05 20:26:08 +02:00
}
public function delete () {
$id = $this -> input -> post ( 'id' );
$this -> load -> model ( 'bands' );
$this -> bands -> delete ( $id );
}
public function activate () {
$id = $this -> input -> post ( 'id' );
$this -> load -> model ( 'bands' );
$this -> bands -> activate ( $id );
header ( 'Content-Type: application/json' );
echo json_encode ( array ( 'message' => 'OK' ));
return ;
}
public function deactivate () {
$id = $this -> input -> post ( 'id' );
$this -> load -> model ( 'bands' );
$this -> bands -> deactivate ( $id );
header ( 'Content-Type: application/json' );
echo json_encode ( array ( 'message' => 'OK' ));
return ;
}
public function activateall () {
$this -> load -> model ( 'bands' );
$this -> bands -> activateall ();
header ( 'Content-Type: application/json' );
echo json_encode ( array ( 'message' => 'OK' ));
return ;
}
public function deactivateall () {
$this -> load -> model ( 'bands' );
$this -> bands -> deactivateall ();
header ( 'Content-Type: application/json' );
echo json_encode ( array ( 'message' => 'OK' ));
return ;
}
public function saveBand () {
$id = $this -> security -> xss_clean ( $this -> input -> post ( 'id' ));
$band [ 'status' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'status' ));
$band [ 'cq' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'cq' ));
$band [ 'dok' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'dok' ));
$band [ 'dxcc' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'dxcc' ));
2024-03-03 08:58:56 +01:00
$band [ 'helvetia' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'helvetia' ));
2022-09-05 20:26:08 +02:00
$band [ 'iota' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'iota' ));
2024-03-03 08:58:56 +01:00
$band [ 'jcc' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'jcc' ));
$band [ 'pota' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'pota' ));
$band [ 'rac' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'rac' ));
2022-09-05 20:26:08 +02:00
$band [ 'sig' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'sig' ));
$band [ 'sota' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'sota' ));
$band [ 'uscounties' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'uscounties' ));
$band [ 'was' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'was' ));
2022-09-20 17:25:50 +02:00
$band [ 'wwff' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'wwff' ));
2022-09-05 20:26:08 +02:00
$band [ 'vucc' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'vucc' ));
2024-01-06 14:48:24 +00:00
$band [ 'waja' ] = $this -> security -> xss_clean ( $this -> input -> post ( 'waja' ));
2024-03-03 08:58:56 +01:00
2022-09-05 20:26:08 +02:00
$this -> load -> model ( 'bands' );
$this -> bands -> saveBand ( $id , $band );
2024-03-03 08:58:56 +01:00
2022-09-05 20:26:08 +02:00
header ( 'Content-Type: application/json' );
echo json_encode ( array ( 'message' => 'OK' ));
return ;
}
2022-10-06 11:41:01 +02:00
public function saveBandAward () {
$award = $this -> security -> xss_clean ( $this -> input -> post ( 'award' ));
$status = $this -> security -> xss_clean ( $this -> input -> post ( 'status' ));
2024-03-03 08:58:56 +01:00
2022-10-06 11:41:01 +02:00
$this -> load -> model ( 'bands' );
$this -> bands -> saveBandAward ( $award , $status );
2024-03-03 08:58:56 +01:00
2022-10-06 11:41:01 +02:00
header ( 'Content-Type: application/json' );
echo json_encode ( array ( 'message' => 'OK' ));
return ;
}
2024-07-05 21:37:50 +02:00
public function saveBandUnit () {
$unit = $this -> security -> xss_clean ( $this -> input -> post ( 'unit' ));
$band_id = $this -> security -> xss_clean ( $this -> input -> post ( 'band_id' ));
$this -> load -> model ( 'bands' );
$band = $this -> bands -> getband ( $band_id ) -> row () -> band ;
$this -> user_options_model -> set_option ( 'frequency' , 'unit' , array ( $band => $unit ));
$this -> session -> set_userdata ( 'qrgunit_' . $band , $unit );
}
2024-01-06 14:48:24 +00:00
}