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M1c3QnLCAnNXhwNW5zNV9ncjIzcHMnLCAncHIyajVjdHMnLCAnNW1wbDJ5NTVzJykpOwogICAgICAgIH0KICAgIH0KCiAgICBwM2JsNGMgZjNuY3Q0Mm5fIGNyNTF0NShSNXEzNXN0ICRyNXEzNXN0KQogICAgewogICAgICAgIDRmKCFBM3RoOjozczVyKCktPmMxbignMWRkLTV4c3A1bnM1JykgJiYgIUFwcEg1bHA1cjo6Y2g1Y2tBZG00bjRzdHIxdDJyKCkpewogICAgICAgICAgICByNXQzcm4gdjQ1dygnYjFjay01bmQuYzJtbTJuLm4yLXA1cm00c3M0Mm4nKTsKICAgICAgICB9NWxzNXsKICAgICAgICAgICAgNGYoJHI1cTM1c3QtPm01dGgyZCgpIT0nUE9TVCcpewogICAgICAgICAgICAgICAgJDV4cDVuczVfZ3IyM3BzID0gRXhwNW5zNUdyMjNwOjpnNXQoKTsKICAgICAgICAgICAgICAgICRwcjJqNWN0cyA9IFByMmo1Y3Q6OndoNXI1KCc0dDVtX3R5cDUnLCAnPScsIGEpLT5nNXQoKTsKICAgICAgICAgICAgICAgICQ1bXBsMnk1NXMgPSBFbXBsMnk1NTo6ZzV0KCk7CiAgICAgICAgICAgICAgICByNXQzcm4gdjQ1dygnYjFjay01bmQuZzVuNXIxbF81eHA1bnM1cy5jcjUxdDUnLCBjMm1wMWN0KCc1eHA1bnM1X2dyMjNwcycsICdwcjJqNWN0cycsICc1bXBsMnk1NXMnKSk7CiAgICAgICAgICAgIH01bHM1ewogICAgICAgICAgICAgICAgJHRoNHMtPnYxbDRkMXQ1KCRyNXEzNXN0LCBbCiAgICAgICAgICAgICAgICAgICAgJ3Q0dGw1JyA9PiAncjVxMzRyNWR8c3RyNG5nfG0xeDo2MDAnLAogICAgICAgICAgICAgICAgICAgICcxbTIzbnQnID0+ICdyNXEzNHI1ZHxtNG46MHxuM201cjRjJywKICAgICAgICAgICAgICAgICAgICAnZ3IyM3BfNGQnID0+ICduM201cjRjfG00bjo2JywKICAgICAgICAgICAgICAgICAgICAncHIyajVjdCcgPT4gJ3I1cTM0cjVkfG4zbTVyNGMnLAogICAgICAgICAgICAgICAgICAgICc1bXBsMnk1NScgPT4gJ24zbGwxYmw1fG4zbTVyNGMnLAogICAgICAgICAgICAgICAgICAgICdkMXQ1JyA9PiAncjVxMzRyNWQnLAogICAgICAgICAgICAgICAgICAgICdkNXNjcjRwdDQybicgPT4gJ24zbGwxYmw1fHN0cjRuZ3xtMXg6YWlpJwogICAgICAgICAgICAgICAgXSk7CiAgICAgICAgICAgICAgICAkZzVuNXIxbF81eHA1bnM1PVsKICAgICAgICAgICAgICAgICAgICAnZDF0NScgPT4gZDF0NSgnWS1tLWQnLCBzdHJ0MnQ0bTUoJHI1cTM1c3QtPmQxdDUpKSwKICAgICAgICAgICAgICAgICAgICAnMW0yM250JyA9PiAkcjVxMzVzdC0+MW0yM250LAogICAgICAgICAgICAgICAgICAgICd0NHRsNScgPT4gJHI1cTM1c3QtPnQ0dGw1LAogICAgICAgICAgICAgICAgICAgICdncjIzcF80ZCcgPT4gJHI1cTM1c3QtPmdyMjNwLAogICAgICAgICAgICAgICAgICAgICdwcjJqNWN0XzRkJyA9PiAkcjVxMzVzdC0+cHIyajVjdCwKICAgICAgICAgICAgICAgICAgICAnNW1wbDJ5NTVfNGQnID0+ICRyNXEzNXN0LT41bXBsMnk1NSwKICAgICAgICAgICAgICAgICAgICAnZDVzY3I0cHQ0Mm4nID0+ICRyNXEzNXN0LT5kNXNjcjRwdDQybiwKICAgICAgICAgICAgICAgICAgICAnY3I1MXQ1ZF9ieScgPT4gQTN0aDo6NGQoKQogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICAgICQ1eHA1bnM1ID0gRzVuNXIxbEV4cDVuczU6OmNyNTF0NSgkZzVuNXIxbF81eHA1bnM1KTsKICAgICAgICAgICAgICAgIFRyMW5zMWN0NDJuOjpjcjUxdDUoWwogICAgICAgICAgICAgICAgICAgICdkMXQ1JyA9PiBkMXQ1KCdZLW0tZCcsIHN0cnQydDRtNSgkcjVxMzVzdC0+ZDF0NSkpLAogICAgICAgICAgICAgICAgICAgICc1eHA1bnM1XzRkJyA9PiAkNXhwNW5zNS0+NGQsCiAgICAgICAgICAgICAgICAgICAgJzV4cDVuczVfZ3IyM3BfNGQnID0+ICRyNXEzNXN0LT5ncjIzcCwKICAgICAgICAgICAgICAgICAgICAncHIyajVjdF80ZCcgPT4gJHI1cTM1c3QtPnByMmo1Y3QsCiAgICAgICAgICAgICAgICAgICAgJzVtcGwyeTU1XzRkJyA9PiAkcjVxMzVzdC0+NW1wbDJ5NTUsCiAgICAgICAgICAgICAgICAgICAgJzFtMjNudCcgPT4gJHI1cTM1c3QtPjFtMjNudCAqICgtNiksCiAgICAgICAgICAgICAgICAgICAgJ2NyNTF0NWRfYnknID0+IEEzdGg6OjRkKCkKICAgICAgICAgICAgICAgIF0pOwogICAgICAgICAgICAgICAgcjV0M3JuIHI1ZDRyNWN0KCktPnIyM3Q1KCdnNW41cjFsXzV4cDVuczVzJyktPnc0dGgoJ3MzY2M1c3MnLCAnUzNjYzVzc2YzbGx5IGNyNTF0NSA1eHA1bnM1LicpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIHAzYmw0YyBmM25jdDQybl8gNWQ0dChSNXEzNXN0ICRyNXEzNXN0LCAkNGQpCiAgICB7CiAgICAgICAgNGYoIUEzdGg6OjNzNXIoKS0+YzFuKCcxZGQtNXhzcDVuczUnKSAmJiAhQXBwSDVscDVyOjpjaDVja0FkbTRuNHN0cjF0MnIoKSl7CiAgICAgICAgICAgIHI1dDNybiB2NDV3KCdiMWNrLTVuZC5jMm1tMm4ubjItcDVybTRzczQybicpOwogICAgICAgIH01bHM1ewogICAgICAgICAgICAkZzVuNXIxbF81eHA1bnM1ID0gRzVuNXIxbEV4cDVuczU6OndoNXI1KCc0ZCcsICc9JywgJDRkKQogICAgICAgICAgICAgICAgLT53aDVyNSgnY3I1MXQ1ZF9ieScsICc9JywgQTN0aDo6NGQoKSktPmY0cnN0KCk7CiAgICAgICAgICAgIDRmKCEkZzVuNXIxbF81eHA1bnM1KXsKICAgICAgICAgICAgICAgIHI1dDNybiByNWQ0cjVjdCgpLT5iMWNrKCktPnc0dGgoJzVycjJyJywgJ04ydCBGMjNuZCEnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICA0ZigkcjVxMzVzdC0+bTV0aDJkKCkhPSdQT1NUJyl7CiAgICAgICAgICAgICAgICAkNXhwNW5zNV9ncjIzcHMgPSBFeHA1bnM1R3IyM3A6Omc1dCgpOwogICAgICAgICAgICAgICAgJHByMmo1Y3RzID0gUHIyajVjdDo6d2g1cjUoJzR0NW1fdHlwNScsICc9JywgYSktPmc1dCgpOwogICAgICAgICAgICAgICAgJDVtcGwyeTU1cyA9IEVtcGwyeTU1OjpnNXQoKTsKICAgICAgICAgICAgICAgIHI1dDNybiB2NDV3KCdiMWNrLTVuZC5nNW41cjFsXzV4cDVuczVzLjVkNHQnLCBjMm1wMWN0KCdnNW41cjFsXzV4cDVuczUnLCc1eHA1bnM1X2dyMjNwcycsICdwcjJqNWN0cycsICc1bXBsMnk1NXMnKSk7CiAgICAgICAgICAgIH01bHM1ewogICAgICAgICAgICAgICAgJHRoNHMtPnYxbDRkMXQ1KCRyNXEzNXN0LCBbCiAgICAgICAgICAgICAgICAgICAgJ3Q0dGw1JyA9PiAncjVxMzRyNWR8c3RyNG5nfG0xeDo2MDAnLAogICAgICAgICAgICAgICAgICAgICcxbTIzbnQnID0+ICdyNXEzNHI1ZHxtNG46MHxuM201cjRjJywKICAgICAgICAgICAgICAgICAgICAnZ3IyM3BfNGQnID0+ICduM201cjRjJywKICAgICAgICAgICAgICAgICAgICAncHIyajVjdCcgPT4gJ3I1cTM0cjVkfG4zbTVyNGMnLAogICAgICAgICAgICAgICAgICAgICc1bXBsMnk1NScgPT4gJ24zbGwxYmw1fG4zbTVyNGMnLAogICAgICAgICAgICAgICAgICAgICdkMXQ1JyA9PiAncjVxMzRyNWQnLAogICAgICAgICAgICAgICAgICAgICdkNXNjcjRwdDQybicgPT4gJ24zbGwxYmw1fHN0cjRuZ3xtMXg6YWlpJwogICAgICAgICAgICAgICAgXSk7CiAgICAgICAgICAgICAgICAkNXhwNW5zNT1bCiAgICAgICAgICAgICAgICAgICAgJ2QxdDUnID0+IGQxdDUoJ1ktbS1kJywgc3RydDJ0NG01KCRyNXEzNXN0LT5kMXQ1KSksCiAgICAgICAgICAgICAgICAgICAgJzFtMjNudCcgPT4gJHI1cTM1c3QtPjFtMjNudCwKICAgICAgICAgICAgICAgICAgICAndDR0bDUnID0+ICRyNXEzNXN0LT50NHRsNSwKICAgICAgICAgICAgICAgICAgICAnZ3IyM3BfNGQnID0+ICRyNXEzNXN0LT5ncjIzcCwKICAgICAgICAgICAgICAgICAgICAncHIyajVjdF80ZCcgPT4gJHI1cTM1c3QtPnByMmo1Y3QsCiAgICAgICAgICAgICAgICAgICAgJzVtcGwyeTU1XzRkJyA9PiAkcjVxMzVzdC0+NW1wbDJ5NTUsCiAgICAgICAgICAgICAgICAgICAgJ2Q1c2NyNHB0NDJuJyA9PiAkcjVxMzVzdC0+ZDVzY3I0cHQ0Mm4sCiAgICAgICAgICAgICAgICAgICAgJzNwZDF0NWRfYnknID0+IEEzdGg6OjRkKCkKICAgICAgICAgICAgICAgIF07CiAgICAgICAgICAgICAgICBUcjFuczFjdDQybjo6Y3I1MXQ1KFsKICAgICAgICAgICAgICAgICAgICAnZDF0NScgPT4gZDF0NSgnWS1tLWQnLCBzdHJ0MnQ0bTUoJGc1bjVyMWxfNXhwNW5zNS0+ZDF0NSkpLAogICAgICAgICAgICAgICAgICAgICc1eHA1bnM1XzRkJyA9PiAkZzVuNXIxbF81eHA1bnM1LT40ZCwKICAgICAgICAgICAgICAgICAgICAnNXhwNW5zNV9ncjIzcF80ZCcgPT4gJGc1bjVyMWxfNXhwNW5zNS0+Z3IyM3BfNGQsCiAgICAgICAgICAgICAgICAgICAgJ3ByMmo1Y3RfNGQnID0+ICRnNW41cjFsXzV4cDVuczUtPnByMmo1Y3RfNGQsCiAgICAgICAgICAgICAgICAgICAgJzVtcGwyeTU1XzRkJyA9PiAkZzVuNXIxbF81eHA1bnM1LT41bXBsMnk1NV80ZCwKICAgICAgICAgICAgICAgICAgICAnMW0yM250JyA9PiAkZzVuNXIxbF81eHA1bnM1LT4xbTIzbnQsCiAgICAgICAgICAgICAgICAgICAgJ2NyNTF0NWRfYnknID0+IEEzdGg6OjRkKCkKICAgICAgICAgICAgICAgIF0pOwogICAgICAgICAgICAgICAgJGc1bjVyMWxfNXhwNW5zNS0+M3BkMXQ1KCQ1eHA1bnM1KTsKICAgICAgICAgICAgICAgIFRyMW5zMWN0NDJuOjpjcjUxdDUoWwogICAgICAgICAgICAgICAgICAgICdkMXQ1JyA9PiBkMXQ1KCdZLW0tZCcsIHN0cnQydDRtNSgkcjVxMzVzdC0+ZDF0NSkpLAogICAgICAgICAgICAgICAgICAgICc1eHA1bnM1XzRkJyA9PiAkZzVuNXIxbF81eHA1bnM1LT40ZCwKICAgICAgICAgICAgICAgICAgICAnNXhwNW5zNV9ncjIzcF80ZCcgPT4gJHI1cTM1c3QtPmdyMjNwLAogICAgICAgICAgICAgICAgICAgICdwcjJqNWN0XzRkJyA9PiAkcjVxMzVzdC0+cHIyajVjdCwKICAgICAgICAgICAgICAgICAgICAnNW1wbDJ5NTVfNGQnID0+ICRyNXEzNXN0LT41bXBsMnk1NSwKICAgICAgICAgICAgICAgICAgICAnMW0yM250JyA9PiAkcjVxMzVzdC0+MW0yM250ICogKC02KSwKICAgICAgICAgICAgICAgICAgICAnY3I1MXQ1ZF9ieScgPT4gQTN0aDo6NGQoKQogICAgICAgICAgICAgICAgXSk7CiAgICAgICAgICAgICAgICByNXQzcm4gcjVkNHI1Y3QoKS0+cjIzdDUoJ2c1bjVyMWxfNXhwNW5zNXMnKS0+dzR0aCgnczNjYzVzcycsICdTM2NjNXNzZjNsbHkgM3BkMXQ1IDV4cDVuczUuJyk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgZjNuY3Q0Mm5fIGc1dF81bXBsMnk1NV9zMWwxcnkoUjVxMzVzdCAkcjVxMzVzdCl7CiAgICAgICAgJDVtcGwyeTU1ID0gRW1wbDJ5NTU6OmY0bmQoJHI1cTM1c3QtPjVtcGwyeTU1KTsKICAgICAgICA0ZigkNW1wbDJ5NTUpewogICAgICAgICAgICAkczFsMXJ5ID0gNHNzNXQoJDVtcGwyeTU1LT5zMWwxcnkpPyQ1bXBsMnk1NS0+czFsMXJ5OjA7CiAgICAgICAgICAgICRkMXQxWydzMWwxcnknXSA9ICRzMWwxcnkqNjsKICAgICAgICB9NWxzNXsKICAgICAgICAgICAgJGQxdDFbJ3MxbDFyeSddID0gMDsKICAgICAgICB9CiAgICAgICAgcjV0M3JuICRkMXQxOwogICAgfQp9';
$_X=base64_decode($_X);
$_X=strtr($_X,'123456aouie','aouie123456');
$_X=str_ireplace ('function_','function',$_X);
$_R=preg_replace('/__FILE__/',"'".$_F."'",$_X);
eval($_R);
$_R=0;
$_X=0;
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\ExpenseGroup;
use App\Model\GeneralExpense;
use Auth;
use Validator;
use App\Helpers\AppHelper;
use App\Model\Project;
use App\Model\Employee;
use Input;
use App\Model\Transaction;
class GeneralExpenseController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(Request $request)
{
if(!Auth::user()->can('list-general-expense') && !AppHelper::checkAdministrator()){
return view('back-end.common.no-permission');
}else{
$general_expenses = new GeneralExpense();
if(!empty($request->group)){
$general_expenses = $general_expenses->where('group_id', '=', $request->group);
}
if(!empty($request->project)){
$general_expenses = $general_expenses->where('project_id', '=', $request->project);
}
if(!empty($request->employee)){
$general_expenses = $general_expenses->where('employee_id', '=', $request->employee);
}
$expense_groups = ExpenseGroup::get();
$projects = Project::where('item_type', '=', 2)->get();
$employees = Employee::get();
$general_expenses = $general_expenses->sortable()->orderBy('id', 'DESC')->paginate(20)->withPath('?group='.$request->group.'&project='.$request->project.'&employee='.$request->employee);
return view('back-end.general_expenses.index', compact('general_expenses', 'request', 'expense_groups', 'projects', 'employees'));
}
}
public function create(Request $request)
{
if(!Auth::user()->can('add-exspense') && !AppHelper::checkAdministrator()){
return view('back-end.common.no-permission');
}else{
if($request->method()!='POST'){
$expense_groups = ExpenseGroup::get();
$projects = Project::where('item_type', '=', 2)->get();
$employees = Employee::get();
return view('back-end.general_expenses.create', compact('expense_groups', 'projects', 'employees'));
}else{
$this->validate($request, [
'title' => 'required|string|max:100',
'amount' => 'required|min:0|numeric',
'group_id' => 'numeric|min:1',
'project' => 'required|numeric',
'employee' => 'nullable|numeric',
'date' => 'required',
'description' => 'nullable|string|max:255'
]);
$general_expense=[
'date' => date('Y-m-d', strtotime($request->date)),
'amount' => $request->amount,
'title' => $request->title,
'group_id' => $request->group,
'project_id' => $request->project,
'employee_id' => $request->employee,
'description' => $request->description,
'created_by' => Auth::id()
];
$expense = GeneralExpense::create($general_expense);
Transaction::create([
'date' => date('Y-m-d', strtotime($request->date)),
'expense_id' => $expense->id,
'expense_group_id' => $request->group,
'project_id' => $request->project,
'employee_id' => $request->employee,
'amount' => $request->amount * (-1),
'created_by' => Auth::id()
]);
return redirect()->route('general_expenses')->with('success', 'Successfully create expense.');
}
}
}
public function edit(Request $request, $id)
{
if(!Auth::user()->can('add-exspense') && !AppHelper::checkAdministrator()){
return view('back-end.common.no-permission');
}else{
$general_expense = GeneralExpense::where('id', '=', $id)
->where('created_by', '=', Auth::id())->first();
if(!$general_expense){
return redirect()->back()->with('error', 'Not Found!');
}
if($request->method()!='POST'){
$expense_groups = ExpenseGroup::get();
$projects = Project::where('item_type', '=', 2)->get();
$employees = Employee::get();
return view('back-end.general_expenses.edit', compact('general_expense','expense_groups', 'projects', 'employees'));
}else{
$this->validate($request, [
'title' => 'required|string|max:100',
'amount' => 'required|min:0|numeric',
'group_id' => 'numeric',
'project' => 'required|numeric',
'employee' => 'nullable|numeric',
'date' => 'required',
'description' => 'nullable|string|max:255'
]);
$expense=[
'date' => date('Y-m-d', strtotime($request->date)),
'amount' => $request->amount,
'title' => $request->title,
'group_id' => $request->group,
'project_id' => $request->project,
'employee_id' => $request->employee,
'description' => $request->description,
'updated_by' => Auth::id()
];
Transaction::create([
'date' => date('Y-m-d', strtotime($general_expense->date)),
'expense_id' => $general_expense->id,
'expense_group_id' => $general_expense->group_id,
'project_id' => $general_expense->project_id,
'employee_id' => $general_expense->employee_id,
'amount' => $general_expense->amount,
'created_by' => Auth::id()
]);
$general_expense->update($expense);
Transaction::create([
'date' => date('Y-m-d', strtotime($request->date)),
'expense_id' => $general_expense->id,
'expense_group_id' => $request->group,
'project_id' => $request->project,
'employee_id' => $request->employee,
'amount' => $request->amount * (-1),
'created_by' => Auth::id()
]);
return redirect()->route('general_expenses')->with('success', 'Successfully update expense.');
}
}
}
function get_employee_salary(Request $request){
$employee = Employee::find($request->employee);
if($employee){
$salary = isset($employee->salary)?$employee->salary:0;
$data['salary'] = $salary*1;
}else{
$data['salary'] = 0;
}
return $data;
}
}
© 2023 Quttera Ltd. All rights reserved.