correction sur les comptyeurs de tailel de tableaux
This commit is contained in:
@@ -13,10 +13,7 @@ function tri_chap_2($a , $b)
|
||||
if ('S'.$a['instruction'] < 'S'.$b['instruction']) return -1;
|
||||
if ('S'.$a['instruction'] > 'S'.$b['instruction']) return 1;
|
||||
|
||||
if ('S'.$a['code'] < 'S'.$b['code']) return -1;
|
||||
if ('S'.$a['code'] > 'S'.$b['code']) return 1;
|
||||
|
||||
return 0;
|
||||
return tri_chap_1($a , $b);
|
||||
}
|
||||
|
||||
require_once('smeti_db.inc.php');
|
||||
@@ -33,20 +30,21 @@ echo 'Chargement collectivités ';
|
||||
$sql = SMETI_db::$pdo->prepare("SELECT code, item, libelle FROM v_items WHERE plugin = ( SELECT id FROM plugins WHERE libelle = 'Collectivités' )");
|
||||
$sql->execute();
|
||||
$coll = $sql->fetchAll(PDO::FETCH_NUM);
|
||||
$nb_coll = count($coll);
|
||||
echo 'OK'.PHP_EOL;
|
||||
|
||||
echo 'Chargement instructions comptables ';
|
||||
$sql = SMETI_db::$pdo->prepare("SELECT code, id, libelle FROM v_items_tree WHERE parent in ( SELECT id FROM v_items WHERE code = 'INSC' )");
|
||||
$sql->execute();
|
||||
$instructions = $sql->fetchAll(PDO::FETCH_NUM);
|
||||
$nb_instructions = count($instructions);
|
||||
echo 'OK'.PHP_EOL;
|
||||
|
||||
// Se positonner sur l'instruction globale
|
||||
$n = count($instructions);
|
||||
for($i=0;$i<$n;$i++)
|
||||
for($i=0;$i<$nb_instructions;$i++)
|
||||
if ($instructions[$i][0] == 'INSCGLOB')
|
||||
break;
|
||||
if ($i == $n) die;
|
||||
if ($i == $nb_instructions) die;
|
||||
|
||||
$pile_index = 0;
|
||||
$pile_code[$pile_index] = $instructions[$i][0];
|
||||
@@ -79,8 +77,9 @@ $nb_shipments = count($shipments);
|
||||
usort($shipments,'tri_chap_1');
|
||||
// On conserve les chapitres dans un tableau
|
||||
// Ils seront réutilisés plus tard
|
||||
$foncitons = [];
|
||||
$fonctions = [];
|
||||
$fonctions[] = ['BIDON','BIDON'];
|
||||
$record = 0;
|
||||
foreach($shipments as $element)
|
||||
{
|
||||
// Gestion d'une barre de progression
|
||||
@@ -110,8 +109,8 @@ foreach($shipments as $element)
|
||||
SMETI_db::$child = SMETI_db::$pdo->lastInsertId();
|
||||
SMETI_db::$parent = $pile_item[$pile_index];
|
||||
SMETI_db::$req3->execute();
|
||||
|
||||
$fonctions[] = [SMETI_db::$code, SMETI_db::$libelle, SMETI_db::$item];
|
||||
$fonctions[] = [$element['code'], SMETI_db::$libelle, SMETI_db::$item];
|
||||
$record += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +127,11 @@ $pile_index += 1;
|
||||
$pile_code[$pile_index] = '';
|
||||
$pile_item[$pile_index] = 0;
|
||||
|
||||
$nb_fonctions = count($fonctions);
|
||||
|
||||
usort($shipments,'tri_chap_2');
|
||||
$n = count($fonctions);
|
||||
$counter = 0;
|
||||
$record = 0;
|
||||
foreach($shipments as $element)
|
||||
{
|
||||
// Gestion d'une barre de progression
|
||||
@@ -141,21 +142,20 @@ foreach($shipments as $element)
|
||||
if (!isset($element['code'])) continue;
|
||||
if (!isset($element['libelle'])) continue;
|
||||
|
||||
if ('INSC'.$element['instruction'] != $pile_code[$pile_index-1])
|
||||
if ($element['instruction'] != $pile_code[$pile_index-1])
|
||||
{
|
||||
// Se positonner sur l'instruction globale
|
||||
$n = count($instructions);
|
||||
for($i=0;$i<$n;$i++)
|
||||
if ($instructions[$i][0] == 'INSC'.$element['instruction'])
|
||||
// Se positonner sur l'instruction
|
||||
for($i=0;$i<$nb_instructions;$i++)
|
||||
if ($instructions[$i][0] == $element['instruction'])
|
||||
break;
|
||||
if ($i == $n) die;
|
||||
if ($i == $nb_instructions) continue;
|
||||
|
||||
$pile_index = 0;
|
||||
$pile_code[$pile_index] = $instructions[$i][0];
|
||||
$pile_item[$pile_index] = $instructions[$i][1];
|
||||
|
||||
// Rajouter un item pour les chapitres
|
||||
SMETI_db::$code = 'FONC'.$element['instruction'];
|
||||
// Rajouter un item pour les fonctions dans cette instruction
|
||||
SMETI_db::$code = 'FONC'.$element['instruction'];
|
||||
SMETI_db::$libelle = 'Fonctions '. $element['instruction'];
|
||||
SMETI_db::$req1->execute();
|
||||
// Rajouter un lien
|
||||
@@ -166,6 +166,7 @@ foreach($shipments as $element)
|
||||
SMETI_db::$child = SMETI_db::$pdo->lastInsertId();
|
||||
SMETI_db::$parent = $pile_item[$pile_index];
|
||||
SMETI_db::$req3->execute();
|
||||
|
||||
$pile_index += 1;
|
||||
$pile_code[$pile_index] = SMETI_db::$code;
|
||||
$pile_item[$pile_index] = SMETI_db::$child;
|
||||
@@ -173,13 +174,14 @@ foreach($shipments as $element)
|
||||
}
|
||||
|
||||
if ($element['code'] == $last) continue;
|
||||
for($i=0;$i<$n;$i++)
|
||||
if ($fonctions[$i][0] == $element['code'])
|
||||
break;
|
||||
if ($i == $n) continue;
|
||||
|
||||
// Rajouter un lien vers le chapitre
|
||||
SMETI_db::$item = $chapitres[$i][2];
|
||||
for($i=0;$i<$nb_fonctions;$i++)
|
||||
if ($fonctions[$i][0] == 'C'.$element['code'])
|
||||
break;
|
||||
if ($i == $nb_fonctions) continue;
|
||||
|
||||
// Rajouter un lien vers la fonction
|
||||
SMETI_db::$item = $fonctions[$i][2];
|
||||
SMETI_db::$link = 1;
|
||||
SMETI_db::$req2->execute();
|
||||
// Rajouter un noeud
|
||||
@@ -189,6 +191,7 @@ foreach($shipments as $element)
|
||||
|
||||
// NB : on pourrait s'en passer en plaçant le chapitre dans la pile
|
||||
$last = $element['code'];
|
||||
$record += 1;
|
||||
}
|
||||
|
||||
// Enlever la barre de progression
|
||||
|
||||
Reference in New Issue
Block a user