PageRenderTime 36ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/new88li/core/admin/controller/sale/ctl.salescount.php

http://phpfor.googlecode.com/
PHP | 172 lines | 162 code | 8 blank | 2 comment | 21 complexity | 019ec204c14b7eaa0c0d015233c249ff MD5 | raw file
  1. <?php
  2. include_once('objectPage.php');
  3. class ctl_salescount extends adminPage{
  4. var $workground ='analytics';
  5. function index(){
  6. $sales = &$this->system->loadModel('utility/salescount');
  7. //$this->pagedata['year']=date("Y");
  8. //$this->pagedata['month']=date("m");
  9. $value_year=date("Y")-2000;
  10. $value_month=date("m");
  11. if($_GET['search_year']){
  12. $_GET['search_year']=intval($_GET['search_year']);
  13. $_GET['search_month']=intval($_GET['search_month']);
  14. $value_year=$_GET['search_year'];
  15. $value_month=$_GET['search_month'];
  16. $month_st=$_GET['search_year'].'-01-01';
  17. $month_en=$_GET['search_year'].'-12-01';
  18. $day_st=$_GET['search_year'].'-'.($_GET['search_month']+1).'-01';
  19. $day_en=date("Y-m-01",strtotime("+1 month",strtotime($day_st)));
  20. }else{
  21. $month_st=date("Y-01-01");
  22. $month_en=date("Y-12-01");
  23. $day_st=date("Y-m-01");
  24. $day_en=date("Y-m-01",strtotime("+1 month",strtotime($day_st)));
  25. }
  26. $d_year=array();
  27. for($i=2000;$i<=date("Y");$i++){
  28. array_push($d_year,$i);
  29. }
  30. $d_month=array();
  31. for($i=1;$i<=12;$i++){
  32. array_push($d_month,$i);
  33. }
  34. $month_search=$sales->mdl_dosearch($month_st,$month_en,"","","month");
  35. $day_search=$sales->mdl_dosearch($day_st,$day_en,"","","day");
  36. $this->pagedata['day']=$day_search;
  37. $this->pagedata['month']=$month_search;
  38. $this->pagedata['d_year']=$d_year;
  39. $this->pagedata['d_month']=$d_month;
  40. $this->pagedata['value_month']=$value_month;
  41. $this->pagedata['value_year']=$value_year;
  42. $this->page('sale/count/salescount.html');
  43. }
  44. function countall(){
  45. if($_GET['ordertype'] && $_GET['method']){
  46. $order['order']=intval($_GET['ordertype']);
  47. $order['method']=intval($_GET['method']);
  48. }
  49. if($_GET['dosearch']){
  50. $dateFrom=strtotime($_GET['searchfrom']);
  51. $dateTo=strtotime($_GET['searchto']);
  52. $search=$_GET['dosearch'];
  53. $item=$_GET['searchitem'];
  54. $sales=&$this->system->loadModel('utility/salescount');
  55. $result=$sales->count_all($dateFrom,$dateTo,$item,$search,$order);
  56. $this->pagedata['plug']='&dosearch='.$_GET['dosearch'].'&searchitem='.$_GET['searchitem'].'&searchfrom='.$_GET['searchfrom'].'&searchto='.$_GET['searchto'];
  57. }else {
  58. $dateFrom=strtotime(date("Y").'-01-01');
  59. $dateTo=strtotime("+1 year",$dateFrom);
  60. $sales=&$this->system->loadModel('utility/salescount');
  61. $result=$sales->count_all($dateFrom,$dateTo,'','',$order);
  62. }
  63. if($_GET['genexml']==1){
  64. $dataio = $this->system->loadModel('system/dataio');
  65. $io="xls";
  66. $name=array('????','???','???');
  67. $dataio->export_begin("xls",$name,'?????(?)',count($result));
  68. $dataio->export_rows($io,$result);
  69. $dataio->export_finish('xls');
  70. exit();
  71. }
  72. $this->pagedata['data']=$result;
  73. $this->pagedata['method']=$_GET['method'];
  74. $this->page('sale/count/salescountall.html');
  75. }
  76. function do_search(){
  77. $sales = &$this->system->loadModel('utility/salescount');
  78. $results=$sales->mdl_dosearch($_POST['dateFrom'],$_POST['dateTo'],$_POST['dateCompareFrom'],$_POST['dateCompareTo'],$_POST['ptype']);
  79. echo $results;
  80. }
  81. function membercount(){
  82. if($_GET['ordertype'] && $_GET['method'] ){
  83. $order['order']=intval($_GET['ordertype']);
  84. $order['method']=intval($_GET['method']);
  85. }
  86. if($_GET['searchfrom'] && $_GET['searchto']){
  87. $dateFrom=strtotime($_GET['searchfrom']);
  88. $dateTo=strtotime($_GET['searchto']);
  89. $memberinfo=&$this->system->loadModel('utility/salescount');
  90. $result=$memberinfo->member_count($dateFrom,$dateTo,$order);
  91. }else{
  92. $dateFrom=strtotime(date("Y").'-01-01');
  93. $dateTo=strtotime("+1 year",$dateFrom);
  94. $memberinfo=&$this->system->loadModel('utility/salescount');
  95. $result=$memberinfo->member_count($dateFrom,$dateTo,$order);
  96. }
  97. if($_GET['genexml']==1){
  98. $addons = &$this->system->loadModel('system/addons');
  99. $io= $addons->load('xls','io');
  100. $name=array(__('???'),__('??'),__('???'),__('???'));
  101. $io->export_begin($name,__("?????(?)"),count($name));
  102. $io->export_rows($result);
  103. $io->export_finish();
  104. return;
  105. }
  106. $this->pagedata['data']=$result;
  107. $this->pagedata['method']=$_GET['method'];
  108. $this->page('sale/count/membercount.html');
  109. }
  110. function salesguide(){
  111. if($_GET['searchfrom'] && $_GET['searchto']){
  112. $dateFrom=strtotime($_GET['searchfrom']);
  113. $dateTo=strtotime($_GET['searchto']);
  114. $vcompare=&$this->system->loadModel('utility/salescount');
  115. $result['ordersales']=$vcompare->average_order_sales($dateFrom,$dateTo);
  116. $result['ordermember']=$vcompare->have_order_member($dateFrom,$dateTo);
  117. $result['allmember']=$vcompare->all_member();
  118. $result['visit']=$vcompare->count_all_visite($dateFrom,$dateTo);
  119. }else{
  120. $dateFrom=strtotime(date("Y").'-01-01');
  121. $dateTo=strtotime("+1 year",$dateFrom);
  122. $vcompare=&$this->system->loadModel('utility/salescount');
  123. $result['ordersales']=$vcompare->average_order_sales($dateFrom,$dateTo);
  124. $result['ordermember']=$vcompare->have_order_member($dateFrom,$dateTo);
  125. $result['allmember']=$vcompare->all_member();
  126. $result['visit']=$vcompare->count_all_visite($dateFrom,$dateTo);
  127. }
  128. $this->pagedata['data']=$result;
  129. $this->pagedata['method']=$_GET['method'];
  130. $this->page('sale/count/salesguide.html');
  131. }
  132. function visitsalecompare(){
  133. if($_GET['ordertype'] && $_GET['method'] ){
  134. $order['order']=intval($_GET['ordertype']);
  135. $order['method']=intval($_GET['method']);
  136. }
  137. if($_GET['searchfrom'] && $_GET['searchto']){
  138. $dateFrom=strtotime($_GET['searchfrom']);
  139. $dateTo=strtotime($_GET['searchto']);
  140. }else{
  141. $dateFrom=strtotime(date("Y").'-01-01');
  142. $dateTo=strtotime("+1 year",$dateFrom);
  143. }
  144. $this->pagedata['dateFrom'] = $dateFrom;
  145. $this->pagedata['dateTo'] = $dateTo;
  146. $this->pagedata['ship_status'] = 0;
  147. if($_GET['bn']) $this->pagedata['bn'] = $bn = $_GET['bn'];
  148. if(!empty($_GET['ship_status'])) $this->pagedata['ship_status'] = $ship_status = $_GET['ship_status'];
  149. $vcompare=&$this->system->loadModel('utility/salescount');
  150. $result=$vcompare->visit_sale_compare($dateFrom,$dateTo,$order, $bn, $ship_status);
  151. if($_GET['genexml']==1){
  152. $addons = &$this->system->loadModel('system/addons');
  153. $io= $addons->load('xls','io');
  154. $name=array(__('????'),__('????'),__('????'));
  155. $io->export_begin($name,__("????????"),count($name));
  156. $io->export_rows($result);
  157. return;
  158. }
  159. $this->pagedata['method']=$_GET['method'];
  160. $this->pagedata['data']=$result;
  161. $this->page('sale/count/visitsalecompare.html');
  162. }
  163. }
  164. ?>