Example #1
0
 /**
  * @param Category $category
  */
 public function clickCategoryFilterLink($category)
 {
     $elt = $this->getElement('Categories tree')->find('css', sprintf('#node_%s a', $category->getId()));
     if (!$elt) {
         throw new \Exception(sprintf('Could not find category filter "%s".', $category->getId()));
     }
     $elt->click();
 }
 public function getBudgetArticleByCategory(Category $category)
 {
     if (isset($this->_budgetArticles[$category->getId()])) {
         return $this->_budgetArticles[$category->getId()];
     }
     $budgetArticle = new BudgetCategory();
     $this->_budgetArticles[$category->getId()] = $budgetArticle;
     $budgetArticle->setCategory($category);
     $budgetArticle->setType($category->getType() == Category::TYPE_PROFIT ? BudgetCategory::TYPE_PROFIT : BudgetCategory::TYPE_EXPENSE);
     $budgetArticle->setUser($this->_user);
     $budgetArticle->setDateStart($this->_startDate->format('Y-m-d'));
     return $budgetArticle;
 }
 public function update(Category $category)
 {
     if ($this->find($category->getId())) {
         $catId = $category->getId();
         $userId = $category->getUser()->getId();
         $superCat = $category->getParentCategory()->getId();
         $subCat = $category->getSubCategory();
         $sql = "UPDATE " . $this->TABLE_NAME . " SET\n                    userId='{$userId}',superCategory='{$superCat}',subCategory='{$subCat}'\n                    WHERE id='{$catId}'";
         if (mysql_query($sql, $this->connection)) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #4
0
 function test_getId()
 {
     $name = "Work stuff";
     $id = 1;
     $test_Category = new Category($name, $id);
     $result = $test_Category->getId();
     $this->assertEquals(true, is_numeric($result));
 }
 /**
  * Checks and repairs the internal consistency of the object.
  *
  * This method is executed after an already-instantiated object is re-hydrated
  * from the database.  It exists to check any foreign keys to make sure that
  * the objects related to the current object are correct based on foreign key.
  *
  * You can override this method in the stub class, but you should always invoke
  * the base method from the overridden method (i.e. parent::ensureConsistency()),
  * in case your model changes.
  *
  * @throws PropelException
  */
 public function ensureConsistency()
 {
     if ($this->aCategory !== null && $this->thelia_category_id !== $this->aCategory->getId()) {
         $this->aCategory = null;
     }
     if ($this->aLang !== null && $this->lang_id !== $this->aLang->getId()) {
         $this->aLang = null;
     }
 }
 /**
  * Checks and repairs the internal consistency of the object.
  *
  * This method is executed after an already-instantiated object is re-hydrated
  * from the database.  It exists to check any foreign keys to make sure that
  * the objects related to the current object are correct based on foreign key.
  *
  * You can override this method in the stub class, but you should always invoke
  * the base method from the overridden method (i.e. parent::ensureConsistency()),
  * in case your model changes.
  *
  * @throws PropelException
  */
 public function ensureConsistency()
 {
     if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
         $this->aCategory = null;
     }
     if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
         $this->aTaxRule = null;
     }
 }
 /**
  * Checks and repairs the internal consistency of the object.
  *
  * This method is executed after an already-instantiated object is re-hydrated
  * from the database.  It exists to check any foreign keys to make sure that
  * the objects related to the current object are correct based on foreign key.
  *
  * You can override this method in the stub class, but you should always invoke
  * the base method from the overridden method (i.e. parent::ensureConsistency()),
  * in case your model changes.
  *
  * @throws PropelException
  */
 public function ensureConsistency()
 {
     if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
         $this->aCategory = null;
     }
     if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
         $this->aAttribute = null;
     }
 }
 /**
  * Checks and repairs the internal consistency of the object.
  *
  * This method is executed after an already-instantiated object is re-hydrated
  * from the database.  It exists to check any foreign keys to make sure that
  * the objects related to the current object are correct based on foreign key.
  *
  * You can override this method in the stub class, but you should always invoke
  * the base method from the overridden method (i.e. parent::ensureConsistency()),
  * in case your model changes.
  *
  * @throws PropelException
  */
 public function ensureConsistency()
 {
     if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
         $this->aCategory = null;
     }
     if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
         $this->aFeature = null;
     }
 }
 public static function getAllCategoriesFromDatabase($dbConn)
 {
     $categoryIds = readFromDatabase::readEntireColumnFromTable($dbConn, array(self::ID_COLUMN_NAME), self::TABLE_NAME);
     $categories = array();
     foreach ($categoryIds as $categoryId) {
         $category = new Category($dbConn, $categoryId[self::ID_COLUMN_NAME]);
         $categories[$category->getId()] = $category->getName();
     }
     return $categories;
 }
