Exemplo n.º 1
0
	public function movePart () {
		$this->requireParameter("targetCategory");
		
		if ($this->getParameter("parts", false) !== false) {
			/* We are moving multiple parts */
			foreach ($this->getParameter("parts") as $part) {
				$part = Part::loadById($part);
				$category = Category::loadById($this->getParameter("targetCategory"));
					
				$part->setCategory($category);
			}
		} else {
			$part = Part::loadById($this->getParameter("part"));
			$category = Category::loadById($this->getParameter("targetCategory"));
			
			$part->setCategory($category);
				
		}
		
		
		PartKeepr::getEM()->flush();
	}
Exemplo n.º 2
0
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"]));
	$oPart->setComment(convertText($part["comment"]));
	$oPart->setFootprint($newFootprints[$part["id_footprint"]]);
	$oPart->setCategory($newCategories[$part["id_category"]]);
	$oPart->setStorageLocation($newStorageLocations[$part["id_storeloc"]]);
	$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";
Exemplo n.º 3
0
<?php

namespace de\RaumZeitLabor\PartKeepr\Tests;

declare (encoding='UTF-8');
include "../src/backend/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;
use de\RaumZeitLabor\PartKeepr\PartUnit\PartUnitManager;
use Doctrine\DBAL\Migrations\Migration, Doctrine\DBAL\Migrations\Configuration\YamlConfiguration;
PartKeepr::initialize();
$aPartResults[] = array();
$dql = "SELECT pp.quantity, p.id FROM ";
$dql .= "de\\RaumZeitLabor\\PartKeepr\\Project\\ProjectPart pp JOIN pp.part p WHERE pp.project = :project";
$query = PartKeepr::getEM()->createQuery($dql);
$query->setParameter("project", 1);
foreach ($query->getArrayResult() as $result) {
    $part = Part::loadById($result["id"]);
    if (array_key_exists($result["id"], $aPartResults)) {
        $aPartResults[$result["id"]]["quantity"] += $result["quantity"];
    } else {
        $aPartResults[$result["id"]] = array("quantity" => $result["quantity"], "part" => array("response" => array("totalCount" => 1, "data" => $part->serialize())), "storageLocation_name" => $part->getStorageLocation()->getName());
    }
}
print_r($aPartResults);
Exemplo n.º 4
0
	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);
			}
		}
	}