예제 #1
0
 public function getWarehouseList()
 {
     /* Load Model of warehouses and setup the list */
     App::import('Model', 'Warehouse');
     $warehouse = new Warehouse();
     /* Set conditions */
     $options = array('fields' => array('City.city_name', 'Warehouse.warehouse_name', 'Warehouse.id'), 'joins' => array(array('alias' => 'City', 'table' => 'cities', 'type' => 'LEFT', 'conditions' => array('City.id = WarehouseDesc.city_id'))), 'conditions' => array('WarehouseDesc.is_deleted' => 0));
     $getWarehouseAllWithStatus = $warehouse->find('all', $options);
     $newWarehouseList = array();
     if ($warehouse->find('count') > 0) {
         foreach ($getWarehouseAllWithStatus as $index => $value) {
             $newWarehouseList[$value["Warehouse"]["id"]] = $value["Warehouse"]["warehouse_name"] . " (" . $value["City"]["city_name"] . ")";
         }
     }
     return $getWarehouseList = $newWarehouseList;
 }
예제 #2
0
 public function getWarehouseList()
 {
     /* Load Model of warehouses and setup the list */
     App::import('Model', 'Warehouse');
     $warehouse = new Warehouse();
     $getWarehouseAllWithStatus = $warehouse->find('all');
     $newWarehouseList = array();
     if ($warehouse->find('count') > 0) {
         foreach ($getWarehouseAllWithStatus as $index => $value) {
             if ($value["WarehouseDesc"]["is_deleted"] == "1") {
                 $newWarehouseList[$value["Warehouse"]["id"]] = $value["Warehouse"]["warehouse_name"] . " (Under Deleted)";
             } else {
                 $newWarehouseList[$value["Warehouse"]["id"]] = $value["Warehouse"]["warehouse_name"];
             }
         }
     }
     return $getWarehouseList = $newWarehouseList;
 }
예제 #3
0
 public function postWarehouseEdit($WarehouseId)
 {
     $rules = array('name' => 'required|min:2|unique:warehouse,name,' . $WarehouseId, 'user_id' => 'unique:warehouse,user_id,' . $WarehouseId);
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('goods/warehouse-edit/' . $WarehouseId)->withErrors($validator)->withInput();
     }
     $warehouse = Warehouse::find($WarehouseId);
     $warehouse->name = Input::get('name');
     $warehouse->user_id = Input::get('user_id');
     $warehouse->save();
     return Redirect::to('goods/warehouse-all')->with('success', '仓库更新成功!');
 }
예제 #4
0
 public function getRecoverEmptyGood($goodEmptyId)
 {
     $good_empty = GoodEmpty::find($goodEmptyId);
     $branch = Branch::find($good_empty->branch_id);
     $warehouse = Warehouse::find(Input::get('warehouse_id'));
     $products = Product::where('store', '>', 0)->where('price', '>', 0)->where('warehouse_id', $warehouse->id)->where('good_id', '=', $good_empty->good_id)->get();
     return View::make('branch.recover-empty-good')->with(compact('products'))->with(compact('branch'))->with(compact('warehouse'));
 }
예제 #5
0
 public function getPrint()
 {
     $warehouse = Warehouse::all();
     $users = User::where('grade', '10')->where('disable', '0')->get();
     $warehouse_name = '';
     $user_name = '';
     $prints = array();
     $count_prints = 0;
     $warehouse_id = Input::get('warehouse_id');
     $user_id = Input::get('user_id');
     if ($warehouse_id === '0' || $user_id === '0') {
         return Redirect::to('picking/print')->with('error', '仓库和业务员都需要选择!');
     }
     if ($warehouse_id && $user_id) {
         $warehouse_name = Warehouse::find($warehouse_id)->pluck('name');
         $user = User::find($user_id);
         $user_name = $user->username;
         $prints = Delivery::where('warehouse_id', $warehouse_id)->where('status', '2')->where('user_id', $user_id)->with('items', 'user')->get();
         $count_prints = count($prints);
     }
     return View::make('picking.print')->with(compact('warehouse'))->with(compact('users'))->with(compact('prints'))->with(compact('warehouse_name'))->with(compact('user_name'))->with(compact('count_prints'));
 }
