src/Entity/Client.php line 100

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  4. use Symfony\Component\Security\Core\Security;
  5. use Smt\CoreBundle\Service\SmtApi;
  6. /**
  7.  * Corporate Client
  8.  *
  9.  * @author jairo.erazo
  10.  */
  11. class Client{
  12.   private $Lo_SmtApi;
  13.   private $Lo_Security;
  14.   private $o_Session;
  15.   public function __construct(SmtApi $Ao_SmtApiSecurity $securitySessionInterface $session){
  16.     $this->Lo_SmtApi $Ao_SmtApi;
  17.     $this->Lo_Security $security;
  18.     $this->o_Session $session;
  19.   }
  20.     /*
  21.      *  Die Funktion speichert die Daten des Kundes im SMT School
  22.      */
  23.     public function setClient($Ao_Data) {
  24.       $Ls_EndPoint 'ClientsTool/setClient';
  25.       $La_Data['Form'] = $Ao_Data;
  26.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  27.       $Ls_Data json_encode($La_Data);
  28.       $Ls_Answer =  $this->Lo_SmtApi->callApi('POST'$Ls_EndPoint$Ls_Datatrue$Lo_Header);
  29.       return json_decode($Ls_Answer);
  30.     }
  31.     /*
  32.      *  Die Funktion schikt die Daten des Kundes
  33.      */
  34.     public function getClient($Ai_ClientId$Ai_AddressRoleID) {
  35.       $Ls_EndPoint 'ClientsTool/getClient';
  36.       $La_Data = [
  37.         "i_ClientId" => $Ai_ClientId,
  38.         "i_AddressRoleID" => $Ai_AddressRoleID
  39.       ];
  40.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  41.       $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_EndPoint$La_Datatrue$Lo_Header);
  42.       return json_decode($Ls_Answer);
  43.     }
  44.     /*
  45.      *  Die Funktion schikt die ClientID, die zu einem User gehört
  46.      */
  47.     public function getClientIDFromAgent($Ai_AgentPersonID) {
  48.       $Ls_EndPoint 'ClientsTool/getClientIDFromAgent';
  49.       $La_Data = [
  50.         "Li_PersonID" => $Ai_AgentPersonID
  51.       ];
  52.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  53.       $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_EndPoint$La_Datatrue$Lo_Header);
  54.       $Lo_Answer json_decode($Ls_Answer);
  55.       $Lo_ClientID json_encode($Lo_Answer->Result);
  56.       return $Lo_ClientID;
  57.     }
  58.     /*
  59.      *  Die Funktion schikt die Client IDs, die zu einem User gehört
  60.      */
  61.     public function getClientsPersonIDFromAgent($Ai_AgentPersonID) {
  62.       $Li_AgentId $Ai_AgentPersonID;
  63.       if ($Ai_AgentPersonID == 'user') {
  64.         $Lo_User $this->Lo_Security->getUser();
  65.         $Li_AgentId $Lo_User->getPersonID();
  66.       } // if
  67.       $Ls_EndPoint 'ClientsTool/getClientsIDFromAgent';
  68.       $La_Data = [
  69.         "Li_PersonID" => $Li_AgentId
  70.       ];
  71.       
  72.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  73.       $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_EndPoint$La_Datatrue$Lo_Header);
  74.       $Lo_Answer json_decode($Ls_Answer);
  75.       
  76.       return $Lo_Answer->Result;
  77.     }
  78.     /*
  79.      *  Die Funktion schikt die Client-Liste, die zu einem User gehört
  80.      */
  81.     public function getAgentCompanies($Ai_AgentPersonID$Ai_AddressRoleID) {
  82.       $Li_AgentId $Ai_AgentPersonID;
  83.       if ($Ai_AgentPersonID == 'user') {
  84.         $Lo_User $this->Lo_Security->getUser();
  85.         $Li_AgentId $Lo_User->getPersonID();
  86.       } // if
  87.       $Ls_EndPoint 'ClientsTool/getCompaniesFromAgentPersonID';
  88.       $La_Data = [
  89.         "i_PersonID" => $Li_AgentId,
  90.         "i_AddressRoleID" => $Ai_AddressRoleID
  91.       ];
  92.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  93.       $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_EndPoint$La_Datatrue$Lo_Header);
  94.       return json_decode($Ls_Answer);
  95.     }
  96.     /*
  97.      *  Die Funktion schikt eine Liste der Kunden
  98.      */
  99.     public function searchClient($As_ClientName$Ai_AddressRoleID) {
  100.       $Ls_EndPoint 'SalesTool/searchClient';
  101.       $Lo_User $this->Lo_Security->getUser();
  102.       $Li_PersonID $Lo_User->getPersonID();
  103.       $La_WordsSearch explode(" "$As_ClientName);
  104.       $La_Data = [
  105.         "a_WordsSearch" => $La_WordsSearch,
  106.         "i_PersonID" => $Li_PersonID,
  107.         "i_AddressRoleID" => $Ai_AddressRoleID
  108.       ];
  109.       $Ls_Data json_encode($La_Data);
  110.       
  111.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  112.       $Ls_Answer $this->Lo_SmtApi->callApi('POST'$Ls_EndPoint$Ls_Datatrue$Lo_Header);
  113.       return json_decode($Ls_Answer);
  114.     }
  115.     /*
  116.      *  Die Funktion schikt eine Liste von gebuchte Kurse
  117.      */
  118.     public function getClientCourses($Ai_ClientId$As_CourseGroup$Ai_AddressRoleID) {
  119.       $Ls_ApiUrl 'ClientsTool/getClientCourses';
  120.       $Lo_User $this->Lo_Security->getUser();
  121.       $Li_PersonID $Lo_User->getPersonID();
  122.       $La_Data = [
  123.         "i_ClientID" => $Ai_ClientId,
  124.         "s_CourseGroup" => $As_CourseGroup,
  125.         "i_PersonID" => $Li_PersonID,
  126.         "i_AddressRoleID" => $Ai_AddressRoleID
  127.       ];
  128.       
  129.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  130.       $Ls_Answer =  $this->Lo_SmtApi->callApi('GET'$Ls_ApiUrl$La_Datatrue$Lo_Header);
  131.       return json_decode($Ls_Answer);
  132.     }
  133.     /*
  134.      *  Die Funktion schikt die Details von einem Kurs
  135.      */
  136.     public function getClientCourseDetails($Ai_CourseId$Ai_AddressRoleID) {
  137.       $Ls_ApiUrl 'ClientsTool/getClientCourseDetails';
  138.       $Lo_User $this->Lo_Security->getUser();
  139.       $Li_PersonID $Lo_User->getPersonID();
  140.       $La_Data = [
  141.         "i_CourseId" => $Ai_CourseId,
  142.         "i_PersonID" => $Li_PersonID,
  143.         "i_AddressRoleID" => $Ai_AddressRoleID
  144.       ];
  145.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  146.       $Ls_Answer =  $this->Lo_SmtApi->callApi('GET'$Ls_ApiUrl$La_Datatrue$Lo_Header);
  147.       return json_decode($Ls_Answer);
  148.     }
  149.   /*
  150.     *  Die Funktion schickt die Liste von Mitarbeiteranfragen
  151.     */
  152.   public function getEmployeeRequest($Ai_ClientId$Ai_AddressRoleID)
  153.   {
  154.     $Ls_ApiUrl 'ClientsTool/employeeRequest';
  155.     $Lo_User $this->Lo_Security->getUser();
  156.     $Li_PersonID $Lo_User->getPersonID();
  157.     $La_Data = [
  158.       "i_ClientId" => $Ai_ClientId,
  159.       "i_PersonID" => $Li_PersonID,
  160.       "i_AddressRoleID" => $Ai_AddressRoleID
  161.     ];
  162.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  163.     $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_ApiUrl$La_Datatrue$Lo_Header);
  164.     return json_decode($Ls_Answer);
  165.   }
  166.   /*
  167.   *  Die Funktion schickt die Liste von Mitarbeiteranfragen
  168.   */
  169.   public function getCourseRequest($Ai_ClientId$Ai_AddressRoleID)
  170.   {
  171.     $Ls_ApiUrl 'ClientsTool/courseRequests';
  172.     $Lo_User $this->Lo_Security->getUser();
  173.     $Li_PersonID $Lo_User->getPersonID();
  174.     $La_Data = [
  175.       "i_ClientId" => $Ai_ClientId,
  176.       "i_PersonID" => $Li_PersonID,
  177.       "i_AddressRoleID" => $Ai_AddressRoleID
  178.     ];
  179.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  180.     $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_ApiUrl$La_Datatrue$Lo_Header);
  181.     return json_decode($Ls_Answer);
  182.   }
  183.   /*
  184.   *  Die Funktion abbrecht die Kursangrafe 
  185.   */
  186.   public function cancelCourseRequest($Ao_RequestData) {
  187.     $Ls_EndPoint 'ClientsTool/cancelCourseRequest';
  188.     $La_Data['o_RequestData'] = $Ao_RequestData;
  189.     $Lo_User $this->Lo_Security->getUser();
  190.     $Li_PersonID $Lo_User->getPersonID();
  191.     $La_Data['i_PersonID'] = $Li_PersonID;
  192.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  193.     $Ls_Data json_encode($La_Data);
  194.     $Ls_Answer $this->Lo_SmtApi->callApi('POST'$Ls_EndPoint$Ls_Datatrue$Lo_Header);
  195.     return json_decode($Ls_Answer);
  196.   }
  197.   /*
  198.   *  Die Funktion bestätigt die Kursangrafe 
  199.   */
  200.   public function acceptCourseRequest($Ao_RequestData) {
  201.     $Ls_EndPoint 'ClientsTool/acceptCourseRequest';
  202.     $La_Data['o_RequestData'] = $Ao_RequestData;
  203.     $Lo_User $this->Lo_Security->getUser();
  204.     $Li_PersonID $Lo_User->getPersonID();
  205.     $La_Data['i_PersonID'] = $Li_PersonID;
  206.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  207.     $Ls_Data json_encode($La_Data);
  208.     $Ls_Answer $this->Lo_SmtApi->callApi('POST'$Ls_EndPoint$Ls_Datatrue$Lo_Header);
  209.     return json_decode($Ls_Answer);
  210.   }
  211.   /*
  212.    *  Die Funktion addiert eine Firma zu einem Kurs
  213.    */
  214.   public function bookAsCompany($Ao_BookingData) {
  215.     $Ls_EndPoint 'ClientsTool/bookAsCompany';
  216.     $Lo_User $this->Lo_Security->getUser();
  217.     $La_Data['o_BookingData'] = $Ao_BookingData;
  218.     $La_Data['i_PersonID'] = $Lo_User->getPersonID();
  219.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  220.     $Ls_Data json_encode($La_Data);
  221.     $Ls_Answer =  $this->Lo_SmtApi->callApi('POST'$Ls_EndPoint$Ls_Datatrue$Lo_Header);
  222.     return json_decode($Ls_Answer);
  223.   }
  224.   /*
  225.   *  Die Funktion schickt die AgentID einer Firma
  226.   */
  227.   public function getAgentIDFromClient($Ai_ClientId)
  228.   {
  229.     $Ls_ApiUrl 'ClientsTool/getAgentIDFromClient';
  230.     $Lo_User $this->Lo_Security->getUser();
  231.     $Li_PersonID $Lo_User->getPersonID();
  232.     $La_Data = [
  233.       "i_ClientId" => $Ai_ClientId,
  234.       "i_PersonID" => $Li_PersonID
  235.     ];
  236.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  237.     $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_ApiUrl$La_Datatrue$Lo_Header);
  238.     return json_decode($Ls_Answer);
  239.   }
  240.   /*
  241.      *  Die Funktion listClientCourseParticipants schickt die Liste von Participants eines Kurs einer Firma
  242.      */
  243.     public function listClientCourseParticipants($Ai_CourseId$Ai_ClientID$Ai_AddressRoleID)
  244.     {
  245.       $Ls_ApiUrl 'ClientsTool/clientCourseParticipants';
  246.       $Lo_User $this->Lo_Security->getUser();
  247.       $Li_PersonID $Lo_User->getPersonID();
  248.       $La_Data = [
  249.         "i_CourseID" => $Ai_CourseId,
  250.         "i_PersonID" => $Li_PersonID,
  251.         "i_ClientID" => intval($Ai_ClientID),
  252.         "i_AddressRoleID" => $Ai_AddressRoleID
  253.       ];
  254.       $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  255.       $Ls_Answer $this->Lo_SmtApi->callApi('GET'$Ls_ApiUrl$La_Datatrue$Lo_Header);
  256.       return json_decode($Ls_Answer);
  257.     }
  258.   
  259.   /*
  260.   *  Die Funktion hinzufügt einen Mitarbeiter 
  261.   */
  262.   public function addEmployee($Ao_RequestData) {
  263.     $Ls_EndPoint 'ClientsTool/addEmployee';
  264.     $La_Data['o_RequestData'] = $Ao_RequestData;
  265.     $Lo_User $this->Lo_Security->getUser();
  266.     $Li_PersonID $Lo_User->getPersonID();
  267.     $La_Data['i_PersonID'] = $Li_PersonID;
  268.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  269.     $Ls_Data json_encode($La_Data);
  270.     $Ls_Answer $this->Lo_SmtApi->callApi('POST'$Ls_EndPoint$Ls_Datatrue$Lo_Header);
  271.     return json_decode($Ls_Answer);
  272.   }
  273.   /*
  274.   *  Die Funktion löscht einen Mitarbeiter 
  275.   */
  276.   public function removeEmployee($Ao_RequestData) {
  277.     $Ls_EndPoint 'ClientsTool/removeEmployee';
  278.     $La_Data['o_RequestData'] = $Ao_RequestData;
  279.     $Lo_User $this->Lo_Security->getUser();
  280.     $Li_PersonID $Lo_User->getPersonID();
  281.     $La_Data['i_PersonID'] = $Li_PersonID;
  282.     $Lo_Header 'Cookie: ' $this->o_Session->get('core/a_Person/LoginHeaders/Set-Cookie');
  283.     $Ls_Data json_encode($La_Data);
  284.     $Ls_Answer $this->Lo_SmtApi->callApi('POST'$Ls_EndPoint$Ls_Datatrue$Lo_Header);
  285.     return json_decode($Ls_Answer);
  286.   }
  287. }