Exemplo n.º 1
0
 protected function setUp()
 {
     $this->products = array();
     $this->compositions = array();
     // Setup tax and categories
     $taxCat = new TaxCat("Tax");
     $tax = new Tax(null, "Tax", stdtimefstr("2001-01-01 00:00:00"), 0.1);
     $taxCat->addTax($tax);
     $taxCat->id = TaxesService::createCat($taxCat);
     $pdo = PDOBuilder::getPDO();
     $id = CompositionsService::CAT_ID;
     $catCmp = new Category(null, "Compositions", false, 1);
     $sql = "INSERT INTO CATEGORIES (ID, NAME, PARENTID, DISPORDER, IMAGE) " . "VALUES (:id, :name, :pid, :order, null)";
     $stmt = $pdo->prepare($sql);
     $stmt->bindParam(":name", $catCmp->label, \PDO::PARAM_STR);
     $stmt->bindParam(":pid", $catCmp->parentId, \PDO::PARAM_INT);
     $stmt->bindParam(":id", $id, \PDO::PARAM_INT);
     $stmt->bindParam(":order", $catCmp->dispOrder, \PDO::PARAM_INT);
     $stmt->execute();
     $cat = new Category(null, "Category", false, 2);
     $cat->id = CategoriesService::createCat($cat);
     // Set up products
     $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2);
     $prd->id = ProductsService::create($prd, null);
     $this->products[] = $prd;
     $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 3, $taxCat->id, true, false);
     $prd2->id = ProductsService::create($prd2, null);
     $this->products[] = $prd2;
     $cmp = new Composition("CMP", "composition", 1.0, $id, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2);
     $subgrp = new Subgroup(null, "Subgroup", 1, false);
     $subgrp->addProduct(new SubgroupProduct($prd->id, null, 1));
     $subgrp->addProduct(new SubgroupProduct($prd2->id, null, 2));
     $cmp->addGroup($subgrp);
     $cmp->id = CompositionsService::create($cmp, null, null);
     $this->compositions[] = $cmp;
 }
 private function buildDataToInsert($year, $subgroupId, $fontId, $typeId, $varietyId, $originId, $destinyId)
 {
     $font = new Font();
     $font->setId($fontId);
     $type = new CoffeType();
     $type->setId($typeId);
     $variety = new Variety();
     $variety->setId($varietyId);
     $origin = new Country();
     $origin->setId($originId);
     $destiny = new Country();
     $destiny->setId($destinyId);
     $subgroup = new Subgroup();
     $subgroup->setId($subgroupId);
     return new Data($year, $subgroup, $font, $type, $variety, $origin, $destiny);
 }
Exemplo n.º 3
0
 public function postUserToSubgroup()
 {
     $selected_users = Input::get('user');
     $selected_subgroup = Input::get('subgroup');
     $subgroup = Subgroup::find($selected_subgroup);
     // giving the User a subgroup
     if (isset($selected_users)) {
         foreach ($selected_users as $user_id) {
             $user = User::find($user_id);
             foreach ($subgroup->users as $member) {
                 if ($member->id == $user->id) {
                     return Redirect::to('/')->with('error', $member->name . ' is already in ' . $subgroup->name);
                 }
             }
             $user->subgroups()->attach($subgroup->id);
         }
     } else {
         return Redirect::to('/')->with('error', 'No users were checked!');
     }
     return Redirect::to('/');
 }
Exemplo n.º 4
0
 public function getSubgroupId()
 {
     return $this->subgroup->id();
 }