This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see .
 public function destroyAction()
 {
     $this->logger->entering();
     try {
         $this->logger->info('Getting item from Params');
         $lineItems = new LineItem();
         $lineItem = $lineItems->find($this->_getParam('id'))->current();
         $this->logger->info('Checking Item is in owned by user');
         if ($lineItem->user_id != $this->session->user_id) {
             throw new Exception("Line Item:{$lineItem->id} is not owned by user:{$this->session->user_id}");
         }
         $this->logger->info('Deleting item from bag');
         $lineItem->delete();
         $this->logger->info('Redirecting to index');
         $this->_redirect('/');
     } catch (Exception $e) {
         $this->logger->warn($e->getMessage());
         $this->flash->notice = 'Invalid Action';
         $this->_redirect('/');
         $this->logger->info('Clearing flash notice');
         $this->flash->keep = 1;
         unset($this->flash->notice);
     }
     $this->logger->exiting();
 }
Esempio n. 2
0
    public function testUnmarshalling()
    {
        $booksXml = <<<XML
<?xml version="1.0"?>
<purchase-order xmlns="http://openuri.org/easypo">
  <customer>
    <name>Gladys Kravitz</name>
    <address>Anytown, PA</address>
  </customer>
  <date>2003-01-07T14:16:00-05:00</date>
  <line-item>
    <description>Burnham's Celestial Handbook, Vol 1</description>
    <per-unit-ounces>5</per-unit-ounces>
    <price>21.79</price>
    <quantity>2</quantity>
  </line-item>
  <line-item>
    <description>Burnham's Celestial Handbook, Vol 2</description>
    <per-unit-ounces>5</per-unit-ounces>
    <price>19.89</price>
    <quantity>2</quantity>
  </line-item>
  <shipper>
    <name>ZipShip</name>
    <per-ounce-rate>0.74</per-ounce-rate>
  </shipper>
</purchase-order>
XML;
        $filepath = dirname(__FILE__) . '/../../_files/EasyPO/';
        $binding = new PiBX_Runtime_Binding($filepath . '/binding.xml');
        $unmarshaller = new PiBX_Runtime_Unmarshaller($binding);
        $po = new PurchaseOrder();
        $po->setDate('2003-01-07T14:16:00-05:00');
        $customer = new Customer();
        $customer->setName('Gladys Kravitz');
        $customer->setAddress('Anytown, PA');
        $lineItem1 = new LineItem();
        $lineItem1->setDescription('Burnham\'s Celestial Handbook, Vol 1');
        $lineItem1->setPerUnitOunces('5');
        $lineItem1->setPrice(21.79);
        $lineItem1->setQuantity(2);
        $lineItem2 = new LineItem();
        $lineItem2->setDescription('Burnham\'s Celestial Handbook, Vol 2');
        $lineItem2->setPerUnitOunces('5');
        $lineItem2->setPrice(19.89);
        $lineItem2->setQuantity(2);
        $shipper = new Shipper();
        $shipper->setName('ZipShip');
        $shipper->setPerOunceRate(0.74);
        $po->setCustomer($customer);
        $po->setLineItems(array($lineItem1, $lineItem2));
        $po->setShipper($shipper);
        $object = $unmarshaller->unmarshal($booksXml);
        $this->assertEquals($po, $object);
    }
Esempio n. 3
0
 public function addLineItem(LineItem $lineItem)
 {
     if ($this->pricesIncludeVat === null) {
         $this->pricesIncludeVat = $lineItem->getPriceIncludesVat();
     } else {
         if ($this->pricesIncludeVat !== $lineItem->getPriceIncludesVat()) {
             throw new \Exception("Lineitems in an invoice an either include VAT or not, but it must be the same for all items");
         }
     }
     $this->lineItems[] = $lineItem;
     return $this;
 }
 public function newAction()
 {
     $this->logger->entering();
     $this->logger->info('Loading user');
     $users = new User();
     $user = $users->find($this->session->user_id)->current();
     $this->logger->info('Finding line items of the user');
     $lineItemTable = new LineItem();
     $where = $this->db->quoteInto('user_id = ?', $user->id);
     $lineItems = $lineItemTable->fetchAll($where);
     $items = array();
     $swapbucksTotal = 0;
     $transactionTotal = 0;
     foreach ($lineItems as $lineItem) {
         $item = $lineItem->findParentRow('Item');
         if (1 == $lineItem->shipping) {
             $shippingCharge = Item::shippingCharge($item->weight);
         } else {
             $shippingCharge = 0;
         }
         $items[$item->name] = array('quantity' => 1, 'transFee' => 1, 'item_id' => $item->id, 'title' => $item->name, 'price' => $item->points, 'line_item_id' => $lineItem->id, 'user_id' => $lineItem->user_id, 'shipping_method' => $lineItem->shipping, 'shipping_charge' => $shippingCharge, 'total' => $item->points + $shippingCharge);
         $swapbucksTotal += $items[$item->name]['total'];
         $transactionTotal += $items[$item->name]['transFee'];
     }
     $this->logger->info('Determine swapbucks to be bought');
     $swapbucksToBuy = null;
     if ($swapbucksTotal > $user->balance) {
         $swapbucksToBuy = $swapbucksTotal - $user->balance;
         $items['Swapbucks'] = array('title' => 'Swapbucks', 'quantity' => $swapbucksToBuy, 'price' => 0, 'shipping_charge' => 0, 'total' => 0, 'transFee' => $swapbucksToBuy);
         $transactionTotal += $swapbucksToBuy;
         $finalBalance = 0;
     } else {
         $finalBalance = $user->balance - $swapbucksTotal;
     }
     $paypalParams = array('cmd' => '_xclick', 'business' => '*****@*****.**', 'return' => 'http://swaplady.com/transactions/create', 'cancel_return' => 'http://swaplady.com/', 'currency_code' => 'USD', 'item_name' => 'Swaplady', 'amount' => $transactionTotal, 'no_shipping' => '1');
     $paypal = new PayPalEWP();
     $paypal->setTempFileDirectory('../tmp');
     //path to temp file
     $paypal->setCertificate('../config/pubcert.pem', '../config/prvkey.pem');
     //path to your public certificate, private key
     $paypal->setCertificateID('KF4WJNF89QEN6');
     //certificate id generated by PayPal when you uploaded your public certificate to your PayPal account
     $paypal->setPayPalCertificate('../config/sandbox_pubcert.pem');
     //PayPal public certificate
     $encryptedButton = $paypal->encryptButton($paypalParams);
     $this->logger->info('Populating the View');
     $this->view->assign(array('title' => 'Shopping Bag', 'user' => $user, 'swapbucksTotal' => $swapbucksTotal, 'transactionTotal' => $transactionTotal, 'swapbucksToBuy' => $swapbucksToBuy, 'finalBalance' => $finalBalance, 'items' => $items, 'paypalParams' => $paypalParams, 'encryptedButton' => $encryptedButton));
     $this->render();
     $this->logger->exiting();
 }
