public static function updateWorkflows($id, $nuevosWorkflows)
 {
     workflow::where("deleted", "=", 0)->join("Estado as ea", "ea.idEstado", "=", "idEstadoActual")->join("Estado as es", "es.idEstado", "=", "idEstadoSiguiente")->where(function ($query) use($id) {
         return $query->where("ea.idTipoItem", "=", $id)->orWhere("es.idTipoItem", "=", $id);
     })->update(['deleted' => 1]);
     foreach ($nuevosWorkflows as $workflow) {
         $workflowDB = workflow::buscarPorEstados($workflow->idEstadoActual, $workflow->idEstadoSiguiente)->first();
         if (!is_null($workflowDB)) {
             $workflowDB->deleted = 0;
             $workflowDB->save();
         } else {
             $workflow->save();
         }
     }
 }
예제 #2
0
    }
    return $response->withJson($dataResponse);
});
$app::Router()->get($app->path('tipoitem_workflow'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $estados = EstadoController::getByItemTypeId($parse->get('id'));
    $workflows = TipoItemController::getWorkflows($parse->get('id'));
    $resultado = ["estados" => $estados, "workflows" => $workflows];
    echo json_encode($resultado);
});
$app::Router()->post($app->path('workflow_update'), function (Request $request, Response $response, $args) {
    $workflows = new Eloquent\Collection();
    $body = file_get_contents("php://input");
    $body_params = json_decode($body);
    foreach ($body_params->workflows as $workflow) {
        $item = new Workflow();
        $item->estadoActual()->associate($workflow->idEstadoActual);
        $item->estadoSiguiente()->associate($workflow->idEstadoSiguiente);
        $workflows->add($item);
    }
    TipoItemController::updateWorkflows($body_params->idItemType, $workflows);
    json_encode(true);
});
$app::Router()->get($app->path('states_tipoitem'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $estados = EstadoController::getByItemTypeId($parse->get('id'));
    $workflows = TipoItemController::getWorkflows($parse->get('id'));
    $resultado = ["estados" => $estados, "workflows" => $workflows];
    echo json_encode($resultado);
});
$app::Router()->get($app->path('equipos_atencion'), function (Request $request, Response $response, $args) {