Jump to content
Romain3001

Modification Du Dashboard Trends

Recommended Posts

Bonjour,

Je cherche désespérement un moyen de modifier la classe GetOrders de AdminStatsController.
L'idée serait de pouvoir comptabiliser à la fois les commandes ayant le statut "Paiement Accepté" et les commandes "en cours de préparation". Une idée ?

 

 

    public static function getOrders($date_from, $date_to, $granularity = false)
    {
        if ($granularity == 'day') {
            $orders = array();
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT LEFT(`invoice_date`, 10) as date, COUNT(*) as orders
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1
'.Shop::addSqlRestriction(false, 'o').'
GROUP BY LEFT(`invoice_date`, 10)');
            foreach ($result as $row) {
                $orders[strtotime($row['date'])] = $row['orders'];
            }
            return $orders;
        } elseif ($granularity == 'month') {
            $orders = array();
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT LEFT(`invoice_date`, 7) as date, COUNT(*) as orders
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND o.logable = 1 AND os.current_state=19
'.Shop::addSqlRestriction(false, 'o').'
GROUP BY LEFT(`invoice_date`, 7)');
            foreach ($result as $row) {
                $orders[strtotime($row['date'].'-01')] = $row['orders'];
            }
            return $orders;
        } else {
            $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*) as orders
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND o.logable = 1 AND os.current_state=19
'.Shop::addSqlRestriction(false, 'o'));
        }
 
        return $orders;
    }
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More