Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Search options

  • Loading branch information...
commit fa36978ede56ce34f735272965273f46e04d10f6 1 parent 77110fb
@vaadbait vaadbait authored
View
4 application/controllers/AuthController.php
@@ -25,9 +25,11 @@ public function loginAction() {
if ($this->isValid($_POST)) {
$data = $_POST;
$db = Zend_Db_Table::getDefaultAdapter();
- $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'tenants', 'tnt_email', 'tnt_password');
+ $bld_id = Zend_Registry::get('bld_id');
+ $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'tenants', 'tnt_email', 'tnt_password', "? and (bld_id = $bld_id)");
$authAdapter->setIdentity($data['email']);
$authAdapter->setCredential(md5($data['password']));
+ $authAdapter->setCredentialTreatment("? and (bld_id = $bld_id)");
$result = $authAdapter->authenticate();
if ($result->isValid()) {
$uData = $authAdapter->getResultRowObject(
View
14 application/controllers/BuildingsController.php
@@ -0,0 +1,14 @@
+<?php
+
+class BuildingsController extends Vaad_Controller_Action {
+
+ public function init() {
+ $this->tbl = new Vaad_DbTable_Buildings();
+ $this->select = $this->tbl->select();
+ $this->select->where('id>0');
+ $this->form = new Vaad_Form_Building();
+ $this->_name = 'בניינים';
+ }
+
+}
+
View
3  application/controllers/TenantsController.php
@@ -8,6 +8,9 @@ public function init() {
$this->select->order('tnt_app_num');
$this->form = new Vaad_Form_Tenant();
+
+ $this->setSearchForm(new Vaad_Form_TenantSearch);
+
$this->_name = 'דייר';
}
View
2  application/languages/he.php
@@ -9,6 +9,8 @@
'delete' => 'מחיקה',
'view' => 'הצגת פרטים',
'All' => 'הכל',
+ 'search' => 'חפש',
+ 'Search' => 'חיפוש',
'Apply Filter' => 'סנן',
'Remove Filters' => 'הסר סינון',
'Remove Order' => 'הסר מיון',
View
2  application/layouts/scripts/layout.phtml
@@ -7,8 +7,8 @@
<link rel="stylesheet" href="/css/print.css" type="text/css" media="print">
<!--[if lt IE 8]><link rel="stylesheet" href="/css/ie.css" type="text/css" media="screen, projection"><![endif]-->
- <link rel="stylesheet" href="/css/vaad.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="/css/plugins/rtl/screen.css" type="text/css" media="screen, projection">
+ <link rel="stylesheet" href="/css/vaad.css" type="text/css" media="screen, projection">
<style type="text/css" media="print">img { display:none; }</style>
<link rel="icon" type="image/ico" href="/favicon.ico">
<?php echo $this->jQuery(); ?>
View
12 application/views/scripts/buildings/index.phtml
@@ -0,0 +1,12 @@
+<div id="view-content">
+ <?php
+ foreach ($this->paginator as $row) {
+ //echo "<span class='postit view'>\n";
+ $title = $row->bld_street;
+ echo "<a href='/buildings/view/" . $row->id . "'>$title</a><br>";
+ //echo "</span>\n";
+ }
+ ?>
+ <div class='clear'></div>
+ <?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml') ?>
+</div>
View
11 application/views/scripts/buildings/view.phtml
@@ -0,0 +1,11 @@
+<div class='form-header' id="view-content">
+ <br /><br />
+ <?php echo $this->form; ?>
+ <div class="messages">
+ <?php foreach (Zend_Controller_Action_HelperBroker::getStaticHelper("flashMessenger")
+ ->getMessages() as $message) :
+ ?>
+ <p><?php echo $this->escape($message); ?></p>
+<?php endforeach; ?>
+ </div>
+</div>
View
10 application/views/scripts/sidebar/actions.phtml
@@ -9,4 +9,14 @@
}
?>
</ul>
+<?php if (($this->action == 'index') and (isset($this->searchForm))): ?>
+<h4><?php echo $translator->_('Search'); ?></h4>
+<ul class="action_search">
+
+ <?php
+ echo $this->searchForm;
+ ?>
+<?php endif; ?>
+</ul>
+
<?php $this->placeholder('sidebar')->captureEnd() ?>
View
22 css/vaad.css
@@ -234,6 +234,28 @@ label {
padding-bottom: 10px;
}
+form .action_search {
+ background: transparent;
+ padding: 0px;
+}
+
+.action_search .zend_form {
+ background: transparent;
+ padding: 0px;
+ margin: 0px;
+}
+
+.action_search label{
+ float: none;
+}
+
+ul.action_search, ol.action_search , dd.action_search{
+ margin: 0;
+ padding:0;
+ margin-right: 0;
+}
+
+
.submit {
background : transparent;
border : 0px none;
View
2  index.php
@@ -9,7 +9,7 @@
// Define application environment
defined('APPLICATION_ENV')
-|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
+|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
View
27 library/Vaad/Controller/Action.php
@@ -15,6 +15,7 @@ class Vaad_Controller_Action extends Zend_Controller_Action {
protected $tbl;
protected $select = null;
protected $form;
+ protected $searchForm = '';
private function isVaad() {
$auth = Zend_Auth::getInstance();
@@ -35,23 +36,27 @@ public function preDispatch($withmenu = true) {
$this->_control = $cnt;
$this->_action = $act;
+ $this->view->action = $act;
$ucnt = str_replace(' ', '', ucwords(str_replace('_', ' ', $cnt)));
$this->view->topPageTitle = $translator->_($ucnt);
$this->view->mainMenuTitle = $translator->_($ucnt);
+ $acl = new Vaad_Controller_Plugin_Acl();
+ $identity = Zend_Auth::getInstance()->getIdentity();
+
$this->view->cntName = $cnt;
if ($withmenu) {
$menu = array(
'list' => "/$cnt/index",
);
- if ($this->isVaad() and ($act != 'create')) {
+ if ($acl->isAllowed($identity->role, $cnt, 'create') and ($act != 'create')) {
$menu['new'] = "/$cnt/create";
}
$id = $this->getRequest()->getParam('id');
if ((int) $id > 0) {
- if ($this->isVaad() && ($act != 'edit')) {
+ if ($acl->isAllowed($identity->role, $cnt, 'edit') && ($act != 'edit')) {
$menu['edit'] = "/$cnt/edit/$id";
}
if ($act != 'view')
@@ -63,6 +68,11 @@ public function preDispatch($withmenu = true) {
}
}
+ public function setSearchForm($frm) {
+ $this->searchForm = $frm;
+ $this->view->searchForm = $frm;
+ }
+
protected function getPage() {
$page = $this->_getParam('page', 0);
if ($page > 0)
@@ -81,6 +91,16 @@ protected function setPaginator($result, $cnt = 9) {
public function indexAction() {
+ if ($this->_request->getPost()) {
+ $formData = $this->_request->getPost();
+ foreach ($formData as $k => $v) {
+ if ($k != 'search') {
+ if (!empty($v)) {
+ $this->select->where("$k = '$v'");
+ }
+ }
+ }
+ }
$this->view->rows = $this->tbl->fetchAll($this->select);
$page = $this->getPage();
@@ -93,7 +113,8 @@ public function listAction() {
public function viewAction($save = false) {
$id = $this->getRequest()->getParam('id');
- if ($this->isVaad()) $save = true;
+ if ($this->isVaad())
+ $save = true;
if ($this->_request->getPost()) {
$formData = $this->_request->getPost();
View
44 library/Vaad/Controller/Plugin/Acl.php
@@ -2,8 +2,17 @@
class Vaad_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract {
- public function preDispatch(Zend_Controller_Request_Abstract $request) {
- $acl = new Zend_Acl;
+ protected $_acl = null;
+
+ public function isAllowed($role, $controller, $action) {
+ if ($this->_acl == null) {
+ $this->_acl = new Zend_Acl ();
+ $this->_setRole($this->_acl);
+ }
+ return $this->_acl->isAllowed($role, $controller, $action);
+ }
+
+ private function _setRole($acl) {
$acl->addRole(new Zend_Acl_Role('guest'));
$acl->addRole(new Zend_Acl_Role('tenant'), 'guest');
$acl->addRole(new Zend_Acl_Role('vaad'), 'tenant');
@@ -28,10 +37,11 @@ public function preDispatch(Zend_Controller_Request_Abstract $request) {
$acl->add(new Zend_Acl_Resource('tasks'));
$acl->add(new Zend_Acl_Resource('forums'));
$acl->add(new Zend_Acl_Resource('transactions'));
- $acl->add(new Zend_Acl_Resource('incomes'));
+ $acl->add(new Zend_Acl_Resource('incomes'));
$acl->add(new Zend_Acl_Resource('send'));
$acl->add(new Zend_Acl_Resource('accounts'));
$acl->add(new Zend_Acl_Resource('deposit'));
+ $acl->add(new Zend_Acl_Resource('buildings'));
$acl->allow('guest', 'auth', array('login', 'thankyou'));
$acl->allow('guest', 'auth', array('register'));
@@ -43,7 +53,7 @@ public function preDispatch(Zend_Controller_Request_Abstract $request) {
$acl->allow('tenant', 'auth', array('logout'));
$acl->allow('tenant', 'tenants', array('index', 'view', 'astable'));
- $acl->allow('tenant', 'tickets', array('index', 'edit', 'view', 'add'));
+ $acl->allow('tenant', 'tickets', array('index', 'edit', 'view', 'create'));
$acl->allow('tenant', 'contacts', array('index', 'view', 'astable'));
$acl->allow('tenant', 'posts', array('index'));
$acl->allow('tenant', 'projects', array('index', 'view'));
@@ -67,6 +77,7 @@ public function preDispatch(Zend_Controller_Request_Abstract $request) {
$acl->allow('vaad', 'accounts', null);
$acl->allow('vaad', 'deposit', null);
$acl->allow('vaad', 'forums', null);
+ $acl->allow('vaad', 'buildings', null);
$acl->allow('vaad', 'admin', null); // Vaad can do admin process
@@ -83,6 +94,15 @@ public function preDispatch(Zend_Controller_Request_Abstract $request) {
$role = 'guest';
}
+ return $role;
+ }
+
+ public function preDispatch(Zend_Controller_Request_Abstract $request) {
+ $acl = new Zend_Acl;
+ $this->_acl = $acl;
+ $role = $this->_setRole($acl);
+
+
$controller = $request->controller;
$action = $request->action;
Zend_Registry::set('controller', ucfirst($controller));
@@ -91,20 +111,12 @@ public function preDispatch(Zend_Controller_Request_Abstract $request) {
Zend_Registry::set('IsAllow', $all);
- /*
- $this->getResponse()
- ->appendBody("<p> [$role] [$all] [$controller] [$action]</p>\n");
- foreach ($_POST as $k => $v) {
- $this->getResponse()
- ->appendBody("<p> [$k] [$v] [$role] </p>\n");
- }
- */
if (!$acl->isAllowed($role, $controller, $action)) {
+ $testSpace = new Zend_Session_Namespace('testSpace');
+ $testSpace->setExpirationSeconds(7 * 24 * 60 * 60);
+ $testSpace->__set('controller', $controller);
+ $testSpace->__set('action', $action);
if ($role == 'guest') {
- $testSpace = new Zend_Session_Namespace('testSpace');
- $testSpace->setExpirationSeconds(7*24*60*60);
- $testSpace->__set('controller', $controller);
- $testSpace->__set('action', $action);
$request->setControllerName('auth');
$request->setActionName('login');
} else {
View
6 library/Vaad/DbTable/Buildings.php
@@ -0,0 +1,6 @@
+<?php
+class Vaad_DbTable_Buildings extends Vaad_DbTable_Abstract {
+ protected $_name = 'buildings';
+}
+
+?>
View
74 library/Vaad/Form/Building.php
@@ -0,0 +1,74 @@
+<?php
+
+class Vaad_Form_Building extends ZendX_JQuery_Form {
+
+ public function __construct($options = null) {
+ parent::__construct($options);
+ $this->setAction($options['action'])->setMethod('post');
+ $id = $this->createElement('hidden', 'id');
+ $this->addElement($id);
+ $site_id = $this->createElement('text', 'site_id', array('size' => 17, 'label' => 'site_id'));
+ $site_id->setRequired(true);
+ $this->addElement($site_id);
+ $is_active = $this->createElement('checkbox', 'is_active', array('size' => 17, 'label' => 'is_active'));
+ $is_active->setRequired(true);
+ $this->addElement($is_active);
+ $bld_street = $this->createElement('text', 'bld_street', array('size' => 17, 'label' => 'bld_street'));
+ $bld_street->setRequired(true);
+ $this->addElement($bld_street);
+ $bld_num = $this->createElement('text', 'bld_num', array('size' => 17, 'label' => 'bld_num'));
+ $bld_num->setRequired(true);
+ $this->addElement($bld_num);
+ $bld_city = $this->createElement('text', 'bld_city', array('size' => 17, 'label' => 'bld_city'));
+ $bld_city->setRequired(true);
+ $this->addElement($bld_city);
+ $bld_zip = $this->createElement('text', 'bld_zip', array('size' => 17, 'label' => 'bld_zip'));
+ $bld_zip->setRequired(true);
+ $this->addElement($bld_zip);
+ $bld_num_app = $this->createElement('text', 'bld_num_app', array('size' => 17, 'label' => 'bld_num_app'));
+ $bld_num_app->setRequired(true);
+ $this->addElement($bld_num_app);
+ $bld_min_floor = $this->createElement('text', 'bld_min_floor', array('size' => 17, 'label' => 'bld_min_floor'));
+ $bld_min_floor->setRequired(true);
+ $this->addElement($bld_min_floor);
+ $bld_max_floor = $this->createElement('text', 'bld_max_floor', array('size' => 17, 'label' => 'bld_max_floor'));
+ $bld_max_floor->setRequired(true);
+ $this->addElement($bld_max_floor);
+ $confdel = new Zend_Form_Element_Checkbox('confdel');
+ $confdel->setDescription('<span class="confdel">אישור מחיקה</span>')
+ ->setDecorators(array(
+ 'ViewHelper',
+ array('Description', array('escape' => false, 'tag' => false)),
+ 'Errors',
+ ));
+ $this->addElement($confdel);
+
+ $save = new Zend_Form_Element_Submit('save', array('class' => 'button'));
+ $this->addElement($save);
+ $back = new Zend_Form_Element_Submit('back', array('class' => 'button'));
+ $this->addElement($back);
+ $repeat = new Zend_Form_Element_Submit('repeat', array('class' => 'button'));
+ $this->addElement($repeat);
+ $delete = new Zend_Form_Element_Submit('delete', array('class' => 'button'));
+ $this->addElement($delete);
+ $id->setDecorators(array('ViewHelper'));
+ $save->setDecorators(array('ViewHelper'));
+ $back->setDecorators(array('ViewHelper'));
+ $repeat->setDecorators(array('ViewHelper'));
+ $delete->setDecorators(array('ViewHelper'));
+ $this->addDisplayGroups(array(
+ 'right' => array(
+ 'elements' => array('site_id', 'is_active', 'bld_street', 'bld_num', 'bld_city'),
+ ),
+ 'left' => array(
+ 'elements' => array('bld_zip', 'bld_num_app', 'bld_min_floor', 'bld_max_floor'),
+ ),
+ 'bottom' => array(
+ 'elements' => array('id', 'save', 'back', 'repeat', 'delete', 'confdel'),
+ ),
+ ));
+
+ $this->setDisplayGroupDecorators(array('Description', 'FormElements', 'Fieldset'));
+ }
+
+}
View
22 library/Vaad/Form/Income.php
@@ -9,7 +9,7 @@ public function __construct($options = null) {
$this->addElement($id);
$bld_id = $this->createElement('hidden', 'bld_id');
$this->addElement($bld_id);
-
+
$prj_id = $this->createElement('select', 'prj_id', array('size' => 1, 'label' => 'prj_id'));
$prj_tbl = new Vaad_DbTable_Projects();
$prj_rows = $prj_tbl->getAll();
@@ -17,7 +17,7 @@ public function __construct($options = null) {
$prj_id->addMultiOption($row->id, $row->prj_title);
}
$prj_id->setRequired(true);
-
+
$this->addElement($prj_id);
$inc_date = new ZendX_JQuery_Form_Element_DatePicker('inc_date');
$inc_date->setJQueryParams(array('dateFormat' => 'dd/mm/yy', 'timeFormat' => 'hh:mm:ss'));
@@ -39,15 +39,15 @@ public function __construct($options = null) {
$inc_chk_date->setJQueryParams(array('dateFormat' => 'dd/mm/yy', 'timeFormat' => 'hh:mm:ss'));
$inc_chk_date->setAttrib('size', '10')->setLabel('inc_chk_date')->setValue(date('d/m/Y H:i:s'));
$this->addElement($inc_chk_date);
-
+
$inc_apt_num = $this->createElement('select', 'inc_apt_num', array('size' => 1, 'label' => 'inc_apt_num'));
$tbl = new Vaad_DbTable_Appartments();
$rows = $tbl->fetchAll();
foreach ($rows as $row) {
- $inc_apt_num->addMultiOption($row->id, $row->app_num);
+ $inc_apt_num->addMultiOption($row->id, $row->app_num);
}
$this->addElement($inc_apt_num);
-
+
$inc_bank = $this->createElement('select', 'inc_bank', array('size' => 1, 'label' => 'inc_bank'));
$bnk_tbl = new Vaad_DbTable_BankCodes();
@@ -57,13 +57,13 @@ public function __construct($options = null) {
}
$inc_bank->setRequired(true);
$this->addElement($inc_bank);
- $save = new Zend_Form_Element_Submit('save');
+ $save = new Zend_Form_Element_Submit('save', array('class' => 'button'));
$this->addElement($save);
- $back = new Zend_Form_Element_Submit('back');
+ $back = new Zend_Form_Element_Submit('back', array('class' => 'button'));
$this->addElement($back);
- $repeat = new Zend_Form_Element_Submit('repeat');
+ $repeat = new Zend_Form_Element_Submit('repeat', array('class' => 'button'));
$this->addElement($repeat);
- $delete = new Zend_Form_Element_Submit('delete');
+ $delete = new Zend_Form_Element_Submit('delete', array('class' => 'button'));
$this->addElement($delete);
$id->setDecorators(array('ViewHelper'));
$bld_id->setDecorators(array('ViewHelper'));
@@ -73,10 +73,10 @@ public function __construct($options = null) {
$delete->setDecorators(array('ViewHelper'));
$this->addDisplayGroups(array(
'right' => array(
- 'elements' => array('prj_id','inc_apt_num', 'inc_date', 'inc_until_date', ),
+ 'elements' => array('prj_id', 'inc_apt_num', 'inc_date', 'inc_until_date',),
),
'left' => array(
- 'elements' => array('inc_amount', 'inc_chk_date','inc_bank', 'inc_branch', 'inc_chk_no' ),
+ 'elements' => array('inc_amount', 'inc_chk_date', 'inc_bank', 'inc_branch', 'inc_chk_no'),
),
'bottom' => array(
'elements' => array('id', 'bld_id', 'save', 'back', 'repeat', 'delete'),
View
31 library/Vaad/Form/TenantSearch.php
@@ -0,0 +1,31 @@
+<?php
+
+class Vaad_Form_TenantSearch extends ZendX_JQuery_Form {
+
+ public function __construct($options = null) {
+ parent::__construct($options);
+
+ $this->setAttrib('class', 'action_search');
+ $this->setAction($options['action'])->setMethod('post');
+ $tnt_app_num = $this->createElement('select', 'tnt_app_num', array('size' => 1, 'label' => 'tnt_app_num'));
+ $tnt_app_num->addMultiOption(0, 'כל הדירות');
+ $tbl = new Vaad_DbTable_Appartments();
+ $rows = $tbl->fetchAll();
+ foreach ($rows as $row) {
+ $tnt_app_num->addMultiOption($row->id, $row->app_num);
+ }
+ $tnt_app_num->setRequired(true);
+ $this->addElement($tnt_app_num);
+ $tnt_first_name = $this->createElement('text', 'tnt_first_name', array('size' => 10, 'label' => 'tnt_first_name'));
+ $tnt_first_name->setRequired(true);
+ $this->addElement($tnt_first_name);
+ $tnt_last_name = $this->createElement('text', 'tnt_last_name', array('size' => 10, 'label' => 'tnt_last_name'));
+ $tnt_last_name->setRequired(true);
+ $this->addElement($tnt_last_name);
+
+ $search = new Zend_Form_Element_Submit('search', array('class' => 'button'));
+ $this->addElement($search);
+ $search->setDecorators(array('ViewHelper'));
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.