Jump to content

Edit History

Pistoletabilles

Pistoletabilles

10 hours ago, coeos.pro said:

quelque chose comme :

 

complète tous les paiements au début, ensuite le HTML est, comme le dit Mediacom87, à mettre dans un fichier tpl (langage SMARTY) 

 

 

<?php 
$paiements = array(
    'paypal' => 'Paiement Paypal', 
    'NATURABUY' => 'Paiement Naturabuy Carte bancaire', 
    'NaturaBuyPayment' => 'Paiement Naturabuy CB3X',
);


foreach ($paiements as $paiement => $name) {
        $this->html .= '
            <h4>'.$name.'</h4>
            <table class="table" style="border: 0; cellspacing: 0;">
            <thead>
            <tr>
            <th>
            <span class="title_box  active">Pays</span>
            </th>
            <th>
            <span class="title_box  active">Nombre de commandes</span>
            </th>
            <th>
            <span class="title_box  active">Total HT</span>
            </th>
            <th>
            <span class="title_box  active">Total TTC</span>
            </th>
            </tr>
            </thead>
            <tboby>';
        
        $datas = $this->getDatasPayment($paiement);
        foreach ($datas as $result) {
            $this->html .= '
                <tr>
                    <td>' . $result['PAYS'] . '</td>
                    <td>' . $result['Nombre_total_cmde'] . '</td>
                    <td>' . Tools::displayPrice($result['CA_HT'], $currency) . '</td>
                    <td>' . Tools::displayPrice($result['CA_TTC'], $currency) . '</td>
                </tr>';
        }
        
        $total = $this->getTotalDatasPayment($paiement);
        foreach ($total as $sum)
            $this->html .= '
                <thead>
                <tr>
                <td>
                <strong>Total</strong>
                </td>
                <td>' . $sum['Nombre_total_cmde'] . '</td>
                <td>' . Tools::displayPrice($sum['CA_HT'], $currency) . '</td>
                <td>' . Tools::displayPrice($sum['CA_TTC'], $currency) . '</td>
                </tr>
                </thead>
                </tboby>
                </table>
                <hr>';
        
        
        
}


private function getDatasPayment($paiement)
{
    $sql = 'SELECT
    cl.name AS PAYS,
    COUNT(o.id_order) AS Nombre_total_cmde,
    ROUND(SUM(o.total_paid_tax_excl), 2) AS CA_HT,
    ROUND(SUM(o.total_paid), 2) AS CA_TTC
    FROM ' . _DB_PREFIX_ . 'orders o
    LEFT JOIN ' . _DB_PREFIX_ . 'address a ON o.id_address_invoice = a.id_address
    LEFT JOIN ' . _DB_PREFIX_ . 'country_lang cl ON cl.id_country = a.id_country
    WHERE  o.date_add BETWEEN ' . ModuleGraph::getDateBetween() . '
    AND o.current_state IN (2, 3, 4 ,5, 9, 18, 25, 26, 20, 31, 32, 33)
    AND o.module LIKE ("'.pSQL($paiement).'")
    AND cl.id_lang = 1
    GROUP BY a.id_country';
    return Db::getInstance()->executeS($sql);
}
private function getTotalDatasPayment($paiement)
{
    $sql = 'SELECT
        cl.name AS PAYS,
        COUNT(o.id_order) AS Nombre_total_cmde,
        ROUND(SUM(o.total_paid_tax_excl), 2) AS CA_HT,
        ROUND(SUM(o.total_paid), 2) AS CA_TTC
        FROM ' . _DB_PREFIX_ . 'orders o
        LEFT JOIN ' . _DB_PREFIX_ . 'address a ON o.id_address_invoice = a.id_address
        LEFT JOIN ' . _DB_PREFIX_ . 'country_lang cl ON cl.id_country = a.id_country
        WHERE  o.date_add BETWEEN ' . ModuleGraph::getDateBetween() . '
        AND o.current_state IN (2, 3, 4 ,5, 9, 18, 25, 26, 20, 31, 32, 33)
        AND o.module IN ("'.pSQL($paiement).'")
        AND cl.id_lang = 1';
    return Db::getInstance()->executeS($sql);
}

Super merci, je vais essayer de me débrouiller avec ces aides mais comment faire car je dois ajouter une condition AND o.payment après la condition AND o.module pour filtrer un peu plus sur le module Naturabuy

