Exemplo n.º 1
0
 public function insertItems(Items $items)
 {
     $con = self::openConnection();
     $affected = 0;
     mysqli_begin_transaction($con);
     $stm = mysqli_stmt_init($con);
     $sql = "INSERT INTO category VALUES (?, ?, ?)";
     mysqli_stmt_prepare($stm, $sql);
     foreach ($items->getItems() as $item) {
         $code = $item->getCode();
         $name = $item->getName();
         $parent = $item->getParent() == null ? null : $item->getParent()->getCode();
         mysqli_stmt_bind_param($stm, 'sss', $code, $name, $parent);
         mysqli_stmt_execute($stm);
         if (mysqli_affected_rows($con) == 1) {
             $affected++;
         }
     }
     if ($affected > 0) {
         mysqli_commit($con);
     } else {
         mysqli_rollback($con);
     }
     return $affected;
 }
Exemplo n.º 2
0
function post_list()
{
    // only run on the first call
    if (!Registry::has('rwar_post_archive')) {
        // capture original article if one is set
        if ($article = Registry::get('article')) {
            Registry::set('original_article', $article);
        }
    }
    if (!($posts = Registry::get('rwar_post_archive'))) {
        $posts = Post::where('status', '=', 'published')->sort('created', 'desc')->get();
        Registry::set('rwar_post_archive', $posts = new Items($posts));
    }
    if ($result = $posts->valid()) {
        // register single post
        Registry::set('article', $posts->current());
        // move to next
        $posts->next();
    } else {
        // back to the start
        $posts->rewind();
        // reset original article
        Registry::set('article', Registry::get('original_article'));
        // remove items
        Registry::set('rwar_post_archive', false);
    }
    return $result;
}
Exemplo n.º 3
0
 public function insertItems(Items $items)
 {
     $con = self::openConnection();
     $affected = 0;
     mysqli_begin_transaction($con);
     $stm = mysqli_stmt_init($con);
     $sql = "INSERT INTO product VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
     mysqli_stmt_prepare($stm, $sql);
     foreach ($items->getItems() as $item) {
         $code = $item->getCode();
         $articul = $item->getArticul();
         $name = $item->getName();
         $bmuID = $item->getBasicMeasurementUnit() == null ? null : $item->getBasicMeasurementUnit()->getId();
         $price = $item->getPrice();
         $curID = $item->getCurrency() == null ? null : $item->getCurrency()->getId();
         $muID = $item->getMeasurementUnit() == null ? null : $item->getMeasurementUnit()->getId();
         $parent = $item->getParent() == null ? null : $item->getParent()->getCode();
         mysqli_stmt_bind_param($stm, 'sssdddds', $code, $articul, $name, $bmuID, $price, $curID, $muID, $parent);
         mysqli_stmt_execute($stm);
         if (mysqli_affected_rows($con) == 1) {
             $affected++;
         }
     }
     if ($affected > 0) {
         mysqli_commit($con);
     } else {
         mysqli_rollback($con);
     }
     return $affected;
 }
Exemplo n.º 4
0
 function render()
 {
     $render = new Render();
     $render->assign('update', true);
     $render->display('head.tpl');
     $items = new Items($this->db);
     $list = $items->get_items();
     $render->assign('items', $list);
     $render->display('items.tpl');
     $render->display('foot.tpl');
 }