Example #10
0
 function test_getId()
 {
     //Arrange
     $name = "Work stuff";
     $id = 1;
     $test_category = new Category($name, $id);
     //Act
     $result = $test_category->getId();
     //Assert
     $this->assertEquals(true, is_numeric($result));
 }
Example #11
0
 public function insert(Category $category, Subcategory $subcategory, Brand $brand, Item $item)
 {
     //        $sql = "INSERT INTO item values (null, 'aalluu', 'asdfasd',true,true, '2015-10-10','asdfasf', 'asdfasd', 1, 1 ,1, 1)";
     $sql = "INSERT INTO item values (null, '" . $item->getTitle() . "','" . $item->getDetail() . "',true,false, '" . $item->getDate() . "', '" . $item->getLocation() . "','asfasf'," . $category->getId() . "," . $subcategory->getId() . ", 1 ," . $brand->getId() . ")";
     echo $sql;
     if ($this->conn->query($sql) === TRUE) {
         echo "Insert operation successful";
     } else {
         echo "Error inserting: ";
     }
 }
Example #12
0
 function test_find()
 {
     $name = "Wash the dog";
     $name2 = "Home stuff";
     $test_Category = new Category($name);
     $test_Category->save();
     $test_Category2 = new Category($name2);
     $test_Category2->save();
     $result = Category::find($test_Category->getId());
     $this->assertEquals($test_Category, $result);
 }
 public function edit(User $currentUser, Category $category)
 {
     $id = intval($category->getId());
     $name = $this->database->quote($category->getName());
     $description = $this->database->quote($category->getDescription());
     $query = "UPDATE category SET name = '" . $name . "', description = '" . $description . "' WHERE id = " . $id;
     $result = $this->database->exec($query);
     if ($result) {
         return true;
     } else {
         throw new Exception("Catastrophe base de données.");
     }
 }
Example #14
0
	/**
	 * (non-PHPdoc)
	 * @see de\RaumZeitLabor\PartKeepr\Util.Serializable::serialize()
	 */
	public function serialize () {
		$aManufacturers = array();
		
		foreach ($this->getManufacturers() as $manufacturer) {
			$aManufacturers[] = $manufacturer->serialize();
		}
		
		$aDistributors = array();
		
		foreach ($this->getDistributors() as $distributor) {
			$aDistributors[] = $distributor->serialize();
		}
		
		$aParameters = array();
		foreach ($this->getParameters() as $parameter) {
			$aParameters[] = $parameter->serialize();
		}
		
		$aImages = array();
		foreach ($this->getImages() as $image) {
			$aImages[] = $image->serialize();
		}
		
		$aAttachments = array();
		foreach ($this->getAttachments() as $attachment) {
			$aAttachments[] = $attachment->serialize();
		}
		
		return array(
					"id" => $this->getId(),
					"name" => $this->getName(),
					"comment" => $this->getComment(),
					"stockLevel" => $this->getStockLevel(),
					"footprint_id" => is_object($this->footprint) ? $this->footprint->getId() : null,
					"minStockLevel" => $this->minStockLevel,
					"storageLocation_id" => is_object($this->storageLocation) ? $this->storageLocation->getId() : null,
					"storageLocationName" => is_object($this->storageLocation) ? $this->storageLocation->getName() : null,
					"category_id" => is_object($this->category) ?  $this->category->getId() : null,
					"partUnit_id" => is_object($this->partUnit) ? $this->getPartUnit()->getId() : null,
					"partUnit_name" => is_object($this->partUnit) ? $this->getPartUnit()->getId() : PartKeepr::i18n("Pieces"),
					"partUnit_shortName" => is_object($this->partUnit) ? $this->getPartUnit()->getId() : "",
					"manufacturers" => $aManufacturers,
					"distributors" => $aDistributors,
					"images" => $aImages,
					"attachments" => $aAttachments,
					"parameters" => $aParameters
		
		);
	}
Example #15
0
 function test_save()
 {
     //Arrange
     $name = "Home stuff";
     $id = null;
     $test_category = new Category($name, $id);
     $test_category->save();
     $due_date = "2015-10-12";
     $description = "Wash the dog";
     $category_id = $test_category->getId();
     $test_task = new Task($description, $due_date, $id, $category_id);
     //Act
     $test_task->save();
     //Assert
     $result = Task::getAll();
     var_dump($result);
     $this->assertEquals($test_task, $result[0]);
 }
