commit() публичный статический метод

public static commit ( )
 /**
  * Setup global $DB as original DB object again.
  */
 function tearDown()
 {
     $this->test_DB->commit();
     if ($this->test_DB->error) {
         $this->fail('There has been a DB error.');
     }
     $this->dropTestDbTables();
     $GLOBALS['DB'] =& $this->old_DB;
     parent::tearDown();
 }
 public function commit()
 {
     $this->assertFinished();
     $this->finished = true;
     if (!$this->savepointName) {
         $this->db->commit();
     } else {
         $this->db->savepointRelease($this->savepointName);
     }
 }
Пример #3
0
 /**
  * Update the specified resource in storage.
  * POST /cargo/editar
  *
  * @return Response
  */
 public function postEditar()
 {
     if (Request::ajax()) {
         $sql = "";
         $cargoId = Input::get('id');
         $array = array();
         $array['grupo_persona_id'] = Input::get('grupop');
         $array['cargo_estrategico_id'] = Input::get('cargo');
         $cargo_estrategico = Input::get('cargo');
         $array['id'] = $cargoId;
         DB::beginTransaction();
         DB::table('grupos_cargos')->where('grupo_persona_id', Input::get('grupop'))->update(array('estado' => 0));
         for ($i = 0; $i < count($cargo_estrategico); $i++) {
             $sql = "  SELECT id\n                        FROM grupos_cargos\n                        WHERE grupo_persona_id='" . Input::get('grupop') . "'\n                        AND cargo_estrategico_id='" . $cargo_estrategico[$i] . "'";
             $rf = DB::select($sql);
             if (count($rf) > 0) {
                 $cargo = GrupoCargo::find($rf[0]->id);
                 $cargo->fecha_inicio = Input::get('fecha_inicio');
                 $cargo->estado = 1;
                 $cargo->usuario_updated_at = Auth::user()->id;
                 $cargo->save();
             } else {
                 $cargo = new GrupoCargo();
                 $cargo->grupo_persona_id = Input::get('grupop');
                 $cargo->cargo_estrategico_id = $cargo_estrategico[$i];
                 $cargo->fecha_inicio = Input::get('fecha_inicio');
                 $cargo->estado = 1;
                 $cargo->usuario_created_at = Auth::user()->id;
                 $cargo->save();
             }
         }
         DB::commit();
         return Response::json(array('rst' => 1, 'msj' => 'Registro actualizado correctamente'));
     }
 }
Пример #4
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         //dd($this->req);
         \DB::begintransaction();
         $me = \Me::data()->id_karyawan;
         // Create PO
         $po = data_po::create(['id_sph' => $this->req['id'], 'id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'id_pembuat' => $me, 'id_acc' => 0, 'adjustment' => $this->req['adjustment'], 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'keterangan' => $this->req['ket'], 'titipan' => $this->req['titipan']]);
         foreach ($this->req['id_barang'] as $i => $id_barang) {
             data_po_item::create(['id_po' => $po->id_po, 'id_item' => $id_barang, 'req_qty' => $this->req['qty'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i], 'id_prq' => $this->req['id_prq'][$i]]);
             data_prq::find($this->req['id_prq'][$i])->update(['status' => 2]);
             // update Harga
             data_barang::find($id_barang)->update(['harga_beli' => $this->req['harga'][$i]]);
             // Update Log harga
             data_harga::create(['id_barang' => $id_barang, 'harga' => $this->req['harga'][$i], 'keterangan' => 'Update berdasarkan PO', 'id_po' => $po->id_po, 'id_karyawan' => $me, 'tipe' => 1]);
             data_prq_item::find($this->req['id_prq_item'][$i])->update(['status' => 2]);
         }
         $format = 'PO-';
         $po->no_po = $format . \Format::code($po->id_po);
         $po->save();
         \Loguser::create('Membuat PO dengan No. PO ' . $po->no_po);
         \DB::commit();
         return ['result' => true, 'err' => 'PO berhasil dibuat dengan No. ' . $po->no_po];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['result' => false, 'err' => $e->getMessage()];
     }
 }
Пример #5
0
 public function create(array $data)
 {
     DB::beginTransaction();
     try {
         $data['status'] = 0;
         if (isset($data['cupom_code'])) {
             $cupom = $this->cupomRepository->findByField('code', $data['cupom_code'])->first();
             $data['cupom'] = $cupom->id;
             $cupom->used = 1;
             $cupom->save();
             unset($data['cupom_code']);
         }
         $items = $data['items'];
         unset($data['items']);
         $order = $this->orderRepository->create($data);
         $total = 0;
         foreach ($items as $item) {
             $item['price'] = $this->productRepository->find($item['product_id'])->price;
             $order->items()->create($item);
             $total += $item['price'] * $item['qtd'];
         }
         $order->total = $total;
         if (isset($cupom)) {
             $order->total = $total - $cupom->value;
         }
         $order->save();
         \DB::commit();
     } catch (\Exception $e) {
         \DB::rollback();
         throw $e;
     }
 }
