public function insert_db($item_kode, $voucher_type, $voucher_no, $voucher_dtl_no, $actual_qty, $warehouse, $qty_after_trans, $valuation_rate, $stock_value, $stock_value_diff, $incoming_rate = 0, $batch = null) { $item = Item::first(array('conditions' => "item_kode = '" . $item_kode . "'")); // saat nya entry data stock ledger /* "stock_value" => $stock_value,*/ $attr = array("created" => date("Y-m-d H:i:s"), "modified" => date("Y-m-d H:i:s"), "fiscal_year" => date('Y'), "company" => "RSMM", "posting_date" => date("Y-m-d H:i:s"), "posting_time" => date("H:i:s"), "qty_after_transaction" => $qty_after_trans, "voucher_no" => $voucher_no, "voucher_detail_no" => $voucher_dtl_no, "valuation_rate" => $valuation_rate, "voucher_type" => $voucher_type, "incoming_rate" => $incoming_rate, "item_kode" => $item->item_kode, "item_nama" => $item->item_nama, "item_uom" => $item->item_uom, "batch_no" => $batch, "actual_qty" => $actual_qty, "stock_value" => $stock_value, "stock_value_difference" => $stock_value_diff, "warehouse" => $warehouse); $attr["id"] = ZiUtil::GetNowID(); $this->Table->insert($attr); }
public function packages() { $this->seo(array("title" => "Packages", "view" => $this->getLayoutView())); $view = $this->getActionView(); $ps = array(); $packages = Package::all(array("live = ?" => 1), array("*"), "created", "desc"); foreach ($packages as $p) { $is = array(); $items = json_decode($p->item); foreach ($items as $key => $i) { $it = Item::first(array("id = ?" => $i), array("name")); array_push($is, $it->name); } array_push($ps, array("name" => $p->name, "price" => $p->price + $p->tax, "item" => implode(",", $is), "id" => $p->id)); } $view->set("packages", $ps); }
/** * Update an Item * @before _secure, _admin */ public function edit($item_id) { $item = Item::first(array("id = ?" => $item_id)); if (!$item) { $this->redirect("/admin"); } $this->seo(array("title" => "Items | Edit", "view" => $this->getLayoutView())); $view = $this->getActionView(); $errors = array(); if (RequestMethods::post("action") == "updateItem") { $response = $this->_saveItem($item); if ($response["success"]) { $item = $response["item"]; $view->set("success", "Item Updated!!"); } else { $errors = $response["errors"]; } } $view->set("errors", $errors)->set("item", $item)->set("items", $this->items); }
protected function session($user) { $this->setUser($user); $now = strftime("%Y-%m-%d", strtotime('now')); $session = Registry::get("session"); $subscriptions = array(); $subscription = \Subscription::all(array("user_id = ?" => $user->id, "live = ?" => true, "expiry > ?" => $now), array("item_id")); foreach ($subscription as $s) { $item = \Item::first(array("id = ?" => $s->item_id), array("name")); array_push($subscriptions, $item->name); } $session->set("subscriptions", $subscriptions); }