update v 1.0.7.5
This commit is contained in:
@@ -11,10 +11,12 @@ use App\Http\Requests\helpdesk\OrganizationUpdate;
|
||||
// models
|
||||
/* Define OrganizationRequest to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
/* Define OrganizationUpdate to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
/* Define OrganizationUpdate to validate the create form */
|
||||
use App\User;
|
||||
// classes
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* OrganizationController
|
||||
@@ -54,7 +56,7 @@ class OrganizationController extends Controller
|
||||
/* get all values of table organization */
|
||||
return view('themes.default1.agent.helpdesk.organization.index');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +133,7 @@ class OrganizationController extends Controller
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.organization.create');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,14 +152,14 @@ class OrganizationController extends Controller
|
||||
/* Check whether function success or not */
|
||||
if ($org->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Created Successfully');
|
||||
return redirect('organizations')->with('success', Lang::get('lang.organization_created_successfully'));
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Create');
|
||||
return redirect('organizations')->with('fails', Lang::get('lang.organization_can_not_create'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Create');
|
||||
return redirect('organizations')->with('fails', Lang::get('lang.organization_can_not_create'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +179,7 @@ class OrganizationController extends Controller
|
||||
/* To view page */
|
||||
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +199,7 @@ class OrganizationController extends Controller
|
||||
/* To view page */
|
||||
return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,22 +214,22 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function update($id, Organization $org, OrganizationUpdate $request)
|
||||
{
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
/* update the organization table */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
/* update the organization table */
|
||||
/* Check whether function success or not */
|
||||
if ($orgs->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Updated Successfully');
|
||||
return redirect('organizations')->with('success', Lang::get('lang.organization_updated_successfully'));
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
return redirect('organizations')->with('fails', Lang::get('lang.organization_can_not_update'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// dd($e);
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('organizations')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,22 +242,21 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function destroy($id, Organization $org, User_org $user_org)
|
||||
{
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
$user_orgs = $user_org->where('org_id', '=', $id)->get();
|
||||
foreach ($user_orgs as $user_org) {
|
||||
$user_org->delete();
|
||||
}
|
||||
/* Delete the field selected from the table */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
$user_orgs = $user_org->where('org_id', '=', $id)->get();
|
||||
foreach ($user_orgs as $user_org) {
|
||||
$user_org->delete();
|
||||
}
|
||||
/* Delete the field selected from the table */
|
||||
/* Check whether function success or not */
|
||||
$orgs->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
|
||||
return redirect('organizations')->with('success', Lang::get('lang.organization_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('organizations')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,4 +279,53 @@ class OrganizationController extends Controller
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the report of organizations.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type $date111
|
||||
* @param type $date122
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function orgChartData($id, $date111 = '', $date122 = '')
|
||||
{
|
||||
$date11 = strtotime($date122);
|
||||
$date12 = strtotime($date111);
|
||||
if ($date11 && $date12) {
|
||||
$date2 = $date12;
|
||||
$date1 = $date11;
|
||||
} else {
|
||||
// generating current date
|
||||
$date2 = strtotime(date('Y-m-d'));
|
||||
$date3 = date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
// generating a date range of 1 month
|
||||
$date1 = strtotime(date($format, strtotime('-1 month'.$date3)));
|
||||
}
|
||||
$return = '';
|
||||
$last = '';
|
||||
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
|
||||
$thisDate = date('Y-m-d', $i);
|
||||
|
||||
$user_orga_relation_id = '';
|
||||
$user_orga_relations = User_org::where('org_id', '=', $id)->get();
|
||||
foreach ($user_orga_relations as $user_orga_relation) {
|
||||
$user_orga_relation_id[] = $user_orga_relation->user_id;
|
||||
}
|
||||
$created = \DB::table('tickets')->select('created_at')->whereIn('user_id', $user_orga_relation_id)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->whereIn('user_id', $user_orga_relation_id)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->whereIn('user_id', $user_orga_relation_id)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
|
||||
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
$last = rtrim($return, ',');
|
||||
$users = User::whereId($id)->first();
|
||||
|
||||
return '['.$last.']';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user