本文整理汇总了PHP中Supplier::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Supplier::get方法的具体用法?PHP Supplier::get怎么用?PHP Supplier::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Supplier
的用法示例。
在下文中一共展示了Supplier::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveItem
/**
* (non-PHPdoc)
* @see DetailsPageAbstract::saveItem()
*/
public function saveItem($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
if (!isset($param->CallbackParameter->id)) {
throw new Exception('Invalid supplier ID passed in!');
}
$supplier = ($id = trim($param->CallbackParameter->id)) === '' ? new Supplier() : Supplier::get($id);
if (!$supplier instanceof Supplier) {
throw new Exception('Invalid supplier passed in!');
}
$contactName = trim($param->CallbackParameter->address->contactName);
$contactNo = trim($param->CallbackParameter->address->contactNo);
$street = trim($param->CallbackParameter->address->street);
$city = trim($param->CallbackParameter->address->city);
$region = trim($param->CallbackParameter->address->region);
$postCode = trim($param->CallbackParameter->address->postCode);
$country = trim($param->CallbackParameter->address->country);
$address = $supplier->getAddress();
$supplier->setName(trim($param->CallbackParameter->name))->setDescription(trim($param->CallbackParameter->description))->setContactNo(trim($param->CallbackParameter->contactNo))->setEmail(trim($param->CallbackParameter->email))->setAddress(Address::create($street, $city, $region, $country, $postCode, $contactName, $contactNo, $address))->save();
$results['url'] = '/supplier/' . $supplier->getId() . '.html' . (isset($_REQUEST['blanklayout']) ? '?blanklayout=' . $_REQUEST['blanklayout'] : '');
$results['item'] = $supplier->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage() . $ex->getTraceAsString();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例2: saveOrder
/**
* saveOrder
*
* @param unknown $sender
* @param unknown $param
*
* @throws Exception
*
*/
public function saveOrder($sender, $param)
{
$results = $errors = array();
$daoStart = false;
try {
Dao::beginTransaction();
$daoStart = true;
$supplier = Supplier::get(trim($param->CallbackParameter->supplier->id));
if (!$supplier instanceof Supplier) {
throw new Exception('Invalid Supplier passed in!');
}
$supplierContactName = trim($param->CallbackParameter->supplier->contactName);
$supplierContactNo = trim($param->CallbackParameter->supplier->contactNo);
$supplierEmail = trim($param->CallbackParameter->supplier->email);
if (!empty($supplierContactName) && $supplierContactName !== $supplier->getContactName()) {
$supplier->setContactName($supplierContactName);
}
if (!empty($supplierContactNo) && $supplierContactNo !== $supplier->getContactNo()) {
$supplier->setContactNo($supplierContactNo);
}
if (!empty($supplierEmail) && $supplierEmail !== $supplier->getEmail()) {
$supplier->setEmail($supplierEmail);
}
$supplier->save();
$purchaseOrder = PurchaseOrder::create($supplier, trim($param->CallbackParameter->supplierRefNum), $supplierContactName, $supplierContactNo, StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->shippingCost)), StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->handlingCost)))->setTotalAmount(StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->totalPaymentDue)))->setEta(trim($param->CallbackParameter->eta))->setStatus(PurchaseOrder::STATUS_NEW)->save()->addComment(trim($param->CallbackParameter->comments), Comments::TYPE_PURCHASING);
foreach ($param->CallbackParameter->items as $item) {
if (!($product = Product::get(trim($item->productId))) instanceof Product) {
throw new Exception('Invalid Product passed in!');
}
$purchaseOrder->addItem($product, StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice)), 0 - abs(intval(trim($item->qtyOrdered))));
}
if ($param->CallbackParameter->submitToSupplier === true) {
$purchaseOrder->setStatus(PurchaseOrder::STATUS_ORDERED);
}
// For credit PO
if (isset($param->CallbackParameter->type) && trim($param->CallbackParameter->type) === 'CREDIT') {
$purchaseOrder->setIsCredit(true);
if (isset($param->CallbackParameter->po) && ($fromPO = PurchaseOrder::get(trim($param->CallbackParameter->po->id))) instanceof PurchaseOrder) {
$purchaseOrder->setFromPO($fromPO);
}
}
$purchaseOrder->save();
$daoStart = false;
Dao::commitTransaction();
$results['item'] = $purchaseOrder->getJson();
if (isset($param->CallbackParameter->confirmEmail) && trim($confirmEmail = trim($param->CallbackParameter->confirmEmail)) !== '') {
$pdfFile = EntityToPDF::getPDF($purchaseOrder);
$asset = Asset::registerAsset($purchaseOrder->getPurchaseOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
EmailSender::addEmail('purchasing@budgetpc.com.au', $confirmEmail, 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
EmailSender::addEmail('purchasing@budgetpc.com.au', 'purchasing@budgetpc.com.au', 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
$purchaseOrder->addComment('An email sent to "' . $confirmEmail . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
}
} catch (Exception $ex) {
if ($daoStart === true) {
Dao::rollbackTransaction();
}
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例3: getItems
/**
* Getting the items
*
* @param unknown $sender
* @param unknown $param
* @throws Exception
*
*/
public function getItems($sender, $param)
{
$results = $errors = array();
try {
if (!isset($param->CallbackParameter->searchCriteria->supplierId) || !($supplier = Supplier::get(trim($param->CallbackParameter->searchCriteria->supplierId))) instanceof Supplier) {
throw new Exception('Invalid Supplier provided');
}
if (!isset($param->CallbackParameter->searchCriteria->invoiceNo) || ($invoiceNo = trim($param->CallbackParameter->searchCriteria->invoiceNo)) === '') {
throw new Exception('Invalid Invoice number provided');
}
ReceivingItem::getQuery()->eagerLoad('ReceivingItem.purchaseOrder', 'inner join', 'rec_item_po', 'rec_item_po.id = rec_item.purchaseOrderId');
if (ReceivingItem::countByCriteria('rec_item_po.supplierId = ? and rec_item.invoiceNo = ?', array($supplier->getId(), $invoiceNo)) === 0) {
throw new Exception('There is no such a invoice(invoice No=' . $invoiceNo . ') for supplier:' . $supplier->getName());
}
$sql = 'select ri.productId,
ri.unitPrice `unitPrice`,
sum(ri.qty) `qty`,
group_concat(distinct ri.id) `itemIds`,
group_concat(distinct po.id) `poIds`
from receivingitem ri
inner join purchaseorder po on (po.id = ri.purchaseOrderId)
where ri.active = 1 and ri.invoiceNo = ? and po.supplierId = ?
group by ri.productId, ri.unitPrice';
$params = array($invoiceNo, $supplier->getId());
$rows = Dao::getResultsNative($sql, $params);
$results['supplier'] = $supplier->getJson();
$results['items'] = array();
foreach ($rows as $row) {
$items = count($itemIds = explode(',', $row['itemIds'])) === 0 ? array() : ReceivingItem::getAllByCriteria('id in (' . implode(',', array_fill(0, count($itemIds), '?')) . ')', $itemIds);
$pos = count($poIds = explode(',', $row['poIds'])) === 0 ? array() : PurchaseOrder::getAllByCriteria('id in (' . implode(',', array_fill(0, count($poIds), '?')) . ')', $poIds);
$results['items'][] = array('product' => Product::get($row['productId'])->getJson(), 'totalQty' => $row['qty'], 'totalPrice' => $row['unitPrice'] * $row['qty'], 'items' => array_map(create_function('$a', 'return $a->getJson();'), $items), 'purchaseOrders' => array_map(create_function('$a', 'return $a->getJson();'), $pos));
}
} catch (Exception $ex) {
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例4: updateInvoiceNo
/**
* updateInvoiceNo
*
* @param unknown $sender
* @param unknown $param
* @throws Exception
*
*/
public function updateInvoiceNo($sender, $param)
{
$results = $errors = array();
try {
if (!isset($param->CallbackParameter->supplierId) || !($supplier = Supplier::get(trim($param->CallbackParameter->supplierId))) instanceof Supplier) {
throw new Exception('Invalid Supplier provided.');
}
if (!isset($param->CallbackParameter->newInoviceNo) || ($newInoviceNo = trim($param->CallbackParameter->newInoviceNo)) === '') {
throw new Exception('Invalid newInoviceNo.');
}
if (!isset($param->CallbackParameter->oldInvoiceNo)) {
throw new Exception('Invalid oldInvoiceNo.');
}
$oldInvoiceNo = trim($param->CallbackParameter->oldInvoiceNo);
ReceivingItem::updateByCriteria('invoiceNo = :newInvoiceNo', 'invoiceNo = :oldInvoiceNo and purchaseOrderId in (select po.id from purchaseorder po where po.active = 1 and po.supplierId = :supplierId)', array('newInvoiceNo' => $newInoviceNo, 'oldInvoiceNo' => $oldInvoiceNo, 'supplierId' => $supplier->getId()));
} catch (Exception $ex) {
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例5: _setSupplierCodes
private function _setSupplierCodes(Product &$product, $param)
{
if (isset($param->CallbackParameter->supplierCodes) && count($supplierCodes = $param->CallbackParameter->supplierCodes) > 0) {
foreach ($supplierCodes as $code) {
if (!($supplier = Supplier::get(trim($code->typeId))) instanceof Supplier) {
continue;
}
if (!isset($code->id) || ($id = trim($code->id)) === '') {
if (trim($code->active) === '1') {
SupplierCode::create($product, $supplier, trim($code->value));
}
//if it's deactivated one, ignore
} else {
if (($supplierCode = SupplierCode::get($id)) instanceof SupplierCode) {
$supplierCode->setActive(trim($code->active) === '1')->setCode(trim($code->value))->setSupplier($supplier)->setProduct($product)->save();
}
}
}
}
return $this;
}
示例6: saveItem
/**
* (non-PHPdoc)
* @see DetailsPageAbstract::saveItem()
*/
public function saveItem($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
$perchaseorder = !isset($param->CallbackParameter->id) ? new PurchaseOrder() : PurchaseOrder::get(trim($param->CallbackParameter->id));
if (!$perchaseorder instanceof PurchaseOrder) {
throw new Exception('Invalid Purchase Order passed in!');
}
$purchaseOrderNo = trim($param->CallbackParameter->purchaseOrderNo);
$supplierId = trim($param->CallbackParameter->supplierId);
$supplier = Supplier::get($supplierId);
$orderDate = trim($param->CallbackParameter->orderDate);
$totalAmount = trim($param->CallbackParameter->totalAmount);
$totalPaid = trim($param->CallbackParameter->totalPaid);
if (isset($param->CallbackParameter->id)) {
$perchaseorder->setPurchaseOrderNo($purchaseOrderNo)->setSupplier($supplier)->setSupplierRefNo($supplierId)->setOrderDate($orderDate)->setTotalAmount($totalAmount)->setTotalPaid($totalPaid)->save();
} else {
// PurchaseOrder::
}
$results['url'] = '/purchase/' . $perchaseorder->getId() . '.html';
$results['item'] = $perchaseorder->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage() . $ex->getTraceAsString();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}