2006-03-22 18:52:12 +01:00
< ? php
/* Copyright ( C ) 2003 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2007-12-28 17:05:16 +01:00
* Copyright ( C ) 2004 - 2007 Laurent Destailleur < eldy @ users . sourceforge . net >
2006-03-22 18:52:12 +01:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2006-03-22 18:52:12 +01:00
* ( at your option ) any later version .
*
* 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
2011-08-03 02:45:22 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2006-03-22 18:52:12 +01:00
*/
2009-01-31 02:17:53 +01:00
2006-03-22 18:52:12 +01:00
/**
2011-08-03 03:13:30 +02:00
* \file htdocs / boutique / index . php
* \ingroup boutique
* \brief Page accueil zone boutique
2010-08-09 17:42:57 +02:00
*/
2006-03-22 18:52:12 +01:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/boutique/osc_master.inc.php' ;
2006-03-22 18:52:12 +01:00
$langs -> load ( " boutique " );
2009-10-19 21:54:27 +02:00
$langs -> load ( " orders " );
2006-08-04 03:44:29 +02:00
2006-03-22 18:52:12 +01:00
2006-07-13 14:58:59 +02:00
llxHeader ( " " , $langs -> trans ( " OSCommerceShop " ), " " );
2006-03-22 18:52:12 +01:00
2006-07-13 14:58:59 +02:00
print_fiche_titre ( $langs -> trans ( " OSCommerceShop " ));
2006-03-22 18:52:12 +01:00
2006-07-13 14:58:59 +02:00
print '<table width="100%" class="notopnoleftnoright">' ;
2006-03-22 18:52:12 +01:00
2006-07-13 14:58:59 +02:00
print '<tr><td valign="top" width="40%" class="notopnoleft">' ;
2006-03-22 18:52:12 +01:00
2009-01-31 02:17:53 +01:00
/*
2012-07-12 17:16:25 +02:00
/* Chiffre d ' affaires
2010-08-09 17:42:57 +02:00
*/
2012-07-12 17:16:25 +02:00
//print_barre_liste("Chiffre d'affaires", $page, "ca.php");
2006-03-22 18:52:12 +01:00
2006-07-13 14:58:59 +02:00
print_titre ( $langs -> trans ( 'SalesTurnover' ));
2006-03-22 18:52:12 +01:00
print '<table class="noborder" cellspacing="0" cellpadding="3" width="100%">' ;
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( " Total " ) . '</td></tr>' ;
2012-04-30 15:01:25 +02:00
$now = dol_now ();
2006-03-22 18:52:12 +01:00
$sql = " SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois " ;
2009-01-31 02:17:53 +01:00
$sql .= " FROM " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders_total as t " ;
$sql .= " JOIN " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders as o ON o.orders_id = t.orders_id " ;
2012-04-30 15:01:25 +02:00
$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR( " . $dbosc -> idate ( $now ) . " ) " ;
2006-03-22 18:52:12 +01:00
$sql .= " GROUP BY mois ORDER BY mois " ;
2007-12-28 17:05:16 +01:00
$result = $dbosc -> query ( $sql );
if ( $result )
2006-03-22 18:52:12 +01:00
{
2010-08-09 17:42:57 +02:00
$num = $dbosc -> num_rows ( $result );
2006-03-22 18:52:12 +01:00
2010-08-09 17:42:57 +02:00
$var = True ;
$i = 0 ;
if ( $num > 0 )
{
while ( $i < $num )
2006-03-22 18:52:12 +01:00
{
2010-08-09 17:42:57 +02:00
$objp = $dbosc -> fetch_object ( $result );
$var =! $var ;
2013-06-20 09:18:12 +02:00
print " <tr " . $bc [ $var ] . " > " ;
2010-08-09 17:42:57 +02:00
print '<td align="left">' . $objp -> mois . '</td>' ;
print '<td align="right">' . price ( $objp -> value ) . '</td>' ;
print " </tr> \n " ;
$i ++ ;
}
2006-03-22 18:52:12 +01:00
}
2010-08-09 17:42:57 +02:00
$dbosc -> free ();
2006-03-22 18:52:12 +01:00
}
else
{
2010-08-09 17:42:57 +02:00
dol_print_error ( $dbosc );
2006-03-22 18:52:12 +01:00
}
print " </table> " ;
2006-07-13 14:58:59 +02:00
print '</td><td valign="top" width="60%" class="notopnoleftnoright">' ;
print_titre ( $langs -> trans ( " Orders " ));
2006-03-22 18:52:12 +01:00
/*
2010-08-09 17:42:57 +02:00
* 5 derniees commandes recues
2006-03-22 18:52:12 +01:00
select o . orders_id , o . customers_id , o . customers_name , o . date_purchased , o . payement_method , o . status , t . value
2010-08-09 17:42:57 +02:00
from orders_total as t
join orders as o on o . orders_id = t . orders_id where t . class = ' ot_subtotal ' order by o . date_purchased desc
2006-03-22 18:52:12 +01:00
*/
$sql = " SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method " ;
2009-01-31 02:17:53 +01:00
$sql .= " FROM " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders_total as t JOIN " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders as o on o.orders_id = t.orders_id " ;
2006-03-22 18:52:12 +01:00
$sql .= " WHERE t.class = 'ot_subtotal' ORDER BY o.date_purchased desc " ;
2010-08-09 17:42:57 +02:00
$resql = $dbosc -> query ( $sql );
if ( $resql )
2006-03-22 18:52:12 +01:00
{
2006-08-04 03:44:29 +02:00
$langs -> load ( " orders " );
2010-08-09 17:42:57 +02:00
$num = $dbosc -> num_rows ( $resql );
2006-08-04 03:44:29 +02:00
if ( $num > 0 )
2006-03-22 18:52:12 +01:00
{
2006-08-04 03:44:29 +02:00
$i = 0 ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2009-10-19 21:54:27 +02:00
print '<td colspan="4">' . $langs -> trans ( " LastOrders " ) . '</td></tr>' ;
2006-08-04 03:44:29 +02:00
$num = min ( $num , OSC_MAXNBCOM );
while ( $i < $num )
{
2010-08-09 17:42:57 +02:00
$obj = $dbosc -> fetch_object ( $resql );
2006-08-04 03:44:29 +02:00
print " <tr><td> $obj->orders_id </td><td> $obj->customers_name </td><td> " . price ( $obj -> value ) . " </td><td> $obj->payment_method </td></tr> " ;
$i ++ ;
}
print " </table><br> " ;
2006-03-22 18:52:12 +01:00
}
}
else
{
2010-08-09 17:42:57 +02:00
dol_print_error ( $dbosc );
2006-03-22 18:52:12 +01:00
}
/*
2010-03-27 03:29:49 +01:00
* 5 derni<EFBFBD> res commandes en attente
2010-08-09 17:42:57 +02:00
*/
2006-03-22 18:52:12 +01:00
$sql = " SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method " ;
2009-01-31 02:17:53 +01:00
$sql .= " FROM " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders_total as t JOIN " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders as o on o.orders_id = t.orders_id " ;
2006-03-22 18:52:12 +01:00
$sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status = 5 order by o.date_purchased desc " ;
2010-08-09 17:42:57 +02:00
$resql = $dbosc -> query ( $sql );
if ( $resql )
2006-03-22 18:52:12 +01:00
{
2010-08-09 17:42:57 +02:00
$langs -> load ( " orders " );
$num = $dbosc -> num_rows ( $resql );
if ( $num > 0 )
{
$i = 0 ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="4">' . $langs -> trans ( " En Attente " ) . '</td></tr>' ;
2009-01-31 02:17:53 +01:00
2006-03-22 18:52:12 +01:00
$num = min ( $num , OSC_MAXNBCOM );
2010-08-09 17:42:57 +02:00
while ( $i < $num )
{
2009-01-31 02:17:53 +01:00
2010-08-09 17:42:57 +02:00
$obj = $dbosc -> fetch_object ( $resql );
2006-03-22 18:52:12 +01:00
print " <tr><td> $obj->orders_id </td><td> $obj->customers_name </td><td> " . price ( $obj -> value ) . " </td><td> $obj->payment_method </td></tr> " ;
$i ++ ;
2010-08-09 17:42:57 +02:00
}
print " </table><br> " ;
2006-03-22 18:52:12 +01:00
}
}
else
{
2010-08-09 17:42:57 +02:00
dol_print_error ( $dbosc );
2006-03-22 18:52:12 +01:00
}
/*
2010-03-27 03:29:49 +01:00
* Commandes <EFBFBD> traiter
2006-03-22 18:52:12 +01:00
*/
$sql = " SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method " ;
2009-01-31 02:17:53 +01:00
$sql .= " FROM " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders_total as t JOIN " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders as o on o.orders_id = t.orders_id " ;
2006-03-22 18:52:12 +01:00
$sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status = 2 order by o.date_purchased desc " ;
2010-08-09 17:42:57 +02:00
$resql = $dbosc -> query ( $sql );
if ( $resql )
2006-03-22 18:52:12 +01:00
{
2010-08-09 17:42:57 +02:00
$langs -> load ( " orders " );
$num = $dbosc -> num_rows ( $resql );
if ( $num > 0 )
{
$i = 0 ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2011-02-23 09:58:39 +01:00
print '<td colspan="4">' . $langs -> trans ( " TreatmentInProgress " ) . '</td></tr>' ;
2006-03-22 18:52:12 +01:00
$num = min ( $num , OSC_MAXNBCOM );
2010-08-09 17:42:57 +02:00
while ( $i < $num )
{
2009-01-31 02:17:53 +01:00
2010-08-09 17:42:57 +02:00
$obj = $dbosc -> fetch_object ( $resql );
2006-03-22 18:52:12 +01:00
print " <tr><td> $obj->orders_id </td><td> $obj->customers_name </td><td> " . price ( $obj -> value ) . " </td><td> $obj->payment_method </td></tr> " ;
$i ++ ;
2010-08-09 17:42:57 +02:00
}
print " </table><br> " ;
2006-03-22 18:52:12 +01:00
}
}
else
{
2010-08-09 17:42:57 +02:00
dol_print_error ( $dbosc );
2006-03-22 18:52:12 +01:00
}
print '</td></tr><tr>' ;
/*
2010-08-09 17:42:57 +02:00
* Derniers clients qui ont command<EFBFBD>
*/
2006-03-22 18:52:12 +01:00
$sql = " SELECT o.orders_id, o.customers_name, o.delivery_country, o.date_purchased, t.value, s.orders_status_name as statut " ;
2009-01-31 02:17:53 +01:00
$sql .= " FROM " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders_total as t JOIN " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders as o on o.orders_id = t.orders_id " ;
$sql .= " JOIN " . $conf -> global -> OSC_DB_NAME . " . " . $conf -> global -> OSC_DB_TABLE_PREFIX . " orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1 " ;
2006-03-22 18:52:12 +01:00
$sql .= " WHERE t.class = 'ot_subtotal' order by o.date_purchased desc " ;
2010-08-09 17:42:57 +02:00
$resql = $dbosc -> query ( $sql );
if ( $resql )
2006-03-22 18:52:12 +01:00
{
2010-08-09 17:42:57 +02:00
$langs -> load ( " orders " );
$num = $dbosc -> num_rows ( $resql );
if ( $num > 0 )
2006-03-22 18:52:12 +01:00
{
2010-08-09 17:42:57 +02:00
$i = 0 ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="7">' . $langs -> trans ( " Derniers clients " ) . '</td></tr>' ;
2009-01-31 02:17:53 +01:00
2010-08-09 17:42:57 +02:00
$num = min ( $num , OSC_MAXNBCOM );
while ( $i < $num )
{
$obj = $dbosc -> fetch_object ( $resql );
print " <tr><td> $obj->date_purchased </td><td> $obj->customers_name </td><td> $obj->delivery_country </td><td> " . price ( $obj -> value ) . " </td><td> $obj->payment_method </td><td> $obj->orders_id </td><td> $obj->statut </td></tr> " ;
$i ++ ;
}
print " </table><br> " ;
2006-03-22 18:52:12 +01:00
}
}
else
{
2010-08-09 17:42:57 +02:00
dol_print_error ( $dbosc );
2006-03-22 18:52:12 +01:00
}
print '</tr></table>' ;
2006-09-03 15:57:19 +02:00
$dbosc -> close ();
2006-03-22 18:52:12 +01:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2006-03-22 18:52:12 +01:00
?>