public function fromJson($json)
 {
     if (!empty($json)) {
         $this->TransactionId = $json['TransactionId'];
         $this->POSTransactionId = $json['POSTransactionId'];
         $this->TransactionTime = $json['TransactionTime'];
         $this->Total = $json['Total'];
         $this->Payer = new UserModel();
         $this->Payer->fromJson($json['Payer']);
         $this->Payee = new UserModel();
         $this->Payee->fromJson($json['Payee']);
         $this->Comment = $json['Comment'];
         $this->Status = $json['Status'];
         $this->TransactionType = $json['TransactionType'];
         $this->Items = array();
         if (!empty($json['Items'])) {
             foreach ($json['Items'] as $i) {
                 $item = new ItemModel();
                 $item->fromJson($i);
                 array_push($this->Items, $item);
             }
         }
         $this->RelatedId = $json['RelatedId'];
         $this->POSId = $json['POSId'];
         $this->PaymentId = $json['PaymentId'];
     }
 }
 public function add()
 {
     return View::make('admin.items.add');
     if (Input::all()) {
         $itemModel = new ItemModel();
         $insert = $itemModel->insert(Input::all());
         if ($insert === TRUE) {
             return Redirect::to('admin/items')->with('message', 'Item added');
         } else {
             return Redirect::to('admin/items/add')->withErrors($insert)->withInput();
         }
     }
 }
示例#3
0
 protected function get()
 {
     global $user, $routes;
     $redirect = false;
     if (isset($_GET['id'])) {
         $result = ListModel::get_from_id($_GET['id']);
         $list = $result->fetchArray(SQLITE3_ASSOC);
         /* check if result exists */
         if ($list && gettype($list) == 'array') {
             /* check that list is owned by user */
             $list_user = ListModel::get_from_id_and_user_id($list['id'], $user->pk)->fetchArray(SQLITE3_ASSOC);
             if ($list_user && gettype($list_user) == 'array') {
                 $this->list = $list;
                 $this->items = ItemModel::get_for_list_id($list['id']);
             } else {
                 $redirect = true;
             }
         } else {
             $redirect = true;
         }
     } else {
         $redirect = true;
     }
     if ($redirect) {
         header('Location: ' . $routes['lists']);
     }
 }
 public function detail($params)
 {
     $category = new ItemModel();
     $result_array = $category->detail($params);
     $validated_params = $category->detailParams($params);
     // $hitCount         = $category->getHitCount();
     $status = new StatusModel($result_array);
     $output = "";
     if (!empty($params["output"])) {
         $output = $params["output"];
     }
     $result = array("status" => $status->toArray(), "params" => $validated_params, "result" => $result_array);
     $view = new item_SearchView();
     $view->appendHeader($status->code);
     $view->appendHeader($output);
     $view->render($result, $output);
 }
示例#5
0
 public function post()
 {
     global $user, $routes;
     parent::get();
     $item_id = isset($_POST['item_id']) ? $_POST['item_id'] : null;
     $is_checked = isset($_POST['checked']) ? $_POST['checked'] : null;
     if (!empty($item_id) && !empty($is_checked)) {
         ItemModel::mark_completed($item_id, $is_checked == 1 ? true : false);
         $this->context['success'] = true;
     }
 }
示例#6
0
 public function post()
 {
     global $user, $routes;
     parent::get();
     $content = $_POST['content'];
     $this->is_json = isset($_GET['json']);
     if (isset($content) && !empty($content)) {
         ItemModel::add($this->list['id'], $content);
         if (!$this->is_json) {
             header('Location: ' . $routes['list_view'] . '?id=' . $this->list['id']);
         } else {
             $r = array('success' => true, 'item_name' => $content, 'list_id' => $this->list['id']);
             header('Content-Type: application/json');
             echo json_encode($r);
         }
     }
 }
示例#7
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ItemModel::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#8
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['CategoryModel'])) {
         $model->attributes = $_POST['CategoryModel'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $modelItem = new ItemModel('search');
     $modelItem->unsetAttributes();
     // clear any default values
     $modelItem->category_id = $model->id;
     if (isset($_GET['ItemModel'])) {
         $modelItem->attributes = $_GET['ItemModel'];
     }
     $this->render('update', array('model' => $model, 'modelItem' => $modelItem));
 }
 /**
  * Check the integrity of an item model. Add missing data if necessary.
  *
  * @param  \REDACTED\Wastage\ItemModel $item
  *
  * @return void
  */
 protected function checkIntegrity(ItemModel $item)
 {
     if ($item->department_id < 1) {
         $item->department()->associate($this->department);
     }
     if ($item->wastage_id < 1) {
         $item->wastage()->associate($this->wastage);
     }
 }
示例#10
0
<?php

class ItemModel extends ImplicitWOGAPModel
{
    public $table = 'wog_df';
}
ItemModel::setParams(array('d_id' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_df' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_mdf' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_mstr' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_magl' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_msmart' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_mau' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'ch_id' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_money' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_name' => array('filter' => FILTER_SANITIZE_STRING), 'd_type' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_fie' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_at' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_mat' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_dbst' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_hp' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_sp' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_str' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_smart' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_agi' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_life' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_vit' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_au' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_g_be' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_s' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_hole' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_plus' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_lv' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'skill' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'stime' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'ch_pro' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_send' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'd_vip' => array('filter' => FILTER_SANITIZE_NUMBER_INT)));
示例#11
0
 public function searchItems()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $model = new ItemModel();
     $model->unsetAttributes();
     $model->section_id = $this->id;
     return $model->search();
 }