Fix formatting and whitespace

This commit is contained in:
Zeb Fross 2020-04-01 20:09:22 -07:00
parent ad0abe6b59
commit 8d0622cafa
6 changed files with 52 additions and 36 deletions

View File

@ -307,15 +307,23 @@ class StockApiController extends BaseApiController
} }
$default_location_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_location_id'); $default_location_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_location_id');
$default_qu_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_qu_id');
if (!$default_location_id) if (!$default_location_id)
{
$default_location_id = $this->getDatabase()->locations()->limit(1)->fetch()['id']; $default_location_id = $this->getDatabase()->locations()->limit(1)->fetch()['id'];
}
$default_qu_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_qu_id');
if (!$default_qu_id) if (!$default_qu_id)
{
$default_qu_id = $this->getDatabase()->quantity_units()->limit(1)->fetch()['id']; $default_qu_id = $this->getDatabase()->quantity_units()->limit(1)->fetch()['id'];
}
$shopping_location_id = null;
if (array_key_exists('shopping_location_id', $requestBody))
{
$shopping_location_id = $requestBody['shopping_location_id'];
}
$shopping_location_id = array_key_exists('shopping_location_id', $requestBody) ? $requestBody['shopping_location_id'] : null;
$parsedData = json_decode($requestBody['json-data'], true); $parsedData = json_decode($requestBody['json-data'], true);
$lastInsertId = $this->getStockService()->AddMultipleProducts($parsedData, $default_qu_id, $lastInsertId = $this->getStockService()->AddMultipleProducts($parsedData, $default_qu_id,

View File

@ -79,16 +79,24 @@ class StockController extends BaseController
$location_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_location_id'); $location_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_location_id');
$location = null; $location = null;
if ($location_id > 0) if ($location_id > 0)
{
$location = $this->getDatabase()->locations()->where('id', $location_id).fetch(); $location = $this->getDatabase()->locations()->where('id', $location_id).fetch();
}
else else
{
$location = $this->getDatabase()->locations()->limit(1)->fetch(); $location = $this->getDatabase()->locations()->limit(1)->fetch();
}
$qu_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_location_id'); $qu_id = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'product_presets_location_id');
$quantity_unit = null; $quantity_unit = null;
if ($qu_id > 0) if ($qu_id > 0)
{
$quantity_unit = $this->getDatabase()->quantity_units()->where('id', $qui_id).fetch(); $quantity_unit = $this->getDatabase()->quantity_units()->where('id', $qui_id).fetch();
}
else else
{
$quantity_unit = $this->getDatabase()->quantity_units()->limit(1)->fetch(); $quantity_unit = $this->getDatabase()->quantity_units()->limit(1)->fetch();
}
return $this->renderPage($response, 'uploadjson', [ return $this->renderPage($response, 'uploadjson', [
'location' => $location, 'location' => $location,

View File

@ -6,10 +6,10 @@ class KrogerToGrocyConverter
{ {
// Fields returned: 'name', 'location_id', 'qu_id_purchase', 'qu_id_stock', // Fields returned: 'name', 'location_id', 'qu_id_purchase', 'qu_id_stock',
// 'qu_factor_purchase_to_stock', 'barcode', 'default_best_before_days' // 'qu_factor_purchase_to_stock', 'barcode', 'default_best_before_days'
// 'quantity', 'transaction_date', 'price_paid', 'picture_url' // 'quantity', 'transaction_date', 'price_paid', 'picture_url', 'min_stock_amount'
public static function ConvertJson($data, $default_quantity_units, $default_location_id) public static function ConvertJson($data, $default_quantity_units, $default_location_id)
{ {
if (array_key_exists("data", $data)) if ($data != null && array_key_exists("data", $data))
{ {
$data = $data['data']; $data = $data['data'];
} }

View File

@ -1,4 +1,4 @@
{ {
"Version": "2.6.3", "Version": "2.6.2",
"ReleaseDate": "2020-03-29" "ReleaseDate": "2020-03-29"
} }

View File

@ -209,7 +209,7 @@
@if(GROCY_FEATURE_FLAG_UPLOAD_JSON) @if(GROCY_FEATURE_FLAG_UPLOAD_JSON)
<li class="nav-item nav-item-sidebar" data-toggle="tooltip" data-placement="right" title="{{ $__t('Upload json') }}" data-nav-for-page="upload-json"> <li class="nav-item nav-item-sidebar" data-toggle="tooltip" data-placement="right" title="{{ $__t('Upload json') }}" data-nav-for-page="upload-json">
<a class="nav-link discrete-link" href="{{ $U('/uploadjson') }}"> <a class="nav-link discrete-link" href="{{ $U('/uploadjson') }}">
<i class="fas fa-fire"></i> <i class="fas fa-code"></i>
<span class="nav-link-text">{{ $__t('Upload Json') }}</span> <span class="nav-link-text">{{ $__t('Upload Json') }}</span>
</a> </a>
</li> </li>