magento site : www.1234.com
We have lot of Designers in site (Seller/ Vendor). we assigned each product to one Designer with help of attribute Designer ID
as below image under Catalog > Manage Products
section
We are using below code in www.1234.com/php/site6/padistatus.php to display form & saving form values in order_details
column. [ custom database ]
here once we select Designer from dropdown, than related Order numbers of that designer will display, after selecting order number
, it will display related Products Ids of that Order Number.
here for "Product ids" , we are saving values in "dproduct_id" column.
what we need is Previously selected & saved Product Ids should not display again in dropdown
example : here we already saved 15517 product Id in Database, so it should not display again in form. only 15515 product Id should display in dropdown.
full code : http://pastebin.com/PT6A0wrA
Edit
With help of below code , Previously saved product ids are not displaying per designer but i need solution for Previously saved product ids should not display for all designers.
assume In one order [ order id : 100000136 ] , 2 designers products will be sold [ ex : sudeep's product id : 15442 & Darshan product id : 152] , so that when we select Darshan in dropdown, only Darshan's product id 152 should display, but now product id 152 is displaying for both Sudeep & Darshan. same happening for Another product id also.
updated code :
<table>
<tr><td> Designer </td><td>
<select onchange="getOrderDetail(event);" name="designer_id" id="designer_id" >
<option value="">Select Designer</option>
<?php
while($data = $stmt->fetch())
{
if($data['type']=="admin")continue;
?>
<option value="<?php echo $data['userID'];?>">
<?php
echo $data['name'];
?>
</option>
<?php } ?>
</select>
</td><td><p id="error_para1" ></p></td></tr>
<tr><td>Order Number: </td><td>
<div id="ordernumbers">
<select name="designerorder_id" id="designerorder_id" class="designerorder_id" onchange='getProductDetail(this.value)'>
<option value="">Select Order</option>
</select>
</div>
</td><td><p id="error_para2" ></p></td></tr>
<tr><td>Product</td><td>
<div id="productnumbers" name="dproduct_id" id="dproduct_id" >
<select id="mySelect" >
<option>Select Products</option>
</select>
</div>
</td><td><p id="error_para3" ></p></td> </tr>
Designerpaidstatus.php
$htmltext='';
//$htmltext.="<select id='designerpaidstatus.php' name='designerorder_id' onchange='getProductDetail(this.value)' class='selectvalue'><option value=''>Select Order</option>";
$htmltext.="<option value=''>Select Order</option>";
$data=array();
foreach ($order as $orderData)
{
$sqlq1="select dproduct_id from order_details where designer_id='".$id."' and designerorder_id='".$orderData->getIncrementId()."'";
$sqlq=mysqli_query($conVar,$sqlq1);
while($rdata=mysqli_fetch_assoc($sqlq))
{
$data[]=$rdata['dproduct_id'];
}
$orderitems=$orderData['dproduct_id'];
$oitem=explode(',',$orderitems);
$finalValue=$orderData->getIncrementId()."-".$orderitemsarray[$k];
$result=array_diff($oitem,$data);
$result1=implode(',',$result);
if(count($result)>1){
$htmltext=$htmltext.'<option class="'.$result1.'" name="'.$result1.'" value="'.$orderData->getIncrementId().'">'. $orderData->getIncrementId().'</option>';
} }
$htmltext=$htmltext."</select>";
echo $htmltext;
exit;
script
function getOrderDetail(e)
{
var designerId=e.target.options[e.target.selectedIndex].value;
var url="http://sbdev2.kidsdial.com:81/php/site6/designerpaidstatus.php?designer_id="+designerId+"&opration=2";
var request = jQuery.ajax( {
url: url ,
type: 'POST',
} );
request.done( function (result)
{
//document.getElementById('ordernumbers').innerHTML =result;
$(".designerorder_id").html(result);
} );
request.fail( function ( error )
{
console.dir(error);
} );
}
function getProductDetail(e)
{
var productId = $(".designerorder_id option:selected").attr("class"); //$('option:selected', this).attr('class');
var finalstrig=productId.split(",");
var select='';
select+='<select class="test" multiple="multiple" name="dproduct_ids" id="dproduct_ids">';
for(i=0;i<finalstrig.length;i++)
{
if(finalstrig[i]!=0)
{
select +='<option value="'+finalstrig[i]+'">'+finalstrig[i]+'</option>';
}
}
select +='</select>';
document.getElementById('productnumbers').innerHTML =select;
(function($) {
$(function() {
$('.test').fSelect();
});
})(jQuery);
}
$(function(){
$("#button_reset").click(function() {
$("#productnumbers").html('<select id="mySelect"><option>Select Products</option></select>');
});
});
Edit 2
what below query do is
1.it first execute a like query with designer id and fetches all the orders :
$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id',array('like' => '%'.$id.'%'));
2. Iterates through the order and fetches all the product ids....
$sqlq1="select dproduct_id from order_details where designer_id='".$id."' and designerorder_id='".$orderData->getIncrementId()."'";
so when i execute any of below queries, there will be a common row and all the product id from that row will appear for all these designers.
when i ran below query in magento database, i got result as below image.
select * from sales_flat_order where designer_id like '%4%';
select * from sales_flat_order where designer_id like '%5%';
select * from sales_flat_order where designer_id like '%8%';
select * from sales_flat_order where designer_id like '%9%';
function getProductDetail(e)
.....Edit
part in question, we are using only those code i posted in question.....