コード例 #1
0
ファイル: SetupDatabase.php プロジェクト: nessi/PartKeepr
	$oPart->setMinStockLevel($part["mininstock"]);
	$oPart->setPartUnit($partUnit);
	for ($i=0;$i<rand(0,15);$i++) {
		$randomManufacturer = rand(0, count($aManufacturers)-1);
		$oPart->getManufacturers()->add(new PartManufacturer($oPart, $aManufacturers[$randomManufacturer]));
	}
	
	$oPart->getDistributors()->add(new PartDistributor($oPart, $aDistributors[$part["id_supplier"]]));
	
	//echo "Migrating part ".sprintf("%-40s", $part["name"])."\r";
	
	/* Add existing datasheets */
	$datasheetQuery = "SELECT datasheeturl FROM datasheets WHERE part_id = ".$part["id"];
	$r3 = mysql_query($datasheetQuery);
	while ($res = mysql_fetch_assoc($r3)) {
			$attachment = new PartAttachment();
			$attachment->setPart($oPart);
			$attachment->replaceFromURL($res["datasheeturl"]);
			$attachment->setDescription(PartKeepr::i18n("Datasheet"));
			$oPart->getAttachments()->add($attachment);

		
	}
	
	PartKeepr::getEM()->persist($oPart);
	
	$oStock = new StockEntry($oPart, $part["instock"]);
	
	$priceQuery = "SELECT AVG(preis) AS preis FROM preise WHERE part_id = ".$part["id"];
	
	$r2 = mysql_query($priceQuery);
コード例 #2
0
ファイル: PartTest.php プロジェクト: nessi/PartKeepr
<?php
namespace de\RaumZeitLabor\PartKeepr\Tests;
declare(encoding = 'UTF-8');

include("../src/de/RaumZeitLabor/PartKeepr/PartKeepr.php");

use de\RaumZeitLabor\PartKeepr\Auth\User;
use de\RaumZeitLabor\PartKeepr\Footprint\Footprint;
use de\RaumZeitLabor\PartKeepr\Footprint\FootprintManager;
use de\RaumZeitLabor\PartKeepr\Category\Category;
use de\RaumZeitLabor\PartKeepr\Category\CategoryManager;
use de\RaumZeitLabor\PartKeepr\PartKeepr;
use de\RaumZeitLabor\PartKeepr\Part\Part;
use de\RaumZeitLabor\PartKeepr\Part\PartAttachment;

PartKeepr::initialize();

$test = new PartAttachment();
$test->replaceFromURL("http://www.datasheetcatalog.org/datasheet/motorola/MCT7809BD2T.pdf");
コード例 #3
0
ファイル: file.php プロジェクト: nessi/PartKeepr
use de\RaumZeitLabor\PartKeepr\PartKeepr;
use de\RaumZeitLabor\PartKeepr\Image\Image;
use de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerICLogo;

include("../src/de/RaumZeitLabor/PartKeepr/PartKeepr.php");

PartKeepr::initialize("");

$type = $_REQUEST["type"];
$id = $_REQUEST["id"];

try {
	switch ($type) {
		case "PartAttachment":
			$file = PartAttachment::loadById($id);
			break;
		case "FootprintAttachment":
				$file = FootprintAttachment::loadById($id);
				break;			
		default:
			$file = null;
			// Add default image?
	}
	
} catch (\Exception $e) {
	$file = null;
	// Something bad happened
}

if ($file == null) {
コード例 #4
0
ファイル: PartManager.php プロジェクト: nessi/PartKeepr
	private function processAttachmentChanges (Part $part, Array $data) {
		if (array_key_exists("updates", $data)) {
			foreach ($data["updates"] as $record) {
				foreach ($part->getAttachments() as $partAttachment) {
					if ($partAttachment->getId() == $record["id"]) {
						$partAttachment->setDescription($record["description"]);
						break;
					}
				}
			}
		}
	
		if (array_key_exists("removals", $data)) {
			foreach ($data["removals"] as $record) {
				foreach ($part->getAttachments() as $partAttachment) {
					if ($partAttachment->getId() == $record["id"]) {
						PartKeepr::getEM()->remove($partAttachment);
						$part->getAttachments()->removeElement($partAttachment);
						break;
					}
				}
			}
		}
	
		if (array_key_exists("inserts", $data)) {
			foreach ($data["inserts"] as $record) {
				$attachment = new PartAttachment();
				$attachment->setPart($part);
				$attachment->setDescription($record["description"]); 
				
				$file = TempUploadedFile::loadById($record["tmp_id"]);
				
				$attachment->replace($file->getFilename());
				$attachment->setOriginalFilename($file->getOriginalFilename());
	
				$part->getAttachments()->add($attachment);
			}
		}
	}