Пример #6
0
 public function postSchimbaStadiu($id_livrabil)
 {
     $actualizare_ore = Input::get('ore_lucrate') > 0;
     $is_stadiu = Input::get('stadiu_selectionat') != null && Input::get('stadiu_selectionat') > 0;
     $array_update = array();
     if ($is_stadiu) {
         //Face insert in tabela de istoric de stadii
         //Actualizeaza stadiul livrabilului
         $array_update = array_add($array_update, 'id_stadiu', Input::get('stadiu_selectionat'));
     }
     if ($actualizare_ore) {
         //Actualizeaza numarul de ore lucrate la acest livrabil
         $array_update = array_add($array_update, 'ore_lucrate', Input::get('ore_lucrate'));
     }
     // Start transaction!
     DB::beginTransaction();
     if ($is_stadiu) {
         try {
             DB::table('istoric_stadii_livrabil')->insertGetId(array('id_livrabil_etapa' => Input::get('id_livrabil_etapa'), 'id_stadiu' => Input::get('stadiu_selectionat'), 'id_user' => Entrust::user()->id));
         } catch (Exception $e) {
             DB::rollback();
             return Redirect::back()->with('message', 'Eroare salvare date: ' . $e);
         }
     }
     if ($is_stadiu || $actualizare_ore) {
         try {
             DB::table('livrabile_etapa')->where('id', Input::get('id_livrabil_etapa'))->update($array_update);
         } catch (Exception $e) {
             DB::rollback();
             return Redirect::back()->with('message', 'Eroare salvare date: ' . $e);
         }
     }
     DB::commit();
     return Redirect::back()->with('message', 'Actualizare realizata cu succes!')->withInput();
 }
Пример #7
0
    function changePassword()
    {
        $validator = new Validate();
        $validated = $validator->validateNewPassword();
        if ($validated->fails()) {
            return \View::make('accounts.password')->withErrors($validated);
        }
        if (\Auth::check()) {
            $hashed = \Hash::make(\Input::get('password'));
            $id = \Auth::user()->user_id;
            \DB::beginTransaction();
            try {
                $statement = \User::find($id);
                $statement->password = $hashed;
                $statement->save();
            } catch (ValidationException $e) {
                DB::rollback();
                throw $e;
            }
            \DB::commit();
            \Auth::logout();
            return \Redirect::to('admin/logout')->with('message', '<div class="alert alert-dismissible alert-success alert-link">
				<button type="button" class="close" data-dismiss="alert">×</button>
				Password changed. Please log in.
				</div>');
        }
        return \Redirect::to('admin')->with('message', '<div class="alert alert-dismissible alert-success alert-link">
		<button type="button" class="close" data-dismiss="alert">×</button>
		Password changed. Please log in.
		</div>');
    }
Пример #8
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         \DB::begintransaction();
         $me = \Me::data()->id_karyawan;
         $retur = data_retur::create(['tipe' => 2, 'id_po' => $this->req['id_po'], 'id_vendor' => $this->req['id_vendor'], 'id_karyawan' => $me]);
         data_po::find($this->req['id_po'])->update(['status' => 2]);
         foreach ($this->req['id_barang'] as $i => $id_barang) {
             if (!empty($this->req['qty'][$i])) {
                 data_retur_item::create(['id_retur' => $retur->id_retur, 'id_barang' => $id_barang, 'id_satuan' => $this->req['id_satuan'][$i], 'qty' => $this->req['qty'][$i], 'qty_lg' => $this->req['qty'][$i]]);
                 // Log Stok
                 data_log_barang::create(['id_barang' => $id_barang, 'qty' => $this->req['qty'][$i], 'id_gudang' => 0, 'kondisi' => 2, 'tipe' => 5, 'id_parent' => $retur->id_retur, 'id_karyawan' => $me]);
                 // Update stok
                 $barang = data_barang::find($id_barang);
                 $barang->out = $barang->out + $this->req['qty'][$i];
                 $barang->save();
                 // Update data PO items
                 $itm = data_po_item::where('id_po', $this->req['id_po'])->where('id_item', $id_barang)->first();
                 $qpo = $itm->qty + $this->req['qty'][$i];
                 data_po_item::where('id_po', $this->req['id_po'])->where('id_item', $id_barang)->update(['qty' => $qpo, 'status' => 1]);
             }
         }
         $format = 'EX-RTN-';
         $kode = $format . \Format::code($retur->id_retur);
         $retur->no_retur = $kode;
         $retur->save();
         \Loguser::create('Membuat Retur Pembelian dengan No. ' . $kode);
         \DB::commit();
         return ['result' => true, 'label' => 'success', 'err' => 'Return Pembelian berhasil dibuat dengan No. ' . $kode];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['result' => false, 'label' => 'danger', 'err' => $e->getMessage()];
     }
 }
 /**
  * Creates a new entry, puts the id into the session and
  * redirects back to the index page.
  */
 public function store()
 {
     if (Entry::canCreateOrEdit() === false) {
         return Redirect::route('entry.index')->withMessage("Sorry, the competition has now started and new entries cannot be created.");
     }
     $input = Input::all();
     $validator = Validator::make($input, Entry::$entry_rules);
     if ($validator->fails()) {
         return Redirect::route('entry.create')->withInput()->withErrors($validator);
     }
     DB::beginTransaction();
     $entry = new Entry();
     $entry->email = $input['email'];
     $entry->secret = Hash::make($input['secret']);
     $entry->confirmation = uniqid('', true);
     $entry->first_name = $input['first_name'];
     $entry->last_name = $input['last_name'];
     $entry->peer_group = $input['peer_group'];
     $entry->save();
     $matches = Match::all();
     foreach ($matches as $match) {
         $match_prediction = new MatchPrediction();
         $match_prediction->team_a = $match->team_a;
         $match_prediction->team_b = $match->team_b;
         $match_prediction->pool = $match->pool;
         $match_prediction->match_date = $match->match_date;
         $entry->matchPredictions()->save($match_prediction);
     }
     DB::commit();
     $this->sendConfirmationEmail($entry);
     $this->putEntryIdIntoSession($entry->id);
     return View::make('entry.edit')->with('entry', $entry);
 }
