-
+
\ No newline at end of file
diff --git a/web/bin/tests/bootstrap.php b/web/bin/tests/bootstrap.php
index bfff0a5..81840a5 100644
--- a/web/bin/tests/bootstrap.php
+++ b/web/bin/tests/bootstrap.php
@@ -1,23 +1,23 @@
- 1, 'sku' => 'TEST-001', 'name' => 'Fixture Product A', 'price' => 9.99, 'status' => 'active', 'nameproducts' => 'Prod A'],
- ['idproducts' => 2, 'sku' => 'TEST-002', 'name' => 'Fixture Product B', 'price' => 19.99, 'status' => 'active', 'nameproducts' => 'Prod B'],
- ['idproducts' => 3, 'sku' => 'TEST-003', 'name' => 'Fixture Product C', 'price' => 29.99, 'status' => 'inactive', 'nameproducts' => 'Prod C'],
- ];
-
- $dbs = [$dbName];
- if (!empty($prefix)) {
- $dbs[] = $prefix . $dbName;
- }
-
- $total = 0;
- foreach ($dbs as $db) {
- $collection = $client->{$db}->products;
- foreach ($docs as $doc) {
- $collection->updateOne(['sku' => $doc['sku']], ['$set' => $doc], ['upsert' => true]);
- }
- $count = $collection->countDocuments(['sku' => ['$in' => array_column($docs, 'sku')]]);
- echo "Inserted/updated $count fixture documents into $db.products\n";
- $total += $count;
- }
-
- echo "Total fixtures processed: $total\n";
- exit(0);
-
-} catch (\Exception $e) {
- fwrite(STDERR, "Fixture loader failed: " . $e->getMessage() . "\n");
- exit(2);
-}
+ 1, 'sku' => 'TEST-001', 'name' => 'Fixture Product A', 'price' => 9.99, 'status' => 'active', 'nameproducts' => 'Prod A'],
+ ['idproducts' => 2, 'sku' => 'TEST-002', 'name' => 'Fixture Product B', 'price' => 19.99, 'status' => 'active', 'nameproducts' => 'Prod B'],
+ ['idproducts' => 3, 'sku' => 'TEST-003', 'name' => 'Fixture Product C', 'price' => 29.99, 'status' => 'inactive', 'nameproducts' => 'Prod C'],
+ ];
+
+ $dbs = [$dbName];
+ if (!empty($prefix)) {
+ $dbs[] = $prefix . $dbName;
+ }
+
+ $total = 0;
+ foreach ($dbs as $db) {
+ $collection = $client->{$db}->products;
+ foreach ($docs as $doc) {
+ $collection->updateOne(['sku' => $doc['sku']], ['$set' => $doc], ['upsert' => true]);
+ }
+ $count = $collection->countDocuments(['sku' => ['$in' => array_column($docs, 'sku')]]);
+ echo "Inserted/updated $count fixture documents into $db.products\n";
+ $total += $count;
+ }
+
+ echo "Total fixtures processed: $total\n";
+ exit(0);
+
+} catch (\Exception $e) {
+ fwrite(STDERR, "Fixture loader failed: " . $e->getMessage() . "\n");
+ exit(2);
+}
diff --git a/web/bin/tests/fixtures/tmp_test_mongo.php b/web/bin/tests/fixtures/tmp_test_mongo.php
index 44e3244..5f0746f 100644
--- a/web/bin/tests/fixtures/tmp_test_mongo.php
+++ b/web/bin/tests/fixtures/tmp_test_mongo.php
@@ -1,18 +1,18 @@
-selectDatabase('maw_idae_test')->selectCollection('products');
- $doc = $col->findOne(['sku' => 'TEST-001']);
- if ($doc) {
- echo "Found: " . json_encode((array)$doc) . "\n";
- } else {
- echo "No document found\n";
- }
-} catch (Exception $e) {
- echo 'ERROR: ' . $e->getMessage() . "\n";
-}
+selectDatabase('maw_idae_test')->selectCollection('products');
+ $doc = $col->findOne(['sku' => 'TEST-001']);
+ if ($doc) {
+ echo "Found: " . json_encode((array)$doc) . "\n";
+ } else {
+ echo "No document found\n";
+ }
+} catch (Exception $e) {
+ echo 'ERROR: ' . $e->getMessage() . "\n";
+}
diff --git a/web/bin/tests/integration/IdaeQueryIntegrationTest.php b/web/bin/tests/integration/IdaeQueryIntegrationTest.php
index f3acd62..8e1e6a7 100644
--- a/web/bin/tests/integration/IdaeQueryIntegrationTest.php
+++ b/web/bin/tests/integration/IdaeQueryIntegrationTest.php
@@ -1,98 +1,98 @@
-markTestSkipped('MongoDB client or DB constants not available');
- }
-
- // Try no-auth connection first (local dev override uses no-auth mongo)
- $testUser = 'idae_test_user';
- $testPwd = 'idae_test_pwd';
- $testDb = (defined('MDB_PREFIX') ? MDB_PREFIX : '') . 'idae_test';
-
- $client = null;
-
- // Prefer configured MDB_USER (if present) so authenticated reads succeed.
- if (defined('MDB_USER') && defined('MDB_PASSWORD')) {
- try {
- $uri = 'mongodb://' . MDB_USER . ':' . MDB_PASSWORD . '@' . MDB_HOST . '/admin';
- $client = new Client($uri);
- } catch (\Exception $e) {
- $client = null;
- }
- }
-
- // Next try test user created by init script
- if (is_null($client)) {
- try {
- $uri = 'mongodb://' . $testUser . ':' . $testPwd . '@' . MDB_HOST . '/' . $testDb . '?authSource=' . $testDb;
- $client = new Client($uri);
- } catch (\Exception $e) {
- $client = null;
- }
- }
-
- // Finally try no-auth connection (useful for local no-auth Mongo)
- if (is_null($client)) {
- try {
- $uri = 'mongodb://' . MDB_HOST;
- $client = new Client($uri);
- } catch (\Exception $e) {
- $client = null;
- }
- }
-
- if (is_null($client)) {
- $this->markTestSkipped('Cannot establish a MongoDB client connection for tests');
- }
-
- $dbName = $testDb;
- $collection = $client->selectDatabase($dbName)->selectCollection('products');
-
- // Attempt to read an existing fixture inserted by the init script (no writes)
- try {
- $res = $collection->findOne(['idproducts' => 1]);
- } catch (\Exception $e) {
- $this->markTestSkipped('MongoDB read failed: ' . $e->getMessage());
- }
-
- if (empty($res)) {
- $this->markTestSkipped('No fixture documents found in products collection');
- }
-
- // Minimal appscheme_model_instance stub
- $appscheme_model_instance = new class {
- public function findOne($q) {
- return ['codeAppscheme_base' => (defined('MDB_PREFIX')?MDB_PREFIX:'') . 'idae_test', 'codeAppscheme' => 'products'];
- }
- };
-
- // Test connect wrapper that exposes plug() and appscheme_model_instance
- $testConnect = new class($client, $appscheme_model_instance) {
- public $appscheme_model_instance;
- private $client;
- public function __construct($client, $appscheme_model_instance) {
- $this->client = $client;
- $this->appscheme_model_instance = $appscheme_model_instance;
- }
- public function plug($base, $table) {
- return $this->client->selectDatabase($base)->selectCollection($table);
- }
- };
-
- // Inject our test connect into IdaeQuery
- $query = new IdaeQuery('products', $testConnect);
-
- $res = $query->findOne(['idproducts' => 1]);
- $resArr = is_array($res) ? $res : (array)$res;
-
- $this->assertIsArray($resArr);
- $this->assertEquals('Prod A', $resArr['nameproducts']);
- }
-}
+markTestSkipped('MongoDB client or DB constants not available');
+ }
+
+ // Try no-auth connection first (local dev override uses no-auth mongo)
+ $testUser = 'idae_test_user';
+ $testPwd = 'idae_test_pwd';
+ $testDb = (defined('MDB_PREFIX') ? MDB_PREFIX : '') . 'idae_test';
+
+ $client = null;
+
+ // Prefer configured MDB_USER (if present) so authenticated reads succeed.
+ if (defined('MDB_USER') && defined('MDB_PASSWORD')) {
+ try {
+ $uri = 'mongodb://' . MDB_USER . ':' . MDB_PASSWORD . '@' . MDB_HOST . '/admin';
+ $client = new Client($uri);
+ } catch (\Exception $e) {
+ $client = null;
+ }
+ }
+
+ // Next try test user created by init script
+ if (is_null($client)) {
+ try {
+ $uri = 'mongodb://' . $testUser . ':' . $testPwd . '@' . MDB_HOST . '/' . $testDb . '?authSource=' . $testDb;
+ $client = new Client($uri);
+ } catch (\Exception $e) {
+ $client = null;
+ }
+ }
+
+ // Finally try no-auth connection (useful for local no-auth Mongo)
+ if (is_null($client)) {
+ try {
+ $uri = 'mongodb://' . MDB_HOST;
+ $client = new Client($uri);
+ } catch (\Exception $e) {
+ $client = null;
+ }
+ }
+
+ if (is_null($client)) {
+ $this->markTestSkipped('Cannot establish a MongoDB client connection for tests');
+ }
+
+ $dbName = $testDb;
+ $collection = $client->selectDatabase($dbName)->selectCollection('products');
+
+ // Attempt to read an existing fixture inserted by the init script (no writes)
+ try {
+ $res = $collection->findOne(['idproducts' => 1]);
+ } catch (\Exception $e) {
+ $this->markTestSkipped('MongoDB read failed: ' . $e->getMessage());
+ }
+
+ if (empty($res)) {
+ $this->markTestSkipped('No fixture documents found in products collection');
+ }
+
+ // Minimal appscheme_model_instance stub
+ $appscheme_model_instance = new class {
+ public function findOne($q) {
+ return ['codeAppscheme_base' => (defined('MDB_PREFIX')?MDB_PREFIX:'') . 'idae_test', 'codeAppscheme' => 'products'];
+ }
+ };
+
+ // Test connect wrapper that exposes plug() and appscheme_model_instance
+ $testConnect = new class($client, $appscheme_model_instance) {
+ public $appscheme_model_instance;
+ private $client;
+ public function __construct($client, $appscheme_model_instance) {
+ $this->client = $client;
+ $this->appscheme_model_instance = $appscheme_model_instance;
+ }
+ public function plug($base, $table) {
+ return $this->client->selectDatabase($base)->selectCollection($table);
+ }
+ };
+
+ // Inject our test connect into IdaeQuery
+ $query = new IdaeQuery('products', $testConnect);
+
+ $res = $query->findOne(['idproducts' => 1]);
+ $resArr = is_array($res) ? $res : (array)$res;
+
+ $this->assertIsArray($resArr);
+ $this->assertEquals('Prod A', $resArr['nameproducts']);
+ }
+}
diff --git a/web/bin/tests/unit/IdaeApiParserTest.php b/web/bin/tests/unit/IdaeApiParserTest.php
index 396da1f..0512587 100644
--- a/web/bin/tests/unit/IdaeApiParserTest.php
+++ b/web/bin/tests/unit/IdaeApiParserTest.php
@@ -1,24 +1,24 @@
-setRequestUri('/products/find/limit:10/page:2');
- $parser->setQyCodeType('php');
-
- $result = $parser->parse();
-
- $this->assertIsArray($result);
- $this->assertArrayHasKey('scheme', $result);
- $this->assertEquals('products', $result['scheme']);
- $this->assertArrayHasKey('where', $result);
- $this->assertArrayHasKey('limit', $result);
- $this->assertEquals('10', $result['limit']);
- $this->assertArrayHasKey('page', $result);
- $this->assertEquals('2', $result['page']);
- }
-}
+setRequestUri('/products/find/limit:10/page:2');
+ $parser->setQyCodeType('php');
+
+ $result = $parser->parse();
+
+ $this->assertIsArray($result);
+ $this->assertArrayHasKey('scheme', $result);
+ $this->assertEquals('products', $result['scheme']);
+ $this->assertArrayHasKey('where', $result);
+ $this->assertArrayHasKey('limit', $result);
+ $this->assertEquals('10', $result['limit']);
+ $this->assertArrayHasKey('page', $result);
+ $this->assertEquals('2', $result['page']);
+ }
+}
diff --git a/web/bin/tests/unit/IdaeQueryUnitTest.php b/web/bin/tests/unit/IdaeQueryUnitTest.php
index 770dbfd..9adcaf2 100644
--- a/web/bin/tests/unit/IdaeQueryUnitTest.php
+++ b/web/bin/tests/unit/IdaeQueryUnitTest.php
@@ -1,52 +1,52 @@
- 1, 'nameproducts' => 'Sample A'],
- ]);
- }
- public function findOne($query = [], $opts = []) {
- return ['idproducts'=>1,'nameproducts'=>'Sample A'];
- }
- };
-
- // fake appscheme_model_instance used by constructor init
- $appscheme_model_instance = new class($fakeColl) {
- private $coll;
- public function __construct($coll) { $this->coll = $coll; }
- public function findOne($q) {
- // return minimal scheme info so IdaeQuery can set collection name
- return ['codeAppscheme' => 'products', 'codeAppscheme_base' => 'testdb'];
- }
- };
-
- // fake connect object
- $fakeConnect = new class($appscheme_model_instance, $fakeColl) {
- public $appscheme_model_instance;
- private $coll;
- public function __construct($asi, $coll) {
- $this->appscheme_model_instance = $asi;
- $this->coll = $coll;
- }
- public function plug($base, $table) {
- // always return our fake collection regardless of args
- return $this->coll;
- }
- };
-
- $query = new IdaeQuery('products', $fakeConnect);
- $result = $query->find(['idproducts' => 1]);
-
- $this->assertIsArray($result);
- $this->assertCount(1, $result);
- $this->assertEquals('Sample A', $result[0]['nameproducts']);
- }
-}
+ 1, 'nameproducts' => 'Sample A'],
+ ]);
+ }
+ public function findOne($query = [], $opts = []) {
+ return ['idproducts'=>1,'nameproducts'=>'Sample A'];
+ }
+ };
+
+ // fake appscheme_model_instance used by constructor init
+ $appscheme_model_instance = new class($fakeColl) {
+ private $coll;
+ public function __construct($coll) { $this->coll = $coll; }
+ public function findOne($q) {
+ // return minimal scheme info so IdaeQuery can set collection name
+ return ['codeAppscheme' => 'products', 'codeAppscheme_base' => 'testdb'];
+ }
+ };
+
+ // fake connect object
+ $fakeConnect = new class($appscheme_model_instance, $fakeColl) {
+ public $appscheme_model_instance;
+ private $coll;
+ public function __construct($asi, $coll) {
+ $this->appscheme_model_instance = $asi;
+ $this->coll = $coll;
+ }
+ public function plug($base, $table) {
+ // always return our fake collection regardless of args
+ return $this->coll;
+ }
+ };
+
+ $query = new IdaeQuery('products', $fakeConnect);
+ $result = $query->find(['idproducts' => 1]);
+
+ $this->assertIsArray($result);
+ $this->assertCount(1, $result);
+ $this->assertEquals('Sample A', $result[0]['nameproducts']);
+ }
+}
diff --git a/web/bin/tests/unit/ProductsApiTest.php b/web/bin/tests/unit/ProductsApiTest.php
index 4affa4a..826c445 100644
--- a/web/bin/tests/unit/ProductsApiTest.php
+++ b/web/bin/tests/unit/ProductsApiTest.php
@@ -26,4 +26,4 @@ public function test_idql_products_returns_sample_when_db_unavailable()
$this->assertIsString($out);
$this->assertStringContainsString('"rs"', $out);
}
-}
+}
diff --git a/web/bin/tests/unit/RestApiTest.php b/web/bin/tests/unit/RestApiTest.php
index c83162e..d22e538 100644
--- a/web/bin/tests/unit/RestApiTest.php
+++ b/web/bin/tests/unit/RestApiTest.php
@@ -1,20 +1,20 @@
-assertIsString($out);
$this->assertStringContainsString('"rs"', $out);
}
-
- public function test_rest_post_products_returns_sample_when_db_unavailable()
- {
- $_SERVER['REQUEST_METHOD'] = 'POST';
- // include parsing tokens in URI again
- $_SERVER['REQUEST_URI'] = '/api/products/method:find/limit:1';
-
- $api = new Idae\Api\IdaeApiRest([]);
- ob_start();
- $api->doRest();
- $out = ob_get_clean();
-
- $this->assertIsString($out);
- $this->assertStringContainsString('"rs"', $out);
- }
-}
+
+ public function test_rest_post_products_returns_sample_when_db_unavailable()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ // include parsing tokens in URI again
+ $_SERVER['REQUEST_URI'] = '/api/products/method:find/limit:1';
+
+ $api = new Idae\Api\IdaeApiRest([]);
+ ob_start();
+ $api->doRest();
+ $out = ob_get_clean();
+
+ $this->assertIsString($out);
+ $this->assertStringContainsString('"rs"', $out);
+ }
+}
diff --git a/web/bin/tests/unit/ValidateQueryTest.php b/web/bin/tests/unit/ValidateQueryTest.php
new file mode 100644
index 0000000..bd0bffb
--- /dev/null
+++ b/web/bin/tests/unit/ValidateQueryTest.php
@@ -0,0 +1,85 @@
+doIdql(['limit' => 1]);
+ $out = ob_get_clean();
+
+ $this->assertIsString($out);
+ $decoded = json_decode($out, true);
+ $this->assertIsArray($decoded);
+ $this->assertArrayHasKey('status', $decoded);
+ $this->assertFalse($decoded['status']);
+ $this->assertStringContainsString('Missing scheme', $decoded['message'] ?? '');
+ $this->assertEquals(422, http_response_code());
+ }
+
+ public function test_invalid_limit_returns_422()
+ {
+ $api = new Idae\Api\IdaeApiRest([]);
+
+ ob_start();
+ // invalid limit value (non-numeric)
+ $api->doIdql(['scheme' => 'products', 'limit' => 'not-a-number']);
+ $out = ob_get_clean();
+
+ $this->assertIsString($out);
+ $decoded = json_decode($out, true);
+ $this->assertIsArray($decoded);
+ $this->assertArrayHasKey('status', $decoded);
+ $this->assertFalse($decoded['status']);
+ $this->assertStringContainsString('Invalid parameter: limit must be numeric', $decoded['message'] ?? '');
+ $this->assertEquals(422, http_response_code());
+ }
+
+ public function test_invalid_where_returns_422()
+ {
+ $api = new Idae\Api\IdaeApiRest([]);
+
+ ob_start();
+ // where must be an array/object
+ $api->doIdql(['scheme' => 'products', 'where' => 'not-an-array']);
+ $out = ob_get_clean();
+
+ $this->assertIsString($out);
+ $decoded = json_decode($out, true);
+ $this->assertIsArray($decoded);
+ $this->assertArrayHasKey('status', $decoded);
+ $this->assertFalse($decoded['status']);
+ $this->assertStringContainsString('Invalid parameter: where must be an object', $decoded['message'] ?? '');
+ $this->assertEquals(422, http_response_code());
+ }
+
+ public function test_invalid_method_returns_422()
+ {
+ $api = new Idae\Api\IdaeApiRest([]);
+
+ ob_start();
+ // invalid method should be rejected
+ $api->doIdql(['scheme' => 'products', 'method' => 'not_a_real_method']);
+ $out = ob_get_clean();
+
+ $this->assertIsString($out);
+ $decoded = json_decode($out, true);
+ $this->assertIsArray($decoded);
+ $this->assertArrayHasKey('status', $decoded);
+ $this->assertFalse($decoded['status']);
+ $this->assertStringContainsString('Invalid parameter: method', $decoded['message'] ?? '');
+ $this->assertEquals(422, http_response_code());
+ }
+}
diff --git a/web/bin/tmp_check.php b/web/bin/tmp_check.php
new file mode 100644
index 0000000..1dd088a
--- /dev/null
+++ b/web/bin/tmp_check.php
@@ -0,0 +1,10 @@
+appscheme_nameid;
- $name_table = $this->appscheme_code;
- $Name_table = ucfirst($name_table);
- $GRILLE_FK = $this->get_grille_fk();
-
- $col = $this->plug($this->app_table_one['codeAppscheme_base'], $this->app_table_one['codeAppscheme']);
- $arr_vars = (empty($table_value)) ? [] : [$name_id => $table_value];
- $rs = $this->find($arr_vars);
- //
- while ($arr = $rs->getNext()):
- $arr_new = [];
- $value_id = (int)$arr[$name_id];
- // DATES debut et fin => t(ime)
- foreach ([null,
- 'Creation',
- 'Debut',
- 'Fin'] as $k => $TYPE_DATE) {
- $suffix_field = $TYPE_DATE . $Name_table;
- $to_time = strtotime($arr['date' . $suffix_field]);
- if (!empty($arr['date' . $suffix_field])):
- if (($arr['time' . $suffix_field]) != $to_time) {
- $arr_new['time' . $suffix_field] = $to_time;
- $arr_new['isoDate' . $suffix_field] = new MongoDate($to_time);
- }
- endif;
- }
- //
-
- if (!empty($arr['color' . $Name_table]) && empty($arr['bgcolor' . $Name_table]) && $arr['color' . $Name_table] != $arr['bgcolor' . $Name_table]):
-
- endif;
-
- if ($this->has_field('slug')) {
- if (empty($arr['slug' . $Name_table]) && !empty($arr['nom' . $Name_table])) {
- $arr_new['slug' . $Name_table] = format_uri($arr['nom' . $Name_table]);
- }
- }
- // FKS : prendre nom et code => appscheme_has_table_field
-
- foreach ($GRILLE_FK as $field):
- $id_fk = $field['idtable_fk'];
- if (empty($arr[$id_fk])) continue;
- $arr_lnk = $this->appscheme_model_instance->findOne(['codeAppscheme' => $field['table_fk']]);
- $rs_fields = $this->appscheme_has_field_model_instance->find(['idappscheme' => $this->idappscheme,
- 'idappscheme_link' => (int)$arr_lnk['idappscheme']]);
-
-
- $arrq = $this->plug($field['base_fk'], $field['table_fk'])->findOne([$id_fk => (int)$arr[$id_fk]]);
- if (empty($arrq)) continue;
- foreach ($rs_fields as $arr_fields) {
- if ($arr[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])] == $arrq[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])]) continue;
- $arr_new[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])] = $arrq[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])];
- }
- //
- foreach ($this->app_default_fields_add as $pfield_name) {
- $full_field_name = $pfield_name . ucfirst($field['table_fk']);
- if (array_key_exists($full_field_name, $arrq)) {
- if ($arr[$full_field_name] !== $arrq[$full_field_name]) {
- $arr_new[$full_field_name] = $arrq[$full_field_name];
- }
- }
- }
-
- endforeach;
-
- // TYPE STATUT
- $arr_has = ['statut',
- 'type',
- 'categorie',
- 'groupe','group'];
- foreach ($arr_has as $key => $statut_type):
- $Statut_type = ucfirst($statut_type);
- $name_table_type = $name_table . '_' . $statut_type;
- $Name_table_type = ucfirst($name_table_type);
- $name_table_type_id = 'id' . $name_table_type;
- $_nom = 'nom' . $name_table_type;
- //
- if (!empty($this->app_table_one['has' . $Statut_type . 'Scheme']) && !empty($arr[$name_table_type_id])):
- $APP_TYPE = new App($name_table_type);
- $arr_tmp = $APP_TYPE->findOne([$name_table_type_id => (int)$arr[$name_table_type_id]]);
-
- foreach ($this->app_default_fields_add as $pfield_name) {
- if (array_key_exists($pfield_name . $Name_table_type, $arr_tmp)) {
- if ($arr_tmp[$pfield_name . $Name_table_type] !== $arr[$pfield_name . $Name_table_type]) {
- $arr_new[$pfield_name . $Name_table_type] = $arr_tmp[$pfield_name . $Name_table_type];
- }
- }
- }
-
- endif;
-
- endforeach;
-
- if ($name_table == 'contrat'):
- if (!empty($arr['idclient'])):
- $APP_TMP = new App('client');
- $rs_test = $col->find(['idclient' => (int)$arr['idclient']])->sort(['dateFinContrat' => 1]);
- $arr_test = $rs_test->getNext();
- $arr_cl = $APP_TMP->findOne(['idclient' => (int)$arr['idclient']]);
-
- if ($arr_cl['dateFinClient'] != $arr_test['dateFinContrat']) $APP_TMP->update(['idclient' => (int)$arr['idclient']], ['dateFinClient' => $arr_test['dateFinContrat']]);
- endif;
- endif;
- if ($name_table == 'conge'):
- $new_value = $arr['nomAgent'] . ' ' . strtolower($arr['codeConge_type']) . ' ' . fonctionsProduction::moisDate_fr($arr['dateDebutConge']);
- if ($arr['nom' . $Name_table] != $new_value) {
- $arr_new['nom' . $Name_table] = $new_value;
- }
- endif;
- if ($name_table == 'ressource'):
- $new_value = $arr['quantite' . $Name_table] . ' * ' . $arr['nomProduit'] . ' - ' . $arr['nomProspect'] . $arr['nomClient'];
- if ($arr['nom' . $Name_table] != $new_value) {
- $arr_new['nom' . $Name_table] = $new_value;
- };
- endif;
- if ($name_table == 'opportunite_ligne'):
- $new_value = $arr['quantite' . $Name_table] . ' * ' . $arr['nomProduit'];
- if ($arr['nom' . $Name_table] != $new_value) {
- $arr_new['nom' . $Name_table] = $new_value;
- };
- endif;
-
- if ($name_table == 'commande'):
- $new_value = date('dmy') . auto_code($arr['codeClient']) . auto_code($arr['codeShop']);
- if ($arr['code' . $Name_table] != $new_value) {
- // $arr_new['code' . $Name_table] = $new_value;
- };
- endif;
-
- if (empty($arr['code' . $Name_table]) && empty($arr_new['code' . $Name_table])):
- $arr_new['code' . $Name_table] = auto_code($arr['nom' . $Name_table]);
- endif;
- if (empty($arr['nom' . $Name_table]) && empty($arr_new['nom' . $Name_table])):
- foreach ($GRILLE_FK as $field):
- $id_fk = $field['idtable_fk'];
- if (empty($arr[$id_fk])) continue;
- //
- $dsp_name = $arr['nom' . ucfirst($field['table_fk'])];
- //
- $arr_new['nom' . $Name_table] .= strtolower($dsp_name) . ' ';
- endforeach;
- endif;
- if (empty($arr['nom' . $Name_table]) && empty($arr_new['nom' . $Name_table])):
- if (!empty($APP_TABLE['hasTypeScheme'])):
- // $arr_new['nom' . $Name_table] = $arr['nom' . $Name_table.'_type'];
- endif;
- // $arr_new['nom' . $Name_table] .= substr(strip_tags($arr['code' . $Name_table]),0,5) ;
- if (!empty($APP_TABLE['hasDateScheme']) && !empty($arr['dateDebut' . $Name_table])):
- $arr_new['nom' . $Name_table] .= ' ' . date_fr($arr['dateDebut' . $Name_table]);
- endif;
- // $arr_new['nom' . $Name_table] .= substr(strip_tags($arr['description' . $Name_table]),0,10);
- endif;
- if (sizeof($arr_new) != 0) {
- $arr_new ['updated_fields'] = $arr_new; // log ???
- // versioning
- $arr_new['dateModification' . $Name_table] = date('Y-m-d');
- $arr_new['heureModification' . $Name_table] = date('H:i:s');
- $arr_new['timeModification' . $Name_table] = time();
-
- $col->update([$name_id => $value_id], ['$set' => $arr_new], ['upsert' => true]);
- }
- if ($rs->count() == 1) {
- return $arr_new;
- }
-
- endwhile;
- }
- }
+appscheme_nameid;
+ $name_table = $this->appscheme_code;
+ $Name_table = ucfirst($name_table);
+ $GRILLE_FK = $this->get_grille_fk();
+
+ $col = $this->plug($this->app_table_one['codeAppscheme_base'], $this->app_table_one['codeAppscheme']);
+ $arr_vars = (empty($table_value)) ? [] : [$name_id => $table_value];
+ $rs = $this->find($arr_vars);
+ //
+ while ($arr = $rs->getNext()):
+ $arr_new = [];
+ $value_id = (int)$arr[$name_id];
+ // DATES debut et fin => t(ime)
+ foreach ([null,
+ 'Creation',
+ 'Debut',
+ 'Fin'] as $k => $TYPE_DATE) {
+ $suffix_field = $TYPE_DATE . $Name_table;
+ $to_time = strtotime($arr['date' . $suffix_field]);
+ if (!empty($arr['date' . $suffix_field])):
+ if (($arr['time' . $suffix_field]) != $to_time) {
+ $arr_new['time' . $suffix_field] = $to_time;
+ $arr_new['isoDate' . $suffix_field] = new MongoDate($to_time);
+ }
+ endif;
+ }
+ //
+
+ if (!empty($arr['color' . $Name_table]) && empty($arr['bgcolor' . $Name_table]) && $arr['color' . $Name_table] != $arr['bgcolor' . $Name_table]):
+
+ endif;
+
+ if ($this->has_field('slug')) {
+ if (empty($arr['slug' . $Name_table]) && !empty($arr['nom' . $Name_table])) {
+ $arr_new['slug' . $Name_table] = format_uri($arr['nom' . $Name_table]);
+ }
+ }
+ // FKS : prendre nom et code => appscheme_has_table_field
+
+ foreach ($GRILLE_FK as $field):
+ $id_fk = $field['idtable_fk'];
+ if (empty($arr[$id_fk])) continue;
+ $arr_lnk = $this->appscheme_model_instance->findOne(['codeAppscheme' => $field['table_fk']]);
+ $rs_fields = $this->appscheme_has_field_model_instance->find(['idappscheme' => $this->idappscheme,
+ 'idappscheme_link' => (int)$arr_lnk['idappscheme']]);
+
+
+ $arrq = $this->plug($field['base_fk'], $field['table_fk'])->findOne([$id_fk => (int)$arr[$id_fk]]);
+ if (empty($arrq)) continue;
+ foreach ($rs_fields as $arr_fields) {
+ if ($arr[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])] == $arrq[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])]) continue;
+ $arr_new[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])] = $arrq[$arr_fields['codeAppscheme_field'] . ucfirst($field['table_fk'])];
+ }
+ //
+ foreach ($this->app_default_fields_add as $pfield_name) {
+ $full_field_name = $pfield_name . ucfirst($field['table_fk']);
+ if (array_key_exists($full_field_name, $arrq)) {
+ if ($arr[$full_field_name] !== $arrq[$full_field_name]) {
+ $arr_new[$full_field_name] = $arrq[$full_field_name];
+ }
+ }
+ }
+
+ endforeach;
+
+ // TYPE STATUT
+ $arr_has = ['statut',
+ 'type',
+ 'categorie',
+ 'groupe','group'];
+ foreach ($arr_has as $key => $statut_type):
+ $Statut_type = ucfirst($statut_type);
+ $name_table_type = $name_table . '_' . $statut_type;
+ $Name_table_type = ucfirst($name_table_type);
+ $name_table_type_id = 'id' . $name_table_type;
+ $_nom = 'nom' . $name_table_type;
+ //
+ if (!empty($this->app_table_one['has' . $Statut_type . 'Scheme']) && !empty($arr[$name_table_type_id])):
+ $APP_TYPE = new App($name_table_type);
+ $arr_tmp = $APP_TYPE->findOne([$name_table_type_id => (int)$arr[$name_table_type_id]]);
+
+ foreach ($this->app_default_fields_add as $pfield_name) {
+ if (array_key_exists($pfield_name . $Name_table_type, $arr_tmp)) {
+ if ($arr_tmp[$pfield_name . $Name_table_type] !== $arr[$pfield_name . $Name_table_type]) {
+ $arr_new[$pfield_name . $Name_table_type] = $arr_tmp[$pfield_name . $Name_table_type];
+ }
+ }
+ }
+
+ endif;
+
+ endforeach;
+
+ if ($name_table == 'contrat'):
+ if (!empty($arr['idclient'])):
+ $APP_TMP = new App('client');
+ $rs_test = $col->find(['idclient' => (int)$arr['idclient']])->sort(['dateFinContrat' => 1]);
+ $arr_test = $rs_test->getNext();
+ $arr_cl = $APP_TMP->findOne(['idclient' => (int)$arr['idclient']]);
+
+ if ($arr_cl['dateFinClient'] != $arr_test['dateFinContrat']) $APP_TMP->update(['idclient' => (int)$arr['idclient']], ['dateFinClient' => $arr_test['dateFinContrat']]);
+ endif;
+ endif;
+ if ($name_table == 'conge'):
+ $new_value = $arr['nomAgent'] . ' ' . strtolower($arr['codeConge_type']) . ' ' . fonctionsProduction::moisDate_fr($arr['dateDebutConge']);
+ if ($arr['nom' . $Name_table] != $new_value) {
+ $arr_new['nom' . $Name_table] = $new_value;
+ }
+ endif;
+ if ($name_table == 'ressource'):
+ $new_value = $arr['quantite' . $Name_table] . ' * ' . $arr['nomProduit'] . ' - ' . $arr['nomProspect'] . $arr['nomClient'];
+ if ($arr['nom' . $Name_table] != $new_value) {
+ $arr_new['nom' . $Name_table] = $new_value;
+ };
+ endif;
+ if ($name_table == 'opportunite_ligne'):
+ $new_value = $arr['quantite' . $Name_table] . ' * ' . $arr['nomProduit'];
+ if ($arr['nom' . $Name_table] != $new_value) {
+ $arr_new['nom' . $Name_table] = $new_value;
+ };
+ endif;
+
+ if ($name_table == 'commande'):
+ $new_value = date('dmy') . auto_code($arr['codeClient']) . auto_code($arr['codeShop']);
+ if ($arr['code' . $Name_table] != $new_value) {
+ // $arr_new['code' . $Name_table] = $new_value;
+ };
+ endif;
+
+ if (empty($arr['code' . $Name_table]) && empty($arr_new['code' . $Name_table])):
+ $arr_new['code' . $Name_table] = auto_code($arr['nom' . $Name_table]);
+ endif;
+ if (empty($arr['nom' . $Name_table]) && empty($arr_new['nom' . $Name_table])):
+ foreach ($GRILLE_FK as $field):
+ $id_fk = $field['idtable_fk'];
+ if (empty($arr[$id_fk])) continue;
+ //
+ $dsp_name = $arr['nom' . ucfirst($field['table_fk'])];
+ //
+ $arr_new['nom' . $Name_table] .= strtolower($dsp_name) . ' ';
+ endforeach;
+ endif;
+ if (empty($arr['nom' . $Name_table]) && empty($arr_new['nom' . $Name_table])):
+ if (!empty($APP_TABLE['hasTypeScheme'])):
+ // $arr_new['nom' . $Name_table] = $arr['nom' . $Name_table.'_type'];
+ endif;
+ // $arr_new['nom' . $Name_table] .= substr(strip_tags($arr['code' . $Name_table]),0,5) ;
+ if (!empty($APP_TABLE['hasDateScheme']) && !empty($arr['dateDebut' . $Name_table])):
+ $arr_new['nom' . $Name_table] .= ' ' . date_fr($arr['dateDebut' . $Name_table]);
+ endif;
+ // $arr_new['nom' . $Name_table] .= substr(strip_tags($arr['description' . $Name_table]),0,10);
+ endif;
+ if (sizeof($arr_new) != 0) {
+ $arr_new ['updated_fields'] = $arr_new; // log ???
+ // versioning
+ $arr_new['dateModification' . $Name_table] = date('Y-m-d');
+ $arr_new['heureModification' . $Name_table] = date('H:i:s');
+ $arr_new['timeModification' . $Name_table] = time();
+
+ $col->update([$name_id => $value_id], ['$set' => $arr_new], ['upsert' => true]);
+ }
+ if ($rs->count() == 1) {
+ return $arr_new;
+ }
+
+ endwhile;
+ }
+ }
diff --git a/web/bin/tools/IdaeDataSchemeImage.php b/web/bin/tools/IdaeDataSchemeImage.php
index 99a7ef7..9f1fa5b 100644
--- a/web/bin/tools/IdaeDataSchemeImage.php
+++ b/web/bin/tools/IdaeDataSchemeImage.php
@@ -1,230 +1,230 @@
-plug_base('sitebase_image')->getGridFs();
- //
- $image = $grid->findOne(['filename' => $image_name]);
- if (empty($image)) {
- $image = $grid->findOne(['filename' => $raw_image_name]);
- }
- $dir = $image->file['metadata']['tag'] . '/'; // tag = table
- $file = $image->file;
-
- switch ($file['metadata']['contentType']) {
- case "image/jpeg":
- $ext = 'jpg';
- break;
- case "image/jpg":
- $ext = 'jpg';
- break;
- case "image/gif":
- $ext = 'gif';
- break;
- case "image/png":
- $ext = 'png';
- break;
- default:
- $ext = 'jpg';
- break;
- }
-
- $image_file = FLATTENIMGDIR . $dir . $image_name;
- $image_http_file = FLATTENIMGHTTP . $dir . $image_name;
-
- if (!file_exists(FLATTENIMGDIR)) {
- mkdir(FLATTENIMGDIR);
- }
- if (!file_exists(FLATTENIMGDIR . $dir)) {
- mkdir(FLATTENIMGDIR . $dir);
- }
- if (empty($image) && !file_exists($image_file)) {
- // echo "ok 3 ";
- return '';
-
- return empty($image) . " but not found $image_file";// HTTPIMAGES."blank.png?f=".$image_http_file;
-
- }
- if (!empty($image) || !file_exists($image_file)) {
- // on écrit image
- $file = $image->file;
- $sdir = $image->file['metadata']['tag'];
- if (is_array($sdir)) {
- $sdir = $sdir[0];
- }
-
- $dir = FLATTENIMGDIR . $sdir . '/';
- if (!file_exists($dir) && !empty($file['length'])) {
- mkdir($dir, 0777);
- }
- if (file_exists($dir) && !empty($file['length']) && !empty($file['chunkSize'])):
-
- if (file_exists($dir . $image_name)) {
- $length = $image->file['length'];
- $filesize = filesize($dir . $image_name);
-
- if ($length == $filesize):
- return $image_http_file;
- else:
- //@chmod($dir , 777);
- $image->write($dir . $image_name);
-
- return $image_http_file;
- endif;
- }
- if (!file_exists($dir . $image_name)) {
-
- $image->write($dir . $image_name);
-
- return $image_http_file;
- }
- endif;
-
- }
- if (file_exists($image_file)) {
- return $image_http_file;
-
- }
-
- return $image_name;
- }
-
- static public function buildImageSizes($table, $table_value, $codeTailleImage, $base = 'sitebase_image', $collection = 'fs') {
- global $buildArr;
- global $IMG_SIZE_ARR;
-
- $IdaeConnect = IdaeConnect::getInstance();
- $conn_base = $IdaeConnect->plug_base($base);
- $grid = $conn_base->getGridFs($collection);
- $objImg = $grid->findOne(array('metadata.table' => $table,
- 'metadata.table_value' => $table_value,
- 'metadata.codeTailleImage' => $codeTailleImage));
- $file = $objImg->file;
- $bytes = $objImg->getBytes();
- if (empty($bytes)) return false;
-
- $file_name = $file['filename'];
- $metadata = $file['metadata'];
-
-
-
- $vars['build'] = [];
-
- switch ($codeTailleImage):
- case 'square':
- $vars['build'] = ['small' => ['from' => $codeTailleImage,
- 'width' => $buildArr['small'][0],
- 'height' => $buildArr['small'][1]],
- 'squary' => ['from' => $codeTailleImage,
- 'width' => $buildArr['squary'][0],
- 'height' => $buildArr['squary'][1]]];
- break;
- case 'small' :
- $vars['build'] = ['smally' => ['from' => $codeTailleImage,
- 'width' => $buildArr['smally'][0],
- 'height' => $buildArr['smally'][1]],
- 'tiny' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['tiny'][0],
- 'height' => $IMG_SIZE_ARR['tiny'][1]],
- 'square' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['square'][0],
- 'height' => $IMG_SIZE_ARR['square'][1]]];
- break;
- case 'large':
- $vars['build'] = ['long' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['long'][0],
- 'height' => $IMG_SIZE_ARR['long'][1]],
- 'small' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['small'][0],
- 'height' => $IMG_SIZE_ARR['small'][1]],
- 'tiny' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['tiny'][0],
- 'height' => $IMG_SIZE_ARR['tiny'][1]],
- 'square' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['square'][0],
- 'height' => $IMG_SIZE_ARR['square'][1]]];
- break;
- case 'wallpaper':
- $vars['build'] = ['small' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['small'][0],
- 'height' => $IMG_SIZE_ARR['small'][1]],
- 'smally' => ['from' => $codeTailleImage,
- 'width' => $buildArr['smally'][0],
- 'height' => $buildArr['smally'][1]],
- 'square' => ['from' => $codeTailleImage,
- 'width' => $IMG_SIZE_ARR['square'][0],
- 'height' => $IMG_SIZE_ARR['square'][1]],
- 'tiny' => ['from' => $codeTailleImage,
- 'width' => $buildArr['tiny'][0],
- 'height' => $buildArr['tiny'][1]]];
- break;
-
- endswitch;
-
- $ins_size = $metadata;
- unset($ins_size['filename']);
-
- foreach ($vars['build'] as $key => $build):
- if (empty($build['width']) || empty($build['height'])) continue;
-
- $new_src = str_replace($codeTailleImage, $key, $file_name);
- $image_sized = $grid->findOne(["filename" => $new_src]);
-
- if (!empty($image_sized)) continue;
-
- $resized_bytes = IdaeImage::thumbImageBytes($bytes, ['width' => $build['width'],
- 'height' => $build['height']]);
- $ins_size = array_merge($ins_size, ['codeTailleImage' => $key,
- 'width' => $build['width'],
- 'height' => $build['height']]);
-
- IdaeImage::saveImageBytes($new_src, $resized_bytes, $ins_size, $base, $collection);
-
- $image_file_sized = str_replace('.jpg', '', $new_src);
- AppSocket::send_cmd('act_notify', ['msg' => ' Génération => ' . $new_src . ' ' . $image_file_sized], session_id());
-
- endforeach;
- }
+plug_base('sitebase_image')->getGridFs();
+ //
+ $image = $grid->findOne(['filename' => $image_name]);
+ if (empty($image)) {
+ $image = $grid->findOne(['filename' => $raw_image_name]);
+ }
+ $dir = $image->file['metadata']['tag'] . '/'; // tag = table
+ $file = $image->file;
+
+ switch ($file['metadata']['contentType']) {
+ case "image/jpeg":
+ $ext = 'jpg';
+ break;
+ case "image/jpg":
+ $ext = 'jpg';
+ break;
+ case "image/gif":
+ $ext = 'gif';
+ break;
+ case "image/png":
+ $ext = 'png';
+ break;
+ default:
+ $ext = 'jpg';
+ break;
+ }
+
+ $image_file = FLATTENIMGDIR . $dir . $image_name;
+ $image_http_file = FLATTENIMGHTTP . $dir . $image_name;
+
+ if (!file_exists(FLATTENIMGDIR)) {
+ mkdir(FLATTENIMGDIR);
+ }
+ if (!file_exists(FLATTENIMGDIR . $dir)) {
+ mkdir(FLATTENIMGDIR . $dir);
+ }
+ if (empty($image) && !file_exists($image_file)) {
+ // echo "ok 3 ";
+ return '';
+
+ return empty($image) . " but not found $image_file";// HTTPIMAGES."blank.png?f=".$image_http_file;
+
+ }
+ if (!empty($image) || !file_exists($image_file)) {
+ // on écrit image
+ $file = $image->file;
+ $sdir = $image->file['metadata']['tag'];
+ if (is_array($sdir)) {
+ $sdir = $sdir[0];
+ }
+
+ $dir = FLATTENIMGDIR . $sdir . '/';
+ if (!file_exists($dir) && !empty($file['length'])) {
+ mkdir($dir, 0777);
+ }
+ if (file_exists($dir) && !empty($file['length']) && !empty($file['chunkSize'])):
+
+ if (file_exists($dir . $image_name)) {
+ $length = $image->file['length'];
+ $filesize = filesize($dir . $image_name);
+
+ if ($length == $filesize):
+ return $image_http_file;
+ else:
+ //@chmod($dir , 777);
+ $image->write($dir . $image_name);
+
+ return $image_http_file;
+ endif;
+ }
+ if (!file_exists($dir . $image_name)) {
+
+ $image->write($dir . $image_name);
+
+ return $image_http_file;
+ }
+ endif;
+
+ }
+ if (file_exists($image_file)) {
+ return $image_http_file;
+
+ }
+
+ return $image_name;
+ }
+
+ static public function buildImageSizes($table, $table_value, $codeTailleImage, $base = 'sitebase_image', $collection = 'fs') {
+ global $buildArr;
+ global $IMG_SIZE_ARR;
+
+ $IdaeConnect = IdaeConnect::getInstance();
+ $conn_base = $IdaeConnect->plug_base($base);
+ $grid = $conn_base->getGridFs($collection);
+ $objImg = $grid->findOne(array('metadata.table' => $table,
+ 'metadata.table_value' => $table_value,
+ 'metadata.codeTailleImage' => $codeTailleImage));
+ $file = $objImg->file;
+ $bytes = $objImg->getBytes();
+ if (empty($bytes)) return false;
+
+ $file_name = $file['filename'];
+ $metadata = $file['metadata'];
+
+
+
+ $vars['build'] = [];
+
+ switch ($codeTailleImage):
+ case 'square':
+ $vars['build'] = ['small' => ['from' => $codeTailleImage,
+ 'width' => $buildArr['small'][0],
+ 'height' => $buildArr['small'][1]],
+ 'squary' => ['from' => $codeTailleImage,
+ 'width' => $buildArr['squary'][0],
+ 'height' => $buildArr['squary'][1]]];
+ break;
+ case 'small' :
+ $vars['build'] = ['smally' => ['from' => $codeTailleImage,
+ 'width' => $buildArr['smally'][0],
+ 'height' => $buildArr['smally'][1]],
+ 'tiny' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['tiny'][0],
+ 'height' => $IMG_SIZE_ARR['tiny'][1]],
+ 'square' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['square'][0],
+ 'height' => $IMG_SIZE_ARR['square'][1]]];
+ break;
+ case 'large':
+ $vars['build'] = ['long' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['long'][0],
+ 'height' => $IMG_SIZE_ARR['long'][1]],
+ 'small' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['small'][0],
+ 'height' => $IMG_SIZE_ARR['small'][1]],
+ 'tiny' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['tiny'][0],
+ 'height' => $IMG_SIZE_ARR['tiny'][1]],
+ 'square' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['square'][0],
+ 'height' => $IMG_SIZE_ARR['square'][1]]];
+ break;
+ case 'wallpaper':
+ $vars['build'] = ['small' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['small'][0],
+ 'height' => $IMG_SIZE_ARR['small'][1]],
+ 'smally' => ['from' => $codeTailleImage,
+ 'width' => $buildArr['smally'][0],
+ 'height' => $buildArr['smally'][1]],
+ 'square' => ['from' => $codeTailleImage,
+ 'width' => $IMG_SIZE_ARR['square'][0],
+ 'height' => $IMG_SIZE_ARR['square'][1]],
+ 'tiny' => ['from' => $codeTailleImage,
+ 'width' => $buildArr['tiny'][0],
+ 'height' => $buildArr['tiny'][1]]];
+ break;
+
+ endswitch;
+
+ $ins_size = $metadata;
+ unset($ins_size['filename']);
+
+ foreach ($vars['build'] as $key => $build):
+ if (empty($build['width']) || empty($build['height'])) continue;
+
+ $new_src = str_replace($codeTailleImage, $key, $file_name);
+ $image_sized = $grid->findOne(["filename" => $new_src]);
+
+ if (!empty($image_sized)) continue;
+
+ $resized_bytes = IdaeImage::thumbImageBytes($bytes, ['width' => $build['width'],
+ 'height' => $build['height']]);
+ $ins_size = array_merge($ins_size, ['codeTailleImage' => $key,
+ 'width' => $build['width'],
+ 'height' => $build['height']]);
+
+ IdaeImage::saveImageBytes($new_src, $resized_bytes, $ins_size, $base, $collection);
+
+ $image_file_sized = str_replace('.jpg', '', $new_src);
+ AppSocket::send_cmd('act_notify', ['msg' => ' Génération => ' . $new_src . ' ' . $image_file_sized], session_id());
+
+ endforeach;
+ }
}
\ No newline at end of file
diff --git a/web/bin/tools/IdaeDataSchemeInit.php b/web/bin/tools/IdaeDataSchemeInit.php
index d37d19b..d8c5209 100644
--- a/web/bin/tools/IdaeDataSchemeInit.php
+++ b/web/bin/tools/IdaeDataSchemeInit.php
@@ -1,402 +1,402 @@
-plug('sitebase_increment', 'auto_increment')->findOne(['_id' => $id]);
- if (!empty($test['value'])) {
- if ($test['value'] < $min) {
- $this->plug('sitebase_increment', 'auto_increment')->update(['_id' => $id], ['value' => (int)$min], ["upsert" => true]);
- }
- }
- }
-
- $this->plug('sitebase_increment', 'auto_increment')->update(['_id' => $id], ['$inc' => ['value' => 1]], ["upsert" => true]);
- $ret = $this->plug('sitebase_increment', 'auto_increment')->findOne(['_id' => $id]);
-
- return (int)$ret['value'];
- }
-
- private function create_base_model($base) {
-
- $ins['codeAppscheme_base'] = $base;
- $ins['nomAppscheme_base'] = $base;
- $ins['idappscheme_base'] = $this->getNext('idappscheme_base');
-
- $this->appscheme_base_model_instance->insert($ins);
-
- return $ins['idappscheme_base'];
- }
-
- private function create_appscheme_model($table) {
-
- $ins['codeAppscheme'] = $table;
- $ins['nomAppscheme'] = $table;
- $ins['idappscheme'] = $this->getNext('idappscheme');
-
- $this->appscheme_model_instance->insert($ins);
-
- return $ins['idappscheme'];
- }
-
- private function create_appscheme_field_group_model($codeAppscheme_field_group, $nomAppscheme_field_group = null) {
-
- $ins['codeAppscheme_field_group'] = $codeAppscheme_field_group;
- $ins['nomAppscheme_field_group'] = $nomAppscheme_field_group ?: $codeAppscheme_field_group;
- $ins['idappscheme_field_group'] = $this->getNext('idappscheme_field_group');
-
- $this->appscheme_field_group_model_instance->insert($ins);
-
- return $ins['idappscheme_field_group'];
- }
-
- private function create_appscheme_field_type_model($codeAppscheme_field_type, $nomAppscheme_field_type = null) {
-
- $ins['codeAppscheme_field_type'] = $codeAppscheme_field_type;
- $ins['nomAppscheme_field_type'] = $nomAppscheme_field_type ?: $codeAppscheme_field_type;
- $ins['idappscheme_field_type'] = $this->getNext('idappscheme_field_type');
-
- $this->appscheme_field_type_model_instance->insert($ins);
-
- return $ins['idappscheme_field_type'];
- }
-
- private function create_appscheme_field_model($codeAppscheme_field, $nomAppscheme_field = null, $codeAppscheme_field_group = null, $codeAppscheme_field_type = null) {
-
- $ins['codeAppscheme_field'] = $codeAppscheme_field;
- $ins['nomAppscheme_field'] = $nomAppscheme_field ?: $codeAppscheme_field;
- $ins['idappscheme_field'] = $this->getNext('idappscheme_field');
- if (!empty($codeAppscheme_field_group)) {
- $ins['idappscheme_field_group'] = $this->init_scheme_field_group($codeAppscheme_field_group);
- }
- if (!empty($codeAppscheme_field_type)) {
- $ins['idappscheme_field_type'] = $this->init_scheme_field_type($codeAppscheme_field_type);
- }
-
- $this->appscheme_field_model_instance->insert($ins);
-
- return $ins['idappscheme_field'];
- }
-
- private function create_appscheme_has_field_model($codeAppscheme, $codeAppscheme_field, $nomAppscheme_has_field = null) {
-
- $ins['codeAppscheme'] = $codeAppscheme;
- $ins['codeAppscheme_field'] = $codeAppscheme_field;
- $ins['codeAppscheme_has_field'] = $codeAppscheme_field . ucfirst($codeAppscheme);
-
- $ARRS = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme]);
- $ARRF = $this->appscheme_field_model_instance->findOne(['codeAppscheme_field' => $codeAppscheme_field]);
-
- $ins['nomAppscheme_field'] = $ARRF['nomAppscheme_field'];
- $ins['nomAppscheme_has_field'] = $nomAppscheme_has_field ?: $ARRF['nomAppscheme_field'] . ' ' . $ARRS['nomAppscheme'];
-
- $ins['idappscheme'] = (int)$ARRS['idappscheme'];
- $ins['idappscheme_field'] = (int)$ARRF['idappscheme_field'];
-
- $ins['idappscheme_has_field'] = $this->getNext('idappscheme_has_field');
-
- $this->appscheme_has_field_model_instance->insert($ins);
- }
-
- private function create_appscheme_has_table_field_model($codeAppscheme, $codeAppscheme_link, $codeAppscheme_field, $nomAppscheme_has_table_field = null) {
-
-
- $ARR_SCHEME = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme]);
- $ARR_SCHEME_LINK = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme_link]);
- $ARR_FIELD = $this->appscheme_field_model_instance->findOne(['codeAppscheme_field' => $codeAppscheme_field]);
-
- $ins['codeAppscheme'] = $codeAppscheme;
- $ins['codeAppscheme_field'] = $codeAppscheme_field;
- $ins['codeAppscheme_has_table_field'] = $codeAppscheme_field . ucfirst($codeAppscheme) . ' ' . $codeAppscheme_link;
- $ins['nomAppscheme_has_table_field'] = $nomAppscheme_has_table_field ?: $ARR_FIELD['nomAppscheme_field'] . ' ' . $ARR_SCHEME['nomAppscheme'] . ' ' . $ARR_SCHEME_LINK['nomAppscheme'];
-
- $ins['idappscheme'] = (int)$ARR_SCHEME['idappscheme'];
- $ins['idappscheme_link'] = (int)$ARR_SCHEME_LINK['idappscheme'];
- $ins['idappscheme_field'] = (int)$ARR_FIELD['idappscheme_field'];
-
- $ins['idappscheme_has_field'] = $this->getNext('idappscheme_has_field');
-
- $this->appscheme_has_table_field_model_instance->insert($ins);
- }
-
- public function init_scheme_field($codeAppscheme_field, $nomAppscheme_field = null, $codeAppscheme_field_group = null, $codeAppscheme_field_type = null) {
-
- $ARRF = $this->appscheme_field_model_instance->findOne(['codeAppscheme_field' => $codeAppscheme_field]);
-
- if (!empty($ARRF['idappscheme_field'])) {
- return (int)$ARRF['idappscheme_field'];
- } else {
- return $this->create_appscheme_field_model($codeAppscheme_field, $nomAppscheme_field ?: $codeAppscheme_field , $codeAppscheme_field_group, $codeAppscheme_field_type);
- }
- }
-
- public function init_scheme_field_type($codeAppscheme_field_type, $nomAppscheme_field_type = null) {
-
- $ARRF = $this->appscheme_field_type_model_instance->findOne(['codeAppscheme_field_type' => $codeAppscheme_field_type]);
-
- if (!empty($ARRF['idappscheme_field_type'])) {
- return (int)$ARRF['idappscheme_field_type'];
- } else {
- return $this->create_appscheme_field_type_model($codeAppscheme_field_type, $nomAppscheme_field_type);
- }
- }
-
- public function init_scheme_field_group($codeAppscheme_field_group, $nomAppscheme_field_group = null) {
-
- $ARRF = $this->appscheme_field_group_model_instance->findOne(['codeAppscheme_field_group' => $codeAppscheme_field_group]);
-
- if (!empty($ARRF['idappscheme_field_group'])) {
- return (int)$ARRF['idappscheme_field_group'];
- } else {
- return $this->create_appscheme_field_group_model($codeAppscheme_field_group, $nomAppscheme_field_group);
- }
- }
-
- public function init_scheme_has_field($codeAppscheme, $codeAppscheme_field, $nomAppscheme_has_field = null) {
-
- $this->init_scheme_field($codeAppscheme_field);
-
- $ARRF = $this->appscheme_has_field_model_instance->findOne(['codeAppscheme' => $codeAppscheme,
- 'codeAppscheme_field' => $codeAppscheme_field]);
-
- if (!empty($ARRF['idappscheme_has_field'])) {
- return (int)$ARRF['idappscheme_has_field'];
- } else {
- return $this->create_appscheme_has_field_model($codeAppscheme, $codeAppscheme_field, $nomAppscheme_has_field);
- }
- }
-
- public function init_scheme_has_table_field($codeAppscheme, $codeAppscheme_link, $codeAppscheme_field, $nomAppscheme_has_table_field = null) {
-
- $test_appscheme = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme]);
- $test_appscheme_link = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme_link]);
-
- $idappscheme_field = $this->init_scheme_field($codeAppscheme_field);
- $idappscheme = (int)$test_appscheme['idappscheme'];
- $idappscheme_link = (int)$test_appscheme_link['idappscheme'];
-
- $ARRF = $this->appscheme_has_table_field_model_instance->findOne(['idappscheme' => $idappscheme,
- 'idappscheme_link' => $idappscheme_link,
- 'idappscheme_field' => $idappscheme_field]);
-
- if (!empty($ARRF['idappscheme_has_table_field'])) {
- return (int)$ARRF['idappscheme_has_table_field'];
- } else {
- return $this->create_appscheme_has_table_field_model($codeAppscheme, $codeAppscheme_link, $codeAppscheme_field, $nomAppscheme_has_table_field);
- }
- }
-
- public function consolidate_app_scheme($table) {
-
- $APP_GROUPE = new App('agent_groupe');
- $APP_DROIT = new App('agent_groupe_droit');
- $APP_BASE = new App('appscheme_base');
- $APP_SCH = new App('appscheme');
- $APP_SCH_FIELD = new App('appscheme_field');
- $APP_SCH_HAS = new App('appscheme_has_field');
- $APP_SCH_HAS_TABLE = new App('appscheme_has_table_field');
- $APP_CONSOLIDATE = new App($table);
-
- $ARR = $APP_SCH->findOne(['codeAppscheme' => $table]);
- $idappscheme = (int)$ARR['idappscheme'];
- if (empty($idappscheme)) {
-
- return;
- }
-
- $arr_main = $APP_SCH_HAS_TABLE->distinct_all('idappscheme_field', ['idappscheme' => $idappscheme]);
- $arr_main_2 = $APP_SCH_HAS->distinct_all('idappscheme_field', ['idappscheme' => $idappscheme]);
-
- if (sizeof($arr_main) != 0 && sizeof($arr_main_2) != 0) {
- $diff = array_values(array_diff($arr_main, $arr_main_2));
- if (sizeof($diff) != 0) {
- $APP_SCH_HAS_TABLE->remove(['idappscheme' => $idappscheme,
- 'idappscheme_field' => ['$in' => $diff]]);
- }
- }
-
- $ARR_GR = $APP_GROUPE->findOne(['codeAgent_groupe' => 'ADMIN']);
- $ARR_FIELD_NOM = $APP_SCH_FIELD->findOne(['codeAppscheme_field' => 'nom']);
- $IDFIELD_NOM = (int)$ARR_FIELD_NOM['idappscheme_field'];
-
- if (!empty($ARR_GR['idagent_groupe'])) {
- $APP_DROIT->create_update(['idagent_groupe' => (int)$ARR_GR['idagent_groupe'],
- 'idappscheme' => $idappscheme], ['C' => true,
- 'R' => true,
- 'U' => true,
- 'D' => true,
- 'L' => true]);
- }
- if (empty($ARR['codeAppscheme_base']) && !empty($ARR['base'])) {
- $idappscheme_base = $APP_BASE->create_update(['codeAppscheme_base' => $ARR['base']], ['nomAppscheme_base' => $ARR['base']]);
- }
- if (empty($ARR['iconAppscheme']) && !empty($ARR['icon'])) {
- $APP_SCH->update(['idappscheme' => $idappscheme], ['iconAppscheme' => $ARR['icon']]);
- }
- //
- $arr_has = ['statut',
- 'type',
- 'categorie',
- 'ligne',
- 'group',
- 'groupe'];
-
- $GRILLEFK = $APP_CONSOLIDATE->get_grille_fk();
- foreach ($arr_has as $key => $value):
- $Value = ucfirst($value);
- $_table = $table . '_' . $value;
-
- if (!empty((int)$ARR['has' . $Value . 'Scheme']) && empty($GRILLEFK[$_table]) && !empty($ARR['codeAppscheme_base'])):
- $this->init_scheme($ARR['codeAppscheme_base'], $_table);
- // put it in grilleFK
- $APP_CONSOLIDATE->set_grille_fk($_table);
- endif;
- $test = strpos($table, "_$value");
- if (strpos($table, "_$value") !== false && (empty($ARR['is' . $Value . 'Scheme']) || empty($ARR['grouped_scheme']))):
- $APP_SCH->update(['idappscheme' => $idappscheme], ['is' . $Value . 'Scheme' => 1,
- 'grouped_scheme' => 1]);
- endif;
- endforeach;
-
-
- $testSF = $APP_SCH_HAS->find(['idappscheme' => $idappscheme]);
- $arrSF = $APP_SCH_HAS->findOne(['idappscheme' => $idappscheme,
- 'idappscheme_field' => $IDFIELD_NOM]);
- // todo activate this
- /*if (empty($arrSF['idappscheme_field']) && $testSF->count() == 0) {
- // echo "
champ nom par defaut vide";
- $ins = ['codeAppscheme_has_field' => 'nom' . ucfirst($table),
- 'codeAppscheme_field' => 'nom'];
- $ins['nomAppscheme_has_field'] = $ARR_FIELD_NOM['nomAppscheme_field'] . ' ' . $ARR['nomAppscheme'];
- $ins['codeAppscheme_has_field'] = $ARR_FIELD_NOM['codeAppscheme_field'] . ucfirst($table);
- $ins['in_mini_fiche'] = 1;
-
- $idappscheme_has_field = $APP_SCH_HAS->create_update(['idappscheme' => $idappscheme,
- 'idappscheme_field' => (int)$IDFIELD_NOM], $ins);
- $APP_SCH_FIELD->consolidate_scheme($idappscheme_has_field);
- }
- $testSF = $APP_SCH_HAS_TABLE->find(['idappscheme' => $idappscheme]);
- $arrSF = $APP_SCH_HAS_TABLE->findOne(['idappscheme' => $idappscheme,
- 'idappscheme_link' => $idappscheme,
- 'idappscheme_field' => $IDFIELD_NOM]);
- if (empty($arrSF['codeAppscheme_field']) && $testSF->count() == 0) {
- // echo "
champ nom personnalisé vide";
- $ins = ['idappscheme' => $idappscheme,
- 'idappscheme_link' => $idappscheme,
- 'idappscheme_field' => $IDFIELD_NOM];
- $ins['nomAppscheme_has_table_field'] = $ARR_FIELD_NOM['nomAppscheme_field'] . ' ' . $ARR['nomAppscheme'];
- $ins['codeAppscheme_has_table_field'] = $ARR_FIELD_NOM['codeAppscheme_field'] . ucfirst($table);
- $ins['idappscheme_field'] = (int)$ARR_FIELD_NOM['idappscheme_field'];
-
- $idappscheme_has_table_field = $APP_SCH_HAS_TABLE->create_update(['idappscheme' => $idappscheme,
- 'idappscheme_link' => $idappscheme], $ins);
- $APP_SCH_HAS_TABLE->consolidate_scheme($idappscheme_has_table_field);
- }*/
-
- }
-
- private function init_scheme_droits($idappscheme) {
- $APP_DROIT = new App('agent_groupe_droit');
- $APP_GROUPE = new App('agent_groupe');
-
- $ARR_GR = $APP_GROUPE->findOne(['codeAgent_groupe' => 'ADMIN']);
-
- if (!empty($ARR_GR['idagent_groupe'])) {
- $APP_DROIT->create_update(['idagent_groupe' => (int)$ARR_GR['idagent_groupe'],
- 'idappscheme' => $idappscheme], ['C' => true,
- 'R' => true,
- 'U' => true,
- 'D' => true,
- 'L' => true]);
- }
- }
-
- public function init_scheme($base, $table, $options = [], $force = false) {
-
- if (empty($table) || empty($base)) return false;
-
- $test_base = $this->appscheme_base_model_instance->findOne(['codeAppscheme_base' => $base]);
-
- if (empty($test_base['idappscheme_base'])) {
- $ins['idappscheme_base'] = $this->create_base_model($base);
- $ins['codeAppscheme_base'] = $base;
- $ins['nomAppscheme_base'] = $base;
-
- } else {
- $ins['idappscheme_base'] = (int)$test_base['idappscheme_base'];
- $ins['codeAppscheme_base'] = $base;
- $ins['nomAppscheme_base'] = $test_base['nomAppscheme_base'];
- }
-
- $test_appscheme = $this->appscheme_model_instance->findOne(['codeAppscheme' => $table]);
-
- if (empty($test_appscheme['idappscheme'])) {
- $ins['idappscheme'] = $this->create_appscheme_model($table);
- $ins['codeAppscheme'] = $table;
- $ins['nomAppscheme'] = $table;
- } elseif ($force == true) {
- $ins['idappscheme'] = (int)$test_appscheme['idappscheme'];
- $ins['codeAppscheme'] = $table;
- unset($ins['_id']);
- } else {
- // return false;
- $ins['idappscheme'] = (int)$test_appscheme['idappscheme'];
- $ins['codeAppscheme'] = $table;
- unset($ins['_id']);
- }
-
- if (!empty($options['has'])) {
- foreach ($options['has'] as $key => $value) {
- $ins['has' . ucfirst($value) . 'Scheme'] = 1;
- }
- unset($options['has']);
- }
-
- if (!empty($options['is'])) {
- foreach ($options['is'] as $key => $value) {
- $ins['is' . ucfirst($value) . ucfirst($table)] = 1;
- }
- unset($options['is']);
- }
-
- if (!empty($options['fields'])) {
- foreach ($options['fields'] as $key => $value) {
- $this->init_scheme_has_field($table, $value);
- }
- unset($options['fields']);
- }
- if (!empty($options['grilleFK'])) { // should exists in the same base
- $ARRFK = [];
- foreach ($options['grilleFK'] as $key => $value) {
- $ARRFK [(int)$key] = ['table' => $value,
- 'ordreTable' => (int)$key,
- 'uid' => uniqid()];
- }
- $ins['grilleFK'] = $ARRFK;
- unset($options['grilleFK']);
- }
-
- $ins = array_filter($ins);
-
- $this->appscheme_model_instance->update(['idappscheme' => $ins['idappscheme']], ['$set' => $ins], ['upsert' => true]);
-
- $this->init_scheme_droits($ins['idappscheme']);
-
- return new App($table);
- }
- }
+plug('sitebase_increment', 'auto_increment')->findOne(['_id' => $id]);
+ if (!empty($test['value'])) {
+ if ($test['value'] < $min) {
+ $this->plug('sitebase_increment', 'auto_increment')->update(['_id' => $id], ['value' => (int)$min], ["upsert" => true]);
+ }
+ }
+ }
+
+ $this->plug('sitebase_increment', 'auto_increment')->update(['_id' => $id], ['$inc' => ['value' => 1]], ["upsert" => true]);
+ $ret = $this->plug('sitebase_increment', 'auto_increment')->findOne(['_id' => $id]);
+
+ return (int)$ret['value'];
+ }
+
+ private function create_base_model($base) {
+
+ $ins['codeAppscheme_base'] = $base;
+ $ins['nomAppscheme_base'] = $base;
+ $ins['idappscheme_base'] = $this->getNext('idappscheme_base');
+
+ $this->appscheme_base_model_instance->insert($ins);
+
+ return $ins['idappscheme_base'];
+ }
+
+ private function create_appscheme_model($table) {
+
+ $ins['codeAppscheme'] = $table;
+ $ins['nomAppscheme'] = $table;
+ $ins['idappscheme'] = $this->getNext('idappscheme');
+
+ $this->appscheme_model_instance->insert($ins);
+
+ return $ins['idappscheme'];
+ }
+
+ private function create_appscheme_field_group_model($codeAppscheme_field_group, $nomAppscheme_field_group = null) {
+
+ $ins['codeAppscheme_field_group'] = $codeAppscheme_field_group;
+ $ins['nomAppscheme_field_group'] = $nomAppscheme_field_group ?: $codeAppscheme_field_group;
+ $ins['idappscheme_field_group'] = $this->getNext('idappscheme_field_group');
+
+ $this->appscheme_field_group_model_instance->insert($ins);
+
+ return $ins['idappscheme_field_group'];
+ }
+
+ private function create_appscheme_field_type_model($codeAppscheme_field_type, $nomAppscheme_field_type = null) {
+
+ $ins['codeAppscheme_field_type'] = $codeAppscheme_field_type;
+ $ins['nomAppscheme_field_type'] = $nomAppscheme_field_type ?: $codeAppscheme_field_type;
+ $ins['idappscheme_field_type'] = $this->getNext('idappscheme_field_type');
+
+ $this->appscheme_field_type_model_instance->insert($ins);
+
+ return $ins['idappscheme_field_type'];
+ }
+
+ private function create_appscheme_field_model($codeAppscheme_field, $nomAppscheme_field = null, $codeAppscheme_field_group = null, $codeAppscheme_field_type = null) {
+
+ $ins['codeAppscheme_field'] = $codeAppscheme_field;
+ $ins['nomAppscheme_field'] = $nomAppscheme_field ?: $codeAppscheme_field;
+ $ins['idappscheme_field'] = $this->getNext('idappscheme_field');
+ if (!empty($codeAppscheme_field_group)) {
+ $ins['idappscheme_field_group'] = $this->init_scheme_field_group($codeAppscheme_field_group);
+ }
+ if (!empty($codeAppscheme_field_type)) {
+ $ins['idappscheme_field_type'] = $this->init_scheme_field_type($codeAppscheme_field_type);
+ }
+
+ $this->appscheme_field_model_instance->insert($ins);
+
+ return $ins['idappscheme_field'];
+ }
+
+ private function create_appscheme_has_field_model($codeAppscheme, $codeAppscheme_field, $nomAppscheme_has_field = null) {
+
+ $ins['codeAppscheme'] = $codeAppscheme;
+ $ins['codeAppscheme_field'] = $codeAppscheme_field;
+ $ins['codeAppscheme_has_field'] = $codeAppscheme_field . ucfirst($codeAppscheme);
+
+ $ARRS = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme]);
+ $ARRF = $this->appscheme_field_model_instance->findOne(['codeAppscheme_field' => $codeAppscheme_field]);
+
+ $ins['nomAppscheme_field'] = $ARRF['nomAppscheme_field'];
+ $ins['nomAppscheme_has_field'] = $nomAppscheme_has_field ?: $ARRF['nomAppscheme_field'] . ' ' . $ARRS['nomAppscheme'];
+
+ $ins['idappscheme'] = (int)$ARRS['idappscheme'];
+ $ins['idappscheme_field'] = (int)$ARRF['idappscheme_field'];
+
+ $ins['idappscheme_has_field'] = $this->getNext('idappscheme_has_field');
+
+ $this->appscheme_has_field_model_instance->insert($ins);
+ }
+
+ private function create_appscheme_has_table_field_model($codeAppscheme, $codeAppscheme_link, $codeAppscheme_field, $nomAppscheme_has_table_field = null) {
+
+
+ $ARR_SCHEME = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme]);
+ $ARR_SCHEME_LINK = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme_link]);
+ $ARR_FIELD = $this->appscheme_field_model_instance->findOne(['codeAppscheme_field' => $codeAppscheme_field]);
+
+ $ins['codeAppscheme'] = $codeAppscheme;
+ $ins['codeAppscheme_field'] = $codeAppscheme_field;
+ $ins['codeAppscheme_has_table_field'] = $codeAppscheme_field . ucfirst($codeAppscheme) . ' ' . $codeAppscheme_link;
+ $ins['nomAppscheme_has_table_field'] = $nomAppscheme_has_table_field ?: $ARR_FIELD['nomAppscheme_field'] . ' ' . $ARR_SCHEME['nomAppscheme'] . ' ' . $ARR_SCHEME_LINK['nomAppscheme'];
+
+ $ins['idappscheme'] = (int)$ARR_SCHEME['idappscheme'];
+ $ins['idappscheme_link'] = (int)$ARR_SCHEME_LINK['idappscheme'];
+ $ins['idappscheme_field'] = (int)$ARR_FIELD['idappscheme_field'];
+
+ $ins['idappscheme_has_field'] = $this->getNext('idappscheme_has_field');
+
+ $this->appscheme_has_table_field_model_instance->insert($ins);
+ }
+
+ public function init_scheme_field($codeAppscheme_field, $nomAppscheme_field = null, $codeAppscheme_field_group = null, $codeAppscheme_field_type = null) {
+
+ $ARRF = $this->appscheme_field_model_instance->findOne(['codeAppscheme_field' => $codeAppscheme_field]);
+
+ if (!empty($ARRF['idappscheme_field'])) {
+ return (int)$ARRF['idappscheme_field'];
+ } else {
+ return $this->create_appscheme_field_model($codeAppscheme_field, $nomAppscheme_field ?: $codeAppscheme_field , $codeAppscheme_field_group, $codeAppscheme_field_type);
+ }
+ }
+
+ public function init_scheme_field_type($codeAppscheme_field_type, $nomAppscheme_field_type = null) {
+
+ $ARRF = $this->appscheme_field_type_model_instance->findOne(['codeAppscheme_field_type' => $codeAppscheme_field_type]);
+
+ if (!empty($ARRF['idappscheme_field_type'])) {
+ return (int)$ARRF['idappscheme_field_type'];
+ } else {
+ return $this->create_appscheme_field_type_model($codeAppscheme_field_type, $nomAppscheme_field_type);
+ }
+ }
+
+ public function init_scheme_field_group($codeAppscheme_field_group, $nomAppscheme_field_group = null) {
+
+ $ARRF = $this->appscheme_field_group_model_instance->findOne(['codeAppscheme_field_group' => $codeAppscheme_field_group]);
+
+ if (!empty($ARRF['idappscheme_field_group'])) {
+ return (int)$ARRF['idappscheme_field_group'];
+ } else {
+ return $this->create_appscheme_field_group_model($codeAppscheme_field_group, $nomAppscheme_field_group);
+ }
+ }
+
+ public function init_scheme_has_field($codeAppscheme, $codeAppscheme_field, $nomAppscheme_has_field = null) {
+
+ $this->init_scheme_field($codeAppscheme_field);
+
+ $ARRF = $this->appscheme_has_field_model_instance->findOne(['codeAppscheme' => $codeAppscheme,
+ 'codeAppscheme_field' => $codeAppscheme_field]);
+
+ if (!empty($ARRF['idappscheme_has_field'])) {
+ return (int)$ARRF['idappscheme_has_field'];
+ } else {
+ return $this->create_appscheme_has_field_model($codeAppscheme, $codeAppscheme_field, $nomAppscheme_has_field);
+ }
+ }
+
+ public function init_scheme_has_table_field($codeAppscheme, $codeAppscheme_link, $codeAppscheme_field, $nomAppscheme_has_table_field = null) {
+
+ $test_appscheme = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme]);
+ $test_appscheme_link = $this->appscheme_model_instance->findOne(['codeAppscheme' => $codeAppscheme_link]);
+
+ $idappscheme_field = $this->init_scheme_field($codeAppscheme_field);
+ $idappscheme = (int)$test_appscheme['idappscheme'];
+ $idappscheme_link = (int)$test_appscheme_link['idappscheme'];
+
+ $ARRF = $this->appscheme_has_table_field_model_instance->findOne(['idappscheme' => $idappscheme,
+ 'idappscheme_link' => $idappscheme_link,
+ 'idappscheme_field' => $idappscheme_field]);
+
+ if (!empty($ARRF['idappscheme_has_table_field'])) {
+ return (int)$ARRF['idappscheme_has_table_field'];
+ } else {
+ return $this->create_appscheme_has_table_field_model($codeAppscheme, $codeAppscheme_link, $codeAppscheme_field, $nomAppscheme_has_table_field);
+ }
+ }
+
+ public function consolidate_app_scheme($table) {
+
+ $APP_GROUPE = new App('agent_groupe');
+ $APP_DROIT = new App('agent_groupe_droit');
+ $APP_BASE = new App('appscheme_base');
+ $APP_SCH = new App('appscheme');
+ $APP_SCH_FIELD = new App('appscheme_field');
+ $APP_SCH_HAS = new App('appscheme_has_field');
+ $APP_SCH_HAS_TABLE = new App('appscheme_has_table_field');
+ $APP_CONSOLIDATE = new App($table);
+
+ $ARR = $APP_SCH->findOne(['codeAppscheme' => $table]);
+ $idappscheme = (int)$ARR['idappscheme'];
+ if (empty($idappscheme)) {
+
+ return;
+ }
+
+ $arr_main = $APP_SCH_HAS_TABLE->distinct_all('idappscheme_field', ['idappscheme' => $idappscheme]);
+ $arr_main_2 = $APP_SCH_HAS->distinct_all('idappscheme_field', ['idappscheme' => $idappscheme]);
+
+ if (sizeof($arr_main) != 0 && sizeof($arr_main_2) != 0) {
+ $diff = array_values(array_diff($arr_main, $arr_main_2));
+ if (sizeof($diff) != 0) {
+ $APP_SCH_HAS_TABLE->remove(['idappscheme' => $idappscheme,
+ 'idappscheme_field' => ['$in' => $diff]]);
+ }
+ }
+
+ $ARR_GR = $APP_GROUPE->findOne(['codeAgent_groupe' => 'ADMIN']);
+ $ARR_FIELD_NOM = $APP_SCH_FIELD->findOne(['codeAppscheme_field' => 'nom']);
+ $IDFIELD_NOM = (int)$ARR_FIELD_NOM['idappscheme_field'];
+
+ if (!empty($ARR_GR['idagent_groupe'])) {
+ $APP_DROIT->create_update(['idagent_groupe' => (int)$ARR_GR['idagent_groupe'],
+ 'idappscheme' => $idappscheme], ['C' => true,
+ 'R' => true,
+ 'U' => true,
+ 'D' => true,
+ 'L' => true]);
+ }
+ if (empty($ARR['codeAppscheme_base']) && !empty($ARR['base'])) {
+ $idappscheme_base = $APP_BASE->create_update(['codeAppscheme_base' => $ARR['base']], ['nomAppscheme_base' => $ARR['base']]);
+ }
+ if (empty($ARR['iconAppscheme']) && !empty($ARR['icon'])) {
+ $APP_SCH->update(['idappscheme' => $idappscheme], ['iconAppscheme' => $ARR['icon']]);
+ }
+ //
+ $arr_has = ['statut',
+ 'type',
+ 'categorie',
+ 'ligne',
+ 'group',
+ 'groupe'];
+
+ $GRILLEFK = $APP_CONSOLIDATE->get_grille_fk();
+ foreach ($arr_has as $key => $value):
+ $Value = ucfirst($value);
+ $_table = $table . '_' . $value;
+
+ if (!empty((int)$ARR['has' . $Value . 'Scheme']) && empty($GRILLEFK[$_table]) && !empty($ARR['codeAppscheme_base'])):
+ $this->init_scheme($ARR['codeAppscheme_base'], $_table);
+ // put it in grilleFK
+ $APP_CONSOLIDATE->set_grille_fk($_table);
+ endif;
+ $test = strpos($table, "_$value");
+ if (strpos($table, "_$value") !== false && (empty($ARR['is' . $Value . 'Scheme']) || empty($ARR['grouped_scheme']))):
+ $APP_SCH->update(['idappscheme' => $idappscheme], ['is' . $Value . 'Scheme' => 1,
+ 'grouped_scheme' => 1]);
+ endif;
+ endforeach;
+
+
+ $testSF = $APP_SCH_HAS->find(['idappscheme' => $idappscheme]);
+ $arrSF = $APP_SCH_HAS->findOne(['idappscheme' => $idappscheme,
+ 'idappscheme_field' => $IDFIELD_NOM]);
+ // todo activate this
+ /*if (empty($arrSF['idappscheme_field']) && $testSF->count() == 0) {
+ // echo "
champ nom par defaut vide";
+ $ins = ['codeAppscheme_has_field' => 'nom' . ucfirst($table),
+ 'codeAppscheme_field' => 'nom'];
+ $ins['nomAppscheme_has_field'] = $ARR_FIELD_NOM['nomAppscheme_field'] . ' ' . $ARR['nomAppscheme'];
+ $ins['codeAppscheme_has_field'] = $ARR_FIELD_NOM['codeAppscheme_field'] . ucfirst($table);
+ $ins['in_mini_fiche'] = 1;
+
+ $idappscheme_has_field = $APP_SCH_HAS->create_update(['idappscheme' => $idappscheme,
+ 'idappscheme_field' => (int)$IDFIELD_NOM], $ins);
+ $APP_SCH_FIELD->consolidate_scheme($idappscheme_has_field);
+ }
+ $testSF = $APP_SCH_HAS_TABLE->find(['idappscheme' => $idappscheme]);
+ $arrSF = $APP_SCH_HAS_TABLE->findOne(['idappscheme' => $idappscheme,
+ 'idappscheme_link' => $idappscheme,
+ 'idappscheme_field' => $IDFIELD_NOM]);
+ if (empty($arrSF['codeAppscheme_field']) && $testSF->count() == 0) {
+ // echo "
champ nom personnalisé vide";
+ $ins = ['idappscheme' => $idappscheme,
+ 'idappscheme_link' => $idappscheme,
+ 'idappscheme_field' => $IDFIELD_NOM];
+ $ins['nomAppscheme_has_table_field'] = $ARR_FIELD_NOM['nomAppscheme_field'] . ' ' . $ARR['nomAppscheme'];
+ $ins['codeAppscheme_has_table_field'] = $ARR_FIELD_NOM['codeAppscheme_field'] . ucfirst($table);
+ $ins['idappscheme_field'] = (int)$ARR_FIELD_NOM['idappscheme_field'];
+
+ $idappscheme_has_table_field = $APP_SCH_HAS_TABLE->create_update(['idappscheme' => $idappscheme,
+ 'idappscheme_link' => $idappscheme], $ins);
+ $APP_SCH_HAS_TABLE->consolidate_scheme($idappscheme_has_table_field);
+ }*/
+
+ }
+
+ private function init_scheme_droits($idappscheme) {
+ $APP_DROIT = new App('agent_groupe_droit');
+ $APP_GROUPE = new App('agent_groupe');
+
+ $ARR_GR = $APP_GROUPE->findOne(['codeAgent_groupe' => 'ADMIN']);
+
+ if (!empty($ARR_GR['idagent_groupe'])) {
+ $APP_DROIT->create_update(['idagent_groupe' => (int)$ARR_GR['idagent_groupe'],
+ 'idappscheme' => $idappscheme], ['C' => true,
+ 'R' => true,
+ 'U' => true,
+ 'D' => true,
+ 'L' => true]);
+ }
+ }
+
+ public function init_scheme($base, $table, $options = [], $force = false) {
+
+ if (empty($table) || empty($base)) return false;
+
+ $test_base = $this->appscheme_base_model_instance->findOne(['codeAppscheme_base' => $base]);
+
+ if (empty($test_base['idappscheme_base'])) {
+ $ins['idappscheme_base'] = $this->create_base_model($base);
+ $ins['codeAppscheme_base'] = $base;
+ $ins['nomAppscheme_base'] = $base;
+
+ } else {
+ $ins['idappscheme_base'] = (int)$test_base['idappscheme_base'];
+ $ins['codeAppscheme_base'] = $base;
+ $ins['nomAppscheme_base'] = $test_base['nomAppscheme_base'];
+ }
+
+ $test_appscheme = $this->appscheme_model_instance->findOne(['codeAppscheme' => $table]);
+
+ if (empty($test_appscheme['idappscheme'])) {
+ $ins['idappscheme'] = $this->create_appscheme_model($table);
+ $ins['codeAppscheme'] = $table;
+ $ins['nomAppscheme'] = $table;
+ } elseif ($force == true) {
+ $ins['idappscheme'] = (int)$test_appscheme['idappscheme'];
+ $ins['codeAppscheme'] = $table;
+ unset($ins['_id']);
+ } else {
+ // return false;
+ $ins['idappscheme'] = (int)$test_appscheme['idappscheme'];
+ $ins['codeAppscheme'] = $table;
+ unset($ins['_id']);
+ }
+
+ if (!empty($options['has'])) {
+ foreach ($options['has'] as $key => $value) {
+ $ins['has' . ucfirst($value) . 'Scheme'] = 1;
+ }
+ unset($options['has']);
+ }
+
+ if (!empty($options['is'])) {
+ foreach ($options['is'] as $key => $value) {
+ $ins['is' . ucfirst($value) . ucfirst($table)] = 1;
+ }
+ unset($options['is']);
+ }
+
+ if (!empty($options['fields'])) {
+ foreach ($options['fields'] as $key => $value) {
+ $this->init_scheme_has_field($table, $value);
+ }
+ unset($options['fields']);
+ }
+ if (!empty($options['grilleFK'])) { // should exists in the same base
+ $ARRFK = [];
+ foreach ($options['grilleFK'] as $key => $value) {
+ $ARRFK [(int)$key] = ['table' => $value,
+ 'ordreTable' => (int)$key,
+ 'uid' => uniqid()];
+ }
+ $ins['grilleFK'] = $ARRFK;
+ unset($options['grilleFK']);
+ }
+
+ $ins = array_filter($ins);
+
+ $this->appscheme_model_instance->update(['idappscheme' => $ins['idappscheme']], ['$set' => $ins], ['upsert' => true]);
+
+ $this->init_scheme_droits($ins['idappscheme']);
+
+ return new App($table);
+ }
+ }
diff --git a/web/bin/views/IdaeView.php b/web/bin/views/IdaeView.php
index 129ca84..948c04f 100644
--- a/web/bin/views/IdaeView.php
+++ b/web/bin/views/IdaeView.php
@@ -1,181 +1,181 @@
-type_session;
-
- $options = ['apply_droit' => [$type_session,
- 'C'],
- 'data_mode' => 'fiche',
- 'scheme_field_view' => 'native',
- 'field_draw_style' => 'draw_html_input',
- 'scheme_field_view_groupby' => 'group',
- 'fields_scheme_part' => 'all',
- 'field_composition' => ['hide_field_icon' => 1,
- 'hide_field_name' => 1,
- 'hide_field_value' => 1]];
-
- $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
- $Fabric->init_app_fields();
- $tplData = $Fabric->get_templateData();
-
- $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
- $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
- $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
-
- }
-
- static public function fiche($table, $table_value, $type_session = null) {
-
- $Session = IdaeSession::getInstance();
- $type_session = $type_session ?: $Session->type_session;
-
- $Idae = Idae::getInstance($table);
- $IdaeDataDB = IdaeDB::getInstance($table);
-
- $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
-
- $options = ['apply_droit' => [$type_session,
- 'R'],
- 'data_mode' => 'fiche',
- 'scheme_field_view' => 'native',
- 'field_draw_style' => 'draw_html_field',
- 'scheme_field_view_groupby' => 'group',
- 'fields_scheme_part' => 'all',
- 'field_composition' => ['hide_field_icon' => 1,
- 'hide_field_name' => 1,
- 'hide_field_value' => 1]];
-
- $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
-
- $Fabric->fetch_query($ARR, 'findOne');
- $tplData = $Fabric->get_templateDataHTML();
-
- $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
- $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
- $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
- $parameters['scheme_field_rfk'] = $tplData['scheme_field_rfk'];
-
- $parameters['fiche_entete'] = $Idae->module('fiche_entete', ['table' => $table,
- 'table_value' => $table_value]);
- $parameters['fiche_ligne'] = $Idae->module('app_fiche/fiche_ligne', ['table' => $table . '_ligne',
- 'vars' => ["id$table" => $table_value]]);
-
- }
-
- static public function update($table, $table_value, $type_session = null) {
-
- $Session = IdaeSession::getInstance();
- $type_session = $type_session ?: $Session->type_session;
-
- $Idae = Idae::getInstance($table);
- $IdaeDataDB = IdaeDB::getInstance($table);
-
- $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
-
- $options = ['apply_droit' => [$type_session,
- 'U'],
- 'data_mode' => 'fiche',
- 'scheme_field_view' => 'native',
- 'field_draw_style' => 'draw_html_input',
- 'scheme_field_view_groupby' => 'group',
- 'fields_scheme_part' => 'all',
- 'hide_field_empty' => 0,
- 'hide_field_icon' => 0,
- 'hide_field_name' => 0,
- 'hide_field_value' => 0,
- 'field_composition' => ['hide_field_icon' => 0,
- 'hide_field_name' => 0,
- 'hide_field_value' => 0]];
-
- $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
- $Fabric->fetch_query($ARR, 'findOne');
- $tplData = $Fabric->get_templateData();
-
- $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
- $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
- $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
- $parameters['scheme_field_image'] = $tplData['scheme_field_image'];
-
- $parameters['fiche_entete'] = $Idae->module('fiche_entete', ['table' => $table,
- 'table_value' => $table_value]);
- }
-
- public function liste($table, $query_vars = [], $type_session = null) {
-
- $Session = IdaeSession::getInstance();
- $type_session = $type_session ?: $Session->type_session;
-
- $options = ['apply_droit' => [$type_session,
- 'R'],
- 'data_mode' => 'liste',
- 'scheme_field_view' => 'mini',
- 'field_draw_style' => 'draw_html_field',
- 'fields_scheme_part' => 'main',
- 'hide_field_empty' => 1,
- 'hide_field_icon' => 1,
- 'hide_field_name' => 1,
- 'hide_field_value' => 1,
- 'field_composition' => ['hide_field_icon' => 1,
- 'hide_field_name' => 1,
- 'hide_field_value' => 1]];
-
- $app = new IdaeDB($table);
- $arr = $app->findOne([]);
-
- $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
- $Fabric->fetch_data([]);
- $tplData = $Fabric->get_templateData();
-
- $out = '';
- foreach ($tplData as $index => $row) {
- $out .= $row['scheme_field_short'];
- }
-
- return $out;
- }
-
- static public function delete($table, $table_value) {
-
- $Session = IdaeSession::getInstance();
- $type_session = $Session->type_session;
-
- $Idae = Idae::getInstance($table);
- $IdaeDataDB = IdaeDB::getInstance($table);
-
- $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
-
- $options = ['apply_droit' => [$type_session,
- 'R'],
- 'data_mode' => 'fiche',
- 'scheme_field_view' => 'native',
- 'field_draw_style' => 'draw_html_field',
- 'scheme_field_view_groupby' => 'group',
- 'fields_scheme_part' => 'all',
- 'field_composition' => ['hide_field_icon' => 1,
- 'hide_field_name' => 1,
- 'hide_field_value' => 1]];
-
- $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
-
- $Fabric->fetch_query($ARR, 'findOne');
- $tplData = $Fabric->get_templateDataHTML();
-
- $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
- $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
- $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
- $parameters['scheme_field_rfk'] = $tplData['scheme_field_rfk'];
-
- $parameters['fiche_entete'] = $Idae->module('fiche_entete', ['table' => $table,
- 'table_value' => $table_value]);
- $parameters['fiche_ligne'] = $Idae->module('app_fiche/fiche_ligne', ['table' => $table . '_ligne',
- 'vars' => ["id$table" => $table_value]]);
- }
- }
+type_session;
+
+ $options = ['apply_droit' => [$type_session,
+ 'C'],
+ 'data_mode' => 'fiche',
+ 'scheme_field_view' => 'native',
+ 'field_draw_style' => 'draw_html_input',
+ 'scheme_field_view_groupby' => 'group',
+ 'fields_scheme_part' => 'all',
+ 'field_composition' => ['hide_field_icon' => 1,
+ 'hide_field_name' => 1,
+ 'hide_field_value' => 1]];
+
+ $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
+ $Fabric->init_app_fields();
+ $tplData = $Fabric->get_templateData();
+
+ $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
+ $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
+ $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
+
+ }
+
+ static public function fiche($table, $table_value, $type_session = null) {
+
+ $Session = IdaeSession::getInstance();
+ $type_session = $type_session ?: $Session->type_session;
+
+ $Idae = Idae::getInstance($table);
+ $IdaeDataDB = IdaeDB::getInstance($table);
+
+ $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
+
+ $options = ['apply_droit' => [$type_session,
+ 'R'],
+ 'data_mode' => 'fiche',
+ 'scheme_field_view' => 'native',
+ 'field_draw_style' => 'draw_html_field',
+ 'scheme_field_view_groupby' => 'group',
+ 'fields_scheme_part' => 'all',
+ 'field_composition' => ['hide_field_icon' => 1,
+ 'hide_field_name' => 1,
+ 'hide_field_value' => 1]];
+
+ $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
+
+ $Fabric->fetch_query($ARR, 'findOne');
+ $tplData = $Fabric->get_templateDataHTML();
+
+ $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
+ $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
+ $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
+ $parameters['scheme_field_rfk'] = $tplData['scheme_field_rfk'];
+
+ $parameters['fiche_entete'] = $Idae->module('fiche_entete', ['table' => $table,
+ 'table_value' => $table_value]);
+ $parameters['fiche_ligne'] = $Idae->module('app_fiche/fiche_ligne', ['table' => $table . '_ligne',
+ 'vars' => ["id$table" => $table_value]]);
+
+ }
+
+ static public function update($table, $table_value, $type_session = null) {
+
+ $Session = IdaeSession::getInstance();
+ $type_session = $type_session ?: $Session->type_session;
+
+ $Idae = Idae::getInstance($table);
+ $IdaeDataDB = IdaeDB::getInstance($table);
+
+ $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
+
+ $options = ['apply_droit' => [$type_session,
+ 'U'],
+ 'data_mode' => 'fiche',
+ 'scheme_field_view' => 'native',
+ 'field_draw_style' => 'draw_html_input',
+ 'scheme_field_view_groupby' => 'group',
+ 'fields_scheme_part' => 'all',
+ 'hide_field_empty' => 0,
+ 'hide_field_icon' => 0,
+ 'hide_field_name' => 0,
+ 'hide_field_value' => 0,
+ 'field_composition' => ['hide_field_icon' => 0,
+ 'hide_field_name' => 0,
+ 'hide_field_value' => 0]];
+
+ $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
+ $Fabric->fetch_query($ARR, 'findOne');
+ $tplData = $Fabric->get_templateData();
+
+ $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
+ $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
+ $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
+ $parameters['scheme_field_image'] = $tplData['scheme_field_image'];
+
+ $parameters['fiche_entete'] = $Idae->module('fiche_entete', ['table' => $table,
+ 'table_value' => $table_value]);
+ }
+
+ public function liste($table, $query_vars = [], $type_session = null) {
+
+ $Session = IdaeSession::getInstance();
+ $type_session = $type_session ?: $Session->type_session;
+
+ $options = ['apply_droit' => [$type_session,
+ 'R'],
+ 'data_mode' => 'liste',
+ 'scheme_field_view' => 'mini',
+ 'field_draw_style' => 'draw_html_field',
+ 'fields_scheme_part' => 'main',
+ 'hide_field_empty' => 1,
+ 'hide_field_icon' => 1,
+ 'hide_field_name' => 1,
+ 'hide_field_value' => 1,
+ 'field_composition' => ['hide_field_icon' => 1,
+ 'hide_field_name' => 1,
+ 'hide_field_value' => 1]];
+
+ $app = new IdaeDB($table);
+ $arr = $app->findOne([]);
+
+ $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
+ $Fabric->fetch_data([]);
+ $tplData = $Fabric->get_templateData();
+
+ $out = '';
+ foreach ($tplData as $index => $row) {
+ $out .= $row['scheme_field_short'];
+ }
+
+ return $out;
+ }
+
+ static public function delete($table, $table_value) {
+
+ $Session = IdaeSession::getInstance();
+ $type_session = $Session->type_session;
+
+ $Idae = Idae::getInstance($table);
+ $IdaeDataDB = IdaeDB::getInstance($table);
+
+ $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
+
+ $options = ['apply_droit' => [$type_session,
+ 'R'],
+ 'data_mode' => 'fiche',
+ 'scheme_field_view' => 'native',
+ 'field_draw_style' => 'draw_html_field',
+ 'scheme_field_view_groupby' => 'group',
+ 'fields_scheme_part' => 'all',
+ 'field_composition' => ['hide_field_icon' => 1,
+ 'hide_field_name' => 1,
+ 'hide_field_value' => 1]];
+
+ $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $options);
+
+ $Fabric->fetch_query($ARR, 'findOne');
+ $tplData = $Fabric->get_templateDataHTML();
+
+ $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
+ $parameters['scheme_field_fk_grouped'] = $tplData['scheme_field_fk_grouped'];
+ $parameters['scheme_field_fk_nongrouped'] = $tplData['scheme_field_fk_nongrouped'];
+ $parameters['scheme_field_rfk'] = $tplData['scheme_field_rfk'];
+
+ $parameters['fiche_entete'] = $Idae->module('fiche_entete', ['table' => $table,
+ 'table_value' => $table_value]);
+ $parameters['fiche_ligne'] = $Idae->module('app_fiche/fiche_ligne', ['table' => $table . '_ligne',
+ 'vars' => ["id$table" => $table_value]]);
+ }
+ }
diff --git a/web/bin/views/IdaeViewPart.php b/web/bin/views/IdaeViewPart.php
index 4aadd18..1732c5e 100644
--- a/web/bin/views/IdaeViewPart.php
+++ b/web/bin/views/IdaeViewPart.php
@@ -1,67 +1,67 @@
-set_defaultFabricOptions();
-
- }
-
- function getPart($part,$table) {
-
- }
-
- public function field_native($table, $table_value) {
-
- $this->defaultFabricOptions->set_option('data_mode', 'fiche');
- $this->defaultFabricOptions->set_option('scheme_field_view', 'native');
- $this->defaultFabricOptions->set_option('scheme_field_view_groupby', 'group');
- $this->defaultFabricOptions->set_option('apply_droit', [IdaeSession::getInstance()->type_session,
- $this->crudCode]);
- $IdaeDataDB = IdaeDB::getInstance($table);
- $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
- $Fabric = $this->getFabric($table, 'findOne', $ARR);
-
- $tplData = $Fabric->get_templateDataHTML();
-
- $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
- }
-
- private function getFabric($table, $data_mode = 'findOne', $resultset) {
-
- $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $this->defaultFabricOptions);
- $Fabric->fetch_query($resultset, $data_mode);
-
- return $Fabric;
- }
-
- private function fields($type = 'native') {
-
- }
-
- private function set_defaultFabricOptions() {
- $this->defaultFabricOptions = new IdaeDataSchemeFieldDrawerFabricOption();
- $this->defaultFabricOptions->set_options(['field_draw_style' => $this->drawMode,
- 'fields_scheme_part' => 'main']);
- }
- }
+set_defaultFabricOptions();
+
+ }
+
+ function getPart($part,$table) {
+
+ }
+
+ public function field_native($table, $table_value) {
+
+ $this->defaultFabricOptions->set_option('data_mode', 'fiche');
+ $this->defaultFabricOptions->set_option('scheme_field_view', 'native');
+ $this->defaultFabricOptions->set_option('scheme_field_view_groupby', 'group');
+ $this->defaultFabricOptions->set_option('apply_droit', [IdaeSession::getInstance()->type_session,
+ $this->crudCode]);
+ $IdaeDataDB = IdaeDB::getInstance($table);
+ $ARR = $IdaeDataDB->findOne(["id$table" => (int)$table_value]);
+ $Fabric = $this->getFabric($table, 'findOne', $ARR);
+
+ $tplData = $Fabric->get_templateDataHTML();
+
+ $parameters['scheme_field_native'] = $tplData['scheme_field_native'];
+ }
+
+ private function getFabric($table, $data_mode = 'findOne', $resultset) {
+
+ $Fabric = new IdaeDataSchemeFieldDrawerFabric($table, $this->defaultFabricOptions);
+ $Fabric->fetch_query($resultset, $data_mode);
+
+ return $Fabric;
+ }
+
+ private function fields($type = 'native') {
+
+ }
+
+ private function set_defaultFabricOptions() {
+ $this->defaultFabricOptions = new IdaeDataSchemeFieldDrawerFabricOption();
+ $this->defaultFabricOptions->set_options(['field_draw_style' => $this->drawMode,
+ 'fields_scheme_part' => 'main']);
+ }
+ }
diff --git a/web/conf.inc.php b/web/conf.inc.php
index d933b98..eddb19a 100644
--- a/web/conf.inc.php
+++ b/web/conf.inc.php
@@ -1,47 +1,47 @@
-getSchemeBaseList();
-
- foreach ($schemeList as $list) {
- var_dump($list['nomAppscheme_base']);
- }*/
-
- // $dataScheme;
- // use Idae\Generator\IdaeGeneratorAppClass;
-
- /*$generator = new IdaeGeneratorAppClass();
- $generator->init();
- $generator->travel();*/
-
+getSchemeBaseList();
+
+ foreach ($schemeList as $list) {
+ var_dump($list['nomAppscheme_base']);
+ }*/
+
+ // $dataScheme;
+ // use Idae\Generator\IdaeGeneratorAppClass;
+
+ /*$generator = new IdaeGeneratorAppClass();
+ $generator->init();
+ $generator->travel();*/
+
diff --git a/web/info.php b/web/info.php
index f35a8ef..7807d67 100644
--- a/web/info.php
+++ b/web/info.php
@@ -1,3 +1,3 @@
-find();
- while ($arr = $rs->getNext()) {
- $idsecteur = (int)$arr['idsecteur'];
- $CommandeSlot = new CommandeSlot($idsecteur);
- $CommandeSlot->distribute($idsecteur);
- $CommandeSlot->draw_debug();
- }
-
-
-
- exit;
- echo ceil(time() - strtotime('2018/07/06 14:52:00')) / 60;
-
- $arr_shops = ['LAMALO', 'PAULE', 'THAI', 'JUSOCT'];
- $arr_commandes = [];
-
- $tot_commande = 0;
- foreach ($arr_shops as $index => $shop) {
- $nbcommand = rand(1, 4);
- $from_command = rand(1, 3);
- $i = 1;
- while ($i <= $nbcommand && $tot_commande <= 12) {
- $code = '#' . sprintf("%03d", $i + $from_command);
- $rang = "S$i";
- $slot = "R$i";
- $arr_commandes[] = ['shop' => $shop, 'code' => $code, 'S' => $rang, 'R' => $slot];
- $arr_commandes_1[$shop][] = "$shop [ $code , $rang , $slot ]";
- $arr_commandes_2[$rang][] = "$rang [$shop $code , $slot ]";
- ++$i;
- ++$tot_commande;
- }
- }
-
- /*var_dump($arr_commandes_1);
- var_dump($arr_commandes_2);*/
-
- $adadou = array_column($arr_commandes, 'S');
- $ADADA = array_count_values($adadou);
-
- var_dump($ADADA);
-
- //$Demo = new Demo();
- //$Demo->launch_demo();
-
- /*var_dump($arr_values_1);
- var_dump($arr_values_2);
- var_dump($arr_values_3);*/
-
- /*$test = $app->get_schemeFields();
- Helper::dump($test);
- $test = $app->get_schemeFieldsMini();
- Helper::dump($test);
- $test = $app->get_schemeFieldsTable();
- Helper::dump($test);
- $test = $app->get_schemeFieldsFk();
- Helper::dump($test);*/
- // $test = $app->get_schemeFieldsTyped();
- // $app->draw_current_field_collection();
- exit;
- IdaeConnect::getInstance()->connect();
-
- $app = new App('produit');
-
- Helper::dump($app->findOne([]));
- exit;
- $test = IdaeDroitsFields::getInstance()->droit_session_table_crud("shop", "commande", "U");
-
- Helper::dump($test);
-
- exit;
- $Demo = new Demo();
-
- $Demo->create_affectation_period();
-
- $Bin = new Bin();
-
- $test = $Bin->test_livreur_affect(59829);
- //$Dispatch->test_livreur_affect(54155);
-
- Helper::dump($test);
-
- $Demo = new Demo();
- $Demo->create_secteur_shift();
-
- $Dispatch = new Dispatch();
- exit;
- $table_value = 54155;
- $APP_COMMANDE_PROPOSITION = new App('commande_proposition');
- $APP_COMMANDE = new App('commande');
-
- $ARR_COMMANDE = $APP_COMMANDE->findOne(['idcommande' => (int)$table_value]);
-
- $room_shop = 'shop_' . $ARR_COMMANDE['idshop'];
- $room_livreur = 'livreur_' . $ARR_COMMANDE['idlivreur'];
-
- exit;
- $Notify = new Notify();
- $Notify->notify_commande_shop(1);
-
- /*SendCmd::insert_mdl('app_console_thumb', 'commande', 136, ['data-table' => 'commande',
- 'data-type_session' => 'shop']);*/
-
- $Dispatch = new Dispatch();
- $Dispatch->propose_commande_shop(54159);
- // $Dispatch->propose_commande_secteur_all_pool();
-
- //$BIN = new Bin();
-
- //$arr = $BIN->get_estimation_wait_time_fields(1);
-
- Helper::dump($arr);
- $a = SendCmd::build_selector(['table' => 'commande',
- ['index' => 'delex',
- 'table_value' => 125]]);
-
- Helper::dump($a);
-
- exit;
- $Bin = new Bin();
-
- $Bin->get_elapsed_minutes_arr_for_commande(53369);
-
- exit;
-
- $Idae = new Idae('commande');
- $ARR_COLLECT = $Idae->get_table_fields($table_value, ['in_min_fiche' => 1]);
-
- $COLLECT_VALUES = array_values($ARR_COLLECT);
- $COLLECT_VALUES_COLUMN = array_column(array_values($ARR_COLLECT), 'appscheme_fields');
- $COLLECT_VALUES_COLUMN_VALUES = array_values($COLLECT_VALUES_COLUMN);
-
- $COLLECT_FIELDS = [];
- foreach ($ARR_COLLECT as $key => $ARR_FIELD_GROUP) {
- foreach ($ARR_FIELD_GROUP['appscheme_fields'] as $CODE_ARR_FIELD => $ARR_FIELD) {
- $COLLECT_FIELDS[] = $ARR_FIELD;
- }
-
- }
-
- Helper::dump($COLLECT_FIELDS);
-
- exit;
- $table = 'commande';
- $table_value = 52646;
- $Table = ucfirst($table);
-
- $Idae = new Idae($table);
- $AppMail = new AppMail();
- $instyle = new InStyle();
- $Idae->consolidate_scheme($table_value);
- $ARR_COMMANDE = $Idae->findOne(["id$table" => (int)$table_value]);
- $Body = $instyle->convert($Idae->fiche_mail($table_value), true);
- /*$AppMail->set_body($Body);
- $AppMail->set_destinataire_email($ARR_COMMANDE["email$Table"]?:'m.mydde@gmail.com');
- $AppMail->set_destinataire_name($ARR_COMMANDE["prenom$Table"].' '.$ARR_COMMANDE["nom$Table"]);
- $AppMail->set_subject('Votre commande '.$ARR_COMMANDE["code$Table"].' avec TAC-TAC');
- $AppMail->sendMail();*/
-
- echo $Body;
- /*echo $Idae->module('app_fiche/app_fiche_mail', ['table' => 'commande',
- 'table_value' => 52557]);*/
-
- exit;
-
-
-
-
-
-
-
-
+find();
+ while ($arr = $rs->getNext()) {
+ $idsecteur = (int)$arr['idsecteur'];
+ $CommandeSlot = new CommandeSlot($idsecteur);
+ $CommandeSlot->distribute($idsecteur);
+ $CommandeSlot->draw_debug();
+ }
+
+
+
+ exit;
+ echo ceil(time() - strtotime('2018/07/06 14:52:00')) / 60;
+
+ $arr_shops = ['LAMALO', 'PAULE', 'THAI', 'JUSOCT'];
+ $arr_commandes = [];
+
+ $tot_commande = 0;
+ foreach ($arr_shops as $index => $shop) {
+ $nbcommand = rand(1, 4);
+ $from_command = rand(1, 3);
+ $i = 1;
+ while ($i <= $nbcommand && $tot_commande <= 12) {
+ $code = '#' . sprintf("%03d", $i + $from_command);
+ $rang = "S$i";
+ $slot = "R$i";
+ $arr_commandes[] = ['shop' => $shop, 'code' => $code, 'S' => $rang, 'R' => $slot];
+ $arr_commandes_1[$shop][] = "$shop [ $code , $rang , $slot ]";
+ $arr_commandes_2[$rang][] = "$rang [$shop $code , $slot ]";
+ ++$i;
+ ++$tot_commande;
+ }
+ }
+
+ /*var_dump($arr_commandes_1);
+ var_dump($arr_commandes_2);*/
+
+ $adadou = array_column($arr_commandes, 'S');
+ $ADADA = array_count_values($adadou);
+
+ var_dump($ADADA);
+
+ //$Demo = new Demo();
+ //$Demo->launch_demo();
+
+ /*var_dump($arr_values_1);
+ var_dump($arr_values_2);
+ var_dump($arr_values_3);*/
+
+ /*$test = $app->get_schemeFields();
+ Helper::dump($test);
+ $test = $app->get_schemeFieldsMini();
+ Helper::dump($test);
+ $test = $app->get_schemeFieldsTable();
+ Helper::dump($test);
+ $test = $app->get_schemeFieldsFk();
+ Helper::dump($test);*/
+ // $test = $app->get_schemeFieldsTyped();
+ // $app->draw_current_field_collection();
+ exit;
+ IdaeConnect::getInstance()->connect();
+
+ $app = new App('produit');
+
+ Helper::dump($app->findOne([]));
+ exit;
+ $test = IdaeDroitsFields::getInstance()->droit_session_table_crud("shop", "commande", "U");
+
+ Helper::dump($test);
+
+ exit;
+ $Demo = new Demo();
+
+ $Demo->create_affectation_period();
+
+ $Bin = new Bin();
+
+ $test = $Bin->test_livreur_affect(59829);
+ //$Dispatch->test_livreur_affect(54155);
+
+ Helper::dump($test);
+
+ $Demo = new Demo();
+ $Demo->create_secteur_shift();
+
+ $Dispatch = new Dispatch();
+ exit;
+ $table_value = 54155;
+ $APP_COMMANDE_PROPOSITION = new App('commande_proposition');
+ $APP_COMMANDE = new App('commande');
+
+ $ARR_COMMANDE = $APP_COMMANDE->findOne(['idcommande' => (int)$table_value]);
+
+ $room_shop = 'shop_' . $ARR_COMMANDE['idshop'];
+ $room_livreur = 'livreur_' . $ARR_COMMANDE['idlivreur'];
+
+ exit;
+ $Notify = new Notify();
+ $Notify->notify_commande_shop(1);
+
+ /*SendCmd::insert_mdl('app_console_thumb', 'commande', 136, ['data-table' => 'commande',
+ 'data-type_session' => 'shop']);*/
+
+ $Dispatch = new Dispatch();
+ $Dispatch->propose_commande_shop(54159);
+ // $Dispatch->propose_commande_secteur_all_pool();
+
+ //$BIN = new Bin();
+
+ //$arr = $BIN->get_estimation_wait_time_fields(1);
+
+ Helper::dump($arr);
+ $a = SendCmd::build_selector(['table' => 'commande',
+ ['index' => 'delex',
+ 'table_value' => 125]]);
+
+ Helper::dump($a);
+
+ exit;
+ $Bin = new Bin();
+
+ $Bin->get_elapsed_minutes_arr_for_commande(53369);
+
+ exit;
+
+ $Idae = new Idae('commande');
+ $ARR_COLLECT = $Idae->get_table_fields($table_value, ['in_min_fiche' => 1]);
+
+ $COLLECT_VALUES = array_values($ARR_COLLECT);
+ $COLLECT_VALUES_COLUMN = array_column(array_values($ARR_COLLECT), 'appscheme_fields');
+ $COLLECT_VALUES_COLUMN_VALUES = array_values($COLLECT_VALUES_COLUMN);
+
+ $COLLECT_FIELDS = [];
+ foreach ($ARR_COLLECT as $key => $ARR_FIELD_GROUP) {
+ foreach ($ARR_FIELD_GROUP['appscheme_fields'] as $CODE_ARR_FIELD => $ARR_FIELD) {
+ $COLLECT_FIELDS[] = $ARR_FIELD;
+ }
+
+ }
+
+ Helper::dump($COLLECT_FIELDS);
+
+ exit;
+ $table = 'commande';
+ $table_value = 52646;
+ $Table = ucfirst($table);
+
+ $Idae = new Idae($table);
+ $AppMail = new AppMail();
+ $instyle = new InStyle();
+ $Idae->consolidate_scheme($table_value);
+ $ARR_COMMANDE = $Idae->findOne(["id$table" => (int)$table_value]);
+ $Body = $instyle->convert($Idae->fiche_mail($table_value), true);
+ /*$AppMail->set_body($Body);
+ $AppMail->set_destinataire_email($ARR_COMMANDE["email$Table"]?:'m.mydde@gmail.com');
+ $AppMail->set_destinataire_name($ARR_COMMANDE["prenom$Table"].' '.$ARR_COMMANDE["nom$Table"]);
+ $AppMail->set_subject('Votre commande '.$ARR_COMMANDE["code$Table"].' avec TAC-TAC');
+ $AppMail->sendMail();*/
+
+ echo $Body;
+ /*echo $Idae->module('app_fiche/app_fiche_mail', ['table' => 'commande',
+ 'table_value' => 52557]);*/
+
+ exit;
+
+
+
+
+
+
+
+
diff --git a/web/vhosts.conf b/web/vhosts.conf
index a7848ae..ac43eee 100644
--- a/web/vhosts.conf
+++ b/web/vhosts.conf
@@ -1,16 +1,16 @@
-
-
- DocumentRoot "{DOCUMENTPATH}/tac-tac.lan/web"
- ServerName "tac-tac.lan"
- ServerAlias "*.tac-tac.lan"
-
- RewriteEngine On
- RewriteCond %{REQUEST_URI} ^/socket.io [NC]
- RewriteCond %{QUERY_STRING} transport=websocket [NC]
- RewriteRule /(.*) ws://tac-tac.lan:3008/$1 [P,L]
-
-
- AllowOverride All
- Options FollowSymLinks Includes Indexes MultiViews
-
-
+
+
+ DocumentRoot "{DOCUMENTPATH}/tac-tac.lan/web"
+ ServerName "tac-tac.lan"
+ ServerAlias "*.tac-tac.lan"
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} ^/socket.io [NC]
+ RewriteCond %{QUERY_STRING} transport=websocket [NC]
+ RewriteRule /(.*) ws://tac-tac.lan:3008/$1 [P,L]
+
+
+ AllowOverride All
+ Options FollowSymLinks Includes Indexes MultiViews
+
+