<div class="main-content">
    <!-- orders section -->
    <div class="d-flex justify-content-between flex-wrap">
        <h3 class="fmon">Orders</h3>
        <div class="oCard fselect">
            <select class="form-select fInp bg-transparent">
                <option value="new order">new order</option>
            </select>
        </div>
    </div>
    <div class="my-2">
        <div class="row">
            <?php foreach($customerlist as $c=>$data){ 
              $patinetdata = $this->common->readdatadocument("Users", $data['patientID']);
                ?>
            <div class="col-md-4 my-2">
                <div class="card p-2 oCard">
                    <div class="m-2">
                        <div class="d-flex">
                        <?php if($patinetdata['image']==""){ ?>
                            <img src="<?php echo base_url('assets/images/avatars/04.png'); ?>" alt="" width="70">
                            <?php }else{ ?>
                                <img src="<?php echo $patinetdata['image'] ; ?>" alt="" width="70">   
                               <?php } ?> 
                            <div class="ms-2">
                                <p class="fmon fs5"><?php echo $patinetdata['firstName']." ".$patinetdata['lastName'];   ?></p>
                                <p class="text-muted fs6 fmon">Patient Id: <?php echo $data['patientID']; ?></p>
                            </div>
                        </div>
                        <div class="mt-3">
                            <div class="d-flex justify-content-between">
                                <p class="fmon fs7 m-0">Order Date</p>

                                <p class="fmon fs8 m-0"><?php echo convertTimeinMonth($data['date']); ?></p>
                            </div>
                            <div class="d-flex justify-content-between">
                                <p class="fmon fs7 m-0">Medicine</p>

                                <p class="fmon fs8 m-0">
                                    <?php if($data['status']!="pending"){
                                    //    echo "Medinde Name";
                                      //  var_dump($data['medicine']);
                                        $response=array();
                                        foreach($data['medicine'] as $key=>$v){
                                            array_push($response,$key);
                                        }
                                        $j=implode(",",$response);
                                        echo $j;

                                    } ?>

                                </p>
                            </div>
                            <div class="d-flex justify-content-between">
                                <p class="fmon fs7 m-0">Status</p>

                                <p class="fmon fs8 m-0"><?php echo $data['status'] ?></p>
                            </div>
                        </div>
                        <div class="mt-2 d-flex justify-content-end">
                        <?php if($data['status']=="pending"){?>    
                        <button class="btn crBtn px-4 myButton"  data-id="<?php echo $c; ?>" >
                                Create Order
                            </button>
                            <?php }else{ ?>
                                <button class="btn crBtn px-4 "  >
                                <?php echo $data['status']; ?> Order
                            </button>
                                
                                <?php } ?>    
                        </div>
                    </div>
                </div>
            </div>
            <?php } ?>

        </div>
    </div>
    <div>
        <!-- Modal -->
        <div class="modal" id="exampleModalToggle" aria-hidden="true" aria-labelledby="exampleModalToggleLabel"
            tabindex="-1">
            <div class="modal-dialog modal-dialog-centered modal-lg">
                <div class="modal-content rounded-0 bg-m">
                    <div class="p-2 d-flex justify-content-end">
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body pt-0">
                        <p class="text-center fpop fs10">Creat Order</p>
                        <div class="my-2 row">
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Full Name</label>
                                <input class="form-control rounded-0 mInp" type="text" id="fullname" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Email Address</label>
                                <input class="form-control rounded-0 mInp" id="email" type="email" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Phone Number</label>
                                <input class="form-control rounded-0 mInp" id="phoneNumber" type="text" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Address</label>
                                <input class="form-control rounded-0 mInp" id="address" type="text" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">City </label>
                                <input class="form-control rounded-0 mInp" id="city" type="text" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Post Code</label>
                                <input class="form-control rounded-0 mInp" id="PostCode" type="text" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Medicine Reciever</label>
                                <input class="form-control rounded-0 mInp" id="recivername" type="text" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Reciver Id</label>
                                <input class="form-control rounded-0 mInp" type="text" id="reciverId" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Commnet</label>
                                <input class="form-control rounded-0 mInp" name="comments" id="comments" required type="text" placeholder=" Password" />
                            </div>
                            <div class="col-md-6 my-2">
                                <label class="fmon fs9" for="fname">Select Doctor</label>
                                <div class="oCard fselect w-100">
                                    <select class="form-select fInp bg-transparent" name="doctorid" id="doctorid">
                                        <?php foreach($doctorlist as $d=>$j){?>
                                        <option value="<?php echo $d; ?>"><?php echo $j['firstName']." ".$j['lastName']; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>

                            </div>
                        </div>
                        <div class="col-md-12 my-2">
                            <div class="row">
                                <div class="col-md-11 my-1" id="InpCon">
                                    <div class="mInp d-flex justify-content-between my-1">
                                        <input type="text" name="medicineItem[]" id="medicineItem" class="border-0 bg-transparent p-2 pinp2"
                                            placeholder="Medicine" />
                                        <div class="d-flex align-items-center">
                                            <label for="check" class="fColorred">Monitered Medicine</label>
                                            <input type="checkbox" name="medicinechecked[]" id="medicinechecked" class="mx-2"
                                                style="accent-color: black" checked />
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-1 my-1">
                                    <button class="oCard btn aBtn" id="addBtn">
                                        <img src="<?php echo base_url('assets/images/megaIcons/addb.png'); ?>" alt=""
                                            width="20">

                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12 my-2 d-flex justify-content-center">
                            <button class="btn crBtn px-4 py-2 secondbutton" >
                                Create Now
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="exampleModalToggle2" aria-hidden="true" aria-labelledby="exampleModalToggleLabel2"
        tabindex="-1">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content bg-m rounded-0">
                <div class="modal-body">
                    <div class="my-2 d-flex justify-content-between">
                        <div class="d-flex">
                            <img id="text_patient_image" src="<?php echo base_url('assets/images/avatars/av4.png'); ?>" alt="image" width="150"
                                class="rounded-0" />

                            <div class="ms-2">
                                <p class="fmon fs11 mb-0" id="text_patient_name">Cameron Williamson</p>
                                <p class="fmon fs12 mb-0" id="text_patient_id">Patient Id:25dfs48</p>
                                <div class="d-flex">
                                    <img id="text_reciver_image" src="<?php echo base_url('assets/images/avatars/04.png'); ?>" alt="" width="50"
                                        height="50">

                                    <div class="mx-2">
                                        <p class="fmon fs8 m-0 m-0 text-start fw-bold" id="text_reciver">Davson</p>
                                        <p class="fmon fs13 m-0 text-start fw-bold">
                                            Mdicine Reciever
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                    </div>
                    <div class="my-2">
                        <div class="d-flex my-2">
                            <div class="oCard p-2 wFit iconbox">
                                <i class="fa-solid fa-location-dot colorIcon"></i>
                            </div>
                            <p class="ms-2 mb-0" id="text_address" >
                                30 Cutter Mill Road Great Neck, New York 11021
                            </p>
                        </div>
                        <div class="my-2">
                            <div class="d-flex">
                                <div class="d-flex my-2">
                                    <div class="oCard p-2 wFit iconbox">
                                        <i class="fa-solid fa-phone colorIcon"></i>
                                    </div>
                                    <p class="ms-2 mb-0" id="text_phone">516.773.2000</p>
                                </div>
                                <div class="d-flex my-2 ms-3">
                                    <div class="oCard p-2 wFit iconbox">
                                        <i class="fa-solid fa-envelope colorIcon"></i>
                                    </div>
                                    <p class="ms-2 mb-0" id="text_email">Davson458@info.com</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row my-2">
                        <p class="m-0 fw-bold">List of Medicines</p>
                        <div class="my-2 col-md-12" id="medicineDisplayContainer">
                            <!--
                            <div class="oCard d-flex justify-content-between align-items-center p-1">
                                <p class="m-0 fmon fs15">Panadol</p>
                                <button class="btn crBtn fs14 fmon">
                                    Monitered Medicine
                                </button>
                            </div>
                                        -->
                        
                        
                        </div>
                        <!--
                        <div class="my-2 col-md-12">
                            <div class="oCard d-flex justify-content-between align-items-center p-1">
                                <p class="m-0 fmon">Abacus</p>
                            </div>
                        </div>
                                        -->
                        <div class="my-2 col-md-12">
                            <label for="" class="fmon">Select Driver</label>
                            <div class="oCard d-flex align-items-center p-1">
                                <img src="<?php echo base_url('assets/images/avatars/02.png'); ?>" alt=""
                                    class="fimg d-none" />

                                <select name="driverId" id="driverid" class="form-select  bg-transparent fsl">
                                <?php foreach($driverlist as $d=>$j){?>
                                        <option value="<?php echo $d; ?>"><?php echo $j['firstName']." ".$j['lastName']; ?></option>
                                        <?php } ?>
                                </select>
                                <input type="hidden" id="orderid" value=""/>
                            </div>
                        </div>
                        <div class="my-2 col-md-12 d-flex justify-content-center">
                            <button class="btn crBtn" id="submitorder" >Submit Now</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
document.getElementById("addBtn").addEventListener("click", function() {
    var clone = document.querySelector("#InpCon .mInp").cloneNode(true);
    document.getElementById("InpCon").appendChild(clone);
});

</script>