Пример #10
0
 public function postRegistroEmpresas()
 {
     DB::beginTransaction();
     try {
         $empresa = new LandingEmpresa();
         $empresa->razon_social = ucwords(strtolower(Input::get('empresa_razonsocial')));
         $empresa->ruc = Input::get('empresa_ruc');
         $empresa->inscritos = Input::get('empresa_inscritos');
         $empresa->domicilio = Input::get('empresa_domicilio');
         $empresa->email = Input::get('empresa_email');
         $empresa->telefono = Input::get('empresa_telefono');
         $empresa->celular = Input::get('empresa_celular');
         $empresa->curso = Input::get('empresa_curso');
         $empresa->comentario = Input::get('empresa_comentario');
         $empresa->recibir_noticias = Input::get('empresa_informacion');
         $empresa->ip = Request::getClientIp(true);
         $empresa->save();
         $respuesta = array('status' => 'ok');
         DB::commit();
     } catch (\Exception $e) {
         DB::rollback();
         $respuesta = array('status' => 'error', 'messages' => 'Exception with msg: ' . $e->getMessage());
     }
     return Response::json($respuesta, 200);
 }
Пример #11
0
 public function deleteCategoryInfo($slug)
 {
     $results = \MenuCategory::where('menu_category_slug', '=', $slug)->get();
     foreach ($results as $result) {
         $id = $result->menu_category_id;
     }
     $items_using_cat = \MenuItem::where('menu_item_category_fk', '=', $id)->get();
     foreach ($items_using_cat as $item_using_cat) {
         if ($item_using_cat) {
             return \Redirect::to("admin/category/edit/{$slug}")->with('message', '<div class="alert alert-dismissible alert-danger alert-link">Unable to delete category. Please make sure no items are using this category.</p></div>');
         }
     }
     //if an item exists that has this cat's fk, reload the page with an error
     if (\Auth::check()) {
         \DB::beginTransaction();
         try {
             $statement = \MenuCategory::find($id);
             $statement->delete();
         } catch (ValidationException $e) {
             DB::rollback();
             throw $e;
         }
         \DB::commit();
         return \Redirect::to('admin')->with('message', '<div class="alert alert-dismissible alert-success alert-link">Category has been deleted</p></div>');
     }
     return \Redirect::to('admin');
 }
Пример #12
0
 public function newCategory()
 {
     $validate = new Validate();
     $validated = $validate->Validate_Category();
     $nameToSlug = $this->nameToSlug($validated);
     if (\Auth::check()) {
         if ($validated->passes() && $nameToSlug === true) {
             $slug = \Input::get('name');
             $slug = preg_replace('#[ -]+#', '-', $slug);
             $slug = strtolower($slug);
             \DB::beginTransaction();
             try {
                 $item = new \MenuCategory();
                 $item->menu_category_name = \Input::get('name');
                 $item->menu_category_slug = $slug;
                 $item->save();
             } catch (ValidationException $e) {
                 DB::rollback();
                 throw $e;
             }
             \DB::commit();
             return \Redirect::to('admin/category/edit/' . $slug)->with('message', '<div class="alert alert-dismissible alert-success alert-link"><button type="button" class="close" data-dismiss="alert">×</button>Saved!</p></div>');
         }
         if ($nameToSlug === false) {
             return \View::make('categories.new')->withErrors($validated)->withInput(array('name'))->with('message', '<p class="alert alert-dismissible alert-danger alert-link">That category already exists!');
         }
         return \View::make('categories.new')->withErrors($validated)->withInput(array('name'));
     }
     return \Redirect::to('admin');
 }
