Example #1
0
 public function action_index()
 {
     $session = Session::instance();
     $post = $this->request->post();
     if ($session->get('userType') != 'company') {
         $this->response->body(View::factory('header') . "<div id = 'alertDiv' class='alert alert-success'>  Only companies can create projects. </div>");
         header("Refresh:2; url=project");
     }
     if (isset($_POST['submit'])) {
         if (Company::checkIfApproved($session->get('userId'))) {
             $category = $post['projecttype'];
             $projectname = $post['projectname'];
             $discription = $post['projectdescription'];
             if (Project::createProject($projectname, $category, $discription, $session->get('userId'))) {
                 $this->response->body(View::factory('header') . "<div id = 'alertDiv' class='alert alert-success'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a> Project added successfuly. </div>");
                 header("Refresh:2; url=project");
             } else {
                 $this->response->body(View::factory('header') . "<div id = 'alertDiv' class='alert alert-success'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a> Project adding error. </div>");
                 header("Refresh:2; url=project");
             }
         } else {
             $this->response->body(View::factory('header') . "<div id = 'alertDiv' class='alert alert-success'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a> Company is not aproved by: <strong> Administrator  </strong></div> ");
         }
     } else {
         $this->response->body(View::factory('header') . View::factory('newProject'));
     }
 }
if (!empty($_POST) && Form::isValid('createProject')) {
    // This functions is disabled until students get activated
    //$uid = findUser($_POST['student']);
    // Get current Course
    $course = $user->getCourse($cid);
    /*if( $uid == -1 ) {
        Form::setError('createProject', 'Error: Unable to find that user.');
        header("Location: ?view=createproject&cid=$cid");
      } else {
        Form::clearValues('createProject');
      }*/
    $subject = $_POST['subject'];
    $deadline = new DateTime($_POST['deadline'] . ' ' . $_POST['deadlineTime']);
    $stage = intval($_POST['stage']);
    // Create Project
    $project = Project::createProject($subject, $deadline, $stage, $cid);
    // Add the project to the course
    $course->addProject($project->id);
    // Add the student to the project
    //$project->addStudent($uid);
    // Add a submission to the Project
    $project->createSubmission();
    echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>';
} else {
    $form = new Form('createProject');
    $form->configure(array('action' => "?view=createproject&cid={$cid}"));
    $form->addElement(new Element\HTML('<legend>Create new project</legend>'));
    $form->addElement(new Element\Hidden('form', 'createProject'));
    $form->addElement(new Element\Textbox('Subject:', 'subject', array('validation' => new Validation\RegExp('/^[\\p{L} ]{2,64}$/', 'Error: The %element% field must contain only characters and whitespaces and be between 2 and 64 characters.'), 'required' => 1)));
    $form->addElement(new Element\Select('Stage:', 'stage', $stages, array('validation' => new Validation\RegExp('/^[1-5]{1}$/', 'Error: The %element% field is not valid.'), 'required' => 1, 'longDesc' => 'Starting stage of the project')));
    /*  $form->addElement(new Element\Textbox('Student:', 'student', array(
Example #3
0
   <div id="main">
   
       <?php 
if ($_SESSION['userType'] != 'company') {
    echo "Only companies can create projects";
    header("Refresh:2; url=project.php");
    die;
}
if (isset($_POST['submit'])) {
    if ($companyObj->checkIfApproved($_SESSION['companyID'])) {
        $projectObj = new Project();
        $category = $_POST['projecttype'];
        $projectname = $_POST['projectname'];
        $discription = $_POST['projectdescription'];
        if ($projectObj->createProject($projectname, $category, $discription, $_SESSION['companyID'])) {
            echo "Project added successfuly";
        } else {
            echo "Project adding error";
        }
    } else {
        echo "Company is not approved by administrator";
    }
} else {
    echo "<div class='col-md-4'>\n               <div class='btn-group-vertical'>\n                  <!-- Ako e najaven kako Kompanija da mozi da dodaj  -->\n                  <button onclick='location.href='newproject.php'' type='button' class='btn btn-success btn-md'>New Project</button>\n                  <!-- Ovde ce se iscituvaat proektite so bile napraeni prethodno -->\n                  <button type='button' class='btn btn-success btn-md'>Coding</button>\n                  <button type='button' class='btn btn-success btn-md'>Desing</button>\n                  <button type='button' class='btn btn-success btn-md'>Comunications</button>\n                  <button type='button' class='btn btn-success btn-md'>Education</button>\n               </div>\n            </div>\n            <div class='col-md-8'>\n            <form id='loginForm' role='form' action='newproject.php' method='POST'>\n            <fieldset>\n                    <legend>New Project</legend>\n                    <ol>\n                    <li>\n                     \n                        <input type='radio' name='projecttype' value='coding' checked>Coding\n                        <input type='radio' name='projecttype' value='design'>Desing\n                        <input type='radio' name='projecttype' value='communication'>Communication\n                        <input type='radio' name='projecttype' value='education'>Education\n                       \n                    </li>\n                    <li>\n                        <label for='firstname'>Project Name:</label> \n                        <input type='text' class='form-control' name='projectname' value='' id='projectname' />\n                    </li>\n                     <li>\n                        <label for='lastname'>Project Description:</label> \n                       <textarea rows='4' cols='50' name='projectdescription' id='projectdescription'>Enter Desription of Project here...\n                       </textarea>\n                    </li>\n                     \n                    <input type='submit' class='btn btn-default' name='submit' value='NewProject' />\n                   \n            </fieldset>\n            </form>\n            \n            </div>";
}
?>
    </div>

</div> <!-- End of outer-wrapper which opens in header.php -->
<?php 
 public function createProject()
 {
     $input = Input::all();
     return Project::createProject($input);
 }