<?php

/*
 * PuzzleApp
 * Webemyos
 * Jérôme Oliva
 * GNU Licence
 */

namespace Apps\Crm\Entity;

use Core\Entity\Entity\Entity;
use Core\Entity\Entity\Property;
use Core\Entity\Entity\EntityProperty;

use Apps\Crm\Entity\CrmProspectCalledBack;


class CrmProspect extends Entity {

    //Constructeur
    function __construct($core) {
        //Version
        $this->Version = "2.0.0.0";

        //Nom de la table 
        $this->Core = $core;
        $this->TableName = "CrmProspect";
        $this->Alias = "CrmProspect";

        $this->FirstName = new Property("FirstName", "FirstName", TEXTAREA, false, $this->Alias);
        $this->LastName = new Property("LastName", "LastName", TEXTAREA, false, $this->Alias);
        $this->Email = new Property("Email", "Email", TEXTAREA, false, $this->Alias);
        $this->Phone = new Property("Phone", "Phone", TEXTAREA, false, $this->Alias);
        $this->Adress = new Property("Adress", "Adress", TEXTAREA, false, $this->Alias);
        $this->DateMeet = new Property("DateMeet", "DateMeet", DATEBOX, false, $this->Alias);
        $this->PlaceMeet = new Property("PlaceMeet", "PlaceMeet", TEXTAREA, false, $this->Alias);
        $this->Type = new Property("Type", "Type", TEXTAREA, false, $this->Alias);
        $this->Description = new Property("Description", "Description", TEXTAREA, false, $this->Alias);

        //Creation de l entité 
        $this->Create();
    }
    
    /***
     * 
     */
    function GetCalledBack(){
     
        $calledBack =  new CrmProspectCalledBack($this->Core);
        
        $called =  $calledBack->Find("ProspectId = " . $this->IdEntite);
        
        if(count($called) > 0){
            
            $callebBack = $called[0];
            
            return $callebBack->DateCall->Value . " " . $callebBack->HourCall->Value;
            
        } 
        return "";
        
    }
    
}

?>