<?php 
if (!isset($_SESSION)){
  session_start();
}

require_once("Connections/courier.php");
$searchtext = mysql_real_escape_string(trim($_POST["searchtext_query_item_name"]));
$searcby=$_POST["searchby_administrative"];
$mode_of_payment = $_POST['mode_of_payment_all'];

$searchfacility=$_SESSION['provider_id'];
$servicetype='';
$servicetype=$servicetype."service='Administrative' or ";
$servicetype="and (".substr($servicetype,0,-4).") ";


if ($searchtext != "") {
    $queryItems = "SELECT * FROM service_items WHERE (item LIKE '%$searchtext%' OR ins_com_code = '$searchtext') ORDER BY item DESC limit 0,100";
//    $queryItems = "SELECT * FROM service_items WHERE provider_id='$searchfacility' and (item LIKE '%$searchtext%') ORDER BY item DESC limit 0,100";
    $resultItems = mysql_query($queryItems) or die(mysql_error());
    $arrayItems = mysql_fetch_assoc($resultItems);
    $totalRows = mysql_num_rows($resultItems);
}?>

<table class="table" id="myTable">
    <tr>
        <td>Item Name</td>
        <td>Price</td>
        <td>Qty</td>
        <td></td>
    </tr>
                         <?php if ($totalRows> 0) { ?>                    
                    	<tbody>
                                                    <?php
													$i = 0;
                                                    do {
                                                        $i = $i + 1;
                                                        ?>
            <tr id="abasa" style="cursor: pointer;" id="sell_tr" <?php if($arrayItems['quantity_available_'.$_SESSION['name_code']]>0 || $arrayItems["service_type"]=='Optical Lens' || $arrayItems['service_type']=='Optical Consultation'){ ?> <?php if($mode_of_payment == 'insurance' || $mode_of_payment == 'company' && ($arrayItems["service_type"]=='Optical Lens' || $arrayItems["service_type"]=='Optical Contact Lens' || $arrayItems["service_type"]=='Optical Frame')){ ?> onclick="getItemDetails('<?php echo $arrayItems["id"]; ?>','<?php echo strtoupper($arrayItems["item"]); ?>','<?php echo $arrayItems["price_".$_SESSION["name_code"]];?>','<?php echo $arrayItems["service_type"];?>')"; data-toggle="modal" href="#cash_top_up" <?php }else{ ?> onclick="searchItemsName('administrative_edit_claim_details_administrative','#view_items_response_wrapper_2','<?php echo $arrayItems["id"]; ?>','no_field');" <?php } }else{ ?> onclick="swal('Out of Stock','This Item is Out of Stock at the Moment.','error')" <?php } ?>>


                <td valign="top">
                    <textarea readonly="readonly" cols="20" type="text" name="focusTextarea" id="focusTextarea" style="border: none; resize: none;"><?php echo strtoupper($arrayItems["item"]); ?></textarea>

                    </td>
                                                            <td valign="top"> <?php 
										// if($mode_of_payment=='insurance'){
										// 	echo $arrayItems["price_insurance"];
										// }
										// if($mode_of_payment=='company'){
										// 	echo $arrayItems["price_company"];
										// }
										// if($mode_of_payment=='cash'){ 
											echo $arrayItems['price_'.$_SESSION['name_code']];
										// }
										// if($mode_of_payment=='staff'){ 
										//   echo strtoupper($arrayItems["price_staff"]);
                                        // } 
                                        ?> 
                                                            </td>
                                                            <td valign="top"><?php echo strtoupper($arrayItems['quantity_available_'.$_SESSION['name_code']]); ?></td>
                                                            <td valign="top"  style="text-align:center"> <i id="plus_<?php echo $arrayItems["id"]; ?>" class="icon-plus" style="color:#000;"></i> <i style="display: none;" id="spin_refresh_plus_<?php echo $arrayItems['id']; ?>" class="fa fa-refresh fa-spin fa-fw"></i> </td>
                         </tr>
                                            <?php } while ($arrayItems = mysql_fetch_assoc($resultItems)); ?>
                                                        </tbody>
                 </table>
				 <?php }else{echo '<tr><td colspan="3"><div class="none">Sorry, No Item Found</div></td></tr></table>';}?>
                 

         
        

