Example #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param ProductRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(ProductRequest $request, $id)
 {
     $input = $request->all();
     $input['type'] = 'Product';
     Item::find($id)->update($input);
     return redirect()->route('product.index')->withMessage('Product has been Updated')->withStatus('success');
 }
 public function delete(Request $request, $id)
 {
     $b = Item::find($id);
     $b->name = $request->input('name');
     $b->delete();
     return Redirect('itemmaster');
 }
Example #3
0
 /**
  * @return string
  */
 public function actionIndex()
 {
     $low_stock_items = Item::find()->where('quantity >= 1 AND quantity <= 10')->all();
     $empty_stock_items = Item::find()->where('quantity = 0')->all();
     $logs = Log::find()->orderBy('created_at DESC')->limit(10)->all();
     return $this->render('index', ['low_stock_items' => $low_stock_items, 'empty_stock_items' => $empty_stock_items, 'logs' => $logs]);
 }
Example #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $item = \App\Models\Item::find($id);
     $item->delete();
     return redirect('toDo');
 }
Example #5
0
 /**
  * POST /api/itemRequests
  * @param StoreItemRequest $request
  * @return Response
  */
 public function store(StoreItemRequest $request)
 {
     $currentUser = Auth::user();
     if ($currentUser && $this->itemsRepository->itemAlreadyExists($request)) {
         //Checking $currentUser is true because if it's feedback sent from one of my apps,
         //the itemAlreadyExists method will throw an exception because the user isn't logged in
         return response(['error' => "You already have this item here.", 'status' => Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST);
     } else {
         $item = new Item($request->only(['title', 'body', 'priority', 'urgency', 'favourite', 'alarm', 'not_before', 'recurring_unit', 'recurring_frequency']));
         if ($request->get('recurring_unit') === 'none') {
             $item->recurring_unit = null;
         }
         //This is because the alarm was getting set to 0000-00-00 00:00:00 when no alarm was specified
         if ($request->has('alarm') && !$request->get('alarm')) {
             $item->alarm = null;
         }
         $parent = false;
         if ($request->get('parent_id')) {
             $parent = Item::find($request->get('parent_id'));
             $item->parent()->associate($parent);
         }
         if ($currentUser) {
             $item->user()->associate(Auth::user());
         } else {
             //User is not logged in. It could be a feedback request from one of my apps. Add the item to my items (user_id 1).
             $item->user()->associate(1);
         }
         $item->category()->associate(Category::find($request->get('category_id')));
         $item->index = $item->calculateIndex($request->get('index'), $parent);
         $item->save();
         $item = $this->transform($this->createItem($item, new ItemTransformer()))['data'];
         return response($item, Response::HTTP_CREATED);
     }
 }
Example #6
0
 public function indexAction($test = null)
 {
     $items = Item::find();
     // throw new ApiException('f**k!');
     $this->setMessage(':D');
     $this->setError('D:');
     return $items;
 }
Example #7
0
 public function remove()
 {
     // Get task
     $listItem = $this->getTask();
     // Remove task
     Item::find($listItem)->delete();
     return redirect()->back();
 }
Example #8
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($id)
 {
     //Create stock
     //	Get item
     $item = Item::find($id);
     //	Get suppliers for select list
     $suppliers = Supplier::lists('name', 'id');
     return View::make('inventory.stock.create')->with('item', $item)->with('suppliers', $suppliers);
 }
Example #9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validation_rules($request);
     $itemUpdate = $request->input();
     $item = Item::find($id);
     $item->update($itemUpdate);
     Session::flash('flash_message', 'Data item layanan berhasil diupdate!');
     return redirect('admin/item');
 }
Example #10
0
 /**
  * Updates an existing Menu model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $dataProvider = new ActiveDataProvider(['query' => Item::find()->joinWith('menuItems')->where(['menu_id' => $model->menu_id]), 'pagination' => ['pageSize' => 10]]);
     $all_items = Item::find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->menu_id]);
     } else {
         return $this->render('update', ['model' => $model, 'dataProvider' => $dataProvider, 'all_items' => $all_items]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Item::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'descricao', $this->descricao])->andFilterWhere(['like', 'tipo', $this->tipo]);
     return $dataProvider;
 }
Example #12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Item::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category' => $this->category, 'compressive' => $this->compressive, 'density' => $this->density]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created', $this->created])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'field', $this->field])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'absorption', $this->absorption])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Example #13
0
 /**
  * Updates all book metadata
  *
  * @param $request
  * @param $product
  */
 public function update($request, $product)
 {
     \DB::beginTransaction();
     $product->is->update($request->all());
     $product->is->authors()->sync($request['author-list']);
     $product->update($request->all());
     $item = Item::find($product->organizations()->first()->pivot->id);
     $item->update($request->all());
     if ($request['tag-list']) {
         $item->tags()->sync($request['tag-list']);
     } else {
         $item->tags()->detach();
     }
     \DB::commit();
 }
