Commit 002dd1f9 by hannan

migration and set project director when add new project

parent a5916ce8
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AlterTableInProject extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('project', function (Blueprint $table) {
$table->integer('p_project_director')->after('p_project_task_team')->unsigned()->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('project', function (Blueprint $table) {
$table->dropColumn('p_project_director');
});
}
}
...@@ -7,24 +7,39 @@ ...@@ -7,24 +7,39 @@
<form class="ui form" action="{{ route('timesheet::maintenance.addnewproject' )}}" method="POST"> <form class="ui form" action="{{ route('timesheet::maintenance.addnewproject' )}}" method="POST">
{{csrf_field()}} {{csrf_field()}}
<div class="two fields"> <div class="two fields">
<div class="five wide field"> <div class="eight wide field">
<label>Project Code</label> <label>Project Code</label>
<input type="text" name="projectcode" placeholder="Project Code"> <input type="text" name="projectcode" placeholder="Project Code">
</div> </div>
<div class="five wide field"> <div class="eight wide field">
<label>Project Name</label> <label>Project Name</label>
<input type="text" name="projectname" placeholder="Project Name"> <input type="text" name="projectname" placeholder="Project Name">
</div> </div>
</div> </div>
<div class="field">
<label>Project Manager</label> <div class="two fields">
<select name="projectmanager" class="ui fluid dropdown"> <div class="eight wide field">
<option value="">Project Manager</option> <label>Project Director</label>
@foreach($pm as $key => $value) <select name="projectdirector" class="ui fluid dropdown">
<option value="{{data_get($value,'staff_id')}}">{{data_get($value,'fullname')}}</option> <option value="">Project Director</option>
@endforeach @foreach($pd as $key => $value)
</select> <option value="{{data_get($value,'id')}}">{{data_get($value,'fullname')}}</option>
@endforeach
</select>
</div>
<div class="eight wide field">
<label>Project Manager</label>
<select name="projectmanager" class="ui fluid dropdown">
<option value="">Project Manager</option>
@foreach($pm as $key => $value)
<option value="{{data_get($value,'staff_id')}}">{{data_get($value,'fullname')}}</option>
@endforeach
</select>
</div>
</div> </div>
<div class="field"> <div class="field">
<label>Project Status</label> <label>Project Status</label>
<select name="status" class="ui fluid dropdown"> <select name="status" class="ui fluid dropdown">
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<th class="single line">Project Code</th> <th class="single line">Project Code</th>
<th class="single line">Project Name</th> <th class="single line">Project Name</th>
<th class="single line">Project Manager</th> <th class="single line">Project Manager</th>
<th class="single line">Project Director</th>
<th class="text-center single line">Status</th> <th class="text-center single line">Status</th>
<th class="text-center single line">Action</th> <th class="text-center single line">Action</th>
</tr> </tr>
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
<td class="single line">{{ data_get($project,'projectcode') }} </td> <td class="single line">{{ data_get($project,'projectcode') }} </td>
<td class="single line">{{ data_get($project,'projectname') }} </td> <td class="single line">{{ data_get($project,'projectname') }} </td>
<td class="single line">{{ data_get($project,'projectmanager') }} </td> <td class="single line">{{ data_get($project,'projectmanager') }} </td>
<td class="single line">{{ data_get($project,'projectdirector') }} </td>
<td class="text-center single line">{{ data_get($project,'status') }} </td> <td class="text-center single line">{{ data_get($project,'status') }} </td>
<td class="text-center single line"> <td class="text-center single line">
<button class="compact green ui button" onclick="window.location.href='{{ route('timesheet::maintenance.senaraiProjectTeam', ['id' => $project['id']]) }}';"> <button class="compact green ui button" onclick="window.location.href='{{ route('timesheet::maintenance.senaraiProjectTeam', ['id' => $project['id']]) }}';">
......
...@@ -72,32 +72,32 @@ Route::group( ...@@ -72,32 +72,32 @@ Route::group(
// route to form // route to form
Route::get('chargeableForm',['uses' => 'FormController@chargeableForm', 'as' => 'form.chargeableForm']); Route::get('chargeableForm',['uses' => 'FormController@chargeableForm', 'as' => 'form.chargeableForm']);
Route::get('nonChargeableForm',['uses' => 'FormController@nonChargeableForm', 'as' => 'form.nonChargeableForm']);
Route::get('overheadForm',['uses' => 'FormController@overheadForm', 'as' => 'form.overheadForm']); Route::get('overheadForm',['uses' => 'FormController@overheadForm', 'as' => 'form.overheadForm']);
Route::post('savechargeablehours',['uses' => 'FormController@savechargeablehours', 'as' => 'form.savechargeablehours']); Route::post('savechargeablehours',['uses' => 'FormController@savechargeablehours', 'as' => 'form.savechargeablehours']);
Route::post('savenonchargeablehours',['uses' => 'FormController@savenonchargeablehours', 'as' => 'form.savenonchargeablehours']);
Route::post('saveoverheadhours',['uses' => 'FormController@saveoverheadhours', 'as' => 'form.saveoverheadhours']); Route::post('saveoverheadhours',['uses' => 'FormController@saveoverheadhours', 'as' => 'form.saveoverheadhours']);
Route::post('addOverheadDescription',['uses' => 'FormController@addOverheadDescription', 'as' => 'form.addOverheadDescription']); Route::post('addOverheadDescription',['uses' => 'FormController@addOverheadDescription', 'as' => 'form.addOverheadDescription']);
Route::get('notelist',['uses' => 'FormController@notelist', 'as' => 'form.notelist']); Route::get('notelist',['uses' => 'FormController@notelist', 'as' => 'form.notelist']);
Route::get('penambahannote',['uses' => 'FormController@penambahannote', 'as' => 'form.penambahannote']); Route::get('penambahannote',['uses' => 'FormController@penambahannote', 'as' => 'form.penambahannote']);
Route::post('addnote', ['uses' => 'FormController@addnote', 'as' => 'form.addnote']); Route::post('addnote', ['uses' => 'FormController@addnote', 'as' => 'form.addnote']);
Route::get('filterChargeable',['uses' => 'FormController@filterChargeable', 'as' => 'form.filterChargeable']); Route::get('filterChargeable',['uses' => 'FormController@filterChargeable', 'as' => 'form.filterChargeable']);
Route::get('filterNonChargeable',['uses' => 'FormController@filterNonChargeable', 'as' => 'form.filterNonChargeable']);
Route::get('filterOverhead',['uses' => 'FormController@filterOverhead', 'as' => 'form.filterOverhead']); Route::get('filterOverhead',['uses' => 'FormController@filterOverhead', 'as' => 'form.filterOverhead']);
Route::get('filterNotes',['uses' => 'FormController@filterNotes', 'as' => 'form.filterNotes']); Route::get('filterNotes',['uses' => 'FormController@filterNotes', 'as' => 'form.filterNotes']);
Route::post('chargeableselectmonthphase', ['uses' => 'FormController@chargeableselectmonthphase', 'as' => 'form.chargeableselectmonthphase']); Route::post('chargeableselectmonthphase', ['uses' => 'FormController@chargeableselectmonthphase', 'as' => 'form.chargeableselectmonthphase']);
Route::post('nonchargeableselectmonthphase', ['uses' => 'FormController@nonchargeableselectmonthphase', 'as' => 'form.nonchargeableselectmonthphase']);
Route::post('overheadselectmonthphase', ['uses' => 'FormController@overheadselectmonthphase', 'as' => 'form.overheadselectmonthphase']); Route::post('overheadselectmonthphase', ['uses' => 'FormController@overheadselectmonthphase', 'as' => 'form.overheadselectmonthphase']);
Route::post('noteselectmonthphase', ['uses' => 'FormController@noteselectmonthphase', 'as' => 'form.noteselectmonthphase']); Route::post('noteselectmonthphase', ['uses' => 'FormController@noteselectmonthphase', 'as' => 'form.noteselectmonthphase']);
Route::post('action/upload', ['uses' => 'FormController@uploadAttachement', 'as' => 'form.upload']); Route::post('action/upload', ['uses' => 'FormController@uploadAttachement', 'as' => 'form.upload']);
// nonChargeableForm // nonChargeableForm
Route::post('addnonchargeabletask',['uses' => 'FormController@addnonchargeabletask', 'as' => 'form.addnonchargeabletask']); // Route::get('nonChargeableForm',['uses' => 'FormController@nonChargeableForm', 'as' => 'form.nonChargeableForm']);
// Route::post('savenonchargeablehours',['uses' => 'FormController@savenonchargeablehours', 'as' => 'form.savenonchargeablehours']);
// Route::get('filterNonChargeable',['uses' => 'FormController@filterNonChargeable', 'as' => 'form.filterNonChargeable']);
// Route::post('nonchargeableselectmonthphase', ['uses' => 'FormController@nonchargeableselectmonthphase', 'as' => 'form.nonchargeableselectmonthphase']);
// Route::post('addnonchargeabletask',['uses' => 'FormController@addnonchargeabletask', 'as' => 'form.addnonchargeabletask']);
//calendar //calendar
Route::get('kalendarCharge',['uses' => 'CalendarController@kalendarCharge', 'as' => 'kalendar.kalendarCharge']); // Route::get('kalendarCharge',['uses' => 'CalendarController@kalendarCharge', 'as' => 'kalendar.kalendarCharge']);
Route::get('kalendarNonCharge',['uses' => 'CalendarController@kalendarNonCharge', 'as' => 'kalendar.kalendarNonCharge']); // Route::get('kalendarNonCharge',['uses' => 'CalendarController@kalendarNonCharge', 'as' => 'kalendar.kalendarNonCharge']);
Route::get('kalendar',['uses' => 'CalendarController@kalendar', 'as' => 'kalendar.kalendar']); // Route::get('kalendar',['uses' => 'CalendarController@kalendar', 'as' => 'kalendar.kalendar']);
//php_sqlsrv_80_ts_x86.dll //php_sqlsrv_80_ts_x86.dll
Route::get('ajax/stafflist/{dept}',['uses' => 'MaintenanceController@loadstaff', 'as' => 'maintenance.loadstaff']); Route::get('ajax/stafflist/{dept}',['uses' => 'MaintenanceController@loadstaff', 'as' => 'maintenance.loadstaff']);
......
...@@ -32,35 +32,30 @@ class MaintenanceController extends Controller ...@@ -32,35 +32,30 @@ class MaintenanceController extends Controller
{ {
$chargeable = 1; $chargeable = 1;
$project = Project::where('p_project_type', $chargeable) $project = Project::where('p_project_type', $chargeable)
->with('projectDirector')
->with('projectManager')
->get(); ->get();
$projectlist = []; $projectlist = [];
// nanti project code query dari table project: // nanti project code query dari table project:
if(count($project) > 0) { if(count($project) > 0) {
foreach ($project as $key => $value){ foreach ($project as $key => $value){
$pm = Pteam::where('fk_project_id', $value->id)
->where('role_id', 1)
->where('pt_project_task_sts', 1)
->first();
// dd($pm->pt_team);
$projectlist[] = [ $projectlist[] = [
'id' => $value->id, 'id' => $value->id,
'projectcode' => $value->p_project_code, 'projectcode' => $value->p_project_code,
'projectname' => $value->p_project_description, 'projectname' => $value->p_project_description,
'projectmanager' => $pm->pt_team, 'projectmanager' => $value->projectManager->fullname,
'projectdirector'=> $value->projectDirector->fullname,
'status' => $value->p_project_sts, 'status' => $value->p_project_sts,
]; ];
} }
} }
else else
{ {
$projectlist = []; $projectlist = [];
} }
return view('timesheet::maintenance.senaraiProject',compact('projectlist')); return view('timesheet::maintenance.senaraiProject',compact('projectlist'));
...@@ -73,14 +68,15 @@ class MaintenanceController extends Controller ...@@ -73,14 +68,15 @@ class MaintenanceController extends Controller
->where('status', 1) ->where('status', 1)
->get(); ->get();
// dd($pm); $pd = Staff_info::whereIn('id', [45, 46, 47])
return view('timesheet::maintenance.penambahanProject', compact('pm')); ->get();
return view('timesheet::maintenance.penambahanProject', compact('pm', 'pd'));
} }
public function addnewproject(Request $request) public function addnewproject(Request $request)
{ {
$chargeable = 1; $chargeable = 1;
$nonchargeable = 2;
$userId = users::find(Auth::id()) $userId = users::find(Auth::id())
->u_staffID; ->u_staffID;
...@@ -91,40 +87,39 @@ class MaintenanceController extends Controller ...@@ -91,40 +87,39 @@ class MaintenanceController extends Controller
->withErrors('The information is not complete. Please re-enter!'); ->withErrors('The information is not complete. Please re-enter!');
} else { } else {
// dd($request);
$project = new Project; $project = new Project;
$project->p_project_code = $request->projectcode; $project->p_project_code = $request->projectcode;
$project->p_project_description = $request->projectname; $project->p_project_description = $request->projectname;
$project->p_project_type = $chargeable; $project->p_project_type = $chargeable;
$project->p_project_task_team = $request->projectmanager; $project->p_project_task_team = $request->projectmanager;
$project->p_project_director = $request->projectdirector;
$project->p_project_sts = $request->status; $project->p_project_sts = $request->status;
$project->updated_by = $userId; $project->updated_by = $userId;
$project->save(); $project->save();
$noncharge = new Project; $project = Project::where('p_project_code', $request->projectcode)
$noncharge->p_project_description = $request->projectname; ->with('projectDirector')
$noncharge->p_project_type = $nonchargeable; ->with('projectManager')
$noncharge->p_project_sts = $request->status; ->first();
$noncharge->updated_by = $userId;
$noncharge->save();
$projectId = Project::select('id')
->where('p_project_code', $request->projectcode)
->value('id');
$sname = Staff_info::select('fullname')
->where('staff_id', $request->projectmanager)
->value('fullname');
// dd($projectId);
$team = new Pteam; $team = new Pteam;
$team->role_id = 1; $team->role_id = 1;
$team->pt_project_description = $request->projectname; $team->pt_project_description = $request->projectname;
$team->fk_project_id = $projectId; $team->fk_project_id = $project->id;
$team->pt_staff_id = $request->projectmanager; $team->pt_staff_id = $project->projectManager->staff_id;
$team->pt_team = $sname; $team->pt_team = $project->projectManager->fullname;
$team->pt_project_type = $chargeable;
$team->pt_project_task_sts = 1;
$team->updated_by = $userId;
$team->save();
$team = new Pteam;
$team->role_id = 7;
$team->pt_project_description = $request->projectname;
$team->fk_project_id = $project->id;
$team->pt_staff_id = $project->projectDirector->staff_id;
$team->pt_team = $project->projectDirector->fullname;
$team->pt_project_type = $chargeable; $team->pt_project_type = $chargeable;
$team->pt_project_task_sts = 1; $team->pt_project_task_sts = 1;
$team->updated_by = $userId; $team->updated_by = $userId;
......
...@@ -18,6 +18,11 @@ class Project extends Model ...@@ -18,6 +18,11 @@ class Project extends Model
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','p_project_task_team'); return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','p_project_task_team');
} }
public function projectDirector()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','id','p_project_director');
}
public function projectTeam() public function projectTeam()
{ {
return $this->hasOne('Portal\Timesheet\Model\Pteam','fk_project_id','id'); return $this->hasOne('Portal\Timesheet\Model\Pteam','fk_project_id','id');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment