Requête SQL : select fh.id , fh.facture_type , fh.facture_id , fh.numero , fh.date_impression , fh.date_reglement , sum(fd.total_ht) as total_ht , sum(fd.total_remise) as total_remise , sum(fd.total_tva) as total_tva , sum(fd.total_ttc) as total_ttc , cp.id, cp.libelle, cp.numero as numero_cp from wp_nebul_factures fh inner join wp_nebul_factures_lignes fd on fd.facture_id = fh.facture_id left outer join (SELECT ph.id as article_id, ph.post_author as user_id, GROUP_CONCAT(IF(pd.meta_key = 'societe_code' , pd.meta_value, NULL)) AS societe_code, ph.post_name as article_slug, ph.post_title as article_description, GROUP_CONCAT(IF(pd.meta_key = 'article_code' , pd.meta_value, NULL)) AS article_code, GROUP_CONCAT(IF(pd.meta_key = 'article_prix' , pd.meta_value, NULL)) AS article_prix, GROUP_CONCAT(IF(pd.meta_key = 'article_type' , pd.meta_value, NULL)) AS article_type, GROUP_CONCAT(IF(pd.meta_key = 'article_categorie' , pd.meta_value, NULL)) AS article_categorie, GROUP_CONCAT(IF(pd.meta_key = 'article_stock_quantite' , pd.meta_value, NULL)) AS article_stock_quantite, GROUP_CONCAT(IF(pd.meta_key = 'article_comptabilite' , pd.meta_value, NULL)) AS article_comptabilite FROM wp_posts ph left outer join wp_postmeta pd on ph.id = pd.post_id where 1=1 and ph.post_type = 'article' and ph.post_status = 'publish' GROUP BY ph.id, ph.post_author, ph.post_name, ph.post_title) articles on articles.article_id = fd.article_id left outer join wp_nebul_comptes cp on cp.type='PRODUITS' and cp.code_cp = articles.article_comptabilite where 1=1 and fh.societe_code='ToPKf' and fh.facture_type ='F' and not exists (select 1 from wp_nebul_ecritures ec where 1=1 and ec.piece_type = fh.facture_type and ec.piece_type2 = 'F' and ec.piece_id = fh.facture_id) group by fh.id , fh.facture_type , fh.facture_id , fh.numero , cp.id , cp.libelle , cp.numero

Requête SQL : select fh.id , fh.facture_type , fh.facture_id , fh.numero , fh.date_impression , fh.date_reglement , sum(fd.total_ht) as total_ht , sum(fd.total_remise) as total_remise , sum(fd.total_tva) as total_tva , sum(fd.total_ttc) as total_ttc , cp.id, cp.libelle, cp.numero as numero_cp from wp_nebul_factures fh inner join wp_nebul_factures_lignes fd on fd.facture_id = fh.facture_id left outer join (SELECT ph.id as article_id, ph.post_author as user_id, GROUP_CONCAT(IF(pd.meta_key = 'societe_code' , pd.meta_value, NULL)) AS societe_code, ph.post_name as article_slug, ph.post_title as article_description, GROUP_CONCAT(IF(pd.meta_key = 'article_code' , pd.meta_value, NULL)) AS article_code, GROUP_CONCAT(IF(pd.meta_key = 'article_prix' , pd.meta_value, NULL)) AS article_prix, GROUP_CONCAT(IF(pd.meta_key = 'article_type' , pd.meta_value, NULL)) AS article_type, GROUP_CONCAT(IF(pd.meta_key = 'article_categorie' , pd.meta_value, NULL)) AS article_categorie, GROUP_CONCAT(IF(pd.meta_key = 'article_stock_quantite' , pd.meta_value, NULL)) AS article_stock_quantite, GROUP_CONCAT(IF(pd.meta_key = 'article_comptabilite' , pd.meta_value, NULL)) AS article_comptabilite FROM wp_posts ph left outer join wp_postmeta pd on ph.id = pd.post_id where 1=1 and ph.post_type = 'article' and ph.post_status = 'publish' GROUP BY ph.id, ph.post_author, ph.post_name, ph.post_title) articles on articles.article_id = fd.article_id left outer join wp_nebul_comptes cp on cp.type='PRODUITS' and cp.code_cp = articles.article_comptabilite where 1=1 and fh.societe_code='ToPKf' and fh.facture_type ='F' and fh.statut in ('Payée', 'Payé', 'Réglé', 'Réglée', 'Pointée', 'Pointé') and not exists (select 1 from wp_nebul_ecritures ec where 1=1 and ec.piece_type = fh.facture_type and ec.piece_type2 = 'R' and ec.piece_id = fh.facture_id) group by fh.id , fh.facture_type , fh.facture_id , fh.numero , cp.id , cp.libelle , cp.numero

