/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $organization = Organization::find($id);
     $organization->delete();
     Session::flash('successMessage', 'Your delete was successful.');
     return Redirect::action('OrganizationsController@index');
 }
Exemplo n.º 2
0
 /**
  * Signup a new account with the given parameters
  *
  * @param  array $input Array containing 'username', 'email' and 'password'.
  *
  * @return  User User object that may or may not be saved successfully. Check the id to make sure.
  */
 public function signup($input)
 {
     // $name = array_get($input, 'organization');
     $org = new Organization();
     $lcode = $org->encode($name);
     $organization = Organization::find(array_get($input, 'organization_id'));
     $organization->licensed = 100;
     $organization->license_code = $lcode;
     $organization->update();
     $user = new User();
     $user->username = array_get($input, 'username');
     $user->email = array_get($input, 'email');
     $user->password = array_get($input, 'password');
     $user->user_type = array_get($input, 'user_type');
     $user->username = array_get($input, 'username');
     $user->organization_id = '1';
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $user->password_confirmation = array_get($input, 'password_confirmation');
     // Generate a random confirmation code
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     // Save if valid. Password field will be hashed before save
     $this->save($user);
     return $user;
 }
Exemplo n.º 3
0
 public static function balanceSheet($date)
 {
     $accounts = Account::all();
     $organization = Organization::find(1);
     $pdf = PDF::loadView('pdf.financials.balancesheet', compact('accounts', 'date', 'organization'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream('Balance Sheet.pdf');
 }
Exemplo n.º 4
0
 public function getOrgDocs($id)
 {
     $organization = Organization::find($id);
     $user = Organization::find($id)->user();
     $documents = User::find($organization->user->id)->documents;
     return View::make('inspector.documents_view', ['organization' => $organization, 'user' => $user, 'documents' => $documents]);
 }
Exemplo n.º 5
0
 public function payments()
 {
     $payments = Payment::all();
     $erporders = Erporder::all();
     $erporderitems = Erporderitem::all();
     $organization = Organization::find(1);
     $pdf = PDF::loadView('erpreports.paymentsReport', compact('payments', 'erporders', 'erporderitems', 'organization'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream('Payment List.pdf');
 }
 public function edit($id)
 {
     $organization = Organization::find($id);
     if (!Auth::user()->hasPermissionTo('edit', $organization)) {
         Session::put('status', 'error');
         Session::put('message', 'You do not have permission to edit this organization!');
         return Redirect::to('organization/' . $organization->id);
     } elseif (Input::has('_token')) {
         return $this->save($organization, array_except(Input::all(), '_token'));
     } else {
         return View::make('organization.edit', array('organization' => $organization));
     }
 }
 /**
  *
  **/
 public function postUpdate()
 {
     $organization = Organization::find(Input::get('id'));
     $organization->name = Input::get('name');
     $file = Input::file('image');
     if ($file != null) {
         $upload_success = Input::file('image')->move('public/uploads', $file->getClientOriginalName());
         $organization->logo = $file->getClientOriginalName();
     }
     $organization->address = Input::get('address');
     $organization->webPage = Input::get('webPage');
     $organization->save();
     return Redirect::to('organization/edit')->with('message', 'Registro actualizado con exito');
 }
 public function addAction($f3)
 {
     $data = json_decode($f3->get('BODY'));
     //allows to use one loop for both array and object input
     if (!is_array($data)) {
         $data = array($data);
     }
     $organization = new Organization();
     $is_error = false;
     $message = "";
     $result = array();
     foreach ($data as $item) {
         //create the data in local DB only if it is created in the API
         //attention - id's do not match
         $res = $this->checkDuplicateNamesLocal($item);
         if (max(array_count_values($res)) > 1) {
             $is_error = true;
             $message = "Your request data contains duplicate customer names";
             continue;
         }
         //if first step pass - check if new items already exist in database
         //(could be optimized into one query using IN() operator, depending on real data purpose )
         foreach ($res as $item2) {
             $organization->find(array('name = ?', $item2));
             if ($organization->loaded()) {
                 $is_error = true;
                 $message = "Organization {$organization->name} already added to the database";
                 continue;
             }
         }
         if (!$this->createAPIOrganizationRecursive($item)) {
             $is_error = true;
             $message = "Error while adding organization tree to the pipedrive API";
             continue;
         }
         $this->createOrganizationRecursive($item, $result);
     }
     if ($is_error) {
         $f3->set('content', $this->errorResponse($message));
     } else {
         $f3->set('content', $this->successResponse($result));
     }
 }
Exemplo n.º 9
0
 public function addNote()
 {
     $user_id = Input::get('user_id');
     $org_id = Input::get('org_id');
     $body = Input::get('body');
     $flag = Input::get('flag');
     $user = User::find($user_id);
     $org = Organization::find($org_id);
     if (!$user or !$org) {
         err('Something went wrong with your submission');
         return Redirect::back();
     }
     if (!me()->isOrgAdmin($org)) {
         err('You do not have permission to leave organizational notes for that organization');
         return Redirect::back();
     }
     $note = new OrganizationNote();
     $note->organization_id = $org_id;
     $note->body = $body;
     $user->notes()->save($note);
     msg('Note left successfully');
     return Redirect::back();
 }
Exemplo n.º 10
0
 public function financials()
 {
     $report = Input::get('report_type');
     $date = Input::get('date');
     $accounts = Account::all();
     $organization = Organization::find(1);
     if ($report == 'balancesheet') {
         $pdf = PDF::loadView('pdf.financials.balancesheet', compact('accounts', 'date', 'organization'))->setPaper('a4')->setOrientation('potrait');
         return $pdf->stream('Balance Sheet.pdf');
     }
     if ($report == 'income') {
         $pdf = PDF::loadView('pdf.financials.incomestatement', compact('accounts', 'date', 'organization'))->setPaper('a4')->setOrientation('potrait');
         return $pdf->stream('Income Statement.pdf');
     }
     if ($report == 'trialbalance') {
         $pdf = PDF::loadView('pdf.financials.trialbalance', compact('accounts', 'date', 'organization'))->setPaper('a4')->setOrientation('potrait');
         return $pdf->stream('Trial Balance.pdf');
     }
 }
Exemplo n.º 11
0
 public function sendEmail()
 {
     if (!empty(Input::get('sel'))) {
         $period = Input::get('period');
         $employees = Employee::all();
         $emps = DB::table('employee')->count();
         foreach ($employees as $user) {
             $transacts = DB::table('transact')->join('employee', 'transact.employee_id', '=', 'employee.personal_file_number')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', $user->id)->get();
             $allws = DB::table('transact_allowances')->join('employee', 'transact_allowances.employee_id', '=', 'employee.id')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', $user->id)->groupBy('allowance_name')->get();
             $earnings = DB::table('transact_earnings')->join('employee', 'transact_earnings.employee_id', '=', 'employee.id')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', $user->id)->groupBy('earning_name')->get();
             $deds = DB::table('transact_deductions')->join('employee', 'transact_deductions.employee_id', '=', 'employee.id')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', $user->id)->groupBy('deduction_name')->get();
             $currencies = DB::table('currencies')->select('shortname')->get();
             $organization = Organization::find(1);
             $fyear = '';
             $fperiod = '';
             $part = explode("-", $period);
             if ($part[0] == 1) {
                 $fyear = 'January_' . $part[1];
             } else {
                 if ($part[0] == 2) {
                     $fyear = 'Febraury_' . $part[1];
                 } else {
                     if ($part[0] == 3) {
                         $fyear = 'March_' . $part[1];
                     } else {
                         if ($part[0] == 4) {
                             $fyear = 'April_' . $part[1];
                         } else {
                             if ($part[0] == 5) {
                                 $fyear = 'May_' . $part[1];
                             } else {
                                 if ($part[0] == 6) {
                                     $fyear = 'June_' . $part[1];
                                 } else {
                                     if ($part[0] == 7) {
                                         $fyear = 'July_' . $part[1];
                                     } else {
                                         if ($part[0] == 8) {
                                             $fyear = 'August_' . $part[1];
                                         } else {
                                             if ($part[0] == 9) {
                                                 $fyear = 'September_' . $part[1];
                                             } else {
                                                 if ($part[0] == 10) {
                                                     $fyear = 'October_' . $part[1];
                                                 } else {
                                                     if ($part[0] == 11) {
                                                         $fyear = 'November_' . $part[1];
                                                     } else {
                                                         if ($part[0] == 12) {
                                                             $fyear = 'December_' . $part[1];
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if ($part[0] == 1) {
                 $fperiod = 'January-' . $part[1];
             } else {
                 if ($part[0] == 2) {
                     $fperiod = 'Febraury-' . $part[1];
                 } else {
                     if ($part[0] == 3) {
                         $fperiod = 'March-' . $part[1];
                     } else {
                         if ($part[0] == 4) {
                             $fperiod = 'April-' . $part[1];
                         } else {
                             if ($part[0] == 5) {
                                 $fperiod = 'May-' . $part[1];
                             } else {
                                 if ($part[0] == 6) {
                                     $fperiod = 'June-' . $part[1];
                                 } else {
                                     if ($part[0] == 7) {
                                         $fperiod = 'July-' . $part[1];
                                     } else {
                                         if ($part[0] == 8) {
                                             $fperiod = 'August-' . $part[1];
                                         } else {
                                             if ($part[0] == 9) {
                                                 $fperiod = 'September-' . $part[1];
                                             } else {
                                                 if ($part[0] == 10) {
                                                     $fperiod = 'October-' . $part[1];
                                                 } else {
                                                     if ($part[0] == 11) {
                                                         $fperiod = 'November-' . $part[1];
                                                     } else {
                                                         if ($part[0] == 12) {
                                                             $fperiod = 'December-' . $part[1];
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $fileName = $user->first_name . '_' . $user->last_name . '_' . $fyear . '.pdf';
             $filePath = 'app/views/temp/';
             $pdf = PDF::loadView('pdf.monthlySlip', compact('employee', 'transacts', 'allws', 'deds', 'earnings', 'period', 'currencies', 'organization'))->setPaper('a4')->setOrientation('potrait');
             $pdf->save($filePath . $fileName);
             Mail::send('payslips.message', compact('fperiod', 'user'), function ($message) use($user, $filePath, $fileName) {
                 $message->to($user->email_office, $user->first_name . ' ' . $user->last_name)->subject('Payslip');
                 $message->attach($filePath . $fileName);
             });
             unlink($filePath . $fileName);
         }
         return Redirect::back()->with('success', 'Email Sent!');
     } else {
         if (empty(Input::get('sel')) && !empty(Input::get('employeeid'))) {
             $period = Input::get('period');
             $employees = Employee::all();
             $emps = DB::table('employee')->count();
             $id = Input::get('employeeid');
             $employee = Employee::find($id);
             $transacts = DB::table('transact')->join('employee', 'transact.employee_id', '=', 'employee.personal_file_number')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', Input::get('employeeid'))->get();
             $allws = DB::table('transact_allowances')->join('employee', 'transact_allowances.employee_id', '=', 'employee.id')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', Input::get('employeeid'))->groupBy('allowance_name')->get();
             $earnings = DB::table('transact_earnings')->join('employee', 'transact_earnings.employee_id', '=', 'employee.id')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', Input::get('employeeid'))->groupBy('earning_name')->get();
             $deds = DB::table('transact_deductions')->join('employee', 'transact_deductions.employee_id', '=', 'employee.id')->where('financial_month_year', '=', Input::get('period'))->where('employee.id', '=', Input::get('employeeid'))->groupBy('deduction_name')->get();
             $currencies = DB::table('currencies')->select('shortname')->get();
             $organization = Organization::find(1);
             $fyear = '';
             $fperiod = '';
             $part = explode("-", $period);
             if ($part[0] == 1) {
                 $fyear = 'January_' . $part[1];
             } else {
                 if ($part[0] == 2) {
                     $fyear = 'Febraury_' . $part[1];
                 } else {
                     if ($part[0] == 3) {
                         $fyear = 'March_' . $part[1];
                     } else {
                         if ($part[0] == 4) {
                             $fyear = 'April_' . $part[1];
                         } else {
                             if ($part[0] == 5) {
                                 $fyear = 'May_' . $part[1];
                             } else {
                                 if ($part[0] == 6) {
                                     $fyear = 'June_' . $part[1];
                                 } else {
                                     if ($part[0] == 7) {
                                         $fyear = 'July_' . $part[1];
                                     } else {
                                         if ($part[0] == 8) {
                                             $fyear = 'August_' . $part[1];
                                         } else {
                                             if ($part[0] == 9) {
                                                 $fyear = 'September_' . $part[1];
                                             } else {
                                                 if ($part[0] == 10) {
                                                     $fyear = 'October_' . $part[1];
                                                 } else {
                                                     if ($part[0] == 11) {
                                                         $fyear = 'November_' . $part[1];
                                                     } else {
                                                         if ($part[0] == 12) {
                                                             $fyear = 'December_' . $part[1];
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if ($part[0] == 1) {
                 $fperiod = 'January-' . $part[1];
             } else {
                 if ($part[0] == 2) {
                     $fperiod = 'Febraury-' . $part[1];
                 } else {
                     if ($part[0] == 3) {
                         $fperiod = 'March-' . $part[1];
                     } else {
                         if ($part[0] == 4) {
                             $fperiod = 'April-' . $part[1];
                         } else {
                             if ($part[0] == 5) {
                                 $fperiod = 'May-' . $part[1];
                             } else {
                                 if ($part[0] == 6) {
                                     $fperiod = 'June-' . $part[1];
                                 } else {
                                     if ($part[0] == 7) {
                                         $fperiod = 'July-' . $part[1];
                                     } else {
                                         if ($part[0] == 8) {
                                             $fperiod = 'August-' . $part[1];
                                         } else {
                                             if ($part[0] == 9) {
                                                 $fperiod = 'September-' . $part[1];
                                             } else {
                                                 if ($part[0] == 10) {
                                                     $fperiod = 'October-' . $part[1];
                                                 } else {
                                                     if ($part[0] == 11) {
                                                         $fperiod = 'November-' . $part[1];
                                                     } else {
                                                         if ($part[0] == 12) {
                                                             $fperiod = 'December-' . $part[1];
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $fileName = $employee->first_name . '_' . $employee->last_name . '_' . $fyear . '.pdf';
             $filePath = 'app/views/temp/';
             $pdf = PDF::loadView('pdf.monthlySlip', compact('employee', 'transacts', 'allws', 'deds', 'earnings', 'period', 'currencies', 'organization'))->setPaper('a4')->setOrientation('potrait');
             $pdf->save($filePath . $fileName);
             $user = Employee::find($id);
             Mail::send('payslips.message', compact('fperiod', 'user'), function ($message) use($user, $filePath, $fileName) {
                 $message->to($user->email_office, $user->first_name . ' ' . $user->last_name)->subject('Payslip');
                 $message->attach($filePath . $fileName);
             });
             unlink($filePath . $fileName);
         }
     }
     return Redirect::back()->with('success', 'Email Sent!');
 }
 /**
  * Show the form for editing the specified organization.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $organization = Organization::find($id);
     return View::make('organizations.edit', compact('organization'));
 }
Exemplo n.º 13
0
 public static function getUserOrganization()
 {
     $organization_id = Confide::user()->organization_id;
     $organization = Organization::find($organization_id);
     return $organization;
 }
Exemplo n.º 14
0
            break;
        case 'organizations':
            $object = Organization::all();
            break;
        default:
            $object = '';
    }
    return Response::json($object);
}));
Route::get('{object_name}/{id}/json', array('as' => 'json', function ($object_name, $id) {
    switch ($object_name) {
        case 'user':
            $object = User::find($id);
            break;
        case 'organization':
            $object = Organization::find($id);
            break;
        default:
            $object = '';
    }
    return Response::json($object);
}));
Route::post('{object_name}/search/json', array('as' => 'search', function ($object_name) {
    if (!Input::has('query')) {
        return Response::json(array());
    }
    $query = Input::get('query', '');
    $query = '%' . str_replace(' ', '%', $query) . '%';
    switch ($object_name) {
        case 'user':
            $results = User::where('email', 'LIKE', $query)->orWhere('first_name', 'LIKE', $query)->get()->toArray();
Exemplo n.º 15
0
 /**
  * Process the Meta table for campaign urls and create the
  * campaign from the corresponding URL
  */
 protected function importCampaigns()
 {
     $metas = \Meta::all(['prop = ?' => 'campImport']);
     $users = [];
     $orgs = [];
     foreach ($metas as $m) {
         $user = Usr::find($users, $m->propid, ['_id', 'org_id', 'email', 'meta']);
         $org = \Organization::find($orgs, $user->org_id);
         $categories = \Category::all(['org_id' => $org->_id], ['_id', 'name']);
         $categories = array_values($categories);
         $category = $categories[array_rand($categories)];
         // fetch ad info foreach URL
         $advert_id = $m->value['advert_id'];
         $comm = $m->value['campaign'] ?? $org->meta;
         if (!isset($comm['model']) || !isset($comm['rate'])) {
             continue;
         }
         $urls = $m->value['urls'];
         foreach ($urls as $url) {
             $ad = \Ad::first(['org_id' => $org->_id, 'url' => $url]);
             if ($ad) {
                 continue;
             }
             // already crawled URL may be due to failed cron earlier
             $data = Utils::fetchCampaign($url);
             $image = Utils::downloadImage($data['image']);
             if (!$image) {
                 $image = '';
             }
             $ad = new \Ad(['user_id' => $advert_id, 'org_id' => $org->_id, 'title' => $data['title'], 'description' => $data['description'], 'url' => $url, 'image' => $image, 'category' => [$category->_id], 'type' => 'article', 'live' => false, 'device' => ['ALL']]);
             if ($ad->validate()) {
                 $ad->save();
                 $rev = $comm['revenue'] ?? 1.25 * (double) $comm['rate'];
                 $commission = new \Commission(['ad_id' => $ad->_id, 'model' => $comm['model'], 'rate' => $comm['rate'], 'revenue' => round($rev, 6), 'coverage' => ['ALL']]);
                 $commission->save();
             } else {
                 var_dump($ad->getErrors());
             }
         }
         $msg = 'Campaigns imported for the user: ' . $user->email;
         $this->log($msg);
         $m->delete();
     }
 }
Exemplo n.º 16
0
    Route::get('roles/create', 'RolesController@create');
    Route::get('roles/edit/{id}', 'RolesController@edit');
    Route::post('roles/update/{id}', 'RolesController@update');
    Route::get('roles/delete/{id}', 'RolesController@destroy');
});
Route::get('import', function () {
    return View::make('import');
});
Route::group(['before' => 'manage_system'], function () {
    Route::get('system', function () {
        $organization = Organization::find(1);
        return View::make('system.index', compact('organization'));
    });
});
Route::get('license', function () {
    $organization = Organization::find(1);
    return View::make('system.license', compact('organization'));
});
/**
* Organization routes
*/
Route::group(['before' => 'manage_organization'], function () {
    Route::resource('organizations', 'OrganizationsController');
    Route::post('organizations/update/{id}', 'OrganizationsController@update');
    Route::post('organizations/logo/{id}', 'OrganizationsController@logo');
});
Route::get('language/{lang}', array('as' => 'language.select', 'uses' => 'OrganizationsController@language'));
Route::resource('clients', 'ClientsController');
Route::get('clients/edit/{id}', 'ClientsController@edit');
Route::post('clients/update/{id}', 'ClientsController@update');
Route::get('clients/delete/{id}', 'ClientsController@destroy');
Exemplo n.º 17
0
 public function offprint($id)
 {
     $loanaccount = Loanaccount::findOrFail($id);
     $organization = Organization::find(1);
     $principal_paid = Loanrepayment::getPrincipalPaid($loanaccount);
     $principal_due = $loanaccount->amount_disbursed - $principal_paid;
     $interest_due = $principal_due * ($loanaccount->interest_rate / 100);
     $pdf = PDF::loadView('pdf.offset', compact('loanaccount', 'organization', 'principal_paid', 'interest_due', 'principal_due'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream('Offset.pdf');
 }
Exemplo n.º 18
0
 function index()
 {
     $this->layout('default');
     $this->documents = Organization::find($_SESSION['organization_id'])->documents;
 }
Exemplo n.º 19
0
 public function quotation($id)
 {
     $orders = DB::table('erporders')->join('erporderitems', 'erporders.id', '=', 'erporderitems.erporder_id')->join('items', 'erporderitems.item_id', '=', 'items.id')->join('clients', 'erporders.client_id', '=', 'clients.id')->where('erporders.id', '=', $id)->select('clients.name as client', 'items.name as item', 'quantity', 'clients.address as address', 'clients.phone as phone', 'clients.email as email', 'date', 'erporders.id as id', 'discount_amount', 'erporders.order_number as order_number', 'price', 'description')->get();
     $txorders = DB::table('tax_orders')->join('erporders', 'tax_orders.order_number', '=', 'erporders.order_number')->join('taxes', 'tax_orders.tax_id', '=', 'taxes.id')->where('erporders.id', '=', $id)->get();
     $count = DB::table('tax_orders')->count();
     $erporder = Erporder::findorfail($id);
     $organization = Organization::find(1);
     $pdf = PDF::loadView('erpreports.quotation', compact('orders', 'erporder', 'txorders', 'count', 'organization'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream('quotation.pdf');
 }
Exemplo n.º 20
0
 public function individualleave()
 {
     $id = Input::get("employeeid");
     $employee = Employee::find($id);
     $leavetypes = Leavetype::all();
     $organization = Organization::find(1);
     $pdf = PDF::loadView('leavereports.individualReport', compact('leavetypes', 'employee', 'organization'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream($employee->first_name . '_' . $employee->last_name . '_Leave_Report.pdf');
 }
Exemplo n.º 21
0
 public static function getUserOrganization()
 {
     $organization_id = 1;
     $organization = Organization::find($organization_id);
     return $organization;
 }
Exemplo n.º 22
0
 public function postCalcDocs($id)
 {
     $user = User::find($id);
     $documents = User::find($id)->documents;
     $sum_org_movables_carrying_amount = 0;
     $sum_org_value_movables_carrying_amount = 0;
     $sum_org_buildings_carrying_amount = 0;
     $sum_org_parcels_carrying_amount = 0;
     $sum_org_movables_residual_value = 0;
     $sum_org_value_movables_residual_value = 0;
     $sum_org_buildings_residual_value = 0;
     $sum_org_cars_carrying_amount = 0;
     $sum_org_cars_residual_value = 0;
     foreach ($documents as $document) {
         $type = $document->os_type;
         $items = Document::find($document->id)->items;
         $sum_carrying_amount = 0;
         $sum_residual_value = 0;
         foreach ($items as $item) {
             if (isset($item->carrying_amount)) {
                 $sum_carrying_amount = $sum_carrying_amount + $item->carrying_amount;
             } else {
                 $sum_carrying_amount = $sum_carrying_amount;
             }
             if ($type != 'parcels') {
                 $variable = Item::find($item->id)->variable;
                 if (isset($variable->residual_value)) {
                     $sum_residual_value = $sum_residual_value + $variable->residual_value;
                 }
                 $sum_residual_value = $sum_residual_value;
             }
         }
         $document->doc_carrying_amount = $sum_carrying_amount;
         if ($type != 'parcels') {
             $document->doc_residual_value = $sum_residual_value;
         }
         $document->save();
         if ($type == 'movables') {
             $sum_org_movables_carrying_amount = $sum_org_movables_carrying_amount + $document->doc_carrying_amount;
             $sum_org_movables_residual_value = $sum_org_movables_residual_value + $document->doc_residual_value;
         }
         if ($type == 'value_movables') {
             $sum_org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount + $document->doc_carrying_amount;
             $sum_org_value_movables_residual_value = $sum_org_value_movables_residual_value + $document->doc_residual_value;
         }
         if ($type == 'cars') {
             $sum_org_cars_carrying_amount = $sum_org_cars_carrying_amount + $document->doc_carrying_amount;
             $sum_org_cars_residual_value = $sum_org_cars_residual_value + $document->doc_residual_value;
         }
         if ($type == 'buildings') {
             $sum_org_buildings_carrying_amount = $sum_org_buildings_carrying_amount + $document->doc_carrying_amount;
             $sum_org_buildings_residual_value = $sum_org_buildings_residual_value + $document->doc_residual_value;
         }
         if ($type == 'parcels') {
             $sum_org_parcels_carrying_amount = $sum_org_parcels_carrying_amount + $document->doc_carrying_amount;
         }
     }
     $organization_id = $user->organization_id;
     $organization = Organization::find($organization_id);
     $organization->org_movables_carrying_amount = $sum_org_movables_carrying_amount;
     $organization->org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount;
     $organization->org_cars_carrying_amount = $sum_org_cars_carrying_amount;
     $organization->org_buildings_carrying_amount = $sum_org_buildings_carrying_amount;
     $organization->org_parcels_carrying_amount = $sum_org_parcels_carrying_amount;
     $organization->org_movables_residual_value = $sum_org_movables_residual_value;
     $organization->org_value_movables_residual_value = $sum_org_value_movables_residual_value;
     $organization->org_buildings_residual_value = $sum_org_buildings_residual_value;
     $organization->org_cars_residual_value = $sum_org_cars_residual_value;
     $organization->org_carrying_amount = $organization->org_movables_carrying_amount + $organization->org_value_movables_carrying_amount + $organization->org_buildings_carrying_amount + $organization->org_parcels_carrying_amount;
     $organization->org_residual_value = $organization->org_movables_residual_value + $organization->org_value_movables_residual_value + $organization->org_buildings_residual_value;
     $organization->save();
     return Redirect::action('AdminController@getOrgDocs', [$organization_id]);
 }
Exemplo n.º 23
-9
 public function stock()
 {
     $items = Item::all();
     $organization = Organization::find(1);
     $pdf = PDF::loadView('erpreports.stockReport', compact('items', 'organization'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream('Stock Report.pdf');
 }