KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Question - one report for both employee and manager (different access) based on logged user vs manager (avoid designing two identical reports) #1265

Closed paulo opened this topic on on Jan 22, 2020 - 2 comments

paulo commented on Jan 22, 2020

Hi, I have a report which I pass the logged user id to filter information based on what is assigned to their name something like 'My Report' But also, managers should be able to select an employee and see exactly the same information.

So, right now, I have two reports one for employee 'My Report' and another for managers 'Managers employee my report' . They both have different access who can see them through my application.

At the employee, I get $id = $this->params["userId"]; //Auth::user()->id;

    $staff_id = Staff::where(['user_id' => $id])->value('id');

passed through the controller (using Laravel)

Manager's report, I do a drop-down so managers can select the employee they want to see. <h1>Planners</h1>

        <div class="row form-group">
            <div class="col-md-6 offset-md-3">
                <?php
                Select::create(array(
                    "name"=>"plannerNumber",
                    "dataStore"=>$this->dataStore("planners"),
                    "dataBind"=>array(
                        "text"=>"plannerName",
                        "value"=>"plannerNumber",
                    ),
                    "attributes"=>array(
                        "class"=>"form-control"
                    )
                ));
                ?>
            </div>
        </div>

It is painful to maintain TWO reports, so would anyone have any suggestion(s) on a better way of designing this ? Ideally, I'd have one report. IF I am a manager, I can see a drop-down, if I am NOT a manager, I won't see this drop-down and system will just use my login info.

thank you

KoolReport commented on Jan 22, 2020

That's simple that you make 1 report and give parameters "isManager"

$report = MyReport([
    "isManager"=>$isManager //This information is from your authentication I believe
]);

In your report view, you can do:

<?php if($this->params["isManager"]): ?>

// Show the drop down here

<?php endif ?>

Hope that helps.

paulo commented on Jan 31, 2020

thank you. Worked perfectly !

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None