Pistoletabilles

Pistoletabilles

9 hours ago, coeos.pro said:

quelque chose comme :

 

complète tous les paiements au début, ensuite le HTML est, comme le dit Mediacom87, à mettre dans un fichier tpl (langage SMARTY) 

 

 

<?php 
$paiements = array(
    'paypal' => 'Paiement Paypal', 
    'NATURABUY' => 'Paiement Naturabuy Carte bancaire', 
    'NaturaBuyPayment' => 'Paiement Naturabuy CB3X',
);


foreach ($paiements as $paiement => $name) {
        $this->html .= '
            <h4>'.$name.'</h4>
            <table class="table" style="border: 0; cellspacing: 0;">
            <thead>
            <tr>
            <th>
            <span class="title_box  active">Pays</span>
            </th>
            <th>
            <span class="title_box  active">Nombre de commandes</span>
            </th>
            <th>
            <span class="title_box  active">Total HT</span>
            </th>
            <th>
            <span class="title_box  active">Total TTC</span>
            </th>
            </tr>
            </thead>
            <tboby>';
        
        $datas = $this->getDatasPayment($paiement);
        foreach ($datas as $result) {
            $this->html .= '
                <tr>
                    <td>' . $result['PAYS'] . '</td>
                    <td>' . $result['Nombre_total_cmde'] . '</td>
                    <td>' . Tools::displayPrice($result['CA_HT'], $currency) . '</td>
                    <td>' . Tools::displayPrice($result['CA_TTC'], $currency) . '</td>
                </tr>';
        }
        
        $total = $this->getTotalDatasPayment($paiement);
        foreach ($total as $sum)
            $this->html .= '
                <thead>
                <tr>
                <td>
                <strong>Total</strong>
                </td>
                <td>' . $sum['Nombre_total_cmde'] . '</td>
                <td>' . Tools::displayPrice($sum['CA_HT'], $currency) . '</td>
                <td>' . Tools::displayPrice($sum['CA_TTC'], $currency) . '</td>
                </tr>
                </thead>
                </tboby>
                </table>
                <hr>';
        
        
        
}


private function getDatasPayment($paiement)
{
    $sql = 'SELECT
    cl.name AS PAYS,
    COUNT(o.id_order) AS Nombre_total_cmde,
    ROUND(SUM(o.total_paid_tax_excl), 2) AS CA_HT,
    ROUND(SUM(o.total_paid), 2) AS CA_TTC
    FROM ' . _DB_PREFIX_ . 'orders o
    LEFT JOIN ' . _DB_PREFIX_ . 'address a ON o.id_address_invoice = a.id_address
    LEFT JOIN ' . _DB_PREFIX_ . 'country_lang cl ON cl.id_country = a.id_country
    WHERE  o.date_add BETWEEN ' . ModuleGraph::getDateBetween() . '
    AND o.current_state IN (2, 3, 4 ,5, 9, 18, 25, 26, 20, 31, 32, 33)
    AND o.module LIKE ("'.pSQL($paiement).'")
    AND cl.id_lang = 1
    GROUP BY a.id_country';
    return Db::getInstance()->executeS($sql);
}
private function getTotalDatasPayment($paiement)
{
    $sql = 'SELECT
        cl.name AS PAYS,
        COUNT(o.id_order) AS Nombre_total_cmde,
        ROUND(SUM(o.total_paid_tax_excl), 2) AS CA_HT,
        ROUND(SUM(o.total_paid), 2) AS CA_TTC
        FROM ' . _DB_PREFIX_ . 'orders o
        LEFT JOIN ' . _DB_PREFIX_ . 'address a ON o.id_address_invoice = a.id_address
        LEFT JOIN ' . _DB_PREFIX_ . 'country_lang cl ON cl.id_country = a.id_country
        WHERE  o.date_add BETWEEN ' . ModuleGraph::getDateBetween() . '
        AND o.current_state IN (2, 3, 4 ,5, 9, 18, 25, 26, 20, 31, 32, 33)
        AND o.module IN ("'.pSQL($paiement).'")
        AND cl.id_lang = 1';
    return Db::getInstance()->executeS($sql);
}

Super merci, je vais essyer de me dévrouiller avec ces aides mais comment faire car je dois ajouter une condition AND o.payment après la condition AND o.module pour filtrer un peu plus sur le module Naturabuy

×
×
  • Create New...