Example #1
0
<?php

include_once '../../includes.sys/ini.php';
include_once INTERNAL_ROOT_PORTAL . '/includes.sys/metodos.php';
include_once INTERNAL_ROOT_PORTAL . '/medicao/DAO/TrimestreEmpresaDAO.php';
include_once INTERNAL_ROOT_PORTAL . '/medicao/TrimestreEmpresa.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once INTERNAL_ROOT_PORTAL . '/head.php';
$empresa = new TrimestreEmpresa();
$DAO = new TrimestreEmpresaDao();
//Verifica se a opcao de salvar foi iniciada
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'editar') {
    $empresa->salvar($_FILES, limpaTexto($_GET['id']));
} else {
    $empresa->setId(limpaTexto($_GET['id']));
    $resultado = $DAO->Listar("SELECT A.*, B.nome FROM " . MYSQL_BASE_MEDICAO_TRIMESTRE_EMPRESA . " A \r\n\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_EMPRESAS . " B ON A.id_empresa = B.id\r\n\t\t\t\t\t\t\t\tWHERE A.status = 'S' AND A.id = " . $empresa->getId());
    if ($resultado) {
        $empresa->getId();
        foreach ($resultado as $item) {
            $empresa->setIdEmpresa($item['id_empresa']);
            $empresa->setEmpresa($item['nome']);
        }
    } else {
    }
}
?>
<!-- topbar ends -->
<div class="container-fluid">
	<div class="row-fluid">

		<!-- left menu starts -->
Example #2
0
 function salvar($file, $id)
 {
     $DAO = new TrimestreEmpresaDao();
     if ($file['nf']['size'] != 0) {
         $uploadDir = '../../arquivos/medicao/trimestre/';
         $name = sha1(date("d-m-Y H:i:s") . '1');
         $uploadFile = $uploadDir . $name;
         $extension = pathinfo($file['nf']['name'], PATHINFO_EXTENSION);
         $uploadFile = $uploadFile . '.' . $extension;
         $name = $name . '.' . $extension;
         //Fazer o Upload do arquivo
         if (move_uploaded_file($file['nf']['tmp_name'], $uploadFile)) {
             $nf = $name;
         } else {
             echo $file['nf']['error'];
         }
     } else {
         $nf = "";
     }
     if ($file['recibo']['size'] != 0) {
         $uploadDir = '../../arquivos/medicao/trimestre/';
         $name = sha1(date("d-m-Y H:i:s") . '2');
         $uploadFile = $uploadDir . $name;
         $extension = pathinfo($file['recibo']['name'], PATHINFO_EXTENSION);
         $uploadFile = $uploadFile . '.' . $extension;
         $name = $name . '.' . $extension;
         //Fazer o Upload do arquivo
         if (move_uploaded_file($file['recibo']['tmp_name'], $uploadFile)) {
             $recibo = $name;
         } else {
             echo $file['recibo']['error'];
         }
     } else {
         $recibo = "";
     }
     if ($file['darf']['size'] != 0) {
         $uploadDir = '../../arquivos/medicao/trimestre/';
         $name = sha1(date("d-m-Y H:i:s") . '3');
         $uploadFile = $uploadDir . $name;
         $extension = pathinfo($file['darf']['name'], PATHINFO_EXTENSION);
         $uploadFile = $uploadFile . '.' . $extension;
         $name = $name . '.' . $extension;
         //Fazer o Upload do arquivo
         if (move_uploaded_file($file['darf']['tmp_name'], $uploadFile)) {
             $darf = $name;
         } else {
             echo $file['darf']['error'];
         }
     } else {
         $nf = true;
     }
     if ($file['sefa']['size'] != 0) {
         $uploadDir = '../../arquivos/medicao/trimestre/';
         $name = sha1(date("d-m-Y H:i:s") . '4');
         $uploadFile = $uploadDir . $name;
         $extension = pathinfo($file['sefa']['name'], PATHINFO_EXTENSION);
         $uploadFile = $uploadFile . '.' . $extension;
         $name = $name . '.' . $extension;
         //Fazer o Upload do arquivo
         if (move_uploaded_file($file['sefa']['tmp_name'], $uploadFile)) {
             $sefa = $name;
         } else {
             echo $file['sefa']['error'];
         }
     } else {
         $sefa = "";
     }
     if ($file['divida_ativa']['size'] != 0) {
         $uploadDir = '../../arquivos/medicao/trimestre/';
         $name = sha1(date("d-m-Y H:i:s") . '5');
         $uploadFile = $uploadDir . $name;
         $extension = pathinfo($file['divida_ativa']['name'], PATHINFO_EXTENSION);
         $uploadFile = $uploadFile . '.' . $extension;
         $name = $name . '.' . $extension;
         //Fazer o Upload do arquivo
         if (move_uploaded_file($file['divida_ativa']['tmp_name'], $uploadFile)) {
             $divida_ativa = $name;
         } else {
             echo $file['divida_ativa']['error'];
         }
     } else {
         $divida_ativa = true;
     }
     if ($file['inss']['size'] != 0) {
         $uploadDir = '../../arquivos/medicao/trimestre/';
         $name = sha1(date("d-m-Y H:i:s") . '6');
         $uploadFile = $uploadDir . $name;
         $extension = pathinfo($file['inss']['name'], PATHINFO_EXTENSION);
         $uploadFile = $uploadFile . '.' . $extension;
         $name = $name . '.' . $extension;
         //Fazer o Upload do arquivo
         if (move_uploaded_file($file['inss']['tmp_name'], $uploadFile)) {
             $inss = $name;
         } else {
             echo $file['inss']['error'];
         }
     } else {
         $inss = "";
     }
     if ($file['fgts']['size'] != 0) {
         $uploadDir = '../../arquivos/medicao/trimestre/';
         $name = sha1(date("d-m-Y H:i:s") . '7');
         $uploadFile = $uploadDir . $name;
         $extension = pathinfo($file['fgts']['name'], PATHINFO_EXTENSION);
         $uploadFile = $uploadFile . '.' . $extension;
         $name = $name . '.' . $extension;
         //Fazer o Upload do arquivo
         if (move_uploaded_file($file['fgts']['tmp_name'], $uploadFile)) {
             $fgts = $name;
         } else {
             echo $file['fgts']['error'];
         }
     } else {
         $fgts = "";
     }
     $resultado = $DAO->Listar("UPDATE " . MYSQL_BASE_MEDICAO_TRIMESTRE_EMPRESA . " \r\n\t\t\t\t\t\t\t\t\tSET nf='" . $nf . "', recibo='" . $recibo . "', darf='" . $darf . "', certidao_neg_sefa='" . $sefa . "', certidao_neg_receita='" . $divida_ativa . "', certidao_neg_inss='" . $inss . "', certidao_reg_fgts='" . $fgts . "'\r\n\t\t\t\t\t\t\t\t\tWHERE id=" . $id);
     if ($resultado == true) {
         echo '<script language= "JavaScript">alert("Registro alterado com sucesso");</script>';
         echo '<script language= "JavaScript">location.href="index.php";</script>';
     } else {
         print_r($retorno);
     }
 }