/**
  * Store a newly created resource in storage.
  * POST /projectstages
  *
  * @return Response
  */
 public function store()
 {
     Input::merge(array_map('trim', Input::all()));
     $input_all = Input::all();
     $validation = Validator::make($input_all, Stage::$rules);
     if ($validation->passes()) {
         $stage = new Stage();
         $stage->stage = strtoupper(Input::get('project_stage'));
         $stage->description = strtoupper(Input::get('description'));
         $stage->save();
         return Redirect::route('project.stage.index')->with('class', 'success')->with('message', 'Record successfully created.');
     } else {
         return Redirect::route('project.stage.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.');
     }
 }
Exemplo n.º 2
0
 public function create($aData)
 {
     $oConnection = Propel::getConnection(StagePeer::DATABASE_NAME);
     try {
         if (isset($aData['STG_UID']) && $aData['STG_UID'] == '') {
             unset($aData['STG_UID']);
         }
         if (!isset($aData['STG_UID'])) {
             $aData['STG_UID'] = G::generateUniqueID();
         }
         $oStage = new Stage();
         $oStage->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         $oStage->setStgTitle($aData['STG_TITLE']);
         if ($oStage->validate()) {
             $oConnection->begin();
             $iResult = $oStage->save();
             $oConnection->commit();
             return $aData['STG_UID'];
         } else {
             $sMessage = '';
             $aValidationFailures = $oStage->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The registry cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
Exemplo n.º 3
0
        if ($entreprise->getId() == $_REQUEST['id']) {
            $entrepriseChoisi = $entreprise;
        }
    }
    if ($_REQUEST['nbPostes'] >= 1 && $dateFin != false && $dateDebut != false && $entreprise != null) {
        $stage = new Stage();
        $entreprise = $user->getEntreprises();
        $stage->setTitre($_REQUEST['titre']);
        $stage->setDescription($_REQUEST['description']);
        $stage->setGratification($_REQUEST['gratification']);
        $stage->setDateDebut($dateDebut);
        $stage->setDateFin($dateFin);
        $stage->setDomaine($_REQUEST['domaine']);
        $stage->setEntreprise($entrepriseChoisi);
        $stage->setNbPoste($_REQUEST['nbPostes']);
        $stage->save();
        $pdo = myPDO::getInstance();
        $req = $pdo->prepare(<<<SQL
\t    \tSELECT numStage
\t    \tFROM Stage
\t    \tORDER BY dateCreation DESC LIMIT 1
SQL
);
        $req->execute();
        // mail
        // récupération des adresses
        $reqAdresses = $pdo->prepare(<<<SQL
\t\t\tSELECT mail
\t\t\tFROM Etudiant
\t\t\tWHERE 1
SQL
Exemplo n.º 4
0
 private function changeLoanStage(ConnectionInterface $con, Loan $loan, $oldStatus = null, $newStatus, \DateTime $date = null)
 {
     $date = $date ?: new \DateTime();
     $newLoanStage = new Stage();
     $newLoanStage->setLoan($loan)->setBorrower($loan->getBorrower())->setStatus($newStatus)->setStartDate($date);
     if ($oldStatus) {
         $currentLoanStage = StageQuery::create()->filterByLoan($loan)->findOneByStatus($oldStatus);
         if ($currentLoanStage) {
             $currentLoanStage->setEndDate($date);
             $currentLoanStage->save($con);
         }
     }
     $newLoanStageSuccess = $newLoanStage->save($con);
     if (!$newLoanStageSuccess) {
         throw new \Exception();
     }
 }