Permalink
Browse files

option to restrict staff to their own departments

  • Loading branch information...
1 parent 8ba1a14 commit 7c2334b234fdf3e9bdf0c50062664d985287d385 @charlesmarshall charlesmarshall committed May 14, 2012
Showing with 8 additions and 3 deletions.
  1. +1 −0 lib/model/Staff.php
  2. +7 −3 view/WorkController/create.ajax
View
@@ -23,6 +23,7 @@ public function setup(){
$this->define("invited", "BooleanField", array('editable'=>false, 'default'=>0));
$this->define("password_token", "CharField", array('editable'=>false));
$this->define("api_tokens", "HasManyField", array('target_model'=>'AccessToken', 'editable'=>false,"eager_loading"=>true));
+ $this->define("restricted", "BooleanField", array('default'=>1));
$this->columns['send_notification'][1]['editable'] = true;
}
@@ -7,17 +7,21 @@
$jobs = new Job("live");
$staff = new Staff;
$dept = new Department;
- $dept = $dept->for_department($active_staff->department_id(), false);
+ $depts = $active_staff->department_id();
if(!$active_staff->admin()) $staff = $staff->filter("id", $active_staff->primval);
- else $staff = $staff->for_department($active_staff->department_id(), "staff");
+ else $staff = $staff->for_department($depts, "staff");
+ if($active_staff->restricted){
+ $jobs->for_department($depts);
+ $dept = $dept->for_department($depts, false);
+ }
?>
<div class='split clearfix'>
<span class='clearfix'>
<label>Job</label>
<select name="<?=$model->table?>[job_id]" id="<?=$model->table?>_jobs">
<option value="">-- Select --</option>
<?$org = false;?>
- <?foreach($jobs->for_department($active_staff->department_id())->order("organisation_id ASC, date_go_live ASC")->all() as $job):?>
+ <?foreach($jobs->order("organisation_id ASC, date_go_live ASC")->all() as $job):?>
<?if($org != $job->organisation_id):?>
<?if($org):?></optgroup><?endif?>
<optgroup label="<?=(($o = $job->client)? $o->title : "No Client")?>">

0 comments on commit 7c2334b

Please sign in to comment.