Beispiel #1
0
         $cn->rollback();
         alert($e->getMessage());
         $correct = 1;
     }
 }
 /* Second step : we save the name and category
  * and propose the items we add the item */
 if ($correct == 2 || isset($_POST['step2'])) {
     try {
         $cn->start();
         /* Save forecast */
         $a = new Forecast($cn);
         $a->set_parameter('name', $_POST['an_name']);
         $a->set_parameter('start_date', $_POST['start_date']);
         $a->set_parameter('end_date', $_POST['end_date']);
         $a->save();
         $id = $a->get_parameter("id");
         /* save cat */
         for ($i = 0; $i < MAX_CAT; $i++) {
             if (strlen(trim($_POST['fr_cat' . $i])) != 0) {
                 $c = new Forecast_Cat($cn);
                 $c->set_parameter('order', $_POST['fr_order' . $i]);
                 $c->set_parameter('desc', $_POST['fr_cat' . $i]);
                 $c->set_parameter('forecast', $id);
                 $c->save();
             }
         }
         $cn->commit();
     } catch (Exception $e) {
         alert($e->getMessage());
         $correct = 1;