public function gerateBilling() { $order = null; $customers = $this->getUserID(); $structJsonArray = array(); foreach ($customers as $customer) { $structJson = new Json(); $structJson->setCustomerId($customer['zoho_books_contact_id']); $structJson->setDate(date('d-m-Y')); $invoices_per_costumer = $this->getUserInvoice($customer['zoho_books_contact_id']); //var_dump($invoices_per_costumer); foreach ($invoices_per_costumer as $invoice_each) { $item = new Item(); $order++; $item->setItemId("460000000027017"); $item->setProjectId(""); $item->setExpenseId(""); $item->setName("Print Services"); $item->setDescription($invoice_each['description']); $item->setItemOrder($order); $item->setRate($invoice_each['rate']); $item->setUnit("Nos"); $item->setQuantity(1.0); $item->setDiscount(0.0); $item->setTaxId("460000000027005"); $structJson->setLineItems($item); $item = null; } $structJson->setNotes("Thanks for your business."); $order = null; $structJsonArray[] = $structJson; $structJson = null; } return $structJsonArray; }
public function testSetGetDescription() { // Arrange $item = new Item(); $item->setDescription('this is an item description'); $expectedResult = 'this is an item description'; // Act $result = $item->getDescription(); // Assert $this->assertEquals($result, $expectedResult); }
public function create(Category $category, $name, $price, $stock, $image, $description) { $errors = array(); $item = new Item($this->db); try { $item->setCategory($category); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $item->setName($name); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $item->setPrice($price); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $item->setStock($stock); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $item->setImage($image); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $item->setDescription($description); } catch (Exception $e) { $errors[] = $e->getMessage(); } if (count($errors) == 0) { $name = $this->db->quote($item->getName()); $price = $this->db->quote($item->getPrice()); $stock = $this->db->quote($item->getStock()); $image = $this->db->quote($item->getImage()); $description = $this->db->quote($item->getDescription()); $idCategory = $item->getCategory()->getId(); $query = ' INSERT INTO item (id_category, name, price, stock, image, description) VALUES(' . $idCategory . ',' . $name . ',' . $price . ',' . $stock . ',' . $image . ',' . $description . ')'; $res = $this->db->exec($query); if ($res) { $id = $this->db->lastInsertId(); if ($id) { return $this->readByID($id); } else { throw new Exception('Internal server Error'); } } } }
function testSetDescription() { //Arrange $description = "Pliny the Elder"; $cost = 5.0; $id = null; $test_item = new Item($description, $cost, $id); $new_description = "Pliny the Younger"; //Act $test_item->setDescription($new_description); $result = $test_item->getDescription(); //Assert $this->assertEquals($new_description, $result); }
/** * Takes a Feed object and updates the Item table with new entries on that feed * Returns number of new records added **/ protected function updateFeed($feedRecord) { $feed = $this->getFeed($feedRecord->getLink()); echo "Feed: ", $feedRecord->getLink(), " (", count($feed->entries), " items)\n"; $itemCriteria = new Criteria(); $newItems = 0; // Short circuit if the feed parsing failed if (empty($feed) || empty($feed->entries)) { echo "ERROR: Returned feed not valid, or empty\n"; return 0; } foreach ($feed->entries as $entry) { //echo $entry->title, "\n"; // Check whether this entry already exists $itemCriteria->add(ItemPeer::ATOMID, $entry->id, Criteria::EQUAL); $num = ItemPeer::doCount($itemCriteria); // Skip the current entry if we already have it if ($num > 0) { //echo "INFO: Duplicate atom id: {$entry->id}. Skipping\n"; continue; } // Create a new Item record, and save $item = new Item(); $item->fromArray(array('Atomid' => $entry->id, 'Title' => $entry->title, 'Link' => $this->getLinkHref($entry->links, 'alternate'), 'Description' => '', 'Published' => $entry->published)); if (!empty($entry->content->text)) { $item->setDescription($entry->content->text); } elseif (!empty($entry->summary)) { $item->setDescription($entry->summary); } $item->setFeed($feedRecord); //print_r($item); $item->save(); $newItems++; } return $newItems; }
function scrapeHtml() { $url = "http://nivent.nicovideo.jp/"; $items = array(); $html = file_get_html($url); foreach ($html->find('div[id=list] div[class=box clearfix]') as $key => $html_item) { //データの元 //var_dump($html_item); $title = $html_item->find('div[class=infoUpper] strong a'); $link = $html_item->find('div[class=infoUpper] strong a'); $description = $html_item->find('div[class=infoLower] p[class=body]'); $thumbnail = $html->find('div[class=thumb] img'); //var_dump($link); //アイテムを格納 $item = new Item(); $item->setTitle($title[0]->innertext); $item->setLink("http://nivent.nicovideo.jp" . $link[0]->href); $item->setDescription(createImgTag($thumbnail[$key]->src) . $description[0]->innertext); $items[] = $item; } return $items; }
/** * createItem * -- * @param Item $item * @param $sku * @param $description * @return ArrayOfItem|int|mixed|null */ public function createItem(Item $item, $sku, $description) { if ($item != null) { // Instantiate a new ArrayOfItem try { // Set SKU & description of new item $item->setSKU($sku); $item->setDescription($description); // Set array of items, inc. above item. $aoItems = new ArrayOfItem(); $aoItems->setItem([$item]); // return the new [items]. return $aoItems; } catch (Exception $e) { // Something went wrong - error_log & return error message error_log($e->getMessage() . "-" . $e->getTraceAsString()); return $e->getCode(); } } else { return null; } }
function createAction(Request $request, Application $app) { if (null === ($user = $app['session']->get('user'))) { return $app->redirect('/login'); } $newItem = new Item(); $newItem->setName($request->get('name')); $newItem->setDescription($request->get('description')); $newItem->setPrice($request->get('price')); $newItem->setCalories($request->get('calories')); $newItem->setAllergyInformation($request->get('allergyInformation')); $em = $app['orm.em']; $categoryRepository = $em->getRepository('Category'); $Category = $categoryRepository->find($request->get('category')); $newItem->setCategory($Category); $file = $request->files->get('photo'); $newItem->setPhoto($file->getClientOriginalName()); $file = $request->files->get('photo'); $file->move(__DIR__ . '/../public/img', $file->getClientOriginalName()); $em->persist($newItem); $em->flush(); return $app->redirect('/itemAdmin'); }
post_author_name, post_date, post_source_uri, post_source_name, post_category, category_id, category_name FROM post LEFT JOIN category ON category_id = post_category_id WHERE post_valid=1 LIMIT 10'); while ($row = mysql_fetch_object($request)) { // Creating a new feed item $rssItem = new Item(); $rssItem->setTitle($row->post_title); $rssItem->setDescription($row->post_description); $rssItem->setLink('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id); $rssItem->setGuid('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id, true); $rssItem->setComments('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id . '#comments'); $rssItem->setAuthor($row->post_author_email, $row->post_author_name); $rssItem->setPubDate($row->post_date); $rssItem->setSource($row->post_source_uri, $row->post_source_name); $rssItem->setEnclosure('http://www.mywebsite.com/blog/images/nopicture.jpg', 2800, 'image/jpg'); $rssItem->setCategory('http://www.mywebsite.com/blog/category.php.idCat=' . $row->category_id, $row->category_name); // Add the item to the feed $rssFeed->appendItem($rssItem); } // Save the feed $rssFeed->save(); // SQL connection closing mysql_close();
protected function generateInvoiceItems() { for ($j = 0; $j < mt_rand(1, 10); $j++) { $item = new Item(); $item->setDescription($this->items[array_rand($this->items)]); $item->setUnitaryCost(mt_rand(100, 100000) / 100); $item->setQuantity(mt_rand(1, 10)); if (mt_rand(1, 15) == 1) { $item->setDiscount(mt_rand(1, 70)); } $max_tax = mt_rand(1, 10) == 1 ? mt_rand(1, 3) : 1; for ($kk = 0; $kk < $max_tax; $kk++) { $item->Taxes[] = $this->getRandomTax(); } $this->inv->Items[] = $item; } }
static function getItems(Feed &$feed) { $fid = $feed->getId(); $text = $feed->getMessage(); static::doParse($text); $assocs = static::$array; $result = array(); foreach ($assocs as $index => $assoc) { $item = new Item(); $item->setId($fid . '_' . $index); $item->setFeed($feed); if (isset($assoc['type'])) { $item->setType($assoc['type']); } else { $item->setType('GLOBAL'); } if (isset($assoc['description'])) { $item->setDescription($assoc['description']); } if (isset($assoc['global'])) { $item->setGlobal($assoc['global']); } if (isset($assoc['name'])) { $item->setName($assoc['name']); } if (isset($assoc['note'])) { $item->setNote($assoc['note']); } if (isset($assoc['price_digit'])) { $item->setPrice($assoc['price_digit']); } if (isset($assoc['price'])) { $item->setPriceStr($assoc['price']); } if (isset($assoc['status'])) { $item->setStatus($assoc['status']); } $result[] = $item; } if (!$result) { $item = new Item(); $item->setId($fid . '_0'); $item->setFeed($feed); $item->setType('GLOBAL'); $item->setGlobal($text); $result[] = $item; } return $result; }
$channel = $feed->getElementsByTagName('channel')->item(0); // the whole channel element $channelTitle = $channel->getElementsByTagName('link')->item(0)->nodeValue; // channel title $items = $feed->getElementsByTagName('item'); // All items in this feed foreach ($items as $key) { $title = $key->getElementsByTagName('title')->item(0)->nodeValue; $link = $key->getElementsByTagName('link')->item(0)->nodeValue; $description = $key->getElementsByTagName('description')->item(0)->nodeValue; $pubDate = $key->getElementsByTagName('pubDate')->item(0)->nodeValue; $item = new Item(); $item->setMedia($channelTitle); $item->setTitle($title); $item->setLink($link); $item->setDescription($description); $item->setPubDate($pubDate); $result[] = $item; } } usort($result, 'compareByDate'); function compareByDate(Item $a, Item $b) { $a = strtotime($a->getPubDate()); $b = strtotime($b->getPubDate()); if ($a == $b) { return 0; } return $a < $b ? 1 : -1; } foreach ($result as $val) {
private static function parseTransactionItem($data) { // <transaction> <items> <item> $item = new Item(); // <transaction> <items> <item> <id> if (isset($data["id"])) { $item->setId($data["id"]); } // <transaction> <items> <item> <description> if (isset($data["description"])) { $item->setDescription($data["description"]); } // <transaction> <items> <item> <quantity> if (isset($data["quantity"])) { $item->setQuantity($data["quantity"]); } // <transaction> <items> <item> <amount> if (isset($data["amount"])) { $item->setAmount($data["amount"]); } // <transaction> <items> <item> <weight> if (isset($data["weight"])) { $item->setWeight($data["weight"]); } return $item; }
/** * @covers Debril\RssAtomBundle\Protocol\Parser\Item::setDescription */ public function testSetDescription() { $newDescription = 'A brand new description'; $this->object->setDescription($newDescription); $this->assertEquals($newDescription, $this->object->getDescription()); }
$item->addSizePrice(new SizePrice("M", 25.0)); $item->addSizePrice(new SizePrice("S", 25.0)); $items[] = $item; $item = new Item(); $item->setName("Zipper"); $item->setDescription("Wer mag es nicht, das flauschige Allwetterkleidungsstück für den Nerd von heute. " . "\n\nAuf Wunsch mit eigenem Schriftzug."); $item->setImage("zipper.jpg"); $item->addSizePrice(new SizePrice("XXL", 35.0)); $item->addSizePrice(new SizePrice("XL", 35.0)); $item->addSizePrice(new SizePrice("L", 35.0)); $item->addSizePrice(new SizePrice("M", 35.0)); $item->addSizePrice(new SizePrice("S", 35.0)); $items[] = $item; $item = new Item(); $item->setName("Laser-Foo"); $item->setDescription("Diverse Gegenstände, die wir erfolgreich einer Laserbehandlung unterzogen haben."); $item->setImage("pfannenwender.jpg"); $item->addSizePrice(new SizePrice("Pfannenwender mit Logo", 5.0)); $item->addSizePrice(new SizePrice("Minecraft-Spaten", 5.0)); $items[] = $item; $item = new Item(); $item->setName("Schürze"); $item->setDescription("Es soll auch Nerds geben, die sich in die Küche trauen. Das wollen wir natürlich " . "unterstützen! Die Bestickung wird von unseren Fachkräften Unicorn oder Inte mittels " . "unserer programmierbaren Stickmaschine vorgenommen."); $item->setImage("schuerze.jpg"); $item->addSizePrice(new SizePrice("XXL", 20.0)); $item->addSizePrice(new SizePrice("XL", 20.0)); $item->addSizePrice(new SizePrice("L", 20.0)); $item->addSizePrice(new SizePrice("M", 20.0)); $item->addSizePrice(new SizePrice("S", 20.0)); $items[] = $item; $targetMails = array("*****@*****.**", "*****@*****.**");
require 'autoload.php'; require 'classes/autoload.php'; // Create a new ThreeCentralAPI Class $a = new ThreeCentralAPI("{REDACTED}", "479", "23", "1", "Incapi", "Incapi"); // Retrieve the SoapClient $b = $a->getClient(); // Retrieve the ExternalLoginInformation $external_login_information = $a->getExtLoginData(); // Array of items $aoItems = new ArrayOfItem(); // New item $item = new Item($a->api_customer_id, 0.0, 1.0, 1.0, 1, InventoryMethod::LIFO, 0.99, 12.0, true, true, true, true, true, true, true, true, true, true, true, 5.0, MeasurementSystemType::USImperial, 25.0, 15.0, 10.0, 10.0, false, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 50.0, false, HazMatPackingGroup::aDefault, HazMatFlag::aDefault, 25.0, 0); // set sku of that item $item->setSKU("TEST1"); // set description $item->setDescription("Testing API"); // add item to arr. $aoItems->setItem([$item]); // create order $order = new Order(1); // contact information $contact_info = new ContactInfoExt(3); // company name $contact_info->setCompanyName("Some Company"); // contact information $contact_info->setCustomerName("John Doe"); $contact_info->setDept("IT"); $contact_info->setPhoneNumber1("9547854455"); $contact_info->setName("Johnathon Doe"); $contact_info->setEmailAddress1("*****@*****.**"); $contact_info->setFax("9548884213");
/** * Initialize the object with raw data * * @param $data * @return Item */ public static function initializeWithRawData($data) { $item = new Item(); if (isset($data['description'])) { $item->setDescription($data['description']); } if (isset($data['amount'])) { $item->setAmount($data['amount']); } if (isset($data['price'])) { $item->setPrice($data['price']); } if (isset($data['vat'])) { $item->setVat($data['vat']); } if (isset($data['reference_id'])) { $item->setReferenceId($data['reference_id']); } if (isset($data['total_without_vat'])) { $item->setTotalWithoutVat($data['total_without_vat']); } if (isset($data['total_vat'])) { $item->setTotalVat($data['total_vat']); } if (isset($data['total_with_vat'])) { $item->setTotalWithVat($data['total_with_vat']); } if (isset($data['discount'])) { $item->setDiscount($data['discount']); } if (isset($data['percentage'])) { $item->setDiscountIsPercentage($data['percentage']); } if (isset($data['discount_description'])) { $item->setDiscountDescription($data['discount_description']); } return $item; }
<?php $items = array(); $item = new Item(); $item->setName("RaumZeitLabor T-Shirt"); $item->setDescription("Das Super RZL Shirt"); $item->setImage("tshirt.jpg"); $item->addSizePrice(new SizePrice("XXL", 15.9)); $item->addSizePrice(new SizePrice("XL", 14.9)); $item->addSizePrice(new SizePrice("L", 13.9)); $item->addSizePrice(new SizePrice("M", 12.9)); $item->addSizePrice(new SizePrice("S", 11.9)); $items[] = $item; $item = new Item(); $item->setName("RZL LabCoat"); $item->setDescription("Das Pflichtprogramm für jeden Laboraten! Ein bestickter Labcoat, der auch " . "wunderbar für Ätzsessions geeignet ist. Die Bestickung wird von Unicorn oder Inte " . "mittels unserer Stickmaschine vorgenommen."); $item->setImage("labcoat.jpg"); $item->addSizePrice(new SizePrice("XXL", 15.9)); $item->addSizePrice(new SizePrice("XL", 14.9)); $item->addSizePrice(new SizePrice("L", 13.9)); $item->addSizePrice(new SizePrice("M", 12.9)); $item->addSizePrice(new SizePrice("S", 11.9)); $items[] = $item;
/** * @param Subcategory $subcategory * @param $name * @param $descr * @param $short_descr * @param $price * @param $stock * @return array * @throws Exception */ public function create(Subcategory $subcategory, $name, $descr, $short_descr, $price, $stock) { $errors = array(); $item = new Item($this->db); try { $item->setName($name); $item->setDescription($descr); $item->setShortDescription($short_descr); $item->setPrice($price); $item->setStock($stock); } catch (Exception $e) { $errors[] = $e->getMessage(); } if (count($errors) == 0) { $name = $this->db->quote($item->getName()); $description = $this->db->quote($item->getDescription()); $shortDescription = $this->db->quote($item->getShortDescription()); $price = $this->db->quote($item->getPrice()); $stock = $this->db->quote($item->getStock()); $query = " INSERT INTO item(id_subcategory, name, descr, short_descr, price, stock)\n VALUES(" . $subcategory->getId() . ", " . $name . ", " . $description . ", " . $shortDescription . ", " . $price . ", " . $stock . ")"; $data = $this->db->exec($query); if ($data) { $id = $this->db->lastInsertId(); if ($id) { try { return $this->findById($id); } catch (Exception $e) { $errors[] = $e->getMessage(); return $errors; } } else { throw new Exception('Last insert error'); } } else { throw new Exception('Db error'); } } else { return $errors; } }
/** * Adds a new product/item in this payment request * * @param String $id * @param String $description * @param String $quantity * @param String $amount * @param String $weight * @param String $shippingCost */ public function addItem($id, $description = null, $quantity = null, $amount = null, $weight = null, $shippingCost = null) { $param = $id; if ($this->items == null) { $this->items = array(); } if (is_array($param)) { array_push($this->items, new Item($param)); } else { if ($param instanceof Item) { array_push($this->items, $param); } else { $item = new Item(); $item->setId($param); $item->setDescription($description); $item->setQuantity($quantity); $item->setAmount($amount); $item->setWeight($weight); $item->setShippingCost($shippingCost); array_push($this->items, $item); } } }