Example #1
0
 public static function fromJson($json)
 {
     $r = new Item();
     $r->setId($json->id);
     $r->setSku($json->sku);
     return $r;
 }
Example #2
0
 /**
  * @return void
  **/
 public function __construct()
 {
     $fp = fopen(ROOT . '/data/AbstractFactory/item.csv', 'r');
     while ($data = fgetcsv($fp, 1000, ',')) {
         $item = new Item();
         $item->setId($data[0]);
         $item->setName($data[1]);
         $this->items[$item->getId()] = $item;
     }
     fclose($fp);
 }
Example #3
0
 public static function buildRawExamples()
 {
     // Order persons
     echo ' 8: Initial data: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Inserting an order person
     $newOrderPerson = new \OrderPerson();
     $newOrderPerson->setEmail('*****@*****.**');
     $newOrderPerson->setFirstName('lilian');
     $newOrderPerson->setLastName('tikk');
     $newOrderPerson->insert();
     echo ' 10: After insertion: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Querying full data of an order person
     $orderPerson = new OrderPerson();
     $orderPerson->setId(3);
     $orderPerson->setCompleteOrderPerson();
     echo ' 20: Order person #3: <pre>';
     var_dump($orderPerson);
     echo '</pre>';
     // Updating data of an order person
     $orderPerson->setAddress('Pärnu, Pärnu');
     $orderPerson->update();
     echo ' 24: After updating the order person #3: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Deleting the order person #2
     $orderPerson = new \OrderPerson();
     $orderPerson->setId(2);
     $orderPerson->delete();
     echo ' 43: After deleting the order person #2: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Items
     require_once dirname(__FILE__) . '/Item.php';
     $item = new Item();
     $item->setId(1);
     $item->setName('õun');
     $item->setPrice(1.0);
     $item->setAmount(20.0);
     $item->insertItem($item);
     $item = new \shiporder\Item();
     $item->setId(2);
     $item->setName('pirn');
     $item->setPrice(2.0);
     $item->setAmount(10.0);
     $item->insertItem($item);
     $items = $item->getItems();
     var_dump($items);
 }
Example #4
0
 public function testIndexItemExists()
 {
     // create mocks
     $apiMethods = array('getUserId', 'getSystemValue', 'add3rdPartyScript', 'addStyle', 'addScript');
     $api = $this->getAPIMock($apiMethods);
     $api->expects($this->any())->method('getUserId')->will($this->returnValue('richard'));
     $item = new Item();
     $item->setUser('user');
     $item->setPath('/path');
     $item->setId(3);
     $item->setName('name');
     $itemMapperMock = $this->getMock('ItemMapper', array('findByUserId'));
     $itemMapperMock->expects($this->any())->method('findByUserId')->will($this->returnValue($item));
     $controller = new ItemController($api, null, $itemMapperMock);
     $response = $controller->index();
     $params = $response->getParams();
     $this->assertEquals($item, $params['item']);
 }
Example #5
0
 public function testToExport()
 {
     $item = new Item();
     $item->setId(3);
     $item->setGuid('guid');
     $item->setGuidHash('hash');
     $item->setUrl('https://google');
     $item->setTitle('title');
     $item->setAuthor('author');
     $item->setPubDate(123);
     $item->setBody('body');
     $item->setEnclosureMime('audio/ogg');
     $item->setEnclosureLink('enclink');
     $item->setFeedId(1);
     $item->setStatus(0);
     $item->setRead();
     $item->setStarred();
     $item->setLastModified(321);
     $feed = new Feed();
     $feed->setLink('http://test');
     $feeds = array("feed1" => $feed);
     $this->assertEquals(array('guid' => 'guid', 'url' => 'https://google', 'title' => 'title', 'author' => 'author', 'pubDate' => 123, 'body' => 'body', 'enclosureMime' => 'audio/ogg', 'enclosureLink' => 'enclink', 'unread' => false, 'starred' => true, 'feedLink' => 'http://test'), $item->toExport($feeds));
 }
Example #6
0
 /**
  * Create Item
  */
 static function createItemFromEntity($entity, $qty = 1)
 {
     $item = new Item();
     $item->setId($entity->getId())->setSku($entity->getSku())->setName($entity->getName())->setPrice($entity->getPrice())->setQty($qty)->setIsDiscountable($entity->getIsDiscountable())->setIsTaxable($entity->getIsTaxable());
     return $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;
 }
