public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { $status = true; $msg = "Akun bank berhasil dibuat"; if (Mt::account_in_gl_trans($id)) { $status = false; $msg = "Akun bank gagal dibuat, karena account sudah dipakai transaksi."; } if (Mt::account_used_bank($id) && $status) { $status = false; $msg = "Akun bank gagal dibuat, karena account dipakai akun bank lain."; } if ($status) { $this->loadModel($id, 'MtBankAccounts')->delete(); } echo CJSON::encode(array('success' => $status, 'msg' => $msg)); Yii::app()->end(); if (!Yii::app()->request->isAjaxRequest) { $this->redirect(array('admin')); } } else { throw new CHttpException(400, Yii::t('app', 'Invalid request. Please do not repeat this request again.')); } }
public function actionCreateJurnalUmum() { // return; if (!app()->request->isAjaxRequest) { return; } if (isset($_POST) && !empty($_POST)) { $status = false; $msg = 'Jurnal umum berhasil disimpan.'; $user = app()->user->getId(); $detils = CJSON::decode($_POST['detil']); $transaction = app()->db->beginTransaction(); try { $ref = new MtReferenceCom(); $docref = $ref->get_next_reference(JURNAL_UMUM); $jurnal_umum_id = Mt::get_max_type_no(JURNAL_UMUM); $jurnal_umum_id++; foreach ($detils as $detil) { $amount = $detil['debit'] > 0 ? $detil['debit'] : -$detil['kredit']; Mt::add_gl(JURNAL_UMUM, $jurnal_umum_id, $_POST['tran_date'], $docref, $detil['account'], "-", $amount, $user, $detil['id_mobil']); } $ref->save(JURNAL_UMUM, $jurnal_umum_id, $docref); $transaction->commit(); $status = true; } catch (Exception $ex) { $transaction->rollback(); $status = false; $msg = $ex; } echo CJSON::encode(array('success' => $status, 'id' => $docref, 'msg' => $msg)); app()->end(); } }
public function actionCreateTransfer() { if (!Yii::app()->request->isAjaxRequest) { return; } if (isset($_POST) && !empty($_POST)) { //require_once(Yii::app()->basePath . '/vendors/frontaccounting/ui.inc'); $status = false; $msg = 'Transfer antar kas berhasil diproses.'; $id = -1; $bank_asal = $_POST['bank_act_asal']; $bank_tujuan = $_POST['bank_act_tujuan']; $trans_date = $_POST['trans_date']; $memo = $_POST['memo']; $amount = get_number($_POST['amount']); if ($bank_asal == $bank_tujuan) { echo CJSON::encode(array('success' => false, 'id' => -1, 'msg' => 'Bank asal dan bank tujuan tidak boleh sama.')); Yii::app()->end(); } if ($amount <= 0) { echo CJSON::encode(array('success' => false, 'id' => -1, 'msg' => 'Jumlah yang akan ditransfer harus lebih dari nol.')); Yii::app()->end(); } $transaction = Yii::app()->db->beginTransaction(); try { $ref = new MtReferenceCom(); $docref = $ref->get_next_reference(BANKTRANSFER); $bank_account_asal = Mt::get_act_code_from_bank_act($bank_asal); $bank_account_tujuan = Mt::get_act_code_from_bank_act($bank_tujuan); $trans_no = Mt::get_next_trans_no_bank_trans(); $user = Yii::app()->user->getId(); //debet kode bank tujuan - kredit kode bank asal Mt::add_gl(BANKTRANSFER, $trans_no, $trans_date, $docref, $bank_account_tujuan, $memo, $amount, $user, null); Mt::add_gl(BANKTRANSFER, $trans_no, $trans_date, $docref, $bank_account_asal, $memo, -$amount, $user, null); $ref->save(BANKTRANSFER, $trans_no, $docref); $id = $docref; $transaction->commit(); $status = true; } catch (Exception $ex) { $transaction->rollback(); $status = false; $msg = $ex; } echo CJSON::encode(array('success' => $status, 'id' => $id, 'msg' => $msg)); Yii::app()->end(); } }
public function actionLabaRugiMahkotrans() { if (Yii::app()->request->isAjaxRequest) { return; } if (isset($_POST) && !empty($_POST)) { $format = $_POST['format']; $is_excel = $format == 'excel'; $start_date = $_POST['trans_date_mulai']; $end_date = $_POST['trans_date_sampai']; $start = 1; $file_name = 'LabaRugiMahkotrans'; $worksheet_name = 'Laba Rugi Mahkotrans'; $objPHPExcel = new PHPExcel(); $this->header($objPHPExcel, $start, $worksheet_name, "LABA RUGI"); $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:C{$start}")->setCellValue("A{$start}", "Dari tanggal " . sql2long_date($start_date) . " sampai tanggal " . sql2long_date($end_date))->getStyle("A{$start}")->getFont()->setSize(12)->setBold(true); $objPHPExcel->getActiveSheet()->setTitle($worksheet_name); $start++; $start++; $start_body = $start; // 4100 Pendapatan Sewa $pen_sewa = $this->loadModel('4100', 'MtChartMaster'); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", $pen_sewa->account_name); $tot_pen_sewa = -Mt::get_sum_account_trans($pen_sewa->account_code, NULL, $start_date, $end_date); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B{$start}", $is_excel ? $tot_pen_sewa : number_format($tot_pen_sewa)); $start++; // 4200 Potongan atau Diskon $pen_diskon = $this->loadModel('4200', 'MtChartMaster'); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", $pen_diskon->account_name); $tot_pen_diskon = -Mt::get_sum_account_trans($pen_diskon->account_code, NULL, $start_date, $end_date); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B{$start}", $is_excel ? $tot_pen_diskon : number_format($tot_pen_diskon)); $start++; // Netto $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", $pen_sewa->account_name . ' (Netto)'); $tot_pen_sewa_netto = $tot_pen_sewa - $tot_pen_diskon; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $is_excel ? $tot_pen_sewa_netto : number_format($tot_pen_sewa_netto)); $start++; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", ' '); $start++; // 4300 Pendapatan Denda $pen_denda = $this->loadModel('4300', 'MtChartMaster'); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", $pen_denda->account_name); $tot_pen_denda = -Mt::get_sum_account_trans($pen_denda->account_code, NULL, $start_date, $end_date); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $is_excel ? $tot_pen_denda : number_format($tot_pen_denda)); $start++; // 4400 Pendapatan Lain-lain $pen_lain = $this->loadModel('4400', 'MtChartMaster'); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", $pen_lain->account_name); $tot_pen_lain = -Mt::get_sum_account_trans($pen_lain->account_code, NULL, $start_date, $end_date); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $is_excel ? $tot_pen_lain : number_format($tot_pen_lain)); $start++; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", 'Beban-beban Terkait'); $start++; $acc_beban = Mt::get_beban(); $total_beban_terkait = 0; foreach ($acc_beban as $row) { $beban = $this->loadModel($row['account_code'], 'MtChartMaster'); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", ' --- ' . $beban->account_name); $tot_beban = -Mt::get_sum_account_trans($beban->account_code, NULL, $start_date, $end_date); $total_beban_terkait += $tot_beban; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B{$start}", $is_excel ? $tot_beban : number_format($tot_beban)); $start++; } $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", ' --- Total')->setCellValue("C{$start}", $is_excel ? $total_beban_terkait : number_format($total_beban_terkait)); $start++; $total = $tot_pen_sewa_netto + $tot_pen_denda + $tot_pen_lain - $total_beban_terkait; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", 'Laba')->setCellValue("C{$start}", $is_excel ? $total : number_format($total)); $start++; $end_body = $start - 1; $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start_body}:C{$end_body}")->applyFromArray($styleArray); $start_row = $start_body + 1; if ($is_excel) { $objPHPExcel->setActiveSheetIndex(0)->getStyle("B{$start_body}:C{$end_body}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_ACCOUNTING); } else { $objPHPExcel->setActiveSheetIndex(0)->getStyle("B{$start_body}:C{$end_body}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("A")->setAutoSize(true); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("B")->setAutoSize(true); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("C")->setAutoSize(true); $this->footer($objPHPExcel, $start, $file_name, $format, $worksheet_name); Yii::app()->end(); } }
static function update_comments($type, $id, $date_, $memo_) { if ($date_ == null) { Mt::delete_comments($type, $id); Mt::add_comments($type, $id, Yii::app()->dateFormatter->format('yyyy-MM-dd', time()), $memo_); } else { $criteria = new CDbCriteria(); $criteria->addCondition("type=" . $type); $criteria->addCondition("id=" . $type_no); $criteria->addCondition("date_=" . $date); $comment = MtComments::model()->find($criteria); $comment->memo_ = $memo_; $comment->save(); } }
public function actionIndex() { if (isset($_POST['limit'])) { $limit = $_POST['limit']; } else { $limit = 20; } if (isset($_POST['start'])) { $start = $_POST['start']; } else { $start = 0; } $void = Mt::get_voided(KEMBALI_KENDARAAN); $criteria = new CDbCriteria(); $param = array(); $criteria = new CDbCriteria(); if (isset($_POST['doc_ref_kembali'])) { $criteria->addCondition("doc_ref_kembali like :doc_ref_kembali"); $param[':doc_ref_kembali'] = "%" . $_POST['doc_ref_kembali'] . "%"; } $criteria->addNotInCondition('id_kembali', $void); $criteria->limit = $limit; $criteria->offset = $start; $criteria->params = $param; $model = MtKembaliKendaraan::model()->findAll($criteria); $total = MtKembaliKendaraan::model()->count($criteria); $this->renderJson($model, $total); }
public function actionSetSaldoAwal() { if (!Yii::app()->request->isAjaxRequest) { return; } if (isset($_POST) && !empty($_POST)) { $status = false; $msg = 'Saldo Awal berhasil disimpan.'; $date = $_POST['trans_date']; $user = Yii::app()->user->getId(); $id = Mt::get_next_trans_saldo_awal(); $transaction = Yii::app()->db->beginTransaction(); try { Mt::add_gl(SALDO_AWAL, $id, $date, "-", $_POST['account_code'], '-', get_number($_POST['amount']), $user, null); $transaction->commit(); $status = true; } catch (Exception $ex) { $transaction->rollback(); $status = false; $msg = $ex; } echo CJSON::encode(array('success' => $status, 'id' => $id, 'msg' => $msg)); Yii::app()->end(); } }
public function actionIndex() { if (isset($_POST['limit'])) { $limit = $_POST['limit']; } else { $limit = 20; } if (isset($_POST['start'])) { $start = $_POST['start']; } else { $start = 0; } $param = array(); $void = Mt::get_voided(KAS_MASUK); $criteria = new CDbCriteria(); if (isset($_POST['doc_ref'])) { $criteria->addCondition("doc_ref like :doc_ref"); $param[':doc_ref'] = "%" . $_POST['doc_ref'] . "%"; } if (isset($_POST['dari'])) { $criteria->addCondition("dari like :dari"); $param[':dari'] = "%" . $_POST['dari'] . "%"; } if (isset($_POST['amount'])) { $criteria->addCondition("amount = :amount"); $param[':amount'] = $_POST['amount']; } if (isset($_POST['trans_date'])) { $criteria->addCondition("trans_date = :trans_date"); $param[':trans_date'] = substr($_POST['trans_date'], 0, 10); } $criteria->addNotInCondition('kas_masuk_id', $void); $criteria->limit = $limit; $criteria->offset = $start; $criteria->params = $param; $model = MtKasMasuk::model()->findAll($criteria); $total = MtKasMasuk::model()->count($criteria); $this->renderJson($model, $total); }
public function actionIndex() { if (isset($_POST['limit'])) { $limit = $_POST['limit']; } else { $limit = 20; } if (isset($_POST['start'])) { $start = $_POST['start']; } else { $start = 0; } $void = Mt::get_voided(PINJAM_KENDARAAN); $criteria = new CDbCriteria(); $criteria->addNotInCondition('id_pinjam', $void); $criteria->limit = $limit; $criteria->offset = $start; $model = MtPinjamKendaraan::model()->findAll($criteria); $total = MtPinjamKendaraan::model()->count($criteria); if (isset($_GET['MtPinjamKendaraan'])) { $model->attributes = $_GET['MtPinjamKendaraan']; } if (isset($_GET['output']) && $_GET['output'] == 'json') { $this->renderJson($model, $total); } else { $model = new MtPinjamKendaraan('search'); $model->unsetAttributes(); $this->render('admin', array('model' => $model)); } }