/**
  * @throws OrganisationUnitIDMissingException
  */
 public static function create()
 {
     if ($_GET['action'] == "add_child" and $_GET['id'] or $_GET['action'] == "add") {
         if ($_GET['nextpage'] == 1) {
             $page_1_passed = true;
             if ($_POST['name']) {
                 if (OrganisationUnit::exist_name($_POST['name']) == true) {
                     $page_1_passed = false;
                     $error = "This name already exists";
                 }
             } else {
                 $page_1_passed = false;
                 $error = "You must enter a name";
             }
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("organisation_unit/admin/organisation_unit/add.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&');
             $template->set_var("params", $params);
             if ($error) {
                 $template->set_var("error", $error);
             } else {
                 $template->set_var("error", "");
             }
             if ($_GET['action'] == "add_child" and is_numeric($_GET['id'])) {
                 $organisation_unit = new OrganisationUnit($_GET['id']);
                 $template->set_var("parent", $organisation_unit->get_name());
             } else {
                 $template->set_var("parent", "on root");
             }
             if ($_POST['name']) {
                 $template->set_var("name", $_POST['name']);
             } else {
                 $template->set_var("name", "");
             }
             $type_array = OrganisationUnit::list_types();
             $result = array();
             $counter = 0;
             foreach ($type_array as $key => $value) {
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = OrganisationUnit::get_name_by_type_id($value);
                 $counter++;
             }
             $template->set_var("option", $result);
             $template->output();
         } else {
             $paramquery = $_GET;
             unset($paramquery['nextpage']);
             unset($paramquery['action']);
             $params = http_build_query($paramquery);
             $organisation_unit = new OrganisationUnit(null);
             if ($_GET['action'] == "add_child" and is_numeric($_GET['id'])) {
                 $toid = $_GET['id'];
             } else {
                 $toid = null;
             }
             if ($_POST['contains_projects'] == "1") {
                 $stores_data = true;
             } else {
                 $stores_data = false;
             }
             $paramquery = $_GET;
             unset($paramquery['action']);
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&');
             if ($organisation_unit->create($toid, $_POST['name'], $_POST['type'], $stores_data)) {
                 Common_IO::step_proceed($params, "Add Organisation Unit", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Add Organisation Unit", "Operation Failed", null);
             }
         }
     } else {
         throw new OrganisationUnitIDMissingException();
     }
 }