'pages', 'action' => 'display', 'slug'=>'home')); # check for custom homepage on app/config/homepage.txt # if not, default to pages/display/home $app_homepage = cms_get_homepage_route(); $app_homepage = isset($app_homepage['controller']) ? $app_homepage : array('controller'=>'pages', 'action'=>'display', 'slug'=>'home'); Router::connect('/', $app_homepage); # index redirects Router::connect('/admin', array('controller' => 'index', 'action'=>'adminredirect')); //Router::connect('/events', array('controller' => 'events', 'action'=>'index')); //Router::connect('/store', array('controller' => 'products', 'action'=>'index')); //Router::connect('/listings', array('controller' => 'listings', 'action'=>'index')); # routing for the rest of content (the trailing * will make named parameters work) # these words are also listed on page model's beforeSave to make sure it doesn't get used as slug Router::connect('/pages/:slug/*', array('controller' => 'pages', 'action'=>'display')); Router::connect('/albums/:slug/*', array('controller' => 'albums', 'action'=>'display')); Router::connect('/forms/:slug/*', array('controller' => 'forms', 'action'=>'display')); Router::connect('/files/:slug/*', array('controller' => 'uploads', 'action'=>'display')); Router::connect('/events/:slug/*', array('controller' => 'events', 'action'=>'display')); Router::connect('/store/:action/*', array('controller' => 'products')); Router::connect('/teststore/:action/*', array('controller' => 'teststore')); Router::connect('/listings/:action/*', array('controller' => 'listings')); //Router::connect('/blogs/*', array('controller'=>'blogs', 'action'=>'display')); Router::connect('/blogs/:blog_slug', array('controller'=>'blogs', 'action'=>'home')); Router::connect('/blogs/:blog_slug/index/*', array('controller'=>'blogs', 'action'=>'home')); Router::connect('/blogs/:blog_slug/feed', array('controller'=>'blogs', 'action'=>'feed')); Router::connect('/blogs/:blog_slug/:post_slug/*', array('controller'=>'blogs', 'action'=>'display_post')); # basic routing for pages Router::connect('/:slug', array('controller' =>'pages', 'action'=>'display'));loadModel('Customer'); $graph = $this->getParam('url.graph') ? $this->getParam('url.graph') : 'month'; $year = $this->getParam('url.year') ? $this->getParam('url.year') : date('Y'); $month = $this->getParam('url.month') ? $this->getParam('url.month') : intval(date('n')); $this->set('graph', $graph); if($graph=='month') { $current_period = strtotime("{$year}-{$month}-1"); # days of month $month_days = intval(date('t', $current_period)); # days elapsed if we are in the current month (eg. 15); otherwise same as month_days $current_month_days = intval(date('t', $current_period)); $graph_title = date('F Y', $current_period); $current_year = date('Y'); $current_month = intval(date('n')); if($current_year==$year && $current_month==$month) { $current_day = intval(date('j')); # set current day to yesterday, except if day is 1 $current_month_days = ($current_day > 1) ? $current_day-1 : 1; } $orders = $this->Customer->Order->find('all', array( 'fields'=> array('grandtotal', 'completed'), 'conditions'=> array( 'completed >=' => "{$year}-{$month}-1 00:00:00", 'completed <=' => "{$year}-{$month}-{$current_month_days} 23:59:59" ), 'order'=> 'completed asc', 'recursive'=> -1 )); //debug($orders);die; # build daily array $daily = array(); foreach(range(1,$current_month_days) as $i) { $daily[$i]['orders'] = 0; $daily[$i]['total'] = 0; } # assume that all items are in the same month # fill up daily and weekly array $total_sales = 0; $total_orders = 0; $average_sale = 0; foreach($orders as $i) { $order_date = strtotime($i['Order']['completed']); $order_day = date('j', $order_date); $order_total = $i['Order']['grandtotal']; $daily[$order_day]['orders']++; $daily[$order_day]['total'] = $daily[$order_day]['total'] + $order_total; $total_orders++; $total_sales = $total_sales + $order_total; } # format to money foreach($daily as $k=>$v) { $daily[$k]['total'] = Util::intToMoney($daily[$k]['total'], 2, ''); } $average_sale = ($total_orders<=0) ? 0 : Util::intToMoney($total_sales/$total_orders, 2); $total_sales = Util::intToMoney($total_sales, 2); # build graph data $daily_index = array(); $daily_ticks = array(); $daily_sales_total = array(); $daily_orders_total = array(); $min_sales_total = false; $max_sales_total = false; $min_orders_total = false; $max_orders_total = false; foreach($daily as $k=>$v) { $day = date('D', strtotime("{$year}-{$month}-{$k}")); $daily_sales_total[] = array($k, floatval($v['total'])); $daily_orders_total[] = array($k, intval($v['orders'])); $daily_index[$k] = array( 'orders'=> $v['orders'], 'total'=> number_format($v['total'], 2, '.', ','), 'date'=> date('m/d/y', strtotime("{$year}-{$month}-{$k}")), 'day'=> $day ); $daily_ticks[] = ($day=='Mon') ? array($k, "{$k}") : array($k, "{$k}"); } # create numeric array for sorting daily $daily_sorted = array(); foreach($daily as $i) { $daily_sorted[] = array('orders'=>$i['orders'], 'total'=>floatval($i['total'])); } $daily_sorted = Set::sort($daily_sorted, '{n}.total', 'asc'); $min_sales_total = floor($daily_sorted[0]['total']); $max_sales_total = ceil($daily_sorted[count($daily_sorted)-1]['total']); $daily_sorted = Set::sort($daily_sorted, '{n}.orders', 'asc'); $min_orders_total = floor($daily_sorted[0]['orders']); $max_orders_total = ceil($daily_sorted[count($daily_sorted)-1]['orders']); $this->set('daily_sales_total', $daily_sales_total); $this->set('daily_orders_total', $daily_orders_total); $this->set('daily_index', $daily_index); $this->set('daily_ticks', $daily_ticks); $graph_data = array( 'year'=> $year, 'month'=> $month, 'month_days'=> $month_days, 'current_period'=> $current_period, 'graph_title'=> $graph_title, 'min_sales_total'=> $min_sales_total, 'max_sales_total'=> $max_sales_total, 'min_orders_total'=> $min_orders_total, 'max_orders_total'=> $max_orders_total, 'total_sales'=> $total_sales, 'average_sale'=> $average_sale ); $this->set('graph_data', $graph_data); # end graph data # start weekly stuff # TODO: if in current month, average won't be accurate because times will include future dates # build weekly array $weekly = array(); foreach(range(1,7) as $i) { $weekly[$i]['orders'] = 0; $weekly[$i]['total'] = 0; $weekly[$i]['times'] = 0; } foreach($orders as $i) { $order_date = strtotime($i['Order']['completed']); $order_weekday = date('w', $order_date); # convert sunday(0) to 7 $order_weekday = ($order_weekday==0) ? 7 : $order_weekday; $order_total = $i['Order']['grandtotal']; $weekly[$order_weekday]['orders']++; $weekly[$order_weekday]['total'] = $weekly[$order_weekday]['total'] + $order_total; } # add times to weekly foreach($daily as $k=>$v) { $weekday = date('w', strtotime("{$year}-{$month}-{$k}")); $weekday = ($weekday==0) ? 7 : $weekday; $weekly[$weekday]['times']++; } $weekly_index = array(); $weekly_sales_total = array(); $weekly_orders_total = array(); foreach($weekly as $k=>$v) { $days = array(1=>'Monday', 2=>'Tuesday', 3=>'Wednesday', 4=>'Thursday', 5=>'Friday', 6=>'Saturday', 7=>'Sunday'); $average_total = $v['times'] ? round($v['total']/$v['times']) : 0; $average_orders = $v['times'] ? round($v['orders']/$v['times'], 1) : 0; $weekly_index[$k] = array( 'total'=> Util::intToMoney($average_total, 2,','), 'orders'=> $average_orders, 'day'=> $days[$k], 'times'=> $v['times'] ); $weekly_sales_total[] = array($k, floatval(Util::intToMoney($average_total,2,''))); $weekly_orders_total[] = array($k, $average_orders); } $this->set('weekly_sales_total', $weekly_sales_total); $this->set('weekly_orders_total', $weekly_orders_total); $this->set('weekly_index', $weekly_index); # end weekly stuff $latest_orders = $this->Customer->Order->find('all', array( 'fields'=> array('id', 'transaction_id', 'customer_name', 'grandtotal', 'completed'), 'limit'=> 20, 'order'=> 'completed desc', 'contain'=> array() )); $this->set('latest_orders', $latest_orders); $best_selling = $this->Customer->Order->Lineitem->find('all', array( 'fields'=> array('id', 'product_name', 'product_id', 'price', 'count(*) as count'), 'conditions'=> array( 'created >=' => "{$year}-{$month}-1 00:00:00", 'created <=' => "{$year}-{$month}-{$month_days} 23:59:59" ), 'group'=> array('product_id'), 'order'=> 'count desc', 'limit'=> 10, 'recursive'=> -1 )); $this->set('best_selling', $best_selling); } // if period==month # yearly graph if($graph=='year') { $current_period = strtotime("{$year}-01-01"); $graph_title = date('Y', $current_period); $next_year = $year+1; $next_year = "{$next_year}"; $orders = $this->Customer->Order->find('all', array( 'fields'=> array('grandtotal', 'completed'), 'conditions'=> array( 'completed >=' => $year, 'completed <' => $next_year, ), 'order'=> 'completed asc', )); //debug($orders);die; # build daily array $daily = array(); foreach(range(1,12) as $i) { $daily[$i]['orders'] = 0; $daily[$i]['total'] = 0; } # assume that all items are in the same month # fill up daily and weekly array $total_sales = 0; $total_orders = 0; $average_sale = 0; foreach($orders as $i) { $order_date = strtotime($i['Order']['completed']); $order_month = date('n', $order_date); $order_total = $i['Order']['grandtotal']; $daily[$order_month]['orders']++; $daily[$order_month]['total'] = $daily[$order_month]['total'] + $order_total; $total_orders++; $total_sales = $total_sales + $order_total; } # format to money foreach($daily as $k=>$v) { $daily[$k]['total'] = Util::intToMoney($daily[$k]['total'], 2, ''); } $average_sale = ($total_orders<=0) ? 0 : Util::intToMoney($total_sales/$total_orders, 2); $total_sales = Util::intToMoney($total_sales, 2); # build graph data $daily_index = array(); $daily_ticks = array(); $daily_sales_total = array(); $daily_orders_total = array(); $min_sales_total = false; $max_sales_total = false; $min_orders_total = false; $max_orders_total = false; foreach($daily as $k=>$v) { //$day = date('D', strtotime("{$year}-{$month}-{$k}")); $daily_sales_total[] = array($k, floatval($v['total'])); $daily_orders_total[] = array($k, intval($v['orders'])); # use date as month, day as year, since this is yearly $daily_index[$k] = array( 'orders'=> $v['orders'], 'total'=> number_format($v['total'], 2, '.', ','), 'date'=> date('F', strtotime("{$year}-{$k}-01")), 'day'=> date('Y', strtotime("{$year}-{$k}-01")), ); $daily_ticks[] = array($k, strtoupper(date('M', strtotime("{$year}-{$k}-01"))) ); } # create numeric array for sorting daily $daily_sorted = array(); foreach($daily as $i) { $daily_sorted[] = array('orders'=>$i['orders'], 'total'=>floatval($i['total'])); } $daily_sorted = Set::sort($daily_sorted, '{n}.total', 'asc'); $min_sales_total = floor($daily_sorted[0]['total']); $max_sales_total = ceil($daily_sorted[count($daily_sorted)-1]['total']); $daily_sorted = Set::sort($daily_sorted, '{n}.orders', 'asc'); $min_orders_total = floor($daily_sorted[0]['orders']); $max_orders_total = ceil($daily_sorted[count($daily_sorted)-1]['orders']); $this->set('daily_sales_total', $daily_sales_total); $this->set('daily_orders_total', $daily_orders_total); $this->set('daily_index', $daily_index); $this->set('daily_ticks', $daily_ticks); $graph_data = array( 'year'=> $year, 'month'=> $month, 'month_days'=> 12, 'current_period'=> $current_period, 'graph_title'=> $graph_title, 'min_sales_total'=> $min_sales_total, 'max_sales_total'=> $max_sales_total, 'min_orders_total'=> $min_orders_total, 'max_orders_total'=> $max_orders_total, 'total_sales'=> $total_sales, 'average_sale'=> $average_sale ); $this->set('graph_data', $graph_data); # end graph data # start weekly stuff # TODO: if in current month, average won't be accurate because times will include future dates # build weekly array $weekly = array(); foreach(range(1,7) as $i) { $weekly[$i]['orders'] = 0; $weekly[$i]['total'] = 0; $weekly[$i]['times'] = 0; } foreach($orders as $i) { $order_date = strtotime($i['Order']['completed']); $order_weekday = date('w', $order_date); # convert sunday(0) to 7 $order_weekday = ($order_weekday==0) ? 7 : $order_weekday; $order_total = $i['Order']['grandtotal']; $weekly[$order_weekday]['orders']++; $weekly[$order_weekday]['total'] = $weekly[$order_weekday]['total'] + $order_total; } # add times to weekly foreach($daily as $k=>$v) { $weekday = date('w', strtotime("{$year}-{$month}-{$k}")); $weekday = ($weekday==0) ? 7 : $weekday; $weekly[$weekday]['times']++; } $weekly_index = array(); $weekly_sales_total = array(); $weekly_orders_total = array(); foreach($weekly as $k=>$v) { $days = array(1=>'Monday', 2=>'Tuesday', 3=>'Wednesday', 4=>'Thursday', 5=>'Friday', 6=>'Saturday', 7=>'Sunday'); $average_total = $v['times'] ? round($v['total']/$v['times']) : 0; $average_orders = $v['times'] ? round($v['orders']/$v['times'], 1) : 0; $weekly_index[$k] = array( 'total'=> Util::intToMoney($average_total, 2,','), 'orders'=> $average_orders, 'day'=> $days[$k], 'times'=> $v['times'] ); $weekly_sales_total[] = array($k, floatval(Util::intToMoney($average_total,2,''))); $weekly_orders_total[] = array($k, $average_orders); } $this->set('weekly_sales_total', $weekly_sales_total); $this->set('weekly_orders_total', $weekly_orders_total); $this->set('weekly_index', $weekly_index); # end weekly stuff $latest_orders = $this->Customer->Order->find('all', array( 'fields'=> array('id', 'transaction_id', 'customer_name', 'grandtotal', 'completed'), 'limit'=> 20, 'order'=> 'completed desc', 'contain'=> array() )); $this->set('latest_orders', $latest_orders); $best_selling = $this->Customer->Order->Lineitem->find('all', array( 'fields'=> array('id', 'product_name', 'product_id', 'price', 'sum(qty) as count'), 'conditions'=> array( 'created >=' => $year, 'created <' => $next_year ), 'group'=> array('product_id'), 'order'=> 'count desc', 'limit'=> 10, )); $this->set('best_selling', $best_selling); } // if period==year } function admin_tools() { $this->Breadcrumbs->set('Store', 'Tools'); } function admin_generate_random_data() { die; $this->Order = ClassRegistry::init('Order'); $month = "06"; foreach(range(1,14) as $day) { $total_orders = rand(5, 7); if($total_orders) foreach(range(1, $total_orders) as $order_i) { $totalprice = rand(25000, 40000); $this->Order->create(); $this->Order->save(array( 'transaction_id'=> '2147483647', 'grandtotal'=> $totalprice, 'created'=> "2009-{$month}-{$day} 08:00:00", 'modified'=> "2009-{$month}-{$day} 08:00:00", 'completed'=> "2009-{$month}-{$day} 08:00:00", 'year'=> '2009', 'month'=> $month, 'day'=> $day )); print "2009-{$month}-{$day} 08:00:00 : {$totalprice}
"; } print "
"; } exit; } } "mysql", "persistent" => false, "host" => "localhost", "login" => "promptings_user", "password" => "Pathfinders27", "database" => "promptings", "mysql_path" => "", "prefix" => "" ); }
Warning (2): get_object_vars() expects parameter 1 to be object, null given [CORE/cake/libs/model/connection_manager.php, line 197]
<? if(isset($page_title)) {print h($page_title. " | ");} else {print "";} print h($website_title); ?> element('default_head') ?>
image('book.png', array('url'=>'/store')) ?>
image('buyNow.gif', array('url'=>'http://www.eagleonepublishing.com')) ?>
link($html->image('peekInside.gif'), '/uploads/files/2_Promptings_peek_inside_new.pdf', array('target' => '_blank'), null, false)?>
image('videoChat.gif', array('url'=>'/video-chat')) ?>
element('default_nav') ?>
element('default_subnav') ?>

Missing Database Connection

Error: ConnectionManager requires a database connection

Error: Confirm you have created the file : app/config/database.php.

Notice: If you want to customize this error message, create app/views/errors/missing_connection.ctp.

element('default_footer') ?> element('default_analytics') ?>