Example #8
0
 private static function arrayToMenuItem($pages, $depth, $curDepth, $order)
 {
     $items = array();
     foreach ($pages as $pageRow) {
         $page = new \Ip\Page($pageRow['id']);
         $item = new Item();
         $subSelected = false;
         if ($curDepth < $depth) {
             $children = ipDb()->selectAll('page', '*', array('parentId' => $page->getId(), 'isVisible' => 1, 'isSecured' => 0, 'isDeleted' => 0), "ORDER BY {$order}");
             if ($children) {
                 $childrenItems = self::arrayToMenuItem($children, $depth, $curDepth + 1, $order);
                 $item->setChildren($childrenItems);
             }
         }
         if ($page->isCurrent() || $page->getRedirectUrl() && $page->getLink() == \Ip\Internal\UrlHelper::getCurrentUrl()) {
             $item->markAsCurrent(true);
         } elseif ($page->isInCurrentBreadcrumb() || $subSelected || $page->getRedirectUrl() && self::existInBreadcrumb($page->getLink())) {
             $item->markAsInCurrentBreadcrumb(true);
         }
         if ($page->isDisabled()) {
             $item->setUrl('');
         } elseif ($page->getRedirectUrl()) {
             $url = $page->getRedirectUrl();
             if (!preg_match('/^((http|https):\\/\\/)/i', $url)) {
                 $url = 'http://' . $url;
             }
             $item->setUrl($url);
         } else {
             $item->setUrl($page->getLink());
         }
         $metaTitle = $page->getMetaTitle();
         $item->setBlank($page->isBlank());
         $item->setTitle($page->getTitle());
         $item->setDepth($curDepth);
         $item->setDisabled($page->isDisabled());
         $item->setId($page->getId());
         $item->setAlias($page->getAlias());
         $item->setPageTitle(empty($metaTitle) ? $page->getTitle() : $metaTitle);
         $items[] = $item;
     }
     return $items;
 }