function updateItem($line_of_text)
{
    $model = new Items();
    $model->item_id = $line_of_text[0];
    $model->company_id = $line_of_text[1];
    $model->part_number = $line_of_text[2];
    if (empty($model->part_number)) {
        $model->part_number = 'Not Available';
    }
    $model->name = $line_of_text[3];
    if (empty($model->name)) {
        $model->name = 'Not Available';
    }
    $model->description = $line_of_text[4];
    $model->barcode = $line_of_text[5];
    $model->location_room = $line_of_text[6];
    $model->location_row = $line_of_text[7];
    $model->location_column = $line_of_text[8];
    $model->location_shelf = $line_of_text[9];
    $model->category_id = $line_of_text[10];
    $model->current_quantity = $line_of_text[11];
    if (empty($model->current_quantity)) {
        $model->current_quantity = '0';
    }
    $model->available_quantity = $line_of_text[12];
    if (empty($model->available_quantity)) {
        $model->available_quantity = '0';
    }
    $model->recommended_lowest_quantity = $line_of_text[13];
    $model->recommended_highest_quantity = $line_of_text[14];
    $model->remarks = $line_of_text[15];
    $model->active = $line_of_text[16];
    $model->image_url = $line_of_text[17];
    $model->sale_price = $line_of_text[18];
    $model->factory_due_date = $line_of_text[19];
    $model->suppliers_id = $line_of_text[20];
    $model->fits_in_model = $line_of_text[21];
    $model->created = $line_of_text[22];
    $model->modified = $line_of_text[23];
    $model->deleted = $line_of_text[24];
    if ($model->save()) {
        echo '<tr style="background-color:#EAF2D3"><td>' . $model->part_number . '</td><td>Part Number Saved</td><td></td> </tr>';
    } else {
        $errors = $model->getErrors();
        echo '<tr style="background-color:#FF8566"><td>' . $model->part_number . '</td><td>Part Number Not Saved</td><td>';
        echo "Item not imported";
        foreach ($errors as $e) {
            echo "<br>" . $e[0];
        }
        echo '</td></tr>';
        //print_r($model->getErrors()).'</td></tr>';
    }
    //end of save else
}
Exemplo n.º 6
0
 /**
  * The default action - show the home page
  */
 public function addAction()
 {
     $arUser = $this->authenticate();
     if (!$this->_request->isPost()) {
         $this->view->channel_id = $this->_getParam('channel_id');
         $this->view->formAction = $this->getRequest()->getBaseUrl() . '/item/add';
     } else {
         $channelID = (int) $this->_getParam('channel_id');
         $item = new Items();
         $item->addItem($channelID, $this->_getParam('title'), $arUser['id']);
         $this->_helper->redirector->goto('add', 'item', null, array('channel_id' => $channelID));
     }
 }
 public function actionCreate()
 {
     Yii::app()->clientScript->registerPackage('items-edit');
     if (!isset($_GET['id']) || NULL == ($model = Items::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'id' => (int) $_GET['id'])))) {
         $model = new Items();
     }
     if (isset($_POST['Items'])) {
         $model->attributes = $_POST['Items'];
         $fn = Files::model()->uploadFile('Items[image]');
         if ($fn) {
             $model->image = $fn['filename'];
         } elseif (isset($_POST['Items']['image_src'])) {
             $model->image = $_POST['Items']['image_src'];
         }
         $new = $model->isNewRecord;
         if ($model->save()) {
             $cats = isset($_POST['categories']) ? $_POST['categories'] : array();
             if (!$new && empty($cats)) {
                 ItemsCategory::model()->deleteAllByAttributes(array('item_id' => $model->id));
             } else {
                 if (!$new) {
                     $dbcats = ItemsCategory::model()->findAll('item_id=:iid', array('iid' => $model->id));
                     $ids = array();
                     foreach ($dbcats as $i => $dbc) {
                         if (false !== ($k = array_search($dbc->category_id, $cats))) {
                             unset($cats[$k]);
                             unset($dbc[$i]);
                         } else {
                             $ids[] = $dbc->category_id;
                         }
                     }
                     //deleteing corresponding categories
                     if (!empty($ids)) {
                         $ids = implode(",", $ids);
                         ItemsCategory::model()->deleteAll('item_id=:iid AND category_id IN (:cid)', array('iid' => $model->id, 'cid' => $ids));
                     }
                 }
                 if (!empty($cats)) {
                     foreach ($cats as $cat) {
                         $c = new ItemsCategory();
                         $c->attributes = array('category_id' => $cat, 'item_id' => $model->id);
                         $c->save();
                     }
                 }
             }
             Yii::app()->user->setFlash('ItemSaved', '1');
             $this->refresh();
         }
     }
     $this->render('_form', array('model' => $model));
 }
