we are displaying all the order related information in custom page : www.1234.com/php/site6/orders.php
if we login than we can see all orders. Here Order id, Prodcut Ids..etc are fetching from magento database.
but only Designer column is fething from custom database [ table : tbl_users
, column: name
]
There are 2 types of dashboard - admin & designer, if designer login than we want to hide column Designer
php
function getDesignerCollection()
$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt->execute(array(
":uid" => $designerId
));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
return $row['name'];
}
{
$accountType = $rows['type'];
if ($accountType == "admin")
{
$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
'nin' => '0'
));
}
else
{
$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
'like' => '%' . $_SESSION['userSession'] . '%'
));
}
$i = 0;
foreach($order as $orderData)
{
$orderitems = $orderData['dproduct_id'];
$orderitemsarray = explode(",", $orderitems);
$k = 0;
$oDate = new DateTime($orderData['created_at']);
$sDate = $oDate->format("Y-m-d");
while ($k < count($orderitemsarray))
{
if ($orderitemsarray[$k] != '0')
{
$stmtorders = $user_home->runQuery("SELECT * FROM order_details WHERE designerorder_id=:designerorder_id");
$stmtorders->execute(array(
":designerorder_id" => $orderData['entity_id']
));
$roworders = $stmtorders->fetch(PDO::FETCH_ASSOC);
$productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
$designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
$responce[] = array(
$orderData->getIncrementId() ,
$orderData->getIncrementId() ,
$orderitemsarray[$k],
$productdetail->getName() ,
$designerName,
$orderData['status'],
$orderData['grand_total'],
$orderData['customer_email'],
$commission,
$dorderStatus,
$sDate
);
}
$k++;
$i++;
}
}
echo json_encode($responce);
}
script
var dsOption= {
fields :[
{name : 'entity_id' },
{name : 'entity_id' },
{name : 'product_id' },
{name : 'product_name'},
{name : 'designer_id' },
{name : 'status' },
{name : 'grand_total' },
{name : 'customer_email' },
{name : 'commission' },
{name : 'paid_status' },
{name : 'created_at'},
],
recordType : 'array',
data : __TEST_DATA__
}
var colsOption = [
{id: 'entity_id' , header: "Order Id" , width :"15",renderer : my_renderId},
{id: 'created_at' , header: "Order Date" , width :"120"},
{id: 'entity_id' , header: "Order Id" , width :"75"},
{id: 'product_id' , header: "Product Id" , width :"70"},
{id: 'product_name' , header: "Product Name" , width :"200"},
{id: 'designer_id' , header: "Designer" , width :"110"},
{id: 'status' , header: "Order Status" , width :"100"},
{id: 'grand_total' , header: " Order Amount" , width :"120"},
{id: 'customer_email' , header: "User Email" , width :"150"},
{id: 'paid_status' , header: "Paid status" , width :"80"},
{id: 'commission' , header: "commission" , width :"80"}
];
If i remove below line from above script, than "Designer" column will hide in both admin & Designer dashboard.
{id: 'designer_id' , header: "Designer" , width :"110"},
$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array( 'like' => '%' . $_SESSION['userSession'] . '%' ));
, so i asked here, i will take your suggestion & try to ask in stackoverflow if the question is purely related to php....