Example #14
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Item::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['updated_at' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'quantity' => $this->quantity, 'stock' => $this->stock, 'price' => $this->price, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'unit', $this->unit]);
     return $dataProvider;
 }
Example #15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchWithItem($params)
 {
     $query = Item::find();
     $query->innerJoinWith('itemPrices.price');
     $query->joinWith('billItems');
     $query->orderBy(BillItem::tableName() . '.quantity DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new Sort(['attributes' => ['name', 'code', 'quantity', 'quantity_stock', 'created_at', 'updated_at', 'item_total' => ['asc' => ['price.total' => SORT_ASC], 'desc' => ['price.total' => SORT_DESC]]]])]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['quantity' => $this->quantity, 'quantity_stock' => $this->quantity_stock, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'price.total', $this->item_total]);
     return $dataProvider;
 }
Example #16
0
 /**
  * Updates an existing Order model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $order_items = OrderItem::find(['order_id' => $id])->joinWith('item')->all();
     if ($model->load(Yii::$app->request->post())) {
         $request = Yii::$app->request;
         OrderItem::deleteAll(['order_id' => $id]);
         if (isset($request->post()['Order']['order_items'])) {
             $items = $request->post()['Order']['order_items'];
             foreach ($items as $key => $val) {
                 $double = OrderItem::find()->where(['item_id' => $key, 'order_id' => $id])->count();
                 if (!$double) {
                     $order_item = new OrderItem();
                     $order_item->item_id = $key;
                     $order_item->count = $val;
                     $order_item->order_id = $id;
                     $order_item->save();
                 }
             }
         }
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->order_id]);
         }
     } else {
         return $this->render('update', ['model' => $model, 'locations' => $this->getAllLocations(), 'all_menu' => $this->getAllMenu(), 'addons' => Item::find()->asArray()->where(['item_type' => Item::ADDON_TYPE])->all(), 'order_items' => $this->getOrderItems($id)]);
     }
 }
Example #17
0
 public function details($id)
 {
     //查看商品详情
     $item = Item::find($id);
     return view('admin.item.details', $item);
 }
 public function find($id)
 {
     return Item::find($id);
 }
Example #19
0
foreach ($modelDetails as $i => $modelDetail) {
    ?>
                        <tr class="item">
                            <td>
                                <b><?php 
    echo $i + 1;
    ?>
</b>
                                <?php 
    if (!$modelDetail->isNewRecord) {
        echo Html::activeHiddenInput($modelDetail, "[{$i}]id");
    }
    ?>
                            </td>
                            <td><?php 
    echo $form->field($modelDetail, "[{$i}]item_id")->widget(Select2::className(), ['data' => ArrayHelper::map(Item::find()->all(), 'id', 'name'), 'disabled' => !$modelDetail->isNewRecord])->label(false);
    ?>
</td>
                            <td><?php 
    echo $form->field($modelDetail, "[{$i}]quantity")->textInput()->label(false);
    ?>
</td>
                            <td><button type="button" class="pull-right remove-item btn btn-danger btn-xs"><i class="fa fa-minus"></i> Hapus</button></td>
                        </div>
                    <?php 
}
?>
                </table>
            <?php 
DynamicFormWidget::end();
?>
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Item::find($id);
     $item->delete();
     return redirect()->back();
 }
Example #21
0
 /**
  * Delete an Item of a Conference.
  *
  * @param  ItemRequest  $request
  * @param  int  $cid
  * @param  int  $iid
  * @return Response
  */
 public function destroy(ItemRequest $request, $cid, $iid)
 {
     try {
         $user = $this->isConferenceManager($request, $cid);
         if (!$user) {
             return response()->error(403, 'You are not a manager of this conference!');
         }
         $conference = Conference::find($cid);
         if (!$conference) {
             return response()->error(404, 'Conference Not Found');
         }
         $item = Item::find($iid);
         if (!$item) {
             return response()->error(404, 'Item Not Found');
         }
         $item->delete();
         return response()->success();
     } catch (Exception $e) {
         return response()->error();
     }
 }
Example #22
0
 public function getItem($itemId)
 {
     return Item::find($itemId);
 }
 public function download_csv_damaged(Request $request, $id)
 {
     if ($request->ajax()) {
         $search_value = $request->input('search_value');
         if ($search_value == NULL) {
             $download_csv_data = Factoryitem::damage($id);
             $item = Item::find($id);
             return response()->json(array('download_csv_data' => $download_csv_data, 'item' => $item));
         } else {
             $download_csv_data = Factoryitem::where('itemsid', $id)->where(function ($query) use($search_value) {
                 $query->where('slno', 'like', '%' . $search_value . '%')->orWhere('created_at', 'like', '%' . $search_value . '%');
             })->where('status', 0)->get();
             $item = Item::find($id);
             return response()->json(array('download_csv_data' => $download_csv_data, 'item' => $item));
         }
     }
 }
Example #24
0
 public function maxId()
 {
     $id = Item::find()->select('max(id)')->scalar();
     return $id;
 }
Example #25
0
?>
<div class="menu-update">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo $this->render('_form', ['model' => $model]);
?>
    
    <div class="row">
        <div class = "col-xs-4" id="menu_items_select">
             <?php 
$items = ArrayHelper::map(Item::find()->joinWith(['itemTypeName'])->where(['!=', 'item_type', Item::ADDON_TYPE])->all(), 'item_id', 'item_name', 'itemTypeName.item_type_name');
$params = ['multiple' => 'true'];
echo Html::activeDropDownList($model, 'menuItems', $items, $params);
?>
        </div>
        <div class="col-xs-2"><button class="btn btn-primary" id='add_to_menu' data-menu="<?php 
echo $model->menu_id;
?>
"> Add Items </button></div>
    </div>
    <br>
    <?php 
\yii\widgets\Pjax::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'item_id', 'item_name', 'item_price', 'item_tarif', 'itemTypeName.item_type_name', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $object) {
Example #26
0
/**
 * RESTORE an item 
 *
 * (the model migth allow soft deletes!)
 *
 * Make sure the new sequence number fits sequentially into 
 *    the list of sequence numbers of the existing items for a plan
 *    and that all current sequence numbers are in 1.0 steps
 *
 * @param object $items
 * @param number $new_seq_no
 */
function restoreItem($id)
{
    // this item should be restored
    $item = Item::onlyTrashed()->find($id);
    if (!$item) {
        return false;
    }
    $item->restore();
    // get all items of the related plan
    $plan = Plan::find($item->plan_id);
    $items = $plan->items()->orderBy('seq_no')->get();
    // numbering them countering with 1.0
    $counter = 1.0;
    foreach ($items as $item) {
        if ($item->seq_no != $counter) {
            $i = Item::find($item->id);
            # get the actual DB record
            $item->seq_no = $counter;
            # update the current selection
            $i->seq_no = $counter;
            # update the seq_no
            $i->save();
            # save the record
        }
        $counter += 1.0;
    }
    return true;
}
Example #27
0
 /**
  * REMOVE the specified resource from storage.
  *(if the model allows soft-deletes)
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function trash($id)
 {
     $item = Item::find($id);
     if ($item) {
         $plan_id = $item->plan_id;
         $plan = Plan::find($plan_id);
     } else {
         flashError('Error! Item with ID "' . $id . '" not found! (F:trash)');
         return \Redirect::back();
     }
     // check user rights (teachers and leaders can edit items of their own plan)
     if (!checkRights($plan)) {
         return redirect()->back();
     }
     // get item and delete it
     $item = deleteItem($id);
     if ($item) {
         // notify event listener that an item was updated
         event(new CspotItemUpdated($item));
         // back to full plan view
         //flash('Item deleted.');
         return \Redirect::route('plans.edit', $plan_id);
     }
     flashError('Error! Problem trying to delete item with ID "' . $id . '"');
     return \Redirect::back();
 }
Example #28
0
 /**
  *
  * @return array
  */
 public function descendants()
 {
     $descendant_ids = [];
     $index = 0;
     while (true) {
         $item = Item::find($descendant_ids[$index]);
         //Add all the item's immediate children to the array
         foreach ($item->children()->lists('id') as $child_id) {
             $descendant_ids[] = $child_id;
         }
         $index++;
     }
     return $descendant_ids;
 }
 public function delete($id)
 {
     Item::find($id)->delete();
 }
Example #30
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $item = \App\Models\Item::find($id);
     $document = \App\Models\Item::find($id)->document;
     $type = $document->os_type;
     switch ($type) {
         case 'buildings':
             $variable = \App\Models\Item::find($id)->variable();
             $building = \App\Models\Item::find($id)->building();
             $address = \App\Models\Item::find($id)->address();
             $variable->delete();
             $address->delete();
             $building->delete();
             $item->delete();
             //return Redirect::action('DocumentController@show', [$item->document->id]);
             return redirect()->back();
             break;
         case 'car':
             $variable = \App\Models\Item::find($id)->variable();
             $variable->delete();
             $car = \App\Models\Item::find($id)->car();
             $car->delete();
             $item->delete();
             //return Redirect::action('DocumentController@show', [$item->document->id]);
             return redirect()->back();
             break;
         case 'parcels':
             $parcel = \App\Models\Item::find($id)->parcel();
             $address = \App\Models\Item::find($id)->address();
             $address->delete();
             $parcel->delete();
             $item->delete();
             //return Redirect::action('DocumentController@show', [$item->document->id]);
             return redirect()->back();
             break;
         case 'movables' || 'value_movables':
             $variable = \App\Models\Item::find($id)->variable();
             $variable->delete();
             $item->delete();
             //return Redirect::action('DocumentController@show', [$item->document->id]);
             return redirect()->back();
             break;
     }
 }