<?php
use Entity\Company;
class Company_BBG_Controller extends Base_Controller {
/**
* action_upload_bbg
*
* This controller method uploads and checks the extensions
* and sizes of files before they're uploaded, then uploads them
* and returns the outcome and if succesful, alongside the resultant
* URL pointing to where the file is situated.
*/
public function action_upload_bbg()
{
$f = new fileUploader;
$f->setExtensions(['xlsx', 'xls']);
return $f->handle('bbg');
}
public function action_import()
{
if (!Input::get('BBG')) {
return View::make('company::staff.bbg.import');
}
// Replace the URL of the file with the path equivilent
$bbg = str_replace(URL::base(), path('public'), Input::get('BBG'))[0];
$importer = new bbg();
$response = $importer->import($bbg);
if ($response === true) {
Session::flash('message', 'Successfully imported the BBG file');
} else {
Session::flash(
'message',
'Error: The BBG file was not successfully imported - the
following Tickers were not imported into the system: <ul><li>'
. implode('</li><li> ', $response)
. '</ul>'
);
}
return Redirect::to('company/import/BBG');
}
}