Пример #13
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //dd($this->req);
     try {
         \DB::begintransaction();
         $parent_id = empty($this->req['parent_id']) ? 0 : $this->req['parent_id'];
         $file = '';
         if (!empty($_FILES['feed_file']['tmp_name'])) {
             $base_name = date('d_m_Y_') . md5($_FILES['feed_file']['name']) . rand(11111, 99999) . time();
             $fl_name = $base_name . '.png';
             $fl = file_get_contents($_FILES['feed_file']['tmp_name']);
             \Image::make($fl)->save($this->path . $fl_name);
             $file = $fl_name;
         }
         $feed = data_feedback::create(['title' => $this->req['feed_title'], 'ask' => $this->req['feed_ask'], 'link' => $this->req['feed_link'], 'parent_id' => $parent_id, 'file' => $file, 'id_karyawan' => \Me::data()->id_karyawan]);
         $kode = \Format::code($feed->id_feedback);
         $feed->kode = $kode;
         $feed->save();
         if ($parent_id > 0) {
             $up = data_feedback::find($parent_id);
             $up->notif = $up->notif + 1;
             $up->save();
         }
         \Loguser::create('Megisi form feedback Kode. #' . $kode);
         \DB::commit();
         return ['label' => 'success', 'err' => 'Feedback berhasil terkirim dengan Kode. ' . $feed->kode];
     } catch (\Exception $e) {
         \DB::rollback();
         if (file_exists($this->path . $file)) {
             @unlink($this->path . $file);
         }
         return ['label' => 'danger', 'err' => $e->getMessage()];
     }
 }
Пример #14
0
 public function updateRestaurantInfo()
 {
     $user = \Auth::user();
     $id = $user->user_id;
     $restaurant = \Restaurant::all();
     foreach ($restaurant as $rest) {
         $restaurant_name = $rest->restaurant_name;
         $restaurant_street_1 = $rest->restaurant_street_1;
         $restaurant_street_2 = $rest->restaurant_street_2;
         $restaurant_phone = $rest->restaurant_phone;
         $restaurant_email = $rest->restaurant_email;
         $restaurant_id = $rest->restaurant_info_id;
     }
     \DB::beginTransaction();
     try {
         $statement = \Restaurant::find($restaurant_id);
         $statement->restaurant_name = \Input::get('name');
         $statement->restaurant_street_1 = \Input::get('address1');
         $statement->restaurant_street_2 = \Input::get('address2');
         $statement->restaurant_email = \Input::get('email');
         $statement->restaurant_phone = \Input::get('phone');
         $statement->user_id_fk = $id;
         $statement->save();
     } catch (ValidationException $e) {
         DB::rollback();
         throw $e;
     }
     \DB::commit();
     return \Redirect::to('admin/account/edit/restaurant')->withRestaurantName($restaurant_name)->withRestaurantStreet_1($restaurant_street_1)->withRestaurantStreet_2($restaurant_street_2)->withRestaurantPhone($restaurant_phone)->withRestaurantEmail($restaurant_email)->with('message', '<p class="alert alert-dismissible alert-success alert-link">Saved!' . '</p>');
 }
 public function postAdminSettings()
 {
     $title = Input::get('title');
     $about = Input::get('about');
     $address = Input::get('address');
     $phone = Input::get('phone');
     $email = Input::get('email');
     $location = Input::get('location');
     $file = Input::file('file');
     $destinationPath = 'uploads';
     $filename = DB::table('settings')->first()->logo;
     // If the uploads fail due to file system, you can try doing public_path().'/uploads'
     if ($file) {
         $filename = time() . $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $upload_success = Input::file('file')->move($destinationPath, $filename);
     }
     DB::beginTransaction();
     try {
         DB::table('settings')->where('id', 1)->update(array('title' => $title, 'logo' => $filename, 'about' => $about, 'address' => $address, 'phone' => $phone, 'email' => $email, 'location' => $location));
         DB::commit();
         return Redirect::route('getAdminSettings')->with(array('status' => 'success'));
     } catch (\Exception $e) {
         DB::rollback();
         return Redirect::route('getAdminSettings')->with(array('status' => 'error'));
     }
 }