Exemplo n.º 8
0
 public static function &get_instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Items();
     }
     return self::$instance;
 }
Exemplo n.º 9
0
 /**
  * Process a single feed
  *
  * @param array $feed Feed information (required elements are 'name' for error reporting, 'feed' for the feed URL and 'id' for the feed's unique internal ID)
  * @return int Number of items added
  */
 public static function process_single($feed)
 {
     do_action('iu-feed-start', $feed);
     $sp =& self::load_feed($feed);
     if ($error = $sp->error()) {
         self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
         do_action('iu-feed-finish', $feed);
         return -1;
     }
     $count = 0;
     $items = $sp->get_items();
     foreach ($items as $item) {
         $new_item = self::normalise($item, $feed['id']);
         $new_item = apply_filters('item_data_precache', $new_item, $feed);
         if (Items::get_instance()->check_item($new_item)) {
             $count++;
             do_action('iu-item-add', $new_item, $feed);
         } else {
             do_action('iu-item-noadd', $new_item, $feed);
         }
     }
     $sp->__destruct();
     unset($sp);
     do_action('iu-feed-finish', $feed);
     return $count;
 }
Exemplo n.º 10
0
function display_page_content()
{
    $section_name = requestIdParam();
    $section = Sections::FindByName($section_name);
    $item_name = getRequestVarAtIndex(3);
    $item = Items::FindByName($item_name);
    $gallery = $item->getGallery();
    ?>

		<h1><?php 
    echo $item->display_name;
    ?>
</h1>
<?php 
    $next_item = $item->findNext($section);
    $prev_item = $item->findPrev($section);
    if ($prev_item) {
        echo "\t\t\t\t<a href=\"" . get_link("portfolio/item/{$section_name}/" . $prev_item->name) . "\">previous</a>\n";
    }
    if ($next_item) {
        echo "\t\t\t\t<a href=\"" . get_link("portfolio/item/{$section_name}/" . $next_item->name) . "\">next</a>\n";
    }
    echo $item->content;
    foreach ($gallery->get_photos() as $photo) {
        echo "<img src=\"/" . $photo->getPublicUrl() . "\" /><br />";
    }
}
Exemplo n.º 11
0
 public static function process()
 {
     header('Content-Type: text/plain; charset=utf-8');
     require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
     $updated = false;
     foreach (self::$feeds as $feed) {
         do_action('iu-feed-start', $feed);
         $sp = self::load_feed($feed);
         if ($error = $sp->error()) {
             self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
             continue;
         }
         $count = 0;
         $items = $sp->get_items();
         foreach ($items as $item) {
             $new_item = self::normalise($item, $feed['id']);
             $new_item = apply_filters('item_data_precache', $new_item);
             if (Items::get_instance()->check_item($new_item)) {
                 $count++;
                 $updated = true;
             }
         }
         do_action('iu-feed-finish', $feed);
     }
     Items::get_instance()->sort_all();
     if ($updated) {
         Items::get_instance()->save_cache();
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($main_item_id)
 {
     $model = new OutboundItemsHistory();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->main_item_id = $main_item_id;
     if (isset($_POST['OutboundItemsHistory'])) {
         $model->attributes = $_POST['OutboundItemsHistory'];
         if ($model->save()) {
             $available_quantity = $model->available_quantity_in_stock - $model->quantity_moved;
             $current_quantity = $model->current_quantity_in_stock - $model->quantity_moved;
             //$q_moved=$model->quantity_moved;
             $itemModel = Items::model()->updateByPk($model->main_item_id, array('available_quantity' => $available_quantity + $model->quantity_moved, 'current_quantity' => $current_quantity + $model->quantity_moved));
             //if($model->save())
             $this->redirect(array('view', 'id' => $model->history_id_item));
         }
     }
     $this->render('create', array('model' => $model));
     /*original
     		if(isset($_POST['OutboundItemsHistory']))
     		{
     			$model->attributes=$_POST['OutboundItemsHistory'];
     			if($model->save())
     				$this->redirect(array('view','id'=>$model->history_id_item));
     		}
     
     		$this->render('create',array(
     			'model'=>$model,
     		));*/
 }
Exemplo n.º 13
0
 public function getByOwner($ownerID)
 {
     $DBH = utility::connectToDB();
     if ($DBH == \NULL) {
         return \NULL;
     }
     $sql = "\n\t\t\t\t  SELECT \n\t\t\t\t\t     * \n\t\t\t\t  FROM \n\t\t\t\t      items\n\t\t\t\t  WHERE \n\t\t\t\t\t  owner = :id\n\t\t\t\t  ";
     try {
         $STH = $DBH->prepare($sql);
         $STH->bindParam(':id', $ownerID);
         if ($STH->execute()) {
             $results = $STH->fetchAll();
         } else {
             echo 'Error: retreaving data\\n';
             print_r($DBH->errorInfo());
             print_r($STH->errorInfo());
             return \NULL;
         }
         $count = $STH->rowCount();
     } catch (PDOException $e) {
         echo 'Error: ' . $e->getMessage();
         $DBH = \NULL;
         return \NULL;
     }
     $DBH = \NULL;
     return Items::newCollection($results, $count);
 }
Exemplo n.º 14
0
function instapaper_submit()
{
    $id = $_GET['id'];
    $item = Items::get_instance()->get_item($id);
    if (false === $item) {
        throw new Exception(_r('Invalid item ID specified', 'instapaper'));
    }
    $user = get_option('instapaper_user');
    if (empty($user)) {
        throw new Exception(sprintf(_r('Please set your username and password in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
    }
    if (!check_nonce($_GET['_nonce'])) {
        throw new Exception(_r('Nonces did not match. Try again.', 'instapaper'));
    }
    $data = array('username' => get_option('instapaper_user', ''), 'password' => get_option('instapaper_pass', ''), 'url' => $item->permalink, 'title' => apply_filters('the_title', $item->title));
    $request = new HTTPRequest('', 2);
    $response = $request->post("https://www.instapaper.com/api/add", array(), $data);
    switch ($response->status_code) {
        case 400:
            throw new Exception(_r('Internal error. Please report this.', 'instapaper'));
        case 403:
            throw new Exception(sprintf(_r('Invalid username/password. Please check your details in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
        case 500:
            throw new Exception(_r('An error occurred when contacting Instapaper. Please try again later.', 'instapaper'));
    }
    instapaper_page_head();
    ?>
	<div id="message">
		<h1><?php 
    _e('Success!');
    ?>
</h1>
		<p class="sidenote"><?php 
    _e('Closing window in...', 'instapaper');
    ?>
</p>
		<p class="sidenote" id="counter">3</p>
	</div>
	<script>
		$(document).ready(function () {
			setInterval(countdown, 1000);
		});

		function countdown() {
			if(timer > 0) {
				$('#counter').text(timer);
				timer--;
			}
			else {
				self.close();
			}
		}

		var timer = 2;
	</script>
<?php 
    instapaper_page_foot();
    die;
}
Exemplo n.º 15
0
 public static function items_getList($start = 0, $limit = null)
 {
     $items = Items::get_instance()->retrieve();
     if ($limit == null) {
         return $items;
     }
     return array_slice($items, $start, $limit, true);
 }
Exemplo n.º 16
0
 public function getIAlltems()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     // $criteria=new CDbCriteria;
     // $criteria->compare('item_id',$this->item_id);
     // $criteria->compare('name',$this->name);
     return $Items = Items::model()->findAll();
 }
Exemplo n.º 17
0
 function render()
 {
     if (isset($_REQUEST['newest'])) {
         $newest = $_REQUEST['newest'];
     } else {
         $newest = 0;
     }
     if (isset($_REQUEST['pivot'])) {
         $pivot = $_REQUEST['pivot'];
     } else {
         $pivot = false;
     }
     $items = new Items($this->db);
     $list = $items->get_items($newest, $pivot);
     $render = new Render();
     $render->assign('items', $list);
     $render->display('items.tpl');
 }
Exemplo n.º 18
0
 public function postClear()
 {
     $clear = Input::get('clear');
     // make sure submit was clicked
     if (!empty($clear)) {
         $items = Items::where('completed', 1)->delete();
     }
     return Redirect::route('home');
 }
Exemplo n.º 19
0
 public function actionView()
 {
     $slug = Yii::app()->request->getParam('slug');
     $criteria = new CDbCriteria();
     $criteria->condition = 'itm_slug=:itm_slug';
     $criteria->params = array(':itm_slug' => $slug);
     $model = Items::model()->find($criteria);
     $this->render('view', array('model' => $model));
 }
Exemplo n.º 20
0
 protected function createGeneralContent()
 {
     $mainTag = new Div();
     $mainTag->addAttribute("style", "margin: 1px 0px 0px 3px;");
     $items = new Items();
     $catalogLinks = new CatalogLinks();
     if (array_key_exists(UrlParameters::PAGE_NAME, $_GET)) {
         $pageNumber = Constants::DEFAULT_PAGE_NUMBER;
         $itemsCount = Labels::VIEW_MODE_NUMERIC_DEF;
         if (array_key_exists(UrlParameters::PAGE_NUM, $_GET)) {
             $pageNumber = Utils::getFromGET(UrlParameters::PAGE_NUM);
         }
         if (array_key_exists(UrlParameters::ITEMS_COUNT, $_GET)) {
             $itemsCount = Utils::getFromGET(UrlParameters::ITEMS_COUNT);
         }
         if (array_key_exists(UrlParameters::SEARCH_VALUE, $_GET)) {
             $itemsType = new CatalogLoader();
             $searchValue = Utils::getFromGET(UrlParameters::SEARCH_VALUE);
             $itemsType->getItemSearchData($pageNumber, $itemsCount, $searchValue);
             if ($itemsType->dataTotalCount == 0) {
                 return "";
             }
             $mainTag->addChild($catalogLinks->getPaginationLinks($pageNumber, $itemsCount, $itemsType->dataTotalCount, 'top'));
             $mainTag->addChild($items->getItemsTable($pageNumber, $itemsCount, $itemsType->data, '', $searchValue));
             $mainTag->addChild($catalogLinks->getPaginationLinks($pageNumber, $itemsCount, $itemsType->dataTotalCount, 'bottom'));
         } else {
             if (array_key_exists(UrlParameters::KEY, $_GET)) {
                 $itemsType = new CatalogLoader();
                 $keyValue = Utils::getFromGET(UrlParameters::KEY);
                 $itemsType->getItemsMenuData($pageNumber, $itemsCount, $keyValue);
                 $mainTag->addChild($catalogLinks->getPaginationLinks($pageNumber, $itemsCount, $itemsType->dataTotalCount, 'top'));
                 $mainTag->addChild($items->getItemsTable($pageNumber, $itemsCount, $itemsType->data, $keyValue, ''));
                 $mainTag->addChild($catalogLinks->getPaginationLinks($pageNumber, $itemsCount, $itemsType->dataTotalCount, 'bottom'));
             } else {
                 $itemsType = new CatalogLoader();
                 $itemsType->getItemsMainData($pageNumber, $itemsCount);
                 $mainTag->addChild($catalogLinks->getPaginationLinks($pageNumber, $itemsCount, $itemsType->dataTotalCount, 'top'));
                 $mainTag->addChild($items->getItemsTable($pageNumber, $itemsCount, $itemsType->data, '', ''));
                 $mainTag->addChild($catalogLinks->getPaginationLinks($pageNumber, $itemsCount, $itemsType->dataTotalCount, 'bottom'));
             }
         }
     }
     return $mainTag;
 }
Exemplo n.º 21
0
function display_page_content()
{
    $listname = getRequestVarAtIndex(2);
    switch ($listname) {
        case "portfolio":
            foreach ($_POST as $ordered_objects => $order_value) {
                // splits up the key to see if we are ordering a section, item or ignoring a portfolio area
                $ordered_parts = explode("_", $ordered_objects);
                // NOTICE: I have learned that when there are portfoli orphans, this reordering script breaks. I removed the hidden fields in the Orphans section, but check in on that if you notice reordering breaking again.
                //$debug = "";
                if ($ordered_parts[0] != "PortFolioAreas") {
                    if ($ordered_parts[0] == "SectionOrder") {
                        $section = Sections::FindById($ordered_parts[1]);
                        $section->display_order = $order_value;
                        $section->save();
                        //$debug .= $section->display_name." updated";
                    } else {
                        $section = Sections::FindById($ordered_parts[0]);
                        $item = Items::FindById($ordered_parts[1]);
                        $item->updateOrderInSection($section, $order_value);
                        //$debug .= $item->display_name." updated";
                    }
                }
                //setFlash( "<h3>".$debug."</h3>" );
                //setFlash( "<h3>".var_export( $_POST, true )."</h3>" );
            }
            break;
        case "areaspages":
            foreach ($_POST as $ordered_objects => $order_value) {
                // splits up the key to see if we are ordering a section, item or ignoring a portfolio area
                $ordered_parts = explode("_", $ordered_objects);
                //$debug = "";
                if ($ordered_parts[0] == "AreaOrder") {
                    $area = Areas::FindById($ordered_parts[1]);
                    $area->display_order = $order_value;
                    $area->save();
                    //$debug .= "$area->display_name updated";
                } else {
                    if ($ordered_parts[0] == "SubPage") {
                        $page = Pages::FindById($ordered_parts[1]);
                        $page->display_order = $order_value;
                        $page->save();
                        //$debug .= "$page->display_name sub page updated";
                    } else {
                        $area = Areas::FindById($ordered_parts[0]);
                        $page = Pages::FindById($ordered_parts[1]);
                        $page->updateOrderInArea($area, $order_value);
                        //$debug .= "$page->display_name updated in $area->display_name";
                    }
                }
            }
            //setFlash( "<h3>".$debug."</h3>" );
            //setFlash( "<h3>".var_export( $_POST, true )."</h3>" );
            break;
    }
}
Exemplo n.º 22
0
/**
 * This is a tool for selecting photos (to possibly add)
 * @param $facebook
 *  Optional. You can provide instance of the Facebook class.
 * @param $upload
 *  Defaults to false. If true, shows an option to upload, as well.
 * @param $action_uri
 *  Defaults to 'items/addPhoto'. The URI to submit the form to.
 * @param $filter_visible
 *  Optional string. Set to 'everyone' to only display albums visible to everyone.
 * @param $on_success
 *  Optional string. The url to redirect to after a photo is added or uploaded.
 */
function items_addPhoto_tool($params)
{
    if (isset(Users::$facebook)) {
        $facebook = Users::$facebook;
    } else {
        $app = Pie_Config::expect('pie', 'app');
        if (!isset(Users::$facebooks[$app])) {
            throw new Pie_Exception_MissingObject(array('name' => 'Users::$facebooks[' . $app . ']'));
        }
        $facebook = Users::$facebooks[$app];
    }
    $defaults = array('facebook' => $facebook, 'upload' => false, 'action_uri' => 'items/addPhoto', 'on_success' => Pie_Request::url());
    extract(array_merge($defaults, $params));
    if (!$facebook instanceof Facebook) {
        throw new Pie_Exception_WrongType(array('field' => '$facebook', 'type' => 'Facebook'));
    }
    if (isset($_REQUEST['_pie']['onSuccess'])) {
        $on_success = $_REQUEST['_pie']['onSuccess'];
    }
    $sn = Pie_Session::name();
    $sid = Pie_Session::id();
    $photos = array();
    if (isset($aid)) {
        $photos = Items::facebookPhotos($facebook, $aid);
        return Pie::view('items/tool/addPhotoList.php', compact('photos'));
    }
    $facebook->require_login();
    $album_rows = Items::facebookAlbums($facebook);
    $albums = array();
    foreach ($album_rows as $ar) {
        if (isset($filter_visible) and $ar['visible'] != $filter_visible) {
            continue;
        }
        $albums[$ar['aid']] = $ar['name'];
    }
    $albums = $albums;
    if (count($album_rows)) {
        $row = reset($album_rows);
        $photos = Items::facebookPhotos($facebook, $row['aid']);
    }
    $throbber_url = Pie_Html::themedUrl('plugins/items/img/anim/throbber.gif');
    $url_json = json_encode(Pie_Uri::url($action_uri));
    Pie_Response::addStylesheet('plugins/items/css/Items.css');
    if (Pie_Request::accepts('text/fbml')) {
        Pie_Response::addScript('plugins/items/fbjs/Items.fb.js');
    } else {
        Pie_Response::addScript('plugins/items/js/Items.js');
    }
    if (is_bool($upload)) {
        $upload = uniqid('up.', false);
    }
    $addPhoto_url_json = json_encode(Pie_Uri::url('items/addPhoto'));
    Pie_Response::addScriptLine("\tPie.Items.urls['items/addPhoto'] = {$addPhoto_url_json};");
    return Pie::view('items/tool/addPhoto.php', compact('action_uri', 'on_success', 'on_added', 'albums', 'photos', 'throbber_url', 'upload'));
}
Exemplo n.º 23
0
 public function executeDetail()
 {
     $id = $this->get('id');
     if (!$id || !($item = \Items::retrieveById($id))) {
         return $this->raise404(t('Product Category not found!'));
     }
     $term = $item->getCat();
     $this->setView('Products/item_detail');
     $this->view()->assign(['item' => $item, 'term' => $term]);
     return $this->renderComponent();
 }
Exemplo n.º 24
0
 function paginated()
 {
     $items = Items::getItems();
     $curPage = isset($this->params[0]) ? $this->params[0] : 0;
     $p = new Pagination($items, $curPage);
     $p->before(APP_URL . '/mymodule/paginated')->after('/anything/else/')->startAtOne();
     $this->_view->pagination = $p;
     $this->_view->items = $items;
     $this->template('content', 'paginatedExemple.phtml');
     $this->show('main.tpl');
 }
Exemplo n.º 25
0
 public function pushProductInListAction($idProduct, $idList)
 {
     $item = new Items();
     $em = $this->getDoctrine()->getManager();
     $productRepository = $em->getRepository('URProductBundle:Product');
     $listRepository = $em->getRepository('URUserBundle:Loyalty');
     $product = $productRepository->findById($idProduct)[0];
     $list = $listRepository->findById($idList)[0];
     $item->setProduct($product);
     $item->setList($list);
     $em->persist($item);
     $em->flush();
     if (($nbItem = $list->getNbItems()) == 0) {
         $list->setType(1);
     }
     $list->setNbItems($nbItem + 1);
     $em->persist($list);
     $em->flush();
     return new Response('Produit ajouté');
 }
Exemplo n.º 26
0
/**
 * Generates a SimplePie object from a list of feeds
 *
 * Takes an input array and parses it using the SimplePie library. Returns a SimplePie object.
 * @param array $input Deprecated
 * @return object SimplePie object with all feed's associated data
 */
function lilina_return_items($input = '', $conditions = array())
{
    foreach (Feeds::get_instance()->getAll() as $the_feed) {
        $feed_list[] = $the_feed['feed'];
    }
    $itemcache = Items::get_instance();
    $itemcache->init();
    $conditions = apply_filters('return_items-conditions', array('time' => time() - 86400));
    $itemcache->set_conditions($conditions);
    $itemcache->filter();
    return apply_filters('return_items', $itemcache);
}
Exemplo n.º 27
0
 /**
  * Edits a item
  * @param Items $item
  */
 public function editItem($item)
 {
     // Validate the inputs
     $validator = Validator::make(Input::all(), $item->getUpdateRules());
     if ($validator->passes()) {
         $oldItem = clone $item;
         $item->name = Input::get('name');
         $item->description = Input::get('description');
         $item->price = Input::get('price');
         $item->city = Input::get('city');
         $item->state = Input::get('state');
         $item->street = Input::get('street');
         $item->prepareRules($oldItem, $item);
         // Save if valid. Password field will be hashed before save
         $item->amend();
     }
     // Get validation errors (see Ardent package)
     $error = $item->errors()->all();
     if (empty($error)) {
         return Redirect::to('item')->with('success', Lang::get('item/item.item_updated'));
     }
 }
Exemplo n.º 28
0
 public function begin()
 {
     $terms = $this->getParams('terms');
     $ordering = $this->getParams('ordering');
     $fetchChild = $this->getParams('fetch_child', false);
     $limit = $this->getParams('limit');
     $q = \Items::select()->where('`is_draft` = 0 AND `status` = :status')->setParameter(':status', 'ACTIVE', \PDO::PARAM_STR);
     if (!empty($ordering)) {
         foreach ($ordering as $_o) {
             $q->addOrderBy(@$_o['field'], @$_o['order']);
         }
     } else {
         $q->orderBy('created_time', 'DESC');
     }
     if ($limit) {
         $q->setMaxResults((int) $limit);
     }
     if (is_array($terms) && !empty($terms)) {
         $t = $terms;
         if ($fetchChild) {
             foreach ($terms as $term_id) {
                 if ($term = \Terms::retrieveById($term_id)) {
                     $descendants = (array) $term->getDescendants();
                     foreach ($descendants as $d) {
                         $t[] = $d->getId();
                     }
                     unset($d);
                 }
             }
         }
         $terms = $t;
         $q->andWhere('`cat_id` IN (' . implode(', ', $terms) . ')');
     } elseif (is_scalar($terms) && is_numeric($terms)) {
         $t = [$terms];
         if ($term = \Terms::retrieveById($terms)) {
             if ($fetchChild) {
                 $descendants = (array) $term->getDescendants();
                 foreach ($descendants as $d) {
                     $t[] = $d->getId();
                 }
                 unset($d);
             }
         }
         if (sizeof($t) > 1) {
             $q->andWhere('`cat_id` IN (' . implode(', ', $t) . ')');
         } else {
             $q->andWhere('`cat_id` = :term_id')->setParameter(':term_id', $terms, \PDO::PARAM_INT);
         }
     }
     $this->items = $q->execute();
 }
Exemplo n.º 29
0
 public function showallAction()
 {
     $this->view->title = "Showing All PSI Inventory";
     $items = new Items();
     $select = $items->select()->setIntegrityCheck(false);
     $select->from('t_items');
     $select->join('t_sites', 't_items.site_id = t_sites.id', 'name AS sitename');
     $select->join('t_status', 't_items.status_id = t_status.id', 'name AS statusname');
     //echo $select->__toString();
     $this->view->items = $items->fetchAll($select);
     //TODO Figure out how to use a view instead
     /* 	$dbconfig = Zend_Registry::get('config');
     		$db = Zend_Db::factory($dbconfig->db);
     		$listing = new Zend_Db_Select($db);
     		$listing->from('t_items');
     		$items = $listing->query();
     	//	$this->view->items = $items->fetchAll();
     		return $items->fetchAll();
     		$this->view->
     	//	$db->closeConnection();
     	//	return $result;
     	*/
 }
Exemplo n.º 30
0
 public function __construct($sp = null)
 {
     $this->data = new DataHandler();
     $current = $this->data->load('items.data');
     if ($current !== null) {
         // Workaround for old, serialized PHP database
         if (($this->items = json_decode($current)) === $current) {
             $this->items = unserialize($current);
         }
         $this->items = (array) $this->items;
         $this->cached_items = $this->items;
     }
     parent::__construct($sp);
 }