2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:04:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								require_once  './src/Label/vendor/autoload.php' ;  
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								use  Cloudlog\Label\PDF_Label ;  
						 
					
						
							
								
									
										
										
										
											2023-06-12 14:20:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								use  Cloudlog\Label\tfpdf ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								use  Cloudlog\Label\font\unifont\ttfonts ;  
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  (  !  defined ( 'BASEPATH' ))  exit ( 'No direct script access allowed' );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  Labels  extends  CI_Controller  {  
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									/* 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|  Controller :  Labels 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									|  This  Controller  handles  all  things  Labels ,  creating ,  editing  and  printing 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 */ 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  __construct ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										parent :: __construct (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> helper ( array ( 'form' ,  'url' ,  'psr4_autoloader' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'user_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( ! $this -> user_model -> authorize ( 2 ))  {  $this -> session -> set_flashdata ( 'notice' ,  'You\'re not allowed to do that!' );  redirect ( 'dashboard' );  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|  Function :  index 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|  Nothing  fancy  just  shows  the  main  display  of  how  many  labels  are  waiting 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									|  to  be  printed  per  station  profile . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 */ 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									public  function  index ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data [ 'page_title' ]  =  " QSL Card Labels " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data [ 'labels' ]  =  $this -> labels_model -> fetchLabels ( $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 16:05:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$data [ 'papertypes' ]  =  $this -> labels_model -> fetchPapertypes ( $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$data [ 'qsos' ]  =  $this -> labels_model -> fetchQsos ( $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$footerData  =  []; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$footerData [ 'scripts' ]  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'assets/js/sections/labels.js' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'interface_assets/header' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'labels/index' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'interface_assets/footer' ,  $footerData ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|  Function :  create 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									|  Shows  the  form  used  to  create  a  label  type . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 */ 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									public  function  create ()  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$data [ 'page_title' ]  =  " Create Label Type " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> library ( 'form_validation' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 16:34:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data [ 'papertypes' ]  =  $this -> labels_model -> fetchPapertypes ( $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> form_validation -> set_rules ( 'label_name' ,  'Label Name' ,  'required' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $this -> form_validation -> run ()  ==  FALSE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> view ( 'interface_assets/header' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> view ( 'labels/create' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> view ( 'interface_assets/footer' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										else 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> labels_model -> addLabel (); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 00:59:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										/* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|  Function :  createpaper 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|-------------------------------------------------------------------------- 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									|  Shows  the  form  used  to  create  a  paper  type . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									| 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  createpaper ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data [ 'page_title' ]  =  " Create Paper Type " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> library ( 'form_validation' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> form_validation -> set_rules ( 'paper_name' ,  'Paper Name' ,  'required' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $this -> form_validation -> run ()  ==  FALSE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> view ( 'interface_assets/header' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> view ( 'labels/createpaper' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> view ( 'interface_assets/footer' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 01:10:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$this -> labels_model -> addPaper (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  catch  ( \Throwable  $th )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$this -> session -> set_flashdata ( 'error' ,  'Your paper could not be saved. Remember that it can\'t have the same name as existing paper types.' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												redirect ( 'labels/createpaper' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 00:59:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-27 21:03:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  printids ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$ids  =  xss_clean ( json_decode ( $this -> input -> post ( 'id' ))); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-01 16:30:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$offset  =  xss_clean ( $this -> input -> post ( 'startat' )); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-05 17:42:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$grid  =  $this -> input -> post ( 'grid' )  ===  " true "  ?  1  :  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-26 17:10:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$via  =  $this -> input -> post ( 'via' )  ===  " true "  ?  1  :  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$awards  =  $this -> input -> post ( 'awards' )  ===  " true "  ?  1  :  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-27 21:03:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$result  =  $this -> labels_model -> export_printrequestedids ( $ids ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> prepareLabel ( $result ,  true ,  $offset ,  $grid ,  $via ,  $awards ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-27 21:03:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									public  function  print ( $station_id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$clean_id  =  xss_clean ( $station_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:49:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$offset  =  xss_clean ( $this -> input -> post ( 'startat' )); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-05 13:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$grid  =  xss_clean ( $this -> input -> post ( 'grid' )  ? ?  0 ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-26 17:10:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$via  =  xss_clean ( $this -> input -> post ( 'via' )  ? ?  0 ); 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$awards  =  xss_clean ( $this -> input -> post ( 'awards' )  ? ?  0 ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-31 01:25:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> load -> model ( 'stations' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $this -> stations -> check_station_is_accessible ( $station_id ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$result  =  $this -> labels_model -> export_printrequested ( $clean_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-14 22:28:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> prepareLabel ( $result ,  false ,  $offset ,  $grid ,  $via ,  $awards ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-31 01:25:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-27 21:03:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  prepareLabel ( $qsos ,  $jscall  =  false ,  $offset  =  1 ,  $grid  =  false ,  $via  =  false ,  $awards  =  false )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-27 21:03:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$label  =  $this -> labels_model -> getDefaultLabel (); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-04 00:22:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $label )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 19:34:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$label -> font = 'DejaVuSans' ;  // Fix font to DejaVuSans
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:37:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$ptype = $this -> labels_model -> getPaperType ( $label -> paper_type_id ); 	// fetch papersize out of paper-table
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 16:55:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  (( $ptype -> paper_id  ? ?  '' )  !=  '' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 12:45:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													if  ( $ptype -> metric  ==  'in' ) 	{ 		// convert papersize to mm if given in inch
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$paper_width = $ptype -> width * 25.4 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$paper_height = $ptype -> height * 25.4 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$paper_width = $ptype -> width ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$paper_height = $ptype -> height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 16:55:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$pdf  =  new  PDF_Label ( array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'paper-size' 	=>  'custom' ,  				// $label->paper_type,	// The only Type left is "custom" because A4 and so on are also defined at paper_types
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'metric' 		=>  $label -> metric , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'marginLeft' 	=>  $label -> marginleft , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'marginTop' 		=>  $label -> margintop , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'NX' 			=>  $label -> nx , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'NY' 			=>  $label -> ny , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'SpaceX' 		=>  $label -> spacex , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'SpaceY' 		=>  $label -> spacey , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'width' 			=>  $label -> width , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'height' 		=>  $label -> height , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'font-size' 		=>  $label -> font_size , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 12:45:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														'pgX' 		=>  $paper_width , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'pgY' 		=>  $paper_height 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 16:55:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													)); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( $jscall )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														header ( 'Content-Type: application/json' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														echo  json_encode ( array ( 'message'  =>  'You need to assign a paperType to the label before printing' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$this -> session -> set_flashdata ( 'error' ,  'You need to assign a paperType to the label before printing' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-04 00:22:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-28 18:24:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( $jscall )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													header ( 'Content-Type: application/json' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													echo  json_encode ( array ( 'message'  =>  'You need to create a label and set it to be used for print.' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$this -> session -> set_flashdata ( 'error' ,  'You need to create a label and set it to be used for print.' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-28 18:24:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-04 00:22:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  catch  ( \Throwable  $th )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-28 18:24:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( $jscall )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												header ( 'Content-Type: application/json' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												echo  json_encode ( array ( 'message'  =>  'Something went wrong! The label could not be generated. Check label size and font size.' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$this -> session -> set_flashdata ( 'error' ,  'Something went wrong! The label could not be generated. Check label size and font size.' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-28 18:24:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-12 14:20:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										define ( 'FPDF_FONTPATH' ,  './src/Label/font/' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 18:20:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$pdf -> AddPage ( $ptype -> orientation ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $label -> font  ==  'DejaVuSans' )  { 	// leave this here, for future Use
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-12 14:20:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$pdf -> AddFont ( $label -> font , '' , 'DejaVuSansMono.ttf' , true ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 16:55:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$pdf -> SetFont ( $label -> font , '' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-12 14:20:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$pdf -> AddFont ( $label -> font ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$pdf -> SetFont ( $label -> font ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-27 21:03:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $qsos -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> makeMultiQsoLabel ( $qsos -> result (),  $pdf ,  $label -> qsos ,  $offset ,  $ptype -> orientation ,  $grid ,  $via ,  $awards ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> session -> set_flashdata ( 'message' ,  '0 QSOs found for print!' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											redirect ( 'labels' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$pdf -> Output (); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  makeMultiQsoLabel ( $qsos ,  $pdf ,  $numberofqsos ,  $offset ,  $orientation ,  $grid ,  $via ,  $awards )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$text  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$current_callsign  =  '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 16:28:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$current_sat  =  '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:08:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$current_sat_mode  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$current_sat_bandrx  =  '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$qso_data  =  []; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:46:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $offset  !==  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for  ( $i  =  1 ;  $i  <  $offset ;  $i ++ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 18:20:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$pdf -> Add_Label ( '' , $orientation ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:46:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										foreach ( $qsos  as  $qso )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:50:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  (( $this -> pretty_sat_mode ( $qso -> COL_SAT_MODE )  !==  $current_sat_mode )  ||  ( $qso -> COL_SAT_NAME   !==  $current_sat )  ||  ( $qso -> COL_CALL  !==  $current_callsign )  ||  // Call, SAT or SAT-Mode differs?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											(  ( $qso -> COL_BAND_RX  !==  $current_sat_bandrx )  &&  ( $this -> pretty_sat_mode ( $qso -> COL_SAT_MODE )  !==  '' ))  )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											   // ((($qso->COL_SAT_NAME ?? '' !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) && ($qso->COL_SAT_NAME ?? '' !== '') && ($col->COL_BAND_RX ?? '' !== $current_sat_bandrx))) {
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( ! empty ( $qso_data ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$this -> finalizeData ( $pdf ,  $current_callsign ,  $qso_data ,  $numberofqsos ,  $orientation ,  $grid ,  $via ,  $awards ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$qso_data  =  []; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$current_callsign  =  $qso -> COL_CALL ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 16:28:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$current_sat  =  $qso -> COL_SAT_NAME ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:50:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$current_sat_mode  =  $this -> pretty_sat_mode ( $qso -> COL_SAT_MODE ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$current_sat_bandrx  =  $qso -> COL_BAND_RX  ? ?  '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$qso_data []  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'time'  =>  $qso -> COL_TIME_ON , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'band'  =>  $qso -> COL_BAND , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-01 15:57:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'mode'  =>  (( $qso -> COL_SUBMODE  ? ?  '' )  ==  '' )  ?  $qso -> COL_MODE  :  $qso -> COL_SUBMODE , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'rst'  =>  $qso -> COL_RST_SENT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'mygrid'  =>  $qso -> station_gridsquare , 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-26 17:10:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'via'  =>  $qso -> COL_QSL_VIA , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'sat'  =>  $qso -> COL_SAT_NAME , 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:50:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'sat_mode'  =>  $this -> pretty_sat_mode ( $qso -> COL_SAT_MODE  ? ?  '' ), 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:08:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'sat_band_rx'  =>  ( $qso -> COL_BAND_RX  ? ?  '' ), 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-05 13:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'qsl_recvd'  =>  $qso -> COL_QSL_RCVD , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'mycall'  =>  $qso -> COL_STATION_CALLSIGN , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'awards'  =>  $this -> stationAwardsList ( $qso ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! empty ( $qso_data ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> finalizeData ( $pdf ,  $current_callsign ,  $qso_data ,  $numberofqsos ,  $orientation ,  $grid ,  $via ,  $awards ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  stationAwardsList ( $station_profile )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$awards  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( trim ( $station_profile -> station_iota )  !==  '' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$awards  .=  " IOTA: "  .  $station_profile -> station_iota  .  "   " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( trim ( $station_profile -> station_sota )  !==  '' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$awards  .=  " SOTA: "  .  $station_profile -> station_sota  .  "   " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( trim ( $station_profile -> station_wwff )  !==  '' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$awards  .=  " WWFF: "  .  $station_profile -> station_wwff  .  "   " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( trim ( $station_profile -> station_pota )  !==  '' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$awards  .=  " POTA: "  .  $station_profile -> station_pota  .  "   " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( trim ( $station_profile -> station_sig )  !==  ''  &&  trim ( $station_profile -> station_sig_info )  !==  '' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$awards  .=  $station_profile -> station_sig  .  " : "  .  $station_profile -> station_sig_info ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $awards ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// New begin
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:50:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  pretty_sat_mode ( $sat_mode )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 15:59:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return ( strlen ( $sat_mode  ? ?  '' )  ==  2  ?  ( strtoupper ( $sat_mode [ 0 ]) . '/' . strtoupper ( $sat_mode [ 1 ]))  :  strtoupper ( $sat_mode  ? ?  '' )); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:50:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:04:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  finalizeData ( $pdf ,  $current_callsign ,  & $preliminaryData ,  $qso_per_label , $orientation ,  $grid ,  $via ,  $awards )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:49:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$tableData  =  []; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$count_qso  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$qso = []; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach  ( $preliminaryData  as  $key  =>  $row )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$qso = $row ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 18:13:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$time  =  strtotime ( $qso [ 'time' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 21:13:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$myFormatForView  =  date ( " d.m.y H:i " ,  $time ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$rowData  =  [ 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 13:35:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'DD.MM.YY  UTC'  =>  $myFormatForView , 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'Band'  =>  $row [ 'band' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'Mode'  =>  $row [ 'mode' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'RST'  =>  $row [ 'rst' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$tableData []  =  $rowData ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$count_qso ++ ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:46:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( $count_qso  ==  $qso_per_label ){ 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$this -> generateLabel ( $pdf ,  $current_callsign ,  $tableData , $count_qso , $qso , $orientation ,  $grid ,  $via ,  $awards ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$tableData  =  [];  // reset the data
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$count_qso  =  0 ;   // reset the counter
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											unset ( $preliminaryData [ $key ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// generate label for remaining QSOs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( $count_qso  >  0 ){ 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> generateLabel ( $pdf ,  $current_callsign ,  $tableData , $count_qso , $qso , $orientation ,  $grid ,  $via ,  $awards ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$preliminaryData  =  [];  // reset the data
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:04:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  generateLabel ( $pdf ,  $current_callsign ,  $tableData , $numofqsos , $qso , $orientation , $grid = true ,  $via = false ,  $awards = false ){ 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$builder  =  new  \AsciiTable\Builder (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$builder -> addRows ( $tableData ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-05 13:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$text  =  " Confirming QSO " . ( $numofqsos > 1  ?  's'  :  '' ) . "  with  " ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-26 17:10:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$text  .=  $current_callsign ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  (( $via )  &&  ( $qso [ 'via' ]  ? ?  ''  !=  '' ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-26 19:29:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$text .= ' via ' . substr ( $qso [ 'via' ], 0 , 8 ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-26 17:10:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$text  .=  " \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-05 13:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$text  .=  $builder -> renderTable (); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( $qso [ 'sat' ]  !=  " " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:08:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  (( $qso [ 'sat_mode' ]  ==  '' )  &&  ( $qso [ 'sat_band_rx' ]  !==  '' ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$text  .=  " \n " . 'Satellite: ' . $qso [ 'sat' ] . ' Band RX: ' . $qso [ 'sat_band_rx' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  elseif  (( $qso [ 'sat_mode' ]  ==  '' )  &&  ( $qso [ 'sat_band_rx' ]  ==  '' ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$text  .=  " \n " . 'Satellite: ' . $qso [ 'sat' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:50:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$text  .=  " \n " . 'Satellite: ' . $qso [ 'sat' ] . ' Mode: ' . $qso [ 'sat_mode' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 14:08:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 22:53:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-05 13:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$text .= " \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $grid )  {  $text  .=  " My call:  " . $qso [ 'mycall' ] . "  Grid:  " . $qso [ 'mygrid' ] . " \n " ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 01:25:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $awards )  {  $text  .=  $qso [ 'awards' ] . " \n " ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-05 13:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$text  .=  " Thanks for the QSO " . ( $numofqsos > 1  ?  's'  :  '' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 17:31:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$text  .=  "  |  " . ( $qso [ 'qsl_recvd' ]  ==  'Y'  ?  'TNX'  :  'PSE' ) . "  QSL " ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 18:20:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$pdf -> Add_Label ( $text , $orientation ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:51:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// New End
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 14:46:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  edit ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$cleanid  =  $this -> security -> xss_clean ( $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 14:53:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$data [ 'label' ]  =  $this -> labels_model -> getLabel ( $cleanid , $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 16:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$data [ 'papertypes' ]  =  $this -> labels_model -> fetchPapertypes ( $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 14:46:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$data [ 'page_title' ]  =  " Edit Label " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'interface_assets/header' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'labels/edit' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'interface_assets/footer' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateLabel ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> labels_model -> updateLabel ( $id ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> session -> set_flashdata ( 'message' ,  'Label was saved.' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 14:46:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										redirect ( 'labels' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  delete ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> labels_model -> deleteLabel ( $id ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> session -> set_flashdata ( 'warning' ,  'Label was deleted.' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-03 00:50:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  saveDefaultLabel ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$id  =  $this -> input -> post ( 'id' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> labels_model -> saveDefaultLabel ( $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  startAtLabel ()  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:49:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$data [ 'stationid' ]  =  xss_clean ( $this -> input -> post ( 'stationid' )); 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 02:02:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> load -> view ( 'labels/startatform' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 16:05:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  editPaper ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$cleanid  =  $this -> security -> xss_clean ( $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data [ 'paper' ]  =  $this -> labels_model -> getPaper ( $cleanid ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data [ 'page_title' ]  =  " Edit Paper " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'interface_assets/header' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'labels/editpaper' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> view ( 'interface_assets/footer' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updatePaper ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 01:10:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> labels_model -> updatePaper ( $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  catch  ( \Throwable  $th )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> session -> set_flashdata ( 'error' ,  'Your paper could not be saved. Remember that it can\'t have the same name as existing paper types.' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$cleanid  =  $this -> security -> xss_clean ( $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											redirect ( 'labels/editpaper/' . $cleanid ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 16:05:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> session -> set_flashdata ( 'message' ,  'Paper was saved.' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 14:15:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  label_cnt_with_paper ( $paper_id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $this -> labels_model -> label_cnt_with_paper ( $paper_id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 16:05:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  deletePaper ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'labels_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> labels_model -> deletePaper ( $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> session -> set_flashdata ( 'warning' ,  'Paper was deleted.' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										redirect ( 'labels' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 14:04:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}