예제 #1
0
 public function scopeLang($query, $id = null)
 {
     if (!$id) {
         $id = dbTrans();
     } else {
         $id = is_numeric($id) ? $id : dbTrans($id);
     }
     return $query->where('lang_id', $id);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \App\Http\Requests\OptionRequest $request
  * @param \App\Criteria $criteria
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\OptionRequest $request, Criteria $criteria)
 {
     DB::transaction(function () use($criteria, $request) {
         $option = $criteria->options()->create(['sort' => $request->get('sort')]);
         $langs = [];
         foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
             $langs[] = ['lang_id' => dbTrans($short), 'title' => $request->get('title_' . $short)];
         }
         $option->langs()->createMany($langs);
     });
     return redirect(action('Admin\\CriteriaOptionController@index', [$criteria->id]))->with('success', 'saved');
 }
 public function actionCreate()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         return;
     }
     if (isset($_POST) && !empty($_POST)) {
         $gl = new GlPah();
         $status = false;
         $msg = 'Transaksi berhasil disimpan.';
         $user = Yii::app()->user->getId();
         $id = -1;
         //require_once(Yii::app()->basePath . '/vendors/frontaccounting/ui.inc');
         $transaction = dbTrans();
         try {
             $ref = new PahReferenceCom();
             $docref = $ref->get_next_reference(T_AKTIVITASGRUP);
             $aktivitas = new PahAktivitasGrupTrans();
             foreach ($_POST as $k => $v) {
                 if ($k == 'amount') {
                     $v = get_number($v);
                 }
                 $_POST['PahAktivitasGrupTrans'][$k] = $v;
             }
             $date = $_POST['PahAktivitasGrupTrans']['trans_date'];
             $_POST['PahAktivitasGrupTrans']['entry_time'] = Now();
             $_POST['PahAktivitasGrupTrans']['users_id'] = $user;
             $_POST['PahAktivitasGrupTrans']['doc_ref'] = $docref;
             $aktivitas->attributes = $_POST['PahAktivitasGrupTrans'];
             if (!$aktivitas->save()) {
                 throw new Exception("Gagal menyimpan aktivitas.");
             }
             $id = $docref;
             $ref->save(T_AKTIVITASGRUP, $aktivitas->aktivitas_id, $docref);
             $bank_account = Pah::get_act_code_from_bank_act($aktivitas->pah_bank_accounts_id);
             $act_sub = $aktivitas->pahSubAktivitas->account_code;
             //debet kode beban - kredit kas bank
             $gl->add_gl(T_AKTIVITASGRUP, $aktivitas->aktivitas_id, $date, $docref, $act_sub, $aktivitas->note, $aktivitas->amount, $user);
             $gl->add_gl(T_AKTIVITASGRUP, $aktivitas->aktivitas_id, $date, $docref, $bank_account, '-', -$aktivitas->amount, $user);
             $gl->validate();
             $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();
     }
 }
예제 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \App\Http\Requests\NewsRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\NewsRequest $request)
 {
     $departmentId = auth()->user()->department_id;
     if ($request->has('department_id') && $this->systemAdmin) {
         $departmentId = $request->get('department_id');
     }
     DB::transaction(function () use($departmentId, $request) {
         $news = News::create(['department_id' => $departmentId, 'active' => $request->get('active'), 'sort' => $request->get('sort')]);
         $langs = [];
         foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
             $langs[] = ['lang_id' => dbTrans($short), 'title' => $request->get('title_' . $short), 'description' => $request->get('description_' . $short)];
         }
         $news->langs()->createMany($langs);
     });
     return redirect(action('Admin\\NewsController@index'))->with('success', 'saved');
 }
예제 #5
0
 public function scopeLang($query)
 {
     return $query->where('lang_id', dbTrans());
 }
예제 #6
0
 private function addDepartmentLangs(Requests\DepartmentRequest $request, Department $department)
 {
     $langs = [];
     foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
         $langs[] = ['lang_id' => dbTrans($short), 'name' => $request->get('name_' . $short), 'title' => $request->get('title_' . $short), 'description' => $request->get('description_' . $short)];
     }
     $department->langs()->createMany($langs);
 }