public function adminShowCustomerForm() { Larasset::start('header')->css('bootstrap-datepicker'); Larasset::start('footer')->js('bootstrap-datepicker'); $data['modes'] = Mode::listModes(); return View::make('customerform', $data); }
public function show() { //Artisan::call('db:dump'); //tt( Receipt::find(2)->user()->get()->toArray() ); Larasset::start('footer')->js('jquery-cookies', 'bootstrap_editable'); $modesArr = Mode::listModes(); //Cartsession::set(); foreach ($modesArr as $key => $value) { @($data['str_modes'] .= ucwords($value) . ':' . $key . ','); } $this->layout->title = Systemsetting::getx('name') . ' - Home'; $this->layout->content = View::make('frontpage', $data); }
private function _update_quantity($product, $inputs) { //Keeping records model instantiated $stocklog = new Stocklog(); //Log Current quantity in stock $stocklog->current_quantity = $product->quantity; /** WE FIRST UPDATE THE QUANTITY **/ //Available symbols and names $avail_symb = array('-' => 'subtract', '+' => 'add'); //We check if maths symbols is there $mathsSymbol = $inputs['value'][0]; //Log add quantity with its maths symbol or not $stocklog->added_quantity = (int) $inputs['value']; if (array_key_exists($mathsSymbol, $avail_symb)) { $inputs['value'] = substr($inputs['value'], 1); $quantitySymbol = $avail_symb[$mathsSymbol]; if ($avail_symb[$mathsSymbol] == 'add') { $product->quantity = $product->quantity + (int) $inputs['value']; } if ($avail_symb[$mathsSymbol] == 'subtract') { $product->quantity = $product->quantity - (int) $inputs['value']; } } else { $product->quantity = (int) $inputs['value']; $quantitySymbol = ''; } //Save the stock log $this->_stockLog($stocklog, $product); /** WE UPDATE ALL THE ACTIVE MODES TOTAL PRICE **/ if (!empty($modes = Mode::listModes())) { foreach ($modes as $value) { $mode_discount = $value . '_discount'; $mode_discountedprice = $value . '_discountedprice'; $mode_price = $value . '_price'; $mode_totalprice = $value . '_totalprice'; $priceToUse = $product->{$mode_discount} == 0 ? $product->{$mode_price} : $product->{$mode_discountedprice}; $product->{$mode_totalprice} = $product->quantity * $priceToUse; } } $mode = $inputs['mode']; $mode_totalprice = $mode . '_totalprice'; $mode_price = $mode . '_price'; $mode_discountedprice = $mode . '_discountedprice'; $mode_discount = $mode . '_discount'; //Save product stock activity $brandLog = $product->brand->name; $productcatLog = $product->categories->name; $log['products'] = "[ {$brandLog} / {$productcatLog} ] = <b class='orange'>" . $product->name . '</b>'; $log['stocktype'] = 'update'; $log['stocktype_update'] = 'quantity'; $log['stocktype_update_quantity'] = $quantitySymbol; $log['stocktype_old'] = $stocklog->current_quantity; $log['stocktype_new'] = (int) $inputs['value']; $this->_saveActivityLog($log); //Ajax response $ajax['value'] = $product->quantity; $ajax['total_price'] = format_money($product->{$mode_totalprice}); $ajax['totalcostprice'] = format_money($product->costprice * $product->quantity); $ajax['discounted_price'] = format_money($product->{$mode_discountedprice}); $ajax['ctype'] = 'quantity'; $ajax['status'] = 'success'; return $ajax; }