Esempio n. 5
0
 public function swapCart($user)
 {
     Zend_Registry::get('logger')->entering();
     Zend_Registry::get('logger')->debug('Instantiate transaction');
     $transactionId = $this->create();
     Zend_Registry::get('logger')->debug('Find items to buy');
     $lineItemTable = new LineItem();
     $items = $lineItemTable->findItems($user->id);
     $lineItems = $user->findLineItem();
     Zend_Registry::get('logger')->debug('Calculate charges & fees');
     $totalCharges = 0;
     $totalFees = 0;
     /*
             foreach ($items as $item)
             {
                 $totalCharges += $item->points + Item::shippingCharge($item->weight);
                 $totalFees += self::TRANSACTION_CHARGE;
             }
     */
     foreach ($lineItems as $lineItem) {
         $item = $lineItem->findParentItem();
         $totalCharges += $item->points;
         if (1 == $lineItem->shipping) {
             $totalCharges += Item::shippingCharge($item->weight);
         }
         $totalFees += self::TRANSACTION_CHARGE;
     }
     Zend_Registry::get('logger')->debug('Calculate swapbucks to buy');
     $swapbucksToBuy = $totalCharges - $user->balance;
     if ($swapbucksToBuy < 0) {
         $swapbucksToBuy = 0;
     }
     Zend_Registry::get('logger')->debug('Find the swaplady user');
     $users = new User();
     $swaplady = $users->fetchRow('username = "******"');
     Zend_Registry::get('logger')->debug('Transfer charges & fees from paypal');
     $totalPaypalTransfer = $totalCharges + $totalFees;
     PaypalEntry::transfer($transactionId, $user, $swaplady, $totalPaypalTransfer);
     Zend_Registry::get('logger')->debug('Transfer bought swapbucks');
     SwapbuckEntry::transfer($transactionId, $swaplady, $user, $swapbucksToBuy);
     Zend_Registry::get('logger')->debug('Transfer items');
     foreach ($items as $item) {
         $this->swapItem($transactionId, $user, $item);
     }
     Zend_Registry::get('logger')->exiting();
 }
Esempio n. 6
0
 /**
  * Test Test Insert No Key
  */
 function testInsertNoKey()
 {
     $this->initScript('line-item-init.sql');
     $item = new LineItem();
     $item->setId(100);
     $item->setCode("blah");
     $item->setOrder(new Order());
     $item->getOrder()->setId(9);
     $item->setPrice(44.0);
     $item->setQuantity(1);
     $key = $this->sqlmap->Insert("InsertLineItemNoKey", $item);
     $this->assertNull($key);
     $this->assertIdentical(100, $item->getId());
     $param["Order_ID"] = 9;
     $param["LineItem_ID"] = 100;
     $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
     $this->assertNotNull($testItem);
     $this->assertIdentical(100, $testItem->getId());
     $this->initScript('line-item-init.sql');
 }
 public function __construct($data = null)
 {
     parent::__construct($data);
     if ($data) {
         $this->body = isset($data->body) ? $data->body : null;
         $this->toList = isset($data->toList) ? $data->toList : null;
         $this->ccList = isset($data->ccList) ? $data->ccList : null;
         $this->bccList = isset($data->bccList) ? $data->bccList : null;
         $this->state = isset($data->state) ? $data->state : null;
         $this->type = isset($data->type) ? $data->type : null;
         $this->openedAt = isset($data->openedAt) ? $data->openedAt : null;
         if ($data->customer) {
             $this->customer = new \HelpScout\model\ref\PersonRef($data->customer);
         }
         if ($data->attachments) {
             $this->attachments = array();
             foreach ($data->attachments as $at) {
                 $this->attachments[] = new \HelpScout\model\Attachment($at);
             }
         }
     }
 }
Esempio n. 8
0
echo $requiredFields;
?>
','&action=insert&form=frmInvoice','frmInvoice')">
<fieldset id="customer">
<legend>Customer</legend>
<?php 
echo frmElements($fsCustomer);
?>
</fieldset>
<fieldset id="summary">
<legend>Summary</legend>
<?php 
echo frmElements($fsInvoice);
?>
</fieldset>
<?php 
$lineItem = new LineItem();
$lineItem->build();
$payment = new InvoicePayment();
$payment->build();
?>
 
</form>
<script type="text/javascript">
<?php 
echo $icoCollapse;
?>
$("#oOptions").append(icoCollapse);
collapseTabs();
</script>