package BOLO.services;

import org.springframework.stereotype.Component;

import BOLO.model.Bolo;
import BOLO.model.FieldInstance;

@Component
public class BoloPdfGenerationService {

    public String GetBoloPdfHeader(Bolo bolo){
        String result= "<table><tr><th><img height='150px'  src=\""+bolo.getAgency().getLogo().getFileDownloadUri()+"\" />"+
        "</th><th><span style=\"color:red;\"> "+
        bolo.getCategory().getName()+"// FOR OFFICIAL USE ONLY// LAW ENFORCEMENT SENSITIVE</span><br/>"+ "<span>"+
        bolo.getAgency().getName()+" Police Department</span><br/><span>"+bolo.getAgency().getAddress()+"</span><br/>" + "<span>"+
        bolo.getAgency().getCity()+", "+bolo.getAgency().getState()+", "+bolo.getAgency().getZipcode()+"</span><br/><span>"+
        bolo.getAgency().getPhone()+"</span></th><th><img  height='150px'  src=\""+bolo.getAgency().getShield().getFileDownloadUri()+"\" />"
        + " </th></tr></table><img  src=\""+bolo.getFeatured().getFileDownloadUri()+"\" />";
        return result;

    }

    public String GetBoloBody(Bolo bolo){
            String result ="<p><span>BOLO ID:</span>"+bolo.getId()+"<br />"+
            "<span>Updated On:</span>"+bolo.getUpdateOn()+"<br />"+
            "<span>Reported On:</span>"+bolo.getUpdateOn()+"<br />"+
            "<span>Posted By:</span>"+bolo.getUpdateOn()+"<br />";
            for (FieldInstance field : bolo.getFields()) {
                result+="<span>"+field.getName() +" : "+ field.getValue()+"<br/></span>";
            }
              
           result+="</p>";
           return result;
    }

    public String GetWarningForBody(){
        String response= "<h1 style=\"color:red;\">A BOLO has been issued! Details have been purposely hidden for security.</h1>"
        + "<h1 style=\"color:red;\">Please login to the BOLO database to view the full details of this BOLO.</h1>";
        return response;
    }
    public String GetBoloAsPDF(Bolo bolo,boolean includeBody){
        String result= "<html><body  style=\"text-align:center;\">";
        result+=GetBoloPdfHeader(bolo);
        result+=includeBody ? GetBoloBody(bolo):GetWarningForBody();
        result+="</body></html>";

        return result;
    }

}