Professional Documents
Culture Documents
Palhoa - SC
- 2015
-
Palhoa - SC
- 2015
RESUMO
There are some companies that manage manually their advertisers through
annotations in books or diary. To make it easy the control of these advertisers by
administrators, this paper proposed a system to automate the management. The
main objective of the system is aimed at the reduction of time spent using controls
and grouping of information to facilitate decision-making. This work includes the
analysis, design and construction of the proposed system, and the end of the work,
the presentation of the application to the users. Based on the proposed solution it
was decided that the application would be developed in PHP in the Object-Oriented
paradigm, using the Yii framework and MySQL database on a server with web
access, to provide the information at any time. Using the system, we found that users
have benefited from some information that were previously restricted, thus facilitating
the programming of visits to advertisers and the consequent optimization of the time
spent for management.
LISTA DE FIGURAS
Figura 1 - Fluxo de Dados MVC..................................................................................17
Figura 2 - Diagramas UML..........................................................................................20
Figura 3 - Diagrama de Casos de Uso........................................................................27
Figura 4 - Diagrama de Classes.................................................................................28
Figura 5 - Modelo Entidade Relacionamento..............................................................29
Figura 6 - Tela inicial do Sistema................................................................................66
Figura 7 - Tela inicial do sistema depois da autenticao..........................................66
Figura 8 - Tela de Login...............................................................................................67
Figura 9 - Tela de erro.................................................................................................67
Figura 10 - Tela Usurios............................................................................................68
Figura 11 - Tela de Cadastro de Usurios...................................................................69
Figura 12 - Tela de visualizao de usurio................................................................70
Figura 13 - Tela de atualizao de usurio.................................................................70
Figura 14 - Administrar usurios.................................................................................71
Figura 15 - Tela de cadastro de classificaes...........................................................72
Figura 16 - Cadastro de atividades.............................................................................72
Figura 17 - Cadastro de servios................................................................................73
Figura 18 - Cadastro de anunciantes..........................................................................74
LISTA DE QUADROS
Quadro 1 Cronograma............................................................................................75
GIS
IDE
MVC
OLAP
PHP
POO
SQL
UML
YII
Yes It Is
Sumrio
1
INTRODUO.....................................................................................................13
OBJETIVO............................................................................................................14
DEFINIO DO ESCOPO...................................................................................15
DESENVOLVIMENTO.........................................................................................16
4.1
TECNOLOGIA, FERRAMENTAS E METODOLOGIAS...............................16
4.1.1
POO - Programao Orientada a Objetos............................................16
4.1.2
MVC Modelo, Viso e Controle..........................................................17
4.1.3
UML Linguagem de Modelagem Unificada........................................19
4.1.4
Yii Framework........................................................................................21
4.1.5
MySQL...................................................................................................21
4.1.6
MySQL WorkBench...............................................................................22
4.1.7
XAMPP..................................................................................................22
4.1.8
NetBeans IDE........................................................................................22
4.1.9
Astah Community..................................................................................23
4.1.10 Google Maps API...................................................................................23
4.2
LEVANTAMENTO DE REQUISITOS............................................................23
4.2.1
Requisitos Funcionais...........................................................................25
4.2.2
Requisitos No Funcionais....................................................................26
4.3
DIAGRAMA DE CASOS DE USO................................................................26
4.4
DIAGRAMA DE CLASSES...........................................................................27
4.5
MODELO ENTIDADE RELACIONAMENTO................................................28
4.6
TABELAS......................................................................................................29
4.7
CDIGO FONTE..........................................................................................31
4.7.1
ARQUIVO DE CONFIGURAO DA APLICAO WEB.....................31
4.7.2
ARQUIVO DE CONFIGURAO DA CONEXO COM O BD.............32
4.7.3
CONTROLLER SITE..........................................................................33
4.7.4
CONTROLLER USURIO.................................................................34
4.7.5
CONTROLLER CLASSIFICAO.....................................................37
4.7.6
CONTROLLER ATIVIDADE...............................................................40
4.7.7
CONTROLLER SERVIO..................................................................42
4.7.8
CONTROLLER ANUNCIANTE...........................................................45
4.7.9
MODELO USURIO...........................................................................48
4.7.10 MODELO CLASSIFICAO..............................................................50
4.7.11 MODELO ATIVIDADE........................................................................51
4.7.12 MODELO SERVIO...........................................................................53
4.7.13 MODELO ANUNCIANTE....................................................................55
4.7.14 MODELO LOGIN................................................................................57
4.7.15 VISO CADASTRO DE USURIO (_form.php)................................59
4.7.16 VISO CADASTRO DE CLASSIFICAO (_form.php)....................60
4.7.17 VISO CADASTRO DE ATIVIDADES (_form.php)............................60
4.7.18 VISO CADASTRO DE SERVICOS (_form.php)..............................61
4.7.19 VISO CADASTRO DE ANUNCIANTES (_form.php).......................62
4.8
TELAS...........................................................................................................65
4.9
CRONOGRAMA...........................................................................................75
5 CONCLUSO......................................................................................................76
5.1
Trabalhos futuros..........................................................................................76
REFERNCIAS.......................................................................................................... 77
APNDICES............................................................................................................... 78
APNDICE A - Cdigo Fonte..................................................................................... 79
13
1 INTRODUO
Garopaba uma cidade que tm como principal fonte de renda o
setor turstico. Para atender este setor, existe uma grande quantidade de Guias
Tursticos, alguns distribudos em papel, outros na internet. Estes guias se dispem
a prestar informaes relevantes ao auxlio dos turistas que visitam a cidade.
Estes Guias, em geral, se mantm com a receita proveniente da
venda de anncios de publicidade e a Gesto destes anncios tem-se percebido
problemtica, ocorrendo na sua maioria de forma manual, sem apoiar-se na ajuda
de sistemas informatizados.
O Sistema a ser construdo busca solucionar este problema,
oferecendo um controle dos Anncios de um Guia Turstico, de forma a aperfeioar a
Gesto.
14
2 OBJETIVO
Segundo Pressman (2011), atualmente existem sete grandes
categorias de software, sendo inerente a cada uma delas seus desafios e suas
especificidades. So elas: Software de sistema, de aplicao, cientfico/de
engenharia, embutido, para linha de produtos, de inteligncia artificial e Aplicaes
para a WEB.
Aplicaes para a Web Chamadas de WebApps, essa categoria de
software centralizada em redes abarca uma vasta gama de aplicaes. Em
sua forma mais simples, as WebApps podem ser pouco mais que um
conjunto de arquivos de hipertexto interconectados, apresentando
informaes por meio de texto e informaes grficas limitadas. Entretanto,
com o aparecimento da Web 2.0, elas tm evoludo e se transformado em
sofisticados ambientes computacionais que no apenas fornecem recursos
especializados, funes computacionais e contedo para o usurio final,
como tambm esto integradas a banco de dados corporativos e aplicaes
comerciais. (PRESSMAN, 2011, p. 35).
15
3 DEFINIO DO ESCOPO
O Sistema Gerenciador de Anunciantes tem como escopo geral
controlar o portflio de anunciantes de um Guia Turstico. Esse gerenciamento se d
atravs do cadastro dos anunciantes, suas atividades e servios prestados, alm da
classificao dos mesmos.
Anunciante qualquer cliente que publica no Guia Turstico,
podendo esta publicidade ser paga ou no. Dependendo da classificao, o Guia
Turstico age com regras de exibio diferente. Essa classificao uma funo que
verificou-se ser dinmica, podendo ser refinada conforme entendimento dos
administradores do Guia Turstico.
Atividade um agrupamento em que os Anunciantes esto
inseridos, tambm dinmica, podendo ser criadas dentro do sistema. Inicialmente,
sero criadas as Atividades: Comrcio, Servios, Gastronomia, Imveis e
Hospedagem.
Servio um agrupamento dentro das Atividades, com maior
especificidade. Este agrupamento, tambm dinmico, ser povoado durante a
utilizao do Sistema, sendo para este trabalho criado apenas alguns exemplos, tais
como Hotis e Pousadas, dentro da Atividade Hospedagem e Restaurante Japons
e Churrascaria, dentro da Atividade Gastronomia.
16
4 DESENVOLVIMENTO
Durante o desenvolvimento do trabalho, foram utilizadas algumas
ferramentas, tecnologias e metodologias, que sero tema deste captulo.
Alm disto, sero abordados nesse captulo o levantamento de
requisitos, sendo divididos entre Requisitos Funcionais e No Funcionais, os
diagramas de classe, de caso de uso e de modelo entidade relacionamento, alm
dos scripts de criao das tabelas do banco de dados e das telas do sistema.
4.1 TECNOLOGIA, FERRAMENTAS E METODOLOGIAS
Nesta
seo
encontram-se
as
tecnologias,
metodologias
17
Herana nos prov um dos maiores benefcios da POO, que o
reuso do cdigo. Essa possibilidade de reutilizar partes de cdigo nos d maior
agilidade e rapidez no dia-a-dia. atravs da herana que as classes compartilham
seus mtodos e atributos com outras classes, pertencentes a mesma hierarquia. Em
PHP a herana se d atravs da palavra reservada extends.
Polimorfismo o princpio que permite que classes filha, derivadas
de uma mesma classe me tenham mtodos iguais, mas com comportamentos
diferentes. Em PHP, diferentemente de outras linguagens como JAVA, no existe
palavra reservada para indicar o polimorfismo, bastando, na codificao da classe
filha, implementar o mtodo que se deseja.
As principais vantagens percebidas no uso da POO so: reuso de
cdigo, maior produtividade, maior facilidade de manuteno, escalabilidade de
aplicaes, gerenciamento mais fcil do desenvolvimento do software.
4.1.2 MVC Modelo, Viso e Controle
Segundo Gabardo (2006), o MVC (Modelo, Viso e Controle) um
padro de design de projetos de software, onde ocorre a separao das camadas de
lgica e negcio da camada de apresentao. Assim, uma alterao em uma
camada no interfere em outra. Na figura abaixo, podemos observar a estrutura
MVC, e como ocorre o fluxo entre suas camadas.
Figura 1 - Fluxo de Dados MVC
18
O Modelo o componente utilizado para representar a camada de
abstrao de dados, as regras de negcio. Normalmente so atribudos a ele as
tarefas de acesso aos dados no banco (alterar, excluir e inserir). alertada pelo
Controle sobre alguma requisio, realiza o processamento necessrio e devolve
para o Controle a resposta.
A Viso a parte principal da camada de apresentao,
representada pela interface com o usurio e responsvel pela definio de como a
informao apresentada ao usurio. No se comunica diretamente com o Modelo
ou com o banco de dados, encaminhando as requisies dos usurios para o
Controle, e deste recebendo a resposta.
O Controle a camada que tm a responsabilidade de ligar a
camada de dados e abstrao, o Modelo, camada de apresentao, a Viso.
responsvel pela traduo das aes do usurio na Viso, e pelo chamado ao
Modelo, para que este retorne a resposta requisio do usurio.
No sistema proposto, a diviso entre as camadas feita de acordo
com os seguintes arquivos:
a) Modelo (models):
Anunciantes.php
Atividades.php
Classificacao.php
LoginForm.php
Servicos.php
Usuarios.php
b) Controle (controllers):
AnunciantesController.php
AtividadesController.php
ClassificacaoController.php
ServicosController.php
SiteController.php
UsuariosController.php
c) Viso (views)
Pasta views
19
20
21
lado do servidor, de cdigo aberto e amplamente utilizada em sistemas de
aplicaes web.
Segundo DallOglio (2007), surgiu em de um produto mais antigo,
criado por Rasmus Lerdorf em 1995, o PHP/FI. A primeira verso que se assemelha
com o PHP atual, foi o PHP 3, criado por Ansi Gutmans e Zeev Suraski, em 1997.
a partir dessa verso que se adotou a nomenclatura PHP, que um acrnimo
recursivo para PHP Hypertext Preprocessor.
Apesar de suportar algumas caractersticas da orientao a objetos
desde a verso 3, foi apenas na verso 5 que se difundiu o uso do PHP como
linguagem orientada a objetos, pois o objetivo dessa verso foi melhorar o
mecanismo de OO, tornando a linguagem apta para se programar com este
paradigma.
Para o desenvolvimento do sistema foi utilizado a verso do PHP
5.6.8.
4.1.4 Yii Framework
Yii um framework MVC de alta performance, escrito em PHP e que
usa componentes para o desenvolvimento de aplicaes web. Desenvolvido para
permitir a mxima reutilizao de cdigo e acelerar o desenvolvimento. Foi escolhido
para o desenvolvimento deste trabalho por ser um framework eficiente, com muitos
recursos e grande documentao. Utilizado em sua verso 1.1 neste trabalho.
4.1.5 MySQL
Sistema de gerenciamento de banco de dados (SGBD) relacional, de
cdigo aberto, escrito em C e C++. Conforme Thompson; Welling (2006) um SGBD
rpido e slido que utiliza a linguagem SQL como interface.
um dos SGBDs mais utilizados do mundo, tendo seu sucesso
facilitado principalmente pela excelente e fcil integrao com a linguagem PHP.
oferecido como padro em grande parte dos pacotes de hospedagem de sites da
internet.
Foi criado na Sucia na dcada de 1990, sendo adquirido pela Sun
22
Microsystem no incio de 2008, sendo esta adquirida pela Oracle em meados de
2009. Hoje suporta vrios recursos de BD, tais como replicao, Hot Backup, GIS,
OLAP, entre outros.
Dentre suas principais caractersticas, podemos:
Facilidade de manuteno.
Portabilidade
Escalabilidade
para
engenharia
reversa.
Integra
desenvolvimento
SQL,
23
4.1.8 NetBeans IDE
Ambiente de desenvolvimento integrado (IDE) multiplataforma,
gratuito e de cdigo aberto para desenvolvedores de softwares em vrias linguagens
de programao, entre as quais PHP. Fornece as ferramentas necessrias para criar
aplicativos profissionais, possuindo um grande conjunto de bibliotecas, mdulos e
APIs.
Seus principais recursos so:
Integrao de mdulos.
24
4.2 LEVANTAMENTO DE REQUISITOS
Uma das principais dificuldades enfrentadas no desenvolvimento de
um sistema entender os requisitos do problema. A engenharia de requisitos atua
sobre essa questo, visando levar a um entendimento sobre qual ser o impacto do
software sobre o negcio, qual a expectativa do cliente e sobre como ser a
interao dos usurios com o sistema.
A engenharia de requisitos fornece o mecanismo apropriado para entender
aquilo que o cliente deseja, analisando as necessidades, avaliando a
viabilidade, negociando uma soluo razovel, especificando a soluo sem
ambiguidades, validando a especificao e gerenciando as necessidades
medida que so transformadas em um sistema operacional. Ela abrange
sete tarefas distintas: concepo, levantamento, elaborao, negociao,
especificao, validao e gesto. (PRESSMAN, 2011, p. 127).
25
objetos diferentes de investigao, ou diferentes tipos de requisitos.
Podemos
Entrevistas:
Consiste
em
conversas
direcionadas,
26
27
Figura 3 - Diagrama de Casos de Uso
28
Figura 4 - Diagrama de Classes
29
Figura 5 - Modelo Entidade Relacionamento
4.6 TABELAS
Com a utilizao do MySQL WorkBench, foram criados os scripts de
criao das tabelas do banco de dados, que seguem abaixo.
-- MySQL Workbench Forward Engineering
-- ------------------------------------------------------ Schema sga
-- ----------------------------------------------------CREATE SCHEMA IF NOT EXISTS `sga` DEFAULT CHARACTER SET latin1 ;
USE `sga` ;
-- ------------------------------------------------------ Table `sga`.`Atividades`
-- ----------------------------------------------------CREATE TABLE IF NOT EXISTS `sga`.`Atividades` (
`cd_atividade` INT NOT NULL AUTO_INCREMENT,
`descricao_atividade` VARCHAR(45) NOT NULL,
PRIMARY KEY (`cd_atividade`))
ENGINE = InnoDB
AUTO_INCREMENT = 0;
-- -----------------------------------------------------
30
-- Table `sga`.`Servicos`
-- ----------------------------------------------------CREATE TABLE IF NOT EXISTS `sga`.`Servicos` (
`cd_servico` INT NOT NULL AUTO_INCREMENT,
`descricao_servico` VARCHAR(45) NOT NULL,
`Atividades_cd_atividade` INT NOT NULL,
PRIMARY KEY (`cd_servico`),
INDEX `fk_Servicos_Atividades1_idx` (`Atividades_cd_atividade` ASC),
CONSTRAINT `fk_Servicos_Atividades1`
FOREIGN KEY (`Atividades_cd_atividade`)
REFERENCES `sga`.`Atividades` (`cd_atividade`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 0;
-- ------------------------------------------------------ Table `sga`.`Classificacao`
-- ----------------------------------------------------CREATE TABLE IF NOT EXISTS `sga`.`Classificacao` (
`cd_classificacao` INT NOT NULL AUTO_INCREMENT,
`descricao_classificacao` VARCHAR(45) NULL,
PRIMARY KEY (`cd_classificacao`))
ENGINE = InnoDB;
-- ------------------------------------------------------ Table `sga`.`Anunciantes`
-- ----------------------------------------------------CREATE TABLE IF NOT EXISTS `sga`.`Anunciantes` (
`codigo` VARCHAR(20) NOT NULL,
`titulo` VARCHAR(128) NOT NULL,
`endereco` VARCHAR(128) NULL,
`fone` VARCHAR(128) NULL,
`frase` VARCHAR(128) NULL,
`logo` VARCHAR(128) NULL,
`link` VARCHAR(128) NULL,
`latitude` DECIMAL(11,6) NULL,
`longitude` DECIMAL(11,6) NULL,
`validade` DATE NOT NULL,
`Classificacao_cd_classificacao` INT NOT NULL,
`Atividades_cd_atividade` INT NOT NULL,
`Servicos_cd_servico` INT NOT NULL,
`impressoes_hp` INT NOT NULL DEFAULT 0,
`cliques_hp` INT NOT NULL DEFAULT 0,
`impressoes_an` INT NOT NULL DEFAULT 0,
`cliques_an` INT NOT NULL DEFAULT 0,
`senha` VARCHAR(255) NOT NULL,
PRIMARY KEY (`codigo`),
INDEX `fk_Anunciantes_Servicos_idx` (`Servicos_cd_servico` ASC),
INDEX `fk_Anunciantes_Atividades1_idx` (`Atividades_cd_atividade` ASC),
INDEX `fk_Anunciantes_Classificacao1_idx` (`Classificacao_cd_classificacao` ASC),
CONSTRAINT `fk_Anunciantes_Servicos`
FOREIGN KEY (`Servicos_cd_servico`)
REFERENCES `sga`.`Servicos` (`cd_servico`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Anunciantes_Atividades1`
FOREIGN KEY (`Atividades_cd_atividade`)
REFERENCES `sga`.`Atividades` (`cd_atividade`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Anunciantes_Classificacao1`
FOREIGN KEY (`Classificacao_cd_classificacao`)
REFERENCES `sga`.`Classificacao` (`cd_classificacao`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
31
ENGINE = InnoDB;
-- ------------------------------------------------------ Table `sga`.`usuarios`
-- ----------------------------------------------------CREATE TABLE IF NOT EXISTS `sga`.`usuarios` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`nome` VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
`senha` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
`email` VARCHAR(64) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `nome` (`nome` ASC))
ENGINE = InnoDB
AUTO_INCREMENT = 0
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
32
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
// database settings are configured in database.php
'db'=>require(dirname(__FILE__).'/database.php'),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'gabriel.lorensi@gmail.com',
),
);
33
'connectionString' => 'mysql:host=localhost;dbname=sga',
'emulatePrepare' => true,
'username' => 'sga_root',
'password' => 'prHnmWzCQbXr5UHj',
'charset' => 'utf8',
);
34
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
*/
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
$this->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->render('login',array('model'=>$model));
}
/**
* Logs out the current user and redirect to homepage.
*/
public function actionLogout()
{
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
}
}
35
array('allow', // allow admin user to perform 'create' and 'update'
actions
'actions'=>array('create','update'),
'users'=>array('admin'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Usuarios;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Usuarios']))
{
$model->attributes=$_POST['Usuarios'];
$senha = $_POST['Usuarios']['senha'];
$model->senha = md5($senha);
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Usuarios']))
{
$model->attributes=$_POST['Usuarios'];
36
$senha = $_POST['Usuarios']['senha'];
$model->senha = md5($senha);
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Usuarios');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Usuarios('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Usuarios']))
$model->attributes=$_GET['Usuarios'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Usuarios the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Usuarios::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
37
/**
* Performs the AJAX validation.
* @param Usuarios $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='usuarios-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
38
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Classificacao;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Classificacao']))
{
$model->attributes=$_POST['Classificacao'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_classificacao));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Classificacao']))
{
$model->attributes=$_POST['Classificacao'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_classificacao));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
39
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Classificacao');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Classificacao('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Classificacao']))
$model->attributes=$_GET['Classificacao'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Classificacao the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Classificacao::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Classificacao $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='classificacao-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
40
4.7.6 CONTROLLER ATIVIDADE
<?php
class AtividadesController extends Controller
{
/**
* @var string the default layout for the views. Defaults to
'//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view'
actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and
'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
41
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Atividades;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Atividades']))
{
$model->attributes=$_POST['Atividades'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_atividade));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Atividades']))
{
$model->attributes=$_POST['Atividades'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_atividade));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
42
$dataProvider=new CActiveDataProvider('Atividades');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Atividades('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Atividades']))
$model->attributes=$_GET['Atividades'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Atividades the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Atividades::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Atividades $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='atividades-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
43
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view'
actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and
'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Servicos;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Servicos']))
{
$model->attributes=$_POST['Servicos'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_servico));
}
44
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Servicos']))
{
$model->attributes=$_POST['Servicos'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_servico));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Servicos');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Servicos('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Servicos']))
$model->attributes=$_GET['Servicos'];
45
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Servicos the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Servicos::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Servicos $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='servicos-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
46
{
return array(
array('allow',
actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and
'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Anunciantes;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Anunciantes'])){
$model->attributes=$_POST['Anunciantes'];
$model->senha = md5($model->senha);
$image = CUploadedFile::getInstance($model, 'logo');
$codigo = $model->codigo;
if ($image!= null){
$name = $codigo.'.'.$image->getExtensionName();
$image->saveAs(Yii::app()->basePath.'/../logos/'.
$codigo.'.'.$image->getExtensionName());
$model->logo = $name;
//die($model->logo.'-'.$name.'-'.$model->codigo);
}
if($model->save()){
47
$this->redirect(array('view','id'=>$model->codigo));
}
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Anunciantes']))
{
$model->attributes=$_POST['Anunciantes'];
$model->senha = md5($model->senha);
if($model->save())
$this->redirect(array('view','id'=>$model->codigo));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Anunciantes');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
48
$model=new Anunciantes('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Anunciantes']))
$model->attributes=$_GET['Anunciantes'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Anunciantes the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Anunciantes::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Anunciantes $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='anunciantes-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
49
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('nome, senha, email', 'required'),
array('nome, senha', 'length', 'max'=>255),
array('nome', 'unique'),
array('email', 'length', 'max'=>64),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, nome, senha, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'Cdigo',
'nome' => 'Nome',
'senha' => 'Senha',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('nome',$this->nome,true);
$criteria->compare('senha',$this->senha,true);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
50
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Usuarios the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
51
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'cd_classificacao' => 'Cdigo',
'descricao_classificacao' => 'Classificao',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('cd_classificacao',$this->cd_classificacao);
$criteria->compare('descricao_classificacao',$this>descricao_classificacao,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Classificacao the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
52
*
* The followings are the available model relations:
* @property Anunciantes[] $anunciantes
* @property Servicos[] $servicoses
*/
class Atividades extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'atividades';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('descricao_atividade', 'required'),
array('descricao_atividade', 'length', 'max'=>45),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('cd_atividade, descricao_atividade', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'anunciantes' => array(self::HAS_MANY, 'Anunciantes',
'Atividades_cd_atividade'),
'servicoses' => array(self::HAS_MANY, 'Servicos',
'Atividades_cd_atividade'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'cd_atividade' => 'Cdigo',
'descricao_atividade' => 'Atividade',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
53
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('cd_atividade',$this->cd_atividade);
$criteria->compare('descricao_atividade',$this->descricao_atividade,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Atividades the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
54
array('Atividades_cd_atividade', 'numerical', 'integerOnly'=>true),
array('descricao_servico', 'length', 'max'=>45),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('cd_servico, descricao_servico, Atividades_cd_atividade,
Atividades.descricao_atividade', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'anunciantes' => array(self::HAS_MANY, 'Anunciantes',
'Servicos_cd_servico'),
'atividadesCdAtividade' => array(self::BELONGS_TO, 'Atividades',
'Atividades_cd_atividade'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'cd_servico' => 'Cdigo',
'descricao_servico' => 'Servio',
'Atividades_cd_atividade' => 'Atividade',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('cd_servico',$this->cd_servico);
$criteria->compare('descricao_servico',$this->descricao_servico,true);
$criteria->compare('Atividades_cd_atividade',$this>Atividades_cd_atividade);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
55
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Servicos the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
56
//array('Classificacao_cd_classificacao, Atividades_cd_atividade,
Servicos_cd_servico, impressoes_hp, cliques_hp, impressoes_an, cliques_an',
'numerical', 'integerOnly'=>true),
array('Classificacao_cd_classificacao, Atividades_cd_atividade,
Servicos_cd_servico', 'numerical', 'integerOnly'=>true),
array('codigo', 'length', 'max'=>20),
array('titulo, endereco, fone, frase, link, logo', 'length',
'max'=>128),
array('latitude, longitude', 'length', 'max'=>11),
array('senha', 'length', 'max'=>255),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('codigo, titulo, endereco, fone, frase, logo, link, latitude,
longitude, validade, Classificacao_cd_classificacao, Atividades_cd_atividade,
Servicos_cd_servico, impressoes_hp, cliques_hp, impressoes_an, cliques_an, senha',
'safe', 'on'=>'search'),
array('codigo', 'unique'),
array('logo', 'file','types'=>'jpg, gif, png',
'allowEmpty'=>true, 'on'=>'update'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'atividadesCdAtividade' => array(self::BELONGS_TO, 'Atividades',
'Atividades_cd_atividade'),
'classificacaoCdClassificacao' => array(self::BELONGS_TO,
'Classificacao', 'Classificacao_cd_classificacao'),
'servicosCdServico' => array(self::BELONGS_TO, 'Servicos',
'Servicos_cd_servico'),
);
}
//
//
//
//
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'codigo' => 'Codigo',
'titulo' => 'Titulo',
'endereco' => 'Endereco',
'fone' => 'Fone',
'frase' => 'Frase',
'logo' => 'Logo',
'link' => 'Link',
'latitude' => 'Latitude',
'longitude' => 'Longitude',
'validade' => 'Validade',
'Classificacao_cd_classificacao' => 'Classificao',
'Atividades_cd_atividade' => 'Atividade',
'Servicos_cd_servico' => 'Servio',
'impressoes_hp' => 'Impressoes Hp',
'cliques_hp' => 'Cliques Hp',
'impressoes_an' => 'Impressoes An',
'cliques_an' => 'Cliques An',
'senha' => 'Senha',
);
}
57
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('codigo',$this->codigo,true);
$criteria->compare('titulo',$this->titulo,true);
$criteria->compare('endereco',$this->endereco,true);
$criteria->compare('fone',$this->fone,true);
$criteria->compare('frase',$this->frase,true);
$criteria->compare('logo',$this->logo,true);
$criteria->compare('link',$this->link,true);
$criteria->compare('latitude',$this->latitude,true);
$criteria->compare('longitude',$this->longitude,true);
$criteria->compare('validade',$this->validade,true);
$criteria->compare('Classificacao_cd_classificacao',$this>Classificacao_cd_classificacao);
$criteria->compare('Atividades_cd_atividade',$this>Atividades_cd_atividade);
$criteria->compare('Servicos_cd_servico',$this->Servicos_cd_servico);
//
$criteria->compare('impressoes_hp',$this->impressoes_hp);
//
$criteria->compare('cliques_hp',$this->cliques_hp);
//
$criteria->compare('impressoes_an',$this->impressoes_an);
//
$criteria->compare('cliques_an',$this->cliques_an);
$criteria->compare('senha',$this->senha,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Anunciantes the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
58
* LoginForm class.
* LoginForm is the data structure for keeping
* user login form data. It is used by the 'login' action of 'SiteController'.
*/
class LoginForm extends CFormModel
{
public $username;
public $password;
public $rememberMe;
private $_identity;
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules()
{
return array(
// username and password are required
array('username, password', 'required'),
// rememberMe needs to be a boolean
array('rememberMe', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),
);
}
/**
* Declares attribute labels.
*/
public function attributeLabels()
{
return array(
'rememberMe'=>'Lembrar',
);
}
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute,$params)
{
if(!$this->hasErrors())
{
$this->_identity=new UserIdentity($this->username,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Usurio ou senha errados!');
}
}
/**
* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
*/
public function login()
{
if($this->_identity===null)
{
$this->_identity=new UserIdentity($this->username,$this->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);
59
return true;
}
else
return false;
}
}
60
4.7.16 VISO CADASTRO DE CLASSIFICAO (_form.php)
<?php
/* @var $this ClassificacaoController */
/* @var $model Classificacao */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'classificacao-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller
code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Campos com <span class="required">*</span> so
obrigatrios.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'descricao_classificacao'); ?>
<?php echo $form>textField($model,'descricao_classificacao',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model,'descricao_classificacao'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
61
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'descricao_atividade'); ?>
<?php echo $form>textField($model,'descricao_atividade',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model,'descricao_atividade'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
62
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
63
<?php echo $form->labelEx($model,'frase'); ?>
<?php echo $form>textField($model,'frase',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'frase'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'logo'); ?>
<?php echo CHtml::activeFileField($model, 'logo'); ?>
<?php echo $form->error($model,'logo'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'link'); ?>
<?php echo $form>urlField($model,'link',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'link'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'validade'); ?>
<?php echo $form->dateField($model,'validade'); ?>
<?php echo $form->error($model,'validade'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Classificacao_cd_classificacao'); ?>
<?php
$classificacao = Classificacao::model()>findAll(array('order'=>'descricao_classificacao asc'));
$clas_lista = CHtml::listData($classificacao,
'cd_classificacao', 'descricao_classificacao');
echo $form>dropDownList($model,'Classificacao_cd_classificacao',
$clas_lista,array('prompt'=>'Selecione a Classificao do Cliente',));
?>
<?php echo $form->error($model,'Classificacao_cd_classificacao'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Atividades_cd_atividade'); ?>
<?php
$atividade = Atividades::model()>findAll(array('order'=>'descricao_atividade asc'));
$ativ_lista = CHtml::listData($atividade, 'cd_atividade',
'descricao_atividade');
echo $form->dropDownList($model,'Atividades_cd_atividade',
$ativ_lista,array('prompt'=>'Selecione a Atividade',));
?>
<?php echo $form->error($model,'Atividades_cd_atividade'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Servicos_cd_servico'); ?>
<?php
$servico = Servicos::model()>findAll(array('order'=>'descricao_servico asc'));
$serv_lista = CHtml::listData($servico, 'cd_servico',
'descricao_servico');
echo $form->dropDownList($model,'Servicos_cd_servico',
$serv_lista,array('prompt'=>'Selecione o Servio',));
?>
<?php echo $form->error($model,'Servicos_cd_servico'); ?>
</div>
<!--
<div class="row">
<?php echo $form->labelEx($model,'impressoes_hp'); ?>
64
<?php echo $form->textField($model,'impressoes_hp'); ?>
<?php echo $form->error($model,'impressoes_hp'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'cliques_hp'); ?>
<?php echo $form->textField($model,'cliques_hp'); ?>
<?php echo $form->error($model,'cliques_hp'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'impressoes_an'); ?>
<?php echo $form->textField($model,'impressoes_an'); ?>
<?php echo $form->error($model,'impressoes_an'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'cliques_an'); ?>
<?php echo $form->textField($model,'cliques_an'); ?>
<?php echo $form->error($model,'cliques_an'); ?>
</div>-->
<div class="row">
<?php echo $form->labelEx($model,'senha'); ?>
<?php echo $form>passwordField($model,'senha',array('size'=>60,'maxlength'=>255)); ?>
<?php echo $form->error($model,'senha'); ?>
</div>
<div class="row">
Clique na localizao do anunciante.
<script src="http://maps.google.com/maps?
file=api&v=2&key=ABQIAAAAj3dHx0tDNOJh4Q5oYu2kxRprCxvELSlEcPfDSERRVWAolemyxRrftuLKp9P8Vw9BlzwGpojbsrTaw"
type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
var address;
//
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(-28.0304, -48.6214), 16);
map.addControl(new GSmallMapControl());
map.addControl(new GScaleControl());
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl);
GEvent.addListener(map, "click", getAddress);
geocoder = new GClientGeocoder();
}
function getAddress(overlay, latlng) {
if (latlng !== null) {
address = latlng;
geocoder.getLocations(latlng, showAddress);
}
}
function showAddress(response) {
map.clearOverlays();
if (!response || response.Status.code !== 200) {
alert("Status Code:" + response.Status.code);
} else {
var string_pos = response.name;
var pos_virg = string_pos.indexOf( "," );
var latlng_pos = string_pos.substring(pos_virg+1) + ',' +
string_pos.substring(0, pos_virg);
65
var latlng_pos_0 = string_pos.substring(0, pos_virg);
var latlng_pos_1 = string_pos.substring(pos_virg+1);
place = response.Placemark[0];
point = new GLatLng(latlng_pos_0, latlng_pos_1);
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(
'<b>Latitude: </b>' + latlng_pos_0 + '<br/>' +
'<b>Longitude: </b>' + latlng_pos_1 + '<br/>');
var t1 = document.getElementById("Anunciantes_latitude");
t1.value = latlng_pos_0;
t1 = document.getElementById("Anunciantes_longitude");
t1.value = latlng_pos_1;
}
}
</script>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 800px; height: 400px"></div>
</div>
<div class="row">
<?php echo $form->labelEx($model,'latitude'); ?>
<?php echo $form>textField($model,'latitude',array('size'=>11,'maxlength'=>11)); ?>
<?php echo $form->error($model,'latitude'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'longitude'); ?>
<?php echo $form>textField($model,'longitude',array('size'=>11,'maxlength'=>11)); ?>
<?php echo $form->error($model,'longitude'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
4.8 TELAS
As telas so o ponto de contato entre o software desenvolvido e os
usurios, onde sero realizadas as funes para as quais este sistema foi
desenvolvido. A seguir sero demonstradas as telas desenvolvidas para o sistema.
66
Figura 6 - Tela inicial do Sistema.
67
Figura 8 - Tela de Login.
68
69
70
Figura 12 - Tela de visualizao de usurio.
71
72
Figura 15 - Tela de cadastro de classificaes.
73
74
Figura 18 - Cadastro de anunciantes.
75
A figura 18 mostra a tela de cadastro dos anunciantes. Para efetivar
o cadastro do sistema obrigatrio o preenchimento dos campos cdigo, ttulo,
validade, classificao, atividade e servios e senha. Estes trs ltimos campos
foram programados da mesma maneira do campo atividade na tela de cadastro de
servios, tambm para facilitar o cadastramento e gerenciamento.
Alm disto, seguindo definies do cliente, foi desenvolvido um
sistema de marcao de localizao do anunciante, que funciona sobre a API do
Google Maps, onde ao clicar na localizao, o sistema preenche automaticamente
os campos de latitude e longitude, para gravao do registro.
Como o campo cdigo a chave primria, o sistema no permite a
gravao de dois usurios com a mesma entrada. J o campo logo, ao ser
preenchido, envia a figura selecionada para uma pasta na aplicao e a grava tendo
como nome o cdigo do cliente. Esse figura deve estar em alguma das seguintes
extenses: GIF, PNG ou JPG, que so os trs principais formatos para imagens na
WEB.
4.9 CRONOGRAMA
Quadro 1 Cronograma
Monografia
Introduo do Trabalho
Redao da Monografia com base no
Referencial Terico
Metodologia, Caractersticas da Empresa e
Descrio da Tecnologia
Levantamento de Requisitos
Diagramas
Desenvolvimento
da
Aplicao
(implementao)
Testes e Validao
Reviso Final
Entrega Final da Monografia
Apresentao da Monografia (no plo de apoio
presencial)
76
5 CONCLUSO
O objetivo do Sistema Gerenciador de Anunciantes otimizar o
gerenciamento dos anunciantes de um Guia Turstico, anteriormente feito em
anotao em cadernos, tornando-o automatizado, utilizando um aplicativo WEB.
Este objetivo foi alcanado.
Aps feedback com o cliente foram encontradas algumas melhorias,
que sero elencadas abaixo, no item trabalhos futuros.
Entre as principais dificuldades encontradas no desenvolvimento
podemos destacar a utilizao de um Framework que ainda no era conhecido pelo
autor e o cronograma apertado para entrega.
Essa primeira dificuldade elencada, trouxe tambm a oportunidade
do aprendizado, mesmo que bsico, do referido Framework. Tambm pode ser
ressaltado o aprendizado ocorrido com a utilizao de novas ferramentas, como o
MySQL WorkBench CE e o Astah Community.
5.1 TRABALHOS FUTUROS
Como citado anteriormente, aps a apresentao ao cliente foram
elencadas as possveis futuras implementaes:
77
REFERNCIAS
ACHOUR, Mehdi et al. Manual do PHP. Disponvel em
<www.php.net/manual/pt_BR>. Acessado em Maio de 2015.
BOOCH, Grady; RUMBAUGH, James; JACOBSON, Ivar. UML: Guia do
usurio. 1a Edio. So Paulo: Elsevier, 2006.
DALLOGLIO, Pablo. PHP: programando com orientao a objetos. 1a
Edio. So Paulo: Novatec, 2007.
FONTELA, Carlos. Programacin Orientada A Objetos. Tcnicas Avanzadas de
Programacin. 1a Edio. Buenos Aires Argentina: Editora Nueva Libreria SRL,
2003.
GABARDO, Ademir C. PHP e MVC com CodeIgniter. 1a Edio. So Paulo:
Novatec, 2012.
GUEDES, Gilleanes T. A. UML 2: uma abordagem prtica. 2a Edio. So
Paulo: Novatec, 2011.
Guia Definitivo do Yii. Disponvel em
<http://www.yiiframework.com/doc/guide/1.1/pt_br/index>. Acessado em Maio de
2015.
KOTONYA, Gerald; SOMMERVILLE, Ian. Requirements engineering: processes
and techniques. 1a Edio. Chichester, Inglaterra: John Wiley, 1998.
Manual de Referncia do MySQL. Disponvel em
<http://dev.mysql.com/doc/refman/5.6/en/index.html>. Acessado em Maio de 2015.
OMG Unified Modeling Language. Disponvel em
<http://www.omg.org/spec/UML/2.5>. Acessado em Maio de 2015.
PRESSMAN, Roger S. Engenharia de software: uma abordagem profissional. 7a
Edio. Porto Alegre: AMGH, 2011.
SOMMERVILLE, Ian. Engenharia de Softwa. 8a Edio. So Paulo: Pearson
Addison Wesley, 2007.
WAZLAWICK, Raul S. Anlise e Projeto de Sistemas de Informao Orientados
a Objetos. 4 ed. So Paulo: Elsevier. 2004.
78
APNDICES
79
Components\Controller.php
<?php
/**
* Controller is the customized base controller class.
* All controller classes for this application should extend from this base class.
*/
class Controller extends CController
{
/**
* @var string the default layout for the controller view. Defaults to
'//layouts/column1',
* meaning using a single column layout. See
'protected/views/layouts/column1.php'.
*/
public $layout='//layouts/column1';
/**
* @var array context menu items. This property will be assigned to {@link
CMenu::items}.
*/
public $menu=array();
/**
* @var array the breadcrumbs of the current page. The value of this property
will
* be assigned to {@link CBreadcrumbs::links}. Please refer to {@link
CBreadcrumbs::links}
* for more details on how to specify this property.
*/
public $breadcrumbs=array();
}?>
Components\UserIdentity.php
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
80
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$username = $this->username;
$password = $this->password;
$usuario
= Usuarios::model()-
>find(array('condition'=>"nome = '$username'"));
if (!empty($username)){
$hashpassword = md5($password);
if ($hashpassword==$usuario->senha){
//die('LOGADO');
$this->errorCode=self::ERROR_NONE;
}
else{
$this->errorCode=self::ERROR_PASSWORD_INVALID;
}
}
else{
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
return !$this->errorCode;
}
}
Controllers\AnunciantesController.php
<?php
class AnunciantesController extends Controller
{
/**
* @var string the default layout for the views. Defaults to
'//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view'
actions
81
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and
'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Anunciantes;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Anunciantes'])){
$model->attributes=$_POST['Anunciantes'];
$model->senha = md5($model->senha);
$image = CUploadedFile::getInstance($model, 'logo');
$codigo = $model->codigo;
if ($image!= null){
$name = $codigo.'.'.$image->getExtensionName();
$image->saveAs(Yii::app()->basePath.'/../logos/'.
$codigo.'.'.$image->getExtensionName());
$model->logo = $name;
//die($model->logo.'-'.$name.'-'.$model->codigo);
}
if($model->save()){
$this->redirect(array('view','id'=>$model->codigo));
}
}
82
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Anunciantes']))
{
$model->attributes=$_POST['Anunciantes'];
$model->senha = md5($model->senha);
if($model->save())
$this->redirect(array('view','id'=>$model->codigo));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Anunciantes');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Anunciantes('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Anunciantes']))
$model->attributes=$_GET['Anunciantes'];
83
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Anunciantes the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Anunciantes::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Anunciantes $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='anunciantes-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
?>
Controllers\AtividadesController.php
<?php
class AtividadesController extends Controller
{
/**
* @var string the default layout for the views. Defaults to
'//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
84
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view'
actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and
'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Atividades;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Atividades']))
{
$model->attributes=$_POST['Atividades'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_atividade));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
85
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Atividades']))
{
$model->attributes=$_POST['Atividades'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_atividade));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Atividades');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Atividades('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Atividades']))
$model->attributes=$_GET['Atividades'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Atividades the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Atividades::model()->findByPk($id);
86
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Atividades $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='atividades-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
?>
Controllers\ClassificacaoController.php
<?php
class ClassificacaoController extends Controller
{
/**
* @var string the default layout for the views. Defaults to
'//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view'
actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and
'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
87
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Classificacao;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Classificacao']))
{
$model->attributes=$_POST['Classificacao'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_classificacao));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Classificacao']))
{
$model->attributes=$_POST['Classificacao'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_classificacao));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
88
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Classificacao');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Classificacao('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Classificacao']))
$model->attributes=$_GET['Classificacao'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Classificacao the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Classificacao::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Classificacao $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='classificacao-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
89
}
?>
Controllers\ServicosController.php
<?php
class ServicosController extends Controller
{
/**
* @var string the default layout for the views. Defaults to
'//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view'
actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and
'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
90
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Servicos;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Servicos']))
{
$model->attributes=$_POST['Servicos'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_servico));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Servicos']))
{
$model->attributes=$_POST['Servicos'];
if($model->save())
$this->redirect(array('view','id'=>$model->cd_servico));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
91
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Servicos');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Servicos('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Servicos']))
$model->attributes=$_GET['Servicos'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Servicos the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Servicos::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Servicos $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='servicos-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
?>
Controllers\SiteController.php
<?php
class SiteController extends Controller
{
/**
* Declares class-based actions.
*/
public function actions()
92
{
return array(
// page action renders "static" pages stored under
'protected/views/site/pages'
// They can be accessed via: index.php?r=site/page&view=FileName
'page'=>array(
'class'=>'CViewAction',
),
);
}
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index');
}
/**
* This is the action to handle external exceptions.
*/
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}
/**
* Displays the login page
*/
public function actionLogin()
{
$model=new LoginForm;
// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
/*
*/
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
$this->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->render('login',array('model'=>$model));
}
/**
* Logs out the current user and redirect to homepage.
*/
public function actionLogout()
{
93
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
}
}?>
Controllers\UsuariosController.php
<?php
class UsuariosController extends Controller
{
/**
* @var string the default layout for the views. Defaults to
'//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view'
actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow admin user to perform 'create' and 'update'
actions
'actions'=>array('create','update'),
'users'=>array('admin'),
),
array('allow', // allow admin user to perform 'admin' and 'delete'
actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
94
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view'
page.
*/
public function actionCreate()
{
$model=new Usuarios;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Usuarios']))
{
$model->attributes=$_POST['Usuarios'];
$senha = $_POST['Usuarios']['senha'];
$model->senha = md5($senha);
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Usuarios']))
{
$model->attributes=$_POST['Usuarios'];
$senha = $_POST['Usuarios']['senha'];
$model->senha = md5($senha);
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin'
page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should
not redirect the browser
95
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] :
array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Usuarios');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Usuarios('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Usuarios']))
$model->attributes=$_GET['Usuarios'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Usuarios the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Usuarios::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Usuarios $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='usuarios-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
Models\Anunciantes.php
<?php
/**
96
* This is the model class for table "anunciantes".
*
* The followings are the available columns in table 'anunciantes':
* @property string $codigo
* @property string $titulo
* @property string $endereco
* @property string $fone
* @property string $frase
* @property string $logo
* @property string $link
* @property string $latitude
* @property string $longitude
* @property string $validade
* @property integer $Classificacao_cd_classificacao
* @property integer $Atividades_cd_atividade
* @property integer $Servicos_cd_servico
* @property integer $impressoes_hp
* @property integer $cliques_hp
* @property integer $impressoes_an
* @property integer $cliques_an
* @property string $senha
*
* The followings are the available model relations:
* @property Atividades $atividadesCdAtividade
* @property Classificacao $classificacaoCdClassificacao
* @property Servicos $servicosCdServico
*/
class Anunciantes extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'anunciantes';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('codigo, titulo, validade, Classificacao_cd_classificacao,
Atividades_cd_atividade, Servicos_cd_servico, senha', 'required'),
//array('Classificacao_cd_classificacao, Atividades_cd_atividade,
Servicos_cd_servico, impressoes_hp, cliques_hp, impressoes_an, cliques_an',
'numerical', 'integerOnly'=>true),
array('Classificacao_cd_classificacao, Atividades_cd_atividade,
Servicos_cd_servico', 'numerical', 'integerOnly'=>true),
array('codigo', 'length', 'max'=>20),
array('titulo, endereco, fone, frase, link, logo', 'length',
'max'=>128),
array('latitude, longitude', 'length', 'max'=>11),
array('senha', 'length', 'max'=>255),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('codigo, titulo, endereco, fone, frase, logo, link, latitude,
longitude, validade, Classificacao_cd_classificacao, Atividades_cd_atividade,
Servicos_cd_servico, impressoes_hp, cliques_hp, impressoes_an, cliques_an, senha',
'safe', 'on'=>'search'),
array('codigo', 'unique'),
97
array('logo', 'file','types'=>'jpg, gif, png',
'allowEmpty'=>true, 'on'=>'update'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'atividadesCdAtividade' => array(self::BELONGS_TO, 'Atividades',
'Atividades_cd_atividade'),
'classificacaoCdClassificacao' => array(self::BELONGS_TO,
'Classificacao', 'Classificacao_cd_classificacao'),
'servicosCdServico' => array(self::BELONGS_TO, 'Servicos',
'Servicos_cd_servico'),
);
}
//
//
//
//
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'codigo' => 'Codigo',
'titulo' => 'Titulo',
'endereco' => 'Endereco',
'fone' => 'Fone',
'frase' => 'Frase',
'logo' => 'Logo',
'link' => 'Link',
'latitude' => 'Latitude',
'longitude' => 'Longitude',
'validade' => 'Validade',
'Classificacao_cd_classificacao' => 'Classificao',
'Atividades_cd_atividade' => 'Atividade',
'Servicos_cd_servico' => 'Servio',
'impressoes_hp' => 'Impressoes Hp',
'cliques_hp' => 'Cliques Hp',
'impressoes_an' => 'Impressoes An',
'cliques_an' => 'Cliques An',
'senha' => 'Senha',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
98
$criteria->compare('codigo',$this->codigo,true);
$criteria->compare('titulo',$this->titulo,true);
$criteria->compare('endereco',$this->endereco,true);
$criteria->compare('fone',$this->fone,true);
$criteria->compare('frase',$this->frase,true);
$criteria->compare('logo',$this->logo,true);
$criteria->compare('link',$this->link,true);
$criteria->compare('latitude',$this->latitude,true);
$criteria->compare('longitude',$this->longitude,true);
$criteria->compare('validade',$this->validade,true);
$criteria->compare('Classificacao_cd_classificacao',$this>Classificacao_cd_classificacao);
$criteria->compare('Atividades_cd_atividade',$this>Atividades_cd_atividade);
$criteria->compare('Servicos_cd_servico',$this->Servicos_cd_servico);
//
$criteria->compare('impressoes_hp',$this->impressoes_hp);
//
$criteria->compare('cliques_hp',$this->cliques_hp);
//
$criteria->compare('impressoes_an',$this->impressoes_an);
//
$criteria->compare('cliques_an',$this->cliques_an);
$criteria->compare('senha',$this->senha,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Anunciantes the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
?>
Models\Atividades.php
<?php
/**
* This is the model class for table "atividades".
*
* The followings are the available columns in table 'atividades':
* @property integer $cd_atividade
* @property string $descricao_atividade
*
* The followings are the available model relations:
* @property Anunciantes[] $anunciantes
* @property Servicos[] $servicoses
*/
class Atividades extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'atividades';
}
99
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('descricao_atividade', 'required'),
array('descricao_atividade', 'length', 'max'=>45),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('cd_atividade, descricao_atividade', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'anunciantes' => array(self::HAS_MANY, 'Anunciantes',
'Atividades_cd_atividade'),
'servicoses' => array(self::HAS_MANY, 'Servicos',
'Atividades_cd_atividade'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'cd_atividade' => 'Cdigo',
'descricao_atividade' => 'Atividade',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('cd_atividade',$this->cd_atividade);
$criteria->compare('descricao_atividade',$this->descricao_atividade,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
100
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Atividades the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
?>
Models\Classificacao.php
<?php
/**
* This is the model class for table "classificacao".
*
* The followings are the available columns in table 'classificacao':
* @property integer $cd_classificacao
* @property string $descricao_classificacao
*
* The followings are the available model relations:
* @property Anunciantes[] $anunciantes
*/
class Classificacao extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'classificacao';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('descricao_classificacao', 'required'),
array('descricao_classificacao', 'length', 'max'=>45),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('cd_classificacao, descricao_classificacao', 'safe',
'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
101
'anunciantes' => array(self::HAS_MANY, 'Anunciantes',
'Classificacao_cd_classificacao'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'cd_classificacao' => 'Cdigo',
'descricao_classificacao' => 'Classificao',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('cd_classificacao',$this->cd_classificacao);
$criteria->compare('descricao_classificacao',$this>descricao_classificacao,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Classificacao the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
?>
Models\LoginForm.php
<?php
/**
* LoginForm class.
* LoginForm is the data structure for keeping
102
* user login form data. It is used by the 'login' action of 'SiteController'.
*/
class LoginForm extends CFormModel
{
public $username;
public $password;
public $rememberMe;
private $_identity;
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules()
{
return array(
// username and password are required
array('username, password', 'required'),
// rememberMe needs to be a boolean
array('rememberMe', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),
);
}
/**
* Declares attribute labels.
*/
public function attributeLabels()
{
return array(
'rememberMe'=>'Lembrar',
);
}
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute,$params)
{
if(!$this->hasErrors())
{
$this->_identity=new UserIdentity($this->username,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Usurio ou senha errados!');
}
}
/**
* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
*/
public function login()
{
if($this->_identity===null)
{
$this->_identity=new UserIdentity($this->username,$this->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);
return true;
}
103
else
return false;
}
}
?>
Models\Servicos.php
<?php
/**
* This is the model class for table "servicos".
*
* The followings are the available columns in table 'servicos':
* @property integer $cd_servico
* @property string $descricao_servico
* @property integer $Atividades_cd_atividade
*
* The followings are the available model relations:
* @property Anunciantes[] $anunciantes
* @property Atividades $atividadesCdAtividade
*/
class Servicos extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'servicos';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('descricao_servico, Atividades_cd_atividade', 'required'),
array('Atividades_cd_atividade', 'numerical', 'integerOnly'=>true),
array('descricao_servico', 'length', 'max'=>45),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('cd_servico, descricao_servico, Atividades_cd_atividade,
Atividades.descricao_atividade', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'anunciantes' => array(self::HAS_MANY, 'Anunciantes',
'Servicos_cd_servico'),
'atividadesCdAtividade' => array(self::BELONGS_TO, 'Atividades',
'Atividades_cd_atividade'),
);
}
104
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'cd_servico' => 'Cdigo',
'descricao_servico' => 'Servio',
'Atividades_cd_atividade' => 'Atividade',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('cd_servico',$this->cd_servico);
$criteria->compare('descricao_servico',$this->descricao_servico,true);
$criteria->compare('Atividades_cd_atividade',$this>Atividades_cd_atividade);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Servicos the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
?>
Models\Usuarios.php
<?php
/**
* This is the model class for table "usuarios".
*
* The followings are the available columns in table 'usuarios':
* @property integer $id
* @property string $nome
105
* @property string $senha
* @property string $email
*/
class Usuarios extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'usuarios';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('nome, senha, email', 'required'),
array('nome, senha', 'length', 'max'=>255),
array('nome', 'unique'),
array('email', 'length', 'max'=>64),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, nome, senha, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'Cdigo',
'nome' => 'Nome',
'senha' => 'Senha',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
106
{
// @todo Please modify the following code to remove attributes that should
not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('nome',$this->nome,true);
$criteria->compare('senha',$this->senha,true);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord
descendants!
* @param string $className active record class name.
* @return Usuarios the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
Views\Anunciantes\Admin.php
<?php
/* @var $this AnunciantesController */
/* @var $model Anunciantes */
$this->breadcrumbs=array(
'Anunciantes'=>array('index'),
'Administrar',
);
$this->menu=array(
array('label'=>'Listar Anunciantes', 'url'=>array('index')),
array('label'=>'Criar Anunciantes', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#anunciantes-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Administrar Anunciantes</h1>
<p>
Voc pode usar os operadores de comparao (<b><</b>, <b><=</b>, <b>></b>,
<b>>=</b>, <b><></b>
ou <b>=</b>) para filtrar os resultados.
107
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'anunciantes-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'codigo',
'titulo',
'endereco',
'fone',
'frase',
'logo',
/*
'link',
'latitude',
'longitude',
*/
'validade',
/*
'Classificacao_cd_classificacao',
'Atividades_cd_atividade',
'Servicos_cd_servico',
'impressoes_hp',
'cliques_hp',
'impressoes_an',
'cliques_an',
'senha',
*/
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Views\Anunciantes\Create.php
<?php
/* @var $this AnunciantesController */
/* @var $model Anunciantes */
$this->breadcrumbs=array(
'Anunciantes'=>array('index'),
'Criar',
);
$this->menu=array(
array('label'=>'Listar Anunciantes', 'url'=>array('index')),
array('label'=>'Administrar Anunciantes', 'url'=>array('admin')),
);
?>
<h1>Criar Anunciantes</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
108
Views\Anunciantes\Index.php
<?php
/* @var $this AnunciantesController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs=array(
'Anunciantes',
);
$this->menu=array(
array('label'=>'Criar Anunciantes', 'url'=>array('create')),
array('label'=>'Administrar Anunciantes', 'url'=>array('admin')),
);
?>
<h1>Anunciantes</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
Views\Anunciantes\Update.php
<?php
/* @var $this AnunciantesController */
/* @var $model Anunciantes */
$this->breadcrumbs=array(
'Anunciantes'=>array('index'),
$model->codigo=>array('view','id'=>$model->codigo),
'Atualizar',
);
$this->menu=array(
array('label'=>'Listar Anunciantes', 'url'=>array('index')),
array('label'=>'Criar Anunciantes', 'url'=>array('create')),
array('label'=>'Visualizar Anunciantes', 'url'=>array('view', 'id'=>$model>codigo)),
array('label'=>'Administrar Anunciantes', 'url'=>array('admin')),
);
?>
<h1>Atualizar Anunciantes <?php echo $model->codigo; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Anunciantes\View.php
<?php
/* @var $this AnunciantesController */
/* @var $model Anunciantes */
$this->breadcrumbs=array(
'Anunciantes'=>array('index'),
$model->codigo,
);
$this->menu=array(
array('label'=>'Listar Anunciantes', 'url'=>array('index')),
array('label'=>'Criar Anunciantes', 'url'=>array('create')),
109
array('label'=>'Atualizar Anunciantes', 'url'=>array('update', 'id'=>$model>codigo)),
array('label'=>'Apagar Anunciantes', 'url'=>'#',
'linkOptions'=>array('submit'=>array('delete','id'=>$model>codigo),'confirm'=>'Voc tem certeza que deseja apagar este item?')),
array('label'=>'Administrar Anunciantes', 'url'=>array('admin')),
);
?>
<h1>Visualizar Anunciantes #<?php echo $model->codigo; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'codigo',
'titulo',
'endereco',
'fone',
'frase',
'logo',
'link',
'latitude',
'longitude',
'validade',
'classificacaoCdClassificacao.descricao_classificacao',
'atividadesCdAtividade.descricao_atividade',
'servicosCdServico.descricao_servico',
'impressoes_hp',
'cliques_hp',
'impressoes_an',
'cliques_an',
'senha',
),
)); ?>
Views\Anunciantes\_form.php
<?php
/* @var $this AnunciantesController */
/* @var $model Anunciantes */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'anunciantes-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller
code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
'stateful'=>true,
'htmlOptions'=>array('enctype' => 'multipart/form-data'),
)); ?>
<p class="note">Campos com <span class="required">*</span> so
obrigatrios.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'codigo'); ?>
110
<?php echo $form>textField($model,'codigo',array('size'=>20,'maxlength'=>20)); ?>
<?php echo $form->error($model,'codigo'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'titulo'); ?>
<?php echo $form>textField($model,'titulo',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'titulo'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'endereco'); ?>
<?php echo $form>textField($model,'endereco',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'endereco'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'fone'); ?>
<?php echo $form>textField($model,'fone',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'fone'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'frase'); ?>
<?php echo $form>textField($model,'frase',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'frase'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'logo'); ?>
<?php echo CHtml::activeFileField($model, 'logo'); ?>
<?php echo $form->error($model,'logo'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'link'); ?>
<?php echo $form>urlField($model,'link',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'link'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'validade'); ?>
<?php echo $form->dateField($model,'validade'); ?>
<?php echo $form->error($model,'validade'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Classificacao_cd_classificacao'); ?>
<?php
$classificacao = Classificacao::model()>findAll(array('order'=>'descricao_classificacao asc'));
$clas_lista = CHtml::listData($classificacao,
'cd_classificacao', 'descricao_classificacao');
echo $form>dropDownList($model,'Classificacao_cd_classificacao',
$clas_lista,array('prompt'=>'Selecione a Classificao do Cliente',));
?>
<?php echo $form->error($model,'Classificacao_cd_classificacao'); ?>
</div>
<div class="row">
111
<?php echo $form->labelEx($model,'Atividades_cd_atividade'); ?>
<?php
$atividade = Atividades::model()>findAll(array('order'=>'descricao_atividade asc'));
$ativ_lista = CHtml::listData($atividade, 'cd_atividade',
'descricao_atividade');
echo $form->dropDownList($model,'Atividades_cd_atividade',
$ativ_lista,array('prompt'=>'Selecione a Atividade',));
?>
<?php echo $form->error($model,'Atividades_cd_atividade'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Servicos_cd_servico'); ?>
<?php
$servico = Servicos::model()>findAll(array('order'=>'descricao_servico asc'));
$serv_lista = CHtml::listData($servico, 'cd_servico',
'descricao_servico');
echo $form->dropDownList($model,'Servicos_cd_servico',
$serv_lista,array('prompt'=>'Selecione o Servio',));
?>
<?php echo $form->error($model,'Servicos_cd_servico'); ?>
</div>
<!--
<div class="row">
<?php echo $form->labelEx($model,'impressoes_hp'); ?>
<?php echo $form->textField($model,'impressoes_hp'); ?>
<?php echo $form->error($model,'impressoes_hp'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'cliques_hp'); ?>
<?php echo $form->textField($model,'cliques_hp'); ?>
<?php echo $form->error($model,'cliques_hp'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'impressoes_an'); ?>
<?php echo $form->textField($model,'impressoes_an'); ?>
<?php echo $form->error($model,'impressoes_an'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'cliques_an'); ?>
<?php echo $form->textField($model,'cliques_an'); ?>
<?php echo $form->error($model,'cliques_an'); ?>
</div>-->
<div class="row">
<?php echo $form->labelEx($model,'senha'); ?>
<?php echo $form>passwordField($model,'senha',array('size'=>60,'maxlength'=>255)); ?>
<?php echo $form->error($model,'senha'); ?>
</div>
<div class="row">
Clique na localizao do anunciante.
<script src="http://maps.google.com/maps?
file=api&v=2&key=ABQIAAAAj3dHx0tDNOJh4Q5oYu2kxRprCxvELSlEcPfDSERRVWAolemyxRrftuLKp9P8Vw9BlzwGpojbsrTaw"
type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
var address;
112
//
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(-28.0304, -48.6214), 16);
map.addControl(new GSmallMapControl());
map.addControl(new GScaleControl());
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl);
GEvent.addListener(map, "click", getAddress);
geocoder = new GClientGeocoder();
}
function getAddress(overlay, latlng) {
if (latlng !== null) {
address = latlng;
geocoder.getLocations(latlng, showAddress);
}
}
function showAddress(response) {
map.clearOverlays();
if (!response || response.Status.code !== 200) {
alert("Status Code:" + response.Status.code);
} else {
var string_pos = response.name;
var pos_virg = string_pos.indexOf( "," );
var latlng_pos = string_pos.substring(pos_virg+1) + ',' +
string_pos.substring(0, pos_virg);
var latlng_pos_0 = string_pos.substring(0, pos_virg);
var latlng_pos_1 = string_pos.substring(pos_virg+1);
place = response.Placemark[0];
point = new GLatLng(latlng_pos_0, latlng_pos_1);
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(
'<b>Latitude: </b>' + latlng_pos_0 + '<br/>' +
'<b>Longitude: </b>' + latlng_pos_1 + '<br/>');
var t1 = document.getElementById("Anunciantes_latitude");
t1.value = latlng_pos_0;
t1 = document.getElementById("Anunciantes_longitude");
t1.value = latlng_pos_1;
}
}
</script>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 800px; height: 400px"></div>
</div>
<div class="row">
<?php echo $form->labelEx($model,'latitude'); ?>
<?php echo $form>textField($model,'latitude',array('size'=>11,'maxlength'=>11)); ?>
<?php echo $form->error($model,'latitude'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'longitude'); ?>
<?php echo $form>textField($model,'longitude',array('size'=>11,'maxlength'=>11)); ?>
<?php echo $form->error($model,'longitude'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
113
</div><!-- form -->
Views\Anunciantes\_search.php
<?php
/* @var $this AnunciantesController */
/* @var $model Anunciantes */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'codigo'); ?>
<?php echo $form>textField($model,'codigo',array('size'=>20,'maxlength'=>20)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'titulo'); ?>
<?php echo $form>textField($model,'titulo',array('size'=>60,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'endereco'); ?>
<?php echo $form>textField($model,'endereco',array('size'=>60,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'fone'); ?>
<?php echo $form>textField($model,'fone',array('size'=>60,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'frase'); ?>
<?php echo $form>textField($model,'frase',array('size'=>60,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'logo'); ?>
<?php echo $form->textField($model,'logo'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'link'); ?>
<?php echo $form>textField($model,'link',array('size'=>60,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'latitude'); ?>
<?php echo $form>textField($model,'latitude',array('size'=>11,'maxlength'=>11)); ?>
</div>
<div class="row">
114
<?php echo $form->label($model,'longitude'); ?>
<?php echo $form>textField($model,'longitude',array('size'=>11,'maxlength'=>11)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'validade'); ?>
<?php echo $form->textField($model,'validade'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'Classificacao_cd_classificacao'); ?>
<?php echo $form->textField($model,'Classificacao_cd_classificacao'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'Atividades_cd_atividade'); ?>
<?php echo $form->textField($model,'Atividades_cd_atividade'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'Servicos_cd_servico'); ?>
<?php echo $form->textField($model,'Servicos_cd_servico'); ?>
</div>
<!--
<div class="row">
<?php echo $form->label($model,'impressoes_hp'); ?>
<?php echo $form->textField($model,'impressoes_hp'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'cliques_hp'); ?>
<?php echo $form->textField($model,'cliques_hp'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'impressoes_an'); ?>
<?php echo $form->textField($model,'impressoes_an'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'cliques_an'); ?>
<?php echo $form->textField($model,'cliques_an'); ?>
</div>-->
<div class="row">
<?php echo $form->label($model,'senha'); ?>
<?php echo $form>textField($model,'senha',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->
Views\Anunciantes\_view.php
<?php
/* @var $this AnunciantesController */
/* @var $data Anunciantes */
?>
115
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('codigo')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->codigo), array('view', 'id'=>$data>codigo)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('titulo')); ?>:</b>
<?php echo CHtml::encode($data->titulo); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('endereco')); ?>:</b>
<?php echo CHtml::encode($data->endereco); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('fone')); ?>:</b>
<?php echo CHtml::encode($data->fone); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('frase')); ?>:</b>
<?php echo CHtml::encode($data->frase); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('logo')); ?>:</b>
<?php echo CHtml::encode($data->logo); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('link')); ?>:</b>
<?php echo CHtml::encode($data->link); ?>
<br />
<?php /*
<b><?php echo CHtml::encode($data->getAttributeLabel('latitude')); ?>:</b>
<?php echo CHtml::encode($data->latitude); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('longitude')); ?>:</b>
<?php echo CHtml::encode($data->longitude); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('validade')); ?>:</b>
<?php echo CHtml::encode($data->validade); ?>
<br />
<b><?php echo CHtml::encode($data>getAttributeLabel('Classificacao_cd_classificacao')); ?>:</b>
<?php echo CHtml::encode($data->Classificacao_cd_classificacao); ?>
<br />
<b><?php echo CHtml::encode($data>getAttributeLabel('Atividades_cd_atividade')); ?>:</b>
<?php echo CHtml::encode($data->Atividades_cd_atividade); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('Servicos_cd_servico')); ?
>:</b>
<?php echo CHtml::encode($data->Servicos_cd_servico); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('impressoes_hp')); ?>:</b>
<?php echo CHtml::encode($data->impressoes_hp); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('cliques_hp')); ?>:</b>
<?php echo CHtml::encode($data->cliques_hp); ?>
<br />
116
<b><?php echo CHtml::encode($data->getAttributeLabel('impressoes_an')); ?>:</b>
<?php echo CHtml::encode($data->impressoes_an); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('cliques_an')); ?>:</b>
<?php echo CHtml::encode($data->cliques_an); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('senha')); ?>:</b>
<?php echo CHtml::encode($data->senha); ?>
<br />
*/ ?>
</div>
Views\Atividades\Admin.php
<?php
/* @var $this AtividadesController */
/* @var $model Atividades */
$this->breadcrumbs=array(
'Atividades'=>array('index'),
'Administrar',
);
$this->menu=array(
array('label'=>'Listar Atividades', 'url'=>array('index')),
array('label'=>'Criar Atividades', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#atividades-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Administrar Atividades</h1>
<p>
Voc pode usar os operadores de comparao (<b><</b>, <b><=</b>, <b>></b>,
<b>>=</b>, <b><></b>
ou <b>=</b>) para filtrar os resultados.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
117
'id'=>'atividades-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'cd_atividade',
'descricao_atividade',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Views\Atividades\Create.php
<?php
/* @var $this AtividadesController */
/* @var $model Atividades */
$this->breadcrumbs=array(
'Atividades'=>array('index'),
'Criar',
);
$this->menu=array(
array('label'=>'Listar Atividades', 'url'=>array('index')),
array('label'=>'Administrar Atividades', 'url'=>array('admin')),
);
?>
<h1>Criar Atividades</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Atividades\Index.php
<?php
/* @var $this AtividadesController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs=array(
'Atividades',
);
$this->menu=array(
array('label'=>'Criar Atividades', 'url'=>array('create')),
array('label'=>'Administrar Atividades', 'url'=>array('admin')),
);
?>
<h1>Atividades</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
118
Views\Atividades\Update.php
<?php
/* @var $this AtividadesController */
/* @var $model Atividades */
$this->breadcrumbs=array(
'Atividades'=>array('index'),
$model->cd_atividade=>array('view','id'=>$model->cd_atividade),
'Atualizar',
);
$this->menu=array(
array('label'=>'Listar Atividades', 'url'=>array('index')),
array('label'=>'Criar Atividades', 'url'=>array('create')),
array('label'=>'Visualizar Atividades', 'url'=>array('view', 'id'=>$model>cd_atividade)),
array('label'=>'Administrar Atividades', 'url'=>array('admin')),
);
?>
<h1>Atualizar Atividades <?php echo $model->cd_atividade; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Atividades\View.php
<?php
/* @var $this AtividadesController */
/* @var $model Atividades */
$this->breadcrumbs=array(
'Atividades'=>array('index'),
$model->cd_atividade,
);
$this->menu=array(
array('label'=>'Listar Atividades', 'url'=>array('index')),
array('label'=>'Criar Atividades', 'url'=>array('create')),
array('label'=>'Atualizar Atividades', 'url'=>array('update', 'id'=>$model>cd_atividade)),
array('label'=>'Apagar Atividades', 'url'=>'#',
'linkOptions'=>array('submit'=>array('delete','id'=>$model>cd_atividade),'confirm'=>'Voc tem certeza que deseja apagar este item?')),
array('label'=>'Administrar Atividades', 'url'=>array('admin')),
);
?>
<h1>Visualizar Atividades #<?php echo $model->cd_atividade; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'cd_atividade',
'descricao_atividade',
),
)); ?>
Views\Atividades\_form.php
119
<?php
/* @var $this AtividadesController */
/* @var $model Atividades */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'atividades-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller
code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Campos com <span class="required">*</span> so
obrigatrios.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'descricao_atividade'); ?>
<?php echo $form>textField($model,'descricao_atividade',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model,'descricao_atividade'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Views\Atividades\_search.php
<?php
/* @var $this AtividadesController */
/* @var $model Atividades */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'cd_atividade'); ?>
<?php echo $form->textField($model,'cd_atividade'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'descricao_atividade'); ?>
<?php echo $form>textField($model,'descricao_atividade',array('size'=>45,'maxlength'=>45)); ?>
</div>
120
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->
Views\Atividades\_view.php
<?php
/* @var $this AtividadesController */
/* @var $data Atividades */
?>
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('cd_atividade')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->cd_atividade), array('view',
'id'=>$data->cd_atividade)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('descricao_atividade')); ?
>:</b>
<?php echo CHtml::encode($data->descricao_atividade); ?>
<br />
</div>
Views\Classificacao\Admin.php
<?php
/* @var $this ClassificacaoController */
/* @var $model Classificacao */
$this->breadcrumbs=array(
'Classificao'=>array('index'),
'Administrar',
);
$this->menu=array(
array('label'=>'Listar Classificao', 'url'=>array('index')),
array('label'=>'Criar Classificao', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#classificacao-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
121
?>
<h1>Administrar Classificaes</h1>
<p>
Voc pode usar os operadores de comparao (<b><</b>, <b><=</b>, <b>></b>,
<b>>=</b>, <b><></b>
ou <b>=</b>) para filtrar os resultados.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'classificacao-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'cd_classificacao',
'descricao_classificacao',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Views\Classificacao\Create.php
<?php
/* @var $this ClassificacaoController */
/* @var $model Classificacao */
$this->breadcrumbs=array(
'Classificao'=>array('index'),
'Criar',
);
$this->menu=array(
array('label'=>'Listar Classificao', 'url'=>array('index')),
array('label'=>'Administrar Classificao', 'url'=>array('admin')),
);
?>
<h1>Criar Classificao</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Classificacao\Index.php
<?php
/* @var $this ClassificacaoController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs=array(
'Classificao',
122
);
$this->menu=array(
array('label'=>'Criar Classificao', 'url'=>array('create')),
array('label'=>'Administrar Classificao', 'url'=>array('admin')),
);
?>
<h1>Classificao</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
Views\Classificacao\Update.php
<?php
/* @var $this ClassificacaoController */
/* @var $model Classificacao */
$this->breadcrumbs=array(
'Classificao'=>array('index'),
$model->cd_classificacao=>array('view','id'=>$model->cd_classificacao),
'Atualizar',
);
$this->menu=array(
array('label'=>'Listar Classificao', 'url'=>array('index')),
array('label'=>'Criar Classificao', 'url'=>array('create')),
array('label'=>'Visualizar Classificao', 'url'=>array('view', 'id'=>$model>cd_classificacao)),
array('label'=>'Administrar Classificao', 'url'=>array('admin')),
);
?>
<h1>Atualizar Classificao <?php echo $model->cd_classificacao; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Classificacao\View.php
<?php
/* @var $this ClassificacaoController */
/* @var $model Classificacao */
$this->breadcrumbs=array(
'Classificao'=>array('index'),
$model->cd_classificacao,
);
$this->menu=array(
array('label'=>'Listar Classificao', 'url'=>array('index')),
array('label'=>'Criar Classificao', 'url'=>array('create')),
array('label'=>'Atualizar Classificao', 'url'=>array('update', 'id'=>$model>cd_classificacao)),
123
array('label'=>'Apagar Classificao', 'url'=>'#',
'linkOptions'=>array('submit'=>array('delete','id'=>$model>cd_classificacao),'confirm'=>'Voc tem certeza que deseja apagar este item?')),
array('label'=>'Administrar Classificao', 'url'=>array('admin')),
);
?>
<h1>Visualizar Classificao #<?php echo $model->cd_classificacao; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'cd_classificacao',
'descricao_classificacao',
),
)); ?>
Views\Classificacao\_form.php
<?php
/* @var $this ClassificacaoController */
/* @var $model Classificacao */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'classificacao-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller
code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Campos com <span class="required">*</span> so
obrigatrios.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'descricao_classificacao'); ?>
<?php echo $form>textField($model,'descricao_classificacao',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model,'descricao_classificacao'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Views\Classificacao\_search.php
124
<?php
/* @var $this ClassificacaoController */
/* @var $model Classificacao */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'cd_classificacao'); ?>
<?php echo $form->textField($model,'cd_classificacao'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'descricao_classificacao'); ?>
<?php echo $form>textField($model,'descricao_classificacao',array('size'=>45,'maxlength'=>45)); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->
Views\Classificacao\_view.php
<?php
/* @var $this ClassificacaoController */
/* @var $data Classificacao */
?>
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('cd_classificacao')); ?
>:</b>
<?php echo CHtml::link(CHtml::encode($data->cd_classificacao), array('view',
'id'=>$data->cd_classificacao)); ?>
<br />
<b><?php echo CHtml::encode($data>getAttributeLabel('descricao_classificacao')); ?>:</b>
<?php echo CHtml::encode($data->descricao_classificacao); ?>
<br />
</div>
Views\Classificacao\Column1.php
<?php /* @var $this Controller */ ?>
<?php $this->beginContent('//layouts/main'); ?>
125
<div id="content">
<?php echo $content; ?>
</div><!-- content -->
<?php $this->endContent(); ?>
Views\Classificacao\Column2.php
<?php /* @var $this Controller */ ?>
<?php $this->beginContent('//layouts/main'); ?>
<div class="span-19">
<div id="content">
<?php echo $content; ?>
</div><!-- content -->
</div>
<div class="span-5 last">
<div id="sidebar">
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
'title'=>'Operations',
));
$this->widget('zii.widgets.CMenu', array(
'items'=>$this->menu,
'htmlOptions'=>array('class'=>'operations'),
));
$this->endWidget();
?>
</div><!-- sidebar -->
</div>
<?php $this->endContent(); ?>
Views\Layouts\Main.php
<?php /* @var $this Controller */ ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="en">
<!-- blueprint CSS framework -->
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request>baseUrl; ?>/css/screen.css" media="screen, projection">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request>baseUrl; ?>/css/print.css" media="print">
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request>baseUrl; ?>/css/ie.css" media="screen, projection">
<![endif]-->
<link
>baseUrl;
<link
>baseUrl;
126
<div class="container" id="page">
<div id="header">
<div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
</div><!-- header -->
<div id="mainmenu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'Login',
'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Usurios',
'url'=>array('/usuarios/index'), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Classificao',
'url'=>array('/classificacao/index'), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Atividades',
'url'=>array('/atividades/index'), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Servios',
'url'=>array('/servicos/index'), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Anunciantes',
'url'=>array('/anunciantes/index'), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user>name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
</div><!-- mainmenu -->
<?php if(isset($this->breadcrumbs)):?>
<?php $this->widget('zii.widgets.CBreadcrumbs', array(
'links'=>$this->breadcrumbs,
)); ?><!-- breadcrumbs -->
<?php endif?>
<?php echo $content; ?>
<div class="clear"></div>
<div id="footer">
Copyright © <?php echo date('Y'); ?> by Gabriel Lorensi Lopes.<br/>
All Rights Reserved.<br/>
<?php echo Yii::powered(); ?>
</div><!-- footer -->
</div><!-- page -->
</body>
</html>
Views\Servicos\Admin.php
<?php
/* @var $this ServicosController */
/* @var $model Servicos */
$this->breadcrumbs=array(
'Servios'=>array('index'),
'Administrar',
);
$this->menu=array(
array('label'=>'Listar Servios', 'url'=>array('index')),
array('label'=>'Criar Servios', 'url'=>array('create')),
);
127
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#servicos-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Administrar Servios</h1>
<p>
Voc pode usar os operadores de comparao (<b><</b>, <b><=</b>, <b>></b>,
<b>>=</b>, <b><></b>
ou <b>=</b>) para filtrar os resultados.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'servicos-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'cd_servico',
'descricao_servico',
'atividadesCdAtividade.descricao_atividade',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Views\Servicos\Create.php
<?php
/* @var $this ServicosController */
/* @var $model Servicos */
$this->breadcrumbs=array(
'Servios'=>array('index'),
'Criar',
);
$this->menu=array(
array('label'=>'Listar Servios', 'url'=>array('index')),
array('label'=>'Administrar Servios', 'url'=>array('admin')),
);
?>
<h1>Criar Servios</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
128
Views\Servicos\Index.php
<?php
/* @var $this ServicosController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs=array(
'Servios',
);
$this->menu=array(
array('label'=>'Criar Servios', 'url'=>array('create')),
array('label'=>'Administrar Servios', 'url'=>array('admin')),
);
?>
<h1>Servios</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
Views\Servicos\Update.php
<?php
/* @var $this ServicosController */
/* @var $model Servicos */
$this->breadcrumbs=array(
'Servios'=>array('index'),
$model->cd_servico=>array('view','id'=>$model->cd_servico),
'Atualizar',
);
$this->menu=array(
array('label'=>'Listar Servios', 'url'=>array('index')),
array('label'=>'Criar Servios', 'url'=>array('create')),
array('label'=>'Visualizar Servios', 'url'=>array('view', 'id'=>$model>cd_servico)),
array('label'=>'Admnistrar Servios', 'url'=>array('admin')),
);
?>
<h1>Atualizar Servios <?php echo $model->cd_servico; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Servicos\View.php
<?php
/* @var $this ServicosController */
/* @var $model Servicos */
129
$this->breadcrumbs=array(
'Servios'=>array('index'),
$model->cd_servico,
);
$this->menu=array(
array('label'=>'Listar Servios', 'url'=>array('index')),
array('label'=>'Criar Servios', 'url'=>array('create')),
array('label'=>'Atualizar Servios', 'url'=>array('update', 'id'=>$model>cd_servico)),
array('label'=>'Apagar Servios', 'url'=>'#',
'linkOptions'=>array('submit'=>array('delete','id'=>$model>cd_servico),'confirm'=>'Voc tem certeza que deseja apagar este item?')),
array('label'=>'Administrar Servios', 'url'=>array('admin')),
);
?>
<h1>Visualizar Servios #<?php echo $model->cd_servico; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'cd_servico',
'descricao_servico',
'atividadesCdAtividade.descricao_atividade',
),
)); ?>
Views\Servicos\_form.php
<?php
/* @var $this ServicosController */
/* @var $model Servicos */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'servicos-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller
code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Campos com <span class="required">*</span> so
obrigatrios.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'descricao_servico'); ?>
<?php echo $form>textField($model,'descricao_servico',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model,'descricao_servico'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Atividades_cd_atividade'); ?>
<?php
$atividade = Atividades::model()>findAll(array('order'=>'descricao_atividade asc'));
130
$ativ_lista = CHtml::listData($atividade, 'cd_atividade',
'descricao_atividade');
echo $form->dropDownList($model,'Atividades_cd_atividade',
$ativ_lista,array('prompt'=>'Selecione a Atividade',));
?>
<?php echo $form->error($model,'Atividades_cd_atividade'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Views\Servicos\_search.php
<?php
/* @var $this ServicosController */
/* @var $model Servicos */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'cd_servico'); ?>
<?php echo $form->textField($model,'cd_servico'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'descricao_servico'); ?>
<?php echo $form>textField($model,'descricao_servico',array('size'=>45,'maxlength'=>45)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'Atividades_cd_atividade'); ?>
<?php echo $form->textField($model,'Atividades_cd_atividade'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->
Views\Servicos\_view.php
<?php
131
/* @var $this ServicosController */
/* @var $data Servicos */
?>
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('cd_servico')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->cd_servico), array('view',
'id'=>$data->cd_servico)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('descricao_servico')); ?
>:</b>
<?php echo CHtml::encode($data->descricao_servico); ?>
<br />
<b><?php echo CHtml::encode($data>getAttributeLabel('Atividades_cd_atividade')); ?>:</b>
<?php echo CHtml::encode($data->atividadesCdAtividade->descricao_atividade); ?>
<br />
</div>
Views\Site\Error.php
<?php
/* @var $this SiteController */
/* @var $error array */
$this->pageTitle=Yii::app()->name . ' - Error';
$this->breadcrumbs=array(
'Erro',
);
?>
<h2>Erro <?php echo $code; ?></h2>
<div class="error">
<?php echo CHtml::encode($message); ?>
</div>
Views\Site\Index.php
<?php
/* @var $this SiteController */
$this->pageTitle=Yii::app()->name;
//$nome = Usuarios::model()->findAll();
//print_r($nome);
?>
<h1>Bem vindo ao <?php echo Yii::app()->name;?></h1>
132
Views\Site\Login.php
<?php
/* @var $this SiteController */
/* @var $model LoginForm */
/* @var $form CActiveForm */
$this->pageTitle=Yii::app()->name . ' - Login';
$this->breadcrumbs=array(
'Login',
);
?>
<h1>Login</h1>
<p>Por Favor, entre com seu login e senha:</p>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
<p class="note">Campos com <span class="required">*</span> so
obrigatrios.</p>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username'); ?>
<?php echo $form->error($model,'username'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password'); ?>
<?php echo $form->error($model,'password'); ?>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model,'rememberMe'); ?>
<?php echo $form->label($model,'rememberMe'); ?>
<?php echo $form->error($model,'rememberMe'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Login'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Views\Usuarios\Admin.php
<?php
/* @var $this UsuariosController */
/* @var $model Usuarios */
133
$this->breadcrumbs=array(
'Usurios'=>array('index'),
'Administrar',
);
$this->menu=array(
array('label'=>'Listar Usurios', 'url'=>array('index')),
array('label'=>'Criar Usurios', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#usuarios-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Administrar Usurios</h1>
<p>
Voc pode usar os operadores de comparao (<b><</b>, <b><=</b>, <b>></b>,
<b>>=</b>, <b><></b>
ou <b>=</b>) para filtrar os resultados.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'usuarios-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'nome',
//'senha',
'email',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Views\Usuarios\Create.php
<?php
/* @var $this UsuariosController */
/* @var $model Usuarios */
$this->breadcrumbs=array(
'Usurios'=>array('index'),
134
'Criar',
);
$this->menu=array(
array('label'=>'Listar Usurios', 'url'=>array('index')),
array('label'=>'Administrar Usurios', 'url'=>array('admin')),
);
?>
<h1>Criar Usurios</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Usuarios\Index.php
<?php
/* @var $this UsuariosController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs=array(
'Usurios',
);
$this->menu=array(
array('label'=>'Criar Usurios', 'url'=>array('create')),
array('label'=>'Administrar Usurios', 'url'=>array('admin')),
);
?>
<h1>Usurios</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
Views\Usuarios\Update.php
<?php
/* @var $this UsuariosController */
/* @var $model Usuarios */
$this->breadcrumbs=array(
'Usurios'=>array('index'),
$model->id=>array('view','id'=>$model->id),
'Atualizar',
);
$this->menu=array(
array('label'=>'Listar Usurios', 'url'=>array('index')),
array('label'=>'Criar Usurios', 'url'=>array('create')),
array('label'=>'Visualizar Usurios', 'url'=>array('view', 'id'=>$model->id)),
array('label'=>'Administrar Usurios', 'url'=>array('admin')),
);
?>
<h1>Atualizar Usurios <?php echo $model->id; ?></h1>
135
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
Views\Usuarios\View.php
<?php
/* @var $this UsuariosController */
/* @var $model Usuarios */
$this->breadcrumbs=array(
'Usurios'=>array('index'),
$model->id,
);
$this->menu=array(
array('label'=>'Listar Usurios', 'url'=>array('index')),
array('label'=>'Criar Usurios', 'url'=>array('create')),
array('label'=>'Atualizar Usurios', 'url'=>array('update', 'id'=>$model->id)),
array('label'=>'Apagar Usurios', 'url'=>'#',
'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Voc
tem certeza que deseja apagar este item?')),
array('label'=>'Administrar Usurios', 'url'=>array('admin')),
);
?>
<h1>Visualizar Usurios #<?php echo $model->id; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'nome',
'email',
),
)); ?>
Views\Usuarios\_form.php
<?php
/* @var $this UsuariosController */
/* @var $model Usuarios */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'usuarios-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller
code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
136
<p class="note">Campos com <span class="required">*</span> so
obrigatrios.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'nome'); ?>
<?php echo $form>textField($model,'nome',array('size'=>20,'maxlength'=>20)); ?>
<?php echo $form->error($model,'nome'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'senha'); ?>
<?php echo $form>passwordField($model,'senha',array('size'=>20,'maxlength'=>255)); ?>
<?php echo $form->error($model,'senha'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form>textField($model,'email',array('size'=>60,'maxlength'=>64)); ?>
<?php echo $form->error($model,'email'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Views\Usuarios\_search.php
<?php
/* @var $this UsuariosController */
/* @var $model Usuarios */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'id'); ?>
<?php echo $form->textField($model,'id'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'nome'); ?>
<?php echo $form>textField($model,'nome',array('size'=>20,'maxlength'=>20)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'senha'); ?>
<?php echo $form>textField($model,'senha',array('size'=>20,'maxlength'=>20)); ?>
137
</div>
<div class="row">
<?php echo $form->label($model,'email'); ?>
<?php echo $form>textField($model,'email',array('size'=>60,'maxlength'=>64)); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->
Views\Usuarios\_view.php
<?php
/* @var $this UsuariosController */
/* @var $data Usuarios */
?>
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data>id)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('nome')); ?>:</b>
<?php echo CHtml::encode($data->nome); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('email')); ?>:</b>
<?php echo CHtml::encode($data->email); ?>
<br />
</div>