File: /var/www/vhosts/creativefellows.nl/jhtaxatie.creativefellows.nl/classes/EnquiryTruck.php
<?php
class EnquiryTruck
{
public function __construct($fields, array $data)
{
foreach($data as $el =>$val){
$this->$el = $val;
}
$this->fields = $fields;
// d($this);
}
public function getId()
{
return $this->enquiry_id;
}
public function getTruckId()
{
return $this->truck_id;
}
public function getTruckAmount()
{
return $this->truck_amount;
}
public function getTruckType()
{
return $this->truck_type;
}
public function getUsage()
{
return $this->fields["Inzet & Gebruik"][1][5][$this->truck_usage];
}
public function getDateFrom()
{
return $this->date_from;
}
public function getTruck()
{
return $this->fields["Inzet & Gebruik"][1][5][$this->truck_usage];
}
public function getCompany()
{
return $this->company_name;
}
public function getLZP()
{
return $this->lzp;
}
public function getPowerType()
{
return $this->getPowerLabel($this->power);
}
private function getPowerLabel($power_id)
{
return $this->fields["Truck"][0][5][$power_id];
}
public function getUsageType()
{
return $this->getUsageLabel($this->truck_usage);
}
private function getUsageLabel($truck_usage_id)
{
return $this->fields["Algemeen"][2][5][$truck_usage_id];
}
public function getBudget()
{
return $this->budget;
}
public function getYear()
{
return $this->build;
}
public function getDate()
{
return strftime("%d-%m-%Y", strtotime($this->date));
}
public function getStickerNumber()
{
return $this->stickernumber;
}
public function getFileNumber()
{
return $this->filenumber;
}
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)
{
switch($input_type)
{
case "select":
case "select_smart":
case "radio_image":
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;
case "upload2":
foreach($this->$element_name as $img){
$data .= '<a href="/enquiry/download/'. $img->getFileId() .'" target="_blank" class="image-upload" />'. $img->getOrgName() .'</a>';
};
return $data;
break;
case "checkbox":
$all_options = $this->fields["Truck"][5][5];
$array_ids = explode(", ",$this->$element_name);
$opt_arr = [];
foreach($array_ids as $id){
$opt_arr[] = $all_options[$id];
}
return implode(", ",$opt_arr);
break;
case "select_smart_multiple":
$items = explode(", ",$this->$element_name);
$selected = [];
foreach($items as $option){
$selected[] = $array_values[$option];
}
return implode(", ",$selected);
break;
default:
return $this->$element_name;
break;
}
}
}
?>