টেবিলে অনেক গুলো রো থাকবে । সেখানে চেক আউট অপশন থাকবে । Multiple check option select korle supplier wage invoice create hobe and invoice products details thakbe
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr style="background-color: #23ab2d;color:white">
<th>
<label class="checkbox-inline"><input type="checkbox" value=""></label>
</th>
<th>Code</th>
<th>Item</th>
<th>Quantity</th>
<th>Supplier</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<?php
// print "<pre>";
// print_r($allsupplierproduct);
foreach($allsupplierproduct as $value){
$query= $this->db->query("SELECT * from supplier where id={$value->supplier_id}");
$result = $query->first_row();
// echo "<pre>";
// print_r($value);
?>
<tr class="gradeA">
<td>
<label class="checkbox-inline">
<input type="checkbox" name="supplierid[]"
value="<?php echo $result->id; ?>-<?php echo $value->id; ?>">
</label>
</td>
<td><?php echo $value->pro_code?></td>
<td>
<!-- <input step="any" type="number" name="quantity" id="quantity" /> -->
<div><?php echo $value->pro_s_name; ?></div>
<div>QTY:<?php echo $value->quantity; ?></div>
</td>
<td>
<input step="any" type="number" name="quantity<?php echo $value->id; ?>" id="quantity" />
<!-- <div><?php //echo $value->pro_s_name; ?></div>
<div>QTY:<?php //echo $value->quantity; ?></div> -->
</td>
<td><?php echo $result->contact_Name?></td>
<td class="center"><?php echo $value->Purchase_Price?>
<input type="hidden" name="uniteprice<?php echo $value->id; ?>"
value="<?php echo $value->Purchase_Price; ?>" id="quantity" />
</td>
</tr>
<?php }?>
</tbody>
</table>
//controller
function arrayChunkByKeyValue($data, $groupByKey)
{
$groupArray = [];
foreach ($data as $singleData) {
$groupArray[$singleData[$groupByKey]][] = $singleData;
}
return $groupArray;
}
function purchaseorderInsert(){
//if (!$this->session->userdata('AdminAccessMail')) redirect("administration");
$supplierid = $this->input->post('supplierid');
if($supplierid){
foreach($supplierid as $key=>$val){
$posts = [];
$explode[] = explode('-',$val);
foreach($explode as $k=>$v){
$sup = $v[0];
$pro = $v[1];
$qty = $this->input->post("quantity{$pro}");
$unPrice = $this->input->post("uniteprice{$pro}");
if(!empty( $qty)){
$posts[$k]['supplier'] = $sup;
$posts[$k]['product_id'] = $pro;
$posts[$k]['quantity'] = $qty;
$posts[$k]['uniteprice'] =$unPrice;
$posts[$k]['totalPrice'] = ($qty * $unPrice);
// echo "<pre>";
// print_r($posts);
// die;
// echo $posts;
}
}
}
$result = $this->arrayChunkByKeyValue($posts, 'supplier');
foreach($result as $key=>$val){
// $arraryPurchase = array('supplier_id' => $key);
$arraryPurchase['supplier_id']=$key;
$arraryPurchase['status']=1;
$arraryPurchase['customername']= $this->cname;
$this->db->insert('purchase_invoice', $arraryPurchase);
$lastid = $this->db->insert_id();
foreach($val as $k=>$v){
$sup = $v['supplier'];
$proid = $v['product_id'];
$qty = $v['quantity'];
$upric = $v['uniteprice'];
$arrayDtails = array('inv_id'=>$lastid,'product_id'=>$proid,'pro_unit_price'=>$upric,'supplier_id'=>$sup,'order_qty'=>$qty);
$this->db->insert('purchase_invoice_details', $arrayDtails);
}
}
$this->session->set_flashdata('successMsg', '<h2 class="alert alert-success">Successfully Send Products</h2>');
redirect('OrderController/purchaseorder', 'refresh');
}
}
Comments
Post a Comment