Пример #16
0
 public function postValidar()
 {
     if (Request::ajax()) {
         $personas = Input::get('personas');
         DB::beginTransaction();
         for ($i = 0; $i < count($personas); $i++) {
             $per = explode("_", $personas[$i]);
             $mensajeria = Mensajeria::where('activista_id', $per[1])->first();
             if (!isset($mensajeria->id)) {
                 $mensajeria = new Mensajeria();
                 $mensajeria->activista_id = $per[1];
                 $mensajeria->usuario_created_at = $this->userID;
             } else {
                 $mensajeria->usuario_updated_at = $this->userID;
             }
             if ($per[0] == 'celular') {
                 $mensajeria->cel = $per[2];
                 $mensajeria->nrollamada = $mensajeria->nrollamada * 1 + 1;
             } else {
                 $mensajeria->email = 1;
                 $mensajeria->validado = 1;
             }
             $mensajeria->save();
         }
         DB::commit();
         return Response::json(array('rst' => 1, 'msj' => 'Se registro correctamente'));
     }
 }
Пример #17
0
 /**
  * Create order record.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function store()
 {
     try {
         \DB::beginTransaction();
         $items = Collection::make(\Input::get('items'));
         $order = new Order();
         // create the order
         $order->save();
         // Attach items to order
         $items->each(function ($item) use($order) {
             $order->addItem($item);
         });
         // Calculate commission & profit
         /** @var \Paxifi\Support\Commission\CalculatorInterface $calculator */
         $calculator = \App::make('Paxifi\\Support\\Commission\\CalculatorInterface');
         $calculator->setCommissionRate($order->OrderDriver()->getCommissionRate());
         $order->setCommission($calculator->calculateCommission($order));
         $order->setProfit($calculator->calculateProfit($order));
         // save order
         $order->save();
         \DB::commit();
         return $this->setStatusCode(201)->respondWithItem(Order::find($order->id));
     } catch (ModelNotFoundException $e) {
         return $this->errorWrongArgs('Invalid product id');
     } catch (\InvalidArgumentException $e) {
         return $this->errorWrongArgs($e->getMessage());
     } catch (\Exception $e) {
         return $this->errorInternalError();
     }
 }
Пример #18
0
 public static function ingresoCtaCte($ctacte_id)
 {
     DB::begintransaction();
     try {
         $CC = Ctacte::findOrFail($ctacte_id);
         $data = array("caja_id" => $CC->caja_id, "importe" => 0, "ingreso_egreso" => "I", "fecha" => date("Y-m-d"), "hora" => date("H:i:s"), "user_id" => Auth::user()->id, "tipo_mov_caja_id" => 2, "medios_pago_caja_id" => NULL, "ctacte_id" => $CC->id);
         $lineas_rec = $CC->lineas_recibo()->get();
         //dd($lineas_rec->toArray());
         foreach ($lineas_rec as $pago) {
             $MC = new MovimientoCaja();
             $data_pago = $data;
             $data_pago["importe"] = $pago->importe;
             $query = MedioPagoCaja::where('tipo', '=', $pago->tipo);
             if ($pago->tipo_cambio > 0) {
                 $query->where('moneda', '=', 'DOL');
             } else {
                 $query->where('moneda', '=', 'ARS');
             }
             $MP = $query->first();
             $data_pago["medios_pago_caja_id"] = $MP->id;
             $MC->fill($data_pago);
             if (!$MC->save()) {
                 DB::rollback();
                 return false;
             }
         }
         DB::commit();
         return true;
     } catch (Exception $e) {
         DB::rollback();
         return Response::json(array('error' => true, 'mensaje' => $e->getMessage()), 200);
     }
 }
 public function rebuild($start_date = null, $end_date = null)
 {
     if (!$start_date) {
         $start_date = config_option('last_sharing_table_rebuild');
     }
     if ($start_date instanceof DateTimeValue) {
         $start_date = $start_date->toMySQL();
     }
     if ($end_date instanceof DateTimeValue) {
         $end_date = $end_date->toMySQL();
     }
     if ($end_date) {
         $end_cond = "AND updated_on <= '{$end_date}'";
     }
     try {
         $object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}"));
         $obj_count = 0;
         DB::beginWork();
         foreach ($object_ids as $id) {
             $obj = Objects::findObject($id);
             if ($obj instanceof ContentDataObject) {
                 $obj->addToSharingTable();
                 $obj_count++;
             }
         }
         set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL());
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
     }
     return $obj_count;
 }