Example #9
0
include_once '../DAO/MedicaoDAO.php';
include_once '../Medicao.class.php';
include_once '../../mensagem/Mensagem.class.php';
include_once '../Item.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once '../../head.php';
$permissoes = listarAcesso();
if (!in_array(7, $permissoes)) {
    echo '<script language= "JavaScript">location.href="index.php";</script>';
}
$DAO = new MedicaoDAO();
$DAOMsg = new MensagemDAO();
$mensagem = new Mensagem();
$medicao = new Medicao();
$item_medicao = new Item();
$item_medicao->setId(limpaTexto($_GET['id']));
$id_medicao = $_GET['id'];
if (ChecarAcessoMedicao($id_medicao) != 1) {
    echo '<script language= "JavaScript">location.href="index.php";</script>';
}
//Verifica se a acao de salvar foi iniciada
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'aprovar') {
    $item_medicao->setId($_POST['id']);
    $item_medicao->setIdPessoa($_POST['id_usuario']);
    $item_medicao->setAprovado($_POST['aprovacao']);
    $item_medicao->setDescricao($_POST['descricao']);
    $item_medicao->setCaminho($_POST['caminho']);
    $descricao = $_POST['descricao'];
    $aprovacao = $_POST['aprovacao'];
    $caminho = $_POST['caminho'];
    $medicao = 0;
 /**
  * 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);
         }
     }
 }
 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;
 }
Example #12
0
 /**
  * Get Item Info
  *
  * @param itemId - required -
  *         Item id
  * @return An Item object with details like itemId, expiration date, file details etc.
  * or the error code and message returned by the server.
  * 	 */
 public function getItemInfo($itemId)
 {
     $parameters = array();
     $urld = 'dpi/v1/item/' . $itemId;
     $this->response = $this->_restTransportInstance->sendRequest($urld, $parameters, 'GET', $this->_authToken);
     $responseBody = simplexml_load_string($this->response);
     $returnObject = new Item();
     if ($responseBody === false) {
         $errorCode = 'N/A';
         $errorMessage = 'The server has encountered an error, please try again.';
         $errorObject = new ErrorStatus($errorCode, $errorMessage);
         $returnObject->setErrorStatus($errorObject);
     } else {
         if (empty($responseBody->errorStatus)) {
             $create = (string) $responseBody->create;
             $returnObject->setCreate($create);
             $expiration = (string) $responseBody->expiration;
             $returnObject->setExpiration($expiration);
             $id = (string) $responseBody->id;
             $returnObject->setId($id);
             $subject = (string) $responseBody->subject;
             $returnObject->setSubject($subject);
             $message = (string) $responseBody->message;
             $returnObject->setMessage($message);
             $recipients = (string) $responseBody->recipients;
             $returnObject->setRecipients(explode(",", $recipients));
             $theFiles = array();
             $filesTag = $responseBody->file;
             if (!empty($filesTag)) {
                 foreach ($responseBody->file as $currentFile) {
                     if ($currentFile->count() > 0) {
                         $file = new File();
                         $file->setDownloadUrl((string) $currentFile->downloadUrl);
                         $file->setDownloads((string) $currentFile->downloads);
                         $file->setId((string) $currentFile->id);
                         $file->setName((string) $currentFile->name);
                         $file->setPasswordProtect((string) $currentFile->passwordProtect);
                         $file->setReturnReceipt((string) $currentFile->returnReceipt);
                         $file->setSize((string) $currentFile->size);
                         $file->setVerifyIdentity((string) $currentFile->verifyIdentity);
                         $tracking = array();
                         $trackTag = $currentFile->tracking;
                         if (!empty($trackTag)) {
                             foreach ($currentFile->tracking as $currentTrack) {
                                 if ($currentTrack->count() > 0) {
                                     $track = new Tracking();
                                     $track->setEmail((string) $currentTrack->email);
                                     $track->setWhen((string) $currentTrack->when);
                                     array_push($tracking, $track);
                                 }
                             }
                             $file->setTracking($tracking);
                         }
                         array_push($theFiles, $file);
                     }
                 }
                 $returnObject->setFiles($theFiles);
             }
         } else {
             $errorCode = (string) $responseBody->errorStatus->code;
             $errorMessage = (string) $responseBody->errorStatus->message;
             $errorObject = new ErrorStatus($errorCode, $errorMessage);
             $returnObject->setErrorStatus($errorObject);
         }
     }
     return $returnObject;
 }
Example #13
0
 function salvar($post, $pagina, $is_null = true)
 {
     $item = new Item();
     $DAO = new ItemDao();
     //Verifica se os campos
     if ($item->validacao($post, $is_null)) {
         $exp = explode("-", $post['item']);
         $item->setId($exp[0]);
         $item->setQuantidadeMes($post['quantidade']);
         $item->setValorMes($post['valor']);
         $item->setIntemContrato($exp[1]);
         $res = $DAO->Listar("SELECT qtd_acumulada, valor_acumulado FROM " . MYSQL_BASE_CONTRATO_ITEM . " WHERE id_contrato = 1 AND id=" . $item->getItemContrato() . " LIMIT 1");
         foreach ($res as $row) {
             $item->setQuantidadeAcumulada($row['qtd_acumulada']);
             $item->setValorAcumulado($row['valor_acumulado']);
         }
         $resultado = $DAO->Atualizar($item);
         if ($resultado == true) {
             $qtd = $item->getQuantidadeAcumulada() + $item->getQuantidadeMes();
             $valor_total = $item->getValorAcumulado() + $item->getValorMes();
             //$valor_acumulado;
             $res = $DAO->AtualizarItemContrato($qtd, $valor_total, $item->getItemContrato());
             if ($res != false) {
                 echo '<script language= "JavaScript">alert("Registro cadastrado com sucesso");</script>';
                 echo '<script language= "JavaScript">location.href="' . $pagina . '.php?id=' . $post['medicao'] . '";</script>';
             } else {
                 echo '<script language= "JavaScript">alert("Erro ao atualizar a quantidade acumulada");</script>';
             }
         } else {
             echo '<script language= "JavaScript">alert("Erro ao cadastrar, por favor entre em contato com a TI.");</script>';
         }
     } else {
         echo '<script language= "JavaScript">alert("Preencha todos os campos");</script>';
     }
 }