You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

664 lines
23 KiB

<?php
// IMPORT DES BIBLIOTHEQUES
require_once("../../base/php/startSession.php");
require_once("../../base/php/classDatabase.php");
require_once("../../base/php/Functions.php" );
require_once("../../base/php/WebAppLog.php");
// DECLARATION DES VARIABLES
$compress64 = true;
$database = new Database("iCTI");
$schema = "";
// RECUPERATION DES PARAMETRES HTTP
$tableName = getPOST("tableName");
$firstCall = getPOST("firstCall");
$updatedOids = getPOST("updatedOids");
// ECRITURE DE LA REPONSE HTTP
$httpString = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
$httpString .= "\n<HTTP_SERVICE>";
if ($tableName != "") {
$httpString .= getRecords($database, $tableName, $firstCall, $updatedOids);
}
$httpString .= "\n</HTTP_SERVICE>";
if ($compress64) {
$httpString = compress64($httpString);
}
echo "<CTICONTENT>$httpString</CTICONTENT>";
// DEFINITIONS DE FONCTION
/**
*
* @param Database $db
* @param string $tableName
* @return string
*/
function getRecords($db, $tableName, $firstCall=0, $updatedOids="") {
$httpString = '';
$sqlColumnAdd = '';
$sqlColumnComplement = "''::text";
$sqlTableJoin = "";
$sqlNbRefJoin = "";
$sqlSort = "$tableName.code";
$httpString_tmp = "";
if ($tableName == 't_articles') {
$sqlColumnAdd .= ",$tableName.gere_en_stock ";
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref ";
$sqlColumnAdd .= ",$tableName.article_reference_cacic_id AS cacic_id ";
$sqlColumnAdd .= ",$tableName.article_reference_cti_id AS rfcti_id ";
$sqlColumnComplement = "COALESCE(t_types_articles.texte,'')";
$sqlColumnComplement .= " || ' ' || COALESCE('(Ref:' || t_article_reference_cacic.code || ')','')";
$sqlColumnComplement .= " || ' ' || COALESCE('(Ref:' || t_article_reference_cti.code || ')','')";
$sqlColumnComplement .= " || ' ' || CASE WHEN $tableName.gere_en_stock IS DISTINCT FROM '0' THEN ''::text ELSE '(Non Géré en stock)'::text END";
$sqlTableJoin = "LEFT JOIN eco.t_types_articles ON $tableName.type_id = t_types_articles.oid AND $tableName.type_id <> 0 ";
$sqlTableJoin .= "LEFT JOIN eco.t_article_reference_cacic ON $tableName.article_reference_cacic_id = t_article_reference_cacic.oid AND $tableName.article_reference_cacic_id <> 0 ";
$sqlTableJoin .= "LEFT JOIN eco.t_article_reference_cti ON $tableName.article_reference_cti_id = t_article_reference_cti.oid AND $tableName.article_reference_cti_id <> 0 ";
$sqlNbRefJoin = "LEFT JOIN (SELECT article_id AS subview_nbref_id, count(*) AS nbref FROM eco.p_lignes_commandes GROUP BY 1) subview_nbref ON t_articles.oid = subview_nbref_id";
$sqlSort = "$tableName.texte";
}
if ($tableName == 't_types_articles') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlColumnAdd .= ",defaut_selon";
$sqlColumnAdd .= ",defaut_selon_codes";
$sqlNbRefJoin = "LEFT JOIN (SELECT type_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_articles GROUP BY 1) subview_nbref ON t_types_articles.oid = subview_nbref_id";
}
if ($tableName == 't_familles_articles') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlNbRefJoin = "LEFT JOIN (SELECT famille_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_articles GROUP BY 1) subview_nbref ON t_familles_articles.oid = subview_nbref_id";
}
if ($tableName == 't_sous_familles_articles') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlNbRefJoin = "LEFT JOIN (SELECT sous_famille_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_articles GROUP BY 1) subview_nbref ON t_sous_familles_articles.oid = subview_nbref_id";
}
if ($tableName == 't_categories_articles') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlNbRefJoin = "LEFT JOIN (SELECT categorie_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_articles GROUP BY 1) subview_nbref ON t_categories_articles.oid = subview_nbref_id";
}
if ($tableName == 't_sous_categories_articles') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlNbRefJoin = "LEFT JOIN (SELECT sous_categorie_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_articles GROUP BY 1) subview_nbref ON t_sous_categories_articles.oid = subview_nbref_id";
}
if ($tableName == 't_fournisseurs') {
$sqlColumnAdd .= ",COALESCE(nbref,0)+COALESCE(nbref2,0) AS nbref, $tableName.fournisseur_reference_cacic_id AS cacic_id, $tableName.fournisseur_reference_cti_id AS rfcti, $tableName.fusionner_vers_fournisseur_id";
$sqlColumnComplement = "CASE WHEN $tableName.fusionner_vers_fournisseur_id > 0 THEN 'Fusionné vers '|| COALESCE(t_fournisseurs_fusion.texte || ' ('||t_fournisseurs_fusion.code||'/'||t_fournisseurs_fusion.code_original||')','?') ELSE COALESCE('CMD : '||to_char(date_commande_last,'YYYY/MM'),'') || ' ' || COALESCE('MVT : '||to_char(date_mouvement_last,'YYYY/MM'),'')END";
$sqlTableJoin .= "LEFT JOIN eco.t_fournisseur_reference_cacic ON $tableName.fournisseur_reference_cacic_id = t_fournisseur_reference_cacic.oid AND $tableName.fournisseur_reference_cacic_id <> 0 ";
$sqlTableJoin .= "LEFT JOIN eco.t_fournisseur_reference_cti ON $tableName.fournisseur_reference_cti_id = t_fournisseur_reference_cti.oid AND $tableName.fournisseur_reference_cti_id <> 0 ";
$sqlNbRefJoin = "LEFT JOIN (SELECT fournisseur_id AS subview_nbref_id, count(*) AS nbref, MAX(date_commande) AS date_commande_last FROM eco.p_commandes GROUP BY 1) subview_nbref ON t_fournisseurs.oid = subview_nbref_id";
$sqlNbRefJoin .= " LEFT JOIN (SELECT fournisseur_id AS subview_nbref2_id, count(*) AS nbref2, MAX(date) AS date_mouvement_last FROM eco.p_mouvements_articles GROUP BY 1) subview_nbref2 ON t_fournisseurs.oid = subview_nbref2_id";
$sqlTableJoin = "LEFT JOIN eco.t_fournisseurs t_fournisseurs_fusion ON $tableName.fusionner_vers_fournisseur_id = t_fournisseurs_fusion.oid";
$sqlSort = "$tableName.texte";
}
if ($tableName == 't_types_fournisseurs') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlNbRefJoin = "LEFT JOIN (SELECT type_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_fournisseurs GROUP BY 1) subview_nbref ON t_types_fournisseurs.oid = subview_nbref_id";
}
if ($tableName == 't_reference_input') {
$sqlColumnComplement = "CASE WHEN nb_lignes > 0 THEN 'Importé le ' || to_char(import_date,'DD/MM/YYYY') || ' (' || nb_lignes || ' lignes)' ELSE 'Vide' END";
}
if ($tableName == 't_article_reference_cacic') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlColumnComplement = "t_types_articles.texte";
$sqlNbRefJoin = "LEFT JOIN (SELECT article_reference_cacic_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_articles GROUP BY 1) subview_nbref ON t_article_reference_cacic.oid = subview_nbref_id";
$sqlTableJoin = "JOIN eco.t_types_articles ON $tableName.type_id = t_types_articles.oid";
$sqlSort = "$tableName.texte";
}
if ($tableName == 't_article_reference_cti') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlColumnAdd .= ", ','||COALESCE(subview_nbref.rfoids,'') AS rfoids";
$sqlColumnComplement = "CASE WHEN $tableName.type_id <> 0 THEN t_types_articles.texte ELSE '' END";
$sqlNbRefJoin = "LEFT JOIN (SELECT article_reference_cti_id AS subview_nbref_id, count(*) AS nbref, base.cti_group_concat_without_sep(texte || '(' || code || ')' || chr(13)) AS arlist, base.cti_group_concat_without_sep(t_articles.oid||',') AS rfoids FROM eco.t_articles GROUP BY 1) subview_nbref ON t_article_reference_cti.oid = subview_nbref_id";
$sqlTableJoin = "JOIN eco.t_types_articles ON $tableName.type_id = t_types_articles.oid";
$sqlSort = "$tableName.texte";
}
if ($tableName == 't_fournisseur_reference_cacic') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlNbRefJoin = "LEFT JOIN (SELECT fournisseur_reference_cacic_id AS subview_nbref_id, count(*) AS nbref FROM eco.t_fournisseurs GROUP BY 1) subview_nbref ON t_fournisseur_reference_cacic.oid = subview_nbref_id";
$sqlSort = "$tableName.texte";
}
if ($tableName == 't_types_mouvements') {
$sqlColumnAdd .= ",COALESCE(particularite_inverser_signe,'0'::text) AS particularite_inverser_signe";
$sqlColumnAdd .= ",COALESCE(sens_force,''::text) AS sens_force";
$sqlColumnComplement = "CASE WHEN $tableName.particularite_inverser_signe = '1' THEN 'Inversion signe' ELSE '' END || ' ' ||
CASE WHEN $tableName.sens_force = 'E' THEN 'Entrée' WHEN $tableName.sens_force = 'S' THEN 'Sortie' ELSE '' END";
}
if ($tableName == 't_fournisseur_reference_cti') {
$sqlColumnAdd .= ",COALESCE(nbref,0) AS nbref";
$sqlColumnAdd .= ", ','||COALESCE(subview_nbref.rfoids,'') AS rfoids";
$sqlNbRefJoin = "LEFT JOIN (SELECT fournisseur_reference_cti_id AS subview_nbref_id, count(*) AS nbref, base.cti_group_concat_without_sep(texte || '(' || code || ')' || chr(13)) AS frlist, base.cti_group_concat_without_sep(t_fournisseurs.oid||',') AS rfoids FROM eco.t_fournisseurs GROUP BY 1) subview_nbref ON t_fournisseur_reference_cti.oid = subview_nbref_id";
$sqlSort = "$tableName.texte";
}
$sqlcmd = "
SELECT
$tableName.oid,
$tableName.code,
$tableName.texte,
$tableName.texte_court,
$tableName.code_original,
$sqlColumnComplement AS complement
$sqlColumnAdd
FROM eco.$tableName
$sqlTableJoin
$sqlNbRefJoin
WHERE $tableName.oid > 0 ";
if ($updatedOids != "") {
$sqlcmd.= "AND
$tableName.oid in ($updatedOids) ";
}
$sqlcmd.= "
ORDER BY $sqlSort";
if ($tableName == 't_divers') {
$sqlcmd = "
SELECT
code,
texte,
valeur,
valeur_date,
description AS complement,
CASE WHEN show_info_module THEN 1 ELSE 0 END AS show_info_module
FROM eco.$tableName
ORDER BY code
";
}
if ($tableName == 't_type_article_cti_rule') {
$sqlcmd = "
SELECT
t_type_article_cti_rule.oid,
''::text AS code,
t_type_article_cti_rule.texte,
type_article_cti_id,
t_type_article_cti.texte AS type_article_cti_texte,
priorite,
array_to_string(
ARRAY[
CASE WHEN liste_type_article <> '' THEN 'Type:' || liste_type_article ELSE NULL END,
CASE WHEN liste_compte <> '' THEN 'Compte:' || liste_compte ELSE NULL END,
CASE WHEN liste_famille <> '' THEN 'Famille:' || liste_famille ELSE NULL END,
CASE WHEN liste_sous_famille <> '' THEN 'Sous-Famille:' || liste_sous_famille ELSE NULL END,
CASE WHEN liste_categorie <> '' THEN 'Catégorie:' || liste_categorie ELSE NULL END,
CASE WHEN liste_sous_categorie <> '' THEN 'Sous-Catégorie:' || liste_sous_categorie ELSE NULL END,
CASE WHEN liste_article <> '' THEN 'Article:' || liste_article ELSE NULL END
],' ') AS rule_texte,
liste_type_article,
liste_compte,
liste_famille,
liste_sous_famille,
liste_categorie,
liste_sous_categorie,
liste_article
FROM eco.$tableName
JOIN eco.t_type_article_cti ON type_article_cti_id = t_type_article_cti.oid
ORDER BY priorite, texte
";
}
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$httpString_tmp .= '\r\n<RECORD ';
$httpString_tmp .= 'oid="' . $record['oid'] . '" ';
$httpString_tmp .= 'code="' . toHTML(trim($record['code'])) . '" ';
$httpString_tmp .= 'texte="' . toHTML(trim($record['texte'])) . '" ';
$httpString_tmp .= 'texte_court="' . toHTML(trim($record['texte_court'])) . '" ';
$httpString_tmp .= 'code_original="' . toHTML(trim($record['code_original'])) . '" ';
$httpString_tmp .= 'complement="' . toHTML(trim($record['complement'])) . '" ';
$httpString_tmp .= 'cacic_id="' . (($tableName == 't_articles' || $tableName == 't_fournisseurs') ? toHTML(trim($record['cacic_id'])) : '0') . '" ';
$httpString_tmp .= 'rfcti_id="' . (($tableName == 't_articles' || $tableName == 't_fournisseurs') ? toHTML(trim($record['rfcti_id'])) : '0') . '" ';
$httpString_tmp .= 'fusionner_vers_fournisseur_id="' . (($tableName == 't_fournisseurs') ? toHTML(trim($record['fusionner_vers_fournisseur_id'])) : '0') . '" ';
$httpString_tmp .= 'rfoids="' . (($tableName == 't_article_reference_cti' || $tableName == 't_fournisseur_reference_cti') ? toHTML(trim($record['rfoids'])) : '') . '" ';
$httpString_tmp .= 'gere_en_stock="' . (($tableName == 't_articles') ? toHTML(trim($record['gere_en_stock'])) : '0') . '" ';
$httpString_tmp .= 'particularite_inverser_signe="' . (($tableName == 't_types_mouvements') ? toHTML(trim($record['particularite_inverser_signe'])) : '0') . '" ';
$httpString_tmp .= 'sens_force="' . (($tableName == 't_types_mouvements') ? toHTML(trim($record['sens_force'])) : '') . '" ';
$httpString_tmp .= 'defaut_selon="' . (($tableName == 't_types_articles') ? toHTML(trim($record['defaut_selon'])) : '') . '" ';
$httpString_tmp .= 'defaut_selon_codes="' . (($tableName == 't_types_articles') ? toHTML(trim($record['defaut_selon_codes'])) : '') . '" ';
$httpString_tmp .= 'nbref="'.toHTML(trim($record['nbref'])) . '" ';
$httpString_tmp .= 'valeur="'.toHTML(trim($record['valeur'])) . '" ';
$httpString_tmp .= 'type_article_cti_id="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['type_article_cti_id'])) : '') . '" ';
$httpString_tmp .= 'type_article_cti_texte="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['type_article_cti_texte'])) : '') . '" ';
$httpString_tmp .= 'priorite="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['priorite'])) : '') . '" ';
$httpString_tmp .= 'liste_type_article="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['liste_type_article'])) : '') . '" ';
$httpString_tmp .= 'liste_compte="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['liste_compte'])) : '') . '" ';
$httpString_tmp .= 'liste_famille="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['liste_famille'])) : '') . '" ';
$httpString_tmp .= 'liste_sous_famille="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['liste_sous_famille'])) : '') . '" ';
$httpString_tmp .= 'liste_categorie="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['liste_categorie'])) : '') . '" ';
$httpString_tmp .= 'liste_sous_categorie="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['liste_sous_categorie'])) : '') . '" ';
$httpString_tmp .= 'liste_article="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['liste_article'])) : '') . '" ';
$httpString_tmp .= 'rule_texte="' . (($tableName == 't_type_article_cti_rule') ? toHTML(trim($record['rule_texte'])) : '') . '" ';
$httpString_tmp .= ' />';
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
if ($firstCall != "0") {
if ($tableName == 't_articles') {
$httpString .= getArray_articles_reference_cacic($db);
$httpString .= getArray_articles_reference_cti($db);
}
if ($tableName == 't_fournisseurs') {
$httpString .= getCombo_fournisseurs($db);
$httpString .= getArray_fournisseurs_reference_cacic($db);
$httpString .= getArray_fournisseurs_reference_cti($db);
}
if ($tableName == 't_article_reference_cti') {
$httpString .= getList_articles($db);
}
if ($tableName == 't_fournisseur_reference_cti') {
$httpString .= getList_fournisseurs($db);
}
if ($tableName == 't_type_article_cti_rule') {
$httpString .= getCombo_type_article_cti($db);
}
}
return $httpString;
}
function getList_articles($db) {
$httpString = "\r\n<LIST_ART>";
$httpString_tmp = "";
$sqlcmd = "SELECT
t_articles.code,
t_articles.texte,
trim(COALESCE(t_lpp.code,'') || ' ' || COALESCE(t_ucd.code,'')) AS lppucd,
t_articles.oid
FROM eco.t_articles
LEFT JOIN base.t_lpp ON lpp_id = t_lpp.oid AND lpp_id <> 0
LEFT JOIN base.t_ucd ON ucd_id = t_ucd.oid AND ucd_id <> 0
WHERE t_articles.oid <> 0
ORDER BY t_articles.texte";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$code = toHTML(trim($record['code']));
$texte = toHTML(trim($record['texte']));
$lppucd = toHTML(trim($record['lppucd']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD code=\"$code\" texte=\"$texte\" lppucd=\"$lppucd\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString .= "\r\n</LIST_ART>";
return $httpString;
}
function getArray_articles_reference_cacic($db) {
$httpString = "\r\n<ARRAY_RA1>";
$httpString_tmp = "";
$sqlcmd = "SELECT
t_article_reference_cacic.code,
t_article_reference_cacic.texte,
t_article_reference_cacic.oid
FROM eco.t_article_reference_cacic
WHERE oid <> 0
ORDER BY code";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$code = toHTML(trim($record['code']));
$texte = toHTML(trim($record['texte']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD code=\"$code\" texte=\"$texte\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString .= "\r\n</ARRAY_RA1>";
return $httpString;
}
function getArray_articles_reference_cti($db) {
$httpString = "\r\n<ARRAY_RA9>";
$httpString_tmp = "";
$sqlcmd = "SELECT
t_article_reference_cti.code,
t_article_reference_cti.texte,
t_article_reference_cti.oid
FROM eco.t_article_reference_cti
WHERE oid <> 0
ORDER BY code";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$code = toHTML(trim($record['code']));
$texte = toHTML(trim($record['texte']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD code=\"$code\" texte=\"$texte\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString .= "\r\n</ARRAY_RA9>";
return $httpString;
}
function getCombo_fournisseurs($db) {
global $database;
$httpString = "";
$httpString = $httpString . "\r\n<COMBO_FOU>";
$httpString = $httpString . "\r\n<RECORD oid=\"0\" texte=\"\" />";
$sqlcmd = "SELECT oid, texte || ' ('||code || '/' || code_original||')' AS texte FROM eco.t_fournisseurs WHERE oid > 0 ORDER BY UPPER(texte)";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
$httpString_tmp = "";
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$texte = toHTML(trim($record['texte']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD texte=\"$texte\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString = $httpString . "\r\n</COMBO_FOU>";
return $httpString;
}
function getList_fournisseurs($db) {
$httpString = "\r\n<LIST_FOU>";
$httpString_tmp = "";
$sqlcmd = "SELECT
t_fournisseurs.code,
t_fournisseurs.texte,
t_fournisseurs.oid
FROM eco.t_fournisseurs
WHERE oid <> 0
ORDER BY texte";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$code = toHTML(trim($record['code']));
$texte = toHTML(trim($record['texte']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD code=\"$code\" texte=\"$texte\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString .= "\r\n</LIST_FOU>";
return $httpString;
}
function getArray_fournisseurs_reference_cacic($db) {
$httpString = "\r\n<ARRAY_RF1>";
$httpString_tmp = "";
$sqlcmd = "SELECT
t_fournisseur_reference_cacic.code,
t_fournisseur_reference_cacic.texte,
t_fournisseur_reference_cacic.oid
FROM eco.t_fournisseur_reference_cacic
WHERE oid <> 0
ORDER BY code";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$code = toHTML(trim($record['code']));
$texte = toHTML(trim($record['texte']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD code=\"$code\" texte=\"$texte\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString .= "\r\n</ARRAY_RF1>";
return $httpString;
}
function getArray_fournisseurs_reference_cti($db) {
$httpString = "\r\n<ARRAY_RF9>";
$httpString_tmp = "";
$sqlcmd = "SELECT
t_fournisseur_reference_cti.code,
t_fournisseur_reference_cti.texte,
t_fournisseur_reference_cti.oid
FROM eco.t_fournisseur_reference_cti
WHERE oid <> 0
ORDER BY code";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$code = toHTML(trim($record['code']));
$texte = toHTML(trim($record['texte']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD code=\"$code\" texte=\"$texte\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString .= "\r\n</ARRAY_RF9>";
return $httpString;
}
function getCombo_type_article_cti($db) {
global $database;
$httpString = "";
$httpString = $httpString . "\r\n<COMBO_TAA>";
$httpString = $httpString . "\r\n<RECORD oid=\"0\" texte=\"\" />";
$sqlcmd = "SELECT oid, texte FROM eco.t_type_article_cti WHERE oid > 0 ORDER BY UPPER(texte)";
$result = $db->exec($sqlcmd);
if ($result != false) {
// lignes
$ok = TRUE;
$httpString_tmp = "";
while ($ok == TRUE) {
$ok = FALSE;
$record = $db->nextRecordAssoc();
if ($record != FALSE) {
$ok = TRUE;
$texte = toHTML(trim($record['texte']));
$oid = toHTML(trim($record['oid']));
$httpString_tmp .= "<RECORD texte=\"$texte\" oid=\"$oid\"/>";
if (strlen($httpString_tmp) > 64000) {
$httpString .= $httpString_tmp;
$httpString_tmp = "";
}
}
}
}
$httpString .= $httpString_tmp;
$httpString = $httpString . "\r\n</COMBO_TAA>";
return $httpString;
}
?>