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); }
private function print_harian($params) { try { $condition = array(); $data = 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; } $sales = SalesApotik::all($condition); $data["rows"] = $sales; $data["title"] = $this->template_header; $data["posting_range"] = sprintf(" %s sampai %s", $params['a'], $params['z']); $data["params"] = sprintf("a=%s&z=%s&cdate=%s", $params['a'], $params['z'], "posting_date"); $data["source_url"] = APP::urlFor('selling.export'); } catch (Exception $e) { App::flash('error', $e); } APP::render('selling/print_laporan_harian', $data); }