예제 #6
0
 /**
  * postEditModal
  */
 public function postEditModal()
 {
     $stockup = Input::get('stockup');
     $stockup = json_decode($stockup, true);
     $order_id = Input::get('order_id');
     $order = Order::find(Input::get('order_id'));
     //添加表
     $stock = new Stockup();
     $stock->order_id = $order_id;
     $stock->stockup_count = 0;
     $stock->item_count = 0;
     $stock->amount = 0.0;
     $stock->operator = '5';
     $stock->auditors = '4';
     $stock->save();
     //添加细表
     $stockup_count = $item_count = $amount = 0;
     foreach ($order->orderdetails as $orderdetail) {
         $confirm_quantity = 0;
         $ready_stock = $real_stock = 0;
         if ($stockup[$orderdetail->item->code]['stockup']) {
             foreach ($stockup[$orderdetail->item->code]['stockup'] as $value) {
                 //库存 有位置 identity status
                 if (isset($value['position']) && !empty($value['position'])) {
                     $stockdetail = new StockupDetail();
                     $stockdetail->stockup_id = $stock->id;
                     $stockdetail->identity = isset($value['item']) ? $value['item'] : '';
                     $stockdetail->supplier_id = 0;
                     $stockdetail->item_id = $orderdetail->item->id;
                     $stockdetail->quantity = $value['quantity'];
                     $stockdetail->position = $value['position'];
                     $stockdetail->status = 2;
                     $stockdetail->packaged = 0;
                     $stockdetail->save();
                     //位置减库存
                     $real_stock += $value['quantity'];
                     //预录入状态更新
                     if (isset($value['item'])) {
                         $item_detail = ItemReceivedPackageDetail::find($value['item']);
                         $item_detail->status = 3;
                         $item_detail->save();
                     }
                     //位置库存
                     $item_position = Warehouse::find($value['position']);
                     $item_position->quantity -= $value['quantity'];
                     $item_position->save();
                 } else {
                     //预录入 没有位置
                     $stockdetail = new StockupDetail();
                     $stockdetail->stockup_id = $stock->id;
                     $stockdetail->identity = $value['item'];
                     $stockdetail->supplier_id = '';
                     $stockdetail->item_id = $orderdetail->item->id;
                     $stockdetail->quantity = $value['quantity'];
                     $stockdetail->position = '';
                     $stockdetail->status = 1;
                     $stockdetail->packaged = 0;
                     $stockdetail->save();
                     $ready_stock += $value['quantity'];
                     //预录入状态更新
                     $item_detail = ItemReceivedPackageDetail::find($value['item']);
                     $item_detail->status = 3;
                     $item_detail->save();
                 }
                 $item_count++;
                 $stockup_count += $value['quantity'];
                 $confirm_quantity += $value['quantity'];
                 $amount += $value['quantity'] * $orderdetail->confirm_price;
                 //减状态
                 //减少库存
             }
         }
         //减少库存总数
         $item = Item::find($orderdetail->item->id);
         $item->stock -= $real_stock;
         $item->readystock -= $ready_stock;
         $item->save();
         //更新订单备货数量
         $detail = OrderDetail::find($orderdetail->id);
         $detail->confirm_quantity = $confirm_quantity;
         $detail->save();
     }
     //总计,匹数,米数,金额
     $stock->stockup_count = $stockup_count;
     $stock->item_count = $item_count;
     $stock->amount = $amount;
     $stock->save();
     //更新订单状态|应付款项合计
     $order->item_fee = $amount;
     $order->order_status = 'order_stockuped';
     $order->save();
     return Redirect::to('admin/stockups');
 }
예제 #7
0
 public function d011($id = null)
 {
     $ruang = Warehouse::find($id);
     $ruang->delete();
     ZiUtil::to_json(json_encode("{ success: true}"));
 }