Skip to content
This repository was archived by the owner on Jan 18, 2019. It is now read-only.

Commit b44c91f

Browse files
committed
chief ministers shown in states page
1 parent fa7dd35 commit b44c91f

File tree

9 files changed

+40
-1008
lines changed

9 files changed

+40
-1008
lines changed

protected/messages/en/messages.mo

0 Bytes
Binary file not shown.

protected/messages/en/messages.po

+1-998
Large diffs are not rendered by default.

protected/models/Officer.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ public function beforeSave()
131131
if (Yii::app()->id == 'app-frontend' && $this->desig == self::DESIG_DEPUTYCOMMISSIONER)
132132
if (! Yii::app ()->user->checkAccess ( 'ADD_DEPUTY_COMMISSIONER' ))
133133
return false;
134-
134+
if($this->isNewRecord)
135+
if($this->desig != self::DESIG_DEPUTYCHIEFMINISTER)
136+
if(self::countByAttributes(['fkey_place' => $this->fkey_place,'desig' => $this->desig])>0)
137+
throw new Exception($this->fkey_place . '-' . $this->desig . ' - already exists');
135138
return parent::beforeSave ();
136139
}
137140

@@ -267,10 +270,10 @@ function savePicture($url)
267270
$outfile = '';
268271
switch($this->desig)
269272
{
273+
case self::DESIG_DEPUTYCHIEFMINISTER:
274+
$outfile = strtolower($stateobj->slug . '_' . $desig . '_' . time() . '.jpg');
275+
break;
270276
case self::DESIG_GOVERNER:
271-
// make picture path
272-
$outfile = strtolower($stateobj->slug . '_' . $desig . '.jpg');
273-
break;
274277
case self::DESIG_CHIEFMINISTER:
275278
$outfile = strtolower($stateobj->slug . '_' . $desig . '.jpg');
276279
break;

protected/models/State.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* @property Results2009[] $results2009s
3333
* @property Sabha[] $sabhas
3434
* @property Ward[] $wards
35+
* @property Officer $chiefminister
36+
* @property Officer $deputychiefminister
3537
*/
3638
class State extends CActiveRecord
3739
{
@@ -108,11 +110,12 @@ public function relations()
108110
'districts' => array(self::HAS_MANY, 'District', 'id_state','order' => 'name'),
109111
'divisions' => array(self::HAS_MANY, 'District', 'id_state','order' => 'name','condition' => 'id_district_division_hq=id_district'),
110112
'placeNames' => array(self::HAS_MANY, 'PlaceNames', 'id_state'),
111-
'governer' => array(self::HAS_ONE, 'Officer', 'fkey_place','condition' => "(desig=:desig1 or desig=:desig2)",'params' => ['desig1' => Officer::DESIG_GOVERNER,'desig2' => Officer::DESIG_LGOVERNER]),
113+
'governer' => array(self::HAS_ONE, 'Officer', 'fkey_place','condition' => "(desig=:desig1 or desig=:desig2)",'params' => ['desig1' => Officer::DESIG_GOVERNER,'desig2' => Officer::DESIG_LGOVERNER]),
112114
'results2009s' => array(self::HAS_MANY, 'Results2009', 'id_state'),
113115
'sabhas' => array(self::HAS_MANY, 'Sabha', 'id_state'),
114116
'wards' => array(self::HAS_MANY, 'Ward', 'id_state'),
115117
'chiefminister' => array(self::HAS_ONE, 'Officer', 'fkey_place','condition' => 'desig=:desig1','params' => ['desig1' => Officer::DESIG_CHIEFMINISTER]),
118+
'deputychiefminister' => array(self::HAS_MANY, 'Officer', 'fkey_place','condition' => 'desig=:desig1','params' => ['desig1' => Officer::DESIG_DEPUTYCHIEFMINISTER]),
116119
);
117120
}
118121

protected/views/officer/create.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
$this->breadcrumbs=array(
77
'Officers'=>array('index'),
8-
'Create',
8+
'Create',
99
);
1010

1111
$this->menu=array(

protected/views/state/_chiefminister.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22
/* @var $this Controller */
33
/* @var $officer Officer */
44
$data = $officer;
5+
switch($data->desig)
6+
{
7+
case Officer::DESIG_CHIEFMINISTER:
8+
$h2title = __('Chief Minister');
9+
break;
10+
case Officer::DESIG_DEPUTYCHIEFMINISTER:
11+
$h2title = __('Deputy Chief Minister');
12+
break;
13+
}
514
?>
615
<div class="view chmin <?=empty ( $data->picture ) ? '' : 'pic'?>">
7-
<h2><?=__('Chief Minister') ?></h2>
16+
<h2><?=$h2title?></h2>
817
<?php
918
if (! empty ( $data->picture ))
1019
echo CHtml::image ( '/images/pics/' . $data->picture, $data->name, [
@@ -15,7 +24,7 @@
1524
{
1625
$att = [
1726
array ( // related city displayed as a link
18-
'label' => __('Chief Minister'),
27+
'label' =>$h2title,
1928
'name' => 'name'
2029
)
2130
];

protected/views/state/_stateeditor.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111
echo CHtml::link(__('Add Chief Minister'),['officer/create','id_state' => $state->id_state,'desig' => Officer::DESIG_CHIEFMINISTER]);
1212
else
1313
echo CHtml::link(__('Edit Chief Minister'),['officer/update','id' => $state->chiefminister->id_officer]);
14+
if(count($state->deputychiefminister)==0)
15+
echo CHtml::link(__('Add Deputy Chief Minister'),['officer/create','id_state' => $state->id_state,'desig' => Officer::DESIG_DEPUTYCHIEFMINISTER]);
16+
else
17+
{
18+
foreach($state->deputychiefminister as $dcm)
19+
echo '<li>' . CHtml::link(__('Edit Deputy Chief Minister') . ' - ' . $dcm->name,['officer/update','id' => $dcm->id_officer]) . '</li>';
20+
}
1421
?>
15-
<li><?=CHtml::link(__('Add Deputy Chief Minister'),['officer/create','id_state' => $state->id_state,'desig' => Officer::DESIG_DEPUTYCHIEFMINISTER])?>
1622
<li><?php
1723
if(empty($state->governer))
1824
echo CHtml::link(__('Add Governer'),['officer/create','id_state' => $state->id_state,'desig' => Officer::DESIG_GOVERNER]);
1925
else
2026
echo CHtml::link(__('Edit Governer'),['officer/update','id' => $state->governer->id_officer]);
2127
?>
2228
</ol>
23-
2429
</div>

protected/views/state/_view.php

+3
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55

66
<div class="view">
77
<?php echo CHtml::link($data->name,['state/view','id' => $data->id_state]); ?>
8+
<?php
9+
if(isset($data->chiefminister)) $this->renderPartial('_chiefminister',['officer' => $data->chiefminister]);
10+
?>
811
</div>

protected/views/state/view.php

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
if(isset($model->chiefminister))
2828
echo $this->renderPartial('_chiefminister',['officer' => $model->chiefminister]);
2929

30+
if(isset($model->deputychiefminister))
31+
{
32+
foreach($model->deputychiefminister as $cmin)
33+
echo $this->renderPartial('_chiefminister',['officer' => $cmin]);
34+
}
35+
3036
if(isset($model->governer))
3137
{
3238
$off = Officer::model()->localized(Yii::app()->language)->findByPk($model->governer->id_officer);

0 commit comments

Comments
 (0)