public function run()
 {
     Area::create(array('nombre' => 'Odontologías', 'descripcion' => 'Odontologías', 'tipo_ayuda_id' => '1'));
     Area::create(array('nombre' => 'Traumatología', 'descripcion' => 'Traumatología', 'tipo_ayuda_id' => '1'));
     Area::create(array('nombre' => 'Nefroligía', 'descripcion' => 'Nefroligía', 'tipo_ayuda_id' => '1'));
     Area::create(array('nombre' => 'Obstetricia', 'descripcion' => 'Obstetricia', 'tipo_ayuda_id' => '1'));
     Area::create(array('nombre' => 'Ginecología', 'descripcion' => 'Ginecología', 'tipo_ayuda_id' => '1'));
     Area::create(array('nombre' => 'Cirugía', 'descripcion' => 'Cirugía', 'tipo_ayuda_id' => '1'));
     Area::create(array('nombre' => 'Efectivo', 'descripcion' => 'Efectivo', 'tipo_ayuda_id' => '2'));
     Area::create(array('nombre' => 'Remodelaciones', 'descripcion' => 'Remodelaciones', 'tipo_ayuda_id' => '3'));
 }
Beispiel #2
0
 /**
  * Store a newly created area in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     $area = Area::create($data);
     $oc = Occupency::where('area_name', '=', $area->name)->first();
     $oc->sound_level = $area->sound;
     $oc->save();
     if ($area) {
         return Response::json(['error' => 'false', 'data' => $area->toArray()], 200);
     }
     return Response::json(['error' => 'true', 'message' => 'Could not create Area'], 400);
 }
Beispiel #3
0
 public function run()
 {
     Area::create(array('NombreArea' => 'Dirección', 'Objetivo_Id' => 1, 'Organigrama_Id' => 1));
     Area::create(array('NombreArea' => 'Subdirección Técnica', 'Objetivo_Id' => 2, 'Organigrama_Id' => 2));
     Area::create(array('NombreArea' => 'Subdirección de Posgrado', 'Objetivo_Id' => 5, 'Organigrama_Id' => 3));
     Area::create(array('NombreArea' => 'Subdirección de Vinculación y Apoyo', 'Objetivo_Id' => 6, 'Organigrama_Id' => 4));
     Area::create(array('NombreArea' => 'Departamento de Servicios Administrativos y Técnicos', 'Objetivo_Id' => 7, 'Organigrama_Id' => 5));
     Area::create(array('NombreArea' => 'Departamento de Sistemas y Banco de Datos', 'Objetivo_Id' => 8, 'Organigrama_Id' => 6));
     Area::create(array('NombreArea' => 'Sala de Juntas', 'Objetivo_Id' => 9));
     Area::create(array('NombreArea' => 'Biblioteca', 'Objetivo_Id' => 10));
     Area::create(array('NombreArea' => 'Vigilancia', 'Objetivo_Id' => 11));
     $this->command->info('AreaTableSeeder: Areas cargadas correctamente');
 }
Beispiel #4
0
 public function run()
 {
     Area::create(['name' => 'Coffee Room', 'sound' => '120', 'temperature' => '20']);
 }
/**
 * create one test case
 *
 * @param integer $case
 * @param integer $stopcase
 * @return mixed null after one stopcase, false after one branchcase, true after last case
 */
