125 lines
5.1 KiB
PHP
125 lines
5.1 KiB
PHP
<?php
|
||
/*************************************************************************************/
|
||
/* */
|
||
/* Thelia */
|
||
/* */
|
||
/* Copyright (c) 2005-2013 OpenStudio */
|
||
/* email : info@thelia.fr */
|
||
/* web : http://www.thelia.net */
|
||
/* */
|
||
/* This program is free software; you can redistribute it and/or modify */
|
||
/* it under the terms of the GNU General Public License as published by */
|
||
/* the Free Software Foundation; either version 3 of the License */
|
||
/* */
|
||
/* This program is distributed in the hope that it will be useful, */
|
||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||
/* GNU General Public License for more details. */
|
||
/* */
|
||
/* You should have received a copy of the GNU General Public License */
|
||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||
/* */
|
||
/*************************************************************************************/
|
||
require_once("pre.php");
|
||
require_once("auth.php");
|
||
|
||
require_once("../lib/magpierss/extlib/Snoopy.class.inc");
|
||
?>
|
||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<?php require_once("title.php");?>
|
||
</head>
|
||
|
||
<?php
|
||
$cnx = new Cnx();
|
||
|
||
function get_result($query) {
|
||
global $cnx;
|
||
|
||
$resul = $cnx->query($query);
|
||
|
||
return $resul ? $cnx->get_result($resul, 0, 0) : 0;
|
||
}
|
||
|
||
$cond_commande_paye = "statut >= ".Commande::PAYE." and statut <> ".Commande::ANNULE;
|
||
$in_commande_paye = "select id from ".Commande::TABLE." where $cond_commande_paye";
|
||
|
||
$nbclient = get_result("select count(*) as nb from ".Client::TABLE);
|
||
$nbproduit = get_result("select count(*) as nb from ".Produit::TABLE);
|
||
$nbcmdinstance = get_result("select count(*) as nb from ".Commande::TABLE." where statut < ".Commande::TRAITEMENT);
|
||
$nbcmdtraitement = get_result("select count(*) as nb from ".Commande::TABLE." where statut = ".Commande::TRAITEMENT);
|
||
$nbcmdlivree = get_result("select count(*) as nb from ".Commande::TABLE." where statut = ".Commande::EXPEDIE);
|
||
$nbproduitenligne = get_result("select count(*) as nb from ".Produit::TABLE." where ligne=1");
|
||
|
||
$nbproduithorsligne = $nbproduit-$nbproduitenligne;
|
||
|
||
$port = get_result("select sum(port) as totport from ".Commande::TABLE." where $cond_commande_paye");
|
||
|
||
$ca = round(get_result("SELECT sum(quantite*prixu) as ca FROM ".Venteprod::TABLE." where commande in ($in_commande_paye)"), 2);
|
||
$ca += get_result("SELECT sum(port) as ca FROM ".Commande::TABLE." where id in ($in_commande_paye)");
|
||
$ca -= get_result("SELECT sum(remise) as ca FROM ".Commande::TABLE." where id in ($in_commande_paye)");
|
||
|
||
$casf = $ca - $port;
|
||
|
||
$nbCommande = get_result("SELECT count(*) as nbCommande FROM ".Commande::TABLE." where $cond_commande_paye");
|
||
|
||
if($nbCommande > 0)
|
||
$panierMoyen = round(($ca/$nbCommande),2);
|
||
else
|
||
$panierMoyen = 0;
|
||
|
||
// La liste des commandes du mois courant
|
||
$query = "select id from ".Commande::TABLE." where datefact like '".date("Y")."-".date("m")."-%%' and $cond_commande_paye";
|
||
|
||
$resul = $cnx->query($query);
|
||
|
||
$list = array();
|
||
|
||
while($resul && $row = $cnx->fetch_object($resul)) {
|
||
$list[] = $row->id;
|
||
}
|
||
|
||
if (count($list) == 0)
|
||
$list = '0';
|
||
else
|
||
$list = implode(',', $list);
|
||
|
||
$camois = round(get_result("SELECT sum(quantite*prixu) as camois FROM ".Venteprod::TABLE." where commande in ($list)"), 2);
|
||
$camois += get_result("SELECT sum(port) as port FROM ".Commande::TABLE." where id in ($list)");
|
||
$camois -= get_result("SELECT sum(remise) as remise FROM ".Commande::TABLE." where id in ($list)");
|
||
|
||
$nbcmdannulee = get_result("select count(*) as nbcmdannulee from ".Commande::TABLE." where statut = ".Commande::ANNULE);
|
||
|
||
$nbrubrique = get_result("select count(id) as nbRubrique from ".Rubrique::TABLE);
|
||
|
||
// Dernière version
|
||
$snoopy = new Snoopy();
|
||
|
||
if($snoopy->fetch("http://thelia.net/version.php")) {
|
||
$versiondispo = trim($snoopy->results);
|
||
if(! preg_match("/^[0-9.]*$/", $versiondispo))
|
||
$versiondispo = "";
|
||
}
|
||
else {
|
||
$versiondispo = "";
|
||
}
|
||
?>
|
||
|
||
<body>
|
||
<div id="wrapper">
|
||
<div id="subwrapper">
|
||
<?php
|
||
$menu="accueil";
|
||
require_once("entete.php");
|
||
?>
|
||
|
||
|
||
|
||
<?php require_once("pied.php");?>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|