Guest User

rela

a guest
Dec 12th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. function getDesignerCollection()
  2. {
  3. global $is_admin;
  4. $user_home = new USER();
  5. require_once '../../app/Mage.php';
  6.  
  7. Mage::app();
  8.  
  9. $stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
  10. $stmts->execute(array(
  11. ":uid" => $_SESSION['userSession']
  12. ));
  13. $rows = $stmts->fetch(PDO::FETCH_ASSOC);
  14.  
  15.  
  16.  
  17. $accountType = $rows['type'];
  18. if ($accountType == "admin")
  19. {
  20. $is_admin = true;
  21. $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
  22. 'nin' => '0'
  23. ));
  24. if ($orderFromDate != '') $order->addFieldToFilter('created_at', array(
  25. 'gteq' => $orderFromDate
  26. ));
  27. if ($orderToDate != '') $order->addFieldToFilter('created_at', array(
  28. 'lteq' => $orderToDate
  29. ));
  30. }
  31. else
  32. {
  33. $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
  34. 'like' => '%' . $_SESSION['userSession'] . '%'
  35. ));
  36. if ($orderFromDate != '') $order->addFieldToFilter('created_at', array(
  37. 'gteq' => $orderFromDate
  38. ));
  39. if ($orderToDate != '') $order->addFieldToFilter('created_at', array(
  40. 'lteq' => $orderToDate
  41. ));
  42. }
  43.  
  44. $i = 0;
  45.  
  46. foreach($order as $orderData)
  47. {
  48. $k = 0;
  49. $orderitems = $orderData['dproduct_id'];
  50. $orderitemsarray = explode(",", $orderitems);
  51.  
  52. $oDate = new DateTime($orderData['created_at']);
  53. $sDate = $oDate->format("M d, Y");
  54.  
  55. while ($k < count($orderitemsarray))
  56. {
  57.  
  58. if ($orderitemsarray[$k] != '0')
  59. {
  60. $stmtorders = $user_home->runQuery("SELECT * FROM order_details");
  61. $stmtorders->execute(array(":dorder_id" => $orderData['entity_id']));
  62. $roworders = $stmtorders->fetch(PDO::FETCH_ASSOC);
  63.  
  64.  
  65. if($data['type']=="admin")continue;
  66.  
  67. if($data['dpaid_status']=='P'){$dorderStatus='Paid';}
  68. if($data['dpaid_status']=='U'){$dorderStatus='Unpaid';}
  69. if($data['dpaid_status']=='R'){$dorderStatus='Returned';}
  70. if($data['dpaid_status']==''){$dpaid_status='';}
  71.  
  72. if ($roworders[
  73.  
  74. 'dproduct_id'] == '')
  75. {
  76. $dorderStatus = "Unpaid";
  77. }
  78. else
  79. {
  80. $dorderStatus = $roworders['dpaid_status'];
  81. }
  82.  
  83. if ($roworders['dproduct_id'] == '')
  84. {
  85. $commission = "comm";
  86. }
  87. else
  88. {
  89. $commission = $roworders['commission'];
  90. }
  91.  
  92. $productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
  93. $designer_id = $productdetail->getDesignerID() ;
  94.  
  95. if($accountType == "admin"){
  96. $designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
  97. $responce[] = array(
  98. $orderData->getIncrementId() ,
  99. $orderData->getIncrementId() ,
  100. $orderitemsarray[$k],
  101. $productdetail->getName() ,
  102. $designerName,
  103. $orderData['status'],
  104. $orderData['grand_total'],
  105. $orderData['customer_email'],
  106. $commission,
  107. $dorderStatus,
  108. $sDate
  109. );
  110.  
  111. }
  112.  
  113. else
  114. {
  115.  
  116. if( $designer_id== $_SESSION['userSession'] ){
  117. $designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
  118. $responce[] = array(
  119. $orderData->getIncrementId() ,
  120. $orderData->getIncrementId() ,
  121. $orderitemsarray[$k],
  122. $productdetail->getName() ,
  123. $designerName,
  124. $orderData['status'],
  125. $orderData['grand_total'],
  126. $orderData['customer_email'],
  127. $commission,
  128. $dorderStatus,
  129. $sDate
  130. );
  131. }
  132. }
  133. }
  134.  
  135. $k++;
  136. $i++;
  137. }
  138. }
  139.  
  140. echo json_encode($responce);
  141. }
Add Comment
Please, Sign In to add comment