Пример #20
0
 public function commission($driver, $ipn)
 {
     try {
         \DB::beginTransaction();
         if ($driver->id == $ipn['custom']) {
             // Get the pre-month commissions.
             $sales = new SaleCollection($driver->sales(Carbon::now()->subMonth(), Carbon::now()));
             if ($sales) {
                 $paypalHelper = new PaypalHelper($driver);
                 // get authorized commission payment
                 if ($authorizedCommissionPayment = $paypalHelper->createPaypalFuturePayment($sales->toArray()['totals'])) {
                     // capture authorized commission payment
                     if ($capture = $paypalHelper->capturePaypalPayment($authorizedCommissionPayment)) {
                         if ($authorizedCommissionPayment['id'] == $capture['parent_payment']) {
                             $commission_payment = ['driver_id' => $driver->id, 'commissions' => $authorizedCommissionPayment['transactions'][0]['amount']['total'], 'currency' => $authorizedCommissionPayment['transactions'][0]['amount']['currency'], 'status' => $authorizedCommissionPayment['state'], 'commission_ipn' => $authorizedCommissionPayment, 'commission_payment_id' => $authorizedCommissionPayment['id'], 'capture_id' => $capture['id'], 'capture_created_at' => $capture['create_time'], 'capture_updated_at' => $capture['update_time'], 'capture_status' => $capture['state'], 'capture_ipn' => $capture];
                             if ($commission = EloquentCommissionRepository::create($commission_payment)) {
                                 \DB::commit();
                                 // Todo:: fire notification event the commission paid.
                                 $commission->type = "billing";
                                 \Event::fire('paxifi.notifications.billing', [$commission]);
                                 return $this->setStatusCode(201)->respondWithItem($commission);
                             }
                         }
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         return $this->setStatusCode(400)->respondWithError($e->getMessage());
     }
 }
Пример #21
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         \DB::begintransaction();
         /* KREDIT */
         data_jurnal::create(['id_faktur' => $this->req['id_faktur'], 'id_coa_ledger' => $this->req['id_coa_ledger'], 'tanggal' => date('Y-m-d', strtotime($this->req['tanggal'])), 'deskripsi' => $this->req['deskripsi'], 'id_payment_methode' => $this->req['id_payment_methode'], 'tipe' => 2, 'total' => $this->req['total']]);
         /* DEBET */
         data_jurnal::create(['id_faktur' => $this->req['id_faktur'], 'id_coa_ledger' => $this->req['perkiraan'], 'tanggal' => date('Y-m-d', strtotime($this->req['tanggal'])), 'deskripsi' => $this->req['deskripsi'], 'id_payment_methode' => $this->req['id_payment_methode'], 'tipe' => 1, 'total' => $this->req['total']]);
         $faktur = data_faktur::find($this->req['id_faktur']);
         if ($this->req['total'] == $this->req['total_old']) {
             $faktur->status = 2;
         } else {
             $faktur->status = 1;
         }
         $faktur->amount_due = $faktur->amount_due + $this->req['total'];
         $faktur->save();
         /* KREDIT */
         $coa = ref_coa_ledger::find($this->req['id_coa_ledger']);
         $coa->balance = $coa->balance + $this->req['total'];
         $coa->save();
         /* DEBET */
         $kira = ref_coa_ledger::find($this->req['perkiraan']);
         $kira->balance = $kira->balance + $this->req['total'];
         $kira->save();
         \DB::commit();
         return ['label' => 'success', 'err' => 'Payment berhasil dilakukan'];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['label' => 'danger', 'err' => $e->getMessage()];
     }
 }
Пример #22
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         //dd($this->req);
         \DB::begintransaction();
         $me = \Me::data()->id_karyawan;
         // Create PO
         $po = data_po::find($this->req['id']);
         $po->update(['id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'adjustment' => $this->req['adjustment'], 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'keterangan' => $this->req['ket']]);
         data_po_item::whereId_po($this->req['id'])->delete();
         foreach ($this->req['id_barang'] as $i => $id_barang) {
             data_po_item::create(['id_po' => $po->id_po, 'id_item' => $id_barang, 'req_qty' => $this->req['qty'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]);
             // update Harga
             data_barang::find($id_barang)->update(['harga_beli' => $this->req['harga'][$i]]);
             // Update Log harga
             data_harga::create(['id_barang' => $id_barang, 'harga_beli' => $this->req['harga'][$i], 'keterangan' => 'Update berdasarkan pembaharuan PO', 'id_po' => $po->id_po, 'id_karyawan' => $me]);
         }
         \Loguser::create('Melakukan perubahan data PO No. ' . $po->no_po);
         \DB::commit();
         return ['result' => true, 'err' => 'PO berhasil diperbaharui'];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['result' => false, 'err' => $e->getMessage()];
     }
 }
Пример #23
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         \DB::begintransaction();
         $sph = data_sph::find($this->id);
         $grup = data_sph_grup::whereId_sph_grup($sph->id_sph_grup)->select('status')->first();
         if ($grup->status == 2) {
             throw new \Exception("Maaf SPH No. " . $sph->no_sph_item . " sudah kadaluarsa!", 1);
         }
         $nsph = data_sph::create(['id_sph_grup' => $sph->id_sph_grup, 'id_vendor' => $sph->id_vendor, 'deadline' => $sph->deadline, 'id_pembuat' => \Me::data()->id_karyawan, 'id_acc' => $sph->id_acc, 'diskon' => $sph->diskon, 'ppn' => $sph->ppn, 'pph' => $sph->pph, 'adjustment' => $sph->adjustment]);
         $items = data_sph_item::whereId_sph($this->id)->get();
         foreach ($items as $item) {
             data_sph_item::create(['id_sph' => $nsph->id_sph, 'id_prq' => $item->id_prq, 'id_item' => $item->id_item, 'qty' => $item->qty, 'harga' => $item->harga, 'diskon' => $item->diskon, 'ppn' => $item->ppn, 'pph' => $item->pph, 'id_satuan' => $item->id_satuan]);
         }
         $fo = 'ISPH/';
         $nsph->no_sph_item = $fo . \Format::code($nsph->id_sph);
         $nsph->save();
         \Loguser::create('Menduplikasi data SPH dari No. ' . $sph->no_sph_item);
         \DB::commit();
         return ['err' => 'SPH berhasil di duplikasi dengan No. ' . $nsph->no_sph_item];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['err' => $e->getMessage()];
     }
 }
Пример #24
0
function console_create_user($args)
{
    $fname = array_shift($args);
    $lname = array_shift($args);
    $email = array_shift($args);
    $admin = array_shift($args) == 'true';
    if (is_null($fname) || is_null($lname) || is_null($email)) {
        throw new Exception('create_user: Missing arguments. Expected: (fname, lname, email, admin)');
    }
    $display_name = $fname . " " . $lname;
    $username = str_replace(" ", "_", strtolower($display_name));
    $user_data = array('username' => $username, 'display_name' => $display_name, 'email' => $email, 'password_generator' => 'random', 'timezone' => 0, 'autodetect_time_zone' => 1, 'create_contact' => false, 'company_id' => owner_company()->getId(), 'send_email_notification' => true, 'personal_project' => 0);
    // array
    try {
        DB::beginWork();
        $user = create_user($user_data, $admin, '');
        if (!$user->getContact() instanceof Contact) {
            $contact = new Contact();
            $contact->setFirstName($fname);
            $contact->setLastName($lname);
            $contact->setEmail($email);
            $contact->setUserId($user->getId());
            $contact->save();
        }
        DB::commit();
    } catch (Exception $e) {
        DB::rollback();
        throw $e;
    }
}
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($quiz_id)
 {
     try {
         DB::beginTransaction();
         $quiz = Quiz::find($quiz_id);
         foreach (Input::get('question') as $input_question) {
             $question_params = array("name" => $input_question['name']);
             $question_validator = Question::validate($question_params);
             if ($question_validator->fails()) {
                 throw new Exception("Question can't be saved");
             }
             $question = new Question($question_params);
             $question = $quiz->questions()->save($question);
             foreach ($input_question['options'] as $value) {
                 $option_params = array("name" => $value['name'], "is_correct" => array_key_exists("is_correct", $value) ? true : false);
                 $option_validator = Option::validate($option_params);
                 if ($option_validator->fails()) {
                     throw new Exception("Option can't be saved");
                 }
                 $option = new Option($option_params);
                 $option = $question->options()->save($option);
             }
         }
         DB::commit();
         return Redirect::to("quizzes/" . $quiz->id . '/questions');
     } catch (Exception $e) {
         DB::rollback();
         //throw new Exception($e);
         return Redirect::to('quizzes/' . $quiz->id . '/questions/create');
     }
 }
Пример #26
0
 public function post_finalizar($venda)
 {
     $sqlVenda = "INSERT INTO vendas (idCliente,idVendedor,dataVenda) VALUES (:idCliente,:idVendedor,:dataVenda)";
     $sqlItemVenda = "INSERT INTO itensVenda (idVenda,idProduto,quantidade,precoUnitario) VALUES (:idVenda,:idProduto,:quantidade,:precoUnitario)";
     try {
         DB::beginTransaction();
         $stmtVendas = DB::prepare($sqlVenda);
         $stmtVendas->bindParam("idCliente", $venda->idCliente);
         $stmtVendas->bindParam("idVendedor", $venda->idVendedor);
         $stmtVendas->bindParam("dataVenda", DB::dateToMySql($venda->data));
         $stmtVendas->execute();
         $venda->idVenda = DB::lastInsertId();
         foreach ($venda->itens as $item) {
             $stmtItem = DB::prepare($sqlItemVenda);
             $stmtItem->bindParam("idVenda", $venda->idVenda);
             $stmtItem->bindParam("idProduto", $item->idProduto);
             $stmtItem->bindParam("quantidade", $item->quantidade);
             $stmtItem->bindParam("precoUnitario", $item->preco);
             $stmtItem->execute();
         }
         DB::commit();
     } catch (Exception $exc) {
         DB::rollBack();
         throw new Exception($exc->getMessage());
     }
     return $venda;
 }
Пример #27
0
 /**
  * Create the shipment for sticker.
  *
  * @param null $driver
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function shipment($driver = null)
 {
     try {
         \DB::beginTransaction();
         if (is_null($driver)) {
             $driver = $this->getAuthenticatedDriver();
         }
         $new_shipment = ["sticker_id" => $driver->sticker->id, "address" => \Input::get('address', $driver->address), "status" => "waiting", "paypal_payment_status" => "pending"];
         with(new CreateShipmentValidator())->validate($new_shipment);
         // Add paypal_metadata_id for future payment.
         $driver->paypal_metadata_id = \Input::get('metadata_id');
         if ($capturedPayment = $this->paypal->buySticker($driver)) {
             $new_shipment['paypal_payment_id'] = $capturedPayment->parent_payment;
             if ($shipment = Shipment::create($new_shipment)) {
                 \DB::commit();
                 return $this->setStatusCode(201)->respondWithItem($shipment);
             }
             return $this->errorInternalError('Shipment for buying sticker created failed.');
         }
         return $this->errorInternalError();
     } catch (ValidationException $e) {
         return $this->errorWrongArgs($e->getErrors());
     } catch (\Exception $e) {
         print_r($e->getMessage());
         return $this->errorInternalError();
     }
 }
Пример #28
0
 function test_1_transactions()
 {
     DB::$nested_transactions = true;
     $depth = DB::startTransaction();
     $this->assert($depth === 1);
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 700, 'Abe');
     $depth = DB::startTransaction();
     $this->assert($depth === 2);
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 800, 'Abe');
     $depth = DB::startTransaction();
     $this->assert($depth === 3);
     $this->assert(DB::transactionDepth() === 3);
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 500, 'Abe');
     $depth = DB::commit();
     $this->assert($depth === 2);
     $age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
     $this->assert($age == 500);
     $depth = DB::rollback();
     $this->assert($depth === 1);
     $age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
     $this->assert($age == 700);
     $depth = DB::commit();
     $this->assert($depth === 0);
     $age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
     $this->assert($age == 700);
     DB::$nested_transactions = false;
 }
Пример #29
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         \DB::begintransaction();
         if ($this->req['id'] < 1) {
             $group = data_sph_grup::create(['id_pembuat' => \Me::data()->id_karyawan]);
         } else {
             $group = data_sph_grup::find($this->req['id']);
             \Loguser::create('Menambahkan Pengajuan pada SPH No. ' . $group->no_sph);
         }
         $sph = data_sph::create(['id_sph_grup' => $group->id_sph_grup, 'id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'id_pembuat' => \Me::data()->id_karyawan, 'id_acc' => 0, 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'adjustment' => $this->req['adjustment'], 'keterangan' => $this->req['ket']]);
         foreach ($this->req['id_prq_item'] as $i => $id_prq_item) {
             data_sph_item::create(['id_sph' => $sph->id_sph, 'id_prq' => $this->req['id_prq'][$i], 'id_item' => $this->req['id_barang'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]);
             data_prq::find($this->req['id_prq'][$i])->update(['status' => 2]);
         }
         if ($this->req['id'] < 1) {
             $format = 'G-SPH/';
             $group->no_sph = $format . \Format::code($group->id_sph_grup);
             $group->save();
             \Loguser::create('Membuat Surat Pengajuan Harga dengan No. ' . $group->no_sph);
         }
         $fo = 'SPH/';
         $sph->no_sph_item = $fo . \Format::code($sph->id_sph);
         $sph->save();
         \DB::commit();
         return ['status' => true, 'err' => $group];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['status' => false, 'err' => $e->getMessage()];
     }
 }
 function add()
 {
     $pt = DB::escape(array_var($_GET, 'pt'));
     $t = DB::escape(array_var($_GET, 't'));
     $dep = ProjectTaskDependencies::findOne(array('conditions' => "`previous_task_id` = {$pt} AND `task_id` = {$t}"));
     if (!$dep instanceof ProjectTaskDependency) {
         try {
             DB::beginWork();
             $dep = new ProjectTaskDependency();
             $dep->setPreviousTaskId(array_var($_GET, 'pt'));
             $dep->setTaskId(array_var($_GET, 't'));
             $dep->save();
             DB::commit();
         } catch (Exception $e) {
             flash_error($e->getMessage());
             DB::rollback();
         }
     }
     flash_success(lang('success add task dependency'));
     $reload = array_var($_GET, 'reload', true);
     if ($reload) {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
 }