Exemplo n.º 1
0
 public function action_commit()
 {
     $item = new Model_Item();
     $item->name = $_POST['item_name'];
     $item->phonetic = $_POST['phonetic'];
     $item->category = $_POST['category'];
     if ($_POST['category'] == 'ピザ') {
         $item->unit_price_s = $_POST['s_money'];
         $item->unit_price_m = $_POST['m_money'];
         $item->unit_price_l = $_POST['l_money'];
     } else {
         $item->unit_price = $_POST['money'];
     }
     $item->explanatory = $_POST['explanation'];
     $item_img = new Model_Itemimg();
     // 初期設定
     $config = array('path' => DOCROOT . DS . 'assets/img', 'randomize' => true, 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'));
     // アップロード基本プロセス実行
     Upload::process($config);
     // 検証
     if (Upload::is_valid()) {
         // 設定を元に保存
         Upload::save();
         $uploadfile = Upload::get_files(0);
         // 情報をデータベースに保存する場合
         $item_img->path = $uploadfile["name"];
     }
     foreach (Upload::get_errors() as $file) {
         // $file['errors']の中にエラーが入っているのでそれを処理
     }
     $item_img->save();
     $item->img_id = $item_img->id;
     $item->save();
     return View::forge('top/top');
 }
Exemplo n.º 2
0
 public function post_add()
 {
     $order = \Session::get(self::ORDER);
     $order['cart'][] = array('item_id' => $_POST['item_id'], 'item_name' => Model_Item::find($_POST['item_id'])->name, 'category' => Model_Item::find($_POST['item_id'])->category, 'order_id' => "", 'num' => $_POST['num'], 'size' => $_POST['size']);
     \Session::set(self::ORDER, $order);
     return $this->response($order);
 }
Exemplo n.º 3
0
 function init()
 {
     parent::init();
     $this->addCondition('category_id', 2);
     $this->hasMany('Mesh_ItemInward', 'item_id');
     $this->hasMany('Mesh_ItemConsume', 'item_id');
 }
Exemplo n.º 4
0
 public function action_historyin($order_id)
 {
     if (empty(\Session::get(self::SESSION_KEY_CART))) {
         \Session::set(self::SESSION_KEY_CART, array('orders' => array()));
     }
     $cart = \Session::get(self::SESSION_KEY_CART);
     $order = Model_Order::find($order_id);
     $total_money = 0;
     foreach ($order->orderline as $orderline) {
         $item = Model_Item::find($orderline['item_id']);
         $quantity = $orderline['num'];
         switch ($orderline['size']) {
             case 'S':
                 $price = $item->unit_price_s;
                 break;
             case 'M':
                 $price = $item->unit_price_m;
                 break;
             case 'L':
                 $price = $item->unit_price_l;
                 break;
             default:
                 $price = $item->unit_price;
                 break;
         }
         $money = $price * $quantity;
         array_push($cart['orders'], array('item_id' => $item['id'], 'item_name' => $item['name'], 'size' => $orderline['size'], 'quantity' => $quantity, 'money' => $money));
     }
     foreach ($cart['orders'] as $order) {
         $total_money += $order['money'];
     }
     $cart['total_money'] = $total_money;
     \Session::set(self::SESSION_KEY_CART, $cart);
     return Response::redirect('mtpizza/cart');
 }
Exemplo n.º 5
0
 public function action_commit()
 {
     $user_id = \Session::get(self::SESSION_KEY_USER_ID);
     $user = Model_Member::find($user_id);
     $address = \Session::get(self::SESSION_KEY_ADDRESS);
     /*------make order----------------------------------------------------------*/
     $order = new Model_Order();
     $order->member_id = $user->id;
     $order->postalcode = $address['postalcode'];
     $order->destination = $address['address'] . $address['billname'] . $address['companyname'];
     $date = time();
     $order->order_date = date('Y-m-d H:i:s', $date);
     $order->print_flag = 0;
     $order->status = 0;
     $order->save();
     /*-----make orderline------------------------*/
     $cart = \Session::get(self::SESSION_KEY_CART);
     foreach ($cart['orders'] as $orderline) {
         $item_id = $orderline['item_id'];
         $item = Model_Item::find($item_id);
         $num = $orderline['quantity'];
         $size = $orderline['size'];
         $neworderline = new Model_Orderline();
         $neworderline->order_id = $order->id;
         $neworderline->item_id = $item_id;
         $neworderline->num = $num;
         $neworderline->size = $size;
         $neworderline->save();
         $earning = new Model_Earning();
         $earning->member_id = $user->id;
         $earning->item_id = $item_id;
         $earning->size = $size;
         switch ($size) {
             case 'S':
                 $unit_price = $neworderline->item->unit_price_s;
                 break;
             case 'M':
                 $unit_price = $neworderline->item->unit_price_m;
                 break;
             case 'L':
                 $unit_price = $neworderline->item->unit_price_m;
                 break;
             default:
                 $unit_price = $neworderline->item->unit_price;
                 break;
         }
         $earning->unit_price = $unit_price;
         $earning->num = $num;
         $earning->date = date('Y-m-d H:i:s', $date);
         $earning->category = $item->category;
         $earning->item_name = $item->name;
         $now = date('Ymd');
         $birthday = date('Ymd', strtotime($user->birthday));
         $earning->age = (int) floor(($now - $birthday) / 10000);
         $earning->save();
     }
     \Session::delete(self::SESSION_KEY_CART);
     return Response::redirect('index.php/message/commit');
 }
Exemplo n.º 6
0
 public function post_isearch()
 {
     $data = array('item_name' => $_POST['name'], 'category' => $_POST['category']);
     if ($data['item_name'] != "") {
         $result = Model_Item::find('all', array('where' => array(array('name', 'like', "%" . $data['item_name'] . "%"))));
     }
     $result = Model_Item::find('all');
     return $result;
 }
Exemplo n.º 7
0
 public function action_detail($item_id, $order_id = null)
 {
     $item = Model_Item::find($item_id);
     /*if(!empty($item)){
           return Response::redirect('index.php/welcome/404');
       }*/
     $category_table = array('ピザ' => 'pizza', 'サイド' => 'side', 'ドリンク' => 'drink');
     $data['detail'] = array('item_id' => $item->id, 'img_path' => 'website/items/' . $item->img['path'], 'item_name' => $item->name, 'category' => $category_table[$item->category], 'prices' => array('unit_price' => $item->unit_price, 'unit_price_s' => $item->unit_price_s, 'unit_price_m' => $item->unit_price_m, 'unit_price_l' => $item->unit_price_l), 'explanatory' => $item->explanatory);
     $data['order_id'] = $order_id;
     $this->template->content = View::forge('website/content/itemdetail', $data);
 }
Exemplo n.º 8
0
 public function post_add()
 {
     $order = \Session::get(self::ORDER);
     $id = $_POST['id'];
     $item = Model_Item::find($_POST['id']);
     $num = $_POST['num'];
     $size = strtoupper($_POST['size']);
     if ($item->category != 'ピザ') {
         $price_key = 'unit_price';
         $size = "";
     } else {
         switch ($size) {
             case 'S':
                 $price_key = 'unit_price_s';
                 break;
             case 'M':
                 $price_key = 'unit_price_m';
                 break;
             case 'L':
                 $price_key = 'unit_price_l';
                 break;
         }
     }
     foreach ($order['cart'] as $key => $value) {
         if ($value['item_id'] == $id && $value['size'] == $size) {
             if ($num == 0) {
                 unset($order['cart'][$key]);
             } else {
                 $order['cart'][$key]['num'] = $num;
             }
             $order['cart'] = array_values($order['cart']);
             \Session::set(self::ORDER, $order);
             return $this->response($order);
         }
     }
     if ($num != 0) {
         $order['cart'][] = array('item_id' => $id, 'item_name' => $item->name, 'category' => $item->category, 'order_id' => "", 'num' => $num, 'size' => $size, 'unit_price' => $item[$price_key]);
     }
     \Session::set(self::ORDER, $order);
     return $this->response($order);
 }
Exemplo n.º 9
0
 public function post_rowList()
 {
     $vowel = strtolower($_POST['vowel']);
     $category_table = array("pizza" => "ピザ", "side" => "サイド", "drink" => "ドリンク");
     $category = $category_table[$_POST['category']];
     $row_table = array('a' => array('あ', 'い', 'う', 'え', 'お'), 'k' => array('か', 'き', 'く', 'け', 'こ', 'が', 'ぎ', 'ぐ', 'げ', 'ご'), 's' => array('さ', 'し', 'す', 'せ', 'そ', 'ざ', 'じ', 'ず', 'ぜ', 'ぞ'), 't' => array('た', 'ち', 'つ', 'て', 'と', 'だ', 'ぢ', 'づ', 'で', 'ど'), 'n' => array('な', 'に', 'ぬ', 'ね', 'の'), 'h' => array('は', 'ひ', 'ふ', 'へ', 'ほ', 'ば', 'び', 'ぶ', 'べ', 'ぼ', 'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ'), 'm' => array('ま', 'み', 'む', 'め', 'も'), 'y' => array('や', 'ゆ', 'よ'), 'r' => array('ら', 'り', 'る', 'れ', 'ろ'), 'w' => array('わ', 'を', 'ん'));
     $row_initials = $row_table[$vowel];
     $query = Model_Item::query()->where('category', '=', $category)->and_where_open();
     foreach ($row_initials as $initial) {
         $query = $query->or_where('name', 'like', $initial . '%')->or_where('name', 'like', mb_convert_kana($initial, 'C') . '%');
     }
     $itemlist = $query->and_where_close()->order_by('name', 'asc')->get();
     $result = array();
     foreach ($itemlist as $item) {
         if ($category == 'ピザ') {
             $result[] = array('id' => $item->id, 'name' => $item->name, 'size' => 'S', 'place' => $item->unit_price_s);
             $result[] = array('id' => $item->id, 'name' => $item->name, 'size' => 'M', 'place' => $item->unit_price_m);
             $result[] = array('id' => $item->id, 'name' => $item->name, 'size' => 'L', 'place' => $item->unit_price_l);
         } else {
             $result[] = array('id' => $item->id, 'name' => $item->name, 'size' => '', 'place' => $item->unit_price);
         }
     }
     return $result;
 }
 /**
  * Delete an item
  * @param bool $branch Delete the entire branch
  * 
  * @return void 
  */
 public function delete($branch = TRUE)
 {
     // check if it is loaded
     if ($this->loaded() == false) {
         throw HTTP_Exception::factory(500, 'Trying to delete unloaded item');
     }
     if ($branch === FALSE) {
         // save deleted
         $deleted = array(clone $this);
         // just delete item
         parent::delete();
         // return it
         return $deleted;
     } else {
         // get id
         $id = $this->id;
         // unload
         $this->clear();
         // get tree
         $tree = $this->tree();
         // get the wrapped branch
         $items = $tree->branch($id, TRUE)->items();
         // go through items and delete all, save deleted
         $deleted = array();
         foreach ($items as $item) {
             $deleted[] = clone $item;
             $item->delete(FALSE);
         }
         // return deleted
         return $deleted;
     }
 }
 /**
  * Pagination
  * @param Model_Item $model
  * @param Array $settings
  */
 protected function pagination($model, $settings)
 {
     // dont paginate
     if ($settings === FALSE || !isset($settings['step'])) {
         return;
     }
     // get offset from state
     $offset = $this->_state->get('pagination.offset', 0);
     // override offset from request
     if ($this->request->query('offset') != NULL) {
         $offset = $this->request->query('offset');
     }
     // store offset
     $this->_state->set('pagination.offset', $offset);
     // get total from state
     $total = $this->_state->get('pagination.total', FALSE);
     // if no total is known (or 0), fire a query
     if (!$total) {
         // get the total
         $total = $model->count();
         // store  total
         $this->_state->set('pagination.total', $total);
     }
     // set limit and offset on the model
     $model->amount($settings['step']);
     $model->skip($offset);
 }
Exemplo n.º 12
0
 function init()
 {
     parent::init();
     $this->addCondition('state', 'lost');
 }
Exemplo n.º 13
0
 public function init()
 {
     $this->_list["list_rank"][''] = "Select";
     $this->_list["list_rank"]['1'] = "1";
     $this->_list["list_rank"]['2'] = "2";
     $this->_list["list_rank"]['3'] = "3";
     $this->_list["list_rank"]['4'] = "4";
     $this->_list["list_rank"]['5'] = "5";
     //Generate Combos
     $item_category = new Model_ItemCategories();
     $result1 = $item_category->getAllCategories();
     $this->_list["item_category"][''] = "Select";
     foreach ($result1 as $rs) {
         $this->_list["item_category"][$rs['pkId']] = $rs['itemCategoryName'];
     }
     $item_units = new Model_ItemUnits();
     $result2 = $item_units->getAllItemUnits();
     $this->_list["item_unit"][''] = "Select";
     foreach ($result2 as $rs) {
         $this->_list["item_unit"][$rs['pkId']] = $rs['itemUnitName'];
     }
     $item = new Model_Item();
     $result3 = $item->getAllItems();
     $this->_list["item"][''] = "Select";
     foreach ($result3 as $rs) {
         $this->_list["item"][$rs['pkId']] = $rs['description'];
     }
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "item_name":
             case "description":
             case "number_of_doses":
             case "item_category_name":
             case "item_unit_name":
             case "item_description":
             case "percent_population_covered":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
     foreach ($this->_hidden as $col => $name) {
         switch ($col) {
             case "item_id":
             case "item_category_id":
             case "item_unit_id":
             case "item_group_id":
                 $this->addElement("hidden", $col);
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
     }
 }
 /**
  * overwrite default as_array tp set additional parsed url in the data
  */
 public function as_array()
 {
     // get regular data
     $array = parent::as_array();
     if ($this->loaded() === TRUE) {
         // set parsed url
         $array['url'] = $this->url();
     }
     return $array;
 }
Exemplo n.º 15
0
 public function action_index()
 {
     $data['item_list'] = Model_Item::find('all');
     return View::forge("order/order", $data);
 }
Exemplo n.º 16
0
 public function init()
 {
     $items = new Model_Item();
     $result = $items->getProductList();
     $productItem = $items->getProductByCategory();
     for ($j = date('Y'); $j >= 2010; $j--) {
         $this->_year["year"][$j] = $j;
     }
     foreach ($result as $item) {
         $this->_list["product"][$item['pkId']] = $item['itemName'];
     }
     foreach ($productItem as $item) {
         $this->_product_item["product_item"][$item['pkId']] = $item['itemName'];
     }
     $locations = new Model_Locations();
     $res = $locations->getProvinceName();
     $this->_province_list["province"]['all'] = "Select";
     foreach ($res as $loc) {
         $this->_province_list["province"][$loc['pk_id']] = $loc['location_name'];
         $this->_province["prov"][$loc['pk_id']] = $loc['location_name'];
     }
     $this->_reporting_list["reporting_product"]['%'] = "All Product";
     foreach ($result as $item) {
         $this->_reporting_list["reporting_product"][$item['pkId']] = $item['itemName'];
     }
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "month":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => 'May', '6' => 'Jun', '7' => 'Jul', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "dist":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags")));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "batch_no":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "year":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('2014' => '2014', '2013' => '2013', '2012' => '2012', '2011' => '2011', '2010' => '2010')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "coldchain_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'ILR/Refrigerators at District + Field Level', '3' => 'Cold Rooms at District Level')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "cc_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'ILR/Refrigerators at Tehsil + Field Level')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "level":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('all' => 'District + Field', '4' => 'District', '6' => 'Field')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "map_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('2' => 'Provincial', '4' => 'District')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "district_level":
                 $this->addElement("select", $col, array("allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('4' => 'District')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "amc_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('C' => 'Consumption', 'A' => 'Avg.Consumption')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "status":
                 $this->addElement("select", $col, array("allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'Functional', '2' => 'Non-Functional')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "vvm_level":
                 $this->addElement("select", $col, array("allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('3' => 'Provincial', '4' => 'District')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_reporting_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_reporting_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_province_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_province_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_province))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_province[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_year))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_year[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_product_item))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_product_item[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
 }
Exemplo n.º 17
0
 function init()
 {
     parent::init();
     $p = $this->join('purchase');
     $p->addField('date');
     $p->hasOne('Item');
 }
Exemplo n.º 18
0
 public function action_commit()
 {
     $orders = \Session::get(self::ORDER);
     if (count($orders['cart']) == 0) {
         Response::redirect('index.php/controlsystem/order/order');
     }
     $post = $_POST;
     $order = new Model_Order();
     $order->postalcode = $post['postalcode1'] . '-' . $post['postalcode2'];
     $order->destination = $post['address'];
     $order->print_flag = false;
     $order->status = false;
     $date = date("Y-m-d", time());
     $order->order_date = $date;
     $customer = Model_Member::query()->where('name', $post['customer_name'])->get_one();
     if (!empty($customer)) {
         $order->member_id = $customer->id;
     } else {
         $order->member_id = null;
     }
     $order->save();
     $order_id = $order->id;
     //make orderlines
     $orders = \Session::get(self::ORDER);
     foreach ($orders['cart'] as $orderline) {
         $item_id = $orderline['item_id'];
         $item = Model_Item::find($item_id);
         $num = $orderline['num'];
         $size = strtoupper($orderline['size']);
         $neworderline = new Model_Orderline();
         $neworderline->order_id = $order->id;
         $neworderline->item_id = $item_id;
         $neworderline->num = $num;
         $neworderline->size = $size;
         $neworderline->save();
         $earning = new Model_Earning();
         if (!empty($customer)) {
             $earning->member_id = $customer->id;
         } else {
             $earning->member_id = null;
         }
         $earning->item_id = $item_id;
         $earning->size = $size;
         switch ($size) {
             case 'S':
                 $unit_price = $neworderline->item->unit_price_s;
                 break;
             case 'M':
                 $unit_price = $neworderline->item->unit_price_m;
                 break;
             case 'L':
                 $unit_price = $neworderline->item->unit_price_m;
                 break;
             default:
                 $unit_price = $neworderline->item->unit_price;
                 break;
         }
         $earning->unit_price = $unit_price;
         $earning->num = $num;
         $earning->date = $date;
         $earning->category = $item->category;
         $earning->item_name = $item->name;
         $now = date('Ymd');
         if (!empty($customer)) {
             $birthday = date('Ymd', strtotime($customer->birthday));
             $earning->age = (int) floor(($now - $birthday) / 10000);
         } else {
             $birthday = null;
             $earning->age = 0;
         }
         $earning->save();
     }
     return View::forge('controlsystem/order/commit');
 }