Prev | Current Page 493 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

Include a reference to shopping_cart.php in admin.php:
// Load Business Tier
require_once BUSINESS_DIR . 'catalog.php';
require_once BUSINESS_DIR . 'shopping_cart.php';
5. Create a new presentation object file named presentation/admin_carts.php, and add the following
code to it:
// Class that supports cart admin functionality
class AdminCarts
{
// Public variables available in smarty template
public $mMessage;
public $mDaysOptions = array (0 => 'All shopping carts',
1 => 'One day old',
10 => 'Ten days old',
20 => 'Twenty days old',
30 => 'Thirty days old',
90 => 'Ninety days old');
public $mSelectedDaysNumber = 0;
public $mLinkToCartsAdmin;
// Private members
public $_mAction = '';
// Class constructor
public function __construct()
{
foreach ($_POST as $key => $value)
// If a submit button was clicked ...
if (substr($key, 0, 6) == 'submit')
{
// Get the scope of submit button
$this->_mAction = substr($key, strlen('submit_'), strlen($key));
// Get selected days number
if (isset ($_POST['days']))
$this->mSelectedDaysNumber = (int) $_POST['days'];
else
trigger_error('days value not set');
}
CHAPTER 12 ?–  CREATING YOUR OWN SHOPPING CART 395
$this->mLinkToCartsAdmin = Link::ToCartsAdmin();
}
public function init()
{
// If counting shopping carts ...
if ($this->_mAction == 'count')
{
$count_old_carts =
ShoppingCart::CountOldShoppingCarts($this->mSelectedDaysNumber);
if ($count_old_carts == 0)
$count_old_carts = 'no';
$this->mMessage = 'There are ' .


Pages:
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
House Extension Kąty Rybackie noclegi kasyno Kołobrzeg plecaki