├── Banco de dados
└── db_mixroupas.sql
├── CSS
├── IMGS
│ ├── contato.png
│ ├── mix-roupas.png
│ └── pug.png
└── style.css
├── Controller
├── CategoriaProdutoController.php
├── FuncionarioController.php
├── PessoaController.php
└── ProdutoController.php
├── DAO
├── CategoriaProdutoDAO.php
├── FuncionarioDAO.php
├── MySQL.php
├── PessoaDAO.php
└── ProdutoDAO.php
├── Model
├── CategoriaProdutoModel.php
├── FuncionarioModel.php
├── PessoaModel.php
└── ProdutoModel.php
├── View
└── modules
│ ├── CategoriaProduto
│ ├── CategoriaProduto.php
│ └── CategoriaProdutoListar.php
│ ├── Funcionario
│ ├── FormFuncionario.php
│ └── ListaFuncionario.php
│ ├── Home
│ └── index.php
│ ├── Pessoa
│ ├── FormPessoa.php
│ └── ListaPessoas.php
│ └── Produto
│ ├── FormProduto.php
│ └── ProdutoListar.php
└── index.php
/Banco de dados/db_mixroupas.sql:
--------------------------------------------------------------------------------
1 | create database db_sistema;
2 |
3 | use db_sistema;
4 |
5 | create table pessoa(
6 | id int auto_increment,
7 | nome varchar(255) not null,
8 | rg varchar(45) not null,
9 | cpf char(11) not null,
10 | data_nascimento date not null,
11 | email varchar(255),
12 | telefone varchar(11),
13 | endereco varchar(255) not null,
14 | primary key(id)
15 | );
16 |
17 | create table categoria_produto(
18 | id int auto_increment,
19 | descricao varchar(150) not null,
20 | primary key(id)
21 | );
22 |
23 | create table produto(
24 | id int auto_increment,
25 | nome varchar(250) not NULL,
26 | preco double not null,
27 | descricao text not null,
28 | id_categoria_produto int,
29 | primary key(id),
30 | foreign key(id_categoria_produto) references categoria_produto(id)
31 | );
32 |
33 | CREATE TABLE funcionario (
34 | id int auto_increment,
35 | nome varchar(255) NOT NULL,
36 | sexo varchar(10) NOT NULL,
37 | rg varchar(45) NOT NULL,
38 | cpf char(11) NOT NULL,
39 | data_nascimento date NOT NULL,
40 | PRIMARY KEY(id)
41 | );
--------------------------------------------------------------------------------
/CSS/IMGS/contato.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fanizzi/ProjetoMVC/9ec816ac7e0d45588304c647afc8f254c40c496f/CSS/IMGS/contato.png
--------------------------------------------------------------------------------
/CSS/IMGS/mix-roupas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fanizzi/ProjetoMVC/9ec816ac7e0d45588304c647afc8f254c40c496f/CSS/IMGS/mix-roupas.png
--------------------------------------------------------------------------------
/CSS/IMGS/pug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fanizzi/ProjetoMVC/9ec816ac7e0d45588304c647afc8f254c40c496f/CSS/IMGS/pug.png
--------------------------------------------------------------------------------
/CSS/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | header {
7 | background-color: #353535;
8 | color: #ffff;
9 | padding: 0 10px 0px;
10 | height: 8vh;
11 | }
12 |
13 | #nav img{
14 | float: left;
15 | width: 200px;
16 | height: 40px;
17 | background-color: #353535;
18 | position: relative;
19 | margin-top: 10px;
20 | margin-right: 150px;
21 | }
22 |
23 | #nav {
24 | text-align: center;
25 | background-color: #353535;
26 |
27 | }
28 |
29 | #nav li {
30 | float: right;
31 | margin: 10px;
32 | padding: 5px;
33 | list-style-type: none;
34 | background-color: #353535;
35 |
36 | }
37 |
38 | #nav ul li a{
39 | position: relative;
40 | color: #fff;
41 | background-color: #353535;
42 | text-transform: uppercase;
43 | font-family: 'Audiowide', cursive;
44 | text-decoration: none;
45 | padding: 16px 0 5px;
46 |
47 | }
48 |
49 | #nav ul li a:hover{
50 | color: rgb(1, 171, 238);
51 | transition: .9s;
52 | }
53 |
54 | #nav ul li a:after{
55 | content: '';
56 | position: absolute;
57 | left: 50%;
58 | bottom: 0;
59 | transform: translateX(-50%) scaleX(0);
60 | -webkit-transform: translateX(-50%) scaleX(0);
61 | -webkit-transform-origin: 50% 50%;
62 | transform-origin: 50% 50%;
63 | width: 100%;
64 | height: 2px;
65 | background-color: rgba(255, 255, 255, 0.9);
66 | -webkit-transition: transform 250ms;
67 | transition: transform 250ms;
68 | }
69 |
70 | #nav ul li a:hover:after {
71 | -webkit-transform: translateX(-50%) scaleX(1);
72 | transform: translateX(-50%) scaleX(1);
73 | }
74 |
75 | footer {
76 | padding: 30px 0;
77 | background-color: #353535;
78 | color: #fff;
79 | text-align: center;
80 | font-family: "Robot", sans-serif;
81 | }
82 |
83 | footer h2{
84 | background-color: #353535;
85 | text-align: center;
86 | position: relative;
87 | }
88 |
89 | footer img {
90 | height: 90px;
91 | width: 90px;
92 | margin: 30px 0;
93 | text-align: center;
94 | background-color: #353535;
95 | position: relative;
96 |
97 | }
98 |
99 | footer p {
100 | margin-top: 25px;
101 | text-align: center;
102 | background-color: #353535;
103 | font-family: "Robot", sans-serif;
104 | position: relative;
105 | }
106 |
107 | .by {
108 | margin-top: 25px;
109 | text-align: center;
110 | background-color: #353535;
111 | font-family: "Robot", sans-serif;
112 | position: relative;
113 |
114 | }
115 |
116 | footer form {
117 | width: 400px;
118 | margin-left: auto;
119 | margin-right: auto;
120 | background-color: #353535;
121 | }
122 |
123 | footer input, footer textarea {
124 | border: none;
125 | padding: 15px;
126 | box-sizing: border-box;
127 | margin-bottom: 20px;
128 | width: 100%;
129 | display: block;
130 | background-color: #ffffff;
131 | font-family: "Robot", sans-serif;
132 | }
133 |
134 | .dropdown a {
135 | background-color: #4CAF50;
136 | color: white;
137 | padding: 16px;
138 | font-size: 16px;
139 | border: none;
140 | cursor: pointer;
141 | }
142 |
143 | .dropdown {
144 | position: relative;
145 | display: inline-block;
146 | }
147 |
148 | .dropdown-content {
149 | display: none;
150 | position: absolute;
151 | background-color: #f9f9f9;
152 | min-width: 160px;
153 | box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
154 | z-index: 1;
155 | }
156 |
157 | .dropdown-content a {
158 | color: black;
159 | padding: 12px 16px;
160 | text-decoration: none;
161 | display: block;
162 | }
163 |
164 | .dropdown-content a:hover {background-color: #f1f1f1}
165 |
166 | .dropdown:hover .dropdown-content {
167 | display: block;
168 | }
169 |
170 | .dropdown:hover .dropbtn {
171 | background-color: #3e8e41;
172 | }
173 |
174 |
175 |
--------------------------------------------------------------------------------
/Controller/CategoriaProdutoController.php:
--------------------------------------------------------------------------------
1 | getAllRows();
13 |
14 | include 'View/modules/CategoriaProduto/CategoriaProdutoListar.php';
15 | }
16 |
17 | ## Devolvendo uma View com um formulário para o usuário.
18 | public static function form()
19 | {
20 | include 'Model/CategoriaProdutoModel.php';
21 |
22 | $model = new CategoriaProdutoModel();
23 |
24 | if(isset($_GET['id']))
25 | $model = $model->getById( (int) $_GET['id']);
26 |
27 | include 'View/modules/CategoriaProduto/CategoriaProduto.php';
28 | }
29 |
30 | ## Salvando os arquivos do formulário na Model para enviar para o banco de dados.
31 | public static function save()
32 | {
33 | include 'Model/CategoriaProdutoModel.php';
34 |
35 | $categoriaProduto = new CategoriaProdutoModel();
36 |
37 | $categoriaProduto->id = $_POST['id'];
38 | $categoriaProduto->descricao = $_POST['descricao'];
39 | $categoriaProduto->save();
40 |
41 | header("Location: /categoria_produto");
42 | }
43 |
44 | public static function delete()
45 | {
46 | include 'Model/CategoriaProdutoModel.php';
47 |
48 | $model = new CategoriaProdutoModel();
49 | $model->delete( (int) $_GET['id']);
50 |
51 | header("Location: /categoria_produto");
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/Controller/FuncionarioController.php:
--------------------------------------------------------------------------------
1 | getAllRows();
12 |
13 | include 'View/modules/Funcionario/ListaFuncionario.php';
14 | }
15 |
16 | public static function form()
17 | {
18 | include 'Model/FuncionarioModel.php';
19 |
20 | $model = new FuncionarioModel();
21 |
22 | if(isset($_GET['id']))
23 | $model = $model->getById( (int) $_GET['id']);
24 |
25 | include 'View/modules/Funcionario/FormFuncionario.php';
26 | }
27 |
28 | public static function save()
29 | {
30 | include 'Model/FuncionarioModel.php';
31 |
32 | $funcionario = new FuncionarioModel();
33 |
34 | $funcionario->id = $_POST['id'];
35 | $funcionario->nome = $_POST['nome'];
36 | $funcionario->sexo = $_POST['sexo'];
37 | $funcionario->rg = $_POST['rg'];
38 | $funcionario->cpf = $_POST['cpf'];
39 | $funcionario->data_nascimento = $_POST['data_nascimento'];
40 |
41 | $funcionario->save();
42 |
43 | header("Location: /funcionario");
44 | }
45 |
46 | public static function delete()
47 | {
48 | include 'Model/FuncionarioModel.php';
49 |
50 | $model = new FuncionarioModel();
51 | $model->delete( (int) $_GET['id']);
52 |
53 | header("Location: /funcionario");
54 | }
55 | }
--------------------------------------------------------------------------------
/Controller/PessoaController.php:
--------------------------------------------------------------------------------
1 | getAllRows();
22 |
23 | include 'View/modules/Pessoa/ListaPessoas.php';
24 | }
25 |
26 |
27 | /**
28 | * Devolve uma View contendo um formulário para o usuário.
29 | */
30 | public static function form()
31 | {
32 | include 'Model/PessoaModel.php';
33 |
34 | $model = new PessoaModel();
35 |
36 | if(isset($_GET['id']))
37 | $model = $model->getById( (int) $_GET['id']);
38 |
39 | include 'View/modules/Pessoa/FormPessoa.php';
40 | }
41 |
42 |
43 | /**
44 | * Preenche um Model para que seja enviado ao banco de dados para salvar.
45 | */
46 | public static function save() {
47 |
48 | include 'Model/PessoaModel.php'; // inclusão do arquivo model.
49 |
50 | $pessoa = new PessoaModel(); // Instância do objeto a ser preenchido.
51 |
52 | // Abaixo cada propriedade do objeto sendo abastecida com os dados informados
53 | // pelo usuário no formulário (note o envio via POST)
54 | $pessoa->id = $_POST['id'];
55 | $pessoa->nome = $_POST['nome'];
56 | $pessoa->rg = $_POST['rg'];
57 | $pessoa->cpf = $_POST['cpf'];
58 | $pessoa->data_nascimento = $_POST['data_nascimento'];
59 | $pessoa->email = $_POST['email'];
60 | $pessoa->telefone = $_POST['telefone'];
61 | $pessoa->endereco = $_POST['endereco'];
62 |
63 | $pessoa->save(); // chamando o método save da model.
64 |
65 | header("Location: /pessoa"); // redirecionando o usuário para outra rota.
66 | }
67 |
68 | public static function delete()
69 | {
70 | include 'Model/PessoaModel.php';
71 |
72 | $model = new PessoaModel();
73 | $model->delete( (int) $_GET['id'] );
74 |
75 | header("Location: /pessoa");
76 | }
77 | }
--------------------------------------------------------------------------------
/Controller/ProdutoController.php:
--------------------------------------------------------------------------------
1 | getAllCategorias();
12 | $model->getAllRows();
13 |
14 | include 'View/modules/Produto/ProdutoListar.php';
15 | }
16 |
17 | public static function form()
18 | {
19 | include 'Model/ProdutoModel.php';
20 |
21 | $model = new ProdutoModel();
22 |
23 | if(isset($_GET['id']))
24 | $model = $model->getById( (int) $_GET['id'] );
25 |
26 | $model1 = new ProdutoModel();
27 | $model1->getAllCategorias();
28 |
29 | include 'View/modules/Produto/FormProduto.php';
30 | }
31 |
32 | public static function save()
33 | {
34 |
35 | include 'Model/ProdutoModel.php';
36 |
37 | $produto = new ProdutoModel();
38 |
39 | $produto->id = $_POST['id'];
40 | $produto->nome = $_POST['nome'];
41 | $produto->preco = $_POST['preco'];
42 | $produto->descricao = $_POST['descricao'];
43 | $produto->id_categoria_produto = $_POST['id_categoria_produto'];
44 |
45 | $produto->save();
46 |
47 | header("Location: /produto");
48 | }
49 |
50 | public static function delete()
51 | {
52 | include 'Model/ProdutoModel.php';
53 |
54 | $model = new ProdutoModel;
55 | $model->delete( (int) $_GET['id']);
56 |
57 | header("Location: /produto");
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/DAO/CategoriaProdutoDAO.php:
--------------------------------------------------------------------------------
1 | conexao = new MySQL();
11 | }
12 |
13 | public function insert(CategoriaProdutoModel $model)
14 | {
15 | $sql = "INSERT INTO categoria_produto
16 | (descricao)
17 | VALUES (?)";
18 |
19 | $stmt = $this->conexao->prepare($sql);
20 | $stmt->bindValue(1, $model->descricao);
21 | $stmt->execute();
22 | }
23 |
24 | public function select()
25 | {
26 | $sql = 'SELECT * FROM categoria_produto';
27 |
28 | $stmt = $this->conexao->prepare($sql);
29 | $stmt->execute();
30 |
31 | return $stmt->fetchAll(PDO::FETCH_CLASS);
32 | }
33 |
34 | public function selectById(int $id)
35 | {
36 | include_once 'Model/CategoriaProdutoModel.php';
37 |
38 | $sql = 'SELECT * FROM categoria_produto WHERE id = ?';
39 |
40 | $stmt = $this->conexao->prepare($sql);
41 | $stmt->bindValue(1, $id);
42 | $stmt->execute();
43 |
44 | return $stmt->fetchObject("CategoriaProdutoModel");
45 | }
46 |
47 | public function delete(int $id)
48 | {
49 | $sql = 'DELETE FROM categoria_produto WHERE id = ?';
50 |
51 | $stmt = $this->conexao->prepare($sql);
52 | $stmt->bindValue(1, $id);
53 | $stmt->execute();
54 | }
55 |
56 | public function update(CategoriaProdutoModel $model)
57 | {
58 | $sql = 'UPDATE categoria_produto SET descricao=? WHERE id = ?';
59 |
60 | $stmt = $this->conexao->prepare($sql);
61 | $stmt->bindValue(1, $model->descricao);
62 | $stmt->bindValue(2, $model->id);
63 | $stmt->execute();
64 | }
65 | }
--------------------------------------------------------------------------------
/DAO/FuncionarioDAO.php:
--------------------------------------------------------------------------------
1 | conexao = new MySQL();
11 |
12 | }
13 |
14 | public function insert(FuncionarioModel $model)
15 | {
16 | $sql = 'INSERT INTO funcionario (nome, sexo, rg, cpf, data_nascimento)
17 | VALUES (?, ?, ?, ?, ?)';
18 |
19 | $stmt = $this->conexao->prepare($sql);
20 |
21 | $stmt->bindValue(1, $model->nome);
22 | $stmt->bindValue(2, $model->sexo);
23 | $stmt->bindValue(3, $model->rg);
24 | $stmt->bindValue(4, $model->cpf);
25 | $stmt->bindValue(5, $model->data_nascimento);
26 |
27 | $stmt->execute();
28 | }
29 |
30 | public function select()
31 | {
32 | $sql = 'SELECT * FROM funcionario';
33 |
34 | $stmt = $this->conexao->prepare($sql);
35 | $stmt->execute();
36 |
37 | return $stmt->fetchAll(PDO::FETCH_CLASS);
38 | }
39 |
40 | public function selectById(int $id)
41 | {
42 | include_once 'Model/FuncionarioModel.php';
43 |
44 | $sql = 'SELECT * FROM funcionario WHERE id = ?';
45 |
46 | $stmt = $this->conexao->prepare($sql);
47 | $stmt->bindValue(1, $id);
48 | $stmt->execute();
49 |
50 | return $stmt->fetchObject("FuncionarioModel");
51 | }
52 |
53 | public function delete(int $id)
54 | {
55 | $sql = 'DELETE FROM funcionario WHERE id = ?';
56 |
57 | $stmt = $this->conexao->prepare($sql);
58 | $stmt->bindValue(1, $id);
59 | $stmt->execute();
60 | }
61 |
62 | public function update(FuncionarioModel $model)
63 | {
64 | $sql = 'UPDATE funcionario SET nome=?, sexo=?, rg=?, cpf=?, data_nascimento=? WHERE id = ?';
65 |
66 | $stmt = $this->conexao->prepare($sql);
67 | $stmt->bindValue(1, $model->nome);
68 | $stmt->bindValue(2, $model->sexo);
69 | $stmt->bindValue(3, $model->rg);
70 | $stmt->bindValue(4, $model->cpf);
71 | $stmt->bindValue(5, $model->data_nascimento);
72 | $stmt->bindValue(6, $model->id);
73 | $stmt->execute();
74 | }
75 | }
--------------------------------------------------------------------------------
/DAO/MySQL.php:
--------------------------------------------------------------------------------
1 | dsn, $this->user, $this->pass);
12 | }
13 | }
--------------------------------------------------------------------------------
/DAO/PessoaDAO.php:
--------------------------------------------------------------------------------
1 | conexao = new MySQL();
11 | }
12 |
13 |
14 | public function insert(PessoaModel $model)
15 | {
16 | $sql = 'INSERT INTO pessoa
17 | (nome, rg, cpf, data_nascimento, email, telefone, endereco)
18 | VALUES (?, ?, ?, ?, ?, ?, ?)';
19 |
20 | $stmt = $this->conexao->prepare($sql);
21 |
22 | $stmt->bindValue(1, $model->nome);
23 | $stmt->bindValue(2, $model->rg);
24 | $stmt->bindValue(3, $model->cpf);
25 | $stmt->bindValue(4, $model->data_nascimento);
26 | $stmt->bindValue(5, $model->email);
27 | $stmt->bindValue(6, $model->telefone);
28 | $stmt->bindValue(7, $model->endereco);
29 |
30 | $stmt->execute();
31 | }
32 |
33 | public function select()
34 | {
35 | $sql = 'SELECT * FROM pessoa';
36 |
37 | $stmt = $this->conexao->prepare($sql);
38 |
39 | $stmt->execute();
40 |
41 | return $stmt->fetchAll(PDO::FETCH_CLASS);
42 | }
43 |
44 | public function delete(int $id)
45 | {
46 | $sql = 'DELETE FROM pessoa WHERE id = ?';
47 |
48 | $stmt = $this->conexao->prepare($sql);
49 | $stmt->bindValue(1, $id);
50 | $stmt->execute();
51 | }
52 |
53 | public function update(PessoaModel $model)
54 | {
55 | $sql = 'UPDATE pessoa SET nome=?, rg=?, cpf=?, data_nascimento=?, email=?, telefone=?, endereco=? WHERE id = ?';
56 |
57 | $stmt = $this->conexao->prepare($sql);
58 | $stmt->bindValue(1, $model->nome);
59 | $stmt->bindValue(2, $model->rg);
60 | $stmt->bindValue(3, $model->cpf);
61 | $stmt->bindValue(4, $model->data_nascimento);
62 | $stmt->bindValue(5, $model->email);
63 | $stmt->bindValue(6, $model->telefone);
64 | $stmt->bindValue(7, $model->endereco);
65 | $stmt->bindValue(8, $model->id);
66 | $stmt->execute();
67 | }
68 |
69 | public function selectById(int $id)
70 | {
71 | include_once 'Model/PessoaModel.php';
72 |
73 | $sql = 'SELECT * FROM pessoa WHERE id = ?';
74 |
75 | $stmt = $this->conexao->prepare($sql);
76 | $stmt->bindValue(1, $id);
77 | $stmt->execute();
78 |
79 | return $stmt->fetchObject("PessoaModel");
80 | }
81 |
82 | }
--------------------------------------------------------------------------------
/DAO/ProdutoDAO.php:
--------------------------------------------------------------------------------
1 | conexao = new MySQL();
11 | }
12 |
13 | public function insert(ProdutoModel $model)
14 | {
15 | $sql = "INSERT INTO produto (nome, preco, descricao, id_categoria_produto)
16 | VALUES (?, ?, ?, ?)";
17 |
18 | $stmt = $this->conexao->prepare($sql);
19 |
20 | $stmt->bindValue(1, $model->nome);
21 | $stmt->bindValue(2, $model->preco);
22 | $stmt->bindValue(3, $model->descricao);
23 | $stmt->bindValue(4, $model->id_categoria_produto);
24 |
25 | $stmt->execute();
26 | }
27 |
28 | public function selectCategoria()
29 | {
30 | $sql = 'SELECT * FROM categoria_produto';
31 |
32 | $stmt = $this->conexao->prepare($sql);
33 | $stmt->execute();
34 |
35 | return $stmt->fetchAll(PDO::FETCH_CLASS);
36 | }
37 |
38 | public function select()
39 | {
40 | $sql = "SELECT * FROM produto";
41 |
42 | $stmt = $this->conexao->prepare($sql);
43 | $stmt->execute();
44 |
45 | return $stmt->fetchAll(PDO::FETCH_CLASS);
46 | }
47 |
48 | public function selectById(int $id)
49 | {
50 | include_once "Model/ProdutoModel.php";
51 |
52 | $sql = "SELECT * FROM produto WHERE id = ?";
53 |
54 | $stmt = $this->conexao->prepare($sql);
55 | $stmt->bindValue(1, $id);
56 | $stmt->execute();
57 |
58 | return $stmt->fetchObject("ProdutoModel");
59 | }
60 |
61 | public function delete(int $id)
62 | {
63 | $sql = 'DELETE FROM produto WHERE id = ?';
64 |
65 | $stmt = $this->conexao->prepare($sql);
66 | $stmt->bindValue(1, $id);
67 | $stmt->execute();
68 | }
69 |
70 | public function update(ProdutoModel $model)
71 | {
72 | $sql = 'UPDATE produto SET nome=?, preco=?, descricao=?, id_categoria_produto=? WHERE id = ?';
73 |
74 | $stmt = $this->conexao->prepare($sql);
75 | $stmt->bindValue(1, $model->nome);
76 | $stmt->bindValue(2, $model->preco);
77 | $stmt->bindValue(3, $model->descricao);
78 | $stmt->bindValue(4, $model->id_categoria_produto);
79 | $stmt->bindValue(5, $model->id);
80 | $stmt->execute();
81 | }
82 | }
--------------------------------------------------------------------------------
/Model/CategoriaProdutoModel.php:
--------------------------------------------------------------------------------
1 | id))
16 | {
17 | $dao->insert($this);
18 | }
19 | else
20 | {
21 | $dao->update($this);
22 | }
23 | }
24 |
25 | public function getAllRows()
26 | {
27 | include 'DAO/CategoriaProdutoDAO.php';
28 |
29 | $dao = new CategoriaProdutoDAO();
30 | $this->rows = $dao->select();
31 | }
32 |
33 | public function getById(int $id)
34 | {
35 | include 'DAO/CategoriaProdutoDAO.php';
36 |
37 | $dao = new CategoriaProdutoDAO();
38 |
39 | $obj = $dao->selectById($id);
40 |
41 | return ($obj) ? $obj : new CategoriaProdutoModel();
42 | }
43 |
44 | public function delete(int $id)
45 | {
46 | include 'DAO/CategoriaProdutoDAO.php';
47 |
48 | $dao = new CategoriaProdutoDAO();
49 | $dao->delete($id);
50 |
51 | header("Location: /categoria_produto");
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/Model/FuncionarioModel.php:
--------------------------------------------------------------------------------
1 | id))
18 | {
19 | $dao->insert($this);
20 | }
21 | else
22 | {
23 | $dao->update($this);
24 | }
25 | }
26 |
27 | public function getAllRows()
28 | {
29 | include 'DAO/FuncionarioDAO.php';
30 |
31 | $dao = new FuncionarioDAO();
32 | $this->rows = $dao->select();
33 | }
34 |
35 | public function getById(int $id)
36 | {
37 | include 'DAO/FuncionarioDAO.php';
38 |
39 | $dao = new FuncionarioDAO();
40 |
41 | $obj = $dao->selectById($id);
42 |
43 | return ($obj) ? $obj : new FuncionarioModel();
44 | }
45 |
46 | public function delete(int $id)
47 | {
48 | include 'DAO/FuncionarioDAO.php';
49 |
50 | $dao = new FuncionarioDAO();
51 | $dao->delete($id);
52 |
53 | header('Location: /funcionario');
54 | }
55 |
56 |
57 |
58 | }
--------------------------------------------------------------------------------
/Model/PessoaModel.php:
--------------------------------------------------------------------------------
1 | id))
29 | {
30 | // Chamando o método insert que recebe o prórpio objeto model
31 | // Já preenchido.
32 | $dao->insert($this);
33 | }
34 | else
35 | {
36 | $dao->update($this);
37 | }
38 |
39 | // chamando o método save da classe DAO e passando a propria instancia
40 | // da model para a classe DAO. Estamos fazendo isso porque o objeto em si
41 | // foi preenchido na Controller correspondente.
42 | }
43 |
44 | public function getAllRows()
45 | {
46 | include 'DAO/PessoaDAO.php';
47 |
48 | $dao = new PessoaDAO();
49 | $this->rows = $dao->select();
50 | }
51 |
52 | public function getById(int $id)
53 | {
54 | include 'DAO/PessoaDAO.php';
55 |
56 | $dao = new PessoaDAO();
57 |
58 | $obj = $dao->selectById($id);
59 |
60 | return ($obj) ? $obj : new PessoaModel();
61 | }
62 |
63 | public function delete(int $id)
64 | {
65 | include 'DAO/PessoaDAO.php';
66 |
67 | $dao = new PessoaDAO();
68 | $dao->delete($id);
69 |
70 | header('Location: /pessoa');
71 | }
72 | }
--------------------------------------------------------------------------------
/Model/ProdutoModel.php:
--------------------------------------------------------------------------------
1 | id))
18 | {
19 | $dao->insert($this);
20 | }
21 | else
22 | {
23 | $dao->update($this);
24 | }
25 | }
26 |
27 | public function getAllRows()
28 | {
29 | include_once 'DAO/ProdutoDAO.php';
30 |
31 | $dao = new ProdutoDAO;
32 | $this->rows = $dao->select();
33 | }
34 |
35 | public function getAllCategorias()
36 | {
37 | include_once 'DAO/ProdutoDAO.php';
38 |
39 | $dao = new ProdutoDAO();
40 |
41 | $this->lista_categorias = $dao->selectCategoria();
42 | }
43 |
44 | public function getById(int $id)
45 | {
46 | include 'DAO/ProdutoDAO.php';
47 |
48 | $dao = new ProdutoDAO();
49 |
50 | $obj = $dao->selectById($id);
51 |
52 | return ($obj) ? $obj : new ProdutoModel;
53 | }
54 |
55 | public function delete(int $id)
56 | {
57 | include 'DAO/ProdutoDAO.php';
58 |
59 | $dao = new ProdutoDAO;
60 | $dao->delete( (int) $id);
61 |
62 | header('Location: /produto');
63 | }
64 | }
--------------------------------------------------------------------------------
/View/modules/CategoriaProduto/CategoriaProduto.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Categoria Produtos
8 |
9 |
10 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/View/modules/CategoriaProduto/CategoriaProdutoListar.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Categoria de Produtos
8 |
9 |
10 |
11 |
12 |
13 | |
14 | ID |
15 | Descrição |
16 |
17 |
18 | rows as $item): ?>
19 |
20 | X |
21 | = $item->id ?> |
22 | = $item->descricao ?> |
23 |
24 |
25 |
26 | rows) == 0): ?>
27 |
28 | Nenhum registro encontrado... |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/View/modules/Funcionario/FormFuncionario.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Funcionário
8 |
9 |
10 |
34 |
35 |
--------------------------------------------------------------------------------
/View/modules/Funcionario/ListaFuncionario.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Funcionários
8 |
9 |
10 |
11 |
12 | |
13 | ID |
14 | Nome |
15 | RG |
16 | CPF |
17 | Data de Nascimento |
18 |
19 |
20 | rows as $item): ?>
21 |
22 | X |
23 | = $item->id ?> |
24 | = $item->nome ?> |
25 | = $item->rg ?> |
26 | = $item->cpf ?> |
27 | = $item->data_nascimento ?> |
28 |
29 |
30 |
31 | rows) == 0): ?>
32 |
33 | Nenhum registro encontrado... |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/View/modules/Home/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Mix Roupas
9 |
10 |
11 |
12 |
13 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/View/modules/Pessoa/FormPessoa.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Cadastro de Pessoa
8 |
11 |
12 |
13 |
43 |
44 |
--------------------------------------------------------------------------------
/View/modules/Pessoa/ListaPessoas.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Pessoas
8 |
9 |
10 |
11 |
12 | |
13 | ID |
14 | Nome |
15 | RG |
16 | CPF |
17 | Data de Nascimento |
18 | Email |
19 | Telefone |
20 | Endereço |
21 |
22 |
23 | rows as $item): ?>
24 |
25 | X |
26 | = $item->id ?> |
27 | = $item->nome ?> |
28 | = $item->rg ?> |
29 | = $item->cpf ?> |
30 | = $item->data_nascimento ?> |
31 | = $item->email ?> |
32 | = $item->telefone ?> |
33 | = $item->endereco ?> |
34 |
35 |
36 |
37 | rows) == 0): ?>
38 |
39 | Nenhum registro encontrado... |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/View/modules/Produto/FormProduto.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Form Produto
8 |
9 |
10 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/View/modules/Produto/ProdutoListar.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
12 | |
13 | ID |
14 | Nome |
15 | Descrição |
16 | Preço |
17 | Categoria |
18 |
19 |
20 | rows as $item): ?>
21 |
22 | X |
23 | = $item->id ?> |
24 | = $item->nome ?> |
25 | = $item->descricao ?> |
26 | = $item->preco ?> |
27 | = $item->id_categoria_produto ?> |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | ";
7 |
8 | include 'Controller/PessoaController.php';
9 | include 'Controller/ProdutoController.php';
10 | include 'Controller/CategoriaProdutoController.php';
11 | include 'Controller/FuncionarioController.php';
12 |
13 | switch($uri_parse)
14 | {
15 | case '/pessoa':
16 | PessoaController::index();
17 | break;
18 |
19 | case '/pessoa/form':
20 | PessoaController::form();
21 | break;
22 |
23 | case '/pessoa/save':
24 | PessoaController::save();
25 | break;
26 |
27 | case '/pessoa/delete':
28 | PessoaController::delete();
29 | break;
30 |
31 | case '/produto':
32 | ProdutoController::index();
33 | break;
34 |
35 | case '/produto/form':
36 | ProdutoController::form();
37 | break;
38 |
39 | case '/produto/save':
40 | ProdutoController::save();
41 | break;
42 |
43 | case '/produto/delete':
44 | ProdutoController::delete();
45 | break;
46 |
47 | case '/categoria_produto':
48 | CategoriaProdutoController::index();
49 | break;
50 |
51 | case '/categoria_produto/form':
52 | CategoriaProdutoController::form();
53 | break;
54 |
55 | case '/categoria_produto/save':
56 | CategoriaProdutoController::save();
57 | break;
58 |
59 | case '/categoria_produto/delete':
60 | CategoriaProdutoController::delete();
61 | break;
62 |
63 | case '/funcionario':
64 | FuncionarioController::index();
65 | break;
66 |
67 | case '/funcionario/form':
68 | FuncionarioController::form();
69 | break;
70 |
71 | case '/funcionario/save':
72 | FuncionarioController::save();
73 | break;
74 |
75 | case '/funcionario/delete':
76 | FuncionarioController::delete();
77 | break;
78 |
79 | default:
80 | include 'View/modules/Home/index.php';
81 | break;
82 | }
--------------------------------------------------------------------------------