Requête SQL : select fh.id , fh.facture_type , fh.facture_id , fh.numero , fh.date_impression , fh.date_reglement , sum(fd.total_ht) as total_ht , sum(fd.total_remise) as total_remise , sum(fd.total_tva) as total_tva , sum(fd.total_ttc) as total_ttc , cp.id, cp.libelle, cp.numero as numero_cp from wp_nebul_factures fh inner join wp_nebul_factures_lignes fd on fd.facture_id = fh.facture_id left outer join (SELECT ph.id as article_id, ph.post_author as user_id, GROUP_CONCAT(IF(pd.meta_key = 'societe_code' , pd.meta_value, NULL)) AS societe_code, ph.post_name as article_slug, ph.post_title as article_description, GROUP_CONCAT(IF(pd.meta_key = 'article_code' , pd.meta_value, NULL)) AS article_code, GROUP_CONCAT(IF(pd.meta_key = 'article_prix' , pd.meta_value, NULL)) AS article_prix, GROUP_CONCAT(IF(pd.meta_key = 'article_type' , pd.meta_value, NULL)) AS article_type, GROUP_CONCAT(IF(pd.meta_key = 'article_categorie' , pd.meta_value, NULL)) AS article_categorie, GROUP_CONCAT(IF(pd.meta_key = 'article_stock_quantite' , pd.meta_value, NULL)) AS article_stock_quantite, GROUP_CONCAT(IF(pd.meta_key = 'article_comptabilite' , pd.meta_value, NULL)) AS article_comptabilite FROM wp_posts ph left outer join wp_postmeta pd on ph.id = pd.post_id where 1=1 and ph.post_type = 'article' and ph.post_status = 'publish' GROUP BY ph.id, ph.post_author, ph.post_name, ph.post_title) articles on articles.article_id = fd.article_id left outer join wp_nebul_comptes cp on cp.type='PRODUITS' and cp.code_cp = articles.article_comptabilite where 1=1 and fh.societe_code='wIgOj' and fh.facture_type ='F' and not exists (select 1 from wp_nebul_ecritures ec where 1=1 and ec.piece_type = fh.facture_type and ec.piece_type2 = 'F' and ec.piece_id = fh.facture_id) group by fh.id , fh.facture_type , fh.facture_id , fh.numero , cp.id , cp.libelle , cp.numero

Requête SQL : select fh.id , fh.facture_type , fh.facture_id , fh.numero , fh.date_impression , fh.date_reglement , sum(fd.total_ht) as total_ht , sum(fd.total_remise) as total_remise , sum(fd.total_tva) as total_tva , sum(fd.total_ttc) as total_ttc , cp.id, cp.libelle, cp.numero as numero_cp from wp_nebul_factures fh inner join wp_nebul_factures_lignes fd on fd.facture_id = fh.facture_id left outer join (SELECT ph.id as article_id, ph.post_author as user_id, GROUP_CONCAT(IF(pd.meta_key = 'societe_code' , pd.meta_value, NULL)) AS societe_code, ph.post_name as article_slug, ph.post_title as article_description, GROUP_CONCAT(IF(pd.meta_key = 'article_code' , pd.meta_value, NULL)) AS article_code, GROUP_CONCAT(IF(pd.meta_key = 'article_prix' , pd.meta_value, NULL)) AS article_prix, GROUP_CONCAT(IF(pd.meta_key = 'article_type' , pd.meta_value, NULL)) AS article_type, GROUP_CONCAT(IF(pd.meta_key = 'article_categorie' , pd.meta_value, NULL)) AS article_categorie, GROUP_CONCAT(IF(pd.meta_key = 'article_stock_quantite' , pd.meta_value, NULL)) AS article_stock_quantite, GROUP_CONCAT(IF(pd.meta_key = 'article_comptabilite' , pd.meta_value, NULL)) AS article_comptabilite FROM wp_posts ph left outer join wp_postmeta pd on ph.id = pd.post_id where 1=1 and ph.post_type = 'article' and ph.post_status = 'publish' GROUP BY ph.id, ph.post_author, ph.post_name, ph.post_title) articles on articles.article_id = fd.article_id left outer join wp_nebul_comptes cp on cp.type='PRODUITS' and cp.code_cp = articles.article_comptabilite where 1=1 and fh.societe_code='wIgOj' and fh.facture_type ='F' and fh.statut in ('Payée', 'Payé', 'Réglé', 'Réglée', 'Pointée', 'Pointé') and not exists (select 1 from wp_nebul_ecritures ec where 1=1 and ec.piece_type = fh.facture_type and ec.piece_type2 = 'R' and ec.piece_id = fh.facture_id) group by fh.id , fh.facture_type , fh.facture_id , fh.numero , cp.id , cp.libelle , cp.numero