Example #16
0
 function testGetTasks()
 {
     //Arrange
     $name = "Work stuff";
     $id = null;
     $test_category = new Category($name, $id);
     $test_category->save();
     $test_category_id = $test_category->getId();
     $description = "Email client";
     $test_task = new Task($description, $id, $test_category_id);
     $test_task->save();
     $description2 = "Meet the boss";
     $test_task2 = new Task($description2, $id, $test_category_id);
     $test_task2->save();
     //Act
     $result = $test_category->getTasks();
     //Assert
     $this->assertEquals([$test_task, $test_task2], $result);
 }
Example #17
0
    public function update(Category $category)
    {
        $id = $category->getId();
        $title = $this->db->quote($title->getTitle());
        $content = $this->db->quote($content->getContent());
        $image = $this->db->quote($image->getImage());
        $idAuthor = $_SESSION['id'];
        $query = '	UPDATE category
						SET title 		=' . $title . ',
							content 	=' . $content . ',
							image 		=' . $image . ',
							$idAuthor 	=' . $idAuthor . '
						WHERE id=' . $id;
        $res = $this->db->exec($query);
        if ($res) {
            $id = $this->db->lastInsertId();
            if ($id) {
                return $this->findById($id);
            } else {
                throw new Exception('Internal server Error');
            }
        }
    }
 /**
  * Quick add project category
  *
  * @param void
  * @return null
  */
 function quick_add_category()
 {
     if ($this->request->isSubmitted() && $this->request->isAsyncCall()) {
         $this->active_category = new Category();
         $this->active_category->setAttributes($this->request->post('category'));
         $this->active_category->setModule($this->active_module);
         $this->active_category->setController($this);
         $this->active_category->setProjectId($this->active_project->getId());
         $this->active_category->setCreatedBy($this->logged_user);
         $this->active_category->setState(STATE_VISIBLE);
         $this->active_category->setVisibility(VISIBILITY_NORMAL);
         $save = $this->active_category->save();
         if ($save && !is_error($save)) {
             print $this->active_category->getId();
             die;
         } else {
             $this->serveData($save);
         }
         // if
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
Example #19
0
 /**
  * @ignore 
  */
 public function addCategory(Category $cat)
 {
     $this->categories[$cat->getId()] = $cat;
 }
Example #20
0
 public function getRatingForCategory(Category $category)
 {
     return RatingValueQuery::create()->filterByRatingHeader($this)->findOneByCategoryId($category->getId());
 }
Example #21
0
 function testFind()
 {
     //Arrange
     $name = "Wash the dog";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $name2 = "Home stuff";
     $id2 = 2;
     $test_category2 = new Category($name2, $id2);
     $test_category2->save();
     //Act
     $result = Category::find($test_category->getId());
     //Assert
     $this->assertEquals($test_category, $result);
 }
 function testGetTasks()
 {
     $name = "Work stuff";
     $id = null;
     $test_Category = new Category($name, $id);
     $test_Category->save();
     $test_category_id = $test_Category->getId();
     $description = "Email client";
     $due_date = 00;
     $test_task = new Task($description, $test_category_id, $due_date, $id);
     $test_task->save();
     $description2 = "Meet with boss";
     $test_task2 = new Task($description2, $test_category_id, $due_date, $id);
     $test_task2->save();
     $result = $test_Category->getTasks();
     $this->assertEquals([$test_task, $test_task2], $result);
 }
Example #23
0
 function test_find()
 {
     //Arrange
     $name = "Home stuff";
     $id = null;
     $test_category = new Category($name, $id);
     $test_category->save();
     $description = "Wash the dog";
     $user_date = "2015-08-18";
     $category_id = $test_category->getId();
     $test_task = new Task($description, $user_date, $id, $category_id);
     $test_task->save();
     $description2 = "Water the lawn";
     $user_date2 = "2015-08-18";
     $test_task2 = new Task($description2, $user_date2, $id, $category_id);
     $test_task2->save();
     //Act
     $result = Task::find($test_task->getId());
     //Assert
     $this->assertEquals($test_task, $result);
 }
Example #24
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Category $value A Category object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Category $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #25
0
        $c->setName($data[$fieldname]);
        $c->save();
        $o->{$set}($c);
    }
}
// Tickets
$ticketCount = 0;
$result = $mongo->tickets->find();
foreach ($result as $r) {
    // Start a ticket record, using mongo's ticket number as the ID
    $d = DateTime::createFromFormat('U', $r['enteredDate']->sec);
    $data = array('id' => $r['number'], 'enteredDate' => $d->format('Y-m-d H:i:s'));
    if (!empty($r['category'])) {
        try {
            $c = new Category($r['category']['name']);
            $data['category_id'] = $c->getId();
        } catch (Exception $e) {
        }
        // Just ignore bad categories
    }
    $peopleFields = array('enteredByPerson', 'assignedPerson', 'referredPerson');
    foreach ($peopleFields as $f) {
        if (!empty($r[$f]['_id'])) {
            $id = getPersonIdFromCrosswalk($r[$f]['_id']);
            if ($id) {
                $data[$f . '_id'] = $id;
            }
        }
    }
    if (!empty($r['address_id'])) {
        $data['addressId'] = $r['address_id'];
Example #26
0
 /**
  * @ignore
  */
 public function addCategory(Category $cat)
 {
     $this->categories[$cat->getId()] = $cat;
     $cat->setParent($this);
 }
$t->isa_ok($category, 'array', 'findOne() called after select(array) returns an array');
$t->is(count($category), 0, 'findOne() called after select(array) returns an empty array if no record is found');

$category1 = new Category();
$category1->setName('cat1');
$category1->save();
$category2 = new Category();
$category2->setName('cat2');
$category2->save();

$finder = sfPropelFinder::from('Category')->
  select(array('Id','Name'), sfModelFinder::ASSOCIATIVE);
$category = $finder->findOne();
$t->isa_ok($category, 'array', 'The row returned by findOne() called after select(array) is an array');
$t->is_deeply(array_keys($category), array('Id', 'Name'), 'The row returned by findOne() called after select(array, sfModelFinder::ASSOCIATIVE) is an associative array where the keys are the requested column names');
$t->is($category['Id'], $category1->getId(), 'The row returned by findOne() called after select(array, sfModelFinder::ASSOCIATIVE) is an associative array where the values are the requested column values');
$t->is($category['Name'], $category1->getName(), 'The row returned by findOne() called after select(array, sfModelFinder::ASSOCIATIVE) is an associative array where the values are the requested column values');

$finder = sfPropelFinder::from('Category')->
  select(array('Id','Name'), sfModelFinder::SIMPLE);
$category = $finder->findOne();
$t->is_deeply(array_keys($category), array(0, 1), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array with numeric keys');
$t->is($category[0], $category1->getId(), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array where the values are the requested column values');
$t->is($category[1], $category1->getName(), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array where the values are the requested column values');

/*********************************************/
/* sfPropelFinder::select() and withColumn() */
/*********************************************/

$t->diag('sfPropelFinder::select() and withColumn()');
 function testDeleteCategoryContacts()
 {
     //arrange
     $name = "Business";
     $id = null;
     $test_category = new Category($name, $id);
     $test_category->save();
     $contact_name = "Jane Doe";
     $phone_number = "555-555-5555";
     $address = "5 Main Street, Anytown, Anystate 55555";
     $category_id = $test_category->getId();
     $test_contact = new Contact($contact_name, $phone_number, $address, $id, $category_id);
     $test_contact->save();
     //act
     $test_category->delete();
     //assert
     $this->assertEquals([], Contact::getAll());
 }
Example #29
0
 /**
  * Declares an association between this object and a Category object.
  *
  * @param      Category $v
  * @return     Article The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setCategory(Category $v = null)
 {
     if ($v === null) {
         $this->setCategoryId(NULL);
     } else {
         $this->setCategoryId($v->getId());
     }
     $this->aCategory = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Category object, it will not be re-added.
     if ($v !== null) {
         $v->addArticle($this);
     }
     return $this;
 }
Example #30
0
    public function Test_of_parent()
    {
        $CategoryA = new Category();
        $CategoryA->description = "Cat A";

        $CategoryAa = new Category();
        $CategoryAa->description = "Cat Aa";

        $CategoryAb = new Category();
        $CategoryAb->description = "Cat Ab";

        $CategoryA->tree->addChild($CategoryAa);
        $CategoryA->tree->addChild($CategoryAb);

        $catAaParent = $CategoryAa->tree->getParent();
        $catAbParent = $CategoryAb->tree->getParent();
        $this->assertEqual($CategoryA->getId(), $catAaParent->getId());
        $this->assertEqual($CategoryA->getId(), $catAbParent->getId());
    }