public function delete()
 {
     $id = \Input::get('id');
     $transaction = Transaction::find($id);
     $retData = $transaction->delete() ? 200 : 500;
     return \Response::json($retData);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Transaction::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['transaction_id' => $this->transaction_id, 'transaction_person_id' => $this->transaction_person_id, 'transaction_time' => $this->transaction_time, 'is_closed' => $this->is_closed]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Transaction::find()->orderBy(['id' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 200]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'is_fulfilled' => $this->is_fulfilled, 'pay_amount' => $this->pay_amount, 'account_type' => $this->account_type]);
     $query->andFilterWhere(['like', 'pay_id', $this->pay_id])->andFilterWhere(['like', 'login', $this->login])->andFilterWhere(['like', 'date', $this->date]);
     return $dataProvider;
 }
 /**
  * Lists all Transaction models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Transaction::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 5
0
 public function update(Request $request, $id)
 {
     if ($request->input('date_order') != null) {
         $date_order = $this->saved_date_format($request->input('date_order'));
         $date_deliver = $this->saved_date_format($request->input('date_deliver'));
         if ($request->input('date_checkout') != null) {
             $date_checkout = $this->saved_date_format($request->input('date_checkout'));
         } else {
             $date_checkout = "0000-00-00";
         }
         $request->merge(array($request->input('customer_id'), 'date_order' => $date_order, 'date_deliver' => $date_deliver, 'date_checkout' => $date_checkout));
     }
     $transUpdate = $request->input();
     $trans = Transaction::find($id);
     $trans->update($transUpdate);
     Session::flash('flash_message', 'OK!');
     return redirect()->back();
 }
Exemplo n.º 6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->except(['account', 'amount']);
     Transaction::find($id)->update($input);
     return redirect()->route('expense.index')->withMessage('Expense has been Updated')->withStatus('success');
 }
Exemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     try {
         $list = Transaction::find($id);
         $previd = $list->id - 1;
         $prevlist = Transaction::find($previd);
         $amount = $list->amount;
         $sourcebankid = Transaction::find($previd)->account_id;
         $tobankid = Transaction::find($id)->account_id;
         $from_balance = Bankncash::find($sourcebankid)->balance;
         $to_balance = Bankncash::find($tobankid)->balance;
         $newfrom_bal = $from_balance + $amount;
         $newto_bal = $to_balance - $amount;
         Bankncash::find($sourcebankid)->update(['balance' => $newfrom_bal]);
         Bankncash::find($tobankid)->update(['balance' => $newto_bal]);
         $list->delete();
         $prevlist->delete();
     } catch (Exception $e) {
         return redirect()->back()->withMessage('Error Reverting Transaction, Possibly it is already Deleted')->withStatus('error');
     }
     return redirect()->back()->withMessage('Transfer Reverted')->withStatus('success');
 }