コード例 #1
0
ファイル: consumables.php プロジェクト: mrjwc/printmaster
 try {
     // Get consumable via ID
     $c = new Consumable($id);
     if (fRequest::isPost()) {
         // Try to validate options
         $validator = new fValidation();
         $validator->addOneOrMoreRule('col_c', 'col_y', 'col_m', 'col_k');
         $validator->overrideFieldName(array('col_c' => 'Colour (Cyan)', 'col_y' => 'Colour (Yellow)', 'col_m' => 'Colour (Magenta)', 'col_k' => 'Colour (Black)'));
         $validator->validate();
         // Update consumable object from POST data and save
         $c->populate();
         $c->linkModels();
         $c->linkTags();
         $c->store();
         // Messaging
         fMessaging::create('affected', fURL::get(), $c->getId());
         fMessaging::create('success', fURL::get(), 'The consumable ' . $c->getName() . ' was successfully updated.');
         fURL::redirect(fURL::get());
     }
 } catch (fNotFoundException $e) {
     fMessaging::create('error', fURL::get(), 'The consumable requested, ID ' . $id . ', could not be found.');
     fURL::redirect(fURL::get());
 } catch (fExpectedException $e) {
     fMessaging::create('error', fURL::get(), $e->getMessage());
 }
 // Get manufacturers also for drop-down box
 #$manufacturers = fRecordSet::build('Manufacturer', NULL, array('name' => 'asc'));
 // Get list of models
 $models = Model::getSimple($db);
 // Get types
 if (feature('consumable_types')) {