function create_case($case, $stopcase) {
	global $bcase, $date, $login, $proposal, $proposal2, $casetitle, $ngroup;

	$stop = 0;
	$branch = 0;
	$casedesc = $case." (stop: ".$stopcase.", branches:";
	foreach ($bcase as $value) $casedesc .= " ".$value;
	$casedesc .= ")";
	echo "Test case ".$casedesc."\n";

	Login::$member = $login;
	$proposal = null;
	$proposal2 = null;
	$casetitle = "";

	// create area
	$area = new Area;
	$area->ngroup = $ngroup->id;
	$area->name = "Test area case ".$casedesc;
	$area->create();

	// create new proposal
	$proposal = new Proposal;
	$proposal->title = "Test ".$date." case ".$casedesc;
	$proposal->content = "Test content";
	$proposal->reason = "Test reason";
	$proposal->create("Test proponent ".$date." proposal case ".$casedesc, $area->id);
	$proponents = array(Login::$member);

	if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
		$casetitle = "draft";
		return;
	}

	$issue = $proposal->issue();

	if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
		$proposal->remove_proponent(Login::$member);
		cron();
		$casetitle = "remove proponent from draft";
		return;
	}

	if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
		$proposal->remove_proponent(Login::$member);
		time_warp($issue, "1 week");
		cron();
		$casetitle = "remove proponent from draft and finally revoke proposal";
		return;
	}

	if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
		$proposal->remove_proponent(Login::$member);
		add_proponent($proposal, "px");
		time_warp($issue, "1 week");
		cron();
		$casetitle = "remove proponent from draft, add new proponent";
		return;
	}

	// add proponents
	for ( $i=2; $i<=REQUIRED_PROPONENTS; $i++ ) {
		add_proponent($proposal, "pi".$i);
		$proponents[] = Login::$member;
	}

	if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
		$casetitle = "draft with proponents";
		return;
	}

	$proposal->submit();

	if ($proposal->state=="submitted") {

		if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
			foreach ($proponents as $proponent) {
				$proposal->remove_proponent($proponent);
			}
			cron();
			$casetitle = "remove all proponents from submitted proposal";
			return;
		}

		if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
			foreach ($proponents as $proponent) {
				$proposal->remove_proponent($proponent);
			}
			for ( $i=1; $i<=REQUIRED_PROPONENTS-1; $i++ ) {
				add_proponent($proposal, "pr".$i);
			}
			time_warp($issue, "1 week");
			cron();
			$casetitle = "remove all proponents from submitted proposal, add less than required new proponents and finally revoke proposal";
			return;
		}

		if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
			foreach ($proponents as $proponent) {
				$proposal->remove_proponent($proponent);
			}
			for ( $i=1; $i<=REQUIRED_PROPONENTS; $i++ ) {
				add_proponent($proposal, "pr".$i);
			}
			time_warp($issue, "1 week");
			cron();
			$casetitle = "remove all proponents from submitted proposal, add sufficient new proponents";
			return;
		}

		$required_supporters = $proposal->quorum_required();

		${'branch'.++$branch.'_array'} = array(0, $required_supporters-1, $required_supporters);
		$supporter_count = ${'branch'.$branch.'_array'}[$bcase[$branch]];

		for ( $i=1; $i<=$supporter_count-REQUIRED_PROPONENTS; $i++ ) {
			add_supporter($proposal, "a".$i);
		}

		if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
			$casetitle = "alternative proposal with $supporter_count supporters";
			return;
		}

		if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
			time_warp($issue, CANCEL_NOT_ADMITTED_INTERVAL);
			cron();
			$casetitle = "cancel long time not admitted proposal";
			return;
		}

		// create alternative proposal
		$proposal2 = new Proposal;
		$proposal2->title = "Test ".$date." alternative proposal case ".$casedesc;
		$proposal2->content = "Test content";
		$proposal2->reason = "Test reason";
		$proposal2->issue = $proposal->issue;
		$proposal2->create("Test proponent ".$date." alternative proposal case ".$casedesc, $area->id);
		$proponents = array(Login::$member);

		if ($stopcase == ++$stop) {
			$casetitle = "alternative draft";
			return;
		}

		// add proponents
		for ( $i=1; $i<=4; $i++ ) {
			add_proponent($proposal2, "qi".$i);
			$proponents[] = Login::$member;
		}

		if ($stopcase == ++$stop) {
			$casetitle = "alternative draft with proponents";
			return;
		}

		$proposal2->submit();

		if ($proposal2->state=="submitted" and $stopcase == ++$stop) {
			foreach ($proponents as $proponent) {
				$proposal2->remove_proponent($proponent);
			}
			cron();
			$casetitle = "remove all proponents from submitted alternative proposal";
			return;
		}

		$required_supporters = $proposal2->quorum_required();

		${'branch'.++$branch.'_array'} = array(0, $required_supporters-1, $required_supporters);
		$supporter_count2 = ${'branch'.$branch.'_array'}[$bcase[$branch]];

		for ( $i=1; $i<=$supporter_count2; $i++ ) {
			add_supporter($proposal2, "a".$i);
		}

		if ($stopcase == ++$stop) {
			$casetitle = "alternative proposal with $supporter_count2 supporters";
			return;
		}

		if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
			time_warp($issue, CANCEL_NOT_ADMITTED_INTERVAL);
			cron();
			$casetitle = "cancel long time not admitted alternative proposal";
			return;
		}

		if ($proposal->state=="admitted" or $proposal2->state=="admitted") {

			// create period
			$sql = "INSERT INTO period (debate, preparation, voting, counting, ballot_voting, ngroup)
			VALUES (
				now() + interval '1 week',
				now() + interval '2 weeks',
				now() + interval '3 weeks',
				now() + interval '4 weeks',
				false,
				".$ngroup->id."
			) RETURNING id";
			$result = DB::query($sql);
			$row = DB::fetch_row($result);
			$period = $row[0];

			// assign issue to period
			$issue->period = $period;
			/** @var $issue Issue */
			$issue->update(["period"]);

			// assigned, but not yet started
			cron();

			if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
				$casetitle = "assigned issue";
				return;
			}

			// move on to state "debate"
			time_warp($issue, "1 week");
			cron();

			$votingmode_required = $issue->quorum_votingmode_required();

			${'branch'.++$branch.'_array'} = array(0, $votingmode_required-1, $votingmode_required);
			$votingmode_demanders_count = ${'branch'.$branch.'_array'}[$bcase[$branch]];

			for ( $i=1; $i<=$votingmode_demanders_count; $i++ ) {
				add_votingmode_demander($proposal2, "a".$i);
			}

			if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
				$casetitle = "issue with $votingmode_demanders_count offline voting demanders";
				return;
			}

			$proposal2->read();

			${'branch'.++$branch.'_array'} = array(false, true);
			if ( ${'branch'.$branch.'_array'}[$bcase[$branch]] and $proposal2->state!="cancelled" ) {
				// remove all proponents from alternative proposal during debate
				foreach ($proponents as $proponent) {
					$proposal2->remove_proponent($proponent);
				}
			}

			// move on to state "preparation"
			time_warp($issue, "1 week");
			cron();

			if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
				$casetitle = "issue in voting preparation state";
				return;
			}

			// move on to state "voting"
			time_warp($issue, "1 week");
			cron();

			if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
				$casetitle = "issue in voting state";
				return;
			}

			// random votes
			random_votes($issue);

			// move on to state "counting" and then "finished"
			time_warp($issue, "1 week");
			cron();

			if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) {
				$casetitle = "issue in finished state";
				return;
			}

			// move on to cleared
			time_warp($issue, CLEAR_INTERVAL);
			cron();

			$casetitle = "issue finished and cleared";

		} else {
			$casetitle = "no admitted proposal";
		}

	} else {
		$casetitle = "proposal not submitted";
	}

	// continue with next case if branches are still available
	for ($i=1; $i<=$branch; $i++) {
		if (isset(${'branch'.$i.'_array'}[++$bcase[$i]])) {
			for ($j=1; $j<$i; $j++) $bcase[$j]=0;
			return true;
		}
	}

	// end of last case
	return "end";
}
 public function create()
 {
     if (!empty($_POST['area'])) {
         $newArea = new Area();
         if (isset($_FILES['fupload']) && $_FILES['fupload']['error'] == 0) {
             //if file upload is set
             move_uploaded_file($_FILES['fupload']['tmp_name'], "public/uploads/" . basename($_FILES['fupload']['name']));
             $image = new Imageresize();
             // an instance of image resize object
             $image->load("public/uploads/" . basename($_FILES['fupload']['name']));
             //$image->image =;
             $image->resize(400, 400);
             $image->save("public/uploads/" . basename($_FILES['fupload']['name']));
             //this section is needed to get the extension for image type in renaming the image
             if ($_FILES['fupload']['type'] == "image/gif") {
                 $ext = ".gif";
             }
             if ($_FILES['fupload']['type'] == "image/png") {
                 $ext = ".png";
             }
             if ($_FILES['fupload']['type'] == "image/jpeg") {
                 $ext = ".jpeg";
             }
             if ($_FILES['fupload']['type'] == "image/pjpeg") {
                 $ext = ".jpeg";
             }
             if ($_FILES['fupload']['type'] == "image/gif") {
                 $ext = ".gif";
             }
             if ($_FILES['fupload']['type'] == "image/jpg") {
                 $ext = ".jpg";
             }
             $new_name = uniqid() . "_" . time() . $ext;
             //new name for the image
             rename("public/uploads/" . basename($_FILES['fupload']['name']), "public/uploads/" . $new_name);
             $photo = $new_name;
             $newArea->img_url = $photo;
         } else {
             //$applicant->img_url = $_POST['imgvalue'];
         }
         $newArea->name = $_POST['area'];
         $newArea->description = $_POST['description'];
         $newArea->datecreated = date("Y:m:s H:i:s");
         if ($newArea->create()) {
             return 1;
             //returns 1 on success
         } else {
             return 2;
             // returns 2 on insert error
         }
     } else {
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
 public function run()
 {
     Area::create(['area' => 'Tecnico en Logistica']);
     Area::create(['area' => 'Tecnico y Soporte y Mantenimiento en Equipo de Computo']);
 }
Beispiel #8
0
/**
 * create group and areas
 *
 * @param string  $name
 * @param object  $parent (optional)
 * @return array
 */
function create_ngroup($name, Ngroup $parent=null) {

	$ngroup = new Ngroup;
	$ngroup->id = DB::fetchfield("SELECT max(id) FROM ngroup") + 1;
	$ngroup->name = $name;
	if ($parent) $ngroup->parent = $parent->id;
	$ngroup->active = true;
	$ngroup->minimum_population = 200;
	$ngroup->minimum_quorum_votingmode = 10;
	$ngroup->create(['id', 'name', 'parent', 'active', 'minimum_population', 'minimum_quorum_votingmode']);

	$area = new Area;
	$area->ngroup = $ngroup->id;
	$area->name = "Politik";
	$area->create();
	$area2 = new Area;
	$area2->ngroup = $ngroup->id;
	$area2->name = "Innerparteiliches";
	$area2->create();

	return [$ngroup, $area];
}