test.php
include("libraries/autoload.php");
use GroceryCrud\Core\GroceryCrud;
$cont_id=210;
$lng = isset($_GET["l"]) ? $_GET["l"] : "el";
$rel_items = 'items210el';
$rel_menus= 'menus'.$cont_id.$lng ;
$items_db = 'items'.$cont_id.$lng ;
$database = include('database.php');
$config = include('config.php');
$crud = new GroceryCrud($config, $database);
$crud->setTable($items_db);
$crud->setSubject('Γραμμής Menu','Menu');
$crud->setMasterDetail("https://scan4.menu/xon/aegean.php");
if ($lng=="el") {
$crud->columns(['last_update', 'language', 'title', 'description','extra_line', 'menu_id', 'placement', 'price', 'is_sub', 'isv']);
$crud->fields(['last_update', 'language', 'title', 'description','extra_line', 'menu_id', 'placement', 'price', 'is_sub', 'isv']);
$crud->requiredFields(['language', 'title', 'menu_id','placement']);
$crud->displayAs([
'last_update'=> 'Τελευταία Ενημέρωση',
'language'=> 'Γλώσσα',
'title'=> 'Τίτλος',
'description'=> 'Περιγραφή',
'isv'=> 'Ορατό;',
'is_sub'=> 'Υπότιτλος;',
'menu_id'=> 'Menu',
'placement' => 'Θέση',
'price' => 'Τιμή',
'extra_line' => 'Extra Γραμμή'
]);
//$crud->fieldType('isv', 'checkbox_boolean');
//$crud->fieldType('is_sub', 'checkbox_boolean');
// $crud->setFieldUpload('Link', '../img/menu', 'https://scan4.menu/img/menu');
$crud->setRelation('menu_id', $rel_menus, 'title');
$crud->defaultOrdering([
'menu_id' => 'ASC',
'placement' => 'ASC'
]);
} else {
$crud->columns(['last_update', 'language', 'title', 'description','original_item_id', 'menu_id']);
$crud->fields(['last_update', 'language', 'title', 'description','original_item_id', 'menu_id']);
$crud->requiredFields(['language', 'title','original_item_id', 'menu_id']);
$crud->displayAs([
'last_update'=> 'Τελευταία Ενημέρωση',
'language'=> 'Γλώσσα',
'title'=> 'Τίτλος',
'description'=> 'Περιγραφή',
'original_item_id' => 'Στη Βασική Γλώσσα',
'menu_id'=> 'Menu'
]);
$crud->setRelation('menu_id', $rel_menus, 'title');
$crud->setRelation('original_item_id', $rel_items, 'title');
/
$crud->defaultOrdering([
'menu_id' => 'ASC']);
}
/* $crud->callbackBeforeInsert(function ($stateParameters) use ($cont_id) {
$stateParameters->data['contact_id'] = $cont_id;
$stateParameters->data['last_update'] = date('Y-m-d');
return $stateParameters;
});
$crud->callbackBeforeUpdate(function ($stateParameters) use ($cont_id) {
$stateParameters->data['contact_id'] = $cont_id;
$stateParameters->data['last_update'] = date('Y-m-d');
return $stateParameters;
});
*/
$crud->setClone();
$output = $crud->render();
if ($output->isJSONResponse) {
header('Content-Type: application/json; charset=utf-8');
echo $output->output;
exit;
}
$css_files = $output->css_files;
$js_files = $output->js_files;
$output = $output->output;
include('view.php');
view.php
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
</head>
<body>
<div style="padding: 20px 10px;">
<?php echo $output; ?>
</div>
<?php foreach($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
</body>
</html>
aegean.php
include("libraries/autoload.php");
use GroceryCrud\Core\GroceryCrud;
$database = include('database.php');
$config = include('config.php');
$c = new GroceryCrud($config, $database);
$c->setLanguage('English');
$c->setTable('items210en');
$c->unsetDatagridTitle();
$c->unsetTools();
$c->unsetOperations();
$c->unsetSearchColumns(['last_update', 'language', 'title', 'description', 'original_item_id',
'extra_line','menu_id', 'contact_id']);
if (!empty($_POST['id'])) {
$c->where(['original_item_id' => $_POST['id']]);
} else {
throw new InvalidArgumentException("Invalid argument for the field 'master_id'");
}
}
$output = $c->render();
?>
first of all if i do not use $c->setLanguage(‘English’)
i get a missconfiguration message
if i do the message is
We can’t process the response of the server. Not well JSON formatted response.
In any case i see that no javascript files echoed
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div style="padding: 20px 10px;">
<script>
window.GroceryCrudConfiguration = window.GroceryCrudConfiguration || {};
Object.assign(window.GroceryCrudConfiguration, {
assetsUrl: 'assets/vendor/grocery-crud/',
autoLoad: true,
});
setTimeout(() => {
// Search for class name ".gc-hidden-message"
const gcHiddenMessage = document.querySelector('.gc-hidden-message');
const gcGifLoader = document.querySelector('.gc-gif-loader');
if (gcHiddenMessage) {
gcHiddenMessage.style.display = 'block';
}
if (gcGifLoader) {
gcGifLoader.remove();
}
}, 3000);
</script>
<div class="grocery-crud" data-api-url="/xon/test.php" data-landing-page-url="/xon/test.php" data-theme="bootstrap-v5"data-unique-id="c74984b74f5c0e38ad3d7ea013335349" data-publish-events="true">
<div style="padding: 10px; border: 1px solid #aaa; border-radius: 10px;margin-bottom: 20px;display: none;" class="gc-hidden-message">
Ooooops, something went wrong! If you can see this message, this is probably a misconfiguration in Grocery CRUD Enterprise!
</div>
<div class="gc-gif-loader" style="width: 16px; height: 16px; background-repeat: no-repeat; background-image:
....
.......
</div>
</div>
<script src="assets/vendor/grocery-crud/static/js/bundle.v3.0.3.71331119.js"></script>
<script src="assets/vendor/grocery-crud/static/js/93.503d461b.chunk.js"></script>
<script src="assets/vendor/grocery-crud/static/js/main.29095ca1.chunk.js"></script>
</body>
</html>
i have tried for hours but can not find what is wrong with the code
it works fine in all previous versions and strange enough it works in the newest version too - besides when i click the arrow to load the second table