Example #1
0
 public function setAttrContato($var)
 {
     $obj = json_decode(fixJSON($var));
     $this->email = $obj->email;
     $this->telCel = $obj->telCel;
     $this->telFixo = $obj->telFixo;
 }
Example #2
0
 public function getValue($fields, $table, $searchField, $search)
 {
     $conn = $this->connect(1);
     if (!is_array($fields)) {
         $fields = [$fields];
     }
     $bind = $f = $json = "";
     foreach ($fields as $a) {
         $comma = $fields[count($fields) - 1] != $a ? "," : "";
         $f .= "\${$a}{$comma}";
         $json .= count($fields) > 1 ? "'{$a}':'\${$a}'{$comma}" : "\${$a}";
         $bind .= "s";
     }
     if (count($fields) > 1) {
         $json = "{ {$json}}";
     }
     $query = "select " . str_replace("\$", "", $f) . " from {$table}";
     if ($searchField != "") {
         $query .= " where {$searchField}=?";
         $query = $conn->prepare($query);
         $query->bind_param("s", $search);
     } else {
         $query = $conn->prepare($query);
     }
     $query->execute();
     eval("\$query->bind_result({$f});");
     $query->fetch();
     eval("\$value=\"{$json}\";");
     $conn->close();
     $return = count($fields) == 1 ? $value : json_decode(fixJSON($value));
     return $return == "" ? 0 : $return;
 }
Example #3
0
 public function buscarDados()
 {
     if ($this->checkExistence("produto", "id", $this->id) === false) {
         return;
     }
     $values = $this->getValue(["custo", "valorVenda", "nome", "remessa", "descricao"], "produto", "id", $this->id);
     echo fixJSON("{'id':{$this->id},\n            'custo':{$values->custo},\n            'valorVenda':{$values->valorVenda},\n            'nome':'{$values->nome}',\n            'idRemessa':{$values->remessa},\n            'descricao':'{$values->descricao}'}");
 }
Example #4
0
 public function Estoque($var)
 {
     $obj = json_decode(fixJSON($var));
     $this->idProduto = $obj->idProduto;
     $this->qtdProd = $obj->qtdProd;
     if (isset($obj->dataSaida)) {
         $this->idFuncionario = $obj->idFuncionario;
         $this->dataSaida = $obj->dataSaida;
     }
 }
Example #5
0
 function __construct($var)
 {
     $this->connect();
     $obj = json_decode(fixJSON($var));
     if (isset($obj->id)) {
         $this->id = $obj->id;
     }
     if (isset($obj->nome)) {
         $this->nome = $obj->nome;
         $this->cpf = $obj->cpf;
     }
 }
Example #6
0
 public function setAttrEndereco($var)
 {
     $obj = json_decode(fixJSON($var));
     $this->logradouro = $obj->logradouro;
     $this->log_nome = $obj->log_nome;
     $this->numero = $obj->numero;
     $this->complemento = $obj->complemento;
     $this->cep = $obj->cep;
     $this->bairro = $obj->bairro;
     $this->cidade = $obj->cidade;
     $this->estado = $obj->estado;
 }
Example #7
0
 public function getPeople()
 {
     $conn = $this->connect();
     $query = $conn->prepare("select * from people");
     $query->execute();
     $query->bind_result($colName, $colEmail, $colAge, $colId);
     $result = "{'people':[";
     while ($query->fetch()) {
         $result .= "{'name':'{$colName}','email':'{$colEmail}','age':'{$colAge}'},";
     }
     echo fixJSON(str_replace(",]}", "]}", $result . "]}"));
 }
Example #8
0
 public function mostrarDados()
 {
     $values = $this->getValue(["dataEntrega", "dataPagamento", "dataPedido"], "remessa", "id", $this->idRemessa);
     echo fixJSON("{'dataEntrega':'{$values->dataEntrega}','dataPagamento':'{$values->dataPagamento}','dataPedido':'{$values->dataPedido}'}");
 }
