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); }
/** * @override * Save the model to the database. * * This function will automatically determine if an INSERT or UPDATE needs to occur. * If a validation or a callback for this model returns false, then the model will * not be saved and this will return false. * * If saving an existing model only data that has changed will be saved. * * @param boolean $validate Set to true or false depending on if you want the validators to run or not * @return boolean True if the model was saved to the database otherwise false */ public function save($validate = true) { if ($this->is_new_record()) { $dt = new \DateTime(); //var_dump($dt->getTimestamp()); $this->set_attributes(array($this->get_primary_key() => ZiUtil::GetTransID())); } //still use save parent return parent::save($validate); }
public function reg_pasien() { $req = APP::request(); $params = $req->get(); $search = ZiUtil::is_set('search', $params); $params["sort"] = "cust_usr_nama"; $params["order"] = "ASC"; $query = "cust_usr_nama ILIKE '%" . $search . "%' OR cust_usr_kode LIKE '%" . $search . "%'"; $results = ZiUtil::search_result_DB($query, $params, 'RegPasien'); return ZiUtil::dataset_json($results['query'], $results['total']); }
public function apiJson() { $comments = file_get_contents('assets/comments.json'); $req = App::request(); if ($req->isPost()) { $post = $req->post(); $commentsDecoded = json_decode($comments, true); $commentsDecoded[] = ['author' => $post['author'], 'text' => $post['text']]; $comments = json_encode($commentsDecoded, JSON_PRETTY_PRINT); file_put_contents('assets/comments.json', $comments); } ZiUtil::to_json($comments); }
public function genInvoice() { $kode_invoice = "070"; $find_invoice = sprintf("SINV-%s-%d-", $kode_invoice, ZiUtil::GetDateNow()); $query = sprintf("id ILIKE '%s%s'", $find_invoice, '%'); var_dump($query); $condition = array('conditions' => $query, 'limit' => 1, 'offset' => 0, 'order' => 'id DESC'); $last_kode_inv = SalesApotik::all($condition); var_dump($last_kode_inv); if (is_null($last_kode_inv)) { $last_kode_inv = "00000"; } $SaleKodeGen = sprintf("SINV-%s-%d-%s", $kode_invoice, ZiUtil::GetDateNow(), str_pad((int) $last_kode_inv + 1, 5, "0", STR_PAD_LEFT)); var_dump($SaleKodeGen); }
public function d011($id = null) { if (!is_null($id)) { $result = ItemPrice::find($id); $result->delete(); ZiUtil::to_json(json_encode("{ success: true}")); return; } App::flash('error', 'Terjadi kesalahan pada inputan anda.'); App::redirect('itemprice.index'); }
private function excel($params) { try { $condition = array(); $data = array(); $dataExcel = array(); if (!empty($params['a']) && !empty($params['z']) && !empty($params['cdate'])) { $col_date = $params['cdate']; $query = sprintf("%s BETWEEN '%s' and '%s' ", $params['cdate'], $params['a'], $params['z']); $condition['conditions'] = $query; } $ar_adapter = \ActiveRecord\ConnectionManager::get_connection($this->app->mode); $connection = $ar_adapter->connection; $stmt = $connection->prepare("select (stocks.get_stock_harian(:awal, :akhir)).*"); $stmt->bindParam(':awal', $params['a']); $stmt->bindParam(':akhir', $params['z']); $stmt->execute(); $stocks = $stmt->fetchAll(PDO::FETCH_CLASS); $dataExcel["B7:C7"] = array('align' => '', 'value' => sprintf("%s sampai dengan %s", $params['a'], $params['z']), 'border' => ''); $line = 10; $i = 1; $total = 0; foreach ($stocks as $row) { $awal = $row->keluar + $row->balance - $row->masuk; $awal = $awal < 0 ? 0 : $awal; $dataExcel["A" . $line] = array('align' => '', 'value' => $i, 'border' => 'all'); $dataExcel["B" . $line] = array('align' => 'center', 'value' => $row->item_kode, 'border' => 'all'); $dataExcel["C" . $line] = array('align' => 'center', 'value' => $row->item_nama, 'border' => 'all'); $dataExcel["D" . $line] = array('align' => 'right', 'value' => $awal, 'border' => 'all', 'num_format' => true); $dataExcel["E" . $line] = array('align' => 'right', 'value' => $row->masuk, 'border' => 'all', 'num_format' => true); $dataExcel["F" . $line] = array('align' => 'right', 'value' => $row->keluar, 'border' => 'all', 'num_format' => true); $dataExcel["G" . $line] = array('align' => 'right', 'value' => $row->balance, 'border' => 'all', 'num_format' => true); $dataExcel["H" . $line] = array('align' => 'center', 'value' => $row->warehouse_nama, 'border' => 'all'); $line++; $i++; $total += 1; } $dataExcel["A" . $line . ":c" . $line] = array('align' => 'right', 'value' => 'Total', 'border' => 'all'); $dataExcel["D" . $line] = array('align' => 'right', 'value' => "=SUM(D10:D" . ($line - 1) . ")", 'border' => 'all', 'num_format' => true); $dataExcel["E" . $line] = array('align' => 'right', 'value' => "=SUM(E10:E" . ($line - 1) . ")", 'border' => 'all', 'num_format' => true); $dataExcel["F" . $line] = array('align' => 'right', 'value' => "=SUM(F10:F" . ($line - 1) . ")", 'border' => 'all', 'num_format' => true); $dataExcel["G" . $line] = array('align' => 'right', 'value' => "=SUM(G10:G" . ($line - 1) . ")", 'border' => 'all', 'num_format' => true); $dataExcel["I" . $line . ":L" . $line] = array('align' => '', 'value' => '', 'border' => 'all'); $fileDetail = ZiUtil::defaultFileDetail(); $fileDetail->template = 'assets/temp/lap_stock.xlsx'; $fileDetail->title = "Laporan Stock"; $fileDetail->subject = "Laporan Stock"; $fileDetail->desc = "Laporan Stock RSMM"; $fileDetail->sheetTitle = "Stock "; $fileDetail->filename = "LSH-" . sprintf("%s-sd-%s", $params['a'], $params['z']) . ".xlsx"; $filename = "LSH-" . sprintf("%s-sd-%s", $params['a'], $params['z']) . ".xlsx"; ZiUtil::generate($filename, $dataExcel, $fileDetail); } catch (Exception $e) { App::flash('error', $e); } }
public function d011($id = null) { $result = UOM::find($id); $result->delete(); ZiUtil::to_json(json_encode("{ success: true}")); }
public static function valuation_rate($item_kode, $warehouse, $batch_no = null) { $query = ""; if (!is_null($batch_no) && !empty($batch_no)) { $query = "batch_no ='" . $batch_no . "' AND "; } $query .= "item_kode ='" . $item_kode . "' AND warehouse ='" . $warehouse . "'"; $conditions = array('conditions' => $query, 'order' => 'created ASC'); $queue = StokQueue::all($conditions); if (empty($queue)) { return 0; } $amount = 0; $amount_qty = 0; foreach ($queue as $row) { $amount += $row->qty * $row->incoming_rate; $amount_qty += ZiUtil::check_int($row->qty); } if ($amount > 0 && $amount_qty > 0) { $valuation_rate = $amount / $amount_qty; return $valuation_rate > 0 ? $valuation_rate : 0; } return 0; }
public function d011($id = null) { if (!empty($id)) { $req = App::request(); if ($req->isPost()) { $post = $req->post(); // url_cancel $sales = SalesApotik::find($id); if (!empty($sales)) { $sales->is_canceled = 1; $sales->save(); //jika berhasil hapus record $query = "parent = '" . $id . "'"; $results = SalesApotikDetail::all(array('conditions' => $query)); if (!empty($results)) { foreach ($results as $row) { //jika berhasil hapus record $folio = KlinikFolio::find($row->id); $folio->delete(); } } ZiUtil::to_json(json_encode("{ success: true}")); return; } } } App::flash('error', 'Terjadi kesalahan pada inputan anda.'); App::redirect('selling.list_penjualan'); }
public function d011($id = null) { $ruang = Warehouse::find($id); $ruang->delete(); ZiUtil::to_json(json_encode("{ success: true}")); }