HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/jhtaxatie.creativefellows.nl/classes/RackEntity.php
<?php

class RackEntity
{
  	protected $label_inspection_rack = "Keuringsformulier";
	 
	 
    public function __construct($fields, array $data,$bmwt_status)
	{
		$this->fields = $fields;
		foreach($data as $el =>$val){
			$this->$el = $val;
		}
		
		if(is_array($bmwt_status)){
			foreach($bmwt_status as $el => $val){
				$this->$el = $val;
			}
			
		}
		
		

    }
	
    public function getId()
	{
        return $this->rack_id;
    }
	
    public function rackVersionNew()
	{
        return $this->form_version == 112 ? true : false;
    }
	
	
	
    public function labelId()
	{
        return $this->label;
    }
	
    public function isNew()
	{
        return $this->new_rack == 1 ? true : false;
    }
	
    public function findings()
	{
        return $this->getLabel() == 1 ? "aaa" : "bbb";
    }
	
    public function newRack($show_all = false)
	{	
		return $this->isNew() ? 1 : 0;
	
		/*
		if($this->isNew() || !$this->isNew() && $show_all === false){
			return 1;
		}
		else{
			return 0;
		}
		*/
      //  return $this->new_rack == 1 && $sticker_count === 0  ? 1 : 0;
    }
	
	
    public function isNewLabel($show_all = false)
	{	
		if($this->isNew()){
			return '<span class="label success" style="font-size:0.5rem;">Opleverkeuring</span>';
		}
		elseif(!$this->isNew() && $show_all === false){
			return '<span class="label success" style="font-size:0.5rem;">Opleverkeuring</span>';
			
		}
		else{
			return '<span class="label" style="font-size:0.5rem;background-color:#ccc;color:#000;">Herkeuring</span>';
		}
 //       return $this->isNew() && $show_all === true ? '<span class="label success" style="font-size:0.5rem;">Opleverkeuring</span>' : '&nbsp;';
    }
	
	
	public function getType()
	{
		return $this->getRackTypeLabel($this->type);
	}
	
	public function getRackTypeLabel($label_id)
	{	
		
		return $this->fields["Magazijnstellingen"][2][5][$label_id];
	}

	public function getBrand()
	{
		return $this->brand;
	}
 
	public function getYear()
	{
		return $this->build;
	}

	public function getDate()
	{
		return strftime("%d-%m-%Y", strtotime($this->date));
	}

	public function getStickerNumber($remove_dots = false)
	{
		return $remove_dots == true ? preg_replace("/[^0-9]/", "",$this->stickernumber) : $this->stickernumber;
	}
	
	public function getStickerNumbers()
	{
		$stickers = explode(",",$this->getStickerNumber());
		$status = "";
		foreach($stickers as $sticker)
		{
			$status .= '<div class="row">
							<div class="small-6 columns text-right">'. trim($sticker).'</div>
							<div class="small-6 columns">'. $this->bmwtStatus() .'</div>
						</div>';
		}
		return $status;
	}
	
	public function getFileNumber()
	{
		return $this->filenumber;
	}
	
	public function getRackNumber($i)
	{
		return $this->getDefaultLabel() ." ". $this->getNumber($i) .": ".$this->getArea();
	}
	
	public function getDefaultLabel(){
		return $this->label_inspection_rack;
	}

	public function getArea()
	{
		 return $this->area;
	}
	
	public function getNumber($i){
		return $i+1;
	}
	
	
	
	
	public function getLabel()
	{
		return $this->label;
	}
	 
 	public function getElementValue($element_name,$input_type,$array_values=null)
 	{	
	//	echo "name=".$element_name." type=".$input_type;
 		switch($input_type)
 		{
			case "select":
			case "select_not_required":
			case "select_smart":
				return $array_values[$this->$element_name];
			break;
			
 			case "price":
 				return "€ ".number_format($this->$element_name, 2,',','.');//money_format('€ .2n',  $this->$element_name);
 			break;
			
 			case "switch":
 				return $this->$element_name == "1" ? "ja" : "nee";
 			break;
			
 			case "upload":
 				foreach($this->$element_name as $img){
 					$data .= '<a href="/upload/'. $img["img_name"] .'" target="_blank" class="image-upload" />'. $img["org_name"] .'</a>';
 				};
				
 				return $data; 
 			break;
			
 			default:	
 				return $this->$element_name;
 			break;
 		}
		
 	}
	
	public function getValue($id)
	{	
		$value = $this->$id;
		
		switch($value)
		{
			case 0:
			$value = 5;
			break;
			
			case 1:
			$value = 2;
			break;
			
			case 2:
			$value = 3;
			break;
			
			case 3:
			$value = 4;
			break;
		}
		return $value;
		
	}
	