Example #9
0
define('CLIENT_PATH', dirname(__FILE__));
include "include.common.php";
$modulePath = getSessionObject("modulePath");
if (!defined('MODULE_PATH')) {
    define('MODULE_PATH', $modulePath);
}
include "server.includes.inc.php";
if (empty($user)) {
    $ret['status'] = "ERROR";
    echo json_encode($ret);
    exit;
}
$_REQUEST['sm'] = fixJSON($_REQUEST['sm']);
$_REQUEST['cl'] = fixJSON($_REQUEST['cl']);
$_REQUEST['ft'] = fixJSON($_REQUEST['ft']);
$columns = json_decode($_REQUEST['cl'], true);
$columns[] = "id";
$table = $_REQUEST['t'];
$obj = new $table();
$sLimit = "";
if (isset($_REQUEST['iDisplayStart']) && $_REQUEST['iDisplayLength'] != '-1') {
    $sLimit = " LIMIT " . intval($_REQUEST['iDisplayStart']) . ", " . intval($_REQUEST['iDisplayLength']);
}
$isSubOrdinates = false;
if (isset($_REQUEST['type']) && ($_REQUEST['type'] = "sub")) {
    $isSubOrdinates = true;
}
$skipEmployeeRestriction = false;
if (isset($_REQUEST['skip']) && ($_REQUEST['type'] = "1")) {
    $skipEmployeeRestriction = true;
function AJAXReturn($type, $msg)
{
    echo fixJSON("{'type':'{$type}','msg':'" . str_replace('"', "'", $msg) . "'}");
}
function AJAXReturn($var)
{
    $obj = json_decode(fixJSON($var));
    echo '{"type":"' . $obj->type . '","msg":"' . $obj->msg . '"}';
}
Example #12
0
 } else {
     if ($action == 'getFieldValues') {
         $ret['data'] = $baseService->getFieldValues($_REQUEST['t'], $_REQUEST['key'], $_REQUEST['value']);
         if ($ret['data'] != null) {
             $ret['status'] = "SUCCESS";
         } else {
             $ret['status'] = "ERROR";
         }
     } else {
         if ($action == 'setAdminEmp') {
             $baseService->setCurrentAdminEmployee($_REQUEST['empid']);
             $ret['status'] = "SUCCESS";
         } else {
             if ($action == 'ca') {
                 if (isset($_REQUEST['req'])) {
                     $_REQUEST['req'] = fixJSON($_REQUEST['req']);
                 }
                 $mod = $_REQUEST['mod'];
                 $modPath = explode("=", $mod);
                 $moduleCapsName = ucfirst($modPath[1]);
                 $subAction = $_REQUEST['sa'];
                 $apiFile = APP_BASE_PATH . $modPath[0] . "/" . $modPath[1] . "/api/" . $moduleCapsName . "ActionManager.php";
                 error_log("Api File:" . $apiFile);
                 $emailSenderFile = APP_BASE_PATH . $modPath[0] . "/" . $modPath[1] . "/api/" . $moduleCapsName . "EmailSender.php";
                 if (file_exists($apiFile)) {
                     include $apiFile;
                     if (file_exists($emailSenderFile)) {
                         include $emailSenderFile;
                     }
                     $cls = $moduleCapsName . "ActionManager";
                     $apiClass = new $cls();
Example #13
0
 public function excluir($target)
 {
     $targetSC = str_replace("a", "á", $target);
     $del = $this->conn->prepare("delete from {$target} where id=?");
     $del->bind_param("d", $id);
     $errors = [];
     foreach ($this->id as $id) {
         $values = $this->getValue(["contato", "endereco"], $target, "id", $id);
         $this->idContato = $values->contato;
         $this->idEndereco = $values->endereco;
         if (gettype($delE = $this->excluirEndereco()) == "string") {
             $er = json_decode(fixJSON($delE));
             $er = [$er->errno, $er->error];
         } elseif (gettype($delC = $this->excluirContato()) == "string") {
             $er = json_decode(fixJSON($delC));
             $er = [$er->errno, $er->error];
         } elseif (!$del->execute()) {
             $er = [$del->errno, $del->error];
         }
         // Erro 2006
         if (isset($er)) {
             array_push($errors, [$this->getValue("nome", $target, "id", $id), $er]);
         }
     }
     $es = ($s = (count($errors) != 0 ? count($errors) : count($this->id)) > 1 ? "s" : "") == "s" ? $target == "fornecedor" ? "es" : "s" : "";
     if (count($errors) != 0) {
         $errorList = "";
         foreach ($errors as $error) {
             $errorList .= "<p>{$error['0']}: erro " . $error[1][0] . " (" . $error[1][1] . ");</p>";
         }
         $success = count($this->id) - count($errors);
         AJAXReturn("error", ($success == 0 ? "Nenhum" : $success) . " {$targetSC}{$es} excluído{$s}, com o{$s} erro{$s} a seguir{$errorList}");
     } else {
         AJAXReturn("success", "Exclusão de " . count($this->id) . " {$targetSC}{$es} finalizada com sucesso!");
     }
 }