/** * create new batch task * @return mixed */ public function create() { $data = Input::all(); $batchData = []; $dataTypeValidator = Validator::make(Input::all(), ['dataType' => 'required']); if ($dataTypeValidator->fails()) { return Redirect::back()->withInput()->with('alert-danger', 'Data type is missing!'); } $dataType = $data['dataType']; $rules = ['startDateTime', 'endDateTime']; if ($dataType == "WATER") { $rules[] = 'waterProblemType'; } elseif ($dataType == "RAIN") { $rules[] = 'rainProblemType'; } if (!isset($data['allStation'])) { $rules[] = 'stations'; } foreach ($rules as $r) { if (!isset($data[$r])) { return Redirect::back()->withInput()->with('alert-danger', $r . ' is incomplete!'); } } if ($data['startDateTime'] == "" or $data['endDateTime'] == "") { return Redirect::back()->withInput()->with('alert-danger', 'Date is incomplete!'); } $batchData['data_type'] = $data['dataType']; if ($batchData['data_type'] == "WATER") { $batchData['problem_type'] = $data['waterProblemType']; } elseif ($batchData['data_type'] == "RAIN") { $batchData['problem_type'] = $data['rainProblemType']; } if (isset($data['allStation'])) { $batchData['all_station'] = true; } else { $batchData['all_station'] = false; $batchData['stations'] = $data['stations']; } $batchData['start_datetime'] = Date($data['startDateTime']); $batchData['end_datetime'] = Date($data['endDateTime']); $batchData['add_datetime'] = Date('Y-m-d H:i:s'); $batch = Batch::create($batchData); Queue::push('BatchController', ['id' => $batch->id]); return Redirect::to('batch')->with('alert-success', 'Task #' . $batch->id . ' Added Successfully.'); }
/** * @param integer $number_of_batches * @return string * @throws BaseUserAccessDeniedException * @throws BaseBatchInvalidArgumentException */ public static function start_test_handler($number_of_batches) { global $user; if ($user->is_admin()) { if (is_numeric($number_of_batches) and $number_of_batches >= 1) { for ($i = 1; $i <= $number_of_batches; $i++) { $batch = new Batch(null); $batch->create(1); } return "1"; } else { throw new BaseBatchInvalidArgumentException(); } } else { throw new BaseUserAccessDeniedException(); } }
<?php require_once "../../includes/initialize.php"; global $session; if (!$session->is_logged_in()) { redirect_to("../../index.php"); } if ($_POST['oper'] == 'add') { $batch = new Batch(); $batch->comments = $_POST['comments']; $batch->about = $_POST['about']; $batch->pending = $_POST['pending']; $batch->enabled = $_POST['enabled']; $batch->fromyear = $_POST['fromyear']; $batch->schoolid = $_POST['schoolid']; $batch->create(); $batchuser = new BatchUser(); $batchuser->pending = 0; $batchuser->enabled = 1; $batchuser->schoolid = $batch->schoolid; $batchuser->batchid = $batch->id; $batchuser->userid = $session->user_id; $batchuser->level = 1; $batchuser->create(); $folder_path = "../../public/schools/" . $batch->schoolid . "/yearbooks/" . $batch->id . "/"; mkdir($folder_path, 0700); mkdir($folder_path . "pages", 0700); mkdir($folder_path . "files", 0700); copy("../../public/index.php", $folder_path . "/pages/index.php"); copy("../../public/page1.html", $folder_path . "/pages/page1.html"); $log = new Log($session->user_id, $clientip, "WEB", "CREATED BATCH: " . $_POST['id']);
if (!Batch::batch_exists($_POST['fromyear'], $school->id)) { $object = new Batch(); $object->fromyear = $_POST['fromyear']; $object->about = $_POST['about']; $object->comments = $_POST['comments']; $object->fbcomments = $_POST['fbcomments']; $object->schoolid = $school->id; $object->enabled = 1; $object->pending = 0; $object->pubdate = $_POST['pubdate']; $object->published = 0; $file = new File($_FILES['cover']); if ($file->valid) { $object->picture = $file->data; } $object->create(); $folder_path = "../../public/schools/" . $school->id . "/yearbooks/" . $object->id . "/"; mkdir($folder_path, 0700); mkdir($folder_path . "pages", 0700); mkdir($folder_path . "files", 0700); copy("../../public/0.students.php", $folder_path . "/pages/0.students.php"); copy("../../public/0.page1.html", $folder_path . "/pages/0.page1.html"); copy("../../public/11.Vision_and-Mission-Sample.html", $folder_path . "/pages/11.Vision_and-Mission-Sample.html"); copy("../../public/12.7.The_Achievers-Sample.html", $folder_path . "/pages/12.7.The_Achievers-Sample.html"); copy("../../public/22.Core_Values-Sample.html", $folder_path . "/pages/22.Core_Values-Sample.html"); copy("../../public/33.Message_of_the_City_Mayor-Sample.html", $folder_path . "/pages/33.Message_of_the_City_Mayor-Sample.html"); copy("../../public/44.3.History-Sample.html", $folder_path . "/pages/44.3.History-Sample.html"); copy("../../public/55.5.Message_of_the_Director-Sample.html", $folder_path . "/pages/55.5.Message_of_the_Director-Sample.html"); $batchuser = new BatchUser(); $batchuser->schoolid = $school->id; $batchuser->batchid = $object->id;
/** * Create a batch * * @param bool $stopJobOnError Should the batch be stopped on error? * @return Batch * @throws \Exception */ public function createBatch($stopJobOnError = false) { $batch = new Batch($this->api); $batch->create($stopJobOnError); return $batch; }
public function store(RegisterBatch $request) { Batch::create($request->all()); }