diff --git a/app/controllers/Admin/BannersController.php b/app/controllers/Admin/BannersController.php index cbfa47c..ba81727 100644 --- a/app/controllers/Admin/BannersController.php +++ b/app/controllers/Admin/BannersController.php @@ -30,7 +30,8 @@ public function addAction() { $this->assets->collection('bottom-js') ->addJs('js/moment/moment.min.js') ->addJs('js/moment/ru.js') - ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js'); + ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js') + ->addJs('js/banners_edit_sizes.js'); $this->assets->collection('css') ->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css'); $banner = new Banners(); @@ -123,7 +124,8 @@ public function editAction() { $this->assets->collection('bottom-js') ->addJs('js/moment/moment.min.js') ->addJs('js/moment/ru.js') - ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js'); + ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js') + ->addJs('js/banners_edit_sizes.js'); $this->assets->collection('css') ->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css'); $id = $this->dispatcher->getParam('id'); diff --git a/app/controllers/Admin/ZonesController.php b/app/controllers/Admin/ZonesController.php index 3a0825c..153ffc0 100644 --- a/app/controllers/Admin/ZonesController.php +++ b/app/controllers/Admin/ZonesController.php @@ -17,7 +17,7 @@ public function addAction() { $zone = new Zones(); if ($this->request->isPost()) { - if($zone->save($this->request->getPost(), array('name'))) + if($zone->save($this->request->getPost(), array('name', 'width', 'height'))) { $this->flashSession->success("Зона успешно создана"); return $this->response->redirect(array('for'=>'controller', 'controller'=>'zones')); @@ -63,7 +63,7 @@ public function editAction() { { if ($this->request->isPost()) { - if($zone->save($this->request->getPost(), array('name'))) + if($zone->save($this->request->getPost(), array('name', 'width', 'height'))) { $this->flashSession->success("Зона отредактирована"); return $this->response->redirect(array('for'=>'controller', 'controller'=>'zones')); diff --git a/app/models/Zones.php b/app/models/Zones.php index 3b78532..fe3d8a3 100644 --- a/app/models/Zones.php +++ b/app/models/Zones.php @@ -4,9 +4,11 @@ class Zones extends ModelBase { - public $id, $name; + public $id, $name, $height, $width; public $labels = array( - 'name' => 'Имя' + 'name' => 'Имя', + 'height' => 'Высота', + 'width' => 'Ширина' ); public function initialize() diff --git a/app/views/admin/banners/edit.phtml b/app/views/admin/banners/edit.phtml index 75472bb..aeb5a1a 100644 --- a/app/views/admin/banners/edit.phtml +++ b/app/views/admin/banners/edit.phtml @@ -118,8 +118,14 @@ $zones = \App\Models\Zones::find(); foreach($zones as $zone):?>
-
diff --git a/app/views/admin/zones/edit.phtml b/app/views/admin/zones/edit.phtml index 09e1a98..e5ec8f0 100644 --- a/app/views/admin/zones/edit.phtml +++ b/app/views/admin/zones/edit.phtml @@ -17,7 +17,23 @@ tag->textField(array('name', 'value'=>$zone->name, 'class'=>'form-control'))?> - +
+ +
+ tag->textField(array( + 'width', + 'value'=>$zone->width, + 'class'=>'form-control', + 'placeholder'=>'Ширина' + ))?> + tag->textField(array( + 'height', + 'value'=>$zone->height, + 'class'=>'form-control', + 'placeholder'=>'Высота' + ))?> +
+
diff --git a/app/views/admin/zones/index.phtml b/app/views/admin/zones/index.phtml index 49db605..719fb7f 100644 --- a/app/views/admin/zones/index.phtml +++ b/app/views/admin/zones/index.phtml @@ -5,7 +5,7 @@
-
+
Список
@@ -22,6 +22,7 @@ ID Имя Код инициализации зоны + Размеры Действия @@ -33,6 +34,7 @@ id}\">
");?> + width == '' ? '???' : $zone->width?>xheight == '' ? '???' : $zone->height?> diff --git a/public/js/banners_edit_sizes.js b/public/js/banners_edit_sizes.js new file mode 100644 index 0000000..cc68e0a --- /dev/null +++ b/public/js/banners_edit_sizes.js @@ -0,0 +1,21 @@ +function init() { + var banner_w = Number($('input#width').val()); + var banner_h = Number($('input#height').val()); + + $('.zone').each(function(){ + var h = Number($(this).find('#height').text()); + var w = Number($(this).find('#width').text()); + + if (w >= banner_w && h >= banner_h) + $(this).find('.status').text('входит в размер этой зоны'); + else + $(this).find('.status').text('не входит в размер этой зоны'); + }); +} + +$(document).ready(function(){ + init(); + $('input#width, input#height').change(function(){ + init(); + }) +}); \ No newline at end of file diff --git a/sql_dump.sql b/sql_dump.sql index bfd9e3c..1caa510 100644 --- a/sql_dump.sql +++ b/sql_dump.sql @@ -55,8 +55,10 @@ CREATE TABLE IF NOT EXISTS `user_tokens` ( ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `zones` ( -`id` int(10) unsigned NOT NULL, - `name` varchar(255) NOT NULL + `id` int(10) unsigned NOT NULL, + `name` varchar(255) NOT NULL, + `height` INT(11) NOT NULL, + `width` INT(11) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `views` (