	public function getValueSign($id)
	{	
		$value = $this->$id;
		
	//	if(!is_numeric($value)){
	///		$title = $id."_title";
	//		return $this->$title."";
	//	}
		
		switch($value)
		{
			case 0:
				$sign = "-";//nvt
			break;
			
			case 1:
				$sign = 3; // goed
			break;
			
			case 2:
				$sign = "\\";// matig
			break;
			
			case 3:
				$sign = 7; // slecht
			break;
			
		}
		return $sign;
		
	}
	
	public function customValueLabel($id)
	{
		$title = $id."_title";
		return $this->$title;
	}
	
	public function valueNumeric($id)
	{
		return is_numeric($this->$id) ? true : false;
	}
	
	public function getValueIcon($id)
	{
		$value = $this->$id;

		if(!is_numeric($value)) return $value;
		
		switch($value)
		{			
			case 0:
				$color = "gray";
			break;
			
			case 1:
				$color = "green";
			break;
			
			case 2:
				$color = "orange";
			break;
			
			case 3:
				$color = "red";
			break;
		    
			default;
				return $value;
		   	break;
		}
		return '<span class="rate-icon '. $color .'">&nbsp;</span>';
	}
	
	public function getXmlLines()
	{
		$rack_fields = $this->rackVersionNew() ? $this->fields["Keuringspunten - Nieuwe stelling"] : $this->fields["Keuringspunten - Oude stelling"] ;
		$lines = [];
		foreach($rack_fields as $i => $field)
		{
			$x = 1;
			foreach($field[5] as $check){
				
				$line = [
					"GroupNumber" => ($i + 1),
					"LineNumber" => $x,
					"Value" => $this->getCheckValue($i+1,$x),
				];
				
				if(strtolower($check) == "overig"){
					$line["AdditionalValue"] = $this->customValueLabel("r".($i+1).$x);
				}
				
				$lines[] = $line;
				$x++;
			}
			
		}
	
		return $lines;
	}
	
	public function getCheckValue($group,$id)
	{	
		$label = "r".$group.$id;
		switch($this->$label)
		{
			case 0:
				return 0;
			break;
				
			case 1:
				return 3;
			break;

			case 2:
				return 2;
			break;

			case 3:
				return 1;
			break;
		}
		return ;
	}
	
	public function getDateBmwt()
	{
		return strftime("%Y-%m-%d", strtotime($this->date));
	}
	
	public function recommendations(){
		return $this->recommendations;
	}
	
	public function bmwtStatusCode()
	{
		return $this->code;
	}
	
	public function bmwtStatus()
	{	
		
		switch($this->bmwtStatusCode())
		{
			default:
				$class 		= "bmwt-status__inactive";
				$message 	= $this->code ? $this->message : "Nog geen status bij BMWT";
				$this->code = $this->code ?? 0 ;
				$tooltip 	= $this->response_id ? ' data-tooltip aria-haspopup="true" class="has-tip" title="'. $message .'"' : '';
			break;
			
			case 100:
				$class 		= "bmwt-status__ok";
				$message 	= "Keuring succesvol bij BMWT afgemeld";
			break;
			
			case 104:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het FORMULIERTYPE is onbekend";
			break;
			
			case 106:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het verplichte veld SERIENUMMER is niet ingevuld";
			break;
			
			case 107:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het verplichte veld KEURINGSDATUM is niet ingevuld";
			break;
			
			case 108:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het verplichte veld STICKERNUMMER is niet ingevuld";
			break;
			
			case 109:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het ingevulde stickernummer is onbekend of onjuist";
			break;
			
			case 110:
				$class 		= "bmwt-status__ok";
				$message 	= "Het ingevulde stickernummer is al gebruikt of teruggemeld";
			break;
			
			case 111:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het ingevulde stickernummer is aan een andere keuringsinstantie toegewezen";
			break;
			
			case 113:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het verplichte veld GEBRUIKERNAAM is niet ingevuld";
			break;
			
			case 114:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het verplichte veld GEBRUIKERADRES is niet ingevuld";
			break;
			
			case 115:
				$class 		= "bmwt-status__inactive";
				$message 	= "Het verplichte veld GEBRUIKERPLAATS is niet ingevuld";
			break;
			
			case 117:
				$class 		= "bmwt-status__inactive";
				$message 	= "Niet alle keuringsgroepen zijn voor dit formulier opgenomen";
			break;
			
			case 118:
				$class 		= "bmwt-status__inactive";
				$message 	= "Niet alle keuringspunten zijn voor dit formulier opgenomen";
			break;
			
			case "Server":
				$class 		= "bmwt-status__red";
				$message 	= "Fout in data niet volgens specificaties BMWT";
			break;
			
			
		}
		
		return '<span class="bmwt-status '.$class.'" data-tooltip aria-haspopup="true" class="has-tip" title="'. $message .' ('. $this->code .')"></span>';
		
	} 

}

?>