2019-02-12 11:21:35 +00:00
|
|
|
<?php
|
|
|
|
namespace App\Http\Controllers\Settings;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
// use App\Http\Requests\ProjectRequest;
|
|
|
|
// use App\Models\Project;
|
|
|
|
// use Illuminate\Http\RedirectResponse;
|
|
|
|
// use Illuminate\Http\Request;
|
|
|
|
use App\Models\Dataset;
|
|
|
|
use Illuminate\View\View;
|
2019-02-21 13:07:00 +00:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2019-02-12 11:21:35 +00:00
|
|
|
|
|
|
|
class WorkflowController extends Controller
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//$this->middleware('auth');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2019-02-21 13:07:00 +00:00
|
|
|
public function review()
|
2019-02-12 11:21:35 +00:00
|
|
|
{
|
|
|
|
$builder = Dataset::query();
|
|
|
|
$datasets = $builder
|
|
|
|
//->where('server_state', 'inprogress')
|
|
|
|
->whereIn('server_state', ['unpublished'])
|
|
|
|
->get();
|
2019-02-21 13:07:00 +00:00
|
|
|
return view('workflow.review', compact('datasets'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function release()
|
|
|
|
{
|
|
|
|
$user = Auth::user();
|
|
|
|
$user_id = $user->id;
|
|
|
|
|
|
|
|
$builder = Dataset::query();
|
|
|
|
$datasets = $builder
|
|
|
|
->where('server_state', 'inprogress')
|
|
|
|
->where('account_id', $user_id)
|
|
|
|
->get();
|
|
|
|
return view('workflow.release', compact('datasets'));
|
2019-02-12 11:21:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function changestate($id, $targetState)
|
|
|
|
{
|
|
|
|
// $docId = $this->getRequest()->getParam('docId');
|
|
|
|
// $targetState = $this->getRequest()->getParam('targetState');
|
|
|
|
|
|
|
|
//$document = $this->_documentsHelper->getDocumentForId($docId);
|
|
|
|
$dataset = Dataset::findOrFail($id);
|
|
|
|
|
|
|
|
// Check if valid target state
|
|
|
|
// if (!$this->_workflowHelper->isValidState($targetState)) {
|
|
|
|
|
|
|
|
// }
|
|
|
|
try {
|
|
|
|
//$this->_workflowHelper->changeState($document, $targetState);
|
|
|
|
$dataset->setServerState($targetState);
|
|
|
|
|
2019-02-15 12:55:14 +00:00
|
|
|
if ($targetState == 'published') {
|
|
|
|
//$this->_sendNotification($document, $form);
|
|
|
|
$time = new \Illuminate\Support\Carbon();
|
|
|
|
$dataset->server_date_published = $time;
|
2019-02-21 13:07:00 +00:00
|
|
|
session()->flash('flash_message', 'You have puplished 1 dataset!');
|
2019-02-15 12:55:14 +00:00
|
|
|
}
|
2019-02-12 11:21:35 +00:00
|
|
|
$dataset->save();
|
2019-02-21 13:07:00 +00:00
|
|
|
return redirect()->back();
|
|
|
|
//return redirect()->route('settings.review.index');
|
2019-02-12 11:21:35 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
//return $this->_redirectTo('index', array('failure' => $e->getMessage()), 'documents', 'admin');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|