public function getApproveTransfer($id)
 {
     $date = DateTime::createFromFormat('d-m-Y', date("d-m-Y"));
     $dateNow = $date->format('Y-m-d');
     $primary = PropTransReq::where('properties_id', $id)->pluck('id');
     $hId = PropertiesUser::where('properties_id', $id)->pluck('history_id');
     $oldOwner = PropertiesUser::where('properties_id', $id)->pluck('user_id');
     $history = PropertiesHistory::find($hId);
     $property = Properties::find($id);
     $request = PropTransReq::find($primary);
     $dept = User::find($request->user_id);
     $par = uniqid('PAR-');
     $property->update(['par' => $par]);
     $history->update(['details' => 'Transferred', 'enddate' => $dateNow]);
     $history = new PropertiesHistory();
     $history->propstatus = 'Transferred';
     $history->par = $par;
     $history->from = $oldOwner;
     $history->property()->associate($property);
     $history->user()->associate(User::find($request->user_id));
     $history->save();
     //-------------------------
     $lastid = PropertiesHistory::orderBy('id', 'desc')->first();
     $approve = PropertiesUser::where('properties_id', $id)->update(array('user_id' => $request->user_id, 'history_id' => $lastid->id, 'dept_id' => $dept->department_id));
     $request->delete();
     //PropTransReq
     return Redirect::route('transfer-requests')->with('alert', 'success|Transfer Request Approved');
 }
示例#2
0
 public function postRequestTransferProp()
 {
     $propertyid = Input::get('propertyid');
     $empid = Input::get('empid');
     if (!empty($propertyid)) {
         $property = PropTransReq::where('properties_id', $propertyid)->first();
         $propinfo = PropertiesUser::where('properties_id', $propertyid)->first();
         if (!empty($property)) {
             return Redirect::route('request-transfer-prop')->with('alert', 'danger|You can only request transfer this property once');
         }
     } else {
         return Redirect::route('request-transfer-prop')->with('alert', 'danger|Please choose a property');
     }
     $request = PropTransReq::create(['user_id' => $empid, 'properties_id' => $propertyid, 'cat_id' => $propinfo->cat_id, 'dept_id' => $propinfo->dept_id]);
     $user = User::find(Auth::id());
     if ($user->gender == 'Male') {
         $gender = 'his';
     } else {
         $gender = 'her';
     }
     $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'User', 'action' => 'requested for Property transfer to.']);
     return Redirect::route('request-transfer-prop')->with('alert', 'success|Transfer requested');
 }