summaryrefslogtreecommitdiff
path: root/trunk/reprap/web/part-lister/models/supplierpart.php
blob: 273a37f41723d3cc0e8ac99a2089e9668f05cb04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?
	class SupplierPart extends Model
	{
		public function __construct($id = null)
		{
			parent::__construct($id, "supplier_parts");
		}
		
		public function getBuyUrl()
		{
			$supplier = new Supplier($this->get('supplier_id'));
			
			//do we have a url?
			if ($supplier->get('buy_link'))
				return str_replace("%%PARTID%%", $this->get('part_num'), $supplier->get('buy_link'));
			
			return false;
		}
		
		public function orderQuantity($total = null)
		{
			if ($total === null)
				$total = $this->get('total_quantity');
			if (!$total)
				$total = 1;
			
			return ceil($total / $this->get('quantity'));
		}
	}
?>