/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::all(); $validation = Validator::make($input, Task::$rules); if ($validation->passes()) { $this->task->create($input); Queue::push(function ($job) { Log::info('Do something when task is created.'); $job->delete(); }); return Redirect::route('tasks.index'); } return Redirect::route('tasks.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.'); }
protected function handleRequest(array $request) { $listId = $request[self::FIELD_LIST_ID]; $title = $request[self::FIELD_TITLE]; $description = $request[self::FIELD_DESCRIPTION]; $beforeId = $request[self::FIELD_BEFORE_TASK_ID]; if (isset($request[self::FIELD_AFTER_LAST_OPEN])) { if ($request[self::FIELD_AFTER_LAST_OPEN]) { $beforeId = Task::findNextTaskIdAfterLastOpenTask($listId); } } TasksList::lock($listId); $ord = null; if ($beforeId) { $beforeTask = Task::fetch($beforeId); if ($beforeTask->getListId() !== $listId) { throw new Exception("Insertion point for a new task is in another list", EndPoint::STATUS_BAD_REQUEST); } $ord = $beforeTask->getOrd(); Task::shiftRight($listId, $ord); } else { $ord = Task::getNextOrd($listId); } $taskId = Task::create($listId, $ord, $title, $description); return array(self::FIELD_TASK_ID => $taskId); }
/** * (non-PHPdoc) * @see DetailsPageAbstract::saveItem() */ public function saveItem($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); $task = null; if (isset($param->CallbackParameter->id) && !($task = Task::get(trim($param->CallbackParameter->id))) instanceof Task) { throw new Exception('Invalid Task passed in!'); } if (!isset($param->CallbackParameter->instructions) || ($instructions = trim($param->CallbackParameter->instructions)) === '') { throw new Exception('Instructions are required!'); } if (!isset($param->CallbackParameter->customerId) || !($customer = Customer::get(trim($param->CallbackParameter->customerId))) instanceof Customer) { throw new Exception('Invalid Customer Passed in!'); } $tech = isset($param->CallbackParameter->techId) ? UserAccount::get(trim($param->CallbackParameter->techId)) : null; $order = isset($param->CallbackParameter->orderId) ? Order::get(trim($param->CallbackParameter->orderId)) : null; $dueDate = new UDate(trim($param->CallbackParameter->dueDate)); $status = isset($param->CallbackParameter->statusId) ? TaskStatus::get(trim($param->CallbackParameter->statusId)) : null; if (!$task instanceof Task) { $task = Task::create($customer, $dueDate, $instructions, $tech, $order); } else { $task->setCustomer($customer)->setDueDate($dueDate)->setInstructions($instructions)->setTechnician($tech)->setFromEntityId($order instanceof Order ? $order->getId() : '')->setFromEntityName($order instanceof Order ? get_class($order) : '')->setStatus($status)->save(); } // $results['url'] = '/task/' . $task->getId() . '.html?' . $_SERVER['QUERY_STRING']; $results['item'] = $task->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Task::create([]); } }
public function run() { $faker = Faker::create(); foreach (range(1, 100) as $index) { Task::create(['name' => $faker->text(10, 20), 'description' => $faker->text(140)]); } }
protected function handleRequest(array $request) { $version = $request[self::FIELD_PROTOCOL_VERSION]; $projectTitle = $request[self::FIELD_TITLE]; $projectDescription = $request[self::FIELD_DESCRIPTION]; $projectId = Project::create(Project::getNextOrd(), $projectTitle, $projectDescription); $listsRep = $request[self::FIELD_LISTS]; $listOrd = 0; foreach ($listsRep as $listRep) { $listTitle = $listRep[self::FIELD_TITLE]; $listId = TasksList::create($projectId, ++$listOrd, $listTitle); $tasksRep = $listRep[self::FIELD_TASKS]; $taskOrd = 0; foreach ($tasksRep as $taskRep) { $taskTitle = $taskRep[self::FIELD_TITLE]; $taskDescription = $taskRep[self::FIELD_DESCRIPTION]; $taskId = Task::create($listId, ++$taskOrd, $taskTitle, $taskDescription); if ($version > 1) { $taskStatus = $taskRep[self::FIELD_TASK_STATUS]; Task::updateStatus($taskId, $taskStatus); } } } return array(self::FIELD_PROJECT_ID => $projectId); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Project $project, Request $request) { $this->validate($request, $this->rules); $input = Input::all(); $input['project_id'] = $project->id; Task::create($input); return Redirect::route('projects.show', $project->slug)->with('message', 'Task created.'); }
public function store(Request $request) { $this->validate($request, ['title' => 'required', 'description' => 'required']); $input = $request->all(); Task::create($input); Session::flash('flash_message', 'Task successfully added!'); return redirect()->back(); }
public function run() { Model::unguard(); $times = 5; for ($i = 0; $i < $times; $i++) { Task::create(array('name' => Str::random(), 'active' => rand(0, 1))); } }
/** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); // $this->call('UserTableSeeder'); DB::table('users')->truncate(); User::create(['username' => 'Sampler', 'email' => '*****@*****.**', 'password' => 'sample', 'password_confirmation' => 'sample', 'confirmed' => true]); DB::table('tasks')->truncate(); Task::create(['user_id' => 1, 'book_id' => 1, 'order_no' => 1, 'status' => 1, 'name' => 'sample_name', 'message' => 'sample_message', 'doing_at' => 'now()', 'pomo' => 1]); }
public function create() { Log::debug(__METHOD__); // Log::debug(print_r(Input::all(), true)); $task = Task::create(['user_id' => Auth::user()->id, 'book_id' => Book::getIdInMessage(Auth::user(), Input::get('message')), 'status' => Task::$status_table[Input::get('priority', 'todo_m')], 'name' => Auth::user()->username, 'message' => Input::get('message')]); $moveId = $this->isMovedFromBook($task) ? $task->id : 0; $taskHtml = View::make('tasks._task')->with(['task' => $task, 'display' => 'none', 'done' => false])->render(); return Response::json(['id' => $task->id, 'status' => $task->statusSymbol(), 'li_html' => $taskHtml, 'move_task_id' => $moveId, 'task_counts' => $this->getTaskCounts(), 'all_books' => $this->getAllBookCounts()])->setCallback('addTodoResponse'); }
/** * Store a newly created resource in storage. * POST /tasks * * @return Response */ public function store() { $tasks = Task::create(Input::all()); if ($tasks) { return ['status' => true, 'data' => $tasks]; } else { return ['status' => false]; } }
public function store() { //add the task if (!Task::taskIsValid(Input::all())) { return Redirect::back()->withInput()->withErrors(Task::$errors); } $addTasks = Task::create(Input::all()); $addTasks->complaint = 'No complaints so far.'; $addTasks->save(); return Redirect::route('tasks.index'); }
public function index() { $task = new Task(); $task->text = 'Tar'; $task->duedate = new Date(); $task->checkb = '0'; $result = $task->create(); if (!$result) { throw new Exception('Error al insertar registro.'); } }
public function run() { Task::truncate(); $faker = Faker::create(); foreach (range(1, 100) as $index) { $numb = array(1, 2, 3, 4); $numbs = array(1, 2); $nums = $numbs[array_rand($numbs)]; $num = $numb[array_rand($numb)]; Task::create(['title' => $faker->sentence, 'description' => $faker->paragraph(3), 'category_id' => $nums, 'employee_id' => $num, 'complaint' => 'No complaints so far.']); } }
/** * create a task instance. * * @param string $name * @param mixed $data * @param \Closure|null $callback * * @return null|Task */ public static function task($name, $data = null, \Closure $callback = null) { $task = self::getTask($name); if (!$task) { if (is_callable($data)) { $callback = $data; $data = null; } $task = Task::create($name, $data, $callback); self::$tasks[$name] = $task; } return $task; }
function CreateTask($data, $fields) { try { $task = new Task(); $result = $task->create($fields); $this->domain->addDomainValue('CREATED', $task->getTasUid()); return $result; } catch (Exception $e) { $result = array('Exception!! ' => $e->getMessage()); if (isset($e->aValidationFailures)) { $result['ValidationFailures'] = $e->aValidationFailures; } return $result; } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $rules = array('title' => 'required|min:3', 'description' => 'required|min:3', 'start_at' => 'required|date|date_format:Y-m-d|after:yesterday', 'priority_id' => 'required|numeric'); $messages = ['start_at.after' => 'The starting date is invalid.']; $this->status_id = 1; //The status is Active $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->passes()) { $task = Task::create(Input::except('_token')); Event::fire('task', [$task->id, 'created']); return Redirect::to('tasks')->with('success', 'Task created successfully'); } else { return Redirect::to('tasks/create')->withErrors($validator)->withInput(); } }
public function dopublish() { $id = intval(Input::get('id')); $this->check_own($id); $project = Project::find($id); if (!$id || !$project) { return Response::json(array("result" => false, 'msg' => '项目不存在')); } $version = trim(Input::get('project_select_version')); if (!preg_match('/^\\w+$/i', $version)) { return Response::json(array("result" => false, 'msg' => '请选择正确的版本')); } $task_ids = array('upd_prj' => '', 'sync_svr' => array()); $task_ids['upd_prj'] = Task::create('update', Auth::id(), array('project_id' => $id, "version" => $version)); $servers_id = Input::get('publish_box'); $servers = Server::whereIn("id", $servers_id)->get(); foreach ($servers as $key => $value) { if ($value->project_id != $id) { //检查服务器是不是属于project continue; } $task_ids['sync_svr'][$value->id] = Task::create('rsync', Auth::id(), array('server_id' => $value->id), $task_ids['upd_prj']); } return Response::json(array("result" => true, 'msg' => '', 'tasks' => $task_ids)); }
protected function createTask() { $task = new Task(); $task->create(); }
/** * addSubProcess * * @param string $sProcessUID * @param integer $iX * @param integer $iY * @return void */ public function addSubProcess($sProcessUID = '', $iX = 0, $iY = 0) { try { $oTask = new Task(); $oNewTask->label = 'Sub-Process'; //G::LoadTranslation('ID_TASK'); $oNewTask->uid = $oTask->create(array('PRO_UID' => $sProcessUID, 'TAS_TITLE' => $oNewTask->label, 'TAS_POSX' => $iX, 'TAS_POSY' => $iY, 'TAS_TYPE' => 'SUBPROCESS')); //$oJSON = new Services_JSON(); $oOP = new SubProcess(); $aData = array('SP_UID' => G::generateUniqueID(), 'PRO_UID' => 0, 'TAS_UID' => 0, 'PRO_PARENT' => $sProcessUID, 'TAS_PARENT' => $oNewTask->uid, 'SP_TYPE' => 'SIMPLE', 'SP_SYNCHRONOUS' => 0, 'SP_SYNCHRONOUS_TYPE' => 'ALL', 'SP_SYNCHRONOUS_WAIT' => 0, 'SP_VARIABLES_OUT' => '', 'SP_VARIABLES_IN' => '', 'SP_GRID_IN' => ''); $oOP->create($aData); return Bootstrap::json_endoce($oNewTask); //$oJSON->encode( $oNewTask ); } catch (Exception $oError) { throw $oError; } }
/** Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone * @param int $project_id Id of project to attach clone task * @param int $parent_task_id Id of task to attach clone task * @param bool $clone_change_dt recalculate date of task regarding new project start date * @param bool $clone_affectation clone affectation of project * @param bool $clone_time clone time of project * @param bool $clone_file clone file of project * @param bool $clone_note clone note of project * @param bool $clone_prog clone progress of project * @return int New id of clone */ function createFromClone($fromid,$project_id,$parent_task_id,$clone_change_dt=false,$clone_affectation=false,$clone_time=false,$clone_file=false,$clone_note=false,$clone_prog=false) { global $user,$langs,$conf; $error=0; $now=dol_now(); $datec = $now; $clone_task=new Task($this->db); $this->db->begin(); // Load source object $clone_task->fetch($fromid); $ori_project_id = $clone_task->fk_project; $clone_task->id = 0; $clone_task->fk_project = $project_id; $clone_task->fk_task_parent = $parent_task_id; $clone_task->date_c = $datec; //Manage Task Date if ($clone_change_dt) { $projectstatic=new Project($this->db); $projectstatic->fetch($ori_project_id); //Origin project strat date $orign_project_dt_start = $projectstatic->date_start; //Calcultate new task start date with difference between origin proj start date and origin task start date if (!empty($clone_task->date_start)) { $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start; } //Calcultate new task end date with difference between origin proj end date and origin task end date if (!empty($clone_task->date_end)) { $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start; } } if (!$clone_prog) { $clone_task->progress=0; } // Create clone $result=$clone_task->create($user); // Other options if ($result < 0) { $this->error=$clone_task->error; $error++; } // End if (! $error) { $this->db->commit(); $clone_task_id=$clone_task->id; //Note Update if (!$clone_note) { $clone_task->note_private=''; $clone_task->note_public=''; } else { $this->db->begin(); $res=$clone_task->update_note_public(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES)); if ($res < 0) { $this->error.=$clone_task->error; $error++; $this->db->rollback(); } else { $this->db->commit(); } $this->db->begin(); $res=$clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES)); if ($res < 0) { $this->error.=$clone_task->error; $error++; $this->db->rollback(); } else { $this->db->commit(); } } //Duplicate file if ($clone_file) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); //retreive project origin ref to know folder to copy $projectstatic=new Project($this->db); $projectstatic->fetch($ori_project_id); $ori_project_ref=$projectstatic->ref; if ($ori_project_id!=$project_id) { $projectstatic->fetch($project_id); $clone_project_ref=$projectstatic->ref; } else { $clone_project_ref=$ori_project_ref; } $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref). "/" . dol_sanitizeFileName($clone_task_id); $ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref). "/" . dol_sanitizeFileName($fromid); $filearray=dol_dir_list($ori_task_dir,"files",0,'','\.meta$','',SORT_ASC,1); foreach($filearray as $key => $file) { if (!file_exists($clone_task_dir)) { if (dol_mkdir($clone_task_dir) < 0) { $this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; $error++; } } $rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'],0,1); if (is_numeric($rescopy) && $rescopy < 0) { $this->error.=$langs->trans("ErrorFailToCopyFile",$ori_task_dir . '/' . $file['name'],$clone_task_dir . '/' . $file['name']); $error++; } } } // clone affectation if ($clone_affectation) { $origin_task = new Task($this->db); $origin_task->fetch($fromid); foreach(array('internal','external') as $source) { $tab = $origin_task->liste_contact(-1,$source); $num=count($tab); $i = 0; while ($i < $num) { $clone_task->add_contact($tab[$i]['id'], $tab[$i]['code'], $tab[$i]['source']); if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $this->error.=$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); $error++; } else { if ($clone_task->error!='') { $this->error.=$clone_task->error; $error++; } } $i++; } } } if($clone_time) { //TODO clone time of affectation } if (! $error) { return $clone_task_id; } else { dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : " . $this->error, LOG_ERR); return -1; } } else { $this->db->rollback(); return -1; } }
/** * Execute the console command. * * @return mixed */ public function fire() { Task::create(['name' => 'Dummy Task', 'description' => 'Task added on ' . Carbon::now()]); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(UserRequest $request) { Task::create($request->all()); return redirect('tasks'); }
/** * Create WebEntry * * @param string $projectUid Unique id of Project * @param string $eventUid Unique id of Event * @param string $activityUid Unique id of Activity * @param string $dynaFormUid WebEntry, unique id of DynaForm * @param string $userUid WebEntry, unique id of User * @param string $title WebEntry, title * @param string $description WebEntry, description * @param string $userUidCreator WebEntry, unique id of creator User * * return void */ public function createWebEntry($projectUid, $eventUid, $activityUid, $dynaFormUid, $userUid, $title, $description, $userUidCreator) { try { $bpmn = new \ProcessMaker\Project\Bpmn(); $arrayEventData = $bpmn->getEvent($eventUid); //Task $task = new \Task(); $prefix = "wee-"; $this->webEntryEventWebEntryTaskUid = $task->create(array("TAS_UID" => $prefix . substr(\ProcessMaker\Util\Common::generateUID(), (32 - strlen($prefix)) * -1), "PRO_UID" => $projectUid, "TAS_TYPE" => "WEBENTRYEVENT", "TAS_TITLE" => "WEBENTRYEVENT", "TAS_START" => "TRUE", "TAS_POSX" => (int) $arrayEventData["BOU_X"], "TAS_POSY" => (int) $arrayEventData["BOU_Y"]), false); //Task - Step $step = new \Step(); $stepUid = $step->create(array("PRO_UID" => $projectUid, "TAS_UID" => $this->webEntryEventWebEntryTaskUid)); $result = $step->update(array("STEP_UID" => $stepUid, "STEP_TYPE_OBJ" => "DYNAFORM", "STEP_UID_OBJ" => $dynaFormUid, "STEP_POSITION" => 1, "STEP_MODE" => "EDIT")); //Task - User $task = new \Tasks(); $result = $task->assignUser($this->webEntryEventWebEntryTaskUid, $userUid, 1); //Route $workflow = \ProcessMaker\Project\Workflow::load($projectUid); $result = $workflow->addRoute($this->webEntryEventWebEntryTaskUid, $activityUid, "SEQUENTIAL"); //WebEntry $arrayWebEntryData = $this->webEntry->create($projectUid, $userUidCreator, array("TAS_UID" => $this->webEntryEventWebEntryTaskUid, "DYN_UID" => $dynaFormUid, "USR_UID" => $userUid, "WE_TITLE" => $title, "WE_DESCRIPTION" => $description, "WE_METHOD" => "WS", "WE_INPUT_DOCUMENT_ACCESS" => 1)); $this->webEntryEventWebEntryUid = $arrayWebEntryData[$this->getFieldNameByFormatFieldName("WE_UID")]; } catch (\Exception $e) { throw $e; } }
if (empty($projectid)) $projectid = $_POST["id"]; // If projectid is '' $task_parent=$tmparray[1]; if (empty($task_parent)) $task_parent = 0; // If task_parent is '' $task = new Task($db); $task->fk_project = $projectid; $task->label = $_POST["label"]; $task->description = $_POST['description']; $task->fk_task_parent = $task_parent; $task->date_c = dol_now(); $task->date_start = $date_start; $task->date_end = $date_end; $task->progress = $_POST['progress']; $taskid = $task->create($user); if ($taskid > 0) { $result = $task->add_contact($_POST["userid"], 'TASKEXECUTIVE', 'internal'); } } if (! $error) { if (empty($projectid)) { Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($_REQUEST["mode"])?'':'?mode='.$_REQUEST["mode"])); exit; } else
<ul class="list-group" id="rank-faculty-student-list"> <li class="list-group-item">Emile Eric</li> <li class="list-group-item">Tamara Naumovic</li> <li class="list-group-item">Mila Marjanovic</li> <li class="list-group-item">Ana Licina</li> </ul> </div> <!-- kraj donje strane modala--> <?php if (isset($_POST['add_task'])) { include "task.class.php"; include "user.class.php"; $task = new Task(); $user = new User(); $task->create($_POST, $user->findUser($_SESSION['id'])); echo $task->writeToDb(); } ?> </div> </div> </div> </div> <!-- kraj modala--> <!-- pocetak desne strane--> <div class="col-md-1" style="padding-top:2%;"></div> <div class="col-md-1" style="padding-top:2%;"></div> <!-- kraj desne strane-->
/** * * @param unknown $object */ static function createTasks(&$object) { global $conf, $langs, $db, $user; if (!empty($conf->global->GRAPEFRUIT_PROJECT_AUTO_ADD_TASKS_ON_CREATE)) { $TLabel = explode("\n", $conf->global->GRAPEFRUIT_PROJECT_AUTO_ADD_TASKS_ON_CREATE); dol_include_once('/projet/class/task.class.php'); foreach ($TLabel as $label) { $label = trim($label); $t = new Task($db); $defaultref = ''; $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) { require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php'; $modTask = new $obj(); $defaultref = $modTask->getNextValue($soc, $object); } if (is_numeric($defaultref) && $defaultref <= 0) { $defaultref = ''; } $t->ref = $defaultref; $t->label = $label; $t->fk_project = $object->id; $t->fk_task_parent = 0; $res = $t->create($user); if ($res < 0) { setEventMessage($langs->trans('ImpossibleToAdd', $label)); } } setEventMessage($langs->trans('autoTasksAdded')); } }
public function store(Request $request) { $input = $request->all(); Task::create($input); return redirect()->back(); }
private function addOrUpdateTasks($id, $task){ try{ $data = \Task::find($id); }catch (\ActiveRecord\RecordNotFound $ex) { $data = null; } $attributes = $this->getTaskAttributes($task); if(is_null($data)){ $data = \Task::create($attributes); if(!is_null($data)){ $id = $data->id; } }else{ $data->update_attributes($attributes); } return $id; }