updated commit

This commit is contained in:
sujitprasad
2015-05-08 16:25:40 +05:30
parent ef834c58dc
commit 267467725e
73 changed files with 2748 additions and 2938 deletions

View File

@@ -1,117 +1,99 @@
<?php namespace App\Http\Controllers\Admin;
use App\Http\Requests\DepartmentRequest;
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
/* include DepartmentUpdate Request for validation */
use App\Http\Requests\DepartmentRequest;
use App\Http\Requests\DepartmentUpdate;
use App\Model\Manage\Sla_plan;
use App\Model\Agent\Agents;
use App\Model\Email\Emails;
use App\Model\Agent\Groups;
use App\Model\Agent\Department;
use App\Model\Email\Template;
/* Include Teams model */
use App\Model\Agent\Teams;
/* Use Group_assign_department */
use App\Model\Agent\Groups;
use App\Model\Agent\Group_assign_department;
use App\Model\Agent\Teams;
use App\Model\Email\Emails;
use App\Model\Email\Template;
use App\Model\Manage\Sla_plan;
use App\User;
use DB;
use App\User;
/**
* DepartmentController
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class DepartmentController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
* Create a new controller instance.
* @return void
*/
public function __construct()
{
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
public function index(Department $department)
{
try
{
/**
* Get index page
* @param type Department $department
* @return type Response
*/
public function index(Department $department) {
try {
$departments = $department->get();
return view('themes.default1.admin.agent.departments.index',compact('departments'));
}
catch(Exception $e)
{
return view('themes.default1.admin.agent.departments.index', compact('departments'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
*
* @return Response
* @param type User $user
* @param type Group_assign_department $group_assign_department
* @param type Department $department
* @param type Sla_plan $sla
* @param type Template $template
* @param type Emails $email
* @param type Groups $group
* @return type Response
*/
public function create(User $user,Group_assign_department $group_assign_department, Department $department, Sla_plan $sla,Template $template,Emails $email,Groups $group)
{
try
{
$slas=$sla->get();
$user=$user->where('role','agent')->get();
$emails=$email->get();
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group) {
try {
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$emails = $email->get();
//$groups=$group->get();
$templates = $template->get();
$department = $department->get();
$groups = $group->lists('id','name');
return view('themes.default1.admin.agent.departments.create',compact('department','templates','slas','user','emails','groups'));
}
catch(Exception $e)
{
$groups = $group->lists('id', 'name');
return view('themes.default1.admin.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
*
* @return Response
* @param type Department $department
* @param type DepartmentRequest $request
* @return type Response
*/
public function store(Department $department,DepartmentRequest $request)
{
try
{
$department -> fill($request->except('group_id'))->save();
$requests = $request->input('group_id');
$id = $department->id;
foreach($requests as $req)
{
DB::insert('insert into group_assign_department(group_id, department_id) values (?,?)', [$req, $id]);
}
public function store(Department $department, DepartmentRequest $request) {
try {
$department->fill($request->except('group_id'))->save();
$requests = $request->input('group_id');
$id = $department->id;
foreach ($requests as $req) {
DB::insert('insert into group_assign_department(group_id, department_id) values (?,?)', [$req, $id]);
}
/* Succes And Failure condition */
/* Check Whether the function Success or Fail */
if($department->save()==true)
{
return redirect('departments')->with('success','Department Created sucessfully');
if ($department->save() == true) {
return redirect('departments')->with('success', 'Department Created sucessfully');
} else {
return redirect('departments')->with('fails', 'Department can not Create');
}
else
{
return redirect('departments')->with('fails','Department can not Create');
}
}
catch(Exception $e)
{
return redirect('departments')->with('fails','Department can not Create');
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department can not Create');
}
}
@@ -121,109 +103,87 @@ class DepartmentController extends Controller {
* @param int $id
* @return Response
*/
public function show($id)
{
public function show($id) {
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
* @param type int $id
* @param type User $user
* @param type Group_assign_department $group_assign_department
* @param type Template $template
* @param type Teams $team
* @param type Department $department
* @param type Sla_plan $sla
* @param type Emails $email
* @param type Groups $group
* @return type Response
*/
public function edit($id,User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department,Sla_plan $sla,Emails $email,Groups $group)
{
try
{
$slas=$sla->get();
$user=$user->where('role','agent')->get();
$emails=$email->get();
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) {
try {
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$emails = $email->get();
//$groups=$group->get();
$templates = $template->get();
$departments = $department->whereId($id)->first();
$groups = $group->lists('id','name');
$assign = $group_assign_department->where('department_id',$id)->lists('group_id');
return view('themes.default1.admin.agent.departments.edit',compact('assign','team','templates','departments','slas','user','emails','groups'));
}
catch(Exception $e)
{
$groups = $group->lists('id', 'name');
$assign = $group_assign_department->where('department_id', $id)->lists('group_id');
return view('themes.default1.admin.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
* @param type int $id
* @param type Group_assign_department $group_assign_department
* @param type Department $department
* @param type DepartmentUpdate $request
* @return type Response
*/
public function update($id,Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request)
{
try
{
$table = $group_assign_department->where('department_id',$id);
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) {
try {
$table = $group_assign_department->where('department_id', $id);
$table->delete();
$requests = $request->input('group_id');
foreach($requests as $req)
{
DB::insert('insert into group_assign_department (group_id, department_id) values (?,?)', [$req, $id]);
}
foreach ($requests as $req) {
DB::insert('insert into group_assign_department (group_id, department_id) values (?,?)', [$req, $id]);
}
$departments = $department->whereId($id)->first();
if($departments->fill($request->except('group_access'))->save())
{
return redirect('departments')->with('success','Department Updated sucessfully');
if ($departments->fill($request->except('group_access'))->save()) {
return redirect('departments')->with('success', 'Department Updated sucessfully');
} else {
return redirect('departments')->with('fails', 'Department not Updated');
}
else
{
return redirect('departments')->with('fails','Department not Updated');
}
}
catch(Exception $e)
{
return redirect('departments')->with('fails','Department not Updated');
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department not Updated');
}
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
* @param type int $id
* @param type Department $department
* @param type Group_assign_department $group_assign_department
* @return type Response
*/
public function destroy($id, Department $department, Group_assign_department $group_assign_department)
{
try
{
public function destroy($id, Department $department, Group_assign_department $group_assign_department) {
try {
/* Becouse of foreign key we delete group_assign_department first */
$group_assign_department = $group_assign_department->where('department_id',$id);
$group_assign_department = $group_assign_department->where('department_id', $id);
$group_assign_department->delete();
$departments = $department->whereId($id)->first();
/* Check the function is Success or Fail */
if($departments->delete()==true)
{
return redirect('departments')->with('success','Department Deleted sucessfully');
if ($departments->delete() == true) {
return redirect('departments')->with('success', 'Department Deleted sucessfully');
} else {
return redirect('departments')->with('fails', 'Department can not Delete');
}
else
{
return redirect('departments')->with('fails','Department can not Delete');
}
}
catch(Exception $e)
{
return redirect('departments')->with('fails','Department can not Delete');
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department can not Delete');
}
}