Пример #1
0
	/**
	 * Creates a new distributor with the given name.
	 * @param string $name The name of the distributor
	 * @return Distributor The new distributor object
	 */
	public function addDistributor ($name) {
		$distributor = new Distributor();
		$distributor->setName($name);
		
		PartKeepr::getEM()->persist($distributor);
		PartKeepr::getEM()->flush();
		
		return $distributor;
	}
Пример #2
0
	/**
	 * Sets the data for the distributor.
	 * @param Distributor $distributor The distributor to process
	 */
	private function setDistributorData (Distributor $distributor) {
		$distributor->setName($this->getParameter("name"));
		$distributor->setComment($this->getParameter("comment", ""));
		$distributor->setAddress($this->getParameter("address", ""));
		$distributor->setURL($this->getParameter("url", ""));
		$distributor->setEmail($this->getParameter("email", ""));
	}
Пример #3
0
	
	foreach ($logos as $logo) {
		$mfglogo = new ManufacturerICLogo();
		$mfglogo->setManufacturer($manufacturer);
		$mfglogo->replace("../setup/data/manufacturers/images/".$logo);
		$mfglogo->setOriginalFilename($logo);
		
		PartKeepr::getEM()->persist($mfglogo);
	}
}

PartKeepr::getEM()->flush();

$r = mysql_query("SELECT * FROM suppliers");
while ($supplier = mysql_fetch_assoc($r)) {
	$distributor = new Distributor();
	$distributor->setName($supplier["name"]);
	
	PartKeepr::getEM()->persist($distributor);
	$aDistributors[$supplier["id"]] = $distributor;
}

$r = mysql_query("SELECT * FROM parts");

$aRandomUnitNames = array("Spannung", "Strom", "Leitfähigkeit", "Viskosität", "Nessis");

$fc=0;

while ($part = mysql_fetch_assoc($r)) {
	$oPart = new Part();
	$oPart->setName(convertText($part["name"]));
Пример #4
0
	private function processDistributorChanges (Part $part, Array $data) {
		if (array_key_exists("updates", $data)) {
			foreach ($data["updates"] as $record) {
				foreach ($part->getDistributors() as $partDistributor) {
					if ($partDistributor->getId() == $record["id"]) {
						$partDistributor->setOrderNumber($record["orderNumber"]);
						$partDistributor->setDistributor(Distributor::loadById($record["distributor_id"]));
						$partDistributor->setPackagingUnit($record["packagingUnit"]);
						break;
					}
				}
			}
		}
		
		if (array_key_exists("removals", $data)) {
			foreach ($data["removals"] as $record) {
				foreach ($part->getDistributors() as $partDistributor) {
					if ($partDistributor->getId() == $record["id"]) {
						PartKeepr::getEM()->remove($partDistributor);
						$part->getDistributors()->removeElement($partDistributor);
						break;
					}
				}
			}
		}
		
		if (array_key_exists("inserts", $data)) {
			foreach ($data["inserts"] as $record) {
				$distributor = new PartDistributor($part, Distributor::loadById($record["distributor_id"]));
				$distributor->setOrderNumber($record["orderNumber"]);
				$distributor->setPackagingUnit($record["packagingUnit"]);
				
				$part->getDistributors()->add($distributor);
			}
		}
	}