/home/techb158/exp.abdallabala.com/application/models
NameSizeModeActions
Account.php4450644editdlrm
ApiKey.php1440644editdlrm
Company.php1240644editdlrm
Contact.php1230644editdlrm
ContactGroup.php1520644editdlrm
Currency.php233340644editdlrm
Integration.php1250644editdlrm
Invoice.php175590644editdlrm
InvoiceItem.php1310644editdlrm
Item.php1190644editdlrm
PaymentGateway.php1180644editdlrm
Transaction.php50450644editdlrm
TransactionCategory.php3880644editdlrm
TransactionMethod.php1300644editdlrm
User.php4790644editdlrm
Edit: /home/techb158/exp.abdallabala.com/application/models/Transaction.php (5045B)
where('currency',$currency_id); if($time == 'current_month'){ $total->where('date','>=',$first_day_month)->where('date','<=',$mdate); } elseif ($time = 'current_week'){ $total->where('date','>=',$this_week_start)->where('date','<=',$mdate); } elseif ($time == 'last_30_days'){ $total->where('date','>=',$before_30_days)->where('date','<=',$mdate); } return $total->sum('cr'); } public static function remove($id){ global $user; if(!has_access($user->roleid,'transactions','delete')){ permissionDenied(); } //find the transaction $t = ORM::for_table('sys_transactions')->find_one($id); if($t){ $a = ORM::for_table('sys_accounts')->where('account',$t['account'])->find_one(); $cr = $t['cr']; $dr = $t['dr']; if($a){ $cbal = $a['balance']; if($cr != '0.00'){ $nbal = $cbal-$cr; } else{ $nbal = $cbal+$dr; } $a->balance = $nbal; $a->save(); } $t->delete(); return true; } else{ return false; } } public static function deposit() { global $_L, $config; $account = _post('account'); $date = _post('date'); $amount = _post('amount'); /* @since v2. added support for ',' as decimal separator */ $amount = Finance::amount_fix($amount); $payerid = _post('payer'); $ref = _post('ref'); $pmethod = _post('pmethod'); $cat = _post('cats'); $tags = $_POST['tags']; /* @since Build 4560. added support file attachments */ $attachments = _post('attachments'); if($payerid == ''){ $payerid = '0'; } $description = _post('description'); $msg = ''; if ($description == '') { $msg .= $_L['description_error'] . '
'; } if (Validator::Length($account, 100, 1) == false) { $msg .= $_L['Choose an Account'].' ' . '
'; } if (is_numeric($amount) == false) { $msg .= $_L['amount_error'] . '
'; } if ($msg == '') { Tags::save($tags,'Income'); //find the current balance for this account $a = ORM::for_table('sys_accounts')->where('account',$account)->find_one(); $cbal = $a['balance']; $nbal = $cbal+$amount; $a->balance=$nbal; $a->save(); $d = ORM::for_table('sys_transactions')->create(); $d->account = $account; $d->type = 'Income'; $d->payerid = $payerid; $d->tags = Arr::arr_to_str($tags); $d->amount = $amount; $d->category = $cat; $d->method = $pmethod; $d->ref = $ref; $d->description = $description; // Build 4560 $d->attachments = $attachments; $d->date = $date; $d->dr = '0.00'; $d->cr = $amount; $d->bal = $nbal; //others $d->payer = ''; $d->payee = ''; $d->payeeid = '0'; $d->status = 'Cleared'; $d->tax = '0.00'; $d->iid = 0; $d->aid = $user->id; $d->updated_at = date('Y-m-d H:i:s'); // // multi currency support $currency = _post('currency'); $currency_find = Currency::find($currency); if(!$currency_find){ $currency_find = Currency::where('iso_code',$config['home_currency'])->first(); } // $d->save(); $tid = $d->id(); _log('New Deposit: '.$description.' [TrID: '.$tid.' | Amount: '.$amount.']','Admin',$user['id']); _msglog('s',$_L['Transaction Added Successfully']); return $